@univerjs/core 0.2.4-alpha.0 → 0.2.5

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,11 +1,11 @@
1
- "use strict";var La=Object.defineProperty;var xa=(e,n,t)=>n in e?La(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var _=(e,n,t)=>xa(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("rxjs"),Cn=require("rxjs/operators"),Pe=require("react");function Pa(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}function ka(e,n){for(var t=0;t<n.length;t++){const r=n[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const st=Pa(Pe);function Fa(){Ha()}const gn=typeof global<"u"?global:typeof self<"u"?self:window;function Ha(){typeof gn.requestIdleCallback!="function"&&(gn.requestIdleCallback=function(t){const r=Date.now();return setTimeout(function(){const o=Math.max(0,50-(Date.now()-r));t({didTimeout:o===0,timeRemaining(){return o}})},1)}),typeof gn.cancelIdleCallback!="function"&&(gn.cancelIdleCallback=function(t){clearTimeout(t)})}const $a="__default_document_sub_component_id20231101__",Qt=2,xs=1;function ja(e,n){if(n==null||e==null)return!0;const{left:t=0,top:r=0,height:s=0,width:o=0,angle:i=0}=n,{left:a=0,top:l=0,height:h=0,width:c=0,angle:u=0}=e,d=c,f=h,p=o,m=s;return Math.abs(a-t)>Qt||Math.abs(l-r)>Qt||Math.abs(d-p)>Qt||Math.abs(f-m)>Qt||Math.abs(u-i)>xs}function Ps(e,n){let t=0,r=e.length-1;for(;t<=r;){const s=Math.floor((r+t)/2);if(n<e[s]&&(s===0||n>=e[s-1]))return s;if(n>=e[s])t=s+1;else if(n<e[s])r=s-1;else return-1}return-1}function ks(e,n){let t=0,r=0,s=0,o=-1,i=e.length-1;for(;t<e.length&&i>=0&&i>=t;){if(r=e[i],i===0?s=0:s=e[i-1],n>=s&&n<=r){o=i;break}if(r=e[t],t===0?s=0:s=e[t-1],n>=s&&n<r){o=t;break}t++,i--}return o}function Wa(e,n){let t=e.length-1;return n<0?-1:n<e[0]?0:n>e[e.length-1]?Number.POSITIVE_INFINITY:(e.length<40||n<=e[20]||n>=e[t-20]?t=ks(e,n):t=Ps(e,n),t)}function Ba(e){const n=new Blob([e],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Fs=(e=>(e[e.DEFAULT_SERIES=0]="DEFAULT_SERIES",e[e.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",e))(Fs||{}),he=(e=>(e[e.NONE=0]="NONE",e[e.THIN=1]="THIN",e[e.HAIR=2]="HAIR",e[e.DOTTED=3]="DOTTED",e[e.DASHED=4]="DASHED",e[e.DASH_DOT=5]="DASH_DOT",e[e.DASH_DOT_DOT=6]="DASH_DOT_DOT",e[e.DOUBLE=7]="DOUBLE",e[e.MEDIUM=8]="MEDIUM",e[e.MEDIUM_DASHED=9]="MEDIUM_DASHED",e[e.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",e[e.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",e[e.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",e[e.THICK=13]="THICK",e))(he||{}),Hs=(e=>(e.TOP="top",e.BOTTOM="bottom",e.LEFT="left",e.RIGHT="right",e.NONE="none",e.ALL="all",e.OUTSIDE="outside",e.INSIDE="inside",e.HORIZONTAL="horizontal",e.VERTICAL="vertical",e.TLBR="tlbr",e.TLBC_TLMR="tlbc_tlmr",e.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",e.BLTR="bl_tr",e.MLTR_BCTR="mltr_bctr",e))(Hs||{}),qe=(e=>(e[e.UNSUPPORTED=0]="UNSUPPORTED",e[e.RGB=1]="RGB",e[e.HEX=2]="HEX",e[e.THEME=3]="THEME",e))(qe||{}),$s=(e=>(e[e.ON=0]="ON",e[e.OFF=1]="OFF",e))($s||{}),js=(e=>(e[e.PASTE_NORMAL=0]="PASTE_NORMAL",e[e.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",e[e.PASTE_FORMAT=2]="PASTE_FORMAT",e[e.PASTE_FORMULA=3]="PASTE_FORMULA",e[e.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",e[e.PASTE_VALUES=5]="PASTE_VALUES",e[e.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",e[e.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",e))(js||{}),Ws=(e=>(e[e.DOCUMENT=0]="DOCUMENT",e[e.PROJECT=1]="PROJECT",e))(Ws||{}),Bs=(e=>(e[e.COLUMNS=0]="COLUMNS",e[e.ROWS=1]="ROWS",e))(Bs||{}),Gs=(e=>(e[e.UP=0]="UP",e[e.RIGHT=1]="RIGHT",e[e.DOWN=2]="DOWN",e[e.LEFT=3]="LEFT",e))(Gs||{});function Ga(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var Vs=(e=>(e[e.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",e[e.TEXT=1]="TEXT",e[e.NUMBER=2]="NUMBER",e[e.PERCENT=3]="PERCENT",e[e.CURRENCY=4]="CURRENCY",e[e.DATE=5]="DATE",e[e.TIME=6]="TIME",e[e.DATE_TIME=7]="DATE_TIME",e[e.SCIENTIFIC=8]="SCIENTIFIC",e))(Vs||{}),Ks=(e=>(e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",e[e.MIN=1]="MIN",e[e.MAX=2]="MAX",e[e.NUMBER=3]="NUMBER",e[e.PERCENT=4]="PERCENT",e[e.PERCENTILE=5]="PERCENTILE",e))(Ks||{}),Pt=(e=>(e.EN_US="enUS",e.ZH_CN="zhCN",e.RU_RU="ruRU",e.ZH_TW="zhTW",e.VI_VN="viVN",e))(Pt||{}),Ys=(e=>(e[e.RANGE=0]="RANGE",e[e.SHEET=1]="SHEET",e))(Ys||{}),zs=(e=>(e[e.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",e[e.PAST_YEAR=1]="PAST_YEAR",e[e.PAST_MONTH=2]="PAST_MONTH",e[e.PAST_WEEK=3]="PAST_WEEK",e[e.YESTERDAY=4]="YESTERDAY",e[e.TODAY=5]="TODAY",e[e.TOMORROW=6]="TOMORROW",e))(zs||{}),Hn=(e=>(e[e.GRID=0]="GRID",e[e.KANBAN=1]="KANBAN",e[e.GANTT=2]="GANTT",e))(Hn||{}),on=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",e[e.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",e))(on||{}),Xs=(e=>(e[e.DASH=0]="DASH",e[e.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",e[e.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",e[e.DASHED_HEAVY=3]="DASHED_HEAVY",e[e.DASH_LONG=4]="DASH_LONG",e[e.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",e[e.DOT_DASH=6]="DOT_DASH",e[e.DOT_DOT_DASH=7]="DOT_DOT_DASH",e[e.DOTTED=8]="DOTTED",e[e.DOTTED_HEAVY=9]="DOTTED_HEAVY",e[e.DOUBLE=10]="DOUBLE",e[e.NONE=11]="NONE",e[e.SINGLE=12]="SINGLE",e[e.THICK=13]="THICK",e[e.WAVE=14]="WAVE",e[e.WAVY_DOUBLE=15]="WAVY_DOUBLE",e[e.WAVY_HEAVY=16]="WAVY_HEAVY",e[e.WORDS=17]="WORDS",e))(Xs||{}),Dt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LEFT=1]="LEFT",e[e.CENTER=2]="CENTER",e[e.RIGHT=3]="RIGHT",e[e.JUSTIFIED=4]="JUSTIFIED",e))(Dt||{}),Wt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TOP=1]="TOP",e[e.MIDDLE=2]="MIDDLE",e[e.BOTTOM=3]="BOTTOM",e))(Wt||{}),Bt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.OVERFLOW=1]="OVERFLOW",e[e.CLIP=2]="CLIP",e[e.WRAP=3]="WRAP",e))(Bt||{}),Tn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ITALIC=1]="ITALIC",e))(Tn||{}),yn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.BOLD=1]="BOLD",e))(yn||{}),Gt=(e=>(e[e.NORMAL=1]="NORMAL",e[e.SUBSCRIPT=2]="SUBSCRIPT",e[e.SUPERSCRIPT=3]="SUPERSCRIPT",e))(Gt||{}),K=(e=>(e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e))(K||{}),Mt=(e=>(e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.FORCE_STRING=4]="FORCE_STRING",e))(Mt||{}),He=(e=>(e[e.DARK1=0]="DARK1",e[e.LIGHT1=1]="LIGHT1",e[e.DARK2=2]="DARK2",e[e.LIGHT2=3]="LIGHT2",e[e.ACCENT1=4]="ACCENT1",e[e.ACCENT2=5]="ACCENT2",e[e.ACCENT3=6]="ACCENT3",e[e.ACCENT4=7]="ACCENT4",e[e.ACCENT5=8]="ACCENT5",e[e.ACCENT6=9]="ACCENT6",e[e.HYPERLINK=10]="HYPERLINK",e[e.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",e))(He||{}),$n=(e=>(e.OFFICE="Office",e.OFFICE_2007_2010="Office 2007-2010",e.GRAYSCALE="Grayscale",e.BLUE_WARM="Blue Warm",e.BLUE="Blue",e.BLUE_II="Blue II",e.BLUE_GREEN="Blue Green",e.GREEN="Green",e.GREEN_YELLOW="Green Yellow",e.YELLOW="Yellow",e.YELLOW_ORANGE="Yellow Orange",e.ORANGE="Orange",e.ORANGE_RED="Orange Red",e.RED_ORANGE="Red Orange",e.RED="Red",e.RED_VIOLET="Red Violet",e.VIOLET="Violet",e.VIOLET_II="Violet II",e.MEDIAN="Median",e.PAPER="Paper",e.MARQUEE="Marquee",e.SLIPSTREAM="Slipstream",e.Aspect="Aspect",e))($n||{}),Qs=(e=>(e.Line="line",e.LineInv="lineInv",e.Triangle="triangle",e.RtTriangle="rtTriangle",e.Rect="rect",e.Diamond="diamond",e.Parallelogram="parallelogram",e.Trapezoid="trapezoid",e.NonIsocelesTrapezoid="nonIsocelesTrapezoid",e.Pentagon="pentagon",e.Hexagon="hexagon",e.Heptagon="heptagon",e.Octagon="octagon",e.Decagon="decagon",e.Dodecagon="dodecagon",e.Star4="star4",e.Star5="star5",e.Star6="star6",e.Star7="star7",e.Star8="star8",e.Star10="star10",e.Star12="star12",e.Star16="star16",e.Star24="star24",e.Star32="star32",e.RoundRect="roundRect",e.Round1Rect="round1Rect",e.Round2SameRect="round2SameRect",e.Round2DiagRect="round2DiagRect",e.Ellipse="ellipse",e))(Qs||{}),qs=(e=>(e.RightArrow="rightArrow",e.LeftArrow="leftArrow",e.UpArrow="upArrow",e.DownArrow="downArrow",e.LeftRightArrow="leftRightArrow",e.UpDownArrow="upDownArrow",e.QuadArrow="quadArrow",e.LeftRightUpArrow="leftRightUpArrow",e.BentArrow="bentArrow",e.UturnArrow="uturnArrow",e.CircularArrow="circularArrow",e.NotchedRightArrow="notchedRightArrow",e.HomePlate="homePlate",e.Chevron="chevron",e.LeftCircularArrow="leftCircularArrow",e.LeftRightCircularArrow="leftRightCircularArrow",e))(qs||{}),Zs=(e=>(e.Plaque="plaque",e.Can="can",e.Cube="cube",e.Bevel="bevel",e.Donut="donut",e.NoSmoking="noSmoking",e.BlockArc="blockArc",e.FoldedCorner="foldedCorner",e))(Zs||{}),Js=(e=>(e.SmileyFace="smileyFace",e.Heart="heart",e.LightningBolt="lightningBolt",e.Sun="sun",e.Moon="moon",e.Cloud="cloud",e.Arc="arc",e.Backpack="backpack",e.Frame="frame",e.HalfFrame="halfFrame",e.Corner="corner",e.Chord="chord",e.Pie="pie",e.Teardrop="teardrop",e.WedgeRectCallout="wedgeRectCallout",e.WedgeRRectCallout="wedgeRRectCallout",e.WedgeEllipseCallout="wedgeEllipseCallout",e.CloudCallout="cloudCallout",e.BorderCallout1="borderCallout1",e.BorderCallout2="borderCallout2",e.BorderCallout3="borderCallout3",e.AccentCallout1="accentCallout1",e.AccentCallout2="accentCallout2",e.AccentCallout3="accentCallout3",e.Callout1="callout1",e.Callout2="callout2",e.Callout3="callout3",e.ActionButtonBackPrevious="actionButtonBackPrevious",e.ActionButtonEnd="actionButtonEnd",e.ActionButtonForwardNext="actionButtonForwardNext",e.ActionButtonHelp="actionButtonHelp",e.ActionButtonHome="actionButtonHome",e.ActionButtonInformation="actionButtonInformation",e.ActionButtonMovie="actionButtonMovie",e.ActionButtonReturn="actionButtonReturn",e.ActionButtonSound="actionButtonSound",e))(Js||{});const eo={[$n.OFFICE]:{[He.ACCENT1]:"#4472C4",[He.ACCENT2]:"#ED7D31",[He.ACCENT3]:"#A5A5A5",[He.ACCENT4]:"#70AD47",[He.ACCENT5]:"#5B9BD5",[He.ACCENT6]:"#70AD47",[He.DARK1]:"#000000",[He.DARK2]:"#44546A",[He.LIGHT1]:"#FFFFFF",[He.LIGHT2]:"#E7E6E6",[He.HYPERLINK]:"#0563C1",[He.FOLLOWED_HYPERLINK]:"#954F72"}};class jn{constructor(){_(this,"_themeValue",He.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=qe.UNSUPPORTED,this._themeColors=$n.OFFICE,this._themeTint=0}asRgbColor(){return new Dn(this._rgbValue,this)}asThemeColor(){return new Mn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case qe.THEME:return this.asThemeColor();case qe.RGB:return this.asRgbColor();case qe.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=qe.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=qe.THEME,this._themeColors=n}setThemeTint(n){this._colorType=qe.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=qe.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class Ut{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 t=+`0x${n[0]}${n[1]}`,r=+`0x${n[2]}${n[3]}`,s=+`0x${n[4]}${n[5]}`;return new jn().setRgbColor(`rgb(${t},${r},${s})`).asRgbColor()}static hexToRgbString(n){const t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(o,i,a,l)=>i+i+a+a+l+l);const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let s=null;if(r){const o=Number.parseInt(r[1],16),i=Number.parseInt(r[2],16),a=Number.parseInt(r[3],16);s=`rgba(${o},${i},${a})`}return s}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Ut(this._builder)}equals(n){return!1}}class to{constructor(n){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const t=n.getRed()/255,r=n.getGreen()/255,s=n.getBlue()/255,o=n.getAlpha()/255,i=Math.min(t,Math.min(r,s)),a=Math.max(t,Math.max(r,s)),l=a-i;if(a===i){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(i+a)/2,this._lightness<.5?this._saturation=l/(a+i):this._saturation=l/(2-a-i),t===a&&(this._hue=(r-s)/l),r===a&&(this._hue=2+(s-t)/l),s===a&&(this._hue=4+(t-r)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=o}asRgbColor(){const n=new jn;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let t;this._lightness<.5?t=this._lightness*(1+this._saturation):t=this._lightness+this._saturation-this._lightness*this._saturation;const r=2*this._lightness-t,s=this._hue/360,o=s+1/3,i=this.setColor(t,r,o),a=this.setColor(t,r,s),l=s-1/3,h=this.setColor(t,r,l);return n.setRgbColor(`rgba(${Math.round(i*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,t,r){r<0&&(r+=1),r>1&&(r-=1);let s;return 6*r<1?s=t+(n-t)*6*r:2*r<1?s=n:3*r<2?s=t+(n-t)*(2/3-r)*6:s=t,s}setLightness(n){this._lightness=n}}const Qe=class Qe extends Ut{constructor(t,r){super(r);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let s=t.match(Qe.RGBA_EXTRACT);if(s){const o=+s[1],i=+s[2],a=+s[3],l=+s[4];this._cssString=t,this._red=o,this._green=i,this._blue=a,this._alpha=l;return}if(s=t.match(Qe.RGB_EXTRACT),s){const o=+s[1],i=+s[2],a=+s[3];this._cssString=t,this._red=o,this._green=i,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Ut.rgbColorToHexValue(this)}getRed(){let t=this._red+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getGreen(){let t=this._green+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getBlue(){let t=this._blue+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getAlpha(){return this._alpha}getColorType(){return qe.RGB}clone(){return new Qe(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(t){return t instanceof Qe?t._red===this._red&&t._blue===this._blue&&t._green===this._green&&t._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(Qe,"RGB_COLOR_AMT",0),_(Qe,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(Qe,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let Dn=Qe;const Ct=class Ct extends Ut{constructor(t,r,s,o){super(o);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=t,this._themeTint=r,this._themeColors=s}lumValue(t,r){if(t==null)return r;let s;return t<0?s=r*(1+t):s=r*(1-t)+(255-255*(1-t)),s}asRgbColor(){const t=eo[this._themeColors];if(t==null)throw new Error("not find themeColors type");const r=t[this._themeColorType];if(r==null)throw new Error("not find themeColors value");let s;if(Ct._cacheThemeColor.has(this._themeColors)){if(s=Ct._cacheThemeColor.get(this._themeColors),s.has(this._themeColorType))return s.get(this._themeColorType)}else s=new Map,Ct._cacheThemeColor.set(this._themeColors,s);const o=new to(Ut.hexValueToRgbColor(r));o.setLightness(this.lumValue(this._themeTint,o.getLightness()*255)/255);const i=o.asRgbColor();return s.set(this._themeColorType,i),i}clone(){return new Ct(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(t){return t instanceof Ct?t._themeColorType===this._themeColorType:!1}getColorType(){return qe.THEME}getThemeColorType(){return this._themeColorType}};_(Ct,"_cacheThemeColor",new Map);let Mn=Ct;const Va="rgb(",Ka="rgba(",lr={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 rt{constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof rt){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const t=no(n);if(t==null){this._setNullColor();return}this._color=t;const r=qa(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}static mix(n,t,r){var h,c;r=Math.min(1,Math.max(0,r));const s=new rt(n).toRgb(),o=new rt(t).toRgb(),i=(h=s.a)!=null?h:1,a=(c=o.a)!=null?c:1,l={r:(o.r-s.r)*r+s.r,g:(o.g-s.g)*r+s.g,b:(o.b-s.b)*r+s.b,a:(a-i)*r+i};return new rt(l)}static getContrastRatio(n,t){const r=new rt(n).getLuminance(),s=new rt(t).getLuminance();return(Math.max(r,s)+.05)/(Math.min(r,s)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:t,b:r,a:s=1}=this.toRgb(),o=s<1;return`rgb${o?"a":""}(${n},${t},${r}${o?`,${s}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:t,g:r,b:s,a:o=1}=this.toRgb(),i=o<1,a=[pn(Math.round(t).toString(16)),pn(Math.round(r).toString(16)),pn(Math.round(s).toString(16)),pn(Math.round(o*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]?i?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:i?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return tl(this.toRgb())}toHsl(){return el(this.toRgb())}lighten(n=10){const t=this.toHsl();return t.l+=n,t.l=Math.min(Math.max(t.l,0),100),new rt(t)}darken(n=10){const t=this.toHsl();return t.l-=n,t.l=Math.min(Math.max(t.l,0),100),new rt(t)}setAlpha(n){return new rt({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:t,b:r}=this.toRgb();return n=er(n),t=er(t),r=er(r),Number((.2126*n+.7152*t+.0722*r).toFixed(3))}getBrightness(){const{r:n,g:t,b:r}=this.toRgb();return(n*299+t*587+r*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 pn=e=>e.length===1?`0${e}`:e,er=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),no=e=>{if(rl(e)){if("r"in e){const r={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(r.a=e.a),r}if("l"in e){const r={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(r.a=e.a),r}const t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}const n=e.trim();if(lr[n]){const t=lr[n],r={r:Math.round(t[0]),g:Math.round(t[1]),b:Math.round(t[2])};return r.a=t[3]||1,r}if(n.startsWith("#"))return Ya(n);if(n.startsWith("rgb"))return za(n);if(n.startsWith("hsl"))return Xa(n);if(n.startsWith("hsv"))return Qa(n)},Ya=e=>{const n=e.substring(1),t=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let r=n.match(t);if(!r||r.length<3)throw new Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(o=>o+o));const s={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(s.a=Number.parseInt(r[3],16)/255),s},za=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal rgb color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal rgb color`);const r={r:Number.parseInt(t[0],10),g:Number.parseInt(t[1],10),b:Number.parseInt(t[2],10)};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Xa=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsl color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsl color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),l:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Qa=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsv color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsv color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),v:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},qa=e=>{const n=no(e);if(n!=null)return"r"in n?n:"l"in n?Za(n):Ja(n)},tr=(e,n,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+(n-e)*6*t:t<1/2?n:t<2/3?e+(n-e)*(2/3-t)*6:e),Za=e=>{let{h:n,s:t,l:r}=e;n/=360,t/=100,r/=100;let s=0,o=0,i=0;if(t===0)s=o=i=r;else{const l=r<.5?r*(1+t):r+t-r*t,h=2*r-l;s=tr(h,l,n+1/3),o=tr(h,l,n),i=tr(h,l,n-1/3)}const a={r:Math.round(s*255),g:Math.round(o*255),b:Math.round(i*255)};return e.a!==void 0&&(a.a=e.a),a},Ja=e=>{let{h:n,s:t,v:r}=e;n=n/360*6,t/=100,r/=100;const s=Math.floor(n),o=n-s,i=r*(1-t),a=r*(1-o*t),l=r*(1-(1-o)*t),h=s%6,c=[r,a,i,i,l,r][h],u=[l,r,r,a,i,i][h],d=[i,i,l,r,r,a][h],f={r:c*255,g:u*255,b:d*255};return e.a!==void 0&&(f.a=e.a),f},el=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),o=Math.min(n,t,r),i=(s+o)/2;let a,l;if(s===o)a=l=0;else{const c=s-o;switch(l=i>.5?c/(2-s-o):c/(s+o),s){case n:a=(t-r)/c+(t<r?6:0);break;case t:a=(r-n)/c+2;break;default:a=(n-t)/c+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(i*100)};return e.a!==void 0&&(h.a=e.a),h},tl=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),o=Math.min(n,t,r);let i;const a=s,l=s-o,h=s===0?0:l/s;if(s===o)i=0;else{switch(s){case n:i=(t-r)/l+(t<r?6:0);break;case t:i=(r-n)/l+2;break;default:i=(n-t)/l+4;break}i/=6}const c={h:Math.round(i*360),s:Math.round(h*100),v:Math.round(a*100)};return e.a!==void 0&&(c.a=e.a),c},nl=e=>e==null,rl=e=>!nl(e)&&typeof e=="object";function sl(e){const n=/^#(?:[0]{3}|[0]{6})\b/,t=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,r=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,o=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||o.test(e))}function ol(e){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,t=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,r=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,o=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||o.test(e))}var ke=(e=>(e[e.COVER=0]="COVER",e[e.REPLACE=1]="REPLACE",e[e.INTERSECTION=2]="INTERSECTION",e))(ke||{});function il(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.si!==void 0)}function al(e){if(e.t!==void 0)return e.t;if(typeof e.v=="string")return Mt.STRING;if(typeof e.v=="number")return Mt.NUMBER;if(typeof e.v=="boolean")return Mt.BOOLEAN}function ll(e){if(e==null)return!0;const{v:n,f:t,si:r,p:s,s:o,custom:i}=e;return!(!(n==null||typeof n=="string"&&n.length===0)||t!=null&&t.length>0||r!=null&&r.length>0||s!=null||i!=null)}function ul(e){return e!=null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}var ro=(e=>(e[e.character=0]="character",e[e.paragraph=1]="paragraph",e[e.table=2]="table",e[e.numbering=3]="numbering",e))(ro||{}),so=(e=>(e[e.TAB=0]="TAB",e[e.SPACE=1]="SPACE",e[e.NOTHING=2]="NOTHING",e))(so||{}),Jt=(e=>(e[e.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.DECIMAL=2]="DECIMAL",e[e.ZERO_DECIMAL=3]="ZERO_DECIMAL",e[e.UPPER_ALPHA=4]="UPPER_ALPHA",e[e.ALPHA=5]="ALPHA",e[e.UPPER_ROMAN=6]="UPPER_ROMAN",e[e.ROMAN=7]="ROMAN",e))(Jt||{}),Rt=(e=>(e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Rt||{}),oo=(e=>(e[e.HYPERLINK=0]="HYPERLINK",e[e.FIELD=1]="FIELD",e[e.SDT=2]="SDT",e[e.BOOKMARK=3]="BOOKMARK",e[e.COMMENT=4]="COMMENT",e[e.CUSTOM=5]="CUSTOM",e[e.MENTION=6]="MENTION",e[e.UNI_FORMULA=7]="UNI_FORMULA",e))(oo||{}),io=(e=>(e[e.COMMENT=0]="COMMENT",e))(io||{}),ao=(e=>(e[e.DRAWING=0]="DRAWING",e[e.CUSTOM=1]="CUSTOM",e))(ao||{}),lo=(e=>(e[e.TRADITIONAL=0]="TRADITIONAL",e[e.MODERN=1]="MODERN",e))(lo||{}),uo=(e=>(e[e.DEFAULT=0]="DEFAULT",e[e.LINES=1]="LINES",e[e.LINES_AND_CHARS=2]="LINES_AND_CHARS",e[e.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",e))(uo||{}),co=(e=>(e[e.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",e[e.CONTINUOUS=1]="CONTINUOUS",e[e.NEXT_PAGE=2]="NEXT_PAGE",e[e.EVEN_PAGE=3]="EVEN_PAGE",e[e.ODD_PAGE=4]="ODD_PAGE",e))(co||{}),ho=(e=>(e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",e))(ho||{}),fo=(e=>(e[e.NORMAL=0]="NORMAL",e[e.TBRL=1]="TBRL",e[e.LRTBV=2]="LRTBV",e))(fo||{}),_o=(e=>(e[e.TEXT_RUN=0]="TEXT_RUN",e[e.AUTO_TEXT=1]="AUTO_TEXT",e[e.PAGE_BREAK=2]="PAGE_BREAK",e[e.COLUMN_BREAK=3]="COLUMN_BREAK",e[e.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",e[e.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",e[e.EQUATION=6]="EQUATION",e[e.DRAWING=7]="DRAWING",e[e.PERSON=8]="PERSON",e[e.RICH_LINK=9]="RICH_LINK",e))(_o||{}),go=(e=>(e[e.BOTH_SIDES=0]="BOTH_SIDES",e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.LARGEST=3]="LARGEST",e))(go||{}),po=(e=>(e[e.INLINE=0]="INLINE",e[e.WRAP_NONE=1]="WRAP_NONE",e[e.WRAP_POLYGON=2]="WRAP_POLYGON",e[e.WRAP_SQUARE=3]="WRAP_SQUARE",e[e.WRAP_THROUGH=4]="WRAP_THROUGH",e[e.WRAP_TIGHT=5]="WRAP_TIGHT",e[e.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",e))(po||{}),mo=(e=>(e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",e[e.NORMAL_TEXT=1]="NORMAL_TEXT",e[e.TITLE=2]="TITLE",e[e.SUBTITLE=3]="SUBTITLE",e[e.HEADING_1=4]="HEADING_1",e[e.HEADING_2=5]="HEADING_2",e[e.HEADING_3=6]="HEADING_3",e[e.HEADING_4=7]="HEADING_4",e[e.HEADING_5=8]="HEADING_5",e[e.HEADING_6=9]="HEADING_6",e))(mo||{}),Eo=(e=>(e[e.AUTO=0]="AUTO",e[e.AT_LEAST=1]="AT_LEAST",e[e.EXACT=2]="EXACT",e))(Eo||{}),Ro=(e=>(e[e.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",e[e.SOLID=1]="SOLID",e[e.DOT=2]="DOT",e[e.DASH=3]="DASH",e))(Ro||{}),Co=(e=>(e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Co||{}),Io=(e=>(e.EVENLY_DISTRIBUTED="0",e.FIXED_WIDTH="1",e))(Io||{}),vo=(e=>(e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",e[e.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",e[e.TOP=2]="TOP",e[e.MIDDLE=3]="MIDDLE",e[e.BOTTOM=4]="BOTTOM",e))(vo||{}),Oo=(e=>(e.NORMAL="normal",e.BOLD="bold",e.ITALIC="italic",e))(Oo||{}),So=(e=>(e[e.PAGE=0]="PAGE",e[e.COLUMN=1]="COLUMN",e[e.CHARACTER=2]="CHARACTER",e[e.MARGIN=3]="MARGIN",e[e.INSIDE_MARGIN=4]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",e[e.LEFT_MARGIN=6]="LEFT_MARGIN",e[e.RIGHT_MARGIN=7]="RIGHT_MARGIN",e))(So||{}),No=(e=>(e[e.PAGE=0]="PAGE",e[e.PARAGRAPH=1]="PARAGRAPH",e[e.LINE=2]="LINE",e[e.MARGIN=3]="MARGIN",e[e.TOP_MARGIN=4]="TOP_MARGIN",e[e.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",e[e.INSIDE_MARGIN=6]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",e))(No||{}),wo=(e=>(e[e.POINT=0]="POINT",e[e.LINE=1]="LINE",e[e.CHARACTER=2]="CHARACTER",e[e.PIXEL=3]="PIXEL",e))(wo||{}),Ao=(e=>(e[e.CENTER=0]="CENTER",e[e.INSIDE=1]="INSIDE",e[e.LEFT=2]="LEFT",e[e.OUTSIDE=3]="OUTSIDE",e[e.RIGHT=4]="RIGHT",e[e.BOTH=5]="BOTH",e[e.DISTRIBUTE=6]="DISTRIBUTE",e))(Ao||{}),bo=(e=>(e[e.BOTTOM=0]="BOTTOM",e[e.CENTER=1]="CENTER",e[e.INSIDE=2]="INSIDE",e[e.OUTSIDE=3]="OUTSIDE",e[e.TOP=4]="TOP",e))(bo||{}),To=(e=>(e[e.compressPunctuation=0]="compressPunctuation",e[e.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",e[e.doNotCompress=2]="doNotCompress",e))(To||{}),yo=(e=>(e[e.PORTRAIT=0]="PORTRAIT",e[e.LANDSCAPE=1]="LANDSCAPE",e))(yo||{}),Do=(e=>(e[e.forward=0]="forward",e[e.backward=1]="backward",e[e.front=2]="front",e[e.back=3]="back",e))(Do||{}),Mo=(e=>(e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e[e.DRAWING_IMAGE=0]="DRAWING_IMAGE",e[e.DRAWING_SHAPE=1]="DRAWING_SHAPE",e[e.DRAWING_CHART=2]="DRAWING_CHART",e[e.DRAWING_TABLE=3]="DRAWING_TABLE",e[e.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",e[e.DRAWING_VIDEO=5]="DRAWING_VIDEO",e[e.DRAWING_GROUP=6]="DRAWING_GROUP",e[e.DRAWING_UNIT=7]="DRAWING_UNIT",e[e.DRAWING_DOM=8]="DRAWING_DOM",e))(Mo||{}),oe=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(oe||{}),Se=(e=>(e[e.NONE=0]="NONE",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(Se||{});function cl(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}function hl(e,n,t){let r=!1,s=!1,o=e,i=n,a=e,l=n;if(t==null)return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:o,endColumn:i,startRow:a,startColumn:l};for(let h=0;h<t.length;h++){const{startRow:c,endRow:u,startColumn:d,endColumn:f}=t[h];if(e===c&&n===d){o=u,i=f,a=c,l=d,s=!0;break}if(e>=c&&e<=u&&n>=d&&n<=f){o=u,i=f,a=c,l=d,r=!0;break}}return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:o,endColumn:i,startRow:a,startColumn:l}}var yr=(e=>(e[e.SLIDE=0]="SLIDE",e[e.MASTER=1]="MASTER",e[e.LAYOUT=2]="LAYOUT",e[e.HANDOUT_MASTER=3]="HANDOUT_MASTER",e[e.NOTES_MASTER=4]="NOTES_MASTER",e))(yr||{}),Uo=(e=>(e[e.SHAPE=0]="SHAPE",e[e.IMAGE=1]="IMAGE",e[e.TEXT=2]="TEXT",e[e.SPREADSHEET=3]="SPREADSHEET",e[e.DOCUMENT=4]="DOCUMENT",e[e.SLIDE=5]="SLIDE",e))(Uo||{}),Lo=(e=>(e[e.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",e[e.NEXT_SLIDE=1]="NEXT_SLIDE",e[e.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",e[e.FIRST_SLIDE=3]="FIRST_SLIDE",e[e.LAST_SLIDE=4]="LAST_SLIDE",e))(Lo||{});const dl="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let fl=e=>crypto.getRandomValues(new Uint8Array(e)),_l=(e,n,t)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,s=-~(1.6*r*n/e.length);return(o=n)=>{let i="";for(;;){let a=t(s),l=s;for(;l--;)if(i+=e[a[l]&r]||"",i.length===o)return i}}},gl=(e,n=21)=>_l(e,n,fl),pl=(e=21)=>{let n="",t=crypto.getRandomValues(new Uint8Array(e));for(;e--;)n+=dl[t[e]&63];return n};const ml=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 El(e){return Number.isNaN(+e)?e.startsWith("http://localhost:3002")||e.startsWith("localhost:3002")?!0:ml.test(e):!1}function Rl(e){return/^[a-zA-Z]+:\/\//.test(e)}function Cl(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Il(e){return Rl(e)?e:Cl(e)?`mailto://${e}`:`https://${e}`}const vl=/^-ms-/,Ol=/-([a-z])/g,Et=["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 t="",r=n;for(;r>=Et.length;)r/=Et.length,r-=1,t+=Et[r%Et.length];const s=n%Et.length;return t+=Et[s],t}static indexAt(n){let t=0;for(let r=0;r<n.length-1;r+=1){const s=n.charCodeAt(r)-65,o=n.length-1-r;t+=Et.length**o+Et.length*s}return t+=n.charCodeAt(n.length-1)-65,t}static deleteBlank(n){return x.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,t=navigator.platform==="Win32"||navigator.platform==="Windows",r=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(r)return"Mac";if(navigator.platform==="X11"&&!t&&!r)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(t){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,t=n.indexOf("Opera")>-1,r=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!t,s=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,o=n.indexOf("Edge")>-1,i=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(r){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 i?"FF":t?"Opera":a?"Safari":l?"Chrome":o?"Edge":s?"IE11":"Unknown browser"}static generateRandomId(n=21,t){return xo(n,t)}static getClassName(n){return n.constructor.name}static deepMerge(n,...t){t.forEach(i=>i&&o(i));function r(i,a){i.forEach((l,h)=>{var c,u;if(x.isArray(l)){const d=(c=a[h])!=null?c:[];a[h]=d,r(l,d);return}if(x.isObject(l)){const d=(u=a[h])!=null?u:{};a[h]=d,s(l,d);return}a[h]=l})}function s(i,a){Object.keys(i).forEach(l=>{var c,u;const h=i[l];if(x.isObject(h)){const d=(c=a[l])!=null?c:{};a[l]=d,s(h,d);return}if(x.isArray(h)){const d=(u=a[l])!=null?u:[];a[l]=d,r(h,d);return}a[l]=h})}function o(i){Object.keys(i).forEach(a=>{var h,c;const l=i[a];if(x.isArray(l)){const u=(h=n[a])!=null?h:[];n[a]=u,r(l,u);return}if(x.isObject(l)){const u=(c=n[a])!=null?c:{};n[a]=u,s(l,u);return}n[a]=l})}return n}static numberFixed(n,t){return Number(Number(n).toFixed(t))}static diffValue(n,t){function r(i,a){const l=x.getValueType(i),h=x.getValueType(a);return l!==h?!1:x.isArray(i)?s(i,a):x.isObject(i)?o(i,a):x.isDate(i)?i.getTime()===a.getTime():x.isRegExp(i)?i.toString()===a.toString():i===a}function s(i,a){if(n.length!==t.length)return!1;for(let l=0,h=i.length;l<h;l++){const c=i[l],u=a[l];if(!r(c,u))return!1}return!0}function o(i,a){const l=Object.keys(i),h=Object.keys(a);if(l.length!==h.length)return!1;for(const c of l){if(!h.includes(c))return!1;const u=i[c],d=a[c];if(!r(u,d))return!1}return!0}return r(n,t)}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 t=[];return n.forEach((r,s)=>{t[s]=x.deepClone(r)}),t}if(this.isObject(n)){const t={};return Object.keys(n).forEach(r=>{const s=n[r];t[r]=x.deepClone(s)}),Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}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,t){return n instanceof t}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 t in n)return!1;return!0}static isMobile(){let n=0,t=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(t=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&t<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 El(n)}static normalizeUrl(n){return Il(n)}static itCount(n){return t=>{for(let r=0;r<n;r++)t&&t()}}static hasLength(n,t){return x.isDefine(n)?x.isDefine(t)?n.length===t:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,t){return t.toUpperCase()}static camelCase(n){return n.replace(vl,"ms-").replace(Ol,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(t=>{const r=n[t];r==null?delete n[t]:x.removeNull(r)}),n}static fillTwoDimensionalArray(n,t,r){return new Array(n).fill(r).map(s=>new Array(t).fill(r))}static numToWord(n){let t="";for(;n>0;){let r=n%26;r=r===0?r=26:r,t=String.fromCharCode(96+r)+t,n=(n-r)/26}return t.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const t=n.toLowerCase().split(""),r=t.length;let s=0,o=0;for(let i=0;i<r;i++)o=t[i].charCodeAt(0)-96,s+=o*26**(r-i-1);return s===0?Number.NaN:s-1}static chatAtABC(n){let o="";for(;n>=0;)o=String.fromCharCode(n%26+97)+o,n=Math.floor(n/26)-1;return o.toUpperCase()}static randSort(n){for(let t=0,r=n.length;t<r;t++){const s=Number.parseInt((Math.random()*r).toString()),o=n[s];n[s]=n[t],n[t]=o}return n}static commonExtend(n,t){const r={};for(const s in n)r[s]=n[s];for(const s in t)t[s]!=null&&(r[s]=t[s]);return r}static commonExtend1(n,t){for(const r in n)t[r]==null&&(t[r]=n[r]);return t}static arrayToObject(n){const t={};return n.forEach((r,s)=>{t[s]={},r.forEach((o,i)=>{t[s][i]=o})}),t}static hasIntersectionBetweenTwoRanges(n,t,r,s){return t>=r&&s>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),r=n.length<=255;return!t&&r}static set(n,t,r){const s=t.split("."),o=s.pop();s.forEach(i=>{n[i]||(n[i]={}),n=n[i]}),o&&(n[o]=r)}static clamp(n,t,r){return Math.max(t,Math.min(r,n))}}function xo(e=21,n){return n?gl(n,e)():pl(e)}function Sl(e){const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,mergeInfo:o}=e;let{startY:i,endY:a,startX:l,endX:h}=e,c=n,u=t,d=n,f=t;if(r&&o){const{startRow:p,startColumn:m,endRow:S,endColumn:y,startY:ee,endY:ge,startX:ce,endX:E}=o;c=p,u=m,d=S,f=y,i=ee,a=ge,l=ce,h=E}return s&&(i=o.startY,a=o.endY,l=o.startX,h=o.endX,d=o.endRow,f=o.endColumn),{startRow:c,startColumn:u,endRow:d,endColumn:f,startY:i,endY:a,startX:l,endX:h}}function Nl(e){if(!e)return;const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,startRow:o,startColumn:i,endRow:a,endColumn:l}=e;let h=n,c=t,u=n,d=t;return(r||s)&&(h=o,c=i,u=a,d=l),{startRow:h,startColumn:c,endRow:u,endColumn:d}}function Po(e){var t;return!e||(((t=e==null?void 0:e.v)==null?void 0:t.toString())||"").length===0&&!e.p}function wl(e){return Po(e)&&(e==null?void 0:e.coverable)!==!1}function ut(e){if(e){if(e.rgb)return e.rgb;if(e.th)return new jn().setThemeColor(e.th).asThemeColor().asRgbColor().getCssString()}return null}function Al(e){return x.isString(e)&&e.substring(0,1)==="="&&e.length>1}function bl(e){return x.isString(e)&&e.length>0}function Tl(e,n=!1){var o;let t="";const r=new Map([["ff",()=>{e.ff&&(t+=`font-family: ${e.ff}; `)}],["fs",()=>{if(e.fs){let i=e.fs;e.va&&(i/=2),t+=`font-size: ${i}pt; `}}],["it",()=>{e.it&&(t+="font-style: italic; ")}],["bl",()=>{e.bl&&(t+="font-weight: bold; ")}],["ul",()=>{var i;(i=e.ul)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):t+="text-decoration: underline; ",e.ul.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.ul.cl)}; `),e.ul.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ul.t} `))}],["st",()=>{var i;(i=e.st)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):t+="text-decoration-line: line-through; ",e.st.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.st.cl)}; `),e.st.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.st.t} `))}],["ol",()=>{var i;(i=e.ol)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):t+="text-decoration-line: overline; ",e.ol.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.ol.cl)}; `),e.ol.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ol.t} `))}],["bg",()=>{e.bg&&(t+=`background: ${ut(e.bg)}; `)}],["bd",()=>{var i,a,l,h,c,u,d,f,p,m,S,y;(i=e.bd)!=null&&i.b&&(t+=`border-bottom: ${mn((a=e.bd)==null?void 0:a.b.s)} ${(l=ut(e.bd.b.cl))!=null?l:""}; `),(h=e.bd)!=null&&h.t&&(t+=`border-top: ${mn((c=e.bd)==null?void 0:c.t.s)} ${(u=ut(e.bd.t.cl))!=null?u:""}; `),(d=e.bd)!=null&&d.r&&(t+=`border-right: ${mn((f=e.bd)==null?void 0:f.r.s)} ${(p=ut(e.bd.r.cl))!=null?p:""}; `),(m=e.bd)!=null&&m.l&&(t+=`border-left: ${mn((S=e.bd)==null?void 0:S.l.s)} ${(y=ut(e.bd.l.cl))!=null?y:""}; `)}],["cl",()=>{e.cl&&(t+=`color: ${ut(e.cl)}; `)}],["va",()=>{e.va===Gt.SUBSCRIPT?t+="vertical-align: sub; ":e.va===Gt.SUPERSCRIPT&&(t+="vertical-align: super; ")}],["td",()=>{e.td===on.LEFT_TO_RIGHT?t+="direction: ltr; ":e.td===on.RIGHT_TO_LEFT&&(t+="direction: rtl; ")}],["tr",()=>{var i,a,l;e.tr&&(t+=`--data-rotate: (${(i=e.tr)==null?void 0:i.a}deg${(a=e.tr)!=null&&a.v?` ,${(l=e.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{e.ht===Dt.LEFT?t+="text-align: left; ":e.ht===Dt.RIGHT?t+="text-align: right; ":e.ht===Dt.CENTER?t+="text-align: center; ":e.ht===Dt.JUSTIFIED&&(t+="text-align: justify; ")}],["vt",()=>{e.vt===Wt.BOTTOM?t+="vertical-align: bottom; ":e.vt===Wt.TOP?t+="vertical-align: top; ":e.vt===Wt.MIDDLE&&(t+="vertical-align: middle; ")}],["tb",()=>{e.tb===Bt.CLIP?t+="white-space: nowrap; overflow-x: hidden; ":e.tb===Bt.WRAP&&(t+="white-space: normal;")}],["pd",()=>{var c,u,d,f,p,m,S,y;const i=`${(c=e.pd)==null?void 0:c.b}pt`,a=`${(u=e.pd)==null?void 0:u.t}pt`,l=`${(d=e.pd)==null?void 0:d.l}pt`,h=`${(f=e.pd)==null?void 0:f.r}pt`;(p=e.pd)!=null&&p.b&&(t+=`padding-bottom: ${i}; `),(m=e.pd)!=null&&m.t&&(t+=`padding-top: ${a}; `),(S=e.pd)!=null&&S.l&&(t+=`padding-left: ${l}; `),(y=e.pd)!=null&&y.r&&(t+=`padding-right: ${h}; `)}]]),s=["bd","tr","tb"];for(const i in e)n&&s.includes(i)||(o=r.get(i))==null||o();return t}function mn(e){let n="";return e===he.NONE?n="none":e===he.THIN?n="0.5pt solid":e===he.HAIR?n="0.5pt double":e===he.DOTTED?n="0.5pt dotted":e===he.DASHED||e===he.DASH_DOT?n="0.5pt dashed":e===he.DASH_DOT_DOT?n="0.5pt dotted":e===he.DOUBLE?n="0.5pt double":e===he.MEDIUM?n="1pt solid":e===he.MEDIUM_DASHED||e===he.MEDIUM_DASH_DOT?n="1pt dashed":e===he.MEDIUM_DASH_DOT_DOT?n="1pt dotted":e===he.SLANT_DASH_DOT?n="0.5pt dashed":e===he.THICK&&(n="1.5pt solid"),n}function yl(e){let n=0;if(e=e.trim(),e==="none")n=he.NONE;else if(e==="0.5pt solid")n=he.THIN;else if(e==="0.5pt double")n=he.HAIR;else if(e==="0.5pt dotted")n=he.DOTTED;else if(e==="0.5pt dashed")n=he.DASHED;else if(e==="1pt solid")n=he.MEDIUM;else if(e==="1pt dashed")n=he.MEDIUM_DASHED;else if(e==="1pt dotted")n=he.MEDIUM_DASH_DOT_DOT;else if(e==="1.5pt solid")n=he.THICK;else if(!e.includes("none"))n=he.THIN;else return he.NONE;return n}function Dl(e,n){let t=e.body;if(n){const{headers:r,footers:s}=e;r!=null&&r[n]?t=r[n].body:s!=null&&s[n]&&(t=s[n].body)}return t}function Ml(e){const{startRow:n,endRow:t,startColumn:r,endColumn:s,rangeType:o}=e;return!(n<0||r<0||t<0||s<0||!(Number.isNaN(n)&&Number.isNaN(t))&&o===oe.COLUMN||!(Number.isNaN(r)&&Number.isNaN(s))&&o===oe.ROW||o!==oe.ROW&&o!==oe.COLUMN&&(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(s)||Number.isNaN(t)))}function Ul(e,n){return{startRow:e,endRow:e,startColumn:n,endColumn:n}}function Dr(e,n){return Object.prototype.toString.call(e)===Object.prototype.toString.call(n)?Object.prototype.toString.call(e)==="[object Object]"||Object.prototype.toString.call(e)==="[object Array]"?Object.keys(e).length!==Object.keys(n).length?!1:Object.keys(e).every(t=>Dr(e[t],n[t])):e===n:!1}function ko(e,n){const t=e.ts||{},r=n.ts||{};return e.sId!==n.sId?!1:Dr(t,r)}function Ll(e,n){return n.some(t=>e.indexOf(t)>-1)}function Wn(e,n,t,r){if(e>n&&([e,n]=[n,e]),t>r&&([t,r]=[r,t]),n<t||r<e)return[e,n];t<e&&(t=e),r>n&&(r=n);const s=r-t+1;let o=[];return e===t?o=[r+1-s,n-s]:n===r?o=[e,t-1]:o=[e,n-s],o}function xl(e){if(e==null)return!1;const n=e.bullet;return(n==null?void 0:n.listId)!=null}function Pl(e){if(e==null)return!1;const n=e.paragraphStyle;return Fo(n)}function Fo(e){var n;return!(e==null||(e.indentStart==null||e.indentStart.v===0)&&e.hanging==null||((n=e.hanging)==null?void 0:n.v)===0)}function Ho(e,n,t){return e.slice(0,n)+t+e.slice(n)}function $o(e,n,t){return n>t?e:e.slice(0,n)+e.slice(t)}function kl(e){return e===null||e.toString().replace(/\s/g,"")===""||typeof e=="boolean"?!1:!isNaN(e)}function Fl(e){let n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+(n<<6)+(n<<16)-n;return n>>>0}function as(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function ls(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var r=t.call(e),s,o=[],i;try{for(;(n===void 0||n-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function us(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))}function en(e){return typeof e=="function"}function Hl(e){var n=function(r){Error.call(r),r.stack=new Error().stack},t=e(n);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var nr=Hl(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
1
+ "use strict";var Pa=Object.defineProperty;var ka=(e,n,t)=>n in e?Pa(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var _=(e,n,t)=>ka(e,typeof n!="symbol"?n+"":n,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("rxjs"),Cn=require("rxjs/operators"),Pe=require("react");function Fa(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}function Ha(e,n){for(var t=0;t<n.length;t++){const r=n[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(r,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const st=Fa(Pe);function ja(){$a()}const gn=typeof global<"u"?global:typeof self<"u"?self:window;function $a(){typeof gn.requestIdleCallback!="function"&&(gn.requestIdleCallback=function(t){const r=Date.now();return setTimeout(function(){const o=Math.max(0,50-(Date.now()-r));t({didTimeout:o===0,timeRemaining(){return o}})},1)}),typeof gn.cancelIdleCallback!="function"&&(gn.cancelIdleCallback=function(t){clearTimeout(t)})}const Wa="__default_document_sub_component_id20231101__",Qt=2,xs=1;function Ba(e,n){if(n==null||e==null)return!0;const{left:t=0,top:r=0,height:s=0,width:o=0,angle:i=0}=n,{left:a=0,top:l=0,height:h=0,width:c=0,angle:u=0}=e,d=c,f=h,p=o,m=s;return Math.abs(a-t)>Qt||Math.abs(l-r)>Qt||Math.abs(d-p)>Qt||Math.abs(f-m)>Qt||Math.abs(u-i)>xs}function Ps(e,n){let t=0,r=e.length-1;for(;t<=r;){const s=Math.floor((r+t)/2);if(n<e[s]&&(s===0||n>=e[s-1]))return s;if(n>=e[s])t=s+1;else if(n<e[s])r=s-1;else return-1}return-1}function ks(e,n){let t=0,r=0,s=0,o=-1,i=e.length-1;for(;t<e.length&&i>=0&&i>=t;){if(r=e[i],i===0?s=0:s=e[i-1],n>=s&&n<=r){o=i;break}if(r=e[t],t===0?s=0:s=e[t-1],n>=s&&n<r){o=t;break}t++,i--}return o}function Ga(e,n){let t=e.length-1;return n<0?-1:n<e[0]?0:n>e[e.length-1]?Number.POSITIVE_INFINITY:(e.length<40||n<=e[20]||n>=e[t-20]?t=ks(e,n):t=Ps(e,n),t)}function Va(e){const n=new Blob([e],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Fs=(e=>(e[e.DEFAULT_SERIES=0]="DEFAULT_SERIES",e[e.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",e))(Fs||{}),he=(e=>(e[e.NONE=0]="NONE",e[e.THIN=1]="THIN",e[e.HAIR=2]="HAIR",e[e.DOTTED=3]="DOTTED",e[e.DASHED=4]="DASHED",e[e.DASH_DOT=5]="DASH_DOT",e[e.DASH_DOT_DOT=6]="DASH_DOT_DOT",e[e.DOUBLE=7]="DOUBLE",e[e.MEDIUM=8]="MEDIUM",e[e.MEDIUM_DASHED=9]="MEDIUM_DASHED",e[e.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",e[e.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",e[e.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",e[e.THICK=13]="THICK",e))(he||{}),Hs=(e=>(e.TOP="top",e.BOTTOM="bottom",e.LEFT="left",e.RIGHT="right",e.NONE="none",e.ALL="all",e.OUTSIDE="outside",e.INSIDE="inside",e.HORIZONTAL="horizontal",e.VERTICAL="vertical",e.TLBR="tlbr",e.TLBC_TLMR="tlbc_tlmr",e.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",e.BLTR="bl_tr",e.MLTR_BCTR="mltr_bctr",e))(Hs||{}),qe=(e=>(e[e.UNSUPPORTED=0]="UNSUPPORTED",e[e.RGB=1]="RGB",e[e.HEX=2]="HEX",e[e.THEME=3]="THEME",e))(qe||{}),js=(e=>(e[e.ON=0]="ON",e[e.OFF=1]="OFF",e))(js||{}),$s=(e=>(e[e.PASTE_NORMAL=0]="PASTE_NORMAL",e[e.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",e[e.PASTE_FORMAT=2]="PASTE_FORMAT",e[e.PASTE_FORMULA=3]="PASTE_FORMULA",e[e.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",e[e.PASTE_VALUES=5]="PASTE_VALUES",e[e.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",e[e.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",e))($s||{}),Ws=(e=>(e[e.DOCUMENT=0]="DOCUMENT",e[e.PROJECT=1]="PROJECT",e))(Ws||{}),Bs=(e=>(e[e.COLUMNS=0]="COLUMNS",e[e.ROWS=1]="ROWS",e))(Bs||{}),Gs=(e=>(e[e.UP=0]="UP",e[e.RIGHT=1]="RIGHT",e[e.DOWN=2]="DOWN",e[e.LEFT=3]="LEFT",e))(Gs||{});function Ka(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var Vs=(e=>(e[e.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",e[e.TEXT=1]="TEXT",e[e.NUMBER=2]="NUMBER",e[e.PERCENT=3]="PERCENT",e[e.CURRENCY=4]="CURRENCY",e[e.DATE=5]="DATE",e[e.TIME=6]="TIME",e[e.DATE_TIME=7]="DATE_TIME",e[e.SCIENTIFIC=8]="SCIENTIFIC",e))(Vs||{}),Ks=(e=>(e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",e[e.MIN=1]="MIN",e[e.MAX=2]="MAX",e[e.NUMBER=3]="NUMBER",e[e.PERCENT=4]="PERCENT",e[e.PERCENTILE=5]="PERCENTILE",e))(Ks||{}),Pt=(e=>(e.EN_US="enUS",e.ZH_CN="zhCN",e.RU_RU="ruRU",e.ZH_TW="zhTW",e.VI_VN="viVN",e))(Pt||{}),zs=(e=>(e[e.RANGE=0]="RANGE",e[e.SHEET=1]="SHEET",e))(zs||{}),Ys=(e=>(e[e.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",e[e.PAST_YEAR=1]="PAST_YEAR",e[e.PAST_MONTH=2]="PAST_MONTH",e[e.PAST_WEEK=3]="PAST_WEEK",e[e.YESTERDAY=4]="YESTERDAY",e[e.TODAY=5]="TODAY",e[e.TOMORROW=6]="TOMORROW",e))(Ys||{}),Hn=(e=>(e[e.GRID=0]="GRID",e[e.KANBAN=1]="KANBAN",e[e.GANTT=2]="GANTT",e))(Hn||{}),on=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",e[e.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",e))(on||{}),Xs=(e=>(e[e.DASH=0]="DASH",e[e.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",e[e.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",e[e.DASHED_HEAVY=3]="DASHED_HEAVY",e[e.DASH_LONG=4]="DASH_LONG",e[e.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",e[e.DOT_DASH=6]="DOT_DASH",e[e.DOT_DOT_DASH=7]="DOT_DOT_DASH",e[e.DOTTED=8]="DOTTED",e[e.DOTTED_HEAVY=9]="DOTTED_HEAVY",e[e.DOUBLE=10]="DOUBLE",e[e.NONE=11]="NONE",e[e.SINGLE=12]="SINGLE",e[e.THICK=13]="THICK",e[e.WAVE=14]="WAVE",e[e.WAVY_DOUBLE=15]="WAVY_DOUBLE",e[e.WAVY_HEAVY=16]="WAVY_HEAVY",e[e.WORDS=17]="WORDS",e))(Xs||{}),Dt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LEFT=1]="LEFT",e[e.CENTER=2]="CENTER",e[e.RIGHT=3]="RIGHT",e[e.JUSTIFIED=4]="JUSTIFIED",e))(Dt||{}),Wt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.TOP=1]="TOP",e[e.MIDDLE=2]="MIDDLE",e[e.BOTTOM=3]="BOTTOM",e))(Wt||{}),Bt=(e=>(e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.OVERFLOW=1]="OVERFLOW",e[e.CLIP=2]="CLIP",e[e.WRAP=3]="WRAP",e))(Bt||{}),Tn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ITALIC=1]="ITALIC",e))(Tn||{}),yn=(e=>(e[e.NORMAL=0]="NORMAL",e[e.BOLD=1]="BOLD",e))(yn||{}),Gt=(e=>(e[e.NORMAL=1]="NORMAL",e[e.SUBSCRIPT=2]="SUBSCRIPT",e[e.SUPERSCRIPT=3]="SUPERSCRIPT",e))(Gt||{}),K=(e=>(e[e.FALSE=0]="FALSE",e[e.TRUE=1]="TRUE",e))(K||{}),Mt=(e=>(e[e.STRING=1]="STRING",e[e.NUMBER=2]="NUMBER",e[e.BOOLEAN=3]="BOOLEAN",e[e.FORCE_STRING=4]="FORCE_STRING",e))(Mt||{}),He=(e=>(e[e.DARK1=0]="DARK1",e[e.LIGHT1=1]="LIGHT1",e[e.DARK2=2]="DARK2",e[e.LIGHT2=3]="LIGHT2",e[e.ACCENT1=4]="ACCENT1",e[e.ACCENT2=5]="ACCENT2",e[e.ACCENT3=6]="ACCENT3",e[e.ACCENT4=7]="ACCENT4",e[e.ACCENT5=8]="ACCENT5",e[e.ACCENT6=9]="ACCENT6",e[e.HYPERLINK=10]="HYPERLINK",e[e.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",e))(He||{}),jn=(e=>(e.OFFICE="Office",e.OFFICE_2007_2010="Office 2007-2010",e.GRAYSCALE="Grayscale",e.BLUE_WARM="Blue Warm",e.BLUE="Blue",e.BLUE_II="Blue II",e.BLUE_GREEN="Blue Green",e.GREEN="Green",e.GREEN_YELLOW="Green Yellow",e.YELLOW="Yellow",e.YELLOW_ORANGE="Yellow Orange",e.ORANGE="Orange",e.ORANGE_RED="Orange Red",e.RED_ORANGE="Red Orange",e.RED="Red",e.RED_VIOLET="Red Violet",e.VIOLET="Violet",e.VIOLET_II="Violet II",e.MEDIAN="Median",e.PAPER="Paper",e.MARQUEE="Marquee",e.SLIPSTREAM="Slipstream",e.Aspect="Aspect",e))(jn||{}),Qs=(e=>(e.Line="line",e.LineInv="lineInv",e.Triangle="triangle",e.RtTriangle="rtTriangle",e.Rect="rect",e.Diamond="diamond",e.Parallelogram="parallelogram",e.Trapezoid="trapezoid",e.NonIsocelesTrapezoid="nonIsocelesTrapezoid",e.Pentagon="pentagon",e.Hexagon="hexagon",e.Heptagon="heptagon",e.Octagon="octagon",e.Decagon="decagon",e.Dodecagon="dodecagon",e.Star4="star4",e.Star5="star5",e.Star6="star6",e.Star7="star7",e.Star8="star8",e.Star10="star10",e.Star12="star12",e.Star16="star16",e.Star24="star24",e.Star32="star32",e.RoundRect="roundRect",e.Round1Rect="round1Rect",e.Round2SameRect="round2SameRect",e.Round2DiagRect="round2DiagRect",e.Ellipse="ellipse",e))(Qs||{}),qs=(e=>(e.RightArrow="rightArrow",e.LeftArrow="leftArrow",e.UpArrow="upArrow",e.DownArrow="downArrow",e.LeftRightArrow="leftRightArrow",e.UpDownArrow="upDownArrow",e.QuadArrow="quadArrow",e.LeftRightUpArrow="leftRightUpArrow",e.BentArrow="bentArrow",e.UturnArrow="uturnArrow",e.CircularArrow="circularArrow",e.NotchedRightArrow="notchedRightArrow",e.HomePlate="homePlate",e.Chevron="chevron",e.LeftCircularArrow="leftCircularArrow",e.LeftRightCircularArrow="leftRightCircularArrow",e))(qs||{}),Zs=(e=>(e.Plaque="plaque",e.Can="can",e.Cube="cube",e.Bevel="bevel",e.Donut="donut",e.NoSmoking="noSmoking",e.BlockArc="blockArc",e.FoldedCorner="foldedCorner",e))(Zs||{}),Js=(e=>(e.SmileyFace="smileyFace",e.Heart="heart",e.LightningBolt="lightningBolt",e.Sun="sun",e.Moon="moon",e.Cloud="cloud",e.Arc="arc",e.Backpack="backpack",e.Frame="frame",e.HalfFrame="halfFrame",e.Corner="corner",e.Chord="chord",e.Pie="pie",e.Teardrop="teardrop",e.WedgeRectCallout="wedgeRectCallout",e.WedgeRRectCallout="wedgeRRectCallout",e.WedgeEllipseCallout="wedgeEllipseCallout",e.CloudCallout="cloudCallout",e.BorderCallout1="borderCallout1",e.BorderCallout2="borderCallout2",e.BorderCallout3="borderCallout3",e.AccentCallout1="accentCallout1",e.AccentCallout2="accentCallout2",e.AccentCallout3="accentCallout3",e.Callout1="callout1",e.Callout2="callout2",e.Callout3="callout3",e.ActionButtonBackPrevious="actionButtonBackPrevious",e.ActionButtonEnd="actionButtonEnd",e.ActionButtonForwardNext="actionButtonForwardNext",e.ActionButtonHelp="actionButtonHelp",e.ActionButtonHome="actionButtonHome",e.ActionButtonInformation="actionButtonInformation",e.ActionButtonMovie="actionButtonMovie",e.ActionButtonReturn="actionButtonReturn",e.ActionButtonSound="actionButtonSound",e))(Js||{});const eo={[jn.OFFICE]:{[He.ACCENT1]:"#4472C4",[He.ACCENT2]:"#ED7D31",[He.ACCENT3]:"#A5A5A5",[He.ACCENT4]:"#70AD47",[He.ACCENT5]:"#5B9BD5",[He.ACCENT6]:"#70AD47",[He.DARK1]:"#000000",[He.DARK2]:"#44546A",[He.LIGHT1]:"#FFFFFF",[He.LIGHT2]:"#E7E6E6",[He.HYPERLINK]:"#0563C1",[He.FOLLOWED_HYPERLINK]:"#954F72"}};class $n{constructor(){_(this,"_themeValue",He.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=qe.UNSUPPORTED,this._themeColors=jn.OFFICE,this._themeTint=0}asRgbColor(){return new Dn(this._rgbValue,this)}asThemeColor(){return new Mn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case qe.THEME:return this.asThemeColor();case qe.RGB:return this.asRgbColor();case qe.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=qe.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=qe.THEME,this._themeColors=n}setThemeTint(n){this._colorType=qe.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=qe.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class Ut{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 t=+`0x${n[0]}${n[1]}`,r=+`0x${n[2]}${n[3]}`,s=+`0x${n[4]}${n[5]}`;return new $n().setRgbColor(`rgb(${t},${r},${s})`).asRgbColor()}static hexToRgbString(n){const t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(t,(o,i,a,l)=>i+i+a+a+l+l);const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let s=null;if(r){const o=Number.parseInt(r[1],16),i=Number.parseInt(r[2],16),a=Number.parseInt(r[3],16);s=`rgba(${o},${i},${a})`}return s}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Ut(this._builder)}equals(n){return!1}}class to{constructor(n){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const t=n.getRed()/255,r=n.getGreen()/255,s=n.getBlue()/255,o=n.getAlpha()/255,i=Math.min(t,Math.min(r,s)),a=Math.max(t,Math.max(r,s)),l=a-i;if(a===i){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(i+a)/2,this._lightness<.5?this._saturation=l/(a+i):this._saturation=l/(2-a-i),t===a&&(this._hue=(r-s)/l),r===a&&(this._hue=2+(s-t)/l),s===a&&(this._hue=4+(t-r)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=o}asRgbColor(){const n=new $n;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let t;this._lightness<.5?t=this._lightness*(1+this._saturation):t=this._lightness+this._saturation-this._lightness*this._saturation;const r=2*this._lightness-t,s=this._hue/360,o=s+1/3,i=this.setColor(t,r,o),a=this.setColor(t,r,s),l=s-1/3,h=this.setColor(t,r,l);return n.setRgbColor(`rgba(${Math.round(i*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,t,r){r<0&&(r+=1),r>1&&(r-=1);let s;return 6*r<1?s=t+(n-t)*6*r:2*r<1?s=n:3*r<2?s=t+(n-t)*(2/3-r)*6:s=t,s}setLightness(n){this._lightness=n}}const Qe=class Qe extends Ut{constructor(t,r){super(r);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let s=t.match(Qe.RGBA_EXTRACT);if(s){const o=+s[1],i=+s[2],a=+s[3],l=+s[4];this._cssString=t,this._red=o,this._green=i,this._blue=a,this._alpha=l;return}if(s=t.match(Qe.RGB_EXTRACT),s){const o=+s[1],i=+s[2],a=+s[3];this._cssString=t,this._red=o,this._green=i,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return Ut.rgbColorToHexValue(this)}getRed(){let t=this._red+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getGreen(){let t=this._green+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getBlue(){let t=this._blue+Qe.RGB_COLOR_AMT;return t>255?t=255:t<0&&(t=0),t}getAlpha(){return this._alpha}getColorType(){return qe.RGB}clone(){return new Qe(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(t){return t instanceof Qe?t._red===this._red&&t._blue===this._blue&&t._green===this._green&&t._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(Qe,"RGB_COLOR_AMT",0),_(Qe,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(Qe,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let Dn=Qe;const Ct=class Ct extends Ut{constructor(t,r,s,o){super(o);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=t,this._themeTint=r,this._themeColors=s}lumValue(t,r){if(t==null)return r;let s;return t<0?s=r*(1+t):s=r*(1-t)+(255-255*(1-t)),s}asRgbColor(){const t=eo[this._themeColors];if(t==null)throw new Error("not find themeColors type");const r=t[this._themeColorType];if(r==null)throw new Error("not find themeColors value");let s;if(Ct._cacheThemeColor.has(this._themeColors)){if(s=Ct._cacheThemeColor.get(this._themeColors),s.has(this._themeColorType))return s.get(this._themeColorType)}else s=new Map,Ct._cacheThemeColor.set(this._themeColors,s);const o=new to(Ut.hexValueToRgbColor(r));o.setLightness(this.lumValue(this._themeTint,o.getLightness()*255)/255);const i=o.asRgbColor();return s.set(this._themeColorType,i),i}clone(){return new Ct(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(t){return t instanceof Ct?t._themeColorType===this._themeColorType:!1}getColorType(){return qe.THEME}getThemeColorType(){return this._themeColorType}};_(Ct,"_cacheThemeColor",new Map);let Mn=Ct;const za="rgb(",Ya="rgba(",lr={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 rt{constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof rt){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const t=no(n);if(t==null){this._setNullColor();return}this._color=t;const r=Ja(this._color);if(r==null){this._setNullColor();return}this._rgbColor=r,this._isValid=!0}static mix(n,t,r){var h,c;r=Math.min(1,Math.max(0,r));const s=new rt(n).toRgb(),o=new rt(t).toRgb(),i=(h=s.a)!=null?h:1,a=(c=o.a)!=null?c:1,l={r:(o.r-s.r)*r+s.r,g:(o.g-s.g)*r+s.g,b:(o.b-s.b)*r+s.b,a:(a-i)*r+i};return new rt(l)}static getContrastRatio(n,t){const r=new rt(n).getLuminance(),s=new rt(t).getLuminance();return(Math.max(r,s)+.05)/(Math.min(r,s)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:t,b:r,a:s=1}=this.toRgb(),o=s<1;return`rgb${o?"a":""}(${n},${t},${r}${o?`,${s}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:t,g:r,b:s,a:o=1}=this.toRgb(),i=o<1,a=[pn(Math.round(t).toString(16)),pn(Math.round(r).toString(16)),pn(Math.round(s).toString(16)),pn(Math.round(o*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]?i?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:i?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return rl(this.toRgb())}toHsl(){return nl(this.toRgb())}lighten(n=10){const t=this.toHsl();return t.l+=n,t.l=Math.min(Math.max(t.l,0),100),new rt(t)}darken(n=10){const t=this.toHsl();return t.l-=n,t.l=Math.min(Math.max(t.l,0),100),new rt(t)}setAlpha(n){return new rt({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:t,b:r}=this.toRgb();return n=er(n),t=er(t),r=er(r),Number((.2126*n+.7152*t+.0722*r).toFixed(3))}getBrightness(){const{r:n,g:t,b:r}=this.toRgb();return(n*299+t*587+r*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 pn=e=>e.length===1?`0${e}`:e,er=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),no=e=>{if(ol(e)){if("r"in e){const r={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(r.a=e.a),r}if("l"in e){const r={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(r.a=e.a),r}const t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}const n=e.trim();if(lr[n]){const t=lr[n],r={r:Math.round(t[0]),g:Math.round(t[1]),b:Math.round(t[2])};return r.a=t[3]||1,r}if(n.startsWith("#"))return Xa(n);if(n.startsWith("rgb"))return Qa(n);if(n.startsWith("hsl"))return qa(n);if(n.startsWith("hsv"))return Za(n)},Xa=e=>{const n=e.substring(1),t=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let r=n.match(t);if(!r||r.length<3)throw new Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(o=>o+o));const s={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(s.a=Number.parseInt(r[3],16)/255),s},Qa=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal rgb color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal rgb color`);const r={r:Number.parseInt(t[0],10),g:Number.parseInt(t[1],10),b:Number.parseInt(t[2],10)};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},qa=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsl color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsl color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),l:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Za=e=>{const n=e.indexOf("(");if(n===-1)throw new Error(`The color '${e}' is illegal hsv color`);const t=e.substring(n+1,e.length-1).split(",");if(t.length<3)throw new Error(`The color '${e}' is illegal hsv color`);const r={h:Number.parseInt(t[0],10),s:Number.parseFloat(t[1]),v:Number.parseFloat(t[2])};return t.length>3&&(r.a=Number.parseFloat(t[3])),r},Ja=e=>{const n=no(e);if(n!=null)return"r"in n?n:"l"in n?el(n):tl(n)},tr=(e,n,t)=>(t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+(n-e)*6*t:t<1/2?n:t<2/3?e+(n-e)*(2/3-t)*6:e),el=e=>{let{h:n,s:t,l:r}=e;n/=360,t/=100,r/=100;let s=0,o=0,i=0;if(t===0)s=o=i=r;else{const l=r<.5?r*(1+t):r+t-r*t,h=2*r-l;s=tr(h,l,n+1/3),o=tr(h,l,n),i=tr(h,l,n-1/3)}const a={r:Math.round(s*255),g:Math.round(o*255),b:Math.round(i*255)};return e.a!==void 0&&(a.a=e.a),a},tl=e=>{let{h:n,s:t,v:r}=e;n=n/360*6,t/=100,r/=100;const s=Math.floor(n),o=n-s,i=r*(1-t),a=r*(1-o*t),l=r*(1-(1-o)*t),h=s%6,c=[r,a,i,i,l,r][h],u=[l,r,r,a,i,i][h],d=[i,i,l,r,r,a][h],f={r:c*255,g:u*255,b:d*255};return e.a!==void 0&&(f.a=e.a),f},nl=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),o=Math.min(n,t,r),i=(s+o)/2;let a,l;if(s===o)a=l=0;else{const c=s-o;switch(l=i>.5?c/(2-s-o):c/(s+o),s){case n:a=(t-r)/c+(t<r?6:0);break;case t:a=(r-n)/c+2;break;default:a=(n-t)/c+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(i*100)};return e.a!==void 0&&(h.a=e.a),h},rl=e=>{let{r:n,g:t,b:r}=e;n/=255,t/=255,r/=255;const s=Math.max(n,t,r),o=Math.min(n,t,r);let i;const a=s,l=s-o,h=s===0?0:l/s;if(s===o)i=0;else{switch(s){case n:i=(t-r)/l+(t<r?6:0);break;case t:i=(r-n)/l+2;break;default:i=(n-t)/l+4;break}i/=6}const c={h:Math.round(i*360),s:Math.round(h*100),v:Math.round(a*100)};return e.a!==void 0&&(c.a=e.a),c},sl=e=>e==null,ol=e=>!sl(e)&&typeof e=="object";function il(e){const n=/^#(?:[0]{3}|[0]{6})\b/,t=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,r=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,o=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||o.test(e))}function al(e){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,t=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,r=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,s=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,o=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(e)||t.test(e)||r.test(e)||s.test(e)||o.test(e))}var ke=(e=>(e[e.COVER=0]="COVER",e[e.REPLACE=1]="REPLACE",e[e.INTERSECTION=2]="INTERSECTION",e))(ke||{});function ll(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.si!==void 0)}function ul(e){if(e.t!==void 0)return e.t;if(typeof e.v=="string")return Mt.STRING;if(typeof e.v=="number")return Mt.NUMBER;if(typeof e.v=="boolean")return Mt.BOOLEAN}function cl(e){if(e==null)return!0;const{v:n,f:t,si:r,p:s,s:o,custom:i}=e;return!(!(n==null||typeof n=="string"&&n.length===0)||t!=null&&t.length>0||r!=null&&r.length>0||s!=null||i!=null)}function hl(e){return e!=null&&(typeof e=="string"||typeof e=="number"||typeof e=="boolean")}var ro=(e=>(e[e.character=0]="character",e[e.paragraph=1]="paragraph",e[e.table=2]="table",e[e.numbering=3]="numbering",e))(ro||{}),so=(e=>(e[e.TAB=0]="TAB",e[e.SPACE=1]="SPACE",e[e.NOTHING=2]="NOTHING",e))(so||{}),Jt=(e=>(e[e.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.DECIMAL=2]="DECIMAL",e[e.ZERO_DECIMAL=3]="ZERO_DECIMAL",e[e.UPPER_ALPHA=4]="UPPER_ALPHA",e[e.ALPHA=5]="ALPHA",e[e.UPPER_ROMAN=6]="UPPER_ROMAN",e[e.ROMAN=7]="ROMAN",e))(Jt||{}),Rt=(e=>(e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Rt||{}),oo=(e=>(e[e.HYPERLINK=0]="HYPERLINK",e[e.FIELD=1]="FIELD",e[e.SDT=2]="SDT",e[e.BOOKMARK=3]="BOOKMARK",e[e.COMMENT=4]="COMMENT",e[e.CUSTOM=5]="CUSTOM",e[e.MENTION=6]="MENTION",e[e.UNI_FORMULA=7]="UNI_FORMULA",e))(oo||{}),io=(e=>(e[e.COMMENT=0]="COMMENT",e))(io||{}),ao=(e=>(e[e.DRAWING=0]="DRAWING",e[e.CUSTOM=1]="CUSTOM",e))(ao||{}),lo=(e=>(e[e.TRADITIONAL=0]="TRADITIONAL",e[e.MODERN=1]="MODERN",e))(lo||{}),uo=(e=>(e[e.DEFAULT=0]="DEFAULT",e[e.LINES=1]="LINES",e[e.LINES_AND_CHARS=2]="LINES_AND_CHARS",e[e.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",e))(uo||{}),co=(e=>(e[e.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",e[e.CONTINUOUS=1]="CONTINUOUS",e[e.NEXT_PAGE=2]="NEXT_PAGE",e[e.EVEN_PAGE=3]="EVEN_PAGE",e[e.ODD_PAGE=4]="ODD_PAGE",e))(co||{}),ho=(e=>(e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",e[e.NONE=1]="NONE",e[e.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",e))(ho||{}),fo=(e=>(e[e.NORMAL=0]="NORMAL",e[e.TBRL=1]="TBRL",e[e.LRTBV=2]="LRTBV",e))(fo||{}),_o=(e=>(e[e.TEXT_RUN=0]="TEXT_RUN",e[e.AUTO_TEXT=1]="AUTO_TEXT",e[e.PAGE_BREAK=2]="PAGE_BREAK",e[e.COLUMN_BREAK=3]="COLUMN_BREAK",e[e.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",e[e.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",e[e.EQUATION=6]="EQUATION",e[e.DRAWING=7]="DRAWING",e[e.PERSON=8]="PERSON",e[e.RICH_LINK=9]="RICH_LINK",e))(_o||{}),go=(e=>(e[e.BOTH_SIDES=0]="BOTH_SIDES",e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.LARGEST=3]="LARGEST",e))(go||{}),po=(e=>(e[e.INLINE=0]="INLINE",e[e.WRAP_NONE=1]="WRAP_NONE",e[e.WRAP_POLYGON=2]="WRAP_POLYGON",e[e.WRAP_SQUARE=3]="WRAP_SQUARE",e[e.WRAP_THROUGH=4]="WRAP_THROUGH",e[e.WRAP_TIGHT=5]="WRAP_TIGHT",e[e.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",e))(po||{}),mo=(e=>(e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",e[e.NORMAL_TEXT=1]="NORMAL_TEXT",e[e.TITLE=2]="TITLE",e[e.SUBTITLE=3]="SUBTITLE",e[e.HEADING_1=4]="HEADING_1",e[e.HEADING_2=5]="HEADING_2",e[e.HEADING_3=6]="HEADING_3",e[e.HEADING_4=7]="HEADING_4",e[e.HEADING_5=8]="HEADING_5",e[e.HEADING_6=9]="HEADING_6",e))(mo||{}),Eo=(e=>(e[e.AUTO=0]="AUTO",e[e.AT_LEAST=1]="AT_LEAST",e[e.EXACT=2]="EXACT",e))(Eo||{}),Ro=(e=>(e[e.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",e[e.SOLID=1]="SOLID",e[e.DOT=2]="DOT",e[e.DASH=3]="DASH",e))(Ro||{}),Co=(e=>(e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",e[e.START=1]="START",e[e.CENTER=2]="CENTER",e[e.END=3]="END",e))(Co||{}),Io=(e=>(e.EVENLY_DISTRIBUTED="0",e.FIXED_WIDTH="1",e))(Io||{}),vo=(e=>(e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",e[e.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",e[e.TOP=2]="TOP",e[e.MIDDLE=3]="MIDDLE",e[e.BOTTOM=4]="BOTTOM",e))(vo||{}),Oo=(e=>(e.NORMAL="normal",e.BOLD="bold",e.ITALIC="italic",e))(Oo||{}),So=(e=>(e[e.PAGE=0]="PAGE",e[e.COLUMN=1]="COLUMN",e[e.CHARACTER=2]="CHARACTER",e[e.MARGIN=3]="MARGIN",e[e.INSIDE_MARGIN=4]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",e[e.LEFT_MARGIN=6]="LEFT_MARGIN",e[e.RIGHT_MARGIN=7]="RIGHT_MARGIN",e))(So||{}),No=(e=>(e[e.PAGE=0]="PAGE",e[e.PARAGRAPH=1]="PARAGRAPH",e[e.LINE=2]="LINE",e[e.MARGIN=3]="MARGIN",e[e.TOP_MARGIN=4]="TOP_MARGIN",e[e.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",e[e.INSIDE_MARGIN=6]="INSIDE_MARGIN",e[e.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",e))(No||{}),wo=(e=>(e[e.POINT=0]="POINT",e[e.LINE=1]="LINE",e[e.CHARACTER=2]="CHARACTER",e[e.PIXEL=3]="PIXEL",e))(wo||{}),bo=(e=>(e[e.CENTER=0]="CENTER",e[e.INSIDE=1]="INSIDE",e[e.LEFT=2]="LEFT",e[e.OUTSIDE=3]="OUTSIDE",e[e.RIGHT=4]="RIGHT",e[e.BOTH=5]="BOTH",e[e.DISTRIBUTE=6]="DISTRIBUTE",e))(bo||{}),Ao=(e=>(e[e.BOTTOM=0]="BOTTOM",e[e.CENTER=1]="CENTER",e[e.INSIDE=2]="INSIDE",e[e.OUTSIDE=3]="OUTSIDE",e[e.TOP=4]="TOP",e))(Ao||{}),To=(e=>(e[e.compressPunctuation=0]="compressPunctuation",e[e.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",e[e.doNotCompress=2]="doNotCompress",e))(To||{}),yo=(e=>(e[e.PORTRAIT=0]="PORTRAIT",e[e.LANDSCAPE=1]="LANDSCAPE",e))(yo||{}),Do=(e=>(e[e.forward=0]="forward",e[e.backward=1]="backward",e[e.front=2]="front",e[e.back=3]="back",e))(Do||{}),Mo=(e=>(e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e[e.DRAWING_IMAGE=0]="DRAWING_IMAGE",e[e.DRAWING_SHAPE=1]="DRAWING_SHAPE",e[e.DRAWING_CHART=2]="DRAWING_CHART",e[e.DRAWING_TABLE=3]="DRAWING_TABLE",e[e.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",e[e.DRAWING_VIDEO=5]="DRAWING_VIDEO",e[e.DRAWING_GROUP=6]="DRAWING_GROUP",e[e.DRAWING_UNIT=7]="DRAWING_UNIT",e[e.DRAWING_DOM=8]="DRAWING_DOM",e))(Mo||{}),oe=(e=>(e[e.NORMAL=0]="NORMAL",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(oe||{}),Se=(e=>(e[e.NONE=0]="NONE",e[e.ROW=1]="ROW",e[e.COLUMN=2]="COLUMN",e[e.ALL=3]="ALL",e))(Se||{});function dl(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}function fl(e,n,t){let r=!1,s=!1,o=e,i=n,a=e,l=n;if(t==null)return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:o,endColumn:i,startRow:a,startColumn:l};for(let h=0;h<t.length;h++){const{startRow:c,endRow:u,startColumn:d,endColumn:f}=t[h];if(e===c&&n===d){o=u,i=f,a=c,l=d,s=!0;break}if(e>=c&&e<=u&&n>=d&&n<=f){o=u,i=f,a=c,l=d,r=!0;break}}return{actualRow:e,actualColumn:n,isMergedMainCell:s,isMerged:r,endRow:o,endColumn:i,startRow:a,startColumn:l}}var yr=(e=>(e[e.SLIDE=0]="SLIDE",e[e.MASTER=1]="MASTER",e[e.LAYOUT=2]="LAYOUT",e[e.HANDOUT_MASTER=3]="HANDOUT_MASTER",e[e.NOTES_MASTER=4]="NOTES_MASTER",e))(yr||{}),Uo=(e=>(e[e.SHAPE=0]="SHAPE",e[e.IMAGE=1]="IMAGE",e[e.TEXT=2]="TEXT",e[e.SPREADSHEET=3]="SPREADSHEET",e[e.DOCUMENT=4]="DOCUMENT",e[e.SLIDE=5]="SLIDE",e))(Uo||{}),Lo=(e=>(e[e.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",e[e.NEXT_SLIDE=1]="NEXT_SLIDE",e[e.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",e[e.FIRST_SLIDE=3]="FIRST_SLIDE",e[e.LAST_SLIDE=4]="LAST_SLIDE",e))(Lo||{});const _l="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let gl=e=>crypto.getRandomValues(new Uint8Array(e)),pl=(e,n,t)=>{let r=(2<<Math.log(e.length-1)/Math.LN2)-1,s=-~(1.6*r*n/e.length);return(o=n)=>{let i="";for(;;){let a=t(s),l=s;for(;l--;)if(i+=e[a[l]&r]||"",i.length===o)return i}}},ml=(e,n=21)=>pl(e,n,gl),El=(e=21)=>{let n="",t=crypto.getRandomValues(new Uint8Array(e));for(;e--;)n+=_l[t[e]&63];return n};const Rl=new Set(["ac","ad","ae","aero","af","ag","ai","al","am","ao","aq","ar","arpa","as","asia","at","au","aw","ax","az","ba","bb","bd","be","bf","bg","bh","bi","biz","bj","bm","bn","bo","br","bs","bt","bv","bw","by","bz","ca","cat","cc","cd","cf","cg","ch","ci","ck","cl","cm","cn","co","com","coop","cr","cu","cv","cw","cx","cy","cz","de","dj","dk","dm","do","dz","ec","edu","ee","eg","er","es","et","eu","fi","fj","fk","fm","fo","fr","ga","gb","gd","ge","gf","gg","gh","gi","gl","gm","gn","gov","gp","gq","gr","gs","gt","gu","gw","gy","hk","hm","hn","hr","ht","hu","id","ie","il","im","in","info","int","io","iq","ir","is","it","je","jm","jo","jobs","jp","ke","kg","kh","ki","km","kn","kp","kr","kw","ky","kz","la","lb","lc","li","lk","lr","ls","lt","lu","lv","ly","ma","mc","md","me","mg","mh","mil","mk","ml","mm","mn","mo","mobi","mp","mq","mr","ms","mt","mu","museum","mv","mw","mx","my","mz","na","name","nc","ne","net","nf","ng","ni","nl","no","np","nr","nu","nz","om","onion","org","pa","pe","pf","pg","ph","pk","pl","pm","pn","post","pr","pro","ps","pt","pw","py","qa","re","ro","rs","ru","rw","sa","sb","sc","sd","se","sg","sh","si","sj","sk","sl","sm","sn","so","sr","ss","st","su","sv","sx","sy","sz","tc","td","tel","tf","tg","th","tj","tk","tl","tm","tn","to","tr","tt","tv","tw","tz","ua","ug","uk","us","uy","uz","va","vc","ve","vg","vi","vn","vu","wf","ws","yt","za","zm","zw"]),Cl=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 Il(e){if(!Number.isNaN(+e))return!1;if(e.startsWith("http://localhost:3002")||e.startsWith("localhost:3002"))return!0;if(Cl.test(e)){if(xo(e))return!0;try{const r=new URL(Po(e)).hostname.split(".").pop();if(r&&Rl.has(r))return!0}catch{return!1}}return!1}function xo(e){return/^[a-zA-Z]+:\/\//.test(e)}function vl(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function Po(e){return xo(e)?e:vl(e)?`mailto://${e}`:`https://${e}`}const Ol=/^-ms-/,Sl=/-([a-z])/g,Et=["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 t="",r=n;for(;r>=Et.length;)r/=Et.length,r-=1,t+=Et[r%Et.length];const s=n%Et.length;return t+=Et[s],t}static indexAt(n){let t=0;for(let r=0;r<n.length-1;r+=1){const s=n.charCodeAt(r)-65,o=n.length-1-r;t+=Et.length**o+Et.length*s}return t+=n.charCodeAt(n.length-1)-65,t}static deleteBlank(n){return x.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,t=navigator.platform==="Win32"||navigator.platform==="Windows",r=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(r)return"Mac";if(navigator.platform==="X11"&&!t&&!r)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(t){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,t=n.indexOf("Opera")>-1,r=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!t,s=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,o=n.indexOf("Edge")>-1,i=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(r){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 i?"FF":t?"Opera":a?"Safari":l?"Chrome":o?"Edge":s?"IE11":"Unknown browser"}static generateRandomId(n=21,t){return ko(n,t)}static getClassName(n){return n.constructor.name}static deepMerge(n,...t){t.forEach(i=>i&&o(i));function r(i,a){i.forEach((l,h)=>{var c,u;if(x.isArray(l)){const d=(c=a[h])!=null?c:[];a[h]=d,r(l,d);return}if(x.isObject(l)){const d=(u=a[h])!=null?u:{};a[h]=d,s(l,d);return}a[h]=l})}function s(i,a){Object.keys(i).forEach(l=>{var c,u;const h=i[l];if(x.isObject(h)){const d=(c=a[l])!=null?c:{};a[l]=d,s(h,d);return}if(x.isArray(h)){const d=(u=a[l])!=null?u:[];a[l]=d,r(h,d);return}a[l]=h})}function o(i){Object.keys(i).forEach(a=>{var h,c;const l=i[a];if(x.isArray(l)){const u=(h=n[a])!=null?h:[];n[a]=u,r(l,u);return}if(x.isObject(l)){const u=(c=n[a])!=null?c:{};n[a]=u,s(l,u);return}n[a]=l})}return n}static numberFixed(n,t){return Number(Number(n).toFixed(t))}static diffValue(n,t){function r(i,a){const l=x.getValueType(i),h=x.getValueType(a);return l!==h?!1:x.isArray(i)?s(i,a):x.isObject(i)?o(i,a):x.isDate(i)?i.getTime()===a.getTime():x.isRegExp(i)?i.toString()===a.toString():i===a}function s(i,a){if(n.length!==t.length)return!1;for(let l=0,h=i.length;l<h;l++){const c=i[l],u=a[l];if(!r(c,u))return!1}return!0}function o(i,a){const l=Object.keys(i),h=Object.keys(a);if(l.length!==h.length)return!1;for(const c of l){if(!h.includes(c))return!1;const u=i[c],d=a[c];if(!r(u,d))return!1}return!0}return r(n,t)}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 t=[];return n.forEach((r,s)=>{t[s]=x.deepClone(r)}),t}if(this.isObject(n)){const t={};return Object.keys(n).forEach(r=>{const s=n[r];t[r]=x.deepClone(s)}),Object.setPrototypeOf(t,Object.getPrototypeOf(n)),t}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,t){return n instanceof t}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 t in n)return!1;return!0}static isMobile(){let n=0,t=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(t=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&t<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 Il(n)}static normalizeUrl(n){return Po(n)}static itCount(n){return t=>{for(let r=0;r<n;r++)t&&t()}}static hasLength(n,t){return x.isDefine(n)?x.isDefine(t)?n.length===t:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,t){return t.toUpperCase()}static camelCase(n){return n.replace(Ol,"ms-").replace(Sl,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(t=>{const r=n[t];r==null?delete n[t]:x.removeNull(r)}),n}static fillTwoDimensionalArray(n,t,r){return new Array(n).fill(r).map(s=>new Array(t).fill(r))}static numToWord(n){let t="";for(;n>0;){let r=n%26;r=r===0?r=26:r,t=String.fromCharCode(96+r)+t,n=(n-r)/26}return t.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const t=n.toLowerCase().split(""),r=t.length;let s=0,o=0;for(let i=0;i<r;i++)o=t[i].charCodeAt(0)-96,s+=o*26**(r-i-1);return s===0?Number.NaN:s-1}static chatAtABC(n){let o="";for(;n>=0;)o=String.fromCharCode(n%26+97)+o,n=Math.floor(n/26)-1;return o.toUpperCase()}static randSort(n){for(let t=0,r=n.length;t<r;t++){const s=Number.parseInt((Math.random()*r).toString()),o=n[s];n[s]=n[t],n[t]=o}return n}static commonExtend(n,t){const r={};for(const s in n)r[s]=n[s];for(const s in t)t[s]!=null&&(r[s]=t[s]);return r}static commonExtend1(n,t){for(const r in n)t[r]==null&&(t[r]=n[r]);return t}static arrayToObject(n){const t={};return n.forEach((r,s)=>{t[s]={},r.forEach((o,i)=>{t[s][i]=o})}),t}static hasIntersectionBetweenTwoRanges(n,t,r,s){return t>=r&&s>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),r=n.length<=255;return!t&&r}static set(n,t,r){const s=t.split("."),o=s.pop();s.forEach(i=>{n[i]||(n[i]={}),n=n[i]}),o&&(n[o]=r)}static clamp(n,t,r){return Math.max(t,Math.min(r,n))}}function ko(e=21,n){return n?ml(n,e)():El(e)}function Nl(e){const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,mergeInfo:o}=e;let{startY:i,endY:a,startX:l,endX:h}=e,c=n,u=t,d=n,f=t;if(r&&o){const{startRow:p,startColumn:m,endRow:S,endColumn:y,startY:ee,endY:ge,startX:ce,endX:E}=o;c=p,u=m,d=S,f=y,i=ee,a=ge,l=ce,h=E}return s&&(i=o.startY,a=o.endY,l=o.startX,h=o.endX,d=o.endRow,f=o.endColumn),{startRow:c,startColumn:u,endRow:d,endColumn:f,startY:i,endY:a,startX:l,endX:h}}function wl(e){if(!e)return;const{actualRow:n,actualColumn:t,isMerged:r,isMergedMainCell:s,startRow:o,startColumn:i,endRow:a,endColumn:l}=e;let h=n,c=t,u=n,d=t;return(r||s)&&(h=o,c=i,u=a,d=l),{startRow:h,startColumn:c,endRow:u,endColumn:d}}function Fo(e){var t;return!e||(((t=e==null?void 0:e.v)==null?void 0:t.toString())||"").length===0&&!e.p}function bl(e){return Fo(e)&&(e==null?void 0:e.coverable)!==!1}function ut(e){if(e){if(e.rgb)return e.rgb;if(e.th)return new $n().setThemeColor(e.th).asThemeColor().asRgbColor().getCssString()}return null}function Al(e){return x.isString(e)&&e.substring(0,1)==="="&&e.length>1}function Tl(e){return x.isString(e)&&e.length>0}function yl(e,n=!1){var o;let t="";const r=new Map([["ff",()=>{e.ff&&(t+=`font-family: ${e.ff}; `)}],["fs",()=>{if(e.fs){let i=e.fs;e.va&&(i/=2),t+=`font-size: ${i}pt; `}}],["it",()=>{e.it&&(t+="font-style: italic; ")}],["bl",()=>{e.bl&&(t+="font-weight: bold; ")}],["ul",()=>{var i;(i=e.ul)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):t+="text-decoration: underline; ",e.ul.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.ul.cl)}; `),e.ul.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ul.t} `))}],["st",()=>{var i;(i=e.st)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):t+="text-decoration-line: line-through; ",e.st.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.st.cl)}; `),e.st.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.st.t} `))}],["ol",()=>{var i;(i=e.ol)!=null&&i.s&&(t.indexOf("text-decoration-line")>-1?t=t.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):t+="text-decoration-line: overline; ",e.ol.cl&&t.indexOf("text-decoration-color")===-1&&(t+=`text-decoration-color: ${ut(e.ol.cl)}; `),e.ol.t&&t.indexOf("text-decoration-style")===-1&&(t+=`text-decoration-style: ${e.ol.t} `))}],["bg",()=>{e.bg&&(t+=`background: ${ut(e.bg)}; `)}],["bd",()=>{var i,a,l,h,c,u,d,f,p,m,S,y;(i=e.bd)!=null&&i.b&&(t+=`border-bottom: ${mn((a=e.bd)==null?void 0:a.b.s)} ${(l=ut(e.bd.b.cl))!=null?l:""}; `),(h=e.bd)!=null&&h.t&&(t+=`border-top: ${mn((c=e.bd)==null?void 0:c.t.s)} ${(u=ut(e.bd.t.cl))!=null?u:""}; `),(d=e.bd)!=null&&d.r&&(t+=`border-right: ${mn((f=e.bd)==null?void 0:f.r.s)} ${(p=ut(e.bd.r.cl))!=null?p:""}; `),(m=e.bd)!=null&&m.l&&(t+=`border-left: ${mn((S=e.bd)==null?void 0:S.l.s)} ${(y=ut(e.bd.l.cl))!=null?y:""}; `)}],["cl",()=>{e.cl&&(t+=`color: ${ut(e.cl)}; `)}],["va",()=>{e.va===Gt.SUBSCRIPT?t+="vertical-align: sub; ":e.va===Gt.SUPERSCRIPT&&(t+="vertical-align: super; ")}],["td",()=>{e.td===on.LEFT_TO_RIGHT?t+="direction: ltr; ":e.td===on.RIGHT_TO_LEFT&&(t+="direction: rtl; ")}],["tr",()=>{var i,a,l;e.tr&&(t+=`--data-rotate: (${(i=e.tr)==null?void 0:i.a}deg${(a=e.tr)!=null&&a.v?` ,${(l=e.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{e.ht===Dt.LEFT?t+="text-align: left; ":e.ht===Dt.RIGHT?t+="text-align: right; ":e.ht===Dt.CENTER?t+="text-align: center; ":e.ht===Dt.JUSTIFIED&&(t+="text-align: justify; ")}],["vt",()=>{e.vt===Wt.BOTTOM?t+="vertical-align: bottom; ":e.vt===Wt.TOP?t+="vertical-align: top; ":e.vt===Wt.MIDDLE&&(t+="vertical-align: middle; ")}],["tb",()=>{e.tb===Bt.CLIP?t+="white-space: nowrap; overflow-x: hidden; ":e.tb===Bt.WRAP&&(t+="white-space: normal;")}],["pd",()=>{var c,u,d,f,p,m,S,y;const i=`${(c=e.pd)==null?void 0:c.b}pt`,a=`${(u=e.pd)==null?void 0:u.t}pt`,l=`${(d=e.pd)==null?void 0:d.l}pt`,h=`${(f=e.pd)==null?void 0:f.r}pt`;(p=e.pd)!=null&&p.b&&(t+=`padding-bottom: ${i}; `),(m=e.pd)!=null&&m.t&&(t+=`padding-top: ${a}; `),(S=e.pd)!=null&&S.l&&(t+=`padding-left: ${l}; `),(y=e.pd)!=null&&y.r&&(t+=`padding-right: ${h}; `)}]]),s=["bd","tr","tb"];for(const i in e)n&&s.includes(i)||(o=r.get(i))==null||o();return t}function mn(e){let n="";return e===he.NONE?n="none":e===he.THIN?n="0.5pt solid":e===he.HAIR?n="0.5pt double":e===he.DOTTED?n="0.5pt dotted":e===he.DASHED||e===he.DASH_DOT?n="0.5pt dashed":e===he.DASH_DOT_DOT?n="0.5pt dotted":e===he.DOUBLE?n="0.5pt double":e===he.MEDIUM?n="1pt solid":e===he.MEDIUM_DASHED||e===he.MEDIUM_DASH_DOT?n="1pt dashed":e===he.MEDIUM_DASH_DOT_DOT?n="1pt dotted":e===he.SLANT_DASH_DOT?n="0.5pt dashed":e===he.THICK&&(n="1.5pt solid"),n}function Dl(e){let n=0;if(e=e.trim(),e==="none")n=he.NONE;else if(e==="0.5pt solid")n=he.THIN;else if(e==="0.5pt double")n=he.HAIR;else if(e==="0.5pt dotted")n=he.DOTTED;else if(e==="0.5pt dashed")n=he.DASHED;else if(e==="1pt solid")n=he.MEDIUM;else if(e==="1pt dashed")n=he.MEDIUM_DASHED;else if(e==="1pt dotted")n=he.MEDIUM_DASH_DOT_DOT;else if(e==="1.5pt solid")n=he.THICK;else if(!e.includes("none"))n=he.THIN;else return he.NONE;return n}function Ml(e,n){let t=e.body;if(n){const{headers:r,footers:s}=e;r!=null&&r[n]?t=r[n].body:s!=null&&s[n]&&(t=s[n].body)}return t}function Ul(e){const{startRow:n,endRow:t,startColumn:r,endColumn:s,rangeType:o}=e;return!(n<0||r<0||t<0||s<0||!(Number.isNaN(n)&&Number.isNaN(t))&&o===oe.COLUMN||!(Number.isNaN(r)&&Number.isNaN(s))&&o===oe.ROW||o!==oe.ROW&&o!==oe.COLUMN&&(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(s)||Number.isNaN(t)))}function Ll(e,n){return{startRow:e,endRow:e,startColumn:n,endColumn:n}}function Dr(e,n){return Object.prototype.toString.call(e)===Object.prototype.toString.call(n)?Object.prototype.toString.call(e)==="[object Object]"||Object.prototype.toString.call(e)==="[object Array]"?Object.keys(e).length!==Object.keys(n).length?!1:Object.keys(e).every(t=>Dr(e[t],n[t])):e===n:!1}function Ho(e,n){const t=e.ts||{},r=n.ts||{};return e.sId!==n.sId?!1:Dr(t,r)}function xl(e,n){return n.some(t=>e.indexOf(t)>-1)}function Wn(e,n,t,r){if(e>n&&([e,n]=[n,e]),t>r&&([t,r]=[r,t]),n<t||r<e)return[e,n];t<e&&(t=e),r>n&&(r=n);const s=r-t+1;let o=[];return e===t?o=[r+1-s,n-s]:n===r?o=[e,t-1]:o=[e,n-s],o}function Pl(e){if(e==null)return!1;const n=e.bullet;return(n==null?void 0:n.listId)!=null}function kl(e){if(e==null)return!1;const n=e.paragraphStyle;return jo(n)}function jo(e){var n;return!(e==null||(e.indentStart==null||e.indentStart.v===0)&&e.hanging==null||((n=e.hanging)==null?void 0:n.v)===0)}function $o(e,n,t){return e.slice(0,n)+t+e.slice(n)}function Wo(e,n,t){return n>t?e:e.slice(0,n)+e.slice(t)}function Fl(e){return e===null||e.toString().replace(/\s/g,"")===""||typeof e=="boolean"?!1:!isNaN(e)}function Hl(e){let n=0;for(let t=0;t<e.length;t++)n=e.charCodeAt(t)+(n<<6)+(n<<16)-n;return n>>>0}function as(e){var n=typeof Symbol=="function"&&Symbol.iterator,t=n&&e[n],r=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function ls(e,n){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var r=t.call(e),s,o=[],i;try{for(;(n===void 0||n-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(a){i={error:a}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(i)throw i.error}}return o}function us(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))}function en(e){return typeof e=="function"}function jl(e){var n=function(r){Error.call(r),r.stack=new Error().stack},t=e(n);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var nr=jl(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
2
  `+t.map(function(r,s){return s+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function cs(e,n){if(e){var t=e.indexOf(n);0<=t&&e.splice(t,1)}}var jo=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,t,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=as(i),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(m){n={error:m}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}else i.remove(this);var c=this.initialTeardown;if(en(c))try{c()}catch(m){o=m instanceof nr?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=as(u),f=d.next();!f.done;f=d.next()){var p=f.value;try{hs(p)}catch(m){o=o!=null?o:[],m instanceof nr?o=us(us([],ls(o)),ls(m.errors)):o.push(m)}}}catch(m){r={error:m}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new nr(o)}},e.prototype.add=function(n){var t;if(n&&n!==this)if(this.closed)hs(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(n)}},e.prototype._hasParent=function(n){var t=this._parentage;return t===n||Array.isArray(t)&&t.includes(n)},e.prototype._addParent=function(n){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(n),t):t?[t,n]:n},e.prototype._removeParent=function(n){var t=this._parentage;t===n?this._parentage=null:Array.isArray(t)&&cs(t,n)},e.prototype.remove=function(n){var t=this._finalizers;t&&cs(t,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}();jo.EMPTY;function $l(e){return e instanceof jo||e&&"closed"in e&&en(e.remove)&&en(e.add)&&en(e.unsubscribe)}function hs(e){en(e)?e():e.unsubscribe()}function Ne(e){let n=!1;return e?$l(e)?{dispose:()=>e.unsubscribe()}:typeof e=="function"?{dispose:()=>{n||(n=!0,e())}}:e:Ne(()=>{})}function jl(e){return Ne(()=>{e.unsubscribe()})}class Mr{constructor(){_(this,"_disposables",new Set)}add(n){const t=Ne(n);return this._disposables.add(t),{dispose:()=>{t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class be{constructor(){_(this,"_disposed",!1);_(this,"_collection",new Mr)}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 Wl extends be{constructor(){super(...arguments);_(this,"dispose$",new q.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Bl extends be{constructor(t){super();_(this,"_ref",0);this._rootDisposable=t}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 qt{static hasLength(n,t){return n.length===t}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 Bn(e,n){const t=e.indexOf(n);return t>-1?(e.splice(t,1),!0):!1}function Gl(e){const n=new Set,t=[];for(const r of e)n.has(r)||(n.add(r),t.push(r));return t}function Vl(e,n){for(let t=e.length-1;t>-1;t--){const r=e[t];if(n(r,t))return r}return null}function Kl(e,n){if(e.length===0)return e;const t=n%e.length;return e.slice(t).concat(e.slice(0,t))}function Yl(e,n){const t=new Map;return e.forEach(r=>{const s=n(r);let o=t.get(s);t.has(s)||(o=[],t.set(s,o)),o.push(r)}),t}function zl(e){return Array.isArray(e)?e:[e]}const ue=Symbol("newer"),Me=Symbol("older");class Wo{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:n.key}):{done:!0,value:void 0}}}class Bo{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:n.value}):{done:!0,value:void 0}}}class Go{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}var Us,Ls;Ls=ue,Us=Me;class ur{constructor(n,t){_(this,"key");_(this,"value");_(this,Ls);_(this,Us);this.key=n,this.value=t,this[ue]=void 0,this[Me]=void 0}toJSON(){return{key:this.key,value:this.value}}}class Vo{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(qt.hasLength(n,1)){if(qt.isNumber(n[0])){const t=n[0];this._initialize(t,void 0);return}if(qt.isIterable(n[0])){const t=n[0];this._initialize(0,t);return}return}if(qt.hasLength(n,2)){const t=n[0],r=n[1];this._initialize(t,r)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),Ne(()=>Bn(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,t&&(this.assign(t),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ue]&&(n===this.oldest&&(this.oldest=n[ue]),n[ue][Me]=n[Me]),n[Me]&&(n[Me][ue]=n[ue]),n[ue]=void 0,n[Me]=this.newest,this.newest&&(this.newest[ue]=n),this.newest=n)}assign(n){let t,r=this.limit||Number.MAX_VALUE;this._keymap.clear();const s=n[Symbol.iterator]();for(let o=s.next();!o.done;o=s.next()){const i=new ur(o.value[0],o.value[1]);if(this._keymap.set(i.key,i),t?(t[ue]=i,i[Me]=t):this.oldest=i,t=i,r--===0)throw new Error("overflow")}this.newest=t,this.size=this._keymap.size}set(n,t){let r=this._keymap.get(n);return r?(r.value=t,this._markEntryAsUsed(r),this):(this._keymap.set(n,r=new ur(n,t)),this.newest?(this.newest[ue]=r,r[Me]=this.newest):this.oldest=r,this.newest=r,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ue]?(this.oldest=this.oldest[ue],this.oldest[Me]=void 0):(this.oldest=void 0,this.newest=void 0),n[ue]=n[Me]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(t=>t(n)),[n.key,n.value]}get(n){const t=this._keymap.get(n);if(t)return this._markEntryAsUsed(t),t.value}has(n){return this._keymap.has(n)}find(n){const t=this._keymap.get(n);return t?t.value:void 0}delete(n){const t=this._keymap.get(n);if(t)return this._keymap.delete(t.key),t[ue]&&t[Me]?(t[Me][ue]=t[ue],t[ue][Me]=t[Me]):t[ue]?(t[ue][Me]=void 0,this.oldest=t[ue]):t[Me]?(t[Me][ue]=void 0,this.newest=t[Me]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Wo(this.oldest)}values(){return new Bo(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Go(this.oldest)}forEach(n,t){typeof t!="object"&&(t=this);let r=this.oldest;for(;r;)n.call(t,r.value,r.key,this),r=r[ue]}toJSON(){const n=new Array(this.size);let t=0,r=this.oldest;for(;r;)n[t++]={key:r.key,value:r.value},r=r[ue];return n}toString(){let n="",t=this.oldest;for(;t;)n+=`${String(t.key)}:${t.value}`,t=t[ue],t&&(n+=" < ");return n}}function It(e){let n=0;const t=Object.keys(e);for(const r of t){const s=Number(r);n=Math.max(n,s)}return n+1}function cr(e,n,t){const r=It(t),s=t;for(let o=r-1;o>=e;o--)s[o+1]=s[o];s[e]=n}function hr(e,n,t){const r=Object.keys(t).reduce((s,o)=>Math.max(s,Number.parseInt(o)),0)+1;for(let s=e;s<r;s++)s<e+n?delete t[s]:t[s]!==void 0&&(t[s-n]=t[s],delete t[s])}function Xl(e,n){const t=e,r=Object.keys(t),s=r.length,o=n,i=Object.keys(o),a=i.length,l={};let h=0;for(let c=0;c<s;c++,h++){const u=r[c];l[h]=t[u]}for(let c=0;c<a;c++,h++){const u=i[c];l[h]=o[u]}return l}function Ql(e,n,t){const r=t;if(It(t)>0){const o={};let i=0;for(let a=e;a<=n;a++)r[a]&&(o[i]=r[a],i++);return o}return{}}function dr(e,n,t,r){const s=e>t;if(!s&&e+n>t)throw new Error("Invalid move operation");s?ql(e,n,t,r):Zl(e,n,t,r)}function ql(e,n,t,r){const s=r,o=[];for(let i=e;i<e+n;i++)o.push(s[i]);for(let i=e-1;i>=t;i--){const a=s[i];s[i+n]=a,a===void 0&&delete s[i+n]}o.forEach((i,a)=>{s[t+a]=i,i===void 0&&delete s[t+a]})}function Zl(e,n,t,r){const s=r,o=[];for(let i=e;i<e+n;i++)o.push(s[i]);for(let i=e+n;i<t;i++){const a=s[i];s[i-n]=a,a===void 0&&delete s[i-n]}o.forEach((i,a)=>{s[t+a-n]=i,i===void 0&&delete s[t+a-n]})}class ot{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new ot({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(n(o,i)===!1)return this}return this}forRow(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(n(o,Object.keys(i).map(l=>Number(l)))===!1)return this}return this}forValue(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(!i)continue;const a=Object.keys(i);for(const l of a){const h=Number(l),c=i[Number(l)];if(n(o,h,c)===!1)return this}}return this}swapRow(n,t){const r=this._matrix[n],s=this._matrix[t];this._matrix[n]=s,this._matrix[t]=r}getRow(n){return this._matrix[n]}getRowOrCreate(n){let t=this.getRow(n);return t==null&&(t={},this._matrix[n]=t),t}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,t=Object.keys(n);if(t.length===0)return!1;for(const r of t){const s=Number(r),o=n[s];if(Object.keys(o).length>0)return!0}return!1}getValue(n,t){var r,s;return(s=(r=this._matrix)==null?void 0:r[n])==null?void 0:s[t]}setValue(n,t,r){const s=this.getRowOrCreate(n);s[t]=r}deleteValue(n,t){var r,s;(s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t]}realDeleteValue(n,t){var r,s,o;if((s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t],this.getRow(n)){const i=this.getRow(n);if(i==null)return;Object.keys(i).length===0&&((o=this._matrix)==null||delete o[n])}}setRow(n,t){this._matrix[n]=t}moveRows(n,t,r){dr(n,t,r,this._matrix)}moveColumns(n,t,r){this.forEach((s,o)=>{dr(n,t,r,o)})}insertRows(n,t){for(let r=n;r<n+t;r++)cr(r,{},this._matrix)}insertColumns(n,t){for(let r=n;r<n+t;r++)this.forEach((s,o)=>{o&&cr(r,void 0,o)})}removeRows(n,t){hr(n,t,this._matrix)}removeColumns(n,t){this.forEach((r,s)=>{s&&hr(n,t,s)})}getFragment(n,t,r,s){const o=new ot;let i=0;for(let a=n;a<=t;a++){const l={};let h=0;for(let c=r;c<=s;c++){const u=this.getValue(a,c);l[h]=u,h++}o.setRow(i,l),i++}return o}getSlice(n,t,r,s){const o=new ot;for(let i=n;i<=t;i++)for(let a=r;a<=s;a++){const l=this.getValue(i,a);l&&o.setValue(i,a,x.deepClone(l))}return o}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return It(this._matrix)}getRange(){const r=this.getLength()-1;let s=0;const o=this.getLength();for(let i=0;i<o;i++){const a=this.getRow(i);if(a){const l=It(a)-1;s=l>s?l:s}}return{startRow:0,startColumn:0,endRow:r,endColumn:s}}toNativeArray(){const n=new Array;return this.forValue((t,r,s)=>{n.push(s)}),n}toArray(){const n=[];return this.forRow((t,r)=>{n[t]==null&&(n[t]=[]),r.forEach(s=>{n[t][s]=this.getValue(t,s)})}),n}toFullArray(){const n=this.getRange(),{endColumn:t,endRow:r}=n,s=[];for(let o=0;o<=r;o++){const i=Array(t+1).fill(void 0);s.push(i)}return this.forValue((o,i,a)=>{s[o][i]=a}),s}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,t=0,r=!1,s=!1;const o=new ot;return this.forEach((i,a)=>{r||(r=!0,n=i),Object.keys(a).forEach(l=>{const h=Number(l);s?h<t&&(t=h):(s=!0,t=h);const c=this.getValue(i,h);o.setValue(i-n,h-t,c)})}),o.getData()}getDataRange(){let n=0,t=0,r=0,s=-1,o=!1,i=!1;return this.forEach((a,l)=>{if(o||(o=!0,n=a),l==null)return;const h=It(l)-1;h>r&&(r=h),Object.keys(l).forEach(c=>{const u=Number(c);i?u<t&&(t=u):(i=!0,t=u)}),a>s&&(s=a)}),{startRow:n,startColumn:t,endRow:s,endColumn:r}}getDiscreteRanges(){const n=[];return this.forEach((t,r)=>{Object.keys(r).forEach(s=>{const o=Number(s);let i=!1;for(const a of n)if(t>=a.startRow&&t<=a.endRow+1&&o>=a.startColumn&&o<=a.endColumn+1){a.endRow=Math.max(t,a.endRow),a.endColumn=Math.max(o,a.endColumn),i=!0;break}i||n.push({startRow:t,endRow:t,startColumn:o,endColumn:o})})}),n}merge(n){this.forValue((t,r)=>{const s=n.getValue(t,r);s!=null&&this.setValue(t,r,s)})}_setOriginValue(n={}){this._matrix=n}}const _t=class _t{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,t){return n==null||t==null?!1:n.endRow===t.endRow&&n.endColumn===t.endColumn&&n.startRow===t.startRow&&n.startColumn===t.startColumn&&(n.rangeType===t.rangeType||n.rangeType===void 0&&t.rangeType===oe.NORMAL||t.rangeType===void 0&&n.rangeType===oe.NORMAL)}static intersects(n,t){if(n.rangeType===oe.ROW&&t.rangeType===oe.COLUMN||n.rangeType===oe.COLUMN&&t.rangeType===oe.ROW)return!0;if(n.rangeType===oe.ROW&&t.rangeType===oe.ROW)return n.startRow<=t.endRow&&n.endRow>=t.startRow;if(n.rangeType===oe.COLUMN&&t.rangeType===oe.COLUMN)return n.startColumn<=t.endColumn&&n.endColumn>=t.startColumn;const r=Math.floor(Number.MAX_SAFE_INTEGER/10),s=Number.isNaN(n.startRow)?0:n.startRow,o=Number.isNaN(n.endRow)?r:n.endRow,i=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?r:n.endColumn,l=Number.isNaN(t.startRow)?0:t.startRow,h=Number.isNaN(t.endRow)?r:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,u=Number.isNaN(t.endColumn)?r:t.endColumn,d=Math.abs(i+a-c-u),f=Math.abs(i-a)+Math.abs(c-u),p=Math.abs(s+o-l-h),m=Math.abs(s-o)+Math.abs(l-h);return d<=f&&p<=m}static getIntersects(n,t){const r=n.startRow,s=n.endRow,o=n.startColumn,i=n.endColumn,a=t.startRow,l=t.endRow,h=t.startColumn,c=t.endColumn;let u,d,f,p;if(a<=s)a>=r?d=a:d=r;else return null;if(l>=r)l>=s?p=s:p=l;else return null;if(h<=i)h>o?u=h:u=o;else return null;if(c>=o)c>=i?f=i:f=c;else return null;return{startRow:d,endRow:p,startColumn:u,endColumn:f,rangeType:oe.NORMAL}}static contains(n,t){return n.startRow<=t.startRow&&n.endRow>=t.endRow&&n.startColumn<=t.startColumn&&n.endColumn>=t.endColumn}static realContain(n,t){return _t.contains(n,t)&&(n.startRow<t.startRow||n.endRow>t.endRow||n.startColumn<t.startColumn||n.endColumn>t.endColumn)}static union(...n){return n.reduce((t,r)=>({startRow:Math.min(t.startRow,r.startRow),startColumn:Math.min(t.startColumn,r.startColumn),endRow:Math.max(t.endRow,r.endRow),endColumn:Math.max(t.endColumn,r.endColumn),rangeType:oe.NORMAL}),n[0])}static realUnion(...n){const t=n.some(o=>o.rangeType===oe.COLUMN),r=n.some(o=>o.rangeType===oe.ROW),s=_t.union(...n);return{startColumn:r?Number.NaN:s.startColumn,endColumn:r?Number.NaN:s.endColumn,startRow:t?Number.NaN:s.startRow,endRow:t?Number.NaN:s.endRow,rangeType:r?oe.ROW:t?oe.COLUMN:oe.NORMAL}}static subtract(n,t){if(t.startRow>n.endRow||t.endRow<n.startRow||t.startColumn>n.endColumn||t.endColumn<n.startColumn)return[n];const r=[];t.startRow>=n.startRow&&r.push({startRow:n.startRow,startColumn:n.startColumn,endRow:t.startRow-1,endColumn:n.endColumn}),t.endRow<=n.endRow&&r.push({startRow:t.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const s=Math.max(n.startRow,t.startRow),o=Math.min(n.endRow,t.endRow);return t.startColumn>=n.startColumn&&r.push({startRow:s,startColumn:n.startColumn,endRow:o,endColumn:t.startColumn-1}),t.endColumn<=n.endColumn&&r.push({startRow:s,startColumn:t.endColumn+1,endRow:o,endColumn:n.endColumn}),r.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,t){return!(n.left>t.right||n.right<t.left||n.top>t.bottom||n.bottom<t.top)}static getIntersectionBetweenTwoRect(n,t){const r=Math.max(n.left,t.left),s=Math.min(n.right,t.right),o=Math.max(n.top,t.top),i=Math.min(n.bottom,t.bottom);return s<=r||i<=o?null:{left:r,right:s,top:o,bottom:i,width:s-r,height:i-o}}};_(_t,"getRelativeRange",(n,t)=>({startRow:n.startRow-t.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-t.startColumn,endColumn:n.endColumn-n.startColumn})),_(_t,"getPositionRange",(n,t,r)=>({...r||{},startRow:r&&[Se.ROW,Se.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:n.startRow+t.startRow,endRow:r&&[Se.ROW,Se.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:n.endRow+n.startRow+t.startRow,startColumn:r&&[Se.COLUMN,Se.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:n.startColumn+t.startColumn,endColumn:r&&[Se.COLUMN,Se.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:n.endColumn+n.startColumn+t.startColumn})),_(_t,"moveHorizontal",(n,t=0,r=0)=>({...n,startColumn:n.startColumn+t,endColumn:n.endColumn+t+r})),_(_t,"moveVertical",(n,t=0,r=0)=>({...n,startRow:n.startRow+t,endRow:n.endRow+t+r})),_(_t,"moveOffset",(n,t,r)=>({...n,startRow:n.startRow+r,endRow:n.endRow+r,startColumn:n.startColumn+t,endColumn:n.endColumn+t}));let vt=_t;class Jl{constructor(n,t){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=n,this._keys=t,n.forEach(r=>{this._initKeyMap(r)})}_initKeyMap(n){this._keys.forEach(t=>{const r=n[t],s=this._keyMaps.get(t)||new Map;s.set(r,n),this._keyMaps.set(t,s)})}getValue(n,t){const r=t||this._keys;for(let s=0;s<r.length;s++){const o=this._keyMaps.get(r[s]);if(o!=null&&o.has(n))return o.get(n)}return null}hasValue(n){for(let t=0;t<this._keys.length;t++){const r=this._keyMaps.get(this._keys[t]);if(r!=null&&r.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,t,r){const s=this.getValue(n);s&&Object.keys(s).includes(t)&&(s[t]=r)}deleteValue(n){const t=this.getValue(n);if(t){this._keys.forEach(s=>{const o=this._keyMaps.get(s),i=t[s];o==null||o.delete(i)});const r=this._values.findIndex(s=>s===t);this._values.splice(r,1)}}getValues(){return this._values}getKeyMap(n){var t;return[...((t=this._keyMaps.get(n))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function fr(e,n,t,r){return{forEach(s){for(let o=e;o<=n;o++)for(let i=t;i<=r;i++)s(o,i)}}}function eu(e){if(e==null||e.length===0)return Number.NaN;const n=e.toLowerCase().split(""),t=n.length,r=i=>i.charCodeAt(0)-96;let s=0,o=0;for(let i=0;i<t;i++)o=r(n[i]),s+=o*26**(t-i-1);return s===0?Number.NaN:s-1}const Un=65,Ko=90,tu=97;function nu(e){const n=Ko-Un+1;let t="";for(;e>=0;)t=String.fromCharCode(e%n+Un)+t,e=Math.floor(e/n)-1;return t}function Yo(e,n){let t="";for(;n>0;)t+=e,n--;return t}function ru(e,n=!1){const t=Ko-Un+1;let r=tu;n&&(r=Un);const s=String.fromCharCode(e%t+r),o=Math.floor(e/t)+1;return Yo(s,o)}function su(e,n){return e.zIndex>n.zIndex?1:e.zIndex===n.zIndex?0:-1}function ou(e,n){return e.zIndex>n.zIndex?-1:e.zIndex===n.zIndex?0:1}function kt(e="index",n=1){return(t,r)=>t[e]>r[e]?n:t[e]===r[e]?0:-n}function iu(e,n){let t;function r(...s){const o=this,i=function(){t=null,e.apply(o,s)};clearTimeout(t),t=setTimeout(i,n)}return Object.defineProperty(r,"cancel",{value:()=>{clearTimeout(t)},enumerable:!1,writable:!1}),r}function In(e,n,t){const{dataStream:r,textRuns:s=[]}=e;let o=n;const i=[];for(const a of s){const{st:l,ed:h}=a;x.hasIntersectionBetweenTwoRanges(n,t,l,h)&&(l>o?(i.push(r.slice(o,l)),i.push(_r(r,{...a,ed:Math.min(h,t)}))):i.push(_r(r,{...a,st:o,ed:Math.min(h,t)}))),o=Math.max(n,Math.min(h,t))}return o!==t&&i.push(r.slice(o,t)),i.join("")}function au(e,n=!0){var t;if(n&&((t=e.paragraphs)!=null&&t.length)){const{dataStream:r,paragraphs:s=[]}=e;let o="",i=-1;for(const a of s){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>i+1?o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${In(e,i+1,l)}</p>`:o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,i=l}return i!==r.length&&(o+=In(e,i,r.length)),o}else return In(e,0,e.dataStream.length)}function _r(e,n){const{st:t,ed:r,ts:s={}}=n,{ff:o,fs:i,it:a,bl:l,ul:h,st:c,ol:u,bg:d,cl:f,va:p}=s;let m=e.slice(t,r);const S=[];return a===K.TRUE&&(m=`<i>${m}</i>`),p===Gt.SUPERSCRIPT?m=`<sup>${m}</sup>`:p===Gt.SUBSCRIPT&&(m=`<sub>${m}</sub>`),(h==null?void 0:h.s)===K.TRUE&&(m=`<u>${m}</u>`),(c==null?void 0:c.s)===K.TRUE&&(m=`<s>${m}</s>`),l===K.TRUE&&(m=`<strong>${m}</strong>`),o&&S.push(`font-family: ${o}`),f&&S.push(`color: ${f.rgb}`),i&&S.push(`font-size: ${i}pt`),u&&S.push("text-decoration: overline"),d&&S.push(`background: ${d.rgb}`),S.length?`<span style="${S.join("; ")};">${m}</span>`:m}const lu={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},uu={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},cu={startRow:0,startColumn:0,endRow:0,endColumn:0},hu={row:0,column:0},vn={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:on.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Dt.UNSPECIFIED,vt:Wt.UNSPECIFIED,tb:Bt.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},zo={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var Xo=(e=>(e.ARRAY_CONVERTOR="ARRAY_CONVERTOR",e.MATRIX_CONVERTOR="MATRIX_CONVERTOR",e))(Xo||{});function En(e,n){const{textRuns:t=[]}=n;let r=0;for(const o of t){const{ts:i={},st:a,ed:l}=o;if(i[e]==null)return K.FALSE;switch(e){case"bl":case"it":{if(i[e]===K.FALSE)return K.FALSE;break}case"ul":case"st":{if(i[e].s===K.FALSE)return K.FALSE;break}default:throw new Error(`unknown style key: ${e} in IStyleBase`)}r+=l-a}return n.dataStream.indexOf(`\r
4
- `)===r?K.TRUE:K.FALSE}const rn=class rn{constructor(n,t,r){_(this,"_range");_(this,"_worksheet");this._deps=r,this._range=t,this._worksheet=n}static foreach(n,t){const{startRow:r,startColumn:s,endRow:o,endColumn:i}=n;for(let a=r;a<=o;a++)for(let l=s;l<=i;l++)t(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=[];for(let i=n;i<=t;i++){const a=[];for(let l=r;l<=s;l++)a.push(this.getMatrix().getValue(i,l)||null);o.push(a)}return o}getMatrix(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=this._worksheet.getCellMatrix(),i=new ot;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)i.setValue(a,l,o.getValue(a,l)||null);return i}getMatrixObject(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=this._worksheet.getCellMatrix(),i=new ot;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)i.setValue(a-n,l-r,o.getValue(a,l)||{});return i}getA1Notation(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range;let o,i;return r<s?(o=x.numToWord(r+1)+(n+1),i=x.numToWord(s+1)+(t+1)):(o=x.numToWord(s+1)+(t+1),i=x.numToWord(r+1)+(n+1)),o===i?`${o}`:`${o}:${i}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var o;const s=n.getStyleByCell(r);return((o=s==null?void 0:s.bg)==null?void 0:o.rgb)||vn.bg.rgb}))}getCell(n,t){const{startRow:r,endRow:s,startColumn:o,endColumn:i}=this._range,a={startRow:r+n,endRow:r+n,startColumn:o+t,endColumn:o+t};return new rn(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:t,endRow:r,startColumn:s,endColumn:o}=this._range,i=this._worksheet.getCellMatrix().getFragment(t,r,s,o).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let h=0;h<=r-t;h++)for(let c=0;c<=o-s;c++){if(i==null||((a=i==null?void 0:i[h])==null?void 0:a[c])==null)continue;const u=i[h][c].s;u&&(i[h][c].s=l.get(u))}}return i}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var o;const s=n.getStyleByCell(r);return((o=s==null?void 0:s.cl)==null?void 0:o.rgb)||vn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("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 t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("st",n.body)===K.TRUE?{s:K.TRUE}:{s:K.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var t,r;const n=((t=this.getValue())==null?void 0:t.p)||{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(s=>{var o;return((o=s==null?void 0:s.ts)==null?void 0:o.fs)!=null})?Math.max(...n.body.textRuns.map(s=>{var o;return((o=s==null?void 0:s.ts)==null?void 0:o.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 t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("it",n.body)===K.TRUE?Tn.ITALIC:Tn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("bl",n.body)===K.TRUE?yn.BOLD:yn.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:t}=this,{startRow:r,endRow:s}=n;let o=0;for(let i=0;i<=s-r;i++){const a=t.getRowHeight(i);o+=a}return o}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:t}=this._range;return t-n+1}getNumRows(){const{startRow:n,endRow:t}=this._range;return t-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(t=>(t==null?void 0:t.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(t=>t.map(r=>n.getStyleByCell(r)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:t}=this,{startColumn:r,endColumn:s}=n;let o=0;for(let i=0;i<=s-r;i++)o+=t.getColumnWidth(i);return o}getWrap(){return this.getWrapStrategy()===Bt.WRAP?K.TRUE:K.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){rn.foreach(this._range,n)}_getStyles(n){const t=this._deps.getStyles();return this.getValues().map(r=>r.map(s=>{const o=t&&t.getStyleByCell(s);return o&&o[n]||vn[n]}))}};_(rn,"transformRange",(n,t)=>n.rangeType===oe.ALL?{startColumn:0,startRow:0,endColumn:t.getMaxColumns()-1,endRow:t.getMaxRows()-1}:n.rangeType===oe.COLUMN?{startRow:0,endRow:t.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===oe.ROW?{startColumn:0,endColumn:t.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let Vt=rn;function du(e,n){if(e.length===0||e[0].length===0)return null;const t=new Array(e[0].length).fill(0);let r=0,s=null;for(let o=0;o<e.length;o++){for(let a=0;a<e[0].length;a++)t[a]=n(e[o][a])?t[a]+1:0;const i=fu(t);i.area>r&&(r=i.area,s={startColumn:i.start,startRow:o-i.height+1,endColumn:i.end,endRow:o})}return s}function fu(e){const n=[];let t=0,r={area:0,height:0,start:0,end:0},s=0;for(;s<e.length;)if(n.length===0||e[s]>=e[n[n.length-1]])n.push(s++);else{const o=e[n.pop()],i=n.length===0?s:s-n[n.length-1]-1;o*i>t&&(t=o*i,r={area:t,height:o,start:n.length===0?0:n[n.length-1]+1,end:s-1})}for(;n.length>0;){const o=e[n.pop()],i=n.length===0?s:s-n[n.length-1]-1;o*i>t&&(t=o*i,r={area:t,height:o,start:n.length===0?0:n[n.length-1]+1,end:s-1})}return r}function _u(e,n){Vt.foreach(n,(t,r)=>{e[t][r]=void 0})}function gu(e,n){const t=e.toFullArray(),r=[];for(;;){const s=du(t,n);if(!s)break;r.push(s),_u(t,s)}return r}function pu(e,n,t,r=!1){let s={...e};const o=s.startAbsoluteRefType||Se.NONE,i=s.endAbsoluteRefType||Se.NONE;return!r&&o===Se.ALL&&i===Se.ALL?s:r||o===Se.NONE&&i===Se.NONE?vt.moveOffset(s,n,t):(o===Se.NONE?s={...s,startRow:s.startRow+t,startColumn:s.startColumn+n}:o===Se.COLUMN?s={...s,startRow:s.startRow+t}:o===Se.ROW&&(s={...s,startColumn:s.startColumn+n}),i===Se.NONE?s={...s,endRow:s.endRow+t,endColumn:s.endColumn+n}:i===Se.COLUMN?s={...s,endRow:s.endRow+t}:i===Se.ROW&&(s={...s,endColumn:s.endColumn+n}),s)}var Ur=Symbol("$$IDENTIFIER_DECORATOR");function mu(e){return e&&e[Ur]===!0}function Lr(e){return typeof e=="function"}function gr(e){return!!(e&&typeof e.useClass<"u")}function pr(e){return!!(e&&typeof e.useFactory<"u")}function mr(e){return!!(e&&typeof e.useValue<"u")}function Eu(e){return!!(e&&typeof e.useExisting<"u")}function Er(e){return!!(e&&typeof e.useAsync<"u")}var Qo=Symbol("AsyncHook");function On(e){return!!(e&&e.__symbol===Qo)}function Ge(e){return typeof e>"u"?"undefined":Lr(e)&&!e[Ur]?e.name:e.toString()}exports.Quantity=void 0;(function(e){e.MANY="many",e.OPTIONAL="optional",e.REQUIRED="required"})(exports.Quantity||(exports.Quantity={}));exports.LookUp=void 0;(function(e){e.SELF="self",e.SKIP_SELF="skipSelf"})(exports.LookUp||(exports.LookUp={}));var Ru=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Le=function(e){Ru(n,e);function n(t){return e.call(this,"[redi]: ".concat(t))||this}return n}(Error),qo=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),ds=Symbol("$$TARGET"),Rr=Symbol("$$DEPENDENCIES"),Cu=function(e){qo(n,e);function n(t,r){var s="Could not find dependency registered on the ".concat(t,' (indexed) parameter of the constructor of "').concat(Ge(r),'".');return e.call(this,s)||this}return n}(Le),Zo=function(e){qo(n,e);function n(t,r){var s='It seems that you register "undefined" as dependency on the '.concat(r+1,' parameter of "').concat(Ge(t),'". Please make sure that there is not cyclic dependency among your TypeScript files, or consider using "forwardRef". For more info please visit our website https://redi.wendell.fun/docs/debug#could-not-find-dependency-registered-on');return e.call(this,s)||this}return n}(Le);function Jo(e){var n=e;return n[Rr]||[]}function xr(e,n){var t=Jo(e),r=t.find(function(s){return s.paramIndex===n});if(!r)throw new Cu(n,e);return r}function Pr(e,n,t,r,s){r===void 0&&(r=exports.Quantity.REQUIRED);var o={paramIndex:t,identifier:n,quantity:r,lookUp:s,withNew:!1};if(typeof n>"u")throw new Zo(e,t);var i=e;i[ds]===i?i[Rr].push(o):(i[Rr]=[o],i[ds]=i)}var fs=new Set;function Ve(e){if(fs.has(e))throw new Le('Identifier "'.concat(e,'" already exists.'));fs.add(e);var n=function(t,r,s){Pr(t,n,s)};return n.toString=function(){return e},n[Ur]=!0,n}var Iu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),vu=function(e){Iu(n,e);function n(t,r,s){var o='Expect "'.concat(r,'" dependency items for id "').concat(Ge(t),'" but get ').concat(s,".");return e.call(this,o)||this}return n}(Le);function ei(e,n,t){if(n===exports.Quantity.OPTIONAL&&t>1||n===exports.Quantity.REQUIRED&&t!==1)throw new vu(e,n,t)}function Ou(e,n){return e===exports.Quantity.MANY?n:n[0]}function Su(e,n,t){var r=xr(e,n);r.quantity=t}function kr(e){return function n(t){return this instanceof n?this:function(r,s,o){if(t)Pr(r,t,o,e);else{if(e===exports.Quantity.REQUIRED)throw new Zo(r,o);Su(r,o,e)}}}}var ti=kr(exports.Quantity.MANY),ni=kr(exports.Quantity.OPTIONAL),it=kr(exports.Quantity.REQUIRED);function Nu(e){return{unwrap:e}}function wu(e){return!!e&&typeof e.unwrap=="function"}function Au(e){return wu(e)?e.unwrap():e}function Cr(e){return!!e&&typeof e.dispose=="function"}var ri=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}();function bu(e){return e.length===1}var Gn=[];function _s(e){Gn.push(e)}function gs(){Gn.pop()}function Tu(){Gn.length=0}var ps=function(e){ri(n,e);function n(t,r,s){var o='Cannot find "'.concat(Ge(r),'" registered by any injector. It is the ').concat(s,'th param of "').concat(mu(t)?Ge(t):t.name,'".');return e.call(this,o)||this}return n}(Le),Sn=function(e){ri(n,e);function n(t){var r=this,s='Cannot find "'.concat(Ge(t),'" registered by any injector. The stack of dependencies is: "').concat(Gn.map(function(o){return Ge(o)}).join(" -> "),'".');return r=e.call(this,s)||this,Tu(),r}return n}(Le),yu=function(){function e(n){var t=this;this.dependencyMap=new Map,this.normalizeDependencies(n).map(function(r){return t.add(r[0],r[1])})}return e.prototype.add=function(n,t){typeof t>"u"&&(t={useClass:n,lazy:!1});var r=this.dependencyMap.get(n);typeof r>"u"&&(r=[],this.dependencyMap.set(n,r)),r.push(t)},e.prototype.delete=function(n){this.dependencyMap.delete(n)},e.prototype.get=function(n,t){t===void 0&&(t=exports.Quantity.REQUIRED);var r=this.dependencyMap.get(n);return ei(n,t,r.length),Ou(t,r)},e.prototype.has=function(n){return this.dependencyMap.has(n)},e.prototype.append=function(n){var t=this;this.normalizeDependencies(n).forEach(function(r){return t.add(r[0],r[1])})},e.prototype.dispose=function(){this.dependencyMap.clear()},e.prototype.normalizeDependencies=function(n){return n.map(function(t){var r=t[0],s;return bu(t)?s={useClass:t[0],lazy:!1}:s=t[1],[r,s]})},e}(),Du=function(){function e(){this.resolvedDependencies=new Map}return e.prototype.add=function(n,t){var r=this.resolvedDependencies.get(n);typeof r>"u"&&(r=[],this.resolvedDependencies.set(n,r)),r.push(t)},e.prototype.has=function(n){return this.resolvedDependencies.has(n)},e.prototype.delete=function(n){if(this.resolvedDependencies.has(n)){var t=this.resolvedDependencies.get(n);t.forEach(function(r){return Cr(r)?r.dispose():void 0}),this.resolvedDependencies.delete(n)}},e.prototype.get=function(n,t){t===void 0&&(t=exports.Quantity.REQUIRED);var r=this.resolvedDependencies.get(n);if(!r)throw new Sn(n);return ei(n,t,r.length),t===exports.Quantity.MANY?r:r[0]},e.prototype.dispose=function(){Array.from(this.resolvedDependencies.values()).forEach(function(n){n.forEach(function(t){return Cr(t)?t.dispose():void 0})}),this.resolvedDependencies.clear()},e}();function Mu(e,n,t){var r=xr(e,n);r.lookUp=t}function si(e){return function n(){return this instanceof n?this:function(t,r,s){Mu(t,s,e)}}}var oi=si(exports.LookUp.SKIP_SELF),ii=si(exports.LookUp.SELF);function Uu(e,n,t){var r=xr(e,n);r.withNew=t}function Lu(e){return function n(){return this instanceof n?this:function(t,r,s){Uu(t,s,e)}}}var ai=Lu(!0);function li(e,n){return n===void 0&&(n=0),e?e.map(function(t,r){if(r+=n,!Array.isArray(t))return{paramIndex:r,identifier:t,quantity:exports.Quantity.REQUIRED,withNew:!1};var s=t.slice(0,t.length-1),o=t[t.length-1],i=void 0,a=exports.Quantity.REQUIRED,l=!1;return s.forEach(function(h){if(h instanceof ii)i=exports.LookUp.SELF;else if(h instanceof oi)i=exports.LookUp.SKIP_SELF;else if(h instanceof ni)a=exports.Quantity.OPTIONAL;else if(h instanceof ti)a=exports.Quantity.MANY;else if(h instanceof ai)l=!0;else throw new Le("unknown dep modifier ".concat(h,"."))}),{paramIndex:r,identifier:o,quantity:a,lookUp:i,withNew:l}}):[]}var Ir;(function(){if(typeof requestIdleCallback<"u"&&typeof cancelIdleCallback<"u")Ir=function(n,t){var r=requestIdleCallback(n,typeof t=="number"?{timeout:t}:void 0),s=!1;return function(){s||(s=!0,cancelIdleCallback(r))}};else{var e=Object.freeze({didTimeout:!0,timeRemaining:function(){return 15}});Ir=function(n){var t=setTimeout(function(){return n(e)}),r=!1;return function(){r||(r=!0,clearTimeout(t))}}}})();var xu=function(){function e(n){var t=this;this.didRun=!1,this.selfExecutor=function(){try{t.value=n()}catch(r){t.error=r}finally{t.didRun=!0}},this.disposeCallback=Ir(function(){return t.selfExecutor()})}return e.prototype.hasRun=function(){return this.didRun},e.prototype.dispose=function(){this.disposeCallback()},e.prototype.getValue=function(){if(this.didRun||(this.dispose(),this.selfExecutor()),this.error)throw this.error;return this.value},e}(),Yt=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ln=function(){return Ln=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Ln.apply(this,arguments)},Tt=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))},Pu=300,Xt=Symbol("$$NOT_INSTANTIATED_SYMBOL"),ku=function(e){Yt(n,e);function n(t){return e.call(this,'Detecting cyclic dependency. The last identifier is "'.concat(Ge(t),'".'))||this}return n}(Le),Fu=function(e){Yt(n,e);function n(){return e.call(this,"Injector cannot be accessed after it was disposed.")||this}return n}(Le),Hu=function(e){Yt(n,e);function n(t){return e.call(this,'Async item "'.concat(Ge(t),'" returns another async item.'))||this}return n}(Le),$u=function(e){Yt(n,e);function n(t){return e.call(this,'Cannot get async item "'.concat(Ge(t),'" from sync api.'))||this}return n}(Le),ms=function(e){Yt(n,e);function n(t){return e.call(this,'Cannot add dependency "'.concat(Ge(t),'" after it is already resolved.'))||this}return n}(Le),ju=function(e){Yt(n,e);function n(t){return e.call(this,'Cannot dependency dependency "'.concat(Ge(t),'" after it is already resolved.'))||this}return n}(Le),pt=function(){function e(n,t){t===void 0&&(t=null),this.parent=t,this.children=[],this.resolutionOngoing=0,this.disposed=!1,this.dependencyCollection=new yu(n||[]),this.resolvedDependencyCollection=new Du,t&&t.children.push(this)}return e.prototype.createChild=function(n){return this._ensureInjectorNotDisposed(),new e(n,this)},e.prototype.dispose=function(){this.children.forEach(function(n){return n.dispose()}),this.children.length=0,this.dependencyCollection.dispose(),this.resolvedDependencyCollection.dispose(),this.deleteSelfFromParent(),this.disposed=!0},e.prototype.deleteSelfFromParent=function(){if(this.parent){var n=this.parent.children.indexOf(this);n>-1&&this.parent.children.splice(n,1)}},e.prototype.add=function(n){this._ensureInjectorNotDisposed();var t=n[0],r=n[1];if(this.resolvedDependencyCollection.has(t))throw new ms(t);typeof r>"u"?this.dependencyCollection.add(t):Er(r)||gr(r)||mr(r)||pr(r)?this.dependencyCollection.add(t,r):this.resolvedDependencyCollection.add(t,r)},e.prototype.replace=function(n){this._ensureInjectorNotDisposed();var t=n[0];if(this.resolvedDependencyCollection.has(t))throw new ms(t);this.dependencyCollection.delete(t),n.length===1?this.dependencyCollection.add(t):this.dependencyCollection.add(t,n[1])},e.prototype.delete=function(n){if(this._ensureInjectorNotDisposed(),this.resolvedDependencyCollection.has(n))throw new ju(n);this.dependencyCollection.delete(n)},e.prototype.invoke=function(n){for(var t=this,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];this._ensureInjectorNotDisposed();var o={get:function(i,a,l){return t._get(i,a,l)}};return n.apply(void 0,Tt([o],r,!1))},e.prototype.has=function(n){var t;return this.dependencyCollection.has(n)||((t=this.parent)===null||t===void 0?void 0:t.has(n))||!1},e.prototype.get=function(n,t,r){this._ensureInjectorNotDisposed();var s=this._get(n,t,r);if(Array.isArray(s)&&s.some(function(o){return On(o)})||On(s))throw new $u(n);return s},e.prototype._get=function(n,t,r,s){var o=exports.Quantity.REQUIRED;if(t===exports.Quantity.REQUIRED||t===exports.Quantity.OPTIONAL||t===exports.Quantity.MANY?o=t:r=t,!s){var i=this.getValue(n,o,r);if(i!==Xt)return i}return this.createDependency(n,o,r,!s)},e.prototype.getAsync=function(n){this._ensureInjectorNotDisposed();var t=this.getValue(n,exports.Quantity.REQUIRED);if(t!==Xt)return Promise.resolve(t);var r=this.createDependency(n,exports.Quantity.REQUIRED);return On(r)?r.whenReady():Promise.resolve(r)},e.prototype.createInstance=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this._ensureInjectorNotDisposed(),this._resolveClassImpl.apply(this,Tt([{useClass:n}],t,!1))},e.prototype._resolveDependency=function(n,t,r){r===void 0&&(r=!0);var s;_s(n);try{mr(t)?s=this._resolveValueDependency(n,t):pr(t)?s=this._resolveFactory(n,t,r):gr(t)?s=this._resolveClass(n,t,r):Eu(t)?s=this._resolveExisting(n,t):s=this._resolveAsync(n,t),gs()}catch(o){throw gs(),o}return s},e.prototype._resolveExisting=function(n,t){var r=this.get(t.useExisting);return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveValueDependency=function(n,t){var r=t.useValue;return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveClass=function(n,t,r){var s=this;r===void 0&&(r=!0),t.useClass;var o;if(t.lazy){var i=new xu(function(){return s._ensureInjectorNotDisposed(),s._resolveClassImpl(t)});o=new Proxy(Object.create(null),{get:function(a,l){if(l in a)return a[l];if(l!=="whenReady"){var h=i.getValue(),c=h[l];return typeof c!="function"||(c=c.bind(h),a[l]=c),c}},set:function(a,l,h){return i.getValue()[l]=h,!0}})}else o=this._resolveClassImpl(t);return n&&r&&this.resolvedDependencyCollection.add(n,o),o},e.prototype._resolveClassImpl=function(n){for(var t,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];var o=n.useClass;this.markNewResolution(o);for(var i=Jo(o).sort(function(S,y){return S.paramIndex-y.paramIndex}).map(function(S){return Ln(Ln({},S),{identifier:Au(S.identifier)})}),a=[],l=0,h=i;l<h.length;l++){var c=h[l];try{var u=this._get(c.identifier,c.quantity,c.lookUp,c.withNew);a.push(u)}catch(S){throw S instanceof Sn?new ps(o,c.identifier,c.paramIndex):S}}var d=Tt([],r,!0),f=i.length>0?i[0].paramIndex:d.length;if(d.length!==f){console.warn("[redi]: Expect ".concat(f," custom parameter(s) of ").concat(Ge(o)," but get ").concat(d.length,"."));var p=f-d.length;p>0?d=Tt(Tt([],d,!0),new Array(p).fill(void 0),!0):d=d.slice(0,f)}var m=new(o.bind.apply(o,Tt(Tt([void 0],d,!1),a,!1)));return(t=n==null?void 0:n.onInstantiation)===null||t===void 0||t.call(n,m),this.markResolutionCompleted(),m},e.prototype._resolveFactory=function(n,t,r){var s;this.markNewResolution(n);for(var o=li(t.deps),i=[],a=0,l=o;a<l.length;a++){var h=l[a];try{var c=this._get(h.identifier,h.quantity,h.lookUp,h.withNew);i.push(c)}catch(d){throw d instanceof Sn?new ps(n,h.identifier,h.paramIndex):d}}var u=t.useFactory.apply(null,i);return r&&this.resolvedDependencyCollection.add(n,u),this.markResolutionCompleted(),(s=t==null?void 0:t.onInstantiation)===null||s===void 0||s.call(t,u),u},e.prototype._resolveAsync=function(n,t){var r=this,s={__symbol:Qo,whenReady:function(){return r._resolveAsyncImpl(n,t)}};return s},e.prototype._resolveAsyncImpl=function(n,t){var r=this;return t.useAsync().then(function(s){var o=r.getValue(n);if(o!==Xt)return o;var i;if(Array.isArray(s)){var a=s[1];if(Er(a))throw new Hu(n);i=r._resolveDependency(n,a)}else Lr(s)?i=r._resolveClassImpl({useClass:s,onInstantiation:t.onInstantiation}):i=s;return r.resolvedDependencyCollection.add(n,i),i})},e.prototype.getValue=function(n,t,r){var s=this;t===void 0&&(t=exports.Quantity.REQUIRED);var o=function(){return s.dependencyCollection.has(n)&&!s.resolvedDependencyCollection.has(n)?Xt:s.resolvedDependencyCollection.get(n,t)},i=function(){return s.parent?s.parent.getValue(n,t):Xt};return r===exports.LookUp.SKIP_SELF?i():r===exports.LookUp.SELF||this.resolvedDependencyCollection.has(n)||this.dependencyCollection.has(n)?o():i()},e.prototype.createDependency=function(n,t,r,s){var o=this;t===void 0&&(t=exports.Quantity.REQUIRED),s===void 0&&(s=!0);var i=function(){var l=o.dependencyCollection.get(n,t),h=null;return Array.isArray(l)?h=l.map(function(c){return o._resolveDependency(n,c,s)}):l&&(h=o._resolveDependency(n,l,s)),h},a=function(){if(o.parent)return o.parent.createDependency(n,t,void 0,s);if(t===exports.Quantity.OPTIONAL)return null;throw _s(n),new Sn(n)};return r===exports.LookUp.SKIP_SELF?a():n===e?this:this.dependencyCollection.has(n)?i():a()},e.prototype.markNewResolution=function(n){if(this.resolutionOngoing+=1,this.resolutionOngoing>=Pu)throw new ku(n)},e.prototype.markResolutionCompleted=function(){this.resolutionOngoing-=1},e.prototype._ensureInjectorNotDisposed=function(){if(this.disposed)throw new Fu},e}();function Wu(e,n,t){t===void 0&&(t=0);var r=li(n,t);r.forEach(function(s){Pr(e,s.identifier,s.paramIndex,s.quantity,s.lookUp)})}var Es=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global,Rs="REDI_GLOBAL_LOCK",Bu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;Es[Rs]?Bu||console.error(`[redi]: You are loading scripts of redi more than once! This may cause undesired behavior in your application.
3
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function cs(e,n){if(e){var t=e.indexOf(n);0<=t&&e.splice(t,1)}}var Bo=function(){function e(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var n,t,r,s,o;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=as(i),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(m){n={error:m}}finally{try{l&&!l.done&&(t=a.return)&&t.call(a)}finally{if(n)throw n.error}}else i.remove(this);var c=this.initialTeardown;if(en(c))try{c()}catch(m){o=m instanceof nr?m.errors:[m]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=as(u),f=d.next();!f.done;f=d.next()){var p=f.value;try{hs(p)}catch(m){o=o!=null?o:[],m instanceof nr?o=us(us([],ls(o)),ls(m.errors)):o.push(m)}}}catch(m){r={error:m}}finally{try{f&&!f.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}if(o)throw new nr(o)}},e.prototype.add=function(n){var t;if(n&&n!==this)if(this.closed)hs(n);else{if(n instanceof e){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(n)}},e.prototype._hasParent=function(n){var t=this._parentage;return t===n||Array.isArray(t)&&t.includes(n)},e.prototype._addParent=function(n){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(n),t):t?[t,n]:n},e.prototype._removeParent=function(n){var t=this._parentage;t===n?this._parentage=null:Array.isArray(t)&&cs(t,n)},e.prototype.remove=function(n){var t=this._finalizers;t&&cs(t,n),n instanceof e&&n._removeParent(this)},e.EMPTY=function(){var n=new e;return n.closed=!0,n}(),e}();Bo.EMPTY;function $l(e){return e instanceof Bo||e&&"closed"in e&&en(e.remove)&&en(e.add)&&en(e.unsubscribe)}function hs(e){en(e)?e():e.unsubscribe()}function Ne(e){let n=!1;return e?$l(e)?{dispose:()=>e.unsubscribe()}:typeof e=="function"?{dispose:()=>{n||(n=!0,e())}}:e:Ne(()=>{})}function Wl(e){return Ne(()=>{e.unsubscribe()})}class Mr{constructor(){_(this,"_disposables",new Set)}add(n){const t=Ne(n);return this._disposables.add(t),{dispose:()=>{t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Ae{constructor(){_(this,"_disposed",!1);_(this,"_collection",new Mr)}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 Bl extends Ae{constructor(){super(...arguments);_(this,"dispose$",new Y.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Gl extends Ae{constructor(t){super();_(this,"_ref",0);this._rootDisposable=t}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 qt{static hasLength(n,t){return n.length===t}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 Bn(e,n){const t=e.indexOf(n);return t>-1?(e.splice(t,1),!0):!1}function Vl(e){const n=new Set,t=[];for(const r of e)n.has(r)||(n.add(r),t.push(r));return t}function Kl(e,n){for(let t=e.length-1;t>-1;t--){const r=e[t];if(n(r,t))return r}return null}function zl(e,n){if(e.length===0)return e;const t=n%e.length;return e.slice(t).concat(e.slice(0,t))}function Yl(e,n){const t=new Map;return e.forEach(r=>{const s=n(r);let o=t.get(s);t.has(s)||(o=[],t.set(s,o)),o.push(r)}),t}function Xl(e){return Array.isArray(e)?e:[e]}const ue=Symbol("newer"),Me=Symbol("older");class Go{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:n.key}):{done:!0,value:void 0}}}class Vo{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:n.value}):{done:!0,value:void 0}}}class Ko{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ue],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}var Us,Ls;Ls=ue,Us=Me;class ur{constructor(n,t){_(this,"key");_(this,"value");_(this,Ls);_(this,Us);this.key=n,this.value=t,this[ue]=void 0,this[Me]=void 0}toJSON(){return{key:this.key,value:this.value}}}class zo{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(qt.hasLength(n,1)){if(qt.isNumber(n[0])){const t=n[0];this._initialize(t,void 0);return}if(qt.isIterable(n[0])){const t=n[0];this._initialize(0,t);return}return}if(qt.hasLength(n,2)){const t=n[0],r=n[1];this._initialize(t,r)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),Ne(()=>Bn(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,t&&(this.assign(t),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ue]&&(n===this.oldest&&(this.oldest=n[ue]),n[ue][Me]=n[Me]),n[Me]&&(n[Me][ue]=n[ue]),n[ue]=void 0,n[Me]=this.newest,this.newest&&(this.newest[ue]=n),this.newest=n)}assign(n){let t,r=this.limit||Number.MAX_VALUE;this._keymap.clear();const s=n[Symbol.iterator]();for(let o=s.next();!o.done;o=s.next()){const i=new ur(o.value[0],o.value[1]);if(this._keymap.set(i.key,i),t?(t[ue]=i,i[Me]=t):this.oldest=i,t=i,r--===0)throw new Error("overflow")}this.newest=t,this.size=this._keymap.size}set(n,t){let r=this._keymap.get(n);return r?(r.value=t,this._markEntryAsUsed(r),this):(this._keymap.set(n,r=new ur(n,t)),this.newest?(this.newest[ue]=r,r[Me]=this.newest):this.oldest=r,this.newest=r,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ue]?(this.oldest=this.oldest[ue],this.oldest[Me]=void 0):(this.oldest=void 0,this.newest=void 0),n[ue]=n[Me]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(t=>t(n)),[n.key,n.value]}get(n){const t=this._keymap.get(n);if(t)return this._markEntryAsUsed(t),t.value}has(n){return this._keymap.has(n)}find(n){const t=this._keymap.get(n);return t?t.value:void 0}delete(n){const t=this._keymap.get(n);if(t)return this._keymap.delete(t.key),t[ue]&&t[Me]?(t[Me][ue]=t[ue],t[ue][Me]=t[Me]):t[ue]?(t[ue][Me]=void 0,this.oldest=t[ue]):t[Me]?(t[Me][ue]=void 0,this.newest=t[Me]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Go(this.oldest)}values(){return new Vo(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ko(this.oldest)}forEach(n,t){typeof t!="object"&&(t=this);let r=this.oldest;for(;r;)n.call(t,r.value,r.key,this),r=r[ue]}toJSON(){const n=new Array(this.size);let t=0,r=this.oldest;for(;r;)n[t++]={key:r.key,value:r.value},r=r[ue];return n}toString(){let n="",t=this.oldest;for(;t;)n+=`${String(t.key)}:${t.value}`,t=t[ue],t&&(n+=" < ");return n}}function It(e){let n=0;const t=Object.keys(e);for(const r of t){const s=Number(r);n=Math.max(n,s)}return n+1}function cr(e,n,t){const r=It(t),s=t;for(let o=r-1;o>=e;o--)s[o+1]=s[o];s[e]=n}function hr(e,n,t){const r=Object.keys(t).reduce((s,o)=>Math.max(s,Number.parseInt(o)),0)+1;for(let s=e;s<r;s++)s<e+n?delete t[s]:t[s]!==void 0&&(t[s-n]=t[s],delete t[s])}function Ql(e,n){const t=e,r=Object.keys(t),s=r.length,o=n,i=Object.keys(o),a=i.length,l={};let h=0;for(let c=0;c<s;c++,h++){const u=r[c];l[h]=t[u]}for(let c=0;c<a;c++,h++){const u=i[c];l[h]=o[u]}return l}function ql(e,n,t){const r=t;if(It(t)>0){const o={};let i=0;for(let a=e;a<=n;a++)r[a]&&(o[i]=r[a],i++);return o}return{}}function dr(e,n,t,r){const s=e>t;if(!s&&e+n>t)throw new Error("Invalid move operation");s?Zl(e,n,t,r):Jl(e,n,t,r)}function Zl(e,n,t,r){const s=r,o=[];for(let i=e;i<e+n;i++)o.push(s[i]);for(let i=e-1;i>=t;i--){const a=s[i];s[i+n]=a,a===void 0&&delete s[i+n]}o.forEach((i,a)=>{s[t+a]=i,i===void 0&&delete s[t+a]})}function Jl(e,n,t,r){const s=r,o=[];for(let i=e;i<e+n;i++)o.push(s[i]);for(let i=e+n;i<t;i++){const a=s[i];s[i-n]=a,a===void 0&&delete s[i-n]}o.forEach((i,a)=>{s[t+a-n]=i,i===void 0&&delete s[t+a-n]})}class ot{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new ot({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(n(o,i)===!1)return this}return this}forRow(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(n(o,Object.keys(i).map(l=>Number(l)))===!1)return this}return this}forValue(n){const t=this._matrix,r=Object.keys(t);for(const s of r){const o=Number(s),i=t[o];if(!i)continue;const a=Object.keys(i);for(const l of a){const h=Number(l),c=i[Number(l)];if(n(o,h,c)===!1)return this}}return this}swapRow(n,t){const r=this._matrix[n],s=this._matrix[t];this._matrix[n]=s,this._matrix[t]=r}getRow(n){return this._matrix[n]}getRowOrCreate(n){let t=this.getRow(n);return t==null&&(t={},this._matrix[n]=t),t}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,t=Object.keys(n);if(t.length===0)return!1;for(const r of t){const s=Number(r),o=n[s];if(Object.keys(o).length>0)return!0}return!1}getValue(n,t){var r,s;return(s=(r=this._matrix)==null?void 0:r[n])==null?void 0:s[t]}setValue(n,t,r){const s=this.getRowOrCreate(n);s[t]=r}deleteValue(n,t){var r,s;(s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t]}realDeleteValue(n,t){var r,s,o;if((s=(r=this._matrix)==null?void 0:r[n])==null||delete s[t],this.getRow(n)){const i=this.getRow(n);if(i==null)return;Object.keys(i).length===0&&((o=this._matrix)==null||delete o[n])}}setRow(n,t){this._matrix[n]=t}moveRows(n,t,r){dr(n,t,r,this._matrix)}moveColumns(n,t,r){this.forEach((s,o)=>{dr(n,t,r,o)})}insertRows(n,t){for(let r=n;r<n+t;r++)cr(r,{},this._matrix)}insertColumns(n,t){for(let r=n;r<n+t;r++)this.forEach((s,o)=>{o&&cr(r,void 0,o)})}removeRows(n,t){hr(n,t,this._matrix)}removeColumns(n,t){this.forEach((r,s)=>{s&&hr(n,t,s)})}getFragment(n,t,r,s){const o=new ot;let i=0;for(let a=n;a<=t;a++){const l={};let h=0;for(let c=r;c<=s;c++){const u=this.getValue(a,c);l[h]=u,h++}o.setRow(i,l),i++}return o}getSlice(n,t,r,s){const o=new ot;for(let i=n;i<=t;i++)for(let a=r;a<=s;a++){const l=this.getValue(i,a);l&&o.setValue(i,a,x.deepClone(l))}return o}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return It(this._matrix)}getRange(){const r=this.getLength()-1;let s=0;const o=this.getLength();for(let i=0;i<o;i++){const a=this.getRow(i);if(a){const l=It(a)-1;s=l>s?l:s}}return{startRow:0,startColumn:0,endRow:r,endColumn:s}}toNativeArray(){const n=new Array;return this.forValue((t,r,s)=>{n.push(s)}),n}toArray(){const n=[];return this.forRow((t,r)=>{n[t]==null&&(n[t]=[]),r.forEach(s=>{n[t][s]=this.getValue(t,s)})}),n}toFullArray(){const n=this.getRange(),{endColumn:t,endRow:r}=n,s=[];for(let o=0;o<=r;o++){const i=Array(t+1).fill(void 0);s.push(i)}return this.forValue((o,i,a)=>{s[o][i]=a}),s}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,t=0,r=!1,s=!1;const o=new ot;return this.forEach((i,a)=>{r||(r=!0,n=i),Object.keys(a).forEach(l=>{const h=Number(l);s?h<t&&(t=h):(s=!0,t=h);const c=this.getValue(i,h);o.setValue(i-n,h-t,c)})}),o.getData()}getDataRange(){let n=0,t=0,r=0,s=-1,o=!1,i=!1;return this.forEach((a,l)=>{if(o||(o=!0,n=a),l==null)return;const h=It(l)-1;h>r&&(r=h),Object.keys(l).forEach(c=>{const u=Number(c);i?u<t&&(t=u):(i=!0,t=u)}),a>s&&(s=a)}),{startRow:n,startColumn:t,endRow:s,endColumn:r}}getDiscreteRanges(){const n=[];return this.forEach((t,r)=>{Object.keys(r).forEach(s=>{const o=Number(s);let i=!1;for(const a of n)if(t>=a.startRow&&t<=a.endRow+1&&o>=a.startColumn&&o<=a.endColumn+1){a.endRow=Math.max(t,a.endRow),a.endColumn=Math.max(o,a.endColumn),i=!0;break}i||n.push({startRow:t,endRow:t,startColumn:o,endColumn:o})})}),n}merge(n){this.forValue((t,r)=>{const s=n.getValue(t,r);s!=null&&this.setValue(t,r,s)})}_setOriginValue(n={}){this._matrix=n}}const _t=class _t{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,t){return n==null||t==null?!1:n.endRow===t.endRow&&n.endColumn===t.endColumn&&n.startRow===t.startRow&&n.startColumn===t.startColumn&&(n.rangeType===t.rangeType||n.rangeType===void 0&&t.rangeType===oe.NORMAL||t.rangeType===void 0&&n.rangeType===oe.NORMAL)}static intersects(n,t){if(n.rangeType===oe.ROW&&t.rangeType===oe.COLUMN||n.rangeType===oe.COLUMN&&t.rangeType===oe.ROW)return!0;if(n.rangeType===oe.ROW&&t.rangeType===oe.ROW)return n.startRow<=t.endRow&&n.endRow>=t.startRow;if(n.rangeType===oe.COLUMN&&t.rangeType===oe.COLUMN)return n.startColumn<=t.endColumn&&n.endColumn>=t.startColumn;const r=Math.floor(Number.MAX_SAFE_INTEGER/10),s=Number.isNaN(n.startRow)?0:n.startRow,o=Number.isNaN(n.endRow)?r:n.endRow,i=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?r:n.endColumn,l=Number.isNaN(t.startRow)?0:t.startRow,h=Number.isNaN(t.endRow)?r:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,u=Number.isNaN(t.endColumn)?r:t.endColumn,d=Math.abs(i+a-c-u),f=Math.abs(i-a)+Math.abs(c-u),p=Math.abs(s+o-l-h),m=Math.abs(s-o)+Math.abs(l-h);return d<=f&&p<=m}static getIntersects(n,t){const r=n.startRow,s=n.endRow,o=n.startColumn,i=n.endColumn,a=t.startRow,l=t.endRow,h=t.startColumn,c=t.endColumn;let u,d,f,p;if(a<=s)a>=r?d=a:d=r;else return null;if(l>=r)l>=s?p=s:p=l;else return null;if(h<=i)h>o?u=h:u=o;else return null;if(c>=o)c>=i?f=i:f=c;else return null;return{startRow:d,endRow:p,startColumn:u,endColumn:f,rangeType:oe.NORMAL}}static contains(n,t){return n.startRow<=t.startRow&&n.endRow>=t.endRow&&n.startColumn<=t.startColumn&&n.endColumn>=t.endColumn}static realContain(n,t){return _t.contains(n,t)&&(n.startRow<t.startRow||n.endRow>t.endRow||n.startColumn<t.startColumn||n.endColumn>t.endColumn)}static union(...n){return n.reduce((t,r)=>({startRow:Math.min(t.startRow,r.startRow),startColumn:Math.min(t.startColumn,r.startColumn),endRow:Math.max(t.endRow,r.endRow),endColumn:Math.max(t.endColumn,r.endColumn),rangeType:oe.NORMAL}),n[0])}static realUnion(...n){const t=n.some(o=>o.rangeType===oe.COLUMN),r=n.some(o=>o.rangeType===oe.ROW),s=_t.union(...n);return{startColumn:r?Number.NaN:s.startColumn,endColumn:r?Number.NaN:s.endColumn,startRow:t?Number.NaN:s.startRow,endRow:t?Number.NaN:s.endRow,rangeType:r?oe.ROW:t?oe.COLUMN:oe.NORMAL}}static subtract(n,t){if(t.startRow>n.endRow||t.endRow<n.startRow||t.startColumn>n.endColumn||t.endColumn<n.startColumn)return[n];const r=[];t.startRow>=n.startRow&&r.push({startRow:n.startRow,startColumn:n.startColumn,endRow:t.startRow-1,endColumn:n.endColumn}),t.endRow<=n.endRow&&r.push({startRow:t.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const s=Math.max(n.startRow,t.startRow),o=Math.min(n.endRow,t.endRow);return t.startColumn>=n.startColumn&&r.push({startRow:s,startColumn:n.startColumn,endRow:o,endColumn:t.startColumn-1}),t.endColumn<=n.endColumn&&r.push({startRow:s,startColumn:t.endColumn+1,endRow:o,endColumn:n.endColumn}),r.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,t){return!(n.left>t.right||n.right<t.left||n.top>t.bottom||n.bottom<t.top)}static getIntersectionBetweenTwoRect(n,t){const r=Math.max(n.left,t.left),s=Math.min(n.right,t.right),o=Math.max(n.top,t.top),i=Math.min(n.bottom,t.bottom);return s<=r||i<=o?null:{left:r,right:s,top:o,bottom:i,width:s-r,height:i-o}}};_(_t,"getRelativeRange",(n,t)=>({startRow:n.startRow-t.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-t.startColumn,endColumn:n.endColumn-n.startColumn})),_(_t,"getPositionRange",(n,t,r)=>({...r||{},startRow:r&&[Se.ROW,Se.ALL].includes(r.startAbsoluteRefType||0)?r.startRow:n.startRow+t.startRow,endRow:r&&[Se.ROW,Se.ALL].includes(r.endAbsoluteRefType||0)?r.endRow:n.endRow+n.startRow+t.startRow,startColumn:r&&[Se.COLUMN,Se.ALL].includes(r.startAbsoluteRefType||0)?r.startColumn:n.startColumn+t.startColumn,endColumn:r&&[Se.COLUMN,Se.ALL].includes(r.endAbsoluteRefType||0)?r.endColumn:n.endColumn+n.startColumn+t.startColumn})),_(_t,"moveHorizontal",(n,t=0,r=0)=>({...n,startColumn:n.startColumn+t,endColumn:n.endColumn+t+r})),_(_t,"moveVertical",(n,t=0,r=0)=>({...n,startRow:n.startRow+t,endRow:n.endRow+t+r})),_(_t,"moveOffset",(n,t,r)=>({...n,startRow:n.startRow+r,endRow:n.endRow+r,startColumn:n.startColumn+t,endColumn:n.endColumn+t}));let vt=_t;class eu{constructor(n,t){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=n,this._keys=t,n.forEach(r=>{this._initKeyMap(r)})}_initKeyMap(n){this._keys.forEach(t=>{const r=n[t],s=this._keyMaps.get(t)||new Map;s.set(r,n),this._keyMaps.set(t,s)})}getValue(n,t){const r=t||this._keys;for(let s=0;s<r.length;s++){const o=this._keyMaps.get(r[s]);if(o!=null&&o.has(n))return o.get(n)}return null}hasValue(n){for(let t=0;t<this._keys.length;t++){const r=this._keyMaps.get(this._keys[t]);if(r!=null&&r.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,t,r){const s=this.getValue(n);s&&Object.keys(s).includes(t)&&(s[t]=r)}deleteValue(n){const t=this.getValue(n);if(t){this._keys.forEach(s=>{const o=this._keyMaps.get(s),i=t[s];o==null||o.delete(i)});const r=this._values.findIndex(s=>s===t);this._values.splice(r,1)}}getValues(){return this._values}getKeyMap(n){var t;return[...((t=this._keyMaps.get(n))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function fr(e,n,t,r){return{forEach(s){for(let o=e;o<=n;o++)for(let i=t;i<=r;i++)s(o,i)}}}function tu(e){if(e==null||e.length===0)return Number.NaN;const n=e.toLowerCase().split(""),t=n.length,r=i=>i.charCodeAt(0)-96;let s=0,o=0;for(let i=0;i<t;i++)o=r(n[i]),s+=o*26**(t-i-1);return s===0?Number.NaN:s-1}const Un=65,Yo=90,nu=97;function ru(e){const n=Yo-Un+1;let t="";for(;e>=0;)t=String.fromCharCode(e%n+Un)+t,e=Math.floor(e/n)-1;return t}function Xo(e,n){let t="";for(;n>0;)t+=e,n--;return t}function su(e,n=!1){const t=Yo-Un+1;let r=nu;n&&(r=Un);const s=String.fromCharCode(e%t+r),o=Math.floor(e/t)+1;return Xo(s,o)}function ou(e,n){return e.zIndex>n.zIndex?1:e.zIndex===n.zIndex?0:-1}function iu(e,n){return e.zIndex>n.zIndex?-1:e.zIndex===n.zIndex?0:1}function kt(e="index",n=1){return(t,r)=>t[e]>r[e]?n:t[e]===r[e]?0:-n}function au(e,n){let t;function r(...s){const o=this,i=function(){t=null,e.apply(o,s)};clearTimeout(t),t=setTimeout(i,n)}return Object.defineProperty(r,"cancel",{value:()=>{clearTimeout(t)},enumerable:!1,writable:!1}),r}function In(e,n,t){const{dataStream:r,textRuns:s=[]}=e;let o=n;const i=[];for(const a of s){const{st:l,ed:h}=a;x.hasIntersectionBetweenTwoRanges(n,t,l,h)&&(l>o?(i.push(r.slice(o,l)),i.push(_r(r,{...a,ed:Math.min(h,t)}))):i.push(_r(r,{...a,st:o,ed:Math.min(h,t)}))),o=Math.max(n,Math.min(h,t))}return o!==t&&i.push(r.slice(o,t)),i.join("")}function lu(e,n=!0){var t;if(n&&((t=e.paragraphs)!=null&&t.length)){const{dataStream:r,paragraphs:s=[]}=e;let o="",i=-1;for(const a of s){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>i+1?o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${In(e,i+1,l)}</p>`:o+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,i=l}return i!==r.length&&(o+=In(e,i,r.length)),o}else return In(e,0,e.dataStream.length)}function _r(e,n){const{st:t,ed:r,ts:s={}}=n,{ff:o,fs:i,it:a,bl:l,ul:h,st:c,ol:u,bg:d,cl:f,va:p}=s;let m=e.slice(t,r);const S=[];return a===K.TRUE&&(m=`<i>${m}</i>`),p===Gt.SUPERSCRIPT?m=`<sup>${m}</sup>`:p===Gt.SUBSCRIPT&&(m=`<sub>${m}</sub>`),(h==null?void 0:h.s)===K.TRUE&&(m=`<u>${m}</u>`),(c==null?void 0:c.s)===K.TRUE&&(m=`<s>${m}</s>`),l===K.TRUE&&(m=`<strong>${m}</strong>`),o&&S.push(`font-family: ${o}`),f&&S.push(`color: ${f.rgb}`),i&&S.push(`font-size: ${i}pt`),u&&S.push("text-decoration: overline"),d&&S.push(`background: ${d.rgb}`),S.length?`<span style="${S.join("; ")};">${m}</span>`:m}const uu={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},cu={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},hu={startRow:0,startColumn:0,endRow:0,endColumn:0},du={row:0,column:0},vn={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:on.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Dt.UNSPECIFIED,vt:Wt.UNSPECIFIED,tb:Bt.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Qo={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var qo=(e=>(e.ARRAY_CONVERTOR="ARRAY_CONVERTOR",e.MATRIX_CONVERTOR="MATRIX_CONVERTOR",e))(qo||{});function En(e,n){const{textRuns:t=[]}=n;let r=0;for(const o of t){const{ts:i={},st:a,ed:l}=o;if(i[e]==null)return K.FALSE;switch(e){case"bl":case"it":{if(i[e]===K.FALSE)return K.FALSE;break}case"ul":case"st":{if(i[e].s===K.FALSE)return K.FALSE;break}default:throw new Error(`unknown style key: ${e} in IStyleBase`)}r+=l-a}return n.dataStream.indexOf(`\r
4
+ `)===r?K.TRUE:K.FALSE}const rn=class rn{constructor(n,t,r){_(this,"_range");_(this,"_worksheet");this._deps=r,this._range=t,this._worksheet=n}static foreach(n,t){const{startRow:r,startColumn:s,endRow:o,endColumn:i}=n;for(let a=r;a<=o;a++)for(let l=s;l<=i;l++)t(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=[];for(let i=n;i<=t;i++){const a=[];for(let l=r;l<=s;l++)a.push(this.getMatrix().getValue(i,l)||null);o.push(a)}return o}getMatrix(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=this._worksheet.getCellMatrix(),i=new ot;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)i.setValue(a,l,o.getValue(a,l)||null);return i}getMatrixObject(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range,o=this._worksheet.getCellMatrix(),i=new ot;for(let a=n;a<=t;a++)for(let l=r;l<=s;l++)i.setValue(a-n,l-r,o.getValue(a,l)||{});return i}getA1Notation(){const{startRow:n,endRow:t,startColumn:r,endColumn:s}=this._range;let o,i;return r<s?(o=x.numToWord(r+1)+(n+1),i=x.numToWord(s+1)+(t+1)):(o=x.numToWord(s+1)+(t+1),i=x.numToWord(r+1)+(n+1)),o===i?`${o}`:`${o}:${i}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var o;const s=n.getStyleByCell(r);return((o=s==null?void 0:s.bg)==null?void 0:o.rgb)||vn.bg.rgb}))}getCell(n,t){const{startRow:r,endRow:s,startColumn:o,endColumn:i}=this._range,a={startRow:r+n,endRow:r+n,startColumn:o+t,endColumn:o+t};return new rn(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:t,endRow:r,startColumn:s,endColumn:o}=this._range,i=this._worksheet.getCellMatrix().getFragment(t,r,s,o).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let h=0;h<=r-t;h++)for(let c=0;c<=o-s;c++){if(i==null||((a=i==null?void 0:i[h])==null?void 0:a[c])==null)continue;const u=i[h][c].s;u&&(i[h][c].s=l.get(u))}}return i}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(t=>t.map(r=>{var o;const s=n.getStyleByCell(r);return((o=s==null?void 0:s.cl)==null?void 0:o.rgb)||vn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("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 t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("st",n.body)===K.TRUE?{s:K.TRUE}:{s:K.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var t,r;const n=((t=this.getValue())==null?void 0:t.p)||{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(s=>{var o;return((o=s==null?void 0:s.ts)==null?void 0:o.fs)!=null})?Math.max(...n.body.textRuns.map(s=>{var o;return((o=s==null?void 0:s.ts)==null?void 0:o.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 t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("it",n.body)===K.TRUE?Tn.ITALIC:Tn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var t,r;const{p:n}=(t=this.getValue())!=null?t:{};return n&&Array.isArray((r=n.body)==null?void 0:r.textRuns)&&n.body.textRuns.length>0?En("bl",n.body)===K.TRUE?yn.BOLD:yn.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:t}=this,{startRow:r,endRow:s}=n;let o=0;for(let i=0;i<=s-r;i++){const a=t.getRowHeight(i);o+=a}return o}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:t}=this._range;return t-n+1}getNumRows(){const{startRow:n,endRow:t}=this._range;return t-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(t=>(t==null?void 0:t.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(t=>t.map(r=>n.getStyleByCell(r)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:t}=this,{startColumn:r,endColumn:s}=n;let o=0;for(let i=0;i<=s-r;i++)o+=t.getColumnWidth(i);return o}getWrap(){return this.getWrapStrategy()===Bt.WRAP?K.TRUE:K.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){rn.foreach(this._range,n)}_getStyles(n){const t=this._deps.getStyles();return this.getValues().map(r=>r.map(s=>{const o=t&&t.getStyleByCell(s);return o&&o[n]||vn[n]}))}};_(rn,"transformRange",(n,t)=>n.rangeType===oe.ALL?{startColumn:0,startRow:0,endColumn:t.getMaxColumns()-1,endRow:t.getMaxRows()-1}:n.rangeType===oe.COLUMN?{startRow:0,endRow:t.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===oe.ROW?{startColumn:0,endColumn:t.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let Vt=rn;function fu(e,n){if(e.length===0||e[0].length===0)return null;const t=new Array(e[0].length).fill(0);let r=0,s=null;for(let o=0;o<e.length;o++){for(let a=0;a<e[0].length;a++)t[a]=n(e[o][a])?t[a]+1:0;const i=_u(t);i.area>r&&(r=i.area,s={startColumn:i.start,startRow:o-i.height+1,endColumn:i.end,endRow:o})}return s}function _u(e){const n=[];let t=0,r={area:0,height:0,start:0,end:0},s=0;for(;s<e.length;)if(n.length===0||e[s]>=e[n[n.length-1]])n.push(s++);else{const o=e[n.pop()],i=n.length===0?s:s-n[n.length-1]-1;o*i>t&&(t=o*i,r={area:t,height:o,start:n.length===0?0:n[n.length-1]+1,end:s-1})}for(;n.length>0;){const o=e[n.pop()],i=n.length===0?s:s-n[n.length-1]-1;o*i>t&&(t=o*i,r={area:t,height:o,start:n.length===0?0:n[n.length-1]+1,end:s-1})}return r}function gu(e,n){Vt.foreach(n,(t,r)=>{e[t][r]=void 0})}function pu(e,n){const t=e.toFullArray(),r=[];for(;;){const s=fu(t,n);if(!s)break;r.push(s),gu(t,s)}return r}function mu(e,n,t,r=!1){let s={...e};const o=s.startAbsoluteRefType||Se.NONE,i=s.endAbsoluteRefType||Se.NONE;return!r&&o===Se.ALL&&i===Se.ALL?s:r||o===Se.NONE&&i===Se.NONE?vt.moveOffset(s,n,t):(o===Se.NONE?s={...s,startRow:s.startRow+t,startColumn:s.startColumn+n}:o===Se.COLUMN?s={...s,startRow:s.startRow+t}:o===Se.ROW&&(s={...s,startColumn:s.startColumn+n}),i===Se.NONE?s={...s,endRow:s.endRow+t,endColumn:s.endColumn+n}:i===Se.COLUMN?s={...s,endRow:s.endRow+t}:i===Se.ROW&&(s={...s,endColumn:s.endColumn+n}),s)}var Ur=Symbol("$$IDENTIFIER_DECORATOR");function Eu(e){return e&&e[Ur]===!0}function Lr(e){return typeof e=="function"}function gr(e){return!!(e&&typeof e.useClass<"u")}function pr(e){return!!(e&&typeof e.useFactory<"u")}function mr(e){return!!(e&&typeof e.useValue<"u")}function Ru(e){return!!(e&&typeof e.useExisting<"u")}function Er(e){return!!(e&&typeof e.useAsync<"u")}var Zo=Symbol("AsyncHook");function On(e){return!!(e&&e.__symbol===Zo)}function Ge(e){return typeof e>"u"?"undefined":Lr(e)&&!e[Ur]?e.name:e.toString()}exports.Quantity=void 0;(function(e){e.MANY="many",e.OPTIONAL="optional",e.REQUIRED="required"})(exports.Quantity||(exports.Quantity={}));exports.LookUp=void 0;(function(e){e.SELF="self",e.SKIP_SELF="skipSelf"})(exports.LookUp||(exports.LookUp={}));var Cu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Le=function(e){Cu(n,e);function n(t){return e.call(this,"[redi]: ".concat(t))||this}return n}(Error),Jo=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),ds=Symbol("$$TARGET"),Rr=Symbol("$$DEPENDENCIES"),Iu=function(e){Jo(n,e);function n(t,r){var s="Could not find dependency registered on the ".concat(t,' (indexed) parameter of the constructor of "').concat(Ge(r),'".');return e.call(this,s)||this}return n}(Le),ei=function(e){Jo(n,e);function n(t,r){var s='It seems that you register "undefined" as dependency on the '.concat(r+1,' parameter of "').concat(Ge(t),'". Please make sure that there is not cyclic dependency among your TypeScript files, or consider using "forwardRef". For more info please visit our website https://redi.wendell.fun/docs/debug#could-not-find-dependency-registered-on');return e.call(this,s)||this}return n}(Le);function ti(e){var n=e;return n[Rr]||[]}function xr(e,n){var t=ti(e),r=t.find(function(s){return s.paramIndex===n});if(!r)throw new Iu(n,e);return r}function Pr(e,n,t,r,s){r===void 0&&(r=exports.Quantity.REQUIRED);var o={paramIndex:t,identifier:n,quantity:r,lookUp:s,withNew:!1};if(typeof n>"u")throw new ei(e,t);var i=e;i[ds]===i?i[Rr].push(o):(i[Rr]=[o],i[ds]=i)}var fs=new Set;function Ve(e){if(fs.has(e))throw new Le('Identifier "'.concat(e,'" already exists.'));fs.add(e);var n=function(t,r,s){Pr(t,n,s)};return n.toString=function(){return e},n[Ur]=!0,n}var vu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ou=function(e){vu(n,e);function n(t,r,s){var o='Expect "'.concat(r,'" dependency items for id "').concat(Ge(t),'" but get ').concat(s,".");return e.call(this,o)||this}return n}(Le);function ni(e,n,t){if(n===exports.Quantity.OPTIONAL&&t>1||n===exports.Quantity.REQUIRED&&t!==1)throw new Ou(e,n,t)}function Su(e,n){return e===exports.Quantity.MANY?n:n[0]}function Nu(e,n,t){var r=xr(e,n);r.quantity=t}function kr(e){return function n(t){return this instanceof n?this:function(r,s,o){if(t)Pr(r,t,o,e);else{if(e===exports.Quantity.REQUIRED)throw new ei(r,o);Nu(r,o,e)}}}}var ri=kr(exports.Quantity.MANY),si=kr(exports.Quantity.OPTIONAL),it=kr(exports.Quantity.REQUIRED);function wu(e){return{unwrap:e}}function bu(e){return!!e&&typeof e.unwrap=="function"}function Au(e){return bu(e)?e.unwrap():e}function Cr(e){return!!e&&typeof e.dispose=="function"}var oi=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}();function Tu(e){return e.length===1}var Gn=[];function _s(e){Gn.push(e)}function gs(){Gn.pop()}function yu(){Gn.length=0}var ps=function(e){oi(n,e);function n(t,r,s){var o='Cannot find "'.concat(Ge(r),'" registered by any injector. It is the ').concat(s,'th param of "').concat(Eu(t)?Ge(t):t.name,'".');return e.call(this,o)||this}return n}(Le),Sn=function(e){oi(n,e);function n(t){var r=this,s='Cannot find "'.concat(Ge(t),'" registered by any injector. The stack of dependencies is: "').concat(Gn.map(function(o){return Ge(o)}).join(" -> "),'".');return r=e.call(this,s)||this,yu(),r}return n}(Le),Du=function(){function e(n){var t=this;this.dependencyMap=new Map,this.normalizeDependencies(n).map(function(r){return t.add(r[0],r[1])})}return e.prototype.add=function(n,t){typeof t>"u"&&(t={useClass:n,lazy:!1});var r=this.dependencyMap.get(n);typeof r>"u"&&(r=[],this.dependencyMap.set(n,r)),r.push(t)},e.prototype.delete=function(n){this.dependencyMap.delete(n)},e.prototype.get=function(n,t){t===void 0&&(t=exports.Quantity.REQUIRED);var r=this.dependencyMap.get(n);return ni(n,t,r.length),Su(t,r)},e.prototype.has=function(n){return this.dependencyMap.has(n)},e.prototype.append=function(n){var t=this;this.normalizeDependencies(n).forEach(function(r){return t.add(r[0],r[1])})},e.prototype.dispose=function(){this.dependencyMap.clear()},e.prototype.normalizeDependencies=function(n){return n.map(function(t){var r=t[0],s;return Tu(t)?s={useClass:t[0],lazy:!1}:s=t[1],[r,s]})},e}(),Mu=function(){function e(){this.resolvedDependencies=new Map}return e.prototype.add=function(n,t){var r=this.resolvedDependencies.get(n);typeof r>"u"&&(r=[],this.resolvedDependencies.set(n,r)),r.push(t)},e.prototype.has=function(n){return this.resolvedDependencies.has(n)},e.prototype.delete=function(n){if(this.resolvedDependencies.has(n)){var t=this.resolvedDependencies.get(n);t.forEach(function(r){return Cr(r)?r.dispose():void 0}),this.resolvedDependencies.delete(n)}},e.prototype.get=function(n,t){t===void 0&&(t=exports.Quantity.REQUIRED);var r=this.resolvedDependencies.get(n);if(!r)throw new Sn(n);return ni(n,t,r.length),t===exports.Quantity.MANY?r:r[0]},e.prototype.dispose=function(){Array.from(this.resolvedDependencies.values()).forEach(function(n){n.forEach(function(t){return Cr(t)?t.dispose():void 0})}),this.resolvedDependencies.clear()},e}();function Uu(e,n,t){var r=xr(e,n);r.lookUp=t}function ii(e){return function n(){return this instanceof n?this:function(t,r,s){Uu(t,s,e)}}}var ai=ii(exports.LookUp.SKIP_SELF),li=ii(exports.LookUp.SELF);function Lu(e,n,t){var r=xr(e,n);r.withNew=t}function xu(e){return function n(){return this instanceof n?this:function(t,r,s){Lu(t,s,e)}}}var ui=xu(!0);function ci(e,n){return n===void 0&&(n=0),e?e.map(function(t,r){if(r+=n,!Array.isArray(t))return{paramIndex:r,identifier:t,quantity:exports.Quantity.REQUIRED,withNew:!1};var s=t.slice(0,t.length-1),o=t[t.length-1],i=void 0,a=exports.Quantity.REQUIRED,l=!1;return s.forEach(function(h){if(h instanceof li)i=exports.LookUp.SELF;else if(h instanceof ai)i=exports.LookUp.SKIP_SELF;else if(h instanceof si)a=exports.Quantity.OPTIONAL;else if(h instanceof ri)a=exports.Quantity.MANY;else if(h instanceof ui)l=!0;else throw new Le("unknown dep modifier ".concat(h,"."))}),{paramIndex:r,identifier:o,quantity:a,lookUp:i,withNew:l}}):[]}var Ir;(function(){if(typeof requestIdleCallback<"u"&&typeof cancelIdleCallback<"u")Ir=function(n,t){var r=requestIdleCallback(n,typeof t=="number"?{timeout:t}:void 0),s=!1;return function(){s||(s=!0,cancelIdleCallback(r))}};else{var e=Object.freeze({didTimeout:!0,timeRemaining:function(){return 15}});Ir=function(n){var t=setTimeout(function(){return n(e)}),r=!1;return function(){r||(r=!0,clearTimeout(t))}}}})();var Pu=function(){function e(n){var t=this;this.didRun=!1,this.selfExecutor=function(){try{t.value=n()}catch(r){t.error=r}finally{t.didRun=!0}},this.disposeCallback=Ir(function(){return t.selfExecutor()})}return e.prototype.hasRun=function(){return this.didRun},e.prototype.dispose=function(){this.disposeCallback()},e.prototype.getValue=function(){if(this.didRun||(this.dispose(),this.selfExecutor()),this.error)throw this.error;return this.value},e}(),zt=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ln=function(){return Ln=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Ln.apply(this,arguments)},Tt=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))},ku=300,Xt=Symbol("$$NOT_INSTANTIATED_SYMBOL"),Fu=function(e){zt(n,e);function n(t){return e.call(this,'Detecting cyclic dependency. The last identifier is "'.concat(Ge(t),'".'))||this}return n}(Le),Hu=function(e){zt(n,e);function n(){return e.call(this,"Injector cannot be accessed after it was disposed.")||this}return n}(Le),ju=function(e){zt(n,e);function n(t){return e.call(this,'Async item "'.concat(Ge(t),'" returns another async item.'))||this}return n}(Le),$u=function(e){zt(n,e);function n(t){return e.call(this,'Cannot get async item "'.concat(Ge(t),'" from sync api.'))||this}return n}(Le),ms=function(e){zt(n,e);function n(t){return e.call(this,'Cannot add dependency "'.concat(Ge(t),'" after it is already resolved.'))||this}return n}(Le),Wu=function(e){zt(n,e);function n(t){return e.call(this,'Cannot dependency dependency "'.concat(Ge(t),'" after it is already resolved.'))||this}return n}(Le),pt=function(){function e(n,t){t===void 0&&(t=null),this.parent=t,this.children=[],this.resolutionOngoing=0,this.disposed=!1,this.dependencyCollection=new Du(n||[]),this.resolvedDependencyCollection=new Mu,t&&t.children.push(this)}return e.prototype.createChild=function(n){return this._ensureInjectorNotDisposed(),new e(n,this)},e.prototype.dispose=function(){this.children.forEach(function(n){return n.dispose()}),this.children.length=0,this.dependencyCollection.dispose(),this.resolvedDependencyCollection.dispose(),this.deleteSelfFromParent(),this.disposed=!0},e.prototype.deleteSelfFromParent=function(){if(this.parent){var n=this.parent.children.indexOf(this);n>-1&&this.parent.children.splice(n,1)}},e.prototype.add=function(n){this._ensureInjectorNotDisposed();var t=n[0],r=n[1];if(this.resolvedDependencyCollection.has(t))throw new ms(t);typeof r>"u"?this.dependencyCollection.add(t):Er(r)||gr(r)||mr(r)||pr(r)?this.dependencyCollection.add(t,r):this.resolvedDependencyCollection.add(t,r)},e.prototype.replace=function(n){this._ensureInjectorNotDisposed();var t=n[0];if(this.resolvedDependencyCollection.has(t))throw new ms(t);this.dependencyCollection.delete(t),n.length===1?this.dependencyCollection.add(t):this.dependencyCollection.add(t,n[1])},e.prototype.delete=function(n){if(this._ensureInjectorNotDisposed(),this.resolvedDependencyCollection.has(n))throw new Wu(n);this.dependencyCollection.delete(n)},e.prototype.invoke=function(n){for(var t=this,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];this._ensureInjectorNotDisposed();var o={get:function(i,a,l){return t._get(i,a,l)}};return n.apply(void 0,Tt([o],r,!1))},e.prototype.has=function(n){var t;return this.dependencyCollection.has(n)||((t=this.parent)===null||t===void 0?void 0:t.has(n))||!1},e.prototype.get=function(n,t,r){this._ensureInjectorNotDisposed();var s=this._get(n,t,r);if(Array.isArray(s)&&s.some(function(o){return On(o)})||On(s))throw new $u(n);return s},e.prototype._get=function(n,t,r,s){var o=exports.Quantity.REQUIRED;if(t===exports.Quantity.REQUIRED||t===exports.Quantity.OPTIONAL||t===exports.Quantity.MANY?o=t:r=t,!s){var i=this.getValue(n,o,r);if(i!==Xt)return i}return this.createDependency(n,o,r,!s)},e.prototype.getAsync=function(n){this._ensureInjectorNotDisposed();var t=this.getValue(n,exports.Quantity.REQUIRED);if(t!==Xt)return Promise.resolve(t);var r=this.createDependency(n,exports.Quantity.REQUIRED);return On(r)?r.whenReady():Promise.resolve(r)},e.prototype.createInstance=function(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return this._ensureInjectorNotDisposed(),this._resolveClassImpl.apply(this,Tt([{useClass:n}],t,!1))},e.prototype._resolveDependency=function(n,t,r){r===void 0&&(r=!0);var s;_s(n);try{mr(t)?s=this._resolveValueDependency(n,t):pr(t)?s=this._resolveFactory(n,t,r):gr(t)?s=this._resolveClass(n,t,r):Ru(t)?s=this._resolveExisting(n,t):s=this._resolveAsync(n,t),gs()}catch(o){throw gs(),o}return s},e.prototype._resolveExisting=function(n,t){var r=this.get(t.useExisting);return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveValueDependency=function(n,t){var r=t.useValue;return this.resolvedDependencyCollection.add(n,r),r},e.prototype._resolveClass=function(n,t,r){var s=this;r===void 0&&(r=!0),t.useClass;var o;if(t.lazy){var i=new Pu(function(){return s._ensureInjectorNotDisposed(),s._resolveClassImpl(t)});o=new Proxy(Object.create(null),{get:function(a,l){if(l in a)return a[l];if(l!=="whenReady"){var h=i.getValue(),c=h[l];return typeof c!="function"||(c=c.bind(h),a[l]=c),c}},set:function(a,l,h){return i.getValue()[l]=h,!0}})}else o=this._resolveClassImpl(t);return n&&r&&this.resolvedDependencyCollection.add(n,o),o},e.prototype._resolveClassImpl=function(n){for(var t,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];var o=n.useClass;this.markNewResolution(o);for(var i=ti(o).sort(function(S,y){return S.paramIndex-y.paramIndex}).map(function(S){return Ln(Ln({},S),{identifier:Au(S.identifier)})}),a=[],l=0,h=i;l<h.length;l++){var c=h[l];try{var u=this._get(c.identifier,c.quantity,c.lookUp,c.withNew);a.push(u)}catch(S){throw S instanceof Sn?new ps(o,c.identifier,c.paramIndex):S}}var d=Tt([],r,!0),f=i.length>0?i[0].paramIndex:d.length;if(d.length!==f){console.warn("[redi]: Expect ".concat(f," custom parameter(s) of ").concat(Ge(o)," but get ").concat(d.length,"."));var p=f-d.length;p>0?d=Tt(Tt([],d,!0),new Array(p).fill(void 0),!0):d=d.slice(0,f)}var m=new(o.bind.apply(o,Tt(Tt([void 0],d,!1),a,!1)));return(t=n==null?void 0:n.onInstantiation)===null||t===void 0||t.call(n,m),this.markResolutionCompleted(),m},e.prototype._resolveFactory=function(n,t,r){var s;this.markNewResolution(n);for(var o=ci(t.deps),i=[],a=0,l=o;a<l.length;a++){var h=l[a];try{var c=this._get(h.identifier,h.quantity,h.lookUp,h.withNew);i.push(c)}catch(d){throw d instanceof Sn?new ps(n,h.identifier,h.paramIndex):d}}var u=t.useFactory.apply(null,i);return r&&this.resolvedDependencyCollection.add(n,u),this.markResolutionCompleted(),(s=t==null?void 0:t.onInstantiation)===null||s===void 0||s.call(t,u),u},e.prototype._resolveAsync=function(n,t){var r=this,s={__symbol:Zo,whenReady:function(){return r._resolveAsyncImpl(n,t)}};return s},e.prototype._resolveAsyncImpl=function(n,t){var r=this;return t.useAsync().then(function(s){var o=r.getValue(n);if(o!==Xt)return o;var i;if(Array.isArray(s)){var a=s[1];if(Er(a))throw new ju(n);i=r._resolveDependency(n,a)}else Lr(s)?i=r._resolveClassImpl({useClass:s,onInstantiation:t.onInstantiation}):i=s;return r.resolvedDependencyCollection.add(n,i),i})},e.prototype.getValue=function(n,t,r){var s=this;t===void 0&&(t=exports.Quantity.REQUIRED);var o=function(){return s.dependencyCollection.has(n)&&!s.resolvedDependencyCollection.has(n)?Xt:s.resolvedDependencyCollection.get(n,t)},i=function(){return s.parent?s.parent.getValue(n,t):Xt};return r===exports.LookUp.SKIP_SELF?i():r===exports.LookUp.SELF||this.resolvedDependencyCollection.has(n)||this.dependencyCollection.has(n)?o():i()},e.prototype.createDependency=function(n,t,r,s){var o=this;t===void 0&&(t=exports.Quantity.REQUIRED),s===void 0&&(s=!0);var i=function(){var l=o.dependencyCollection.get(n,t),h=null;return Array.isArray(l)?h=l.map(function(c){return o._resolveDependency(n,c,s)}):l&&(h=o._resolveDependency(n,l,s)),h},a=function(){if(o.parent)return o.parent.createDependency(n,t,void 0,s);if(t===exports.Quantity.OPTIONAL)return null;throw _s(n),new Sn(n)};return r===exports.LookUp.SKIP_SELF?a():n===e?this:this.dependencyCollection.has(n)?i():a()},e.prototype.markNewResolution=function(n){if(this.resolutionOngoing+=1,this.resolutionOngoing>=ku)throw new Fu(n)},e.prototype.markResolutionCompleted=function(){this.resolutionOngoing-=1},e.prototype._ensureInjectorNotDisposed=function(){if(this.disposed)throw new Hu},e}();function Bu(e,n,t){t===void 0&&(t=0);var r=ci(n,t);r.forEach(function(s){Pr(e,s.identifier,s.paramIndex,s.quantity,s.lookUp)})}var Es=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global,Rs="REDI_GLOBAL_LOCK",Gu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;Es[Rs]?Gu||console.error(`[redi]: You are loading scripts of redi more than once! This may cause undesired behavior in your application.
5
5
  Maybe your dependencies added redi as its dependency and bundled redi to its dist files. Or you import different versions of redi.
6
- For more info please visit our website: https://redi.wendell.fun/en-US/docs/debug#import-scripts-of-redi-more-than-once`):Es[Rs]=!0;var Cs="REDI_CONTEXT_LOCK",Gu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Is=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global;Is[Cs]?Gu||console.error(`[redi]: "RediContext" is already created. You may import "RediContext" from different paths. Use "import { RediContext } from '@wendellhu/redi/react-bindings'; instead."`):Is[Cs]=!0;var un=st.createContext({injector:null});un.displayName="RediContext";var Fr=un.Provider,ui=un.Consumer,Vu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ku=function(e){Vu(n,e);function n(){return e.call(this,"Using dependency injection outside of a RediContext.")||this}return n}(Le);function ci(){var e=st.useContext(un);if(!e.injector)throw new Ku;return e.injector}function Yu(e,n,t){var r=ci();return st.useMemo(function(){return r.get(e,n,t)},[e,n,t])}var xn=function(){return xn=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},xn.apply(this,arguments)};function zu(e){var n=e.children,t=e.dependencies,r=st.useRef(null);return st.useEffect(function(){return function(){var s;return(s=r.current)===null||s===void 0?void 0:s.dispose()}},[]),st.createElement(ui,null,function(s){var o;return r.current?o=r.current:(o=s.injector?s.injector.createChild(t):new pt(t),r.current=o),st.createElement(Fr,{value:{injector:o}},n)})}function Xu(e,n){return function(r){return st.createElement(Fr,{value:{injector:n}},st.createElement(e,xn({},r)))}}function Qu(e,n){return function(r){return st.createElement(zu,{dependencies:n},st.createElement(e,xn({},r)))}}var qu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Zu=function(e){qu(n,e);function n(t){return e.call(this,'You should make "RediContext" as '.concat(t.constructor.name,"'s default context type. ")+"If you want to use multiple context, please check this on React doc site. https://reactjs.org/docs/context.html#classcontexttype")||this}return n}(Le);function Ju(e,n,t){return function(){return{get:function(){var r=this,s=r.context;if(!s||!s.injector)throw new Zu(r);var o=s.injector,i=o.get(e,n||exports.Quantity.REQUIRED,t);return i}}}}var ec=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))};function hi(e,n){var t=e instanceof q.BehaviorSubject&&typeof n>"u"?e.getValue():n,r=Pe.useState(t),s=r[0],o=r[1];return Pe.useEffect(function(){var i=e.subscribe(function(a){return o(a)});return function(){return i.unsubscribe()}},[e]),s}function vs(e){return typeof e=="function"?e():e}function tc(e,n,t,r){if(typeof e=="function"&&!r)throw new Le("Expected deps to be provided when observable is a function!");var s=Pe.useRef(null),o=Pe.useRef(!1),i=Pe.useMemo(function(){return e},ec([],typeof r<"u"?r:[e],!0)),a=Pe.useState(0);a[0];var l=a[1],h=Pe.useRef(function(){var c;if(i){var u=vs(i).subscribe(function(d){o.current=!0,c=d});u.unsubscribe()}return c!=null?c:n}());if(Pe.useEffect(function(){var c=null;return i&&(s.current=vs(i),c=s.current.subscribe(function(u){h.current=u,l(function(d){return d+1})})),function(){return c==null?void 0:c.unsubscribe()}},[i]),t&&!o.current)throw new Error("Expect `shouldHaveSyncValue` but not getting a sync value!");return h.current}function nc(e){var n=Pe.useState(0),t=n[1];Pe.useEffect(function(){var r=e.subscribe(function(){return t(function(s){return s+1})});return function(){return r.unsubscribe()}},[])}var vr=new WeakMap;function rc(e,n){var t=Pe.useRef(void 0),r=hi(e,n),s=Pe.useMemo(function(){return Pe.createContext(r)},[e]),o=Pe.useCallback(function(i){return Pe.createElement(s.Provider,{value:r},i.children)},[e,r]);return t.current!==e&&(t.current&&vr.delete(t.current),t.current=e,vr.set(e,s)),{Provider:o,value:r}}function sc(e){var n=vr.get(e);if(!n)throw new Le("try to read context value but no ancestor component subscribed it.");return Pe.useContext(n)}async function di(e){for(const[n,t]of e.entries())try{if(!await t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}function fi(e){for(const[n,t]of e.entries())try{if(!t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}const cn=Ve("univer.context-service");class _i extends be{constructor(){super(...arguments);_(this,"_contextChanged$",new q.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(t){var r;return(r=this._contextMap.get(t))!=null?r:!1}setContextValue(t,r){this._contextMap.set(t,r),this._contextChanged$.next({[t]:r})}subscribeContextValue$(t){return new q.Observable(r=>{const s=this._contextChanged$.pipe(q.filter(o=>typeof o[t]<"u")).subscribe(o=>r.next(o[t]));return this._contextMap.has(t)&&r.next(this._contextMap.get(t)),()=>s.unsubscribe()})}}var gi=(e=>(e[e.SILENT=0]="SILENT",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.VERBOSE=4]="VERBOSE",e))(gi||{});const St=Ve("univer.log");class pi extends be{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...t){this._logLevel>=4&&this._log(console.debug,...t)}log(...t){this._logLevel>=3&&this._log(console.log,...t)}warn(...t){this._logLevel>=2&&this._log(console.warn,...t)}error(...t){this._logLevel>=1&&this._log(console.error,...t)}setLogLevel(t){this._logLevel=t}_log(t,...r){const s=r[0];/^\[(.*?)\]/g.test(s)?t(`\x1B[97;104m${s}\x1B[0m`,...r.slice(1)):t(...r)}}var oc=Object.defineProperty,ic=Object.getOwnPropertyDescriptor,ac=(e,n,t,r)=>{for(var s=r>1?void 0:r?ic(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&oc(n,t,s),s},Os=(e,n)=>(t,r)=>n(t,r,e),hn=(e=>(e[e.COMMAND=0]="COMMAND",e[e.OPERATION=1]="OPERATION",e[e.MUTATION=2]="MUTATION",e))(hn||{});const dn=Ve("anywhere.command-service");class lc{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),Ne(()=>{var t;this._commands.delete(n.id),this._commandTypes.delete(n.id),(t=n.onDispose)==null||t.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 mi={id:"nil",type:0,handler:()=>!0};exports.CommandService=class extends be{constructor(t,r){super();_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=t,this._logService=r,this._commandRegistry=new lc,this._registerCommand(mi)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(t){return this._commandRegistry.hasCommand(t)}registerCommand(t){return this._registerCommand(t)}registerMultipleCommand(t){return this._registerMultiCommand(t)}beforeCommandExecuted(t){if(this._beforeCommandExecutionListeners.indexOf(t)===-1)return this._beforeCommandExecutionListeners.push(t),Ne(()=>{const r=this._beforeCommandExecutionListeners.indexOf(t);this._beforeCommandExecutionListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(t){if(this._commandExecutedListeners.indexOf(t)===-1)return this._commandExecutedListeners.push(t),Ne(()=>{const r=this._commandExecutedListeners.indexOf(t);this._commandExecutedListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(t,r,s){try{const o=this._commandRegistry.getCommand(t);if(o){const[i]=o,a={id:i.id,type:i.type,params:r},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(c=>c(a,s));const h=await this._execute(i,r,s);return this._commandExecutedListeners.forEach(c=>c(a,s)),l.dispose(),h}throw new Error(`[CommandService]: command "${t}" is not registered.`)}catch(o){throw this._logService.error(o),o}}syncExecuteCommand(t,r,s){var i;const o=this._commandRegistry.getCommand(t);if(o){const[a]=o,l={id:a.id,type:a.type,params:r};if(a.type===2){const u=Vl(this._commandExecutionStack,d=>d.type===0);u&&(l.params=(i=l.params)!=null?i:{},l.params.trigger=u.id)}const h=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(u=>u(l,s));const c=this._syncExecute(a,r,s);return this._commandExecutedListeners.forEach(u=>u(l,s)),h.dispose(),c}throw new Error(`[CommandService]: command "${t}" is not registered.`)}_pushCommandExecutionStack(t){return this._commandExecutionStack.push(t),Ne(()=>Bn(this._commandExecutionStack,t))}_registerCommand(t){return this._commandRegistry.registerCommand(t)}_registerMultiCommand(t){const r=this._commandRegistry.getCommand(t.id);let s;if(r){if(r[0].multi!==!0)throw new Error("Command has registered as a single command.");s=r[0]}else{const i=new Mr;s=new uc(t.id),i.add(this._commandRegistry.registerCommand(s)),i.add(Ne(()=>{this._multiCommandDisposables.delete(t.id)})),this._multiCommandDisposables.set(t.id,i)}const o=s.registerImplementation(t);return Ne(()=>{var i;o.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(t.id))==null||i.dispose()})}async _execute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${t.id}"`),this._commandExecutingLevel++;let o;try{o=await this._injector.invoke(t.handler,r,s),this._commandExecutingLevel--}catch(i){throw o=!1,this._commandExecutingLevel=0,i}return o}_syncExecute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${t.id}".`),this._commandExecutingLevel++;let o;try{if(o=this._injector.invoke(t.handler,r,s),o instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw o=!1,this._commandExecutingLevel=0,i}return o}};exports.CommandService=ac([Os(0,it(pt)),Os(1,St)],exports.CommandService);class uc{constructor(n){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(n,t)=>{if(!this._implementations.length)return!1;const r=n.get(St),s=n.get(cn),o=n.get(pt);for(const i of this._implementations){const a=i.command.preconditions;if((!a||a&&a(s))&&(r.debug("[MultiCommand]",`executing implementation "${i.command.name}".`),await o.invoke(i.command.handler,t)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const t={command:n};return this._implementations.push(t),this._implementations.sort((r,s)=>s.command.priority-r.command.priority),Ne(()=>{var s;const r=this._implementations.indexOf(t);this._implementations.splice(r,1),(s=n.onDispose)==null||s.call(n)})}hasImplementations(){return this._implementations.length>0}}function Hr(e,n,t){const r=e.map(s=>()=>n.syncExecuteCommand(s.id,s.params,t));return fi(r)}function cc(e,n,t){const r=e.map(s=>()=>n.executeCommand(s.id,s.params,t));return di(r)}function Ei(e){return new q.Observable(n=>{const t=e((...r)=>n.next(r));return()=>t==null?void 0:t.dispose()})}function Ri(e){return function(t){return new q.Observable(r=>(t.subscribe({next:s=>{r.next(s),e(s)&&r.complete()},complete:()=>r.complete(),error:s=>r.error(s)}),()=>r.unsubscribe()))}}const hc=e=>new Promise(n=>{q.merge(Ei(e.onCommandExecuted.bind(e)).pipe(Cn.filter(([t])=>t.type===hn.MUTATION)),q.timer(300)).pipe(Cn.debounceTime(16),Cn.first()).subscribe(()=>{n()})});var Ze=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.OK=1]="OK",e[e.INTERNAL_ERROR=2]="INTERNAL_ERROR",e[e.PERMISSION_DENIED=3]="PERMISSION_DENIED",e[e.NOT_FOUND=4]="NOT_FOUND",e[e.UNAUTHENTICATED=5]="UNAUTHENTICATED",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",e[e.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",e[e.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",e[e.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",e[e.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",e[e.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",e[e.APPLY_REJECT=7001]="APPLY_REJECT",e[e.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",e[e.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",e[e.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",e[e.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",e[e.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",e[e.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",e[e.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",e[e.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",e[e.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",e[e.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",e[e.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ze||{});function Ci(e){return!!(e&&e.code&&e.code!==Ze.OK&&e.code!=="OK")}var J=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(J||{}),Ii=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ii||{}),$e=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))($e||{}),Nn=(e=>(e[e.Unkonwn=0]="Unkonwn",e[e.Workbook=1]="Workbook",e[e.Worksheet=2]="Worksheet",e[e.SelectRange=3]="SelectRange",e[e.Document=4]="Document",e[e.Slide=5]="Slide",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Nn||{});class Vn extends be{}class $r{constructor(){_(this,"_data",[])}static create(){return new $r}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const t=this._data.indexOf(n);this._data.splice(t,1)}getData(){return this._data}}class jr{constructor(){_(this,"_data",new Map)}static create(){return new jr}add(n,t){this._data.has(n)||this._data.set(n,t)}delete(n){this._data.delete(n)}getData(){return this._data}}var vi=(e=>(e[e.PARAGRAPH=0]="PARAGRAPH",e[e.SECTION_BREAK=1]="SECTION_BREAK",e[e.TABLE=2]="TABLE",e[e.TABLE_ROW=3]="TABLE_ROW",e[e.TABLE_CELL=4]="TABLE_CELL",e[e.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",e))(vi||{}),gt=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
7
- `,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(gt||{}),Pn=(e=>(e.BULLET_LIST="BULLET_LIST",e.ORDER_LIST="ORDER_LIST",e))(Pn||{});const dc={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function Wr(e){const n=[];for(const t of e){const{ed:r,ts:s}=t;if(t.sId===void 0&&delete t.sId,x.isEmptyObject(s)&&t.sId==null)continue;if(n.length===0){n.push(t);continue}const o=n.pop();ko(t,o)&&x.hasIntersectionBetweenTwoRanges(o.st,o.ed,t.st,t.ed)?n.push({...t,st:o.st,ed:r}):n.push(o,t)}return n}function Oi(e,n,t,r){var h;const{textRuns:s}=e;if(s==null)return;const o=[],i=s.length;let a=!1;const l=(h=n.textRuns)!=null?h:[];if(l.length)for(const c of l)c.st+=r,c.ed+=r;for(let c=0;c<i;c++){const u=s[c],d=s[c+1],{st:f,ed:p}=u;if(p<r)o.push(u);else if(r>=f&&r<=p){if(d&&d.st===d.ed&&r===d.st){o.push(u);continue}if(a)u.st+=t,u.ed+=t,o.push(u);else{a=!0,u.ed+=t;const m=[];if(l.length){const S={...u,st:f,ed:l[0].st};S.ed>S.st&&m.push(S),m.push(...l);const y=l[l.length-1],ee={...u,st:y.ed,ed:p+t};ee.ed>ee.st&&m.push(ee)}else m.push(u);o.push(...m)}}else u.st+=t,u.ed+=t,a||(a=!0,o.push(...l)),o.push(u)}a||(a=!0,o.push(...l)),e.textRuns=Wr(o)}function Br(e,n,t,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:o,dataStream:i}=n,a=[];let l=-1;for(let c=0,u=s.length;c<u;c++){const d=s[c],{startIndex:f}=d;f>=r&&(d.startIndex+=t),l===-1&&f>=r&&(l=c),a.push(d.startIndex)}let h=-1;if(o){for(let c=0,u=o.length;c<u;c++){const d=o[c];d.startIndex+=r;const f=d.startIndex;h=a.indexOf(f)}if(i===gt.PARAGRAPH&&o.length===1){const c=s[l],u=o[0],d=c.paragraphStyle,f=c.bullet;c.paragraphStyle=u.paragraphStyle,c.bullet=u.bullet,u.paragraphStyle=d,u.bullet=f}h!==-1&&s.splice(h,1),s.push(...o),s.sort(kt("startIndex"))}}function fc(e,n,t,r){const{sectionBreaks:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h}=l;h>=r&&(l.startIndex+=t)}const o=n.sectionBreaks;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function Si(e,n,t,r){const{customBlocks:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h}=l;h>=r&&(l.startIndex+=t)}const o=n.customBlocks;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function Ni(e,n,t,r){const{tables:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h,endIndex:c}=l;h>r?(l.startIndex+=t,l.endIndex+=t):c>=r-1&&(l.endIndex+=t)}const o=n.tables;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r,l.endIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function wi(e,n,t,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e,o={};for(let l=0,h=s.length;l<h;l++){const c=s[l];o[c.rangeId]=c;const{startIndex:u,endIndex:d}=c;u>=r?(c.startIndex+=t,c.endIndex+=t):d>r-1&&(c.endIndex+=t)}if(s.find(l=>l.startIndex>r&&l.endIndex<r))return;const a=[];if(n.customRanges){for(let l=0,h=n.customRanges.length;l<h;l++){const c=n.customRanges[l],u=o[c.rangeId];if(c.startIndex+=r,c.endIndex+=r,u){if(u.startIndex<=c.startIndex&&u.endIndex>=c.endIndex||e.dataStream[u.startIndex]===gt.CUSTOM_RANGE_START&&e.dataStream[u.endIndex]===gt.CUSTOM_RANGE_END)continue;if(e.dataStream[u.startIndex]===gt.CUSTOM_RANGE_START){u.endIndex=c.endIndex;continue}if(e.dataStream[u.endIndex]===gt.CUSTOM_RANGE_END){u.startIndex=c.startIndex;continue}}a.push(c)}s.push(...a),s.sort(kt("startIndex"))}}function _c(e){e.sort((r,s)=>r.startIndex-s.startIndex);const n=[];let t=e[0];for(let r=1;r<e.length;r++)t.endIndex+1>=e[r].startIndex?t.endIndex=Math.max(t.endIndex,e[r].endIndex):(n.push(t),t=e[r]);return n.push(t),n}function gc(e){const n={};for(let t=0,r=e.length;t<r;t++){const s=e[t],o=n[s.id];n[s.id]=[...o!=null?o:[],s]}return Object.keys(n).forEach(t=>{const r=n[t],s=_c(r);n[t]=s}),Object.values(n).flat()}function Ai(e,n,t,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;if(t>0)for(let o=0,i=s.length;o<i;o++){const a=s[o],{startIndex:l,endIndex:h}=a;l>=r?(a.startIndex+=t,a.endIndex+=t):h>r-1&&(a.endIndex+=t)}if(n.customDecorations){const o=[];for(let i=0,a=n.customDecorations.length;i<a;i++){const l=n.customDecorations[i];o.push(l),l.startIndex+=r,l.endIndex+=r}s.push(...o),e.customDecorations=gc(s),e.customDecorations.sort(kt("startIndex"))}}function bi(e,n,t){var a;const{textRuns:r}=e,s=t,o=t+n,i=[];if(s===o&&(r!=null&&r.find(l=>l.st===t&&l.ed===t))){const l=r.find(h=>h.st===t&&h.ed===t);return i.push({...l,st:l.st-t,ed:l.ed-t}),e.textRuns=(a=e.textRuns)==null?void 0:a.filter(h=>h!==l),i}if(r){const l=[];for(let h=0,c=r.length;h<c;h++){const u=r[h],{st:d,ed:f}=u;if(s<=d&&o>=f){i.push({...u,st:d-s,ed:f-s});continue}else d<=s&&f>=o?(i.push({...u,st:s-s,ed:o-s}),u.ed-=n):s>=d&&s<f?(i.push({...u,st:s-s,ed:f-s}),u.ed=s):o>d&&o<=f?(i.push({...u,st:d-s,ed:o-s}),u.st=o-n,u.ed-=n):d>=o&&(u.st-=n,u.ed-=n);l.push(u)}e.textRuns=l}return i.length===0&&i.push({st:0,ed:n,ts:{}}),i}function Ti(e,n,t){const{paragraphs:r}=e,s=t,o=t+n,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<o){i.push({...c,startIndex:u-t});continue}else u>=o&&(c.startIndex-=n);a.push(c)}e.paragraphs=a}return i}function yi(e,n,t){const{sectionBreaks:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<=o){i.push({...c,startIndex:u-t});continue}else u>o&&(c.startIndex-=n);a.push(c)}e.sectionBreaks=a}return i}function Di(e,n,t){const{customBlocks:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<=o){i.push({...c,startIndex:u-t});continue}else u>o&&(c.startIndex-=n);a.push(c)}e.customBlocks=a}return i}function Mi(e,n,t){const{tables:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u,endIndex:d}=c;if(s<=u&&o>=d){i.push({...c,startIndex:u-t,endIndex:d-t});continue}else if(u<=s&&d>=o){const f=Wn(u,d,s,o);c.startIndex=f[0],c.endIndex=f[1]}else o<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}e.tables=a}return i}function Ui(e,n,t){const{customRanges:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u,endIndex:d}=c;if(s<=u&&o>=u){i.push({...c,startIndex:u-t,endIndex:d-t});continue}else if(u<=s&&d>=o){const f=Wn(u,d,s,o);c.startIndex=f[0],c.endIndex=f[1]}else o<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}e.customRanges=a}return i}function Li(e,n,t,r=!0){const{customDecorations:s}=e,o=t,i=t+n-1,a=[];if(s){const l=[];for(let h=0,c=s.length;h<c;h++){const u=s[h],{startIndex:d,endIndex:f}=u;if(d>=o&&f<=i){a.push(u);continue}else if(Math.max(o,d)<=Math.min(i,f)){const p=Wn(d,f,o,i);u.startIndex=p[0],u.endIndex=p[1]}else i<d&&r&&(u.startIndex-=n,u.endIndex-=n);l.push(u)}e.customDecorations=l}return a}function pc(e,n,t,r,s){const o=mc(e,n,t,r,s),i=Ec(e,n,t,r,s),a=Rc(e,n,t,r,s),l=Cc(e,n,t,r,s),h=Ic(e,n,t,r,s),c=vc(e,n,t,r,s),u=Oc(e,n,t,r,s);return{dataStream:"",textRuns:o,paragraphs:i,sectionBreaks:a,customBlocks:l,tables:h,customRanges:c,customDecorations:u}}function mc(e,n,t,r,s){const{textRuns:o}=e,{textRuns:i}=n;if(o==null||i==null)return;const a=bi(e,t,r);if(s!==ke.REPLACE){const l=xi(i,a,s);n.textRuns=l}return Oi(e,n,t,r),a}function xi(e,n,t){if(n.length===0)return e;e=x.deepClone(e),n=x.deepClone(n);const r=[],s=e.length,o=n.length;let i=0,a=0,l=null;function h(){return l?(r.push(l),l=null,!0):!1}for(;i<s&&a<o;){const{st:f,ed:p,ts:m}=e[i],{st:S,ed:y,ts:ee,sId:ge}=n[a];let ce;if(t===ke.COVER?ce={...ee,...m}:ce={...m,...ee},p<S)h()||r.push(e[i]),i++;else if(y<f)h()||r.push(n[a]),a++;else{const E={st:Math.min(f,S),ed:Math.max(f,S),ts:f<S?{...m}:{...ee},sId:f<S?void 0:ge};E.ed>E.st&&r.push(E),r.push({st:Math.max(f,S),ed:Math.min(p,y),ts:ce,sId:ge}),p<y?(i++,n[a].st=p,n[a].st===n[a].ed&&a++):(a++,e[i].st=y,e[i].st===e[i].ed&&i++);const v={st:Math.min(p,y),ed:Math.max(p,y),ts:p<y?{...ee}:{...m},sId:p<y?ge:void 0};l=v.ed>v.st?v:null}}h();const c=r[r.length-1],u=e[s-1],d=n[o-1];return c.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?r.push(u):r.push(d)),Wr(r)}function Ec(e,n,t,r,s){const{paragraphs:o}=e,{paragraphs:i}=n;if(o==null||i==null)return;const a=Ti(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c,paragraphStyle:u,bullet:d}=h;let f=[];for(const p of a){const{startIndex:m,paragraphStyle:S,bullet:y}=p;let ee,ge;if(s===ke.COVER?(ee={...S,...u},ge={listId:"",listType:Pn.BULLET_LIST,nestingLevel:0,textStyle:{},...y,...d}):(ee={...u,...S},ge={listId:"",listType:Pn.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...y}),c===m){f.push({startIndex:c,paragraphStyle:ee,bullet:ge});break}}l.push(...f),f=[]}n.paragraphs=l}return Br(e,n,t,r),a}function Rc(e,n,t,r,s){const{sectionBreaks:o}=e,{sectionBreaks:i}=n;if(o==null||i==null)return;const a=yi(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===ke.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.sectionBreaks=l}return Br(e,n,t,r),a}function Cc(e,n,t,r,s){const{customBlocks:o}=e,{customBlocks:i}=n;if(o==null||i==null)return;const a=Di(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===ke.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.customBlocks=l}return Si(e,n,t,r),a}function Ic(e,n,t,r,s){const{tables:o}=e,{tables:i}=n;if(o==null||i==null)return;const a=Mi(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of a){const{startIndex:p,endIndex:m}=f;if(p>=c&&m<=u){s===ke.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}n.tables=l}return Ni(e,n,t,r),a}function vc(e,n,t,r,s){e.customRanges||(e.customRanges=[]);const{customRanges:o}=e,{customRanges:i}=n;if(o==null||i==null)return;let a=[];return s===ke.REPLACE&&(a=Ui(e,t,r)),wi(e,n,0,r),a}function Oc(e,n,t,r,s){e.customDecorations||(e.customDecorations=[]);let o=[];return s===ke.REPLACE&&(o=Li(e,t,r,!1)),Ai(e,n,0,r),o}var Gr=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(Gr||{});function an(e,n,t,r=!1,s=1){const{dataStream:o,textRuns:i=[],paragraphs:a=[],customBlocks:l=[]}=e,h={dataStream:o.slice(n,t)},c=[];for(const p of i){const m=x.deepClone(p),{st:S,ed:y}=m;x.hasIntersectionBetweenTwoRanges(S,y,n,t)&&(n>=S&&n<=y?c.push({...m,st:n,ed:Math.min(t,y)}):t>=S&&t<=y?c.push({...m,st:Math.max(n,S),ed:t}):c.push(m))}c.length?h.textRuns=c.map(p=>{const{st:m,ed:S}=p;return{...p,st:m-n,ed:S-n}}):r&&(h.textRuns=[{st:0,ed:t-n,ts:{}}]);const u=[];for(const p of a){const{startIndex:m}=p;m>=n&&m<=t&&u.push(x.deepClone(p))}u.length&&(h.paragraphs=u.map(p=>({...p,startIndex:p.startIndex-n}))),s===1&&(h.customDecorations=ki(e,n,t));const{customRanges:d}=Pi(e,n,t);h.customRanges=d;const f=[];for(const p of l){const{startIndex:m}=p;m>=n&&m<=t&&f.push(x.deepClone(p))}return f.length&&(h.customBlocks=f.map(p=>({...p,startIndex:p.startIndex-n}))),h}function Sc(e){const{dataStream:n,textRuns:t,paragraphs:r,customRanges:s,customDecorations:o}=e;let i=0,a=0;s==null||s.forEach(h=>{h.startIndex<0&&(i=Math.max(i,-h.startIndex)),h.endIndex>n.length-1&&(a=Math.max(a,h.endIndex-n.length+1))});const l=`${gt.CUSTOM_RANGE_START.repeat(i)}${n}${gt.CUSTOM_RANGE_END.repeat(a)}`;return t&&(t[0]&&(t[0].st=t[0].st-i),t[t.length-1]&&(t[t.length-1].ed=t[t.length-1].ed+a)),t==null||t.forEach(h=>{h.st+=i,h.ed+=i}),r==null||r.forEach(h=>{h.startIndex+=i}),s==null||s.forEach(h=>{h.startIndex+=i,h.endIndex+=i}),o==null||o.forEach(h=>{h.startIndex+=i,h.endIndex+=a}),{...e,dataStream:l,textRuns:t,paragraphs:r,customRanges:s,customDecorations:o}}function Pi(e,n,t){const{customRanges:r=[]}=e;let s=0,o=0;const i=r.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,t-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(i.length){i.forEach(a=>{a.startIndex<n&&(s+=1),a.endIndex>t-1&&(o+=1)});for(let a=0;a<s;a++){const l=i[a];l.startIndex=n-s+a}if(o){const a=[...i].sort((l,h)=>h.endIndex-l.endIndex);for(let l=0;l<o;l++){const h=a[l];h.endIndex=t+o-l-1}}}return{customRanges:i.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:s,rightOffset:o}}function ki(e,n,t){const{customDecorations:r=[]}=e,s=[];return r.forEach(o=>{if(Math.max(o.startIndex,n)<=Math.min(o.endIndex,t-1)){const i=x.deepClone(o);s.push({...i,startIndex:Math.max(i.startIndex-n,0),endIndex:Math.min(i.endIndex,t)-n})}}),s}function Or(e,n,t=ke.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s=[],paragraphs:o=[]}=e,{textRuns:i=[],paragraphs:a=[]}=n,l=xi(i,s,t);l.length&&(r.textRuns=l);const h=[];let c=0,u=0;for(;c<o.length&&u<a.length;){const d=o[c],f=a[u],{startIndex:p}=d,{startIndex:m}=f;p===m?(h.push(x.deepMerge(d,f)),c++,u++):p<m?(h.push(x.deepClone(d)),c++):(h.push(x.deepClone(f)),u++)}return c<o.length&&h.push(...o.slice(c)),u<a.length&&h.push(...a.slice(u)),h.length&&(r.paragraphs=h),r}function Nc(e){const{body:n}=e;if(n==null)return!0;const{textRuns:t=[],paragraphs:r=[]}=n;return t.length===0&&r.length===0}function wc(e=x.generateRandomId(6),n=Pt.EN_US,t=""){return{id:e,locale:n,title:t,body:{dataStream:`\r
8
- `,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 We=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ac(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var je={},Fi={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});function bc(e,n){if(Array.isArray(n))return!1;for(let t in e)if(!Kr(e[t],n[t]))return!1;for(let t in n)if(e[t]===void 0)return!1;return!0}function Tc(e,n){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Kr(e[t],n[t]))return!1;return!0}function Kr(e,n){return e===n?!0:e===null||n===null||typeof e!="object"||typeof n!="object"?!1:Array.isArray(e)?Tc(e,n):bc(e,n)}Vr.default=Kr;var Yr={};Object.defineProperty(Yr,"__esModule",{value:!0});function Sr(e){if(e===null)return null;if(Array.isArray(e))return e.map(Sr);if(typeof e=="object"){const n={};for(let t in e)n[t]=Sr(e[t]);return n}else return e}Yr.default=Sr;var zr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function n(c,u){if(!c)throw new Error(u)}const t=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),r=(c,u)=>typeof c==typeof u?c>u:typeof c=="string"&&typeof u=="number";function s(c,u){for(let d in c){const f=d;u.write(f,c[f])}}e.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__proto__";class o{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--,t(this.container[this.idx])&&this.idx--)}getPath(){const u=[];let d=this.container,f=this.parents.length-1,p=this.idx;for(;p>=0;)u.unshift(d[p]),p===0?(p=this.indexes[f*2],d=this.parents[f--]):p-=t(d[p-1])?2:1;return u}}class i extends o{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&&t(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||t(this.container[u])&&u+1>=this.container.length)return!1;t(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,p){this.container=u,this.idx=d,this.parents=f.slice(),this.indexes=p.slice()}clone(){const u=new i;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 p of this)u&&u.descend(p),this.traverse(u,d),u&&u.ascend()}eachPick(u,d){this.traverse(u,(f,p)=>{f.p!=null&&d(f.p,p)})}eachDrop(u,d){this.traverse(u,(f,p)=>{f.d!=null&&d(f.d,p)})}}e.ReadCursor=i;class a extends o{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&&t(this.container[f])&&f++,n(f===this.container.length||!t(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 p=this.container.splice(f,this.container.length-f);this.container.push(p),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(r(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&r(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const p=[d];this.container.splice(f,0,p),this.container=p}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const u=this.idx+1;if(u<this.container.length&&t(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(!e.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=s){if(u===null)return;if(n(Array.isArray(u)),u===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,p=this.parents.length;let m=0;for(let S=0;S<u.length;S++){const y=u[S];typeof y=="string"||typeof y=="number"?(m++,this.descend(y)):Array.isArray(y)?this.mergeTree(y,d):typeof y=="object"&&d(y,this)}for(;m--;)this.ascend();this.lcIdx=this.parents.length===p?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}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=c=>new i(c);function l(c,u,d){let f,p;p=f=c?c.descendFirst():!1;function m(S){let y;for(;p;){const ee=y=c.getKey();if(S!=null){let ge=!1;if(u&&typeof ee=="number"&&(y=u(ee,c.getComponent()),y<0&&(y=~y,ge=!0)),r(y,S))return null;if(y===S&&!ge)return c}d&&typeof y=="number"&&d(y,c.getComponent()),p=c.nextSibling()}return null}return m.end=()=>{f&&c.ascend()},m}e.advancer=l;function h(c,u,d){let f,p,m,S;for(f=p=c&&c.descendFirst(),m=S=u&&u.descendFirst();f||m;){let y=f?c.getKey():null,ee=m?u.getKey():null;y!==null&&ee!==null&&(r(ee,y)?ee=null:y!==ee&&(y=null)),d(y==null?ee:y,y!=null?c:null,ee!=null?u:null),y!=null&&f&&(f=c.nextSibling()),ee!=null&&m&&(m=u.nextSibling())}p&&c.ascend(),S&&u.ascend()}e.eachChildOf=h})(zr);var Xr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.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"}(e.ConflictType||(e.ConflictType={}))})(Xr);var rr={},yt={},Ss;function Qr(){return Ss||(Ss=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.uniToStrPos=yt.strPosToUni=void 0,yt.strPosToUni=(e,n=e.length)=>{let t=0,r=0;for(;r<n;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(t++,r++)}if(r!==n)throw Error("Invalid offset - splits unicode bytes");return r-t},yt.uniToStrPos=(e,n)=>{let t=0;for(;n>0;n--){const r=e.charCodeAt(t);t+=r>=55296&&r<=57343?2:1}return t}),yt}var sr={},Ns;function Nr(){return Ns||(Ns=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const n=Qr(),t=E=>{if(!Array.isArray(E))throw Error("Op must be an array of components");let v=null;for(let b=0;b<E.length;b++){const z=E[b];switch(typeof z){case"object":if(typeof z.d!="number"&&typeof z.d!="string")throw Error("Delete must be number or string");if(e.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 v=="number")throw Error("Adjacent skip components should be combined");break}v=z}if(typeof v=="number")throw Error("Op has a trailing skip")};function r(E,v){let b=0,z=0;for(let ne=0;ne<E.length;ne++){const X=E[ne];switch(v(X,b,z),typeof X){case"object":b+=e.dlen(X.d);break;case"string":z+=n.strPosToUni(X);break;case"number":b+=X,z+=X;break}}}e.eachOp=r;function s(E,v){const b=[],z=a(b);return r(E,(ne,X,Ke)=>{z(v(ne,X,Ke))}),u(b)}const o=E=>E,i=E=>s(E,o);e.dlen=E=>typeof E=="number"?E:n.strPosToUni(E);const a=E=>v=>{if(!(!v||v.d===0||v.d===""))if(E.length===0)E.push(v);else if(typeof v==typeof E[E.length-1])if(typeof v=="object"){const b=E[E.length-1];b.d=typeof b.d=="string"&&typeof v.d=="string"?b.d+v.d:e.dlen(b.d)+e.dlen(v.d)}else E[E.length-1]+=v;else E.push(v)},l=E=>typeof E=="number"?E:typeof E=="string"?n.strPosToUni(E):typeof E.d=="number"?E.d:n.strPosToUni(E.d);e.uniSlice=(E,v,b)=>{const z=n.uniToStrPos(E,v),ne=b==null?1/0:n.uniToStrPos(E,b);return E.slice(z,ne)};const h=(E,v,b)=>typeof E=="number"?b==null?E-v:Math.min(E,b)-v:e.uniSlice(E,v,b),c=E=>{let v=0,b=0;return{take:(X,Ke)=>{if(v===E.length)return X===-1?null:X;const ve=E[v];let fe;if(typeof ve=="number")return X===-1||ve-b<=X?(fe=ve-b,++v,b=0,fe):(b+=X,X);if(typeof ve=="string"){if(X===-1||Ke==="i"||n.strPosToUni(ve.slice(b))<=X)return fe=ve.slice(b),++v,b=0,fe;{const Ce=b+n.uniToStrPos(ve.slice(b),X);return fe=ve.slice(b,Ce),b=Ce,fe}}else{if(X===-1||Ke==="d"||e.dlen(ve.d)-b<=X)return fe={d:h(ve.d,b)},++v,b=0,fe;{let Ce=h(ve.d,b,b+X);return b+=X,{d:Ce}}}},peek:()=>E[v]}},u=E=>(E.length>0&&typeof E[E.length-1]=="number"&&E.pop(),E);function d(E,v,b){if(b!=="left"&&b!=="right")throw Error("side ("+b+") must be 'left' or 'right'");t(E),t(v);const z=[],ne=a(z),{take:X,peek:Ke}=c(E);for(let fe=0;fe<v.length;fe++){const Ce=v[fe];let Te,Ye;switch(typeof Ce){case"number":for(Te=Ce;Te>0;)Ye=X(Te,"i"),ne(Ye),typeof Ye!="string"&&(Te-=l(Ye));break;case"string":b==="left"&&typeof Ke()=="string"&&ne(X(-1)),ne(n.strPosToUni(Ce));break;case"object":for(Te=e.dlen(Ce.d);Te>0;)switch(Ye=X(Te,"i"),typeof Ye){case"number":Te-=Ye;break;case"string":ne(Ye);break;case"object":Te-=e.dlen(Ye.d)}break}}let ve;for(;ve=X(-1);)ne(ve);return u(z)}function f(E,v){t(E),t(v);const b=[],z=a(b),{take:ne}=c(E);for(let Ke=0;Ke<v.length;Ke++){const ve=v[Ke];let fe,Ce;switch(typeof ve){case"number":for(fe=ve;fe>0;)Ce=ne(fe,"d"),z(Ce),typeof Ce!="object"&&(fe-=l(Ce));break;case"string":z(ve);break;case"object":fe=e.dlen(ve.d);let Te=0;for(;Te<fe;)switch(Ce=ne(fe-Te,"d"),typeof Ce){case"number":z({d:h(ve.d,Te,Te+Ce)}),Te+=Ce;break;case"string":Te+=n.strPosToUni(Ce);break;case"object":z(Ce)}break}}let X;for(;X=ne(-1);)z(X);return u(b)}const p=(E,v)=>{let b=0;for(let z=0;z<v.length&&E>b;z++){const ne=v[z];switch(typeof ne){case"number":{b+=ne;break}case"string":const X=n.strPosToUni(ne);b+=X,E+=X;break;case"object":E-=Math.min(e.dlen(ne.d),E-b);break}}return E},m=(E,v)=>typeof E=="number"?p(E,v):E.map(b=>p(b,v));function S(E,v,b){return s(E,(z,ne)=>typeof z=="object"&&typeof z.d=="number"?{d:b.slice(v,ne,ne+z.d)}:z)}function y(E){return s(E,v=>{switch(typeof v){case"object":if(typeof v.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return v.d;case"string":return{d:v};case"number":return v}})}function ee(E){return s(E,v=>typeof v=="object"&&typeof v.d=="string"?{d:n.strPosToUni(v.d)}:v)}function ge(E){let v=!0;return r(E,b=>{typeof b=="object"&&typeof b.d=="number"&&(v=!1)}),v}function ce(E){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:i,checkOp:t,create(v=""){if(typeof v!="string")throw Error("Initial data must be a string");return E.create(v)},apply(v,b){t(b);const z=E.builder(v);for(let ne=0;ne<b.length;ne++){const X=b[ne];switch(typeof X){case"number":z.skip(X);break;case"string":z.append(X);break;case"object":z.del(e.dlen(X.d));break}}return z.build()},transform:d,compose:f,transformPosition:p,transformSelection:m,isInvertible:ge,makeInvertible(v,b){return S(v,b,E)},stripInvertible:ee,invert:y,invertWithDoc(v,b){return y(S(v,b,E))},isNoop:v=>v.length===0}}e.default=ce}(sr)),sr}var Rn={},ws;function yc(){if(ws)return Rn;ws=1,Object.defineProperty(Rn,"__esModule",{value:!0});const e=Nr(),n=Qr();function t(r,s){return{get:r,getLength(){return r().length},insert(o,i,a){const l=n.strPosToUni(r(),o);return s([l,i],a)},remove(o,i,a){const l=n.strPosToUni(r(),o);return s([l,{d:i}],a)},_onOp(o){e.eachOp(o,(i,a,l)=>{switch(typeof i){case"string":this.onInsert&&this.onInsert(l,i);break;case"object":const h=e.dlen(i.d);this.onRemove&&this.onRemove(l,h)}})},onInsert:null,onRemove:null}}return Rn.default=t,t.provides={text:!0},Rn}var As;function Dc(){return As||(As=1,function(e){var n=We&&We.__createBinding||(Object.create?function(d,f,p,m){m===void 0&&(m=p),Object.defineProperty(d,m,{enumerable:!0,get:function(){return f[p]}})}:function(d,f,p,m){m===void 0&&(m=p),d[m]=f[p]}),t=We&&We.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),r=We&&We.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var p in d)Object.hasOwnProperty.call(d,p)&&n(f,d,p);return t(f,d),f},s=We&&We.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const o=Qr(),i=r(Nr()),a=s(yc()),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(p){let m=o.uniToStrPos(d,p);if(m>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,m)),d=d.slice(m)},append(p){f.push(p)},del(p){d=d.slice(o.uniToStrPos(d,p))},build(){return f.join("")+d}}},slice:i.uniSlice},h=i.default(l),c=Object.assign(Object.assign({},h),{api:a.default});e.type=c,e.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],e.remove=(d,f)=>i.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var u=Nr();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})}(rr)),rr}(function(e){var n=We&&We.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const t=n(Vr),r=n(Yr),s=zr,o=Xr;function i(g,R){if(!g)throw new Error(R)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:g=>g,isNoop:g=>g==null,setDebug(g){},registerSubtype:y,checkValidOp:ne,normalize:X,apply:Ke,transformPosition:ve,compose:fe,tryTransform:Zn,transform:Ma,makeInvertible:Ye,invert:Ce,invertWithDoc:Da,RM_UNEXPECTED_CONTENT:o.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:o.ConflictType.DROP_COLLISION,BLACKHOLE:o.ConflictType.BLACKHOLE,transformNoConflict:(g,R,N)=>os(()=>!0,g,R,N),typeAllowingConflictsPred:g=>Object.assign(Object.assign({},e.type),{transform:(R,N,M)=>os(g,R,N,M)})};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 i(g!=null),typeof R=="number"?(i(Array.isArray(g),"Invalid key - child is not an array"),(g=g.slice()).splice(R,1)):(i(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"?(i(g!=null,"Container is missing for key"),i(Array.isArray(g),"Cannot use numerical key for object container"),i(g.length>=R,"Cannot insert into out of bounds index"),g.splice(R,0,N)):(i(l(g),"Cannot insert into missing item"),i(g[R]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),g[R]=N),N}e.removeOp=(g,R=!0)=>s.writeCursor().writeAtPath(g,"r",R).get(),e.moveOp=(g,R)=>s.writeCursor().writeMove(g,R).get(),e.insertOp=(g,R)=>s.writeCursor().writeAtPath(g,"i",R).get(),e.replaceOp=(g,R,N)=>s.writeCursor().at(g,M=>{M.write("r",R),M.write("i",N)}).get(),e.editOp=(g,R,N,M=!1)=>s.writeCursor().at(g,w=>v(w,R,N,M)).get();const p=(g,R)=>g!=null&&(typeof R=="number"?Array.isArray(g):typeof g=="object"),m=(g,R)=>p(g,R)?g[R]:void 0,S={};function y(g){let R=g.type?g.type:g;R.name&&(S[R.name]=R),R.uri&&(S[R.uri]=R)}const ee=g=>{const R=S[g];if(R)return R;throw Error("Missing type: "+g)};y(Dc());const ge=(g,R)=>g+R;y({name:"number",apply:ge,compose:ge,invert:g=>-g,transform:g=>g});const ce=g=>g==null?null:g.et?ee(g.et):g.es?S["text-unicode"]:g.ena!=null?S.number:null,E=g=>g.es?g.es:g.ena!=null?g.ena:g.e,v=(g,R,N,M=!1)=>{const[w,D]=typeof R=="string"?[ee(R),R]:[R,R.name];!M&&w.isNoop&&w.isNoop(N)||(D==="number"?g.write("ena",N):D==="text-unicode"?g.write("es",N):(g.write("et",D),g.write("e",N)))};function b(g){i(typeof g=="number"),i(g>=0),i(g===(0|g))}function z(g){typeof g=="number"?b(g):i(typeof g=="string")}function ne(g){if(g===null)return;const R=new Set,N=new Set,M=D=>{let B=!0,j=!1;for(let C in D){const O=D[C];if(B=!1,i(C==="p"||C==="r"||C==="d"||C==="i"||C==="e"||C==="es"||C==="ena"||C==="et","Invalid component item '"+C+"'"),C==="p")b(O),i(!R.has(O)),R.add(O),i(D.r===void 0);else if(C==="d")b(O),i(!N.has(O)),N.add(O),i(D.i===void 0);else if(C==="e"||C==="es"||C==="ena"){i(!j),j=!0;const A=ce(D);i(A,"Missing type in edit"),A.checkValidOp&&A.checkValidOp(E(D))}}i(!B)},w=(D,B,j)=>{if(!Array.isArray(D))throw Error("Op must be null or a list");if(D.length===0)throw Error("Empty descent");B||z(D[0]);let C=1,O=0,A=0;for(let T=0;T<D.length;T++){const W=D[T];if(i(W!=null),Array.isArray(W)){const G=w(W,!1);if(O){const I=typeof A,F=typeof G;I===F?i(A<G,"descent keys are not in order"):i(I==="number"&&F==="string")}A=G,O++,C=3}else typeof W=="object"?(i(C===1,`Prev not scalar - instead ${C}`),M(W),C=2):(i(C!==3),z(W),i(s.isValidPathItem(W),"Invalid path key"),C=1)}return i(O!==1,"Operation makes multiple descents. Remove some []"),i(C===2||C===3),D[0]};w(g,!0),i(R.size===N.size,"Mismatched picks and drops in op");for(let D=0;D<R.size;D++)i(R.has(D)),i(N.has(D))}function X(g){let R=0,N=[];const M=s.writeCursor();return M.mergeTree(g,(w,D)=>{const B=ce(w);if(B){const C=E(w);v(D,B,B.normalize?B.normalize(C):C)}for(const C of["r","p","i","d"])if(w[C]!==void 0){const O=C==="p"||C==="d"?(j=w[C],N[j]==null&&(N[j]=R++),N[j]):w[C];D.write(C,O)}var j}),M.get()}function Ke(g,R){if(ne(R),R===null)return g;const N=[];return function M(w,D){let B=w,j=0,C={root:w},O=0,A=C,T="root";function W(){for(;O<j;O++){let G=D[O];typeof G!="object"&&(i(p(A,T)),A=A[T]=h(A[T]),T=G)}}for(;j<D.length;j++){const G=D[j];if(Array.isArray(G)){const I=M(B,G);I!==B&&I!==void 0&&(W(),B=A[T]=I)}else if(typeof G=="object"){G.d!=null?(W(),B=f(A,T,N[G.d])):G.i!==void 0&&(W(),B=f(A,T,G.i));const I=ce(G);if(I)W(),B=A[T]=I.apply(B,E(G));else if(G.e!==void 0)throw Error("Subtype "+G.et+" undefined")}else B=m(B,G)}return C.root}(g=function M(w,D){const B=[];let j=0;for(;j<D.length;j++){const T=D[j];if(Array.isArray(T))break;typeof T!="object"&&(B.push(w),w=m(w,T))}for(let T=D.length-1;T>=j;T--)w=M(w,D[T]);for(--j;j>=0;j--){const T=D[j];if(typeof T!="object"){const W=B.pop();w=w===m(W,T)?W:w===void 0?d(W,T):(O=T,A=w,(C=h(C=W))[O]=A,C)}else c(T)&&(i(w!==void 0,"Cannot pick up or remove undefined"),T.p!=null&&(N[T.p]=w),w=void 0)}var C,O,A;return w}(g,R),R)}function ve(g,R){g=g.slice(),ne(R);const N=s.readCursor(R);let M,w,D=!1;const B=[];for(let C=0;;C++){const O=g[C],A=N.getComponent();if(A&&(A.r!==void 0?D=!0:A.p!=null&&(D=!1,M=A.p,w=C)),C>=g.length)break;let T=0;const W=s.advancer(N,void 0,(I,F)=>{c(F)&&T++});B.unshift(W);const G=W(O);if(typeof O=="number"&&(g[C]-=T),!G)break}if(B.forEach(C=>C.end()),D)return null;const j=()=>{let C=0;if(M!=null){const O=N.getPath();C=O.length,g=O.concat(g.slice(w))}for(;C<g.length;C++){const O=g[C],A=a(N),T=ce(A);if(T){const I=E(A);T.transformPosition&&(g[C]=T.transformPosition(g[C],I));break}let W=0;const G=s.advancer(N,(I,F)=>u(F)?~(I-W):I-W,(I,F)=>{u(F)&&W++})(O);if(typeof O=="number"&&(g[C]+=W),!G)break}};return M!=null?N.eachDrop(null,C=>{C===M&&j()}):j(),g}function fe(g,R){if(ne(g),ne(R),g==null)return R;if(R==null)return g;let N=0;const M=s.readCursor(g),w=s.readCursor(R),D=s.writeCursor(),B=[],j=[],C=[],O=[],A=[],T=[],W=new Set;M.traverse(null,I=>{I.p!=null&&(C[I.p]=M.clone())}),w.traverse(null,I=>{I.d!=null&&(O[I.d]=w.clone())});const G=s.writeCursor();return function I(F,_e,le,Q,me,ct,xe,ye){i(_e||le);const Ee=a(_e),ze=a(le),Je=!!ze&&ze.r!==void 0,Nt=!!Ee&&Ee.i!==void 0,Xe=Ee?Ee.d:null,Be=ze?ze.p:null,ht=(ct||Je)&&Be==null;if(Be!=null)Q=O[Be],xe=j[Be]=new s.WriteCursor;else if(ze&&ze.r!==void 0)Q=null;else{const L=a(Q);L&&L.d!=null&&(Q=null)}const ie=a(Q);if(Xe!=null)if(F=C[Xe],ye=B[Xe]=new s.WriteCursor,ht)ct&&!Je&&ye.write("r",!0);else{const L=A[Xe]=N++;xe.write("d",L)}else if(Ee&&Ee.i!==void 0)F=null;else{const L=a(F);L&&L.p!=null&&(F=null)}let P;Nt?(i(me===void 0),P=Ee.i):P=me;const V=(Be==null?!Nt||ct||Je:P===void 0)?null:xe.getComponent();if(Be!=null){if(!(me!==void 0||Nt)){const L=Xe!=null?A[Xe]:N++;T[Be]=L,ye.write("p",L)}}else Je&&(Nt||me!==void 0||(ze.r,ye.write("r",ze.r)));const k=ht?null:ce(Ee),U=ce(ie);if((k||U)&&(k&&k.name,U&&U.name),k&&U){i(k===U);const L=E(Ee),Y=E(ie),Ae=k.compose(L,Y);v(xe,k,Ae),W.add(ie)}else k?v(xe,k,E(Ee)):U&&(v(xe,U,E(ie)),W.add(ie));const H=typeof P=="object"&&P!=null;let re=!1,se=0,ae=0,we=0,Oe=0,Re=0;const Ue=s.advancer(Q,(L,Y)=>u(Y)?Oe-L-1:L-Oe,(L,Y)=>{u(Y)&&Oe++}),te=s.advancer(F,(L,Y)=>c(Y)?se-L-1:L-se,(L,Y)=>{c(Y)&&se++});if(s.eachChildOf(_e,le,(L,Y,Ae)=>{let Fe,dt,wt=L,et=L,zt=L;if(typeof L=="number"){let De=L+we;dt=Ue(De),et=De+Oe;let Ie=L+ae;Fe=te(Ie),u(a(dt))&&(Fe=null),wt=Ie+se,zt=L+Re,i(wt>=0,"p1PickKey is negative"),i(et>=0,"p2DropKey is negative");const tt=u(a(Y)),ft=c(a(Ae));(tt||ft&&!ht)&&Re--,tt&&ae--,ft&&we--}else Fe=te(L),dt=Ue(L);ye.descend(wt),xe.descend(et);const Ht=H&&!u(a(Y))?P[zt]:void 0,at=I(Fe,Y,Ae,dt,Ht,ht,xe,ye);var lt,$,pe;H&&!ht?Ht!==at&&(re||(P=Array.isArray(P)?P.slice():Object.assign({},P),re=!0),lt=P,pe=at,typeof($=zt)=="number"?(i(Array.isArray(lt)),i($<lt.length)):(i(!Array.isArray(lt)),i(lt[$]!==void 0)),pe===void 0?typeof $=="number"?lt.splice($,1):delete lt[$]:lt[$]=pe):i(at===void 0),xe.ascend(),ye.ascend()}),te.end(),Ue.end(),V!=null)V.i=P;else if(!ct&&!Je&&Be==null)return P}(M,M.clone(),w,w.clone(),void 0,!1,D,G),D.reset(),D.mergeTree(G.get()),D.reset(),D.get(),B.map(I=>I.get()),j.map(I=>I.get()),M.traverse(D,(I,F)=>{const _e=I.p;if(_e!=null){const le=A[_e];le!=null&&F.write("p",le);const Q=B[_e];Q&&Q.get(),Q&&F.mergeTree(Q.get())}else I.r!==void 0&&F.write("r",I.r)}),D.reset(),D.get(),w.traverse(D,(I,F)=>{const _e=I.d;if(_e!=null){const Q=T[_e];Q!=null&&F.write("d",Q);const me=j[_e];me&&F.mergeTree(me.get())}else I.i!==void 0&&F.write("i",I.i);const le=ce(I);le&&!W.has(I)&&v(F,le,E(I))}),D.get()}function Ce(g){if(g==null)return null;const R=new s.ReadCursor(g),N=new s.WriteCursor;let M;const w=[],D=[];return function B(j,C,O){const A=j.getComponent();let T,W=!1;if(A){A.p!=null&&(C.write("d",A.p),w[A.p]=j.clone()),A.r!==void 0&&C.write("i",A.r),A.d!=null&&(C.write("p",A.d),O=void 0),A.i!==void 0&&(O=T=A.i);const I=ce(A);I&&(O===void 0?(M||(M=new Set),M.add(A)):(E(A),O=I.apply(O,E(A)),W=!0))}let G=0;for(const I of j){C.descend(I);const F=typeof I=="number"?I-G:I,_e=m(O,F);u(j.getComponent())&&G++;const le=B(j,C,_e);if(O!==void 0&&le!==void 0){if(W||(W=!0,O=h(O)),!p(O,F))throw Error("Cannot modify child - invalid operation");O[F]=le}C.ascend()}if(T===void 0)return W?O:void 0;C.write("r",O)}(R,N,void 0),M&&(N.reset(),function B(j,C,O){const A=C.getComponent();if(A){const I=A.d;if(I!=null&&(j=w[I],O=D[I]=s.writeCursor()),M.has(A)){const F=ce(A);if(!F.invert)throw Error(`Cannot invert subtype ${F.name}`);v(O,F,F.invert(E(A)))}}let T=0,W=0;const G=s.advancer(j,(I,F)=>c(F)?T-I-1:I-T,(I,F)=>{c(F)&&T++});for(const I of C)if(typeof I=="number"){const F=I-W,_e=G(F),le=F+T;O.descend(le),B(_e,C,O),u(C.getComponent())&&W++,O.ascend()}else O.descend(I),B(G(I),C,O),O.ascend();G.end()}(R.clone(),R,N),D.length&&(N.reset(),R.traverse(N,(B,j)=>{const C=B.p;if(C!=null){const O=D[C];O&&O.get(),O&&j.mergeTree(O.get())}}))),N.get()}const Te=(g,R)=>g.some(N=>typeof N=="object"&&(Array.isArray(N)?Te(N,R):R(N)));function Ye(g,R){if(g==null||!Te(g,C=>{var O;return C.r!==void 0||((O=ce(C))===null||O===void 0?void 0:O.makeInvertible)!=null}))return g;const N=new s.ReadCursor(g),M=new s.WriteCursor;let w=!1;const D=[],B=[],j=(C,O,A)=>{const T=C.getComponent();let W=!1;if(T){T.d!=null&&O.write("d",T.d),T.i!==void 0&&O.write("i",T.i);const I=T.p;if(I!=null&&(D[I]=C.clone(),i(A!==void 0,"Operation picks up at an invalid key"),B[I]=A,O.write("p",T.p)),T.r!==void 0&&A===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const F=ce(T);F&&(F.makeInvertible?w=!0:v(O,F,E(T),!0))}let G=0;for(const I of C){O.descend(I);const F=typeof I=="number"?I-G:I,_e=m(A,F),le=j(C,O,_e);_e!==le&&(W||(W=!0,A=h(A)),le===void 0?(A=d(A,F),typeof I=="number"&&G++):A[F]=le),O.ascend()}return T&&(T.r!==void 0?(O.write("r",r.default(A)),A=void 0):T.p!=null&&(A=void 0)),A};return j(N,M,R),M.get(),w&&(M.reset(),function C(O,A,T,W,G){const I=A.getComponent();if(I){I.i!==void 0?(W=I.i,G=!0):I.d!=null&&(W=B[I.d],O=D[I.d],G=!1,I.d);let Q=ce(I);if(Q&&Q.makeInvertible){const me=E(I);v(T,Q,Q.makeInvertible(me,W),!0)}}let F=0,_e=0;const le=s.advancer(O,(Q,me)=>c(me)?F-Q-1:Q-F,(Q,me)=>{c(me)&&F++});for(const Q of A)if(typeof Q=="number"){const me=Q-_e,ct=le(me),xe=me+F,ye=m(W,G?me:xe);T.descend(Q),C(ct,A,T,ye,G),u(A.getComponent())&&_e++,T.ascend()}else{const me=m(W,Q);T.descend(Q),C(le(Q),A,T,me,G),T.ascend()}le.end()}(N.clone(),N,M,R,!1)),M.get()}function Da(g,R){return Ce(Ye(g,R))}const qn=g=>{if(g==null)return null;const R=g.slice();for(let N=0;N<g.length;N++){const M=R[N];Array.isArray(M)&&(R[N]=qn(M))}return R};function Zn(g,R,N){i(N==="left"||N==="right","Direction must be left or right");const M=N==="left"?0:1;if(R==null)return{ok:!0,result:g};ne(g),ne(R);let w=null;const D=[],B=[],j=[],C=[],O=[],A=[],T=[],W=[],G=[],I=[],F=[],_e=[],le=[],Q=[],me=[];let ct=0;const xe=s.readCursor(g),ye=s.readCursor(R),Ee=s.writeCursor();if(function ie(P,V=null,k){const U=a(V);U&&(U.r!==void 0?k=V.clone():U.p!=null&&(k=null,A[U.p]=P.clone()));const H=P.getComponent();let re;H&&(re=H.p)!=null&&(O[re]=V?V.clone():null,j[re]=P.clone(),k&&(I[re]=!0,G[re]=k),U&&U.p!=null&&(Q[re]=U.p));const se=s.advancer(V);for(const ae of P)ie(P,se(ae),k);se.end()}(ye,xe,null),function ie(P,V,k,U,H){const re=k.getComponent();let se,ae=!1;re&&((se=re.d)!=null?(C[se]=k.clone(),U!=null&&(me[U]==null&&(me[U]=[]),me[U].push(se)),P=O[se]||null,V=j[se]||null,I[se]?(H&&(F[se]=!0),H=G[se]||null):!H||M!==1&&Q[se]!=null||w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.moveOp(V.getPath(),k.getPath())}),ae=!0):re.i!==void 0&&(P=V=null,ae=!0,H&&w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.insertOp(k.getPath(),re.i)})));const we=a(P);we&&(we.r!==void 0?H=P.clone():we.p!=null&&(we.p,U=we.p,H=null));const Oe=ce(re);Oe&&H&&w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.editOp(k.getPath(),Oe,E(re),!0)});let Re=0,Ue=0;const te=s.advancer(V,(Y,Ae)=>c(Ae)?Re-Y-1:Y-Re,(Y,Ae)=>{c(Ae)&&Re++}),L=s.advancer(P);for(const Y of k)if(typeof Y=="number"){const Ae=Y-Ue,Fe=te(Ae);Ue+=+ie(L(Ae+Re),Fe,k,U,H)}else{const Ae=te(Y);ie(L(Y),Ae,k,U,H)}return te.end(),L.end(),ae}(xe,ye,ye.clone(),null,null),C.map(ie=>ie&&ie.get()),w)return{ok:!1,conflict:w};F.map(ie=>!!ie);const ze=[];let Je=null;(function ie(P,V,k,U,H){let re=!1;const se=a(V);if(c(se)){const te=se.p;te!=null?(k=C[te],U=_e[te]=s.writeCursor(),re=!0,H=null):(k=null,H=V.clone())}else u(a(k))&&(k=null);const ae=P.getComponent();if(ae){const te=ae.p;te!=null?(H&&(W[te]=H),ze[te]=H||M===1&&re?null:U.getComponent(),D[te]=P.clone(),k&&(T[te]=k.clone())):ae.r!==void 0&&(H||U.write("r",!0),(H||re)&&(Je==null&&(Je=new Set),Je.add(ae)))}let we=0,Oe=0;const Re=s.advancer(V,void 0,(te,L)=>{c(L)&&we++}),Ue=s.advancer(k,(te,L)=>u(L)?~(te-Oe):te-Oe,(te,L)=>{u(L)&&Oe++});if(P)for(const te of P)if(typeof te=="string"){const L=Re(te),Y=Ue(te);U.descend(te),ie(P,L,Y,U,H),U.ascend()}else{const L=Re(te),Y=te-we,Ae=c(a(L))?null:Ue(Y),Fe=Y+Oe;i(Fe>=0),U.descend(Fe),ie(P,L,Ae,U,H),U.ascend()}Re.end(),Ue.end()})(xe,ye,ye.clone(),Ee,null),Ee.reset();let Nt=[];if(function ie(P,V,k,U,H,re){i(V);const se=V.getComponent();let ae=a(U),we=!1;const Oe=($,pe,De)=>$?e.moveOp($.getPath(),pe.getPath()):e.insertOp(pe.getPath(),De.i);if(u(se)){const $=se.d;$!=null&&(B[$]=V.clone());const pe=$!=null?ze[$]:null;let De=!1;if(se.i!==void 0||$!=null&&pe){let Ie;ae&&(ae.i!==void 0||(Ie=ae.d)!=null&&!I[Ie])&&(De=Ie!=null?$!=null&&$===Q[Ie]:t.default(ae.i,se.i),De||Ie!=null&&M!==1&&Q[Ie]!=null||w==null&&(w={type:o.ConflictType.DROP_COLLISION,op1:Oe($!=null?D[$]:null,V,se),op2:Oe(Ie!=null?j[Ie]:null,U,ae)})),De||(re?w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:Oe($!=null?D[$]:null,V,se),op2:e.removeOp(re.getPath())}):($!=null?(Nt[ct]=$,H.write("d",pe.p=ct++)):H.write("i",r.default(se.i)),we=!0))}else if($!=null&&!pe){const Ie=W[$];Ie&&(re=Ie.clone())}$!=null?(P=D[$],k=A[$],U=T[$]):se.i!==void 0&&(P=k=null,De||(U=null))}else c(a(P))&&(P=k=U=null);const Re=a(P),Ue=a(k);if(c(Ue)){const $=Ue.p;Ue.r!==void 0&&(!Re||Re.r===void 0)||I[$]?(U=null,re=k.clone()):$!=null&&(U=C[$],M!==1&&Q[$]!=null||((H=le[$])||(H=le[$]=s.writeCursor()),H.reset(),re=null))}else!u(se)&&u(ae)&&(U=null);ae=U!=null?U.getComponent():null;const te=ce(se);if(te){const $=E(se);if(re)w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(V.getPath(),te,$,!0),op2:e.removeOp(re.getPath())});else{const pe=ce(ae);let De;if(pe){if(te!==pe)throw Error("Transforming incompatible types");const Ie=E(ae);De=te.transform($,Ie,N)}else De=r.default($);v(H,te,De)}}let L=0,Y=0,Ae=0,Fe=0,dt=0,wt=0,et=P!=null&&P.descendFirst(),zt=et;const Ht=s.advancer(k,void 0,($,pe)=>{c(pe)&&Ae++});let at=U!=null&&U.descendFirst(),lt=at;for(const $ of V)if(typeof $=="number"){let pe;const De=u(V.getComponent()),Ie=$-Y;{let mt;for(;et&&typeof(mt=P.getKey())=="number";){mt+=L;const nt=P.getComponent(),$t=c(nt);if(mt>Ie||mt===Ie&&(!$t||M===0&&De))break;if($t){L--;const At=nt.p;Q.includes(At),nt.d,a(le[nt.d]),c(a(le[nt.d])),(nt.r===void 0||Je&&Je.has(nt))&&(At==null||!ze[At]||M!==1&&Q.includes(At))||dt--}et=P.nextSibling()}pe=et&&mt===Ie?P:null}const tt=Ie-L;let ft=Ht(tt);const Jn=tt-Ae;let _n=null;{let mt,nt;for(;at&&typeof(mt=U.getKey())=="number";){nt=mt-Fe;const $t=U.getComponent(),At=u($t);if(nt>Jn)break;if(nt===Jn){if(!At){_n=U;break}{if(M===0&&De){_n=U;break}const bt=ft&&c(ft.getComponent());if(M===0&&bt)break}}if(At){const bt=$t.d;Q[bt],$t.i===void 0&&(I[bt]||Q[bt]!=null&&M!==1)?(I[bt]||Q[bt]!=null&&M===0)&&(Fe++,wt--):Fe++}at=U.nextSibling()}}const is=Jn+Fe+dt+wt;i(is>=0,"trying to descend to a negative index"),H.descend(is),De&&(pe=ft=_n=null,Y++),ie(pe,V,ft,_n,H,re)&&wt++,H.ascend()}else{let pe;for(;et&&(pe=P.getKey(),typeof pe!="string"||!(pe>$||pe===$));)et=P.nextSibling();const De=et&&pe===$?P:null,Ie=Ht($);let tt;for(;at&&(tt=U.getKey(),typeof tt!="string"||!(tt>$||tt===$));)at=U.nextSibling();const ft=at&&tt===$?U:null;H.descend($),ie(De,V,Ie,ft,H,re),H.ascend()}return Ht.end(),zt&&P.ascend(),lt&&U.ascend(),we}(xe,xe.clone(),ye,ye.clone(),Ee,null),w)return{ok:!1,conflict:w};Ee.reset();const Xe=(ie,P,V)=>ie.traverse(P,(k,U)=>{k.d!=null&&V(k.d,ie,U)});(I.length||_e.length)&&(Xe(ye,Ee,(ie,P,V)=>{I[ie]&&!F[ie]&&V.write("r",!0),_e[ie]&&V.mergeTree(_e[ie].get())}),Ee.reset());const Be=[],ht=[];if((le.length||I.length)&&!w){const ie=s.readCursor(qn(Ee.get()));if(Xe(ie,null,(P,V)=>{Be[P]=V.clone()}),le.forEach(P=>{P&&Xe(s.readCursor(P.get()),null,(V,k)=>{Be[V]=k.clone()})}),function P(V,k,U,H,re,se){const ae=a(k);if(ae&&c(ae))if(ae.p!=null){const L=ae.p;Be[L].getPath(),U=Be[L],H=ht[L]=s.writeCursor()}else ae.r!==void 0&&(U=null);else u(a(U))&&(U=null);const we=V.getComponent();if(we){let L;if((L=we.d)!=null){const Y=le[L];Y&&(Y.get(),H.mergeTree(Y.get()),U=s.readCursor(Y.get()))}}let Oe=0,Re=0;const Ue=s.advancer(k,void 0,(L,Y)=>{c(Y)&&Oe--}),te=s.advancer(U,(L,Y)=>u(Y)?-(L-Re)-1:L-Re,(L,Y)=>{u(Y)&&Re++});for(const L of V)if(typeof L=="number"){const Y=Ue(L),Ae=L+Oe,Fe=te(Ae),dt=Ae+Re;H.descend(dt),P(V,Y,Fe,H),H.ascend()}else H.descend(L),P(V,Ue(L),te(L),H),H.ascend();Ue.end(),te.end()}(ye,ie,ie.clone(),Ee),Ee.reset(),w)return{ok:!1,conflict:w};if(Ee.get(),ht.length){const P=ht.map(k=>k?k.get():null),V=s.readCursor(qn(Ee.get()));if(Xe(V,Ee,(k,U,H)=>{const re=P[k];re&&(H.mergeTree(re),P[k]=null)}),P.find(k=>k)){const k=s.writeCursor(),U=s.writeCursor();let H=0,re=0;P.forEach(se=>{se!=null&&Xe(s.readCursor(se),null,ae=>{const we=Nt[ae];k.writeMove(D[we].getPath(),B[we].getPath(),H++);const Oe=me[we];Oe&&Oe.forEach(Re=>{I[Re]||M!==1&&Q[Re]!=null||U.writeMove(j[Re].getPath(),C[Re].getPath(),re++)})})}),w={type:o.ConflictType.BLACKHOLE,op1:k.get(),op2:U.get()}}}}return w?{ok:!1,conflict:w}:{ok:!0,result:Ee.get()}}const ss=g=>{const R=new Error("Transform detected write conflict");throw R.conflict=g,R.type=R.name="writeConflict",R};function Ma(g,R,N){const M=Zn(g,R,N);if(M.ok)return M.result;ss(M.conflict)}const Ft=g=>{const R=s.writeCursor();return s.readCursor(g).traverse(R,(N,M)=>{(u(N)||ce(N))&&M.write("r",!0)}),R.get()},Ua=(g,R)=>{const{type:N,op1:M,op2:w}=g;switch(N){case o.ConflictType.DROP_COLLISION:return R==="left"?[null,Ft(w)]:[Ft(M),null];case o.ConflictType.RM_UNEXPECTED_CONTENT:let D=!1;return s.readCursor(M).traverse(null,B=>{B.r!==void 0&&(D=!0)}),D?[null,Ft(w)]:[Ft(M),null];case o.ConflictType.BLACKHOLE:return[Ft(M),Ft(w)];default:throw Error("Unrecognised conflict: "+N)}};function os(g,R,N,M){let w=null;for(;;){const D=Zn(R,N,M);if(D.ok)return fe(w,D.result);{const{conflict:B}=D;g(B)||ss(B);const[j,C]=Ua(B,M);R=fe(X(R),j),N=fe(X(N),C),w=fe(w,C)}}}})(Fi);(function(e){var n=We&&We.__createBinding||(Object.create?function(o,i,a,l){l===void 0&&(l=a),Object.defineProperty(o,l,{enumerable:!0,get:function(){return i[a]}})}:function(o,i,a,l){l===void 0&&(l=a),o[l]=i[a]}),t=We&&We.__exportStar||function(o,i){for(var a in o)a!=="default"&&!i.hasOwnProperty(a)&&n(i,o,a)};Object.defineProperty(e,"__esModule",{value:!0}),t(Fi,e);var r=zr;Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=Xr;Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})})(je);const Mc=Ac(je),Uc=ka({__proto__:null,default:Mc},[je]);var Z=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(Z||{});class wr{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 t=this._actions[this._index];if(t){const r=this._offset,s=t.len;return n>=s-r?(n=s-r,this._index+=1,this._offset=0):this._offset+=n,t.t===Z.DELETE||t.t===Z.RETAIN&&t.body==null?x.deepClone({...t,len:n}):x.deepClone({...t,len:n,body:an(t.body,r,r+n)})}else return{t:Z.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:Z.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,t=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=n,this._index=t,[r].concat(s)}}else return[]}}class Hi{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function $i(e,n,t){const{dataStream:r}=e,s=t,o=t+n,i=bi(e,n,t),a=Ti(e,n,t),l=yi(e,n,t),h=Di(e,n,t),c=Mi(e,n,t),u=Ui(e,n,t),d=Li(e,n,t);let f="";return r&&(e.dataStream=$o(r,s,o),f=r.slice(s,o)),{dataStream:f,textRuns:i,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:c,customRanges:u,customDecorations:d}}function ji(e,n,t,r){e.dataStream=Ho(e.dataStream,r,n.dataStream),Oi(e,n,t,r),Br(e,n,t,r),fc(e,n,t,r),Si(e,n,t,r),Ni(e,n,t,r),wi(e,n,t,r),Ai(e,n,t,r)}function Lc(e,n,t,r,s=ke.COVER){return pc(e,n,t,r,s)}function xc(e,n,t){return n<=0?{dataStream:""}:$i(e,n,t)}function Pc(e,n,t,r){t!==0&&ji(e,n,t,r)}function kc(e,n){const t=new Hi;return t.reset(),n.forEach(r=>{switch(r=x.deepClone(r),r.t){case Z.RETAIN:{const{coverType:s,body:o,len:i}=r;o!=null&&Lc(e,o,i,t.cursor,s),t.moveCursor(i);break}case Z.INSERT:{const{body:s,len:o}=r;Pc(e,s,o,t.cursor),t.moveCursor(o);break}case Z.DELETE:{const{len:s}=r;xc(e,s,t.cursor);break}default:throw new Error(`Unknown action type for action: ${r}.`)}}),e}function bs(e){return Object.keys(e).length===1}const sn=class sn{constructor(){_(this,"_actions",[])}static apply(n,t){return kc(n,t)}static compose(n,t){const r=new wr(n),s=new wr(t),o=new sn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===Z.INSERT)o.push(s.next());else if(r.peekType()===Z.DELETE)o.push(r.next());else{const i=Math.min(r.peekLength(),s.peekLength()),a=r.next(i),l=s.next(i);a.t===Z.INSERT&&l.t===Z.RETAIN?l.body==null?o.push(a):o.push({...a,body:Or(a.body,l.body,l.coverType)}):a.t===Z.RETAIN&&l.t===Z.RETAIN?a.body==null&&l.body==null?o.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?o.push({...a,body:Or(a.body,l.body,l.coverType)}):o.push(a.body?a:l):a.t===Z.RETAIN&&l.t===Z.DELETE?o.push(l):a.t===Z.INSERT&&(l.t,Z.DELETE)}return o.trimEndUselessRetainAction(),o.serialize()}static transform(n,t,r){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const t=[];for(const r of n)if(r.t===Z.INSERT)t.push({t:Z.DELETE,len:r.len,line:0,body:r.body,segmentId:r.segmentId});else if(r.t===Z.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");t.push({t:Z.INSERT,body:r.body,len:r.len,line:0,segmentId:r.segmentId})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");t.push({t:Z.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:ke.REPLACE,segmentId:r.segmentId})}else t.push(r);return t}static makeInvertible(n,t){const r=[];let s=0;for(const o of n){if(o.t===Z.DELETE&&o.body==null){const i=an(t,s,s+o.len,!1);o.len=i.dataStream.length,o.body=i}if(o.t===Z.RETAIN&&o.body!=null){const i=an(t,s,s+o.len,!0);o.oldBody={...i,dataStream:""},o.len=i.dataStream.length}r.push(o),o.t!==Z.INSERT&&(s+=o.len)}return r}insert(n,t,r=""){const s={t:Z.INSERT,body:t,len:n,line:0,segmentId:r};return this.push(s),this}retain(n,t="",r,s){const o={t:Z.RETAIN,len:n,segmentId:t};return r!=null&&(o.body=r),s!=null&&(o.coverType=s),this.push(o),this}delete(n,t=""){const r={t:Z.DELETE,len:n,line:0,segmentId:t};return this.push(r),this}serialize(){return this._actions}push(...n){if(n.length>1){for(const o of n)this.push(o);return this}let t=this._actions.length,r=this._actions[t-1];const s=x.deepClone(n[0]);if(s.t===Z.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===Z.DELETE&&s.t===Z.DELETE)return r.len+=s.len,this;if(r.t===Z.DELETE&&s.t===Z.INSERT&&(t-=1,r=this._actions[t-1],r==null))return this._actions.unshift(s),this;if(r.t===Z.RETAIN&&s.t===Z.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===Z.INSERT&&bs(r.body)&&s.t===Z.INSERT&&bs(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return t===this._actions.length?this._actions.push(s):this._actions.splice(t,0,s),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===Z.RETAIN&&Nc(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};_(sn,"id","text-x"),_(sn,"uri","https://github.com/dream-num/univer#text-x");let Ot=sn;Object.defineProperty(Ot,"name",{value:"text-x"});const jt=class jt{static registerSubtype(n){var t;this._subTypes.has(n.name)&&((t=this._subTypes.get(n.name))==null?void 0:t.id)!==Ot.id||(this._subTypes.set(n.name,n),je.type.registerSubtype(n))}static apply(n,t){if(!je.type.isNoop(t))return je.type.apply(n,t)}static compose(n,t){return je.type.compose(n,t)}static transform(n,t,r){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,t){return je.type.invertWithDoc(n,t)}static isNoop(n){return je.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new jt),this._instance}removeOp(n,t){return je.removeOp(n,t)}moveOp(n,t){return je.moveOp(n,t)}insertOp(n,t){return je.insertOp(n,t)}replaceOp(n,t,r){return je.replaceOp(n,t,r)}editOp(n,t=["body"]){return je.editOp(t,Ot.name,n)}};_(jt,"uri","https://github.com/dream-num/univer#json-x"),_(jt,"_subTypes",new Map),_(jt,"_instance",null);let Lt=jt;Lt.registerSubtype(Ot);const qr={id:"default_doc",documentStyle:{}};class Fc extends Vn{constructor(t){super();_(this,"type",J.UNIVER_DOC);_(this,"snapshot");this.snapshot={...qr,...t}}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 t;return((t=this.snapshot.settings)==null?void 0:t.zoomRatio)||1}resetDrawing(t,r){this.snapshot.drawings=t,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(t){this.snapshot.id=t}updateDocumentRenderConfig(t){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=t:r.renderConfig={...r.renderConfig,...t}}updateDocumentStyle(t){this.snapshot.documentStyle==null?this.snapshot.documentStyle=t:this.snapshot.documentStyle={...this.snapshot.documentStyle,...t}}updateDocumentDataMargin(t){const{t:r,l:s,b:o,r:i}=t,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),o!=null&&(a.marginBottom=o),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(t,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){t=t!=null?t:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:t,height:r};return}t!==void 0&&(s.pageSize.width=t),r!==void 0&&(s.pageSize.height=r)}updateDrawing(t,r){const{drawings:s}=this,{width:o,height:i,left:a,top:l}=r,h=s==null?void 0:s[t];if(!h)return;const c=h.docTransform;c.size.width=o,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(t=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:t}:this.snapshot.settings.zoomRatio=1}}class xt extends Fc{constructor(t){var s;super(x.isEmptyObject(t)?wc():t);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const r=6;this._unitId=(s=this.snapshot.id)!=null?s:x.generateRandomId(r),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(t=>{t.dispose()}),this.footerModelMap.forEach(t=>{t.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var t;return(t=this.snapshot.body)==null?void 0:t.customRanges}getCustomDecorations(){var t;return(t=this.snapshot.body)==null?void 0:t.customDecorations}getRev(){var t;return(t=this.snapshot.rev)!=null?t:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(t){if(t.id&&t.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...qr,...t},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(t){if(t!=null){if(this.headerModelMap.has(t))return this.headerModelMap.get(t);if(this.footerModelMap.has(t))return this.footerModelMap.get(t)}return this}getUnitId(){return this._unitId}apply(t){if(!Lt.isNoop(t))return this.snapshot=Lt.apply(this.snapshot,t),t!=null&&t.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(t,r,s=Gr.copy){const o=this.getBody();if(o!=null)return an(o,t,r,!1,s)}_initializeHeaderFooterModel(){const{headers:t,footers:r}=this.getSnapshot();if(t)for(const s in t){const o=t[s];this.headerModelMap.set(s,new xt(o))}if(r)for(const s in r){const o=r[s];this.footerModelMap.set(s,new xt(o))}}updateDocumentId(t){super.updateDocumentId(t),this._unitId=t}}const Wi=Ve("univer.config-service");class Bi{constructor(){_(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,t){this._config.set(n,t)}deleteConfig(n){this._config.delete(n)}}class Gi extends be{constructor(){super(...arguments);_(this,"_error$",new q.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(t){this._error$.next({errorKey:t})}}class Vi{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new Vo(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,t){if(this._cacheMap.has(t))return this._cacheMap.get(t);const r=this._getExistingStyleId(n);return r||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,t){const r=x.generateRandomId(6);return this._styles[r]=n,this._cacheMap.set(t,r),r}setValue(n){if(n==null)return;const t=JSON.stringify(n),r=this.search(n,t);return r!=="-1"?r:this.add(n,t)}toJSON(){return this._styles}getStyleByCell(n){let t;n&&x.isObject(n.s)?t=n.s:t=(n==null?void 0:n.s)&&this.get(n.s);const r=n==null?void 0:n.interceptorStyle;return r?{...t,...r}:t}_generateCacheMap(){const{_styles:n,_cacheMap:t}=this;for(const r in n){const s=JSON.stringify(n[r]);t.set(s,r)}}_getExistingStyleId(n){const{_styles:t}=this;for(const r in t)if(x.diffValue(t[r],n))return r;return null}}class Hc{constructor(n,t){_(this,"_columnData",{});this._config=n,this._columnData=t}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:t}=this,r=t[n];return r?r.hd!==K.TRUE:!0}getHiddenCols(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getColVisible(i);s&&a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:o,endColumn:i-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,o=i)}return s&&r.push({startRow:0,endRow:0,startColumn:o,endColumn:t,rangeType:oe.COLUMN}),r}getVisibleCols(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getColVisible(i);s&&!a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:o,endColumn:i-1,startRow:0,endRow:0})):!s&&a&&(s=!0,o=i)}return s&&r.push({startRow:0,endRow:0,startColumn:o,endColumn:t,rangeType:oe.COLUMN}),r}getColumnDatas(n,t){const r={};let s=0;for(let o=n;o<n+t;o++){const i=this.getColumnOrCreate(o);r[s]=i,s++}return r}getSize(){return It(this._columnData)}getColumnWidth(n){const{_columnData:t}=this,r=this._config;let s=0;return s=(t[n]||{hd:K.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(n){const t=this._columnData[n];if(t)return t}getColumnOrCreate(n){const{_columnData:t}=this,r=this._config,s=t[n];if(s)return s;const o={w:r.defaultColumnWidth,hd:K.FALSE};return this._columnData[n]=o,o}}class $c{constructor(n,t,r){_(this,"_rowData");this._config=n,this._viewModel=t,this._rowData=r}getRowData(){return this._rowData}getRowDatas(n,t){const r={};let s=0;for(let o=n;o<n+t;o++){const i=this.getRowOrCreate(o);r[s]=i,s++}return r}getRowHeight(n,t=1){const{_rowData:r}=this,s=this._config;let o=0;for(let i=0;i<t;i++){const a=r[i+n]||{hd:K.FALSE,h:s.defaultRowHeight},{ia:l,ah:h,h:c=s.defaultRowHeight}=a;o+=(l==null||l===K.TRUE)&&typeof h=="number"?h:c}return o}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:t}=this,r=t[n];if(r)return r;const s=this._config,o={hd:K.FALSE,h:s.defaultRowHeight};return t[n]=o,o}getHiddenRows(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getRowRawVisible(i);s&&a?(s=!1,r.push({startRow:o,endRow:i-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&!a&&(s=!0,o=i)}return s&&r.push({startRow:o,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getVisibleRows(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getRowRawVisible(i);s&&!a?(s=!1,r.push({startRow:o,endRow:i-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&a&&(s=!0,o=i)}return s&&r.push({startRow:o,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getRowRawVisible(n){const t=this.getRow(n);return t?t.hd!==K.TRUE:!0}getSize(){return It(this._rowData)}}const jc="DEFAULT_WORKSHEET_ROW_COUNT",Ki=1e3,Wc="DEFAULT_WORKSHEET_COLUMN_COUNT",Yi=20,Bc="DEFAULT_WORKSHEET_ROW_HEIGHT",zi=24,Gc="DEFAULT_WORKSHEET_COLUMN_WIDTH",Xi=88,Vc="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Qi=46,Kc="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",qi=20;function Zi(e){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:K.FALSE,rowCount:Ki,columnCount:Yi,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Xi,defaultRowHeight:zi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:K.TRUE,rowHeader:{width:Qi,hidden:K.FALSE},columnHeader:{height:qi,hidden:K.FALSE},selections:["A1"],rightToLeft:K.FALSE};return Object.keys(n).forEach(t=>{const r=t;typeof e[r]>"u"&&(e[r]=n[r])}),e}class Ji extends be{constructor(t){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=t}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(t,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(t,r):this.getRawCell(t,r)}getRowFiltered(t){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(t))!=null?s:!1}registerCellContentInterceptor(t){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=t,Ne(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(t){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=t,Ne(()=>this._rowFilteredInterceptor=null)}}class ln{constructor(n,t,r){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=n,this._styles=r,this._snapshot=Zi(t);const{columnData:s,rowData:o,cellData:i}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:x.generateRandomId(6),this._cellData=new ot(i),this._viewModel=new Ji((l,h)=>this.getCellRaw(l,h)),this._rowManager=new $c(this._snapshot,this._viewModel,o),this._columnManager=new Hc(this._snapshot,s)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),t=this.getMergeData();let r=-1,s=-1,o=-1,i=-1,a=!1,l=!1;return n.forEach((h,c)=>{Object.keys(c).forEach(u=>{const d=+u,f=n.getValue(h,d),p=f!=null&&f.s?this._styles.get(f.s):null,m=(p==null?void 0:p.bd)&&(p.bd.b||p.bd.l||p.bd.r||p.bd.t||p.bd.bc_tr||p.bd.bl_tr||p.bd.ml_tr||p.bd.tl_bc||p.bd.tl_br||p.bd.tl_mr);(f&&(f.v||f.p)||p!=null&&p.bg||m)&&(a?r=Math.min(r,h):(r=h,a=!0),s=Math.max(s,h),l?o=Math.min(o,d):(l=!0,o=d),i=Math.max(i,d))})}),t.forEach(h=>{a?r=Math.min(r,h.startRow):(r=h.startRow,a=!0),s=Math.max(s,h.endRow),l?o=Math.min(o,h.startColumn):(o=h.startColumn,a=!0),i=Math.max(i,h.endColumn)}),!a||!l?null:{startColumn:o,startRow:r,endColumn:i,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,t=x.deepClone(n);return new ln(this.unitId,t,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,t){const r=this._snapshot.mergeData;for(let s=0;s<r.length;s++){const o=r[s];if(vt.intersects({startRow:n,startColumn:t,endRow:n,endColumn:t},o))return o}return null}getCell(n,t){return n<0||t<0?null:this._viewModel.getCell(n,t)}getCellRaw(n,t){return this.getCellMatrix().getValue(n,t)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,t,r,s,o=!1){const i=this.getCellMatrix(),a=this._snapshot.mergeData.filter(h=>vt.intersects({startRow:n,startColumn:t,endRow:r,endColumn:s},h)),l=new ot;return fr(n,r,t,s).forEach((h,c)=>{const u=o?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;fr(u,f,c,d).forEach((p,m)=>{p===u&&m===c&&l.setValue(p,m,{...i.getValue(p,m),rowSpan:f-u+1,colSpan:d-c+1}),(p!==u||m!==c)&&l.realDeleteValue(p,m)})}),l}getRange(n,t,r,s){return typeof n=="object"?new Vt(this,n,{getStyles:()=>this._styles}):new Vt(this,{startRow:n,startColumn:t,endColumn:s||t,endRow:r||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:t}=n;return t}getMaxRows(){const{_snapshot:n}=this,{rowCount:t}=n;return t}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:t}=n;return t===0}getTabColor(){const{_snapshot:n}=this,{tabColor:t}=n;return t}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,t){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(n,t);return s.forEach(o=>o.endColumn=r),s}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,t){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(n,t);return s.forEach(o=>o.endRow=r),s}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:t}=n;return t}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,t=!0){const{startRow:r,startColumn:s,endRow:o,endColumn:i}=n,a=this;return{[Symbol.iterator]:()=>{let l=r,h=s;return{next(){for(;;){if(h>i&&(l+=1,h=s),l>o)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&&t){h=d.endColumn+1;continue}const p={row:l,col:h,value:c};return p.colSpan=d.endColumn-d.startColumn+1,p.rowSpan=d.endRow-d.startRow+1,h=d.endColumn+1,{done:!1,value:p}}if(u&&t)h+=1;else{const f={row:l,col:h,value:c};return h+=1,{done:!1,value:f}}}}}}}}iterateByColumn(n,t=!0,r=!0){const{startRow:s,startColumn:o,endRow:i,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let h=s,c=o;return{next(){for(;;){if(h>i&&(c+=1,h=s),c>a)return{done:!0,value:void 0};const u=l.getMergedCell(h,c);if(u){const p=h!==u.startRow,m=p||c!==u.startColumn;if(r&&m||!r&&p){h=u.endRow+1;continue}const S=l.getCell(u.startRow,u.startColumn);if(!S&&t){h=u.endRow+1;continue}const ee={row:h,col:u.startColumn,value:S};return ee.colSpan=u.endColumn-u.startColumn+1,ee.rowSpan=u.endRow-u.startRow+1,h=u.endRow+1,{done:!1,value:ee}}const d=l.getCell(h,c);if(!d&&t)h+=1;else{const p={row:h,col:c,value:d};return h+=1,{done:!1,value:p}}}}}}}}}function Yc(e){var r,s;if(!e)return"";const n=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(n)return n;const t=e.v;return typeof t=="string"?e.t===Mt.BOOLEAN?t.toUpperCase():t.replace(/[\r\n]/g,""):typeof t=="number"?e.t===Mt.BOOLEAN?t?"TRUE":"FALSE":t.toString():typeof t=="boolean"?t?"TRUE":"FALSE":""}const zc="0.2.4-alpha.0";function Xc(e="",n=Pt.ZH_CN,t=""){return{id:e,sheetOrder:[],name:t,appVersion:zc,locale:n,styles:{},sheets:{},resources:[]}}var Qc=Object.defineProperty,qc=Object.getOwnPropertyDescriptor,Zc=(e,n,t,r)=>{for(var s=r>1?void 0:r?qc(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Qc(n,t,s),s},Jc=(e,n)=>(t,r)=>n(t,r,e);function eh(e,n){return`${e.getUnitId()}|${n.getSheetId()}`}exports.Workbook=class extends Vn{constructor(t={},r){super();_(this,"type",J.UNIVER_SHEET);_(this,"_sheetCreated$",new q.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new q.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new q.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");_(this,"_name$");_(this,"name$");this._logService=r;const s=Xc();x.isEmptyObject(t)?this._snapshot=s:this._snapshot=x.commonExtend(s,t);const{styles:o}=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 Vi(o),this._count=1,this._worksheets=new Map,this._name$=new q.BehaviorSubject(t.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(t){return typeof t=="string"||"startRow"in t||"row"in t}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(t){this._name$.next(t),this._snapshot.name=t}getUnitId(){return this._unitId}getRev(){var t;return(t=this._snapshot.rev)!=null?t:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(t,r,s){const{sheets:o,sheetOrder:i}=this._snapshot;if(o[t])return!1;o[t]=s,i.splice(r,0,t);const a=new ln(this._unitId,s,this._styles);return this._worksheets.set(t,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(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===t)}getActiveSheet(t){if(!this._activeSheet&&typeof t>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const t=this._activeSheet;if(t)return t;const r=this._snapshot.sheetOrder;for(let o=0,i=r.length;o<i;o++){const a=this._worksheets.get(r[o]);if(a&&a.isSheetHidden()!==K.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(t){this._activeSheet$.next(t)}removeSheet(t){const r=this._worksheets.get(t);return r?(this._worksheets.delete(t),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(t),1),delete this._snapshot.sheets[t],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:t}=this._snapshot;return t.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:t}=this._snapshot;return t.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:t}=this._snapshot,r=[];return t.forEach(s=>{const o=this._worksheets.get(s);o&&r.push(o.getName())}),r}getSheetIndex(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>t.getSheetId()===s)}getSheetBySheetName(t){const{sheetOrder:r}=this._snapshot,s=r.find(o=>this._worksheets.get(o).getName()===t);return this._worksheets.get(s)}getSheetBySheetId(t){return this._worksheets.get(t)}getSheetByIndex(t){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[t])}getHiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden===K.TRUE).map(t=>t.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden!==K.TRUE).map(t=>t.getConfig().id)}load(t){this._snapshot=t}checkSheetName(t){return this.getSheetsName().includes(t)}uniqueSheetName(t="Sheet1"){let r=t;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}generateNewSheetName(t){let r=t+this._count;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:t,_worksheets:r}=this,{sheets:s,sheetOrder:o}=t;if(x.isEmptyObject(s)){const i=x.generateRandomId();s[i]={id:i}}for(const i in s){const a=s[i],{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 ln(this._unitId,a,this._styles);r.set(i,h),o.includes(i)||o.push(i)}this.ensureActiveSheet()}};exports.Workbook=Zc([Jc(1,St)],exports.Workbook);class Zr extends Vn{constructor(t){var r;super();_(this,"type",J.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...zo,...t},this._unitId=(r=this._snapshot.id)!=null?r:x.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var t;return(t=this._snapshot.body)==null?void 0:t.pages}getPageOrder(){var t;return(t=this._snapshot.body)==null?void 0:t.pageOrder}getPage(t){const r=this.getPages();return r==null?void 0:r[t]}getElementsByPage(t){var r;return(r=this.getPage(t))==null?void 0:r.pageElements}getElement(t,r){var s;return(s=this.getElementsByPage(t))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:yr.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const tn="FOCUSING_SHEET",wn="FOCUSING_DOC",An="FOCUSING_SLIDE",th="FOCUSING_EDITOR_BUT_HIDDEN",ea="EDITOR_ACTIVATED",nh="FOCUSING_EDITOR_INPUT_FORMULA",ta="FOCUSING_FORMULA_EDITOR",rh="FOCUSING_UNIVER_EDITOR",sh="FOCUSING_EDITOR_INPUT_FORMULA",oh="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",ih="FOCUSING_COMMON_DRAWINGS";var ah=Object.defineProperty,lh=Object.getOwnPropertyDescriptor,uh=(e,n,t,r)=>{for(var s=r>1?void 0:r?lh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&ah(n,t,s),s},Ts=(e,n)=>(t,r)=>n(t,r,e);const Kt=Ve("univer.current");exports.UniverInstanceService=class extends be{constructor(t,r){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits",new Map);_(this,"_currentUnits$",new q.BehaviorSubject(this._currentUnits));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new q.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new q.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new q.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=t,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(t){this._createHandler=t}createUnit(t,r){return this._createHandler(t,r,this._ctorByType.get(t))}registerCtorForType(t,r){return this._ctorByType.set(t,r),{dispose:()=>{this._ctorByType.delete(t)}}}getCurrentTypeOfUnit$(t){return this.currentUnits$.pipe(q.map(r=>{var s;return(s=r.get(t))!=null?s:null}),q.distinctUntilChanged())}getCurrentUnitForType(t){return this._currentUnits.get(t)}setCurrentUnitForType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${t}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(t){this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(t){return this._unitAdded$.pipe(q.filter(r=>r.type===t))}__addUnit(t){const r=t.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]),this._unitsByType.get(r).push(t),this._unitAdded$.next(t),this.setCurrentUnitForType(t.getUnitId())}getTypeOfUnitDisposed$(t){return this.unitDisposed$.pipe(q.filter(r=>r.type===t))}getUnit(t,r){var o;const s=(o=this._getUnitById(t))==null?void 0:o[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(J.UNIVER_DOC)}getUniverDocInstance(t){return this.getUnit(t,J.UNIVER_DOC)}getUniverSheetInstance(t){return this.getUnit(t,J.UNIVER_SHEET)}getAllUnitsForType(t){var r;return(r=this._unitsByType.get(t))!=null?r:[]}changeDoc(t,r){const s=this.getAllUnitsForType(J.UNIVER_DOC),o=s.find(i=>i.getUnitId()===t);if(o!=null){const i=s.indexOf(o);s.splice(i,1)}this.__addUnit(r)}get focused(){var r;const t=this._focused$.getValue();return t?(r=this._getUnitById(t))==null?void 0:r[0]:null}focusUnit(t){this._focused$.next(t),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(tn,!0),this._contextService.setContextValue(An,!1)):this.focused instanceof xt?(this._contextService.setContextValue(wn,!0),this._contextService.setContextValue(tn,!1),this._contextService.setContextValue(An,!1)):this.focused instanceof Zr&&(this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(tn,!1),this._contextService.setContextValue(An,!0))}getFocusedUnit(){return this.focused}getUnitType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: No document with unitId ${t}`);return r[1]}disposeUnit(t){const r=this._getUnitById(t);if(!r)return!1;const[s,o]=r,i=this._unitsByType.get(o),a=i.indexOf(s);return i.splice(a,1),this._removeCurrentUnitForType(o),this._focused$.next(null),this._unitDisposed$.next(s),!0}_getUnitById(t){for(const[r,s]of this._unitsByType){const o=s.find(i=>i.getUnitId()===t);if(o)return[o,r]}}};exports.UniverInstanceService=uh([Ts(0,it(pt)),Ts(1,cn)],exports.UniverInstanceService);var de=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(de||{});const ch={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},bn=new Map;function na(e,n){return function(s){Kn(e,n)}}function Kn(e,n){bn.has(e)||bn.set(e,[]),bn.get(e).push(n)}var hh=Object.defineProperty,dh=Object.getOwnPropertyDescriptor,ra=(e,n,t,r)=>{for(var s=r>1?void 0:r?dh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&hh(n,t,s),s},sa=(e,n)=>(t,r)=>n(t,r,e);exports.LifecycleService=class extends be{constructor(t){super();_(this,"_lifecycle$",new q.BehaviorSubject(de.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=t,this._reportProgress(de.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(t){if(t<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(t!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(t),this._lifecycle$.next(t),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return q.merge(oa(this.stage),this._lifecycle$.pipe(q.skip(1))).pipe(Ri(t=>t===de.Steady))}_reportProgress(t){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${ch[t]}".`)}};exports.LifecycleService=ra([sa(0,St)],exports.LifecycleService);exports.LifecycleInitializerService=class extends be{constructor(t){super();_(this,"_seenTokens",new Set);this._injector=t}initModulesOnStage(t){var r;(r=bn.get(t))==null||r.forEach(s=>{this._injector.has(s)&&!this._seenTokens.has(s)&&(this._injector.get(s),this._seenTokens.add(s))})}};exports.LifecycleInitializerService=ra([sa(0,it(pt))],exports.LifecycleInitializerService);function oa(e){switch(e){case de.Starting:return q.of(de.Starting);case de.Ready:return q.of(de.Starting,de.Ready);case de.Rendered:return q.of(de.Starting,de.Ready,de.Rendered);default:return q.of(de.Starting,de.Ready,de.Rendered,de.Steady)}}class nn extends be{constructor(){super();_(this,"_currentLocale$",new q.BehaviorSubject(Pt.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new q.Subject);_(this,"t",(t,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=t.split("."),o=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof o=="string"){let i=o;return r.forEach((a,l)=>{i=i.replace(`{${l}}`,a)}),i}else return t});this.disposeWithMe(Ne(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(t){var r;this._locales=x.deepMerge((r=this._locales)!=null?r:{},t)}setLocale(t){this._currentLocale$.next(t),this.localeChanged$.next()}getLocales(){var t;return(t=this._locales)==null?void 0:t[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(t,r){const s=r.shift();if(s&&t&&s in t){const o=t[s];return r.length>0&&(typeof o=="object"||Array.isArray(o))?this.resolveKeyPath(o,r):o}return null}}var Jr=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(Jr||{});const es=Ve("univer.permission-service");Kn(de.Starting,es);class ia extends be{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new q.Subject);_(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(t){const r=this._permissionPointMap.get(t);r&&(r.complete(),this._permissionPointMap.delete(t))}addPermissionPoint(t){const r=t instanceof q.BehaviorSubject,s=r?t.getValue():t;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?t:new q.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(t,r){const s=this._permissionPointMap.get(t);if(!s)return;const o=s.getValue();o.value=r,o.status=Jr.DONE,s.next({...o}),this._permissionPointUpdate$.next(o)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(t){const r=this._permissionPointMap.get(t);if(r)return r.getValue()}getPermissionPoint$(t){const r=this._permissionPointMap.get(t);if(r)return r}composePermission$(t){const r=t.map(s=>{var i;const o=(i=this._permissionPointMap)==null?void 0:i.get(s);if(!o)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return o.asObservable()});return q.combineLatest(r).pipe(Cn.map(s=>s))}composePermission(t){return t.map(s=>{var i;const o=(i=this._permissionPointMap)==null?void 0:i.get(s);if(!o)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return o.getValue()})}getAllPermissionPoint(){const t=new Map;return this._permissionPointMap.forEach((r,s)=>{t.set(s,r)}),t}}class aa extends be{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new q.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(t){return this.getAllResourceHooks().map(o=>{const i=o.toJson(t);return{name:o.pluginName,data:i}})}getResourcesByType(t,r){return this.getAllResourceHooks().filter(i=>i.businesses.includes(r)).map(i=>{const a=i.toJson(t);return{name:i.pluginName,data:a}})}registerPluginResource(t){const r=t.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,t),this._register$.next(t),Ne(()=>this._resourceMap.delete(r))}disposePluginResource(t){this._resourceMap.delete(t)}loadResources(t,r){this.getAllResourceHooks().forEach(s=>{var i;const o=(i=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:i.data;if(o)try{const a=s.parseJson(o);s.onLoad(t,a)}catch{console.error("LoadResources Error!")}})}unloadResources(t){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(t)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Yn=Ve("resource-manager-service");var fh=Object.defineProperty,_h=Object.getOwnPropertyDescriptor,gh=(e,n,t,r)=>{for(var s=r>1?void 0:r?_h(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&fh(n,t,s),s},ys=(e,n)=>(t,r)=>n(t,r,e);let Ar=class extends be{constructor(n,t){super();_(this,"saveWorkbook",n=>{const t=n.getUnitId(),r=this._resourceManagerService.getResources(t)||[],s=n.getSnapshot();return s.resources=r,s});this._resourceManagerService=n,this._univerInstanceService=t,this._init()}_init(){const n=r=>{r.businesses.forEach(s=>{switch(s){case J.UNRECOGNIZED:case J.UNIVER_UNKNOWN:case J.UNIVER_SLIDE:case J.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(J.UNIVER_DOC).forEach(o=>{const a=(o.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(o.getUnitId(),l)}catch{console.error(`Load Document{${o.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}});break}case J.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(J.UNIVER_SHEET).forEach(o=>{const a=(o.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(o.getUnitId(),l)}catch{console.error(`Load Workbook{${o.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(r=>{n(r)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(r=>{n(r)})),this.disposeWithMe(Ne(this._univerInstanceService.getTypeOfUnitAdded$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.loadResources(r.getUnitId(),r.getSnapshot().resources)}))),this.disposeWithMe(Ne(this._univerInstanceService.getTypeOfUnitDisposed$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.unloadResources(r.getUnitId())})))}saveDoc(n){const t=n.getUnitId(),r=this._resourceManagerService.getResourcesByType(t,J.UNIVER_DOC)||[],s=n.getSnapshot();return s.resources=r,s}};Ar=gh([ys(0,it(Yn)),ys(1,it(Kt))],Ar);const ts=Ve("resource-loader-service");Kn(de.Ready,ts);class ns extends be{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new q.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Ne(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(t){this._currentTheme=t,this._currentTheme$.next(t)}}const zn="__INTERNAL_EDITOR__",la=`${zn}DOCS_NORMAL`,ua=`${zn}DOCS_FORMULA_BAR`,ph=`\r
9
- `;function mh(e){return`${zn}${e}`}function Eh(e){return e.startsWith(zn)}var Rh=Object.defineProperty,Ch=Object.getOwnPropertyDescriptor,Ih=(e,n,t,r)=>{for(var s=r>1?void 0:r?Ch(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Rh(n,t,s),s},or=(e,n)=>(t,r)=>n(t,r,e);const Xn=Ve("univer.undo-redo.service"),vh=20;class ca{dispose(){}async dispatchToHandlers(){return!1}}const ha="univer.command.redo",da="univer.command.undo",fa=new class extends ca{constructor(){super(...arguments);_(this,"type",hn.COMMAND);_(this,"id",da)}async handler(n){const t=n.get(Xn),r=t.pitchTopUndoElement();if(!r)return!1;const s=n.get(dn);return Hr(r.undoMutations,s)?(t.popUndoToRedo(),!0):!1}},_a=new class extends ca{constructor(){super(...arguments);_(this,"type",hn.COMMAND);_(this,"id",ha)}async handler(n){const t=n.get(Xn),r=t.pitchTopRedoElement();if(!r)return!1;const s=n.get(dn);return Hr(r.redoMutations,s)?(t.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends be{constructor(t,r,s){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new q.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=t,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(fa)),this.disposeWithMe(this._commandService.registerCommand(_a)),this.disposeWithMe(Ne(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Ne(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(t){const{unitID:r}=t,s=this._getRedoStack(r,!0),o=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(t.unitID)){const a=this._batchingStatus.get(t.unitID),l=this._pitchUndoElement(t.unitID);a===0||!l?(i(t),this._batchingStatus.set(t.unitID,1)):this._tryBatchingElements(l,t)}else i(t);function i(a){o.push(a),o.length>vh&&o.splice(0,1)}this._updateStatus()}clearUndoRedo(t){const r=this._getRedoStack(t);r&&(r.length=0);const s=this._getUndoStack(t);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const t=this._getFocusedUnitId();return this._pitchUndoElement(t)}pitchTopRedoElement(){const t=this._getFocusedUnitId();return this._pitchRedoElement(t)}_pitchUndoElement(t){const r=this._getUndoStack(t);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(t){const r=this._getRedoStack(t);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}__tempBatchingUndoRedo(t){if(this._batchingStatus.has(t))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(t,0),Ne(()=>this._batchingStatus.delete(t))}_updateStatus(){var o,i;const t=this._getFocusedUnitId(),r=t&&((o=this._undoStacks.get(t))==null?void 0:o.length)||0,s=t&&((i=this._redoStacks.get(t))==null?void 0:i.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(t,r=!1){let s=this._undoStacks.get(t);return!s&&r&&(s=[],this._undoStacks.set(t,s)),s||null}_getRedoStack(t,r=!1){let s=this._redoStacks.get(t);return!s&&r&&(s=[],this._redoStacks.set(t,s)),s||null}_getUndoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getUndoStack(t,!0)}_getRedoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getRedoStack(t,!0)}_tryBatchingElements(t,r){t.redoMutations.push(...r.redoMutations),t.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var i,a,l,h;let t="";const r=this._contextService.getContextValue(tn),s=this._contextService.getContextValue(ta),o=this._contextService.getContextValue(ea);return r?s?t=ua:o?t=la:t=(a=(i=this._univerInstanceService.getFocusedUnit())==null?void 0:i.getUnitId())!=null?a:"":t=(h=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?h:"",t}};exports.LocalUndoRedoService=Ih([or(0,Kt),or(1,dn),or(2,cn)],exports.LocalUndoRedoService);const ga=Symbol("DependentOn");class br extends be{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(br,"pluginName"),_(br,"type",J.UNIVER_UNKNOWN);class Oh{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 Sh{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,t){this._pluginsRegistered.push({plugin:n,options:t})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Nh=Object.defineProperty,wh=Object.getOwnPropertyDescriptor,pa=(e,n,t,r)=>{for(var s=r>1?void 0:r?wh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Nh(n,t,s),s},Zt=(e,n)=>(t,r)=>n(t,r,e);const Ah=4;function bh(...e){return function(n){n[ga]=e}}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(kn,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,t){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:r}=n;r===J.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,t),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(r).register(n,t)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const t=this._injector.createInstance(kn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,t),t}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:t,pluginName:r}=n;if(t===J.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(r==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Ah))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,t]of this._pluginHoldersForTypes)t.started&&t.flush()}};exports.PluginService=pa([Zt(0,it(pt))],exports.PluginService);let kn=class extends be{constructor(n,t,r,s,o,i){super();_(this,"_started",!1);_(this,"_pluginRegistry",new Sh);_(this,"_pluginStore",new Oh);_(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=t,this._logService=r,this._injector=s,this._lifecycleService=o,this._lifecycleInitializerService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(q.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,t){this._pluginRegistry.registerPlugin(n,t)}immediateInitPlugin(n){const t=this._initPlugin(n,void 0);this._pluginsRunLifecycle([t])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:t,options:r})=>this._initPlugin(t,r));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,t){const r=n[ga];if(r){const o=()=>{const i=r.find(a=>!this._checkPluginRegistered(a));return i?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${i.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(i,void 0),!0):!1};for(;o(););}const s=this._injector.createInstance(n,t);return this._pluginStore.addPlugin(s),s}_pluginsRunLifecycle(n){oa(this._lifecycleService.stage).subscribe(t=>this._runStage(n,t)),this._awaitingPlugins.push(n)}_runStage(n,t){n.forEach(r=>{switch(t){case de.Starting:r.onStarting(this._injector);break;case de.Ready:r.onReady();break;case de.Rendered:r.onRendered();break;case de.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(t)}};kn=pa([Zt(2,St),Zt(3,it(pt)),Zt(4,it(exports.LifecycleService)),Zt(5,it(exports.LifecycleInitializerService))],kn);function ma(e,n){if(!n)return e;const t=[];for(const r of e){const s=n.find(([o])=>o===r[0]);if(s){if(s[1]===null)continue;t.push([r[0],s[1]])}else t.push(r)}return t}const Tr={[$e.Editor]:"Editor",[$e.Owner]:"Owner",[$e.Reader]:"Reader",[$e.UNRECOGNIZED]:"UNRECOGNIZED"},Fn=e=>e?{userID:`${Tr[e]}_${x.generateRandomId(8)}`,name:Tr[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},ir=(e,n)=>e.startsWith(Tr[n]);var Th=Object.defineProperty,yh=Object.getOwnPropertyDescriptor,Dh=(e,n,t,r)=>{for(var s=r>1?void 0:r?yh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Th(n,t,s),s};exports.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new q.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new q.BehaviorSubject(Fn()));_(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,t){const r=this._model.get(n);if(r)return r;t&&t()}delete(n){const t=this.getUser(n);this._model.delete(n),t&&this._userChange$.next({type:"delete",user:t})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}};exports.UserManagerService=Dh([na(de.Starting,exports.UserManagerService)],exports.UserManagerService);var Mh=Object.defineProperty,Uh=Object.getOwnPropertyDescriptor,Lh=(e,n,t,r)=>{for(var s=r>1?void 0:r?Uh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Mh(n,t,s),s},Ds=(e,n)=>(t,r)=>n(t,r,e);exports.AuthzIoLocalService=class{constructor(n,t){_(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=t,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(Fn($e.Owner))}_getRole(n){const t=this._userManagerService.getCurrentUser();return t?ir(t.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const t=[...this._permissionMap.keys()].reduce((r,s)=>{const o=this._permissionMap.get(s);return r[s]=o,r},{});return JSON.stringify(t)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[J.UNIVER_SHEET,J.UNIVER_DOC,J.UNIVER_SLIDE],onLoad:(n,t)=>{for(const r in t)this._permissionMap.set(r,t[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const t=x.generateRandomId(8);switch(n.objectType){case Nn.SelectRange:{const r=n.selectRangeObject;this._permissionMap.set(t,{...r,objectType:n.objectType});break}case Nn.Worksheet:{const r=n.worksheetObject;this._permissionMap.set(t,{...r,objectType:n.objectType,readScope:Ii.SomeCollaborator})}}return t}async allowed(n){var t;if(this._permissionMap.has(n.objectID)){const r=this._permissionMap.get(n.objectID);if(r&&r.objectType===Nn.Worksheet)return(t=r==null?void 0:r.strategies)==null?void 0:t.map(s=>({action:s.action,allowed:s.role===$e.Editor}))}return n.actions.map(r=>({action:r,allowed:this._getRole($e.Owner)||this._getRole($e.Editor)}))}async batchAllowed(n){const t=this._userManagerService.getCurrentUser(),r=n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(o=>({action:o,allowed:!1}))}));return t&&(ir(t.userID,$e.Owner)||ir(t.userID,$e.Editor))?n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(o=>({action:o,allowed:!0}))})):r}async list(n){const t=[];return n.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const o={objectID:r,unitID:n.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:$e.Owner,shareScope:-1,creator:Fn($e.Owner),strategies:[],actions:n.actions.map(i=>({action:i,allowed:this._getRole($e.Owner)||this._getRole($e.Editor)}))};t.push(o)}}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}};exports.AuthzIoLocalService=Lh([Ds(0,Yn),Ds(1,it(exports.UserManagerService))],exports.AuthzIoLocalService);const Ea=Ve("IAuthzIoIoService");class xh{constructor(n={},t){_(this,"_startedTypes",new Set);_(this,"_injector");const r=this._injector=Ph(t,n==null?void 0:n.override),{theme:s,locale:o,locales:i,logLevel:a}=n;s&&this._injector.get(ns).setTheme(s),i&&this._injector.get(nn).load(i),o&&this._injector.get(nn).setLocale(o),a&&this._injector.get(St).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(Kt)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(nn).setLocale(n)}createUnit(n,t){return this._univerInstanceService.createUnit(n,t)}createUniverSheet(n){return this._univerInstanceService.createUnit(J.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(J.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(J.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(J.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(J.UNIVER_DOC,xt),this._univerInstanceService.registerCtorForType(J.UNIVER_SLIDE,Zr);const t=n.get(Kt);t.__setCreateHandler((r,s,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginForType(r),this._startedTypes.add(r);const a=n.createInstance(o,s);return t.__addUnit(a),this._tryProgressToReady(),a}const i=n.createInstance(o,s);return t.__addUnit(i),i})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<de.Ready&&(this._injector.get(exports.LifecycleService).stage=de.Ready)}registerPlugin(n,t){this._pluginService.registerPlugin(n,t)}}function Ph(e,n){const t=ma([[Gi],[nn],[ns],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[Kt,{useClass:exports.UniverInstanceService}],[es,{useClass:ia}],[St,{useClass:pi,lazy:!0}],[dn,{useClass:exports.CommandService}],[Xn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Wi,{useClass:Bi}],[cn,{useClass:_i}],[Yn,{useClass:aa,lazy:!0}],[ts,{useClass:Ar,lazy:!0}],[Ea,{useClass:exports.AuthzIoLocalService,lazy:!0}]],n);return e?e.createChild(t):new pt(t)}const kh=(e,n)=>n.length===e.length&&!e.some(t=>n.some(r=>!vt.equals(r,t))),Fh=(e,n)=>n.length===e.length&&e.every((t,r)=>{const s=n[r];return s.unitId===t.unitId&&s.sheetId===t.sheetId&&vt.equals(t.range,s.range)});function Hh(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||!e||typeof n!="object"||!n)return!1;const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;const s=Object.prototype.hasOwnProperty.bind(n);for(let o=0;o<t.length;o++){const i=t[o];if(!s(i))return!1;const a=e[i],l=n[i];if(a!==l)return!1}return!0}function Ra(e){return/^-?\d+(\.\d+)?$/.test(e)}function $h(e){return Ra(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function jh(e){return["true","false"].includes(e.toLowerCase())}function Wh(e,n){return n.forEach(t=>e.add(t)),e}function Bh(e,n=16){let t=0,r=null;return function(...o){const i=Date.now();i-t<n?(r&&clearTimeout(r),r=setTimeout(()=>{t=i,e.apply(this,o)},n)):(t=i,e.apply(this,o))}}function Gh(e){const n=new MessageChannel;let t=!1;const r=()=>{t||e()};return n.port1.onmessage=r,n.port2.postMessage(null),()=>{t=!0,n.port1.close(),n.port2.close()}}var Ca=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(Ca||{});function Vh(e,n,t){if(n==="")return e;const r={id:"mock-id",body:e,documentStyle:{}},s=new xt(r),o=n.length;let i;for(;(i=s.getBody().dataStream.indexOf(n))>=0;){const l=new Ot,h=Lt.getInstance();if(i>0&&l.retain(i),t.length>0){const c=s.sliceBody(i,i+o),u={dataStream:t};Array.isArray(c==null?void 0:c.textRuns)&&c.textRuns.length&&(u.textRuns=[{...c.textRuns[0],st:0,ed:t.length}]),l.insert(t.length,u)}l.delete(o),s.apply(h.editOp(l.serialize()))}const a=s.getBody();return s.dispose(),a}class Ia{constructor(){_(this,"skipNextObservers",!1);_(this,"lastReturnValue");_(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Kh extends q.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(t){let r;typeof t=="function"?r={next:([o,i])=>t(o,i)}:r=t;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((o,i)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(o=>o!==r)),s}clearObservers(){this._sortedObservers.forEach(t=>{var r;return(r=t.complete)==null?void 0:r.call(t)}),this._sortedObservers.length=0}emitEvent(t){var r;if(!this.closed){const s=new Ia;s.lastReturnValue=t;for(const o of this._sortedObservers){const i=(r=o.next)==null?void 0:r.call(o,[t,s]);if(s.lastReturnValue=i,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}const Yh=Ve("ILocalStorageService");function zh(e){return`sheet_interceptor_${e}`}const va=e=>function(n,t){let r=-1;function s(o,i){if(o<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");return r=o,o===e.length?i:e[o].handler(i,t,s.bind(null,o+1))}return s(0,n)};class Xh{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const t=n,r=this._interceptorsByName.get(t);return va(r||[])}intercept(n,t){const r=n;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(t),this._interceptorsByName.set(r,s.sort((o,i)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)})),()=>Bn(this._interceptorsByName.get(r),t)}getInterceptPoints(){return this._interceptorPoints}}const Qh=Ve("univer.snapshot-server-service");class qh{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,t){return Promise.resolve({snapshot:{unitID:"",type:J.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Ze.OK,message:""}})}getSheetBlock(n,t){const r=this._sheetBlockCache.get(t.blockID);return Promise.resolve({block:r,error:{code:Ze.OK,message:""}})}fetchMissingChangesets(n,t){return Promise.resolve({changesets:[],error:{code:Ze.OK,message:""}})}getResourcesRequest(n,t){return Promise.resolve({resources:{},error:{code:Ze.OK,message:""}})}saveSnapshot(n,t){return Promise.resolve({error:{code:Ze.OK,message:""}})}saveSheetBlock(n,t){const{block:r}=t;return r?(this._sheetBlockCache.set(r.id,r),Promise.resolve({error:{code:Ze.OK,message:""},blockID:r.id})):Promise.resolve({error:{code:Ze.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,t){return Promise.resolve({error:{code:Ze.OK,message:""},concurrent:[]})}}function Zh(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(n,t)=>String.fromCharCode(Number.parseInt(t,16))))}function rs(e){return decodeURIComponent(Array.prototype.map.call(atob(e),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const fn=new TextEncoder,Qn=new TextDecoder;function Oa(e){const n=x.deepClone(e);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,fn.encode(JSON.stringify(n))}function Sa(e){const n=x.deepClone(e);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,fn.encode(JSON.stringify(n))}function Jh(e){const n=x.deepClone(e);return delete n.id,delete n.rev,delete n.title,delete n.resources,fn.encode(JSON.stringify(n))}function Ms(e){return JSON.parse(Qn.decode(e))}function ed(e){return JSON.parse(typeof e=="string"?rs(e):Qn.decode(e))}function td(e){return JSON.parse(typeof e=="string"?rs(e):Qn.decode(e))}const ar=256*20;function Na(e,n){const t=new ot(e),r=t.getLength(),s=[];let o=0;for(;o<r;){const i=Math.min(o+ar,r-1),a=t.getSlice(o,Math.min(o+ar,r-1),0,n),l=nd(a);s.push({id:x.generateRandomId(19,"0123456789"),startRow:o,endRow:i,data:l}),o+=ar}return s}function nd(e){const n=e.getData();return fn.encode(JSON.stringify(n))}async function rd(e,n,t,r,s){const o={},i={};if(!await Promise.all(Object.entries(n.sheets).map(async([u,d])=>{const f={id:d.id,type:Hn.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:Oa(d)};if(i[u]=f,d.cellData){const p=Na(d.cellData,d.rowCount),m=await Promise.all(p.map(S=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:S})));if(m.some(S=>{var y;return((y=S.error)==null?void 0:y.code)!==Ze.OK}))return!1;o[u]={sheetID:u,blocks:m.map(S=>S.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Sa(n),h={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:i,blockMeta:o,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:t,rev:h.rev,type:J.UNIVER_SHEET,workbook:h,doc:void 0}}}async function sd(e,n,t,r,s){var d,f;const o={},i={};if(!await Promise.all(Object.entries(n.sheets).map(async([p,m])=>{const S={id:m.id,type:Hn.GRID,name:m.name,rowCount:m.rowCount,columnCount:m.columnCount,originalMeta:Oa(m)};if(i[p]=S,m.cellData){const y=Na(m.cellData,m.rowCount),ee=await Promise.all(y.map(ge=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:ge})));if(ee.some(ge=>{var ce;return((ce=ge.error)==null?void 0:ce.code)!==Ze.OK}))return!1;o[p]={sheetID:p,blocks:ee.map(ge=>ge.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Sa(n),h={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:i,blockMeta:o,resources:n.resources||[],originalMeta:l},c={unitID:t,rev:h.rev,type:J.UNIVER_SHEET,workbook:h,doc:void 0},u=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_SHEET,snapshot:c});if(Ci(u.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
10
- ErrorCode: ${(d=u.error)==null?void 0:d.code}:${(f=u.error)==null?void 0:f.message}`);return{snapshot:c}}function od(e,n,t){const r=e.workbook;if(!r)throw new Error("");const s={};Object.entries(r.sheets).forEach(([l,h])=>{const c=Ms(h.originalMeta);s[l]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...c}});const o=new Map;n.forEach(l=>{o.set(l.id,l)}),r.blockMeta&&Object.entries(r.blockMeta).forEach(([l,h])=>{var d;const c=s[l];c.cellData={};const u=[];(d=h.blocks)==null||d.forEach(f=>{const p=o.get(f);if(p)u.push(p);else throw new Error("")}),u.forEach(f=>{const p=ed(f.data);Object.entries(p).forEach(([m,S])=>{const y=c.cellData[+m]={};Object.entries(S).forEach(([ee,ge])=>{y[+ee]=ge})})})});const i=Ms(r.originalMeta);return{id:e.unitID,rev:r.rev,name:r.name,sheetOrder:r.sheetOrder,appVersion:"",locale:Pt.EN_US,sheets:s,styles:{},resources:r.resources||[],...i}}function id(e){const n=e.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:t,rev:r,name:s,originalMeta:o,resources:i=[]}=n,{body:a,documentStyle:l={},settings:h={},drawings:c={},drawingsOrder:u=[]}=td(o);return{id:t,rev:r,locale:Pt.EN_US,title:s,body:a,documentStyle:l,settings:h,drawings:c,drawingsOrder:u,resources:i}}async function ad(e,n,t,r,s){var l,h,c;const o={unitID:n.id,rev:r,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:Jh(n)},i={unitID:t,rev:o.rev,type:J.UNIVER_DOC,workbook:void 0,doc:o},a=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_DOC,snapshot:i});if(Ci(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
11
- ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(c=a.error)==null?void 0:c.message}`);return{snapshot:i}}async function ld(e,n){const t=e.workbook;if(!t)throw new Error("Workbook metadata is not available");const r=[],s=[];return Object.entries(t.blockMeta).forEach(([o,i])=>{const a=i.blocks.map(async l=>{const h={unitID:t.unitID,type:J.UNIVER_SHEET,blockID:l},{block:c}=await n.getSheetBlock({},h);if(c)r.push(c);else throw new Error("Block not found")});s.push(...a)}),await Promise.all(s),r}var wa=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(wa||{}),Aa=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Aa||{}),ba=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(ba||{}),Ta=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e))(Ta||{}),ya=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(ya||{});const ud=["script","style","meta","comment","link"];function cd(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}Fa();exports.ABCToNumber=eu;exports.AbsoluteRefType=Se;exports.ActionIterator=wr;exports.AlignTypeH=Ao;exports.AlignTypeV=bo;exports.ArrangeTypeEnum=Do;exports.ArrowsAndMarkersShapes=qs;exports.AutoFillSeries=Fs;exports.BaselineOffset=Gt;exports.BasicShapes=Qs;exports.BlockType=ao;exports.BooleanNumber=K;exports.BorderStyleTypes=he;exports.BorderType=Hs;exports.BulletAlignment=Rt;exports.COLORS=lr;exports.CellValueType=Mt;exports.ClientSnapshotServerService=qh;exports.Color=Ut;exports.ColorBuilder=jn;exports.ColorKit=rt;exports.ColorType=qe;exports.ColumnSeparatorType=ho;exports.CommandType=hn;exports.CommonHideTypes=$s;exports.ConfigService=Bi;exports.ContentAlignment=vo;exports.ContextService=_i;exports.CopyPasteType=js;exports.CustomDecorationType=io;exports.CustomRangeType=oo;exports.DEFAULT_CELL=hu;exports.DEFAULT_DOC=qr;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=$a;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=ph;exports.DEFAULT_RANGE=uu;exports.DEFAULT_RANGE_ARRAY=lu;exports.DEFAULT_SELECTION=cu;exports.DEFAULT_SLIDE=zo;exports.DEFAULT_STYLES=vn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Yi;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Wc;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=qi;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=Kc;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Xi;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Gc;exports.DEFAULT_WORKSHEET_ROW_COUNT=Ki;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=jc;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=zi;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Bc;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Qi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Vc;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ua;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=la;exports.DashStyleType=Ro;exports.DataStreamTreeNodeType=vi;exports.DataStreamTreeTokenType=gt;exports.DataValidationErrorStyle=wa;exports.DataValidationImeMode=Aa;exports.DataValidationOperator=ba;exports.DataValidationRenderMode=Ca;exports.DataValidationStatus=ya;exports.DataValidationType=Ta;exports.DependentOn=bh;exports.DesktopLogService=pi;exports.DeveloperMetadataVisibility=Ws;exports.Dimension=Bs;exports.Direction=Gs;exports.Disposable=be;exports.DisposableCollection=Mr;exports.DocStyleType=ro;exports.DocumentDataModel=xt;exports.DocumentFlavor=lo;exports.DrawingTypeEnum=Mo;exports.EDITOR_ACTIVATED=ea;exports.EXTENSION_NAMES=Xo;exports.Entry=ur;exports.EntryIterator=Go;exports.ErrorService=Gi;exports.EventState=Ia;exports.EventSubject=Kh;exports.FOCUSING_COMMON_DRAWINGS=ih;exports.FOCUSING_DOC=wn;exports.FOCUSING_EDITOR_BUT_HIDDEN=th;exports.FOCUSING_EDITOR_INPUT_FORMULA=nh;exports.FOCUSING_EDITOR_STANDALONE=sh;exports.FOCUSING_FORMULA_EDITOR=ta;exports.FOCUSING_SHEET=tn;exports.FOCUSING_SLIDE=An;exports.FOCUSING_UNIVER_EDITOR=rh;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=oh;exports.FollowNumberWithType=so;exports.FontItalic=Tn;exports.FontStyleType=Oo;exports.FontWeight=yn;exports.FormatType=Vs;exports.GlyphType=Jt;exports.GridType=uo;exports.HLSColor=to;exports.HorizontalAlign=Dt;exports.IAuthzIoService=Ea;exports.ICommandService=dn;exports.IConfigService=Wi;exports.IContextService=cn;exports.ILocalStorageService=Yh;exports.ILogService=St;exports.IPermissionService=es;exports.IResourceLoaderService=ts;exports.IResourceManagerService=Yn;exports.ISnapshotServerService=Qh;exports.IUndoRedoService=Xn;exports.IUniverInstanceService=Kt;exports.Inject=it;exports.Injector=pt;exports.InterceptorManager=Xh;exports.InterpolationPointType=Ks;exports.JSON1=Uc;exports.JSONX=Lt;exports.KeyIterator=Wo;exports.LRUHelper=qt;exports.LRUMap=Vo;exports.LifecycleStages=de;exports.LocaleService=nn;exports.LocaleType=Pt;exports.LogLevel=gi;exports.MOVE_BUFFER_VALUE=Qt;exports.Many=ti;exports.MemoryCursor=Hi;exports.NamedStyleType=mo;exports.NilCommand=mi;exports.NumberUnitType=wo;exports.ObjectMatrix=ot;exports.ObjectRelativeFromH=So;exports.ObjectRelativeFromV=No;exports.OnLifecycle=na;exports.Optional=ni;exports.OtherShapes=Zs;exports.PRESET_LIST_TYPE=dc;exports.PageElementType=Uo;exports.PageOrientType=yo;exports.PageType=yr;exports.ParagraphElementType=_o;exports.PermissionService=ia;exports.PermissionStatus=Jr;exports.Plugin=br;exports.PositionedObjectLayoutType=po;exports.PresetListType=Pn;exports.ProtectionType=Ys;exports.RANGE_TYPE=oe;exports.RCDisposable=Bl;exports.RGBA_PAREN=Ka;exports.RGB_PAREN=Va;exports.ROTATE_BUFFER_VALUE=xs;exports.Range=Vt;exports.Rectangle=vt;exports.RediConsumer=ui;exports.RediContext=un;exports.RediError=Le;exports.RediProvider=Fr;exports.RedoCommand=_a;exports.RedoCommandId=ha;exports.RefAlias=Jl;exports.Registry=$r;exports.RegistryAsMap=jr;exports.RelativeDate=zs;exports.RelativeSlideLink=Lo;exports.ResourceManagerService=aa;exports.RgbColor=Dn;exports.RxDisposable=Wl;exports.SectionType=co;exports.Self=ii;exports.SheetTypes=Hn;exports.SheetViewModel=Ji;exports.SkipSelf=oi;exports.SliceBodyType=Gr;exports.SlideDataModel=Zr;exports.SpacingRule=Eo;exports.SpecialShapes=Js;exports.Styles=Vi;exports.THEME_COLORS=eo;exports.TabStopAlignment=Co;exports.TextDecoration=Xs;exports.TextDirection=on;exports.TextDirectionType=fo;exports.TextX=Ot;exports.TextXActionType=Z;exports.ThemeColor=Mn;exports.ThemeColorType=He;exports.ThemeColors=$n;exports.ThemeService=ns;exports.Tools=x;exports.UndoCommand=fa;exports.UndoCommandId=da;exports.UnitModel=Vn;exports.Univer=xh;exports.UniverInstanceType=J;exports.UpdateDocsAttributeType=ke;exports.ValueIterator=Bo;exports.VerticalAlign=Wt;exports.WidthType=Io;exports.WithDependency=Ju;exports.WithNew=ai;exports.Worksheet=ln;exports.WrapStrategy=Bt;exports.WrapTextType=go;exports.afterInitApply=hc;exports.b64DecodeUnicode=rs;exports.b64EncodeUnicode=Zh;exports.binarySearchArray=Ps;exports.cellToRange=Ul;exports.characterSpacingControlType=To;exports.checkForSubstrings=Ll;exports.checkIfMove=ja;exports.checkParagraphHasBullet=xl;exports.checkParagraphHasIndent=Pl;exports.checkParagraphHasIndentByStyle=Fo;exports.codeToBlob=Ba;exports.composeBody=Or;exports.composeInterceptors=va;exports.concatMatrixArray=Xl;exports.connectDependencies=Qu;exports.connectInjector=Xu;exports.convertBodyToHtml=au;exports.covertTextRunToHtml=_r;exports.createDefaultUser=Fn;exports.createIdentifier=Ve;exports.createInterceptorKey=zh;exports.createInternalEditorID=mh;exports.createRowColIter=fr;exports.debounce=iu;exports.dedupe=Gl;exports.deepCompare=Dr;exports.deleteContent=$o;exports.extractPureTextFromCell=Yc;exports.forwardRef=Nu;exports.fromCallback=Ei;exports.fromObservable=jl;exports.generateRandomId=xo;exports.generateTemporarySnap=rd;exports.getArrayLength=It;exports.getBodySlice=an;exports.getBodySliceHtml=In;exports.getBorderStyleType=yl;exports.getCellInfoInMergeData=hl;exports.getCellValueType=al;exports.getColorStyle=ut;exports.getCustomDecorationSlice=ki;exports.getCustomRangeSlice=Pi;exports.getDocsUpdateBody=Dl;exports.getReverseDirection=Ga;exports.getSheetBlocksFromSnapshot=ld;exports.getWorksheetUID=eh;exports.groupBy=Yl;exports.handleStyleToString=Tl;exports.hashAlgorithm=Fl;exports.horizontalLineSegmentsSubtraction=Wn;exports.insertMatrixArray=cr;exports.insertTextToContent=Ho;exports.isAsyncDependencyItem=Er;exports.isAsyncHook=On;exports.isBlackColor=sl;exports.isBooleanString=jh;exports.isCellCoverable=wl;exports.isCellV=ul;exports.isClassDependencyItem=gr;exports.isCtor=Lr;exports.isDisposable=Cr;exports.isEmptyCell=Po;exports.isFactoryDependencyItem=pr;exports.isFormulaId=bl;exports.isFormulaString=Al;exports.isICellData=il;exports.isInternalEditorID=Eh;exports.isNullCell=ll;exports.isNumeric=Ra;exports.isRangesEqual=kh;exports.isRealNum=kl;exports.isSafeNumeric=$h;exports.isSameStyleTextRun=ko;exports.isUnitRangesEqual=Fh;exports.isValidRange=Ml;exports.isValueDependencyItem=mr;exports.isWhiteColor=ol;exports.makeArray=zl;exports.makeCellRangeToRangeData=Nl;exports.makeCellToSelection=Sl;exports.mergeOverrideWithDependencies=ma;exports.mergeSets=Wh;exports.mergeWorksheetSnapshotWithDefault=Zi;exports.moveMatrixArray=dr;exports.moveRangeByOffset=pu;exports.nameCharacterCheck=cd;exports.normalizeBody=Sc;exports.normalizeTextRuns=Wr;exports.numberToABC=nu;exports.numberToListABC=ru;exports.orderSearchArray=ks;exports.queryObjectMatrix=gu;exports.remove=Bn;exports.repeatStringNumTimes=Yo;exports.replaceInDocumentBody=Vh;exports.requestImmediateMacroTask=Gh;exports.rotate=Kl;exports.runOnLifecycle=Kn;exports.searchArray=Wa;exports.selectionToArray=cl;exports.sequence=fi;exports.sequenceAsync=di;exports.sequenceExecute=Hr;exports.sequenceExecuteAsync=cc;exports.setDependencies=Wu;exports.shallowEqual=Hh;exports.skipParseTagNames=ud;exports.sliceMatrixArray=Ql;exports.sortRules=su;exports.sortRulesByDesc=ou;exports.sortRulesFactory=kt;exports.spliceArray=hr;exports.takeAfter=Ri;exports.textDecoder=Qn;exports.textEncoder=fn;exports.throttle=Bh;exports.toDisposable=Ne;exports.transformDocumentDataToSnapshot=ad;exports.transformSnapshotToDocumentData=id;exports.transformSnapshotToWorkbookData=od;exports.transformWorkbookDataToSnapshot=sd;exports.updateAttributeByDelete=$i;exports.updateAttributeByInsert=ji;exports.useDependency=Yu;exports.useDependencyContext=rc;exports.useDependencyContextValue=sc;exports.useDependencyValue=hi;exports.useInjector=ci;exports.useObservable=tc;exports.useUpdateBinder=nc;
6
+ For more info please visit our website: https://redi.wendell.fun/en-US/docs/debug#import-scripts-of-redi-more-than-once`):Es[Rs]=!0;var Cs="REDI_CONTEXT_LOCK",Vu=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,Is=typeof globalThis<"u"&&globalThis||typeof window<"u"&&window||typeof global<"u"&&global;Is[Cs]?Vu||console.error(`[redi]: "RediContext" is already created. You may import "RediContext" from different paths. Use "import { RediContext } from '@wendellhu/redi/react-bindings'; instead."`):Is[Cs]=!0;var un=st.createContext({injector:null});un.displayName="RediContext";var Fr=un.Provider,hi=un.Consumer,Ku=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),zu=function(e){Ku(n,e);function n(){return e.call(this,"Using dependency injection outside of a RediContext.")||this}return n}(Le);function di(){var e=st.useContext(un);if(!e.injector)throw new zu;return e.injector}function Yu(e,n,t){var r=di();return st.useMemo(function(){return r.get(e,n,t)},[e,n,t])}var xn=function(){return xn=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},xn.apply(this,arguments)};function Xu(e){var n=e.children,t=e.dependencies,r=st.useRef(null);return st.useEffect(function(){return function(){var s;return(s=r.current)===null||s===void 0?void 0:s.dispose()}},[]),st.createElement(hi,null,function(s){var o;return r.current?o=r.current:(o=s.injector?s.injector.createChild(t):new pt(t),r.current=o),st.createElement(Fr,{value:{injector:o}},n)})}function Qu(e,n){return function(r){return st.createElement(Fr,{value:{injector:n}},st.createElement(e,xn({},r)))}}function qu(e,n){return function(r){return st.createElement(Xu,{dependencies:n},st.createElement(e,xn({},r)))}}var Zu=function(){var e=function(n,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},e(n,t)};return function(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");e(n,t);function r(){this.constructor=n}n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}}(),Ju=function(e){Zu(n,e);function n(t){return e.call(this,'You should make "RediContext" as '.concat(t.constructor.name,"'s default context type. ")+"If you want to use multiple context, please check this on React doc site. https://reactjs.org/docs/context.html#classcontexttype")||this}return n}(Le);function ec(e,n,t){return function(){return{get:function(){var r=this,s=r.context;if(!s||!s.injector)throw new Ju(r);var o=s.injector,i=o.get(e,n||exports.Quantity.REQUIRED,t);return i}}}}var tc=function(e,n,t){if(t||arguments.length===2)for(var r=0,s=n.length,o;r<s;r++)(o||!(r in n))&&(o||(o=Array.prototype.slice.call(n,0,r)),o[r]=n[r]);return e.concat(o||Array.prototype.slice.call(n))};function fi(e,n){var t=e instanceof Y.BehaviorSubject&&typeof n>"u"?e.getValue():n,r=Pe.useState(t),s=r[0],o=r[1];return Pe.useEffect(function(){var i=e.subscribe(function(a){return o(a)});return function(){return i.unsubscribe()}},[e]),s}function vs(e){return typeof e=="function"?e():e}function nc(e,n,t,r){if(typeof e=="function"&&!r)throw new Le("Expected deps to be provided when observable is a function!");var s=Pe.useRef(null),o=Pe.useRef(!1),i=Pe.useMemo(function(){return e},tc([],typeof r<"u"?r:[e],!0)),a=Pe.useState(0);a[0];var l=a[1],h=Pe.useRef(function(){var c;if(i){var u=vs(i).subscribe(function(d){o.current=!0,c=d});u.unsubscribe()}return c!=null?c:n}());if(Pe.useEffect(function(){var c=null;return i&&(s.current=vs(i),c=s.current.subscribe(function(u){h.current=u,l(function(d){return d+1})})),function(){return c==null?void 0:c.unsubscribe()}},[i]),t&&!o.current)throw new Error("Expect `shouldHaveSyncValue` but not getting a sync value!");return h.current}function rc(e){var n=Pe.useState(0),t=n[1];Pe.useEffect(function(){var r=e.subscribe(function(){return t(function(s){return s+1})});return function(){return r.unsubscribe()}},[])}var vr=new WeakMap;function sc(e,n){var t=Pe.useRef(void 0),r=fi(e,n),s=Pe.useMemo(function(){return Pe.createContext(r)},[e]),o=Pe.useCallback(function(i){return Pe.createElement(s.Provider,{value:r},i.children)},[e,r]);return t.current!==e&&(t.current&&vr.delete(t.current),t.current=e,vr.set(e,s)),{Provider:o,value:r}}function oc(e){var n=vr.get(e);if(!n)throw new Le("try to read context value but no ancestor component subscribed it.");return Pe.useContext(n)}async function _i(e){for(const[n,t]of e.entries())try{if(!await t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}function gi(e){for(const[n,t]of e.entries())try{if(!t())return{index:n,result:!1}}catch(r){return{index:n,result:!1,error:r}}return{result:!0,index:-1}}const cn=Ve("univer.context-service");class pi extends Ae{constructor(){super(...arguments);_(this,"_contextChanged$",new Y.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(t){var r;return(r=this._contextMap.get(t))!=null?r:!1}setContextValue(t,r){this._contextMap.set(t,r),this._contextChanged$.next({[t]:r})}subscribeContextValue$(t){return new Y.Observable(r=>{const s=this._contextChanged$.pipe(Y.filter(o=>typeof o[t]<"u")).subscribe(o=>r.next(o[t]));return this._contextMap.has(t)&&r.next(this._contextMap.get(t)),()=>s.unsubscribe()})}}var mi=(e=>(e[e.SILENT=0]="SILENT",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.VERBOSE=4]="VERBOSE",e))(mi||{});const St=Ve("univer.log");class Ei extends Ae{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...t){this._logLevel>=4&&this._log(console.debug,...t)}log(...t){this._logLevel>=3&&this._log(console.log,...t)}warn(...t){this._logLevel>=2&&this._log(console.warn,...t)}error(...t){this._logLevel>=1&&this._log(console.error,...t)}setLogLevel(t){this._logLevel=t}_log(t,...r){const s=r[0];/^\[(.*?)\]/g.test(s)?t(`\x1B[97;104m${s}\x1B[0m`,...r.slice(1)):t(...r)}}var ic=Object.defineProperty,ac=Object.getOwnPropertyDescriptor,lc=(e,n,t,r)=>{for(var s=r>1?void 0:r?ac(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&ic(n,t,s),s},Os=(e,n)=>(t,r)=>n(t,r,e),hn=(e=>(e[e.COMMAND=0]="COMMAND",e[e.OPERATION=1]="OPERATION",e[e.MUTATION=2]="MUTATION",e))(hn||{});const dn=Ve("anywhere.command-service");class uc{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),Ne(()=>{var t;this._commands.delete(n.id),this._commandTypes.delete(n.id),(t=n.onDispose)==null||t.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 Ri={id:"nil",type:0,handler:()=>!0};exports.CommandService=class extends Ae{constructor(t,r){super();_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=t,this._logService=r,this._commandRegistry=new uc,this._registerCommand(Ri)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(t){return this._commandRegistry.hasCommand(t)}registerCommand(t){return this._registerCommand(t)}registerMultipleCommand(t){return this._registerMultiCommand(t)}beforeCommandExecuted(t){if(this._beforeCommandExecutionListeners.indexOf(t)===-1)return this._beforeCommandExecutionListeners.push(t),Ne(()=>{const r=this._beforeCommandExecutionListeners.indexOf(t);this._beforeCommandExecutionListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(t){if(this._commandExecutedListeners.indexOf(t)===-1)return this._commandExecutedListeners.push(t),Ne(()=>{const r=this._commandExecutedListeners.indexOf(t);this._commandExecutedListeners.splice(r,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(t,r,s){try{const o=this._commandRegistry.getCommand(t);if(o){const[i]=o,a={id:i.id,type:i.type,params:r},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(c=>c(a,s));const h=await this._execute(i,r,s);return this._commandExecutedListeners.forEach(c=>c(a,s)),l.dispose(),h}throw new Error(`[CommandService]: command "${t}" is not registered.`)}catch(o){throw this._logService.error(o),o}}syncExecuteCommand(t,r,s){var i;const o=this._commandRegistry.getCommand(t);if(o){const[a]=o,l={id:a.id,type:a.type,params:r};if(a.type===2){const u=Kl(this._commandExecutionStack,d=>d.type===0);u&&(l.params=(i=l.params)!=null?i:{},l.params.trigger=u.id)}const h=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(u=>u(l,s));const c=this._syncExecute(a,r,s);return this._commandExecutedListeners.forEach(u=>u(l,s)),h.dispose(),c}throw new Error(`[CommandService]: command "${t}" is not registered.`)}_pushCommandExecutionStack(t){return this._commandExecutionStack.push(t),Ne(()=>Bn(this._commandExecutionStack,t))}_registerCommand(t){return this._commandRegistry.registerCommand(t)}_registerMultiCommand(t){const r=this._commandRegistry.getCommand(t.id);let s;if(r){if(r[0].multi!==!0)throw new Error("Command has registered as a single command.");s=r[0]}else{const i=new Mr;s=new cc(t.id),i.add(this._commandRegistry.registerCommand(s)),i.add(Ne(()=>{this._multiCommandDisposables.delete(t.id)})),this._multiCommandDisposables.set(t.id,i)}const o=s.registerImplementation(t);return Ne(()=>{var i;o.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(t.id))==null||i.dispose()})}async _execute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${t.id}"`),this._commandExecutingLevel++;let o;try{o=await this._injector.invoke(t.handler,r,s),this._commandExecutingLevel--}catch(i){throw o=!1,this._commandExecutingLevel=0,i}return o}_syncExecute(t,r,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${t.id}".`),this._commandExecutingLevel++;let o;try{if(o=this._injector.invoke(t.handler,r,s),o instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw o=!1,this._commandExecutingLevel=0,i}return o}};exports.CommandService=lc([Os(0,it(pt)),Os(1,St)],exports.CommandService);class cc{constructor(n){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(n,t)=>{if(!this._implementations.length)return!1;const r=n.get(St),s=n.get(cn),o=n.get(pt);for(const i of this._implementations){const a=i.command.preconditions;if((!a||a&&a(s))&&(r.debug("[MultiCommand]",`executing implementation "${i.command.name}".`),await o.invoke(i.command.handler,t)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const t={command:n};return this._implementations.push(t),this._implementations.sort((r,s)=>s.command.priority-r.command.priority),Ne(()=>{var s;const r=this._implementations.indexOf(t);this._implementations.splice(r,1),(s=n.onDispose)==null||s.call(n)})}hasImplementations(){return this._implementations.length>0}}function Hr(e,n,t){const r=e.map(s=>()=>n.syncExecuteCommand(s.id,s.params,t));return gi(r)}function hc(e,n,t){const r=e.map(s=>()=>n.executeCommand(s.id,s.params,t));return _i(r)}function Ci(e){return new Y.Observable(n=>{const t=e((...r)=>n.next(r));return()=>t==null?void 0:t.dispose()})}function Ii(e){return function(t){return new Y.Observable(r=>(t.subscribe({next:s=>{r.next(s),e(s)&&r.complete()},complete:()=>r.complete(),error:s=>r.error(s)}),()=>r.unsubscribe()))}}const dc=e=>new Promise(n=>{Y.merge(Ci(e.onCommandExecuted.bind(e)).pipe(Cn.filter(([t])=>t.type===hn.MUTATION)),Y.timer(300)).pipe(Cn.debounceTime(16),Cn.first()).subscribe(()=>{n()})});var Ze=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.OK=1]="OK",e[e.INTERNAL_ERROR=2]="INTERNAL_ERROR",e[e.PERMISSION_DENIED=3]="PERMISSION_DENIED",e[e.NOT_FOUND=4]="NOT_FOUND",e[e.UNAUTHENTICATED=5]="UNAUTHENTICATED",e[e.ALREADY_EXISTS=6]="ALREADY_EXISTS",e[e.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",e[e.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",e[e.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",e[e.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",e[e.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",e[e.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",e[e.APPLY_REJECT=7001]="APPLY_REJECT",e[e.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",e[e.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",e[e.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",e[e.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",e[e.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",e[e.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",e[e.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",e[e.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",e[e.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",e[e.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",e[e.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Ze||{});function vi(e){return!!(e&&e.code&&e.code!==Ze.OK&&e.code!=="OK")}var J=(e=>(e[e.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",e[e.UNIVER_DOC=1]="UNIVER_DOC",e[e.UNIVER_SHEET=2]="UNIVER_SHEET",e[e.UNIVER_SLIDE=3]="UNIVER_SLIDE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(J||{}),Oi=(e=>(e[e.SomeCollaborator=0]="SomeCollaborator",e[e.AllCollaborator=1]="AllCollaborator",e[e.OneSelf=2]="OneSelf",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Oi||{}),je=(e=>(e[e.Reader=0]="Reader",e[e.Editor=1]="Editor",e[e.Owner=2]="Owner",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(je||{}),Nn=(e=>(e[e.Unkonwn=0]="Unkonwn",e[e.Workbook=1]="Workbook",e[e.Worksheet=2]="Worksheet",e[e.SelectRange=3]="SelectRange",e[e.Document=4]="Document",e[e.Slide=5]="Slide",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(Nn||{});class Vn extends Ae{}class jr{constructor(){_(this,"_data",[])}static create(){return new jr}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const t=this._data.indexOf(n);this._data.splice(t,1)}getData(){return this._data}}class $r{constructor(){_(this,"_data",new Map)}static create(){return new $r}add(n,t){this._data.has(n)||this._data.set(n,t)}delete(n){this._data.delete(n)}getData(){return this._data}}var Si=(e=>(e[e.PARAGRAPH=0]="PARAGRAPH",e[e.SECTION_BREAK=1]="SECTION_BREAK",e[e.TABLE=2]="TABLE",e[e.TABLE_ROW=3]="TABLE_ROW",e[e.TABLE_CELL=4]="TABLE_CELL",e[e.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",e))(Si||{}),gt=(e=>(e.PARAGRAPH="\r",e.SECTION_BREAK=`
7
+ `,e.TABLE_START="",e.TABLE_ROW_START="\x1B",e.TABLE_CELL_START="",e.TABLE_CELL_END="",e.TABLE_ROW_END="",e.TABLE_END="",e.CUSTOM_RANGE_START="",e.CUSTOM_RANGE_END="",e.COLUMN_BREAK="\v",e.PAGE_BREAK="\f",e.DOCS_END="\0",e.TAB=" ",e.CUSTOM_BLOCK="\b",e.LETTER="",e.SPACE=" ",e))(gt||{}),Pn=(e=>(e.BULLET_LIST="BULLET_LIST",e.ORDER_LIST="ORDER_LIST",e))(Pn||{});const fc={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:Rt.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:Rt.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:Jt.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function Wr(e){const n=[];for(const t of e){const{ed:r,ts:s}=t;if(t.sId===void 0&&delete t.sId,x.isEmptyObject(s)&&t.sId==null)continue;if(n.length===0){n.push(t);continue}const o=n.pop();Ho(t,o)&&x.hasIntersectionBetweenTwoRanges(o.st,o.ed,t.st,t.ed)?n.push({...t,st:o.st,ed:r}):n.push(o,t)}return n}function Ni(e,n,t,r){var h;const{textRuns:s}=e;if(s==null)return;const o=[],i=s.length;let a=!1;const l=(h=n.textRuns)!=null?h:[];if(l.length)for(const c of l)c.st+=r,c.ed+=r;for(let c=0;c<i;c++){const u=s[c],d=s[c+1],{st:f,ed:p}=u;if(p<r)o.push(u);else if(r>=f&&r<=p){if(d&&d.st===d.ed&&r===d.st){o.push(u);continue}if(a)u.st+=t,u.ed+=t,o.push(u);else{a=!0,u.ed+=t;const m=[];if(l.length){const S={...u,st:f,ed:l[0].st};S.ed>S.st&&m.push(S),m.push(...l);const y=l[l.length-1],ee={...u,st:y.ed,ed:p+t};ee.ed>ee.st&&m.push(ee)}else m.push(u);o.push(...m)}}else u.st+=t,u.ed+=t,a||(a=!0,o.push(...l)),o.push(u)}a||(a=!0,o.push(...l)),e.textRuns=Wr(o)}function Br(e,n,t,r){const{paragraphs:s}=e;if(s==null)return;const{paragraphs:o,dataStream:i}=n,a=[];let l=-1;for(let c=0,u=s.length;c<u;c++){const d=s[c],{startIndex:f}=d;f>=r&&(d.startIndex+=t),l===-1&&f>=r&&(l=c),a.push(d.startIndex)}let h=-1;if(o){for(let c=0,u=o.length;c<u;c++){const d=o[c];d.startIndex+=r;const f=d.startIndex;h=a.indexOf(f)}if(i===gt.PARAGRAPH&&o.length===1){const c=s[l],u=o[0],d=c.paragraphStyle,f=c.bullet;c.paragraphStyle=u.paragraphStyle,c.bullet=u.bullet,u.paragraphStyle=d,u.bullet=f}h!==-1&&s.splice(h,1),s.push(...o),s.sort(kt("startIndex"))}}function _c(e,n,t,r){const{sectionBreaks:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h}=l;h>=r&&(l.startIndex+=t)}const o=n.sectionBreaks;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function wi(e,n,t,r){const{customBlocks:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h}=l;h>=r&&(l.startIndex+=t)}const o=n.customBlocks;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function bi(e,n,t,r){const{tables:s}=e;if(s==null)return;for(let i=0,a=s.length;i<a;i++){const l=s[i],{startIndex:h,endIndex:c}=l;h>r?(l.startIndex+=t,l.endIndex+=t):c>=r-1&&(l.endIndex+=t)}const o=n.tables;if(o){for(let i=0,a=o.length;i<a;i++){const l=o[i];l.startIndex+=r,l.endIndex+=r}s.push(...o),s.sort(kt("startIndex"))}}function Ai(e,n,t,r){e.customRanges||(e.customRanges=[]);const{customRanges:s}=e,o={};for(let l=0,h=s.length;l<h;l++){const c=s[l];o[c.rangeId]=c;const{startIndex:u,endIndex:d}=c;u>=r?(c.startIndex+=t,c.endIndex+=t):d>r-1&&(c.endIndex+=t)}if(s.find(l=>l.startIndex>r&&l.endIndex<r))return;const a=[];if(n.customRanges){for(let l=0,h=n.customRanges.length;l<h;l++){const c=n.customRanges[l],u=o[c.rangeId];if(c.startIndex+=r,c.endIndex+=r,u){if(u.startIndex<=c.startIndex&&u.endIndex>=c.endIndex||e.dataStream[u.startIndex]===gt.CUSTOM_RANGE_START&&e.dataStream[u.endIndex]===gt.CUSTOM_RANGE_END)continue;if(e.dataStream[u.startIndex]===gt.CUSTOM_RANGE_START){u.endIndex=c.endIndex;continue}if(e.dataStream[u.endIndex]===gt.CUSTOM_RANGE_END){u.startIndex=c.startIndex;continue}}a.push(c)}s.push(...a),s.sort(kt("startIndex"))}}function gc(e){e.sort((r,s)=>r.startIndex-s.startIndex);const n=[];let t=e[0];for(let r=1;r<e.length;r++)t.endIndex+1>=e[r].startIndex?t.endIndex=Math.max(t.endIndex,e[r].endIndex):(n.push(t),t=e[r]);return n.push(t),n}function pc(e){const n={};for(let t=0,r=e.length;t<r;t++){const s=e[t],o=n[s.id];n[s.id]=[...o!=null?o:[],s]}return Object.keys(n).forEach(t=>{const r=n[t],s=gc(r);n[t]=s}),Object.values(n).flat()}function Ti(e,n,t,r){e.customDecorations||(e.customDecorations=[]);const{customDecorations:s}=e;if(t>0)for(let o=0,i=s.length;o<i;o++){const a=s[o],{startIndex:l,endIndex:h}=a;l>=r?(a.startIndex+=t,a.endIndex+=t):h>r-1&&(a.endIndex+=t)}if(n.customDecorations){const o=[];for(let i=0,a=n.customDecorations.length;i<a;i++){const l=n.customDecorations[i];o.push(l),l.startIndex+=r,l.endIndex+=r}s.push(...o),e.customDecorations=pc(s),e.customDecorations.sort(kt("startIndex"))}}function yi(e,n,t){var a;const{textRuns:r}=e,s=t,o=t+n,i=[];if(s===o&&(r!=null&&r.find(l=>l.st===t&&l.ed===t))){const l=r.find(h=>h.st===t&&h.ed===t);return i.push({...l,st:l.st-t,ed:l.ed-t}),e.textRuns=(a=e.textRuns)==null?void 0:a.filter(h=>h!==l),i}if(r){const l=[];for(let h=0,c=r.length;h<c;h++){const u=r[h],{st:d,ed:f}=u;if(s<=d&&o>=f){i.push({...u,st:d-s,ed:f-s});continue}else d<=s&&f>=o?(i.push({...u,st:s-s,ed:o-s}),u.ed-=n):s>=d&&s<f?(i.push({...u,st:s-s,ed:f-s}),u.ed=s):o>d&&o<=f?(i.push({...u,st:d-s,ed:o-s}),u.st=o-n,u.ed-=n):d>=o&&(u.st-=n,u.ed-=n);l.push(u)}e.textRuns=l}return i.length===0&&i.push({st:0,ed:n,ts:{}}),i}function Di(e,n,t){const{paragraphs:r}=e,s=t,o=t+n,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<o){i.push({...c,startIndex:u-t});continue}else u>=o&&(c.startIndex-=n);a.push(c)}e.paragraphs=a}return i}function Mi(e,n,t){const{sectionBreaks:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<=o){i.push({...c,startIndex:u-t});continue}else u>o&&(c.startIndex-=n);a.push(c)}e.sectionBreaks=a}return i}function Ui(e,n,t){const{customBlocks:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u}=c;if(u>=s&&u<=o){i.push({...c,startIndex:u-t});continue}else u>o&&(c.startIndex-=n);a.push(c)}e.customBlocks=a}return i}function Li(e,n,t){const{tables:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u,endIndex:d}=c;if(s<=u&&o>=d){i.push({...c,startIndex:u-t,endIndex:d-t});continue}else if(u<=s&&d>=o){const f=Wn(u,d,s,o);c.startIndex=f[0],c.endIndex=f[1]}else o<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}e.tables=a}return i}function xi(e,n,t){const{customRanges:r}=e,s=t,o=t+n-1,i=[];if(r){const a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l],{startIndex:u,endIndex:d}=c;if(s<=u&&o>=u){i.push({...c,startIndex:u-t,endIndex:d-t});continue}else if(u<=s&&d>=o){const f=Wn(u,d,s,o);c.startIndex=f[0],c.endIndex=f[1]}else o<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}e.customRanges=a}return i}function Pi(e,n,t,r=!0){const{customDecorations:s}=e,o=t,i=t+n-1,a=[];if(s){const l=[];for(let h=0,c=s.length;h<c;h++){const u=s[h],{startIndex:d,endIndex:f}=u;if(d>=o&&f<=i){a.push(u);continue}else if(Math.max(o,d)<=Math.min(i,f)){const p=Wn(d,f,o,i);u.startIndex=p[0],u.endIndex=p[1]}else i<d&&r&&(u.startIndex-=n,u.endIndex-=n);l.push(u)}e.customDecorations=l}return a}function mc(e,n,t,r,s){const o=Ec(e,n,t,r,s),i=Rc(e,n,t,r,s),a=Cc(e,n,t,r,s),l=Ic(e,n,t,r,s),h=vc(e,n,t,r,s),c=Oc(e,n,t,r,s),u=Sc(e,n,t,r,s);return{dataStream:"",textRuns:o,paragraphs:i,sectionBreaks:a,customBlocks:l,tables:h,customRanges:c,customDecorations:u}}function Ec(e,n,t,r,s){const{textRuns:o}=e,{textRuns:i}=n;if(o==null||i==null)return;const a=yi(e,t,r);if(s!==ke.REPLACE){const l=ki(i,a,s);n.textRuns=l}return Ni(e,n,t,r),a}function ki(e,n,t){if(n.length===0)return e;e=x.deepClone(e),n=x.deepClone(n);const r=[],s=e.length,o=n.length;let i=0,a=0,l=null;function h(){return l?(r.push(l),l=null,!0):!1}for(;i<s&&a<o;){const{st:f,ed:p,ts:m}=e[i],{st:S,ed:y,ts:ee,sId:ge}=n[a];let ce;if(t===ke.COVER?ce={...ee,...m}:ce={...m,...ee},p<S)h()||r.push(e[i]),i++;else if(y<f)h()||r.push(n[a]),a++;else{const E={st:Math.min(f,S),ed:Math.max(f,S),ts:f<S?{...m}:{...ee},sId:f<S?void 0:ge};E.ed>E.st&&r.push(E),r.push({st:Math.max(f,S),ed:Math.min(p,y),ts:ce,sId:ge}),p<y?(i++,n[a].st=p,n[a].st===n[a].ed&&a++):(a++,e[i].st=y,e[i].st===e[i].ed&&i++);const v={st:Math.min(p,y),ed:Math.max(p,y),ts:p<y?{...ee}:{...m},sId:p<y?ge:void 0};l=v.ed>v.st?v:null}}h();const c=r[r.length-1],u=e[s-1],d=n[o-1];return c.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?r.push(u):r.push(d)),Wr(r)}function Rc(e,n,t,r,s){const{paragraphs:o}=e,{paragraphs:i}=n;if(o==null||i==null)return;const a=Di(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c,paragraphStyle:u,bullet:d}=h;let f=[];for(const p of a){const{startIndex:m,paragraphStyle:S,bullet:y}=p;let ee,ge;if(s===ke.COVER?(ee={...S,...u},ge={listId:"",listType:Pn.BULLET_LIST,nestingLevel:0,textStyle:{},...y,...d}):(ee={...u,...S},ge={listId:"",listType:Pn.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...y}),c===m){f.push({startIndex:c,paragraphStyle:ee,bullet:ge});break}}l.push(...f),f=[]}n.paragraphs=l}return Br(e,n,t,r),a}function Cc(e,n,t,r,s){const{sectionBreaks:o}=e,{sectionBreaks:i}=n;if(o==null||i==null)return;const a=Mi(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===ke.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.sectionBreaks=l}return Br(e,n,t,r),a}function Ic(e,n,t,r,s){const{customBlocks:o}=e,{customBlocks:i}=n;if(o==null||i==null)return;const a=Ui(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){s===ke.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.customBlocks=l}return wi(e,n,t,r),a}function vc(e,n,t,r,s){const{tables:o}=e,{tables:i}=n;if(o==null||i==null)return;const a=Li(e,t,r);if(s!==ke.REPLACE){const l=[];for(const h of i){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of a){const{startIndex:p,endIndex:m}=f;if(p>=c&&m<=u){s===ke.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}n.tables=l}return bi(e,n,t,r),a}function Oc(e,n,t,r,s){e.customRanges||(e.customRanges=[]);const{customRanges:o}=e,{customRanges:i}=n;if(o==null||i==null)return;let a=[];return s===ke.REPLACE&&(a=xi(e,t,r)),Ai(e,n,0,r),a}function Sc(e,n,t,r,s){e.customDecorations||(e.customDecorations=[]);let o=[];return s===ke.REPLACE&&(o=Pi(e,t,r,!1)),Ti(e,n,0,r),o}var Gr=(e=>(e[e.copy=0]="copy",e[e.cut=1]="cut",e))(Gr||{});function an(e,n,t,r=!1,s=1){const{dataStream:o,textRuns:i=[],paragraphs:a=[],customBlocks:l=[]}=e,h={dataStream:o.slice(n,t)},c=[];for(const p of i){const m=x.deepClone(p),{st:S,ed:y}=m;x.hasIntersectionBetweenTwoRanges(S,y,n,t)&&(n>=S&&n<=y?c.push({...m,st:n,ed:Math.min(t,y)}):t>=S&&t<=y?c.push({...m,st:Math.max(n,S),ed:t}):c.push(m))}c.length?h.textRuns=c.map(p=>{const{st:m,ed:S}=p;return{...p,st:m-n,ed:S-n}}):r&&(h.textRuns=[{st:0,ed:t-n,ts:{}}]);const u=[];for(const p of a){const{startIndex:m}=p;m>=n&&m<=t&&u.push(x.deepClone(p))}u.length&&(h.paragraphs=u.map(p=>({...p,startIndex:p.startIndex-n}))),s===1&&(h.customDecorations=Hi(e,n,t));const{customRanges:d}=Fi(e,n,t);h.customRanges=d;const f=[];for(const p of l){const{startIndex:m}=p;m>=n&&m<=t&&f.push(x.deepClone(p))}return f.length&&(h.customBlocks=f.map(p=>({...p,startIndex:p.startIndex-n}))),h}function Nc(e){const{dataStream:n,textRuns:t,paragraphs:r,customRanges:s,customDecorations:o}=e;let i=0,a=0;s==null||s.forEach(h=>{h.startIndex<0&&(i=Math.max(i,-h.startIndex)),h.endIndex>n.length-1&&(a=Math.max(a,h.endIndex-n.length+1))});const l=`${gt.CUSTOM_RANGE_START.repeat(i)}${n}${gt.CUSTOM_RANGE_END.repeat(a)}`;return t&&(t[0]&&(t[0].st=t[0].st-i),t[t.length-1]&&(t[t.length-1].ed=t[t.length-1].ed+a)),t==null||t.forEach(h=>{h.st+=i,h.ed+=i}),r==null||r.forEach(h=>{h.startIndex+=i}),s==null||s.forEach(h=>{h.startIndex+=i,h.endIndex+=i}),o==null||o.forEach(h=>{h.startIndex+=i,h.endIndex+=a}),{...e,dataStream:l,textRuns:t,paragraphs:r,customRanges:s,customDecorations:o}}function Fi(e,n,t){const{customRanges:r=[]}=e;let s=0,o=0;const i=r.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,t-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(i.length){i.forEach(a=>{a.startIndex<n&&(s+=1),a.endIndex>t-1&&(o+=1)});for(let a=0;a<s;a++){const l=i[a];l.startIndex=n-s+a}if(o){const a=[...i].sort((l,h)=>h.endIndex-l.endIndex);for(let l=0;l<o;l++){const h=a[l];h.endIndex=t+o-l-1}}}return{customRanges:i.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:s,rightOffset:o}}function Hi(e,n,t){const{customDecorations:r=[]}=e,s=[];return r.forEach(o=>{if(Math.max(o.startIndex,n)<=Math.min(o.endIndex,t-1)){const i=x.deepClone(o);s.push({...i,startIndex:Math.max(i.startIndex-n,0),endIndex:Math.min(i.endIndex,t)-n})}}),s}function Or(e,n,t=ke.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const r={dataStream:e.dataStream},{textRuns:s=[],paragraphs:o=[]}=e,{textRuns:i=[],paragraphs:a=[]}=n,l=ki(i,s,t);l.length&&(r.textRuns=l);const h=[];let c=0,u=0;for(;c<o.length&&u<a.length;){const d=o[c],f=a[u],{startIndex:p}=d,{startIndex:m}=f;p===m?(h.push(x.deepMerge(d,f)),c++,u++):p<m?(h.push(x.deepClone(d)),c++):(h.push(x.deepClone(f)),u++)}return c<o.length&&h.push(...o.slice(c)),u<a.length&&h.push(...a.slice(u)),h.length&&(r.paragraphs=h),r}function wc(e){const{body:n}=e;if(n==null)return!0;const{textRuns:t=[],paragraphs:r=[]}=n;return t.length===0&&r.length===0}function bc(e=x.generateRandomId(6),n=Pt.EN_US,t=""){return{id:e,locale:n,title:t,body:{dataStream:`\r
8
+ `,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 We=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ac(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $e={},ji={},Vr={};Object.defineProperty(Vr,"__esModule",{value:!0});function Tc(e,n){if(Array.isArray(n))return!1;for(let t in e)if(!Kr(e[t],n[t]))return!1;for(let t in n)if(e[t]===void 0)return!1;return!0}function yc(e,n){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Kr(e[t],n[t]))return!1;return!0}function Kr(e,n){return e===n?!0:e===null||n===null||typeof e!="object"||typeof n!="object"?!1:Array.isArray(e)?yc(e,n):Tc(e,n)}Vr.default=Kr;var zr={};Object.defineProperty(zr,"__esModule",{value:!0});function Sr(e){if(e===null)return null;if(Array.isArray(e))return e.map(Sr);if(typeof e=="object"){const n={};for(let t in e)n[t]=Sr(e[t]);return n}else return e}zr.default=Sr;var Yr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function n(c,u){if(!c)throw new Error(u)}const t=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),r=(c,u)=>typeof c==typeof u?c>u:typeof c=="string"&&typeof u=="number";function s(c,u){for(let d in c){const f=d;u.write(f,c[f])}}e.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__proto__";class o{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--,t(this.container[this.idx])&&this.idx--)}getPath(){const u=[];let d=this.container,f=this.parents.length-1,p=this.idx;for(;p>=0;)u.unshift(d[p]),p===0?(p=this.indexes[f*2],d=this.parents[f--]):p-=t(d[p-1])?2:1;return u}}class i extends o{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&&t(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||t(this.container[u])&&u+1>=this.container.length)return!1;t(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,p){this.container=u,this.idx=d,this.parents=f.slice(),this.indexes=p.slice()}clone(){const u=new i;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 p of this)u&&u.descend(p),this.traverse(u,d),u&&u.ascend()}eachPick(u,d){this.traverse(u,(f,p)=>{f.p!=null&&d(f.p,p)})}eachDrop(u,d){this.traverse(u,(f,p)=>{f.d!=null&&d(f.d,p)})}}e.ReadCursor=i;class a extends o{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&&t(this.container[f])&&f++,n(f===this.container.length||!t(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 p=this.container.splice(f,this.container.length-f);this.container.push(p),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(r(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&r(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const p=[d];this.container.splice(f,0,p),this.container=p}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const u=this.idx+1;if(u<this.container.length&&t(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(!e.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=s){if(u===null)return;if(n(Array.isArray(u)),u===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,p=this.parents.length;let m=0;for(let S=0;S<u.length;S++){const y=u[S];typeof y=="string"||typeof y=="number"?(m++,this.descend(y)):Array.isArray(y)?this.mergeTree(y,d):typeof y=="object"&&d(y,this)}for(;m--;)this.ascend();this.lcIdx=this.parents.length===p?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}}e.WriteCursor=a,e.writeCursor=()=>new a,e.readCursor=c=>new i(c);function l(c,u,d){let f,p;p=f=c?c.descendFirst():!1;function m(S){let y;for(;p;){const ee=y=c.getKey();if(S!=null){let ge=!1;if(u&&typeof ee=="number"&&(y=u(ee,c.getComponent()),y<0&&(y=~y,ge=!0)),r(y,S))return null;if(y===S&&!ge)return c}d&&typeof y=="number"&&d(y,c.getComponent()),p=c.nextSibling()}return null}return m.end=()=>{f&&c.ascend()},m}e.advancer=l;function h(c,u,d){let f,p,m,S;for(f=p=c&&c.descendFirst(),m=S=u&&u.descendFirst();f||m;){let y=f?c.getKey():null,ee=m?u.getKey():null;y!==null&&ee!==null&&(r(ee,y)?ee=null:y!==ee&&(y=null)),d(y==null?ee:y,y!=null?c:null,ee!=null?u:null),y!=null&&f&&(f=c.nextSibling()),ee!=null&&m&&(m=u.nextSibling())}p&&c.ascend(),S&&u.ascend()}e.eachChildOf=h})(Yr);var Xr={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.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"}(e.ConflictType||(e.ConflictType={}))})(Xr);var rr={},yt={},Ss;function Qr(){return Ss||(Ss=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.uniToStrPos=yt.strPosToUni=void 0,yt.strPosToUni=(e,n=e.length)=>{let t=0,r=0;for(;r<n;r++){const s=e.charCodeAt(r);s>=55296&&s<=57343&&(t++,r++)}if(r!==n)throw Error("Invalid offset - splits unicode bytes");return r-t},yt.uniToStrPos=(e,n)=>{let t=0;for(;n>0;n--){const r=e.charCodeAt(t);t+=r>=55296&&r<=57343?2:1}return t}),yt}var sr={},Ns;function Nr(){return Ns||(Ns=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;const n=Qr(),t=E=>{if(!Array.isArray(E))throw Error("Op must be an array of components");let v=null;for(let A=0;A<E.length;A++){const X=E[A];switch(typeof X){case"object":if(typeof X.d!="number"&&typeof X.d!="string")throw Error("Delete must be number or string");if(e.dlen(X.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(X.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(X>0))throw Error("Skip components must be >0");if(typeof v=="number")throw Error("Adjacent skip components should be combined");break}v=X}if(typeof v=="number")throw Error("Op has a trailing skip")};function r(E,v){let A=0,X=0;for(let ne=0;ne<E.length;ne++){const Q=E[ne];switch(v(Q,A,X),typeof Q){case"object":A+=e.dlen(Q.d);break;case"string":X+=n.strPosToUni(Q);break;case"number":A+=Q,X+=Q;break}}}e.eachOp=r;function s(E,v){const A=[],X=a(A);return r(E,(ne,Q,Ke)=>{X(v(ne,Q,Ke))}),u(A)}const o=E=>E,i=E=>s(E,o);e.dlen=E=>typeof E=="number"?E:n.strPosToUni(E);const a=E=>v=>{if(!(!v||v.d===0||v.d===""))if(E.length===0)E.push(v);else if(typeof v==typeof E[E.length-1])if(typeof v=="object"){const A=E[E.length-1];A.d=typeof A.d=="string"&&typeof v.d=="string"?A.d+v.d:e.dlen(A.d)+e.dlen(v.d)}else E[E.length-1]+=v;else E.push(v)},l=E=>typeof E=="number"?E:typeof E=="string"?n.strPosToUni(E):typeof E.d=="number"?E.d:n.strPosToUni(E.d);e.uniSlice=(E,v,A)=>{const X=n.uniToStrPos(E,v),ne=A==null?1/0:n.uniToStrPos(E,A);return E.slice(X,ne)};const h=(E,v,A)=>typeof E=="number"?A==null?E-v:Math.min(E,A)-v:e.uniSlice(E,v,A),c=E=>{let v=0,A=0;return{take:(Q,Ke)=>{if(v===E.length)return Q===-1?null:Q;const ve=E[v];let fe;if(typeof ve=="number")return Q===-1||ve-A<=Q?(fe=ve-A,++v,A=0,fe):(A+=Q,Q);if(typeof ve=="string"){if(Q===-1||Ke==="i"||n.strPosToUni(ve.slice(A))<=Q)return fe=ve.slice(A),++v,A=0,fe;{const Ce=A+n.uniToStrPos(ve.slice(A),Q);return fe=ve.slice(A,Ce),A=Ce,fe}}else{if(Q===-1||Ke==="d"||e.dlen(ve.d)-A<=Q)return fe={d:h(ve.d,A)},++v,A=0,fe;{let Ce=h(ve.d,A,A+Q);return A+=Q,{d:Ce}}}},peek:()=>E[v]}},u=E=>(E.length>0&&typeof E[E.length-1]=="number"&&E.pop(),E);function d(E,v,A){if(A!=="left"&&A!=="right")throw Error("side ("+A+") must be 'left' or 'right'");t(E),t(v);const X=[],ne=a(X),{take:Q,peek:Ke}=c(E);for(let fe=0;fe<v.length;fe++){const Ce=v[fe];let Te,ze;switch(typeof Ce){case"number":for(Te=Ce;Te>0;)ze=Q(Te,"i"),ne(ze),typeof ze!="string"&&(Te-=l(ze));break;case"string":A==="left"&&typeof Ke()=="string"&&ne(Q(-1)),ne(n.strPosToUni(Ce));break;case"object":for(Te=e.dlen(Ce.d);Te>0;)switch(ze=Q(Te,"i"),typeof ze){case"number":Te-=ze;break;case"string":ne(ze);break;case"object":Te-=e.dlen(ze.d)}break}}let ve;for(;ve=Q(-1);)ne(ve);return u(X)}function f(E,v){t(E),t(v);const A=[],X=a(A),{take:ne}=c(E);for(let Ke=0;Ke<v.length;Ke++){const ve=v[Ke];let fe,Ce;switch(typeof ve){case"number":for(fe=ve;fe>0;)Ce=ne(fe,"d"),X(Ce),typeof Ce!="object"&&(fe-=l(Ce));break;case"string":X(ve);break;case"object":fe=e.dlen(ve.d);let Te=0;for(;Te<fe;)switch(Ce=ne(fe-Te,"d"),typeof Ce){case"number":X({d:h(ve.d,Te,Te+Ce)}),Te+=Ce;break;case"string":Te+=n.strPosToUni(Ce);break;case"object":X(Ce)}break}}let Q;for(;Q=ne(-1);)X(Q);return u(A)}const p=(E,v)=>{let A=0;for(let X=0;X<v.length&&E>A;X++){const ne=v[X];switch(typeof ne){case"number":{A+=ne;break}case"string":const Q=n.strPosToUni(ne);A+=Q,E+=Q;break;case"object":E-=Math.min(e.dlen(ne.d),E-A);break}}return E},m=(E,v)=>typeof E=="number"?p(E,v):E.map(A=>p(A,v));function S(E,v,A){return s(E,(X,ne)=>typeof X=="object"&&typeof X.d=="number"?{d:A.slice(v,ne,ne+X.d)}:X)}function y(E){return s(E,v=>{switch(typeof v){case"object":if(typeof v.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return v.d;case"string":return{d:v};case"number":return v}})}function ee(E){return s(E,v=>typeof v=="object"&&typeof v.d=="string"?{d:n.strPosToUni(v.d)}:v)}function ge(E){let v=!0;return r(E,A=>{typeof A=="object"&&typeof A.d=="number"&&(v=!1)}),v}function ce(E){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:i,checkOp:t,create(v=""){if(typeof v!="string")throw Error("Initial data must be a string");return E.create(v)},apply(v,A){t(A);const X=E.builder(v);for(let ne=0;ne<A.length;ne++){const Q=A[ne];switch(typeof Q){case"number":X.skip(Q);break;case"string":X.append(Q);break;case"object":X.del(e.dlen(Q.d));break}}return X.build()},transform:d,compose:f,transformPosition:p,transformSelection:m,isInvertible:ge,makeInvertible(v,A){return S(v,A,E)},stripInvertible:ee,invert:y,invertWithDoc(v,A){return y(S(v,A,E))},isNoop:v=>v.length===0}}e.default=ce}(sr)),sr}var Rn={},ws;function Dc(){if(ws)return Rn;ws=1,Object.defineProperty(Rn,"__esModule",{value:!0});const e=Nr(),n=Qr();function t(r,s){return{get:r,getLength(){return r().length},insert(o,i,a){const l=n.strPosToUni(r(),o);return s([l,i],a)},remove(o,i,a){const l=n.strPosToUni(r(),o);return s([l,{d:i}],a)},_onOp(o){e.eachOp(o,(i,a,l)=>{switch(typeof i){case"string":this.onInsert&&this.onInsert(l,i);break;case"object":const h=e.dlen(i.d);this.onRemove&&this.onRemove(l,h)}})},onInsert:null,onRemove:null}}return Rn.default=t,t.provides={text:!0},Rn}var bs;function Mc(){return bs||(bs=1,function(e){var n=We&&We.__createBinding||(Object.create?function(d,f,p,m){m===void 0&&(m=p),Object.defineProperty(d,m,{enumerable:!0,get:function(){return f[p]}})}:function(d,f,p,m){m===void 0&&(m=p),d[m]=f[p]}),t=We&&We.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),r=We&&We.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var p in d)Object.hasOwnProperty.call(d,p)&&n(f,d,p);return t(f,d),f},s=We&&We.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;const o=Qr(),i=r(Nr()),a=s(Dc()),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(p){let m=o.uniToStrPos(d,p);if(m>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,m)),d=d.slice(m)},append(p){f.push(p)},del(p){d=d.slice(o.uniToStrPos(d,p))},build(){return f.join("")+d}}},slice:i.uniSlice},h=i.default(l),c=Object.assign(Object.assign({},h),{api:a.default});e.type=c,e.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],e.remove=(d,f)=>i.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var u=Nr();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return u.default}})}(rr)),rr}(function(e){var n=We&&We.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;const t=n(Vr),r=n(zr),s=Yr,o=Xr;function i(g,R){if(!g)throw new Error(R)}e.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:g=>g,isNoop:g=>g==null,setDebug(g){},registerSubtype:y,checkValidOp:ne,normalize:Q,apply:Ke,transformPosition:ve,compose:fe,tryTransform:Zn,transform:La,makeInvertible:ze,invert:Ce,invertWithDoc:Ua,RM_UNEXPECTED_CONTENT:o.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:o.ConflictType.DROP_COLLISION,BLACKHOLE:o.ConflictType.BLACKHOLE,transformNoConflict:(g,R,N)=>os(()=>!0,g,R,N),typeAllowingConflictsPred:g=>Object.assign(Object.assign({},e.type),{transform:(R,N,M)=>os(g,R,N,M)})};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 i(g!=null),typeof R=="number"?(i(Array.isArray(g),"Invalid key - child is not an array"),(g=g.slice()).splice(R,1)):(i(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"?(i(g!=null,"Container is missing for key"),i(Array.isArray(g),"Cannot use numerical key for object container"),i(g.length>=R,"Cannot insert into out of bounds index"),g.splice(R,0,N)):(i(l(g),"Cannot insert into missing item"),i(g[R]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),g[R]=N),N}e.removeOp=(g,R=!0)=>s.writeCursor().writeAtPath(g,"r",R).get(),e.moveOp=(g,R)=>s.writeCursor().writeMove(g,R).get(),e.insertOp=(g,R)=>s.writeCursor().writeAtPath(g,"i",R).get(),e.replaceOp=(g,R,N)=>s.writeCursor().at(g,M=>{M.write("r",R),M.write("i",N)}).get(),e.editOp=(g,R,N,M=!1)=>s.writeCursor().at(g,w=>v(w,R,N,M)).get();const p=(g,R)=>g!=null&&(typeof R=="number"?Array.isArray(g):typeof g=="object"),m=(g,R)=>p(g,R)?g[R]:void 0,S={};function y(g){let R=g.type?g.type:g;R.name&&(S[R.name]=R),R.uri&&(S[R.uri]=R)}const ee=g=>{const R=S[g];if(R)return R;throw Error("Missing type: "+g)};y(Mc());const ge=(g,R)=>g+R;y({name:"number",apply:ge,compose:ge,invert:g=>-g,transform:g=>g});const ce=g=>g==null?null:g.et?ee(g.et):g.es?S["text-unicode"]:g.ena!=null?S.number:null,E=g=>g.es?g.es:g.ena!=null?g.ena:g.e,v=(g,R,N,M=!1)=>{const[w,D]=typeof R=="string"?[ee(R),R]:[R,R.name];!M&&w.isNoop&&w.isNoop(N)||(D==="number"?g.write("ena",N):D==="text-unicode"?g.write("es",N):(g.write("et",D),g.write("e",N)))};function A(g){i(typeof g=="number"),i(g>=0),i(g===(0|g))}function X(g){typeof g=="number"?A(g):i(typeof g=="string")}function ne(g){if(g===null)return;const R=new Set,N=new Set,M=D=>{let B=!0,$=!1;for(let C in D){const O=D[C];if(B=!1,i(C==="p"||C==="r"||C==="d"||C==="i"||C==="e"||C==="es"||C==="ena"||C==="et","Invalid component item '"+C+"'"),C==="p")A(O),i(!R.has(O)),R.add(O),i(D.r===void 0);else if(C==="d")A(O),i(!N.has(O)),N.add(O),i(D.i===void 0);else if(C==="e"||C==="es"||C==="ena"){i(!$),$=!0;const b=ce(D);i(b,"Missing type in edit"),b.checkValidOp&&b.checkValidOp(E(D))}}i(!B)},w=(D,B,$)=>{if(!Array.isArray(D))throw Error("Op must be null or a list");if(D.length===0)throw Error("Empty descent");B||X(D[0]);let C=1,O=0,b=0;for(let T=0;T<D.length;T++){const W=D[T];if(i(W!=null),Array.isArray(W)){const G=w(W,!1);if(O){const I=typeof b,F=typeof G;I===F?i(b<G,"descent keys are not in order"):i(I==="number"&&F==="string")}b=G,O++,C=3}else typeof W=="object"?(i(C===1,`Prev not scalar - instead ${C}`),M(W),C=2):(i(C!==3),X(W),i(s.isValidPathItem(W),"Invalid path key"),C=1)}return i(O!==1,"Operation makes multiple descents. Remove some []"),i(C===2||C===3),D[0]};w(g,!0),i(R.size===N.size,"Mismatched picks and drops in op");for(let D=0;D<R.size;D++)i(R.has(D)),i(N.has(D))}function Q(g){let R=0,N=[];const M=s.writeCursor();return M.mergeTree(g,(w,D)=>{const B=ce(w);if(B){const C=E(w);v(D,B,B.normalize?B.normalize(C):C)}for(const C of["r","p","i","d"])if(w[C]!==void 0){const O=C==="p"||C==="d"?($=w[C],N[$]==null&&(N[$]=R++),N[$]):w[C];D.write(C,O)}var $}),M.get()}function Ke(g,R){if(ne(R),R===null)return g;const N=[];return function M(w,D){let B=w,$=0,C={root:w},O=0,b=C,T="root";function W(){for(;O<$;O++){let G=D[O];typeof G!="object"&&(i(p(b,T)),b=b[T]=h(b[T]),T=G)}}for(;$<D.length;$++){const G=D[$];if(Array.isArray(G)){const I=M(B,G);I!==B&&I!==void 0&&(W(),B=b[T]=I)}else if(typeof G=="object"){G.d!=null?(W(),B=f(b,T,N[G.d])):G.i!==void 0&&(W(),B=f(b,T,G.i));const I=ce(G);if(I)W(),B=b[T]=I.apply(B,E(G));else if(G.e!==void 0)throw Error("Subtype "+G.et+" undefined")}else B=m(B,G)}return C.root}(g=function M(w,D){const B=[];let $=0;for(;$<D.length;$++){const T=D[$];if(Array.isArray(T))break;typeof T!="object"&&(B.push(w),w=m(w,T))}for(let T=D.length-1;T>=$;T--)w=M(w,D[T]);for(--$;$>=0;$--){const T=D[$];if(typeof T!="object"){const W=B.pop();w=w===m(W,T)?W:w===void 0?d(W,T):(O=T,b=w,(C=h(C=W))[O]=b,C)}else c(T)&&(i(w!==void 0,"Cannot pick up or remove undefined"),T.p!=null&&(N[T.p]=w),w=void 0)}var C,O,b;return w}(g,R),R)}function ve(g,R){g=g.slice(),ne(R);const N=s.readCursor(R);let M,w,D=!1;const B=[];for(let C=0;;C++){const O=g[C],b=N.getComponent();if(b&&(b.r!==void 0?D=!0:b.p!=null&&(D=!1,M=b.p,w=C)),C>=g.length)break;let T=0;const W=s.advancer(N,void 0,(I,F)=>{c(F)&&T++});B.unshift(W);const G=W(O);if(typeof O=="number"&&(g[C]-=T),!G)break}if(B.forEach(C=>C.end()),D)return null;const $=()=>{let C=0;if(M!=null){const O=N.getPath();C=O.length,g=O.concat(g.slice(w))}for(;C<g.length;C++){const O=g[C],b=a(N),T=ce(b);if(T){const I=E(b);T.transformPosition&&(g[C]=T.transformPosition(g[C],I));break}let W=0;const G=s.advancer(N,(I,F)=>u(F)?~(I-W):I-W,(I,F)=>{u(F)&&W++})(O);if(typeof O=="number"&&(g[C]+=W),!G)break}};return M!=null?N.eachDrop(null,C=>{C===M&&$()}):$(),g}function fe(g,R){if(ne(g),ne(R),g==null)return R;if(R==null)return g;let N=0;const M=s.readCursor(g),w=s.readCursor(R),D=s.writeCursor(),B=[],$=[],C=[],O=[],b=[],T=[],W=new Set;M.traverse(null,I=>{I.p!=null&&(C[I.p]=M.clone())}),w.traverse(null,I=>{I.d!=null&&(O[I.d]=w.clone())});const G=s.writeCursor();return function I(F,_e,le,q,me,ct,xe,ye){i(_e||le);const Ee=a(_e),Ye=a(le),Je=!!Ye&&Ye.r!==void 0,Nt=!!Ee&&Ee.i!==void 0,Xe=Ee?Ee.d:null,Be=Ye?Ye.p:null,ht=(ct||Je)&&Be==null;if(Be!=null)q=O[Be],xe=$[Be]=new s.WriteCursor;else if(Ye&&Ye.r!==void 0)q=null;else{const L=a(q);L&&L.d!=null&&(q=null)}const ie=a(q);if(Xe!=null)if(F=C[Xe],ye=B[Xe]=new s.WriteCursor,ht)ct&&!Je&&ye.write("r",!0);else{const L=b[Xe]=N++;xe.write("d",L)}else if(Ee&&Ee.i!==void 0)F=null;else{const L=a(F);L&&L.p!=null&&(F=null)}let P;Nt?(i(me===void 0),P=Ee.i):P=me;const V=(Be==null?!Nt||ct||Je:P===void 0)?null:xe.getComponent();if(Be!=null){if(!(me!==void 0||Nt)){const L=Xe!=null?b[Xe]:N++;T[Be]=L,ye.write("p",L)}}else Je&&(Nt||me!==void 0||(Ye.r,ye.write("r",Ye.r)));const k=ht?null:ce(Ee),U=ce(ie);if((k||U)&&(k&&k.name,U&&U.name),k&&U){i(k===U);const L=E(Ee),z=E(ie),be=k.compose(L,z);v(xe,k,be),W.add(ie)}else k?v(xe,k,E(Ee)):U&&(v(xe,U,E(ie)),W.add(ie));const H=typeof P=="object"&&P!=null;let re=!1,se=0,ae=0,we=0,Oe=0,Re=0;const Ue=s.advancer(q,(L,z)=>u(z)?Oe-L-1:L-Oe,(L,z)=>{u(z)&&Oe++}),te=s.advancer(F,(L,z)=>c(z)?se-L-1:L-se,(L,z)=>{c(z)&&se++});if(s.eachChildOf(_e,le,(L,z,be)=>{let Fe,dt,wt=L,et=L,Yt=L;if(typeof L=="number"){let De=L+we;dt=Ue(De),et=De+Oe;let Ie=L+ae;Fe=te(Ie),u(a(dt))&&(Fe=null),wt=Ie+se,Yt=L+Re,i(wt>=0,"p1PickKey is negative"),i(et>=0,"p2DropKey is negative");const tt=u(a(z)),ft=c(a(be));(tt||ft&&!ht)&&Re--,tt&&ae--,ft&&we--}else Fe=te(L),dt=Ue(L);ye.descend(wt),xe.descend(et);const Ht=H&&!u(a(z))?P[Yt]:void 0,at=I(Fe,z,be,dt,Ht,ht,xe,ye);var lt,j,pe;H&&!ht?Ht!==at&&(re||(P=Array.isArray(P)?P.slice():Object.assign({},P),re=!0),lt=P,pe=at,typeof(j=Yt)=="number"?(i(Array.isArray(lt)),i(j<lt.length)):(i(!Array.isArray(lt)),i(lt[j]!==void 0)),pe===void 0?typeof j=="number"?lt.splice(j,1):delete lt[j]:lt[j]=pe):i(at===void 0),xe.ascend(),ye.ascend()}),te.end(),Ue.end(),V!=null)V.i=P;else if(!ct&&!Je&&Be==null)return P}(M,M.clone(),w,w.clone(),void 0,!1,D,G),D.reset(),D.mergeTree(G.get()),D.reset(),D.get(),B.map(I=>I.get()),$.map(I=>I.get()),M.traverse(D,(I,F)=>{const _e=I.p;if(_e!=null){const le=b[_e];le!=null&&F.write("p",le);const q=B[_e];q&&q.get(),q&&F.mergeTree(q.get())}else I.r!==void 0&&F.write("r",I.r)}),D.reset(),D.get(),w.traverse(D,(I,F)=>{const _e=I.d;if(_e!=null){const q=T[_e];q!=null&&F.write("d",q);const me=$[_e];me&&F.mergeTree(me.get())}else I.i!==void 0&&F.write("i",I.i);const le=ce(I);le&&!W.has(I)&&v(F,le,E(I))}),D.get()}function Ce(g){if(g==null)return null;const R=new s.ReadCursor(g),N=new s.WriteCursor;let M;const w=[],D=[];return function B($,C,O){const b=$.getComponent();let T,W=!1;if(b){b.p!=null&&(C.write("d",b.p),w[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=T=b.i);const I=ce(b);I&&(O===void 0?(M||(M=new Set),M.add(b)):(E(b),O=I.apply(O,E(b)),W=!0))}let G=0;for(const I of $){C.descend(I);const F=typeof I=="number"?I-G:I,_e=m(O,F);u($.getComponent())&&G++;const le=B($,C,_e);if(O!==void 0&&le!==void 0){if(W||(W=!0,O=h(O)),!p(O,F))throw Error("Cannot modify child - invalid operation");O[F]=le}C.ascend()}if(T===void 0)return W?O:void 0;C.write("r",O)}(R,N,void 0),M&&(N.reset(),function B($,C,O){const b=C.getComponent();if(b){const I=b.d;if(I!=null&&($=w[I],O=D[I]=s.writeCursor()),M.has(b)){const F=ce(b);if(!F.invert)throw Error(`Cannot invert subtype ${F.name}`);v(O,F,F.invert(E(b)))}}let T=0,W=0;const G=s.advancer($,(I,F)=>c(F)?T-I-1:I-T,(I,F)=>{c(F)&&T++});for(const I of C)if(typeof I=="number"){const F=I-W,_e=G(F),le=F+T;O.descend(le),B(_e,C,O),u(C.getComponent())&&W++,O.ascend()}else O.descend(I),B(G(I),C,O),O.ascend();G.end()}(R.clone(),R,N),D.length&&(N.reset(),R.traverse(N,(B,$)=>{const C=B.p;if(C!=null){const O=D[C];O&&O.get(),O&&$.mergeTree(O.get())}}))),N.get()}const Te=(g,R)=>g.some(N=>typeof N=="object"&&(Array.isArray(N)?Te(N,R):R(N)));function ze(g,R){if(g==null||!Te(g,C=>{var O;return C.r!==void 0||((O=ce(C))===null||O===void 0?void 0:O.makeInvertible)!=null}))return g;const N=new s.ReadCursor(g),M=new s.WriteCursor;let w=!1;const D=[],B=[],$=(C,O,b)=>{const T=C.getComponent();let W=!1;if(T){T.d!=null&&O.write("d",T.d),T.i!==void 0&&O.write("i",T.i);const I=T.p;if(I!=null&&(D[I]=C.clone(),i(b!==void 0,"Operation picks up at an invalid key"),B[I]=b,O.write("p",T.p)),T.r!==void 0&&b===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const F=ce(T);F&&(F.makeInvertible?w=!0:v(O,F,E(T),!0))}let G=0;for(const I of C){O.descend(I);const F=typeof I=="number"?I-G:I,_e=m(b,F),le=$(C,O,_e);_e!==le&&(W||(W=!0,b=h(b)),le===void 0?(b=d(b,F),typeof I=="number"&&G++):b[F]=le),O.ascend()}return T&&(T.r!==void 0?(O.write("r",r.default(b)),b=void 0):T.p!=null&&(b=void 0)),b};return $(N,M,R),M.get(),w&&(M.reset(),function C(O,b,T,W,G){const I=b.getComponent();if(I){I.i!==void 0?(W=I.i,G=!0):I.d!=null&&(W=B[I.d],O=D[I.d],G=!1,I.d);let q=ce(I);if(q&&q.makeInvertible){const me=E(I);v(T,q,q.makeInvertible(me,W),!0)}}let F=0,_e=0;const le=s.advancer(O,(q,me)=>c(me)?F-q-1:q-F,(q,me)=>{c(me)&&F++});for(const q of b)if(typeof q=="number"){const me=q-_e,ct=le(me),xe=me+F,ye=m(W,G?me:xe);T.descend(q),C(ct,b,T,ye,G),u(b.getComponent())&&_e++,T.ascend()}else{const me=m(W,q);T.descend(q),C(le(q),b,T,me,G),T.ascend()}le.end()}(N.clone(),N,M,R,!1)),M.get()}function Ua(g,R){return Ce(ze(g,R))}const qn=g=>{if(g==null)return null;const R=g.slice();for(let N=0;N<g.length;N++){const M=R[N];Array.isArray(M)&&(R[N]=qn(M))}return R};function Zn(g,R,N){i(N==="left"||N==="right","Direction must be left or right");const M=N==="left"?0:1;if(R==null)return{ok:!0,result:g};ne(g),ne(R);let w=null;const D=[],B=[],$=[],C=[],O=[],b=[],T=[],W=[],G=[],I=[],F=[],_e=[],le=[],q=[],me=[];let ct=0;const xe=s.readCursor(g),ye=s.readCursor(R),Ee=s.writeCursor();if(function ie(P,V=null,k){const U=a(V);U&&(U.r!==void 0?k=V.clone():U.p!=null&&(k=null,b[U.p]=P.clone()));const H=P.getComponent();let re;H&&(re=H.p)!=null&&(O[re]=V?V.clone():null,$[re]=P.clone(),k&&(I[re]=!0,G[re]=k),U&&U.p!=null&&(q[re]=U.p));const se=s.advancer(V);for(const ae of P)ie(P,se(ae),k);se.end()}(ye,xe,null),function ie(P,V,k,U,H){const re=k.getComponent();let se,ae=!1;re&&((se=re.d)!=null?(C[se]=k.clone(),U!=null&&(me[U]==null&&(me[U]=[]),me[U].push(se)),P=O[se]||null,V=$[se]||null,I[se]?(H&&(F[se]=!0),H=G[se]||null):!H||M!==1&&q[se]!=null||w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.moveOp(V.getPath(),k.getPath())}),ae=!0):re.i!==void 0&&(P=V=null,ae=!0,H&&w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.insertOp(k.getPath(),re.i)})));const we=a(P);we&&(we.r!==void 0?H=P.clone():we.p!=null&&(we.p,U=we.p,H=null));const Oe=ce(re);Oe&&H&&w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(H.getPath()),op2:e.editOp(k.getPath(),Oe,E(re),!0)});let Re=0,Ue=0;const te=s.advancer(V,(z,be)=>c(be)?Re-z-1:z-Re,(z,be)=>{c(be)&&Re++}),L=s.advancer(P);for(const z of k)if(typeof z=="number"){const be=z-Ue,Fe=te(be);Ue+=+ie(L(be+Re),Fe,k,U,H)}else{const be=te(z);ie(L(z),be,k,U,H)}return te.end(),L.end(),ae}(xe,ye,ye.clone(),null,null),C.map(ie=>ie&&ie.get()),w)return{ok:!1,conflict:w};F.map(ie=>!!ie);const Ye=[];let Je=null;(function ie(P,V,k,U,H){let re=!1;const se=a(V);if(c(se)){const te=se.p;te!=null?(k=C[te],U=_e[te]=s.writeCursor(),re=!0,H=null):(k=null,H=V.clone())}else u(a(k))&&(k=null);const ae=P.getComponent();if(ae){const te=ae.p;te!=null?(H&&(W[te]=H),Ye[te]=H||M===1&&re?null:U.getComponent(),D[te]=P.clone(),k&&(T[te]=k.clone())):ae.r!==void 0&&(H||U.write("r",!0),(H||re)&&(Je==null&&(Je=new Set),Je.add(ae)))}let we=0,Oe=0;const Re=s.advancer(V,void 0,(te,L)=>{c(L)&&we++}),Ue=s.advancer(k,(te,L)=>u(L)?~(te-Oe):te-Oe,(te,L)=>{u(L)&&Oe++});if(P)for(const te of P)if(typeof te=="string"){const L=Re(te),z=Ue(te);U.descend(te),ie(P,L,z,U,H),U.ascend()}else{const L=Re(te),z=te-we,be=c(a(L))?null:Ue(z),Fe=z+Oe;i(Fe>=0),U.descend(Fe),ie(P,L,be,U,H),U.ascend()}Re.end(),Ue.end()})(xe,ye,ye.clone(),Ee,null),Ee.reset();let Nt=[];if(function ie(P,V,k,U,H,re){i(V);const se=V.getComponent();let ae=a(U),we=!1;const Oe=(j,pe,De)=>j?e.moveOp(j.getPath(),pe.getPath()):e.insertOp(pe.getPath(),De.i);if(u(se)){const j=se.d;j!=null&&(B[j]=V.clone());const pe=j!=null?Ye[j]:null;let De=!1;if(se.i!==void 0||j!=null&&pe){let Ie;ae&&(ae.i!==void 0||(Ie=ae.d)!=null&&!I[Ie])&&(De=Ie!=null?j!=null&&j===q[Ie]:t.default(ae.i,se.i),De||Ie!=null&&M!==1&&q[Ie]!=null||w==null&&(w={type:o.ConflictType.DROP_COLLISION,op1:Oe(j!=null?D[j]:null,V,se),op2:Oe(Ie!=null?$[Ie]:null,U,ae)})),De||(re?w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:Oe(j!=null?D[j]:null,V,se),op2:e.removeOp(re.getPath())}):(j!=null?(Nt[ct]=j,H.write("d",pe.p=ct++)):H.write("i",r.default(se.i)),we=!0))}else if(j!=null&&!pe){const Ie=W[j];Ie&&(re=Ie.clone())}j!=null?(P=D[j],k=b[j],U=T[j]):se.i!==void 0&&(P=k=null,De||(U=null))}else c(a(P))&&(P=k=U=null);const Re=a(P),Ue=a(k);if(c(Ue)){const j=Ue.p;Ue.r!==void 0&&(!Re||Re.r===void 0)||I[j]?(U=null,re=k.clone()):j!=null&&(U=C[j],M!==1&&q[j]!=null||((H=le[j])||(H=le[j]=s.writeCursor()),H.reset(),re=null))}else!u(se)&&u(ae)&&(U=null);ae=U!=null?U.getComponent():null;const te=ce(se);if(te){const j=E(se);if(re)w==null&&(w={type:o.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(V.getPath(),te,j,!0),op2:e.removeOp(re.getPath())});else{const pe=ce(ae);let De;if(pe){if(te!==pe)throw Error("Transforming incompatible types");const Ie=E(ae);De=te.transform(j,Ie,N)}else De=r.default(j);v(H,te,De)}}let L=0,z=0,be=0,Fe=0,dt=0,wt=0,et=P!=null&&P.descendFirst(),Yt=et;const Ht=s.advancer(k,void 0,(j,pe)=>{c(pe)&&be++});let at=U!=null&&U.descendFirst(),lt=at;for(const j of V)if(typeof j=="number"){let pe;const De=u(V.getComponent()),Ie=j-z;{let mt;for(;et&&typeof(mt=P.getKey())=="number";){mt+=L;const nt=P.getComponent(),jt=c(nt);if(mt>Ie||mt===Ie&&(!jt||M===0&&De))break;if(jt){L--;const bt=nt.p;q.includes(bt),nt.d,a(le[nt.d]),c(a(le[nt.d])),(nt.r===void 0||Je&&Je.has(nt))&&(bt==null||!Ye[bt]||M!==1&&q.includes(bt))||dt--}et=P.nextSibling()}pe=et&&mt===Ie?P:null}const tt=Ie-L;let ft=Ht(tt);const Jn=tt-be;let _n=null;{let mt,nt;for(;at&&typeof(mt=U.getKey())=="number";){nt=mt-Fe;const jt=U.getComponent(),bt=u(jt);if(nt>Jn)break;if(nt===Jn){if(!bt){_n=U;break}{if(M===0&&De){_n=U;break}const At=ft&&c(ft.getComponent());if(M===0&&At)break}}if(bt){const At=jt.d;q[At],jt.i===void 0&&(I[At]||q[At]!=null&&M!==1)?(I[At]||q[At]!=null&&M===0)&&(Fe++,wt--):Fe++}at=U.nextSibling()}}const is=Jn+Fe+dt+wt;i(is>=0,"trying to descend to a negative index"),H.descend(is),De&&(pe=ft=_n=null,z++),ie(pe,V,ft,_n,H,re)&&wt++,H.ascend()}else{let pe;for(;et&&(pe=P.getKey(),typeof pe!="string"||!(pe>j||pe===j));)et=P.nextSibling();const De=et&&pe===j?P:null,Ie=Ht(j);let tt;for(;at&&(tt=U.getKey(),typeof tt!="string"||!(tt>j||tt===j));)at=U.nextSibling();const ft=at&&tt===j?U:null;H.descend(j),ie(De,V,Ie,ft,H,re),H.ascend()}return Ht.end(),Yt&&P.ascend(),lt&&U.ascend(),we}(xe,xe.clone(),ye,ye.clone(),Ee,null),w)return{ok:!1,conflict:w};Ee.reset();const Xe=(ie,P,V)=>ie.traverse(P,(k,U)=>{k.d!=null&&V(k.d,ie,U)});(I.length||_e.length)&&(Xe(ye,Ee,(ie,P,V)=>{I[ie]&&!F[ie]&&V.write("r",!0),_e[ie]&&V.mergeTree(_e[ie].get())}),Ee.reset());const Be=[],ht=[];if((le.length||I.length)&&!w){const ie=s.readCursor(qn(Ee.get()));if(Xe(ie,null,(P,V)=>{Be[P]=V.clone()}),le.forEach(P=>{P&&Xe(s.readCursor(P.get()),null,(V,k)=>{Be[V]=k.clone()})}),function P(V,k,U,H,re,se){const ae=a(k);if(ae&&c(ae))if(ae.p!=null){const L=ae.p;Be[L].getPath(),U=Be[L],H=ht[L]=s.writeCursor()}else ae.r!==void 0&&(U=null);else u(a(U))&&(U=null);const we=V.getComponent();if(we){let L;if((L=we.d)!=null){const z=le[L];z&&(z.get(),H.mergeTree(z.get()),U=s.readCursor(z.get()))}}let Oe=0,Re=0;const Ue=s.advancer(k,void 0,(L,z)=>{c(z)&&Oe--}),te=s.advancer(U,(L,z)=>u(z)?-(L-Re)-1:L-Re,(L,z)=>{u(z)&&Re++});for(const L of V)if(typeof L=="number"){const z=Ue(L),be=L+Oe,Fe=te(be),dt=be+Re;H.descend(dt),P(V,z,Fe,H),H.ascend()}else H.descend(L),P(V,Ue(L),te(L),H),H.ascend();Ue.end(),te.end()}(ye,ie,ie.clone(),Ee),Ee.reset(),w)return{ok:!1,conflict:w};if(Ee.get(),ht.length){const P=ht.map(k=>k?k.get():null),V=s.readCursor(qn(Ee.get()));if(Xe(V,Ee,(k,U,H)=>{const re=P[k];re&&(H.mergeTree(re),P[k]=null)}),P.find(k=>k)){const k=s.writeCursor(),U=s.writeCursor();let H=0,re=0;P.forEach(se=>{se!=null&&Xe(s.readCursor(se),null,ae=>{const we=Nt[ae];k.writeMove(D[we].getPath(),B[we].getPath(),H++);const Oe=me[we];Oe&&Oe.forEach(Re=>{I[Re]||M!==1&&q[Re]!=null||U.writeMove($[Re].getPath(),C[Re].getPath(),re++)})})}),w={type:o.ConflictType.BLACKHOLE,op1:k.get(),op2:U.get()}}}}return w?{ok:!1,conflict:w}:{ok:!0,result:Ee.get()}}const ss=g=>{const R=new Error("Transform detected write conflict");throw R.conflict=g,R.type=R.name="writeConflict",R};function La(g,R,N){const M=Zn(g,R,N);if(M.ok)return M.result;ss(M.conflict)}const Ft=g=>{const R=s.writeCursor();return s.readCursor(g).traverse(R,(N,M)=>{(u(N)||ce(N))&&M.write("r",!0)}),R.get()},xa=(g,R)=>{const{type:N,op1:M,op2:w}=g;switch(N){case o.ConflictType.DROP_COLLISION:return R==="left"?[null,Ft(w)]:[Ft(M),null];case o.ConflictType.RM_UNEXPECTED_CONTENT:let D=!1;return s.readCursor(M).traverse(null,B=>{B.r!==void 0&&(D=!0)}),D?[null,Ft(w)]:[Ft(M),null];case o.ConflictType.BLACKHOLE:return[Ft(M),Ft(w)];default:throw Error("Unrecognised conflict: "+N)}};function os(g,R,N,M){let w=null;for(;;){const D=Zn(R,N,M);if(D.ok)return fe(w,D.result);{const{conflict:B}=D;g(B)||ss(B);const[$,C]=xa(B,M);R=fe(Q(R),$),N=fe(Q(N),C),w=fe(w,C)}}}})(ji);(function(e){var n=We&&We.__createBinding||(Object.create?function(o,i,a,l){l===void 0&&(l=a),Object.defineProperty(o,l,{enumerable:!0,get:function(){return i[a]}})}:function(o,i,a,l){l===void 0&&(l=a),o[l]=i[a]}),t=We&&We.__exportStar||function(o,i){for(var a in o)a!=="default"&&!i.hasOwnProperty(a)&&n(i,o,a)};Object.defineProperty(e,"__esModule",{value:!0}),t(ji,e);var r=Yr;Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return r.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return r.WriteCursor}});var s=Xr;Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})})($e);const Uc=Ac($e),Lc=Ha({__proto__:null,default:Uc},[$e]);var Z=(e=>(e.RETAIN="r",e.INSERT="i",e.DELETE="d",e))(Z||{});class wr{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 t=this._actions[this._index];if(t){const r=this._offset,s=t.len;return n>=s-r?(n=s-r,this._index+=1,this._offset=0):this._offset+=n,t.t===Z.DELETE||t.t===Z.RETAIN&&t.body==null?x.deepClone({...t,len:n}):x.deepClone({...t,len:n,body:an(t.body,r,r+n)})}else return{t:Z.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:Z.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,t=this._index,r=this.next(),s=this._actions.slice(this._index);return this._offset=n,this._index=t,[r].concat(s)}}else return[]}}class $i{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function Wi(e,n,t){const{dataStream:r}=e,s=t,o=t+n,i=yi(e,n,t),a=Di(e,n,t),l=Mi(e,n,t),h=Ui(e,n,t),c=Li(e,n,t),u=xi(e,n,t),d=Pi(e,n,t);let f="";return r&&(e.dataStream=Wo(r,s,o),f=r.slice(s,o)),{dataStream:f,textRuns:i,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:c,customRanges:u,customDecorations:d}}function Bi(e,n,t,r){e.dataStream=$o(e.dataStream,r,n.dataStream),Ni(e,n,t,r),Br(e,n,t,r),_c(e,n,t,r),wi(e,n,t,r),bi(e,n,t,r),Ai(e,n,t,r),Ti(e,n,t,r)}function xc(e,n,t,r,s=ke.COVER){return mc(e,n,t,r,s)}function Pc(e,n,t){return n<=0?{dataStream:""}:Wi(e,n,t)}function kc(e,n,t,r){t!==0&&Bi(e,n,t,r)}function Fc(e,n){const t=new $i;return t.reset(),n.forEach(r=>{switch(r=x.deepClone(r),r.t){case Z.RETAIN:{const{coverType:s,body:o,len:i}=r;o!=null&&xc(e,o,i,t.cursor,s),t.moveCursor(i);break}case Z.INSERT:{const{body:s,len:o}=r;kc(e,s,o,t.cursor),t.moveCursor(o);break}case Z.DELETE:{const{len:s}=r;Pc(e,s,t.cursor);break}default:throw new Error(`Unknown action type for action: ${r}.`)}}),e}function As(e){return Object.keys(e).length===1}const sn=class sn{constructor(){_(this,"_actions",[])}static apply(n,t){return Fc(n,t)}static compose(n,t){const r=new wr(n),s=new wr(t),o=new sn;for(;r.hasNext()||s.hasNext();)if(s.peekType()===Z.INSERT)o.push(s.next());else if(r.peekType()===Z.DELETE)o.push(r.next());else{const i=Math.min(r.peekLength(),s.peekLength()),a=r.next(i),l=s.next(i);a.t===Z.INSERT&&l.t===Z.RETAIN?l.body==null?o.push(a):o.push({...a,body:Or(a.body,l.body,l.coverType)}):a.t===Z.RETAIN&&l.t===Z.RETAIN?a.body==null&&l.body==null?o.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?o.push({...a,body:Or(a.body,l.body,l.coverType)}):o.push(a.body?a:l):a.t===Z.RETAIN&&l.t===Z.DELETE?o.push(l):a.t===Z.INSERT&&(l.t,Z.DELETE)}return o.trimEndUselessRetainAction(),o.serialize()}static transform(n,t,r){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const t=[];for(const r of n)if(r.t===Z.INSERT)t.push({t:Z.DELETE,len:r.len,line:0,body:r.body,segmentId:r.segmentId});else if(r.t===Z.DELETE){if(r.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");t.push({t:Z.INSERT,body:r.body,len:r.len,line:0,segmentId:r.segmentId})}else if(r.body!=null){if(r.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");t.push({t:Z.RETAIN,body:r.oldBody,oldBody:r.body,len:r.len,coverType:ke.REPLACE,segmentId:r.segmentId})}else t.push(r);return t}static makeInvertible(n,t){const r=[];let s=0;for(const o of n){if(o.t===Z.DELETE&&o.body==null){const i=an(t,s,s+o.len,!1);o.len=i.dataStream.length,o.body=i}if(o.t===Z.RETAIN&&o.body!=null){const i=an(t,s,s+o.len,!0);o.oldBody={...i,dataStream:""},o.len=i.dataStream.length}r.push(o),o.t!==Z.INSERT&&(s+=o.len)}return r}insert(n,t,r=""){const s={t:Z.INSERT,body:t,len:n,line:0,segmentId:r};return this.push(s),this}retain(n,t="",r,s){const o={t:Z.RETAIN,len:n,segmentId:t};return r!=null&&(o.body=r),s!=null&&(o.coverType=s),this.push(o),this}delete(n,t=""){const r={t:Z.DELETE,len:n,line:0,segmentId:t};return this.push(r),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...n){if(n.length>1){for(const o of n)this.push(o);return this}let t=this._actions.length,r=this._actions[t-1];const s=x.deepClone(n[0]);if(s.t===Z.RETAIN&&s.len===0&&s.body==null)return this;if(typeof r=="object"){if(r.t===Z.DELETE&&s.t===Z.DELETE)return r.len+=s.len,this;if(r.t===Z.DELETE&&s.t===Z.INSERT&&(t-=1,r=this._actions[t-1],r==null))return this._actions.unshift(s),this;if(r.t===Z.RETAIN&&s.t===Z.RETAIN&&r.body==null&&s.body==null)return r.len+=s.len,this;if(r.t===Z.INSERT&&As(r.body)&&s.t===Z.INSERT&&As(s.body))return r.len+=s.len,r.body.dataStream+=s.body.dataStream,this}return t===this._actions.length?this._actions.push(s):this._actions.splice(t,0,s),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===Z.RETAIN&&wc(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};_(sn,"id","text-x"),_(sn,"uri","https://github.com/dream-num/univer#text-x");let Ot=sn;Object.defineProperty(Ot,"name",{value:"text-x"});const $t=class $t{static registerSubtype(n){var t;this._subTypes.has(n.name)&&((t=this._subTypes.get(n.name))==null?void 0:t.id)!==Ot.id||(this._subTypes.set(n.name,n),$e.type.registerSubtype(n))}static apply(n,t){if(!$e.type.isNoop(t))return $e.type.apply(n,t)}static compose(n,t){return $e.type.compose(n,t)}static transform(n,t,r){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,t){return $e.type.invertWithDoc(n,t)}static isNoop(n){return $e.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new $t),this._instance}removeOp(n,t){return $e.removeOp(n,t)}moveOp(n,t){return $e.moveOp(n,t)}insertOp(n,t){return $e.insertOp(n,t)}replaceOp(n,t,r){return $e.replaceOp(n,t,r)}editOp(n,t=["body"]){return $e.editOp(t,Ot.name,n)}};_($t,"uri","https://github.com/dream-num/univer#json-x"),_($t,"_subTypes",new Map),_($t,"_instance",null);let Lt=$t;Lt.registerSubtype(Ot);const qr={id:"default_doc",documentStyle:{}};class Hc extends Vn{constructor(t){super();_(this,"type",J.UNIVER_DOC);_(this,"snapshot");this.snapshot={...qr,...t}}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 t;return((t=this.snapshot.settings)==null?void 0:t.zoomRatio)||1}resetDrawing(t,r){this.snapshot.drawings=t,this.snapshot.drawingsOrder=r}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(t){this.snapshot.id=t}updateDocumentRenderConfig(t){const{documentStyle:r}=this.snapshot;r.renderConfig==null?r.renderConfig=t:r.renderConfig={...r.renderConfig,...t}}updateDocumentStyle(t){this.snapshot.documentStyle==null?this.snapshot.documentStyle=t:this.snapshot.documentStyle={...this.snapshot.documentStyle,...t}}updateDocumentDataMargin(t){const{t:r,l:s,b:o,r:i}=t,{documentStyle:a}=this.snapshot;r!=null&&(a.marginTop=r),s!=null&&(a.marginLeft=s),o!=null&&(a.marginBottom=o),i!=null&&(a.marginRight=i)}updateDocumentDataPageSize(t,r){const{documentStyle:s}=this.snapshot;if(!s.pageSize){t=t!=null?t:Number.POSITIVE_INFINITY,r=r!=null?r:Number.POSITIVE_INFINITY,s.pageSize={width:t,height:r};return}t!==void 0&&(s.pageSize.width=t),r!==void 0&&(s.pageSize.height=r)}updateDrawing(t,r){const{drawings:s}=this,{width:o,height:i,left:a,top:l}=r,h=s==null?void 0:s[t];if(!h)return;const c=h.docTransform;c.size.width=o,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(t=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:t}:this.snapshot.settings.zoomRatio=1}}class xt extends Hc{constructor(t){var s;super(x.isEmptyObject(t)?bc():t);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const r=6;this._unitId=(s=this.snapshot.id)!=null?s:x.generateRandomId(r),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(t=>{t.dispose()}),this.footerModelMap.forEach(t=>{t.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var t;return(t=this.snapshot.body)==null?void 0:t.customRanges}getCustomDecorations(){var t;return(t=this.snapshot.body)==null?void 0:t.customDecorations}getRev(){var t;return(t=this.snapshot.rev)!=null?t:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(t){if(t.id&&t.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...qr,...t},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(t){if(t!=null){if(this.headerModelMap.has(t))return this.headerModelMap.get(t);if(this.footerModelMap.has(t))return this.footerModelMap.get(t)}return this}getUnitId(){return this._unitId}apply(t){if(!Lt.isNoop(t))return this.snapshot=Lt.apply(this.snapshot,t),t!=null&&t.some(r=>Array.isArray(r)&&((r==null?void 0:r[0])==="headers"||(r==null?void 0:r[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(t,r,s=Gr.copy){const o=this.getBody();if(o!=null)return an(o,t,r,!1,s)}_initializeHeaderFooterModel(){const{headers:t,footers:r}=this.getSnapshot();if(t)for(const s in t){const o=t[s];this.headerModelMap.set(s,new xt(o))}if(r)for(const s in r){const o=r[s];this.footerModelMap.set(s,new xt(o))}}updateDocumentId(t){super.updateDocumentId(t),this._unitId=t}}const Gi=Ve("univer.config-service");class Vi{constructor(){_(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,t){this._config.set(n,t)}deleteConfig(n){this._config.delete(n)}}class Ki extends Ae{constructor(){super(...arguments);_(this,"_error$",new Y.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(t){this._error$.next({errorKey:t})}}class zi{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new zo(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,t){if(this._cacheMap.has(t))return this._cacheMap.get(t);const r=this._getExistingStyleId(n);return r||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,t){const r=x.generateRandomId(6);return this._styles[r]=n,this._cacheMap.set(t,r),r}setValue(n){if(n==null)return;const t=JSON.stringify(n),r=this.search(n,t);return r!=="-1"?r:this.add(n,t)}toJSON(){return this._styles}getStyleByCell(n){let t;n&&x.isObject(n.s)?t=n.s:t=(n==null?void 0:n.s)&&this.get(n.s);const r=n==null?void 0:n.interceptorStyle;return r?{...t,...r}:t}_generateCacheMap(){const{_styles:n,_cacheMap:t}=this;for(const r in n){const s=JSON.stringify(n[r]);t.set(s,r)}}_getExistingStyleId(n){const{_styles:t}=this;for(const r in t)if(x.diffValue(t[r],n))return r;return null}}class jc{constructor(n,t){_(this,"_columnData",{});this._config=n,this._columnData=t}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:t}=this,r=t[n];return r?r.hd!==K.TRUE:!0}getHiddenCols(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getColVisible(i);s&&a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:o,endColumn:i-1,startRow:0,endRow:0})):!s&&!a&&(s=!0,o=i)}return s&&r.push({startRow:0,endRow:0,startColumn:o,endColumn:t,rangeType:oe.COLUMN}),r}getVisibleCols(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getColVisible(i);s&&!a?(s=!1,r.push({rangeType:oe.COLUMN,startColumn:o,endColumn:i-1,startRow:0,endRow:0})):!s&&a&&(s=!0,o=i)}return s&&r.push({startRow:0,endRow:0,startColumn:o,endColumn:t,rangeType:oe.COLUMN}),r}getColumnDatas(n,t){const r={};let s=0;for(let o=n;o<n+t;o++){const i=this.getColumnOrCreate(o);r[s]=i,s++}return r}getSize(){return It(this._columnData)}getColumnWidth(n){const{_columnData:t}=this,r=this._config;let s=0;return s=(t[n]||{hd:K.FALSE,w:r.defaultColumnWidth}).w||r.defaultColumnWidth,s}getColumn(n){const t=this._columnData[n];if(t)return t}getColumnOrCreate(n){const{_columnData:t}=this,r=this._config,s=t[n];if(s)return s;const o={w:r.defaultColumnWidth,hd:K.FALSE};return this._columnData[n]=o,o}}class $c{constructor(n,t,r){_(this,"_rowData");this._config=n,this._viewModel=t,this._rowData=r}getRowData(){return this._rowData}getRowDatas(n,t){const r={};let s=0;for(let o=n;o<n+t;o++){const i=this.getRowOrCreate(o);r[s]=i,s++}return r}getRowHeight(n,t=1){const{_rowData:r}=this,s=this._config;let o=0;for(let i=0;i<t;i++){const a=r[i+n]||{hd:K.FALSE,h:s.defaultRowHeight},{ia:l,ah:h,h:c=s.defaultRowHeight}=a;o+=(l==null||l===K.TRUE)&&typeof h=="number"?h:c}return o}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:t}=this,r=t[n];if(r)return r;const s=this._config,o={hd:K.FALSE,h:s.defaultRowHeight};return t[n]=o,o}getHiddenRows(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getRowRawVisible(i);s&&a?(s=!1,r.push({startRow:o,endRow:i-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&!a&&(s=!0,o=i)}return s&&r.push({startRow:o,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getVisibleRows(n=0,t=this.getSize()-1){const r=[];let s=!1,o=-1;for(let i=n;i<=t;i++){const a=this.getRowRawVisible(i);s&&!a?(s=!1,r.push({startRow:o,endRow:i-1,startColumn:0,endColumn:0,rangeType:oe.ROW})):!s&&a&&(s=!0,o=i)}return s&&r.push({startRow:o,endRow:t,startColumn:0,endColumn:0,rangeType:oe.ROW}),r}getRowRawVisible(n){const t=this.getRow(n);return t?t.hd!==K.TRUE:!0}getSize(){return It(this._rowData)}}const Wc="DEFAULT_WORKSHEET_ROW_COUNT",Yi=1e3,Bc="DEFAULT_WORKSHEET_COLUMN_COUNT",Xi=20,Gc="DEFAULT_WORKSHEET_ROW_HEIGHT",Qi=24,Vc="DEFAULT_WORKSHEET_COLUMN_WIDTH",qi=88,Kc="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Zi=46,zc="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Ji=20;function ea(e){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:K.FALSE,rowCount:Yi,columnCount:Xi,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:qi,defaultRowHeight:Qi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:K.TRUE,rowHeader:{width:Zi,hidden:K.FALSE},columnHeader:{height:Ji,hidden:K.FALSE},selections:["A1"],rightToLeft:K.FALSE};return Object.keys(n).forEach(t=>{const r=t;typeof e[r]>"u"&&(e[r]=n[r])}),e}class ta extends Ae{constructor(t){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=t}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(t,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(t,r):this.getRawCell(t,r)}getRowFiltered(t){var r,s;return(s=(r=this._rowFilteredInterceptor)==null?void 0:r.getRowFiltered(t))!=null?s:!1}registerCellContentInterceptor(t){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=t,Ne(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(t){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=t,Ne(()=>this._rowFilteredInterceptor=null)}}class ln{constructor(n,t,r){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=n,this._styles=r,this._snapshot=ea(t);const{columnData:s,rowData:o,cellData:i}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:x.generateRandomId(6),this._cellData=new ot(i),this._viewModel=new ta((l,h)=>this.getCellRaw(l,h)),this._rowManager=new $c(this._snapshot,this._viewModel,o),this._columnManager=new jc(this._snapshot,s)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),t=this.getMergeData();let r=-1,s=-1,o=-1,i=-1,a=!1,l=!1;return n.forEach((h,c)=>{Object.keys(c).forEach(u=>{const d=+u,f=n.getValue(h,d),p=f!=null&&f.s?this._styles.get(f.s):null,m=(p==null?void 0:p.bd)&&(p.bd.b||p.bd.l||p.bd.r||p.bd.t||p.bd.bc_tr||p.bd.bl_tr||p.bd.ml_tr||p.bd.tl_bc||p.bd.tl_br||p.bd.tl_mr);(f&&(f.v||f.p)||p!=null&&p.bg||m)&&(a?r=Math.min(r,h):(r=h,a=!0),s=Math.max(s,h),l?o=Math.min(o,d):(l=!0,o=d),i=Math.max(i,d))})}),t.forEach(h=>{a?r=Math.min(r,h.startRow):(r=h.startRow,a=!0),s=Math.max(s,h.endRow),l?o=Math.min(o,h.startColumn):(o=h.startColumn,a=!0),i=Math.max(i,h.endColumn)}),!a||!l?null:{startColumn:o,startRow:r,endColumn:i,endRow:s}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,t=x.deepClone(n);return new ln(this.unitId,t,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,t){const r=this._snapshot.mergeData;for(let s=0;s<r.length;s++){const o=r[s];if(vt.intersects({startRow:n,startColumn:t,endRow:n,endColumn:t},o))return o}return null}getCell(n,t){return n<0||t<0?null:this._viewModel.getCell(n,t)}getCellRaw(n,t){return this.getCellMatrix().getValue(n,t)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,t,r,s,o=!1){const i=this.getCellMatrix(),a=this._snapshot.mergeData.filter(h=>vt.intersects({startRow:n,startColumn:t,endRow:r,endColumn:s},h)),l=new ot;return fr(n,r,t,s).forEach((h,c)=>{const u=o?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;fr(u,f,c,d).forEach((p,m)=>{p===u&&m===c&&l.setValue(p,m,{...i.getValue(p,m),rowSpan:f-u+1,colSpan:d-c+1}),(p!==u||m!==c)&&l.realDeleteValue(p,m)})}),l}getRange(n,t,r,s){return typeof n=="object"?new Vt(this,n,{getStyles:()=>this._styles}):new Vt(this,{startRow:n,startColumn:t,endColumn:s||t,endRow:r||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:t}=n;return t}getMaxRows(){const{_snapshot:n}=this,{rowCount:t}=n;return t}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:t}=n;return t===0}getTabColor(){const{_snapshot:n}=this,{tabColor:t}=n;return t}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,t){const r=this.getMaxColumns()-1,s=this._rowManager.getHiddenRows(n,t);return s.forEach(o=>o.endColumn=r),s}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,t){const r=this.getMaxRows()-1,s=this._columnManager.getHiddenCols(n,t);return s.forEach(o=>o.endRow=r),s}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:t}=n;return t}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,t=!0){const{startRow:r,startColumn:s,endRow:o,endColumn:i}=n,a=this;return{[Symbol.iterator]:()=>{let l=r,h=s;return{next(){for(;;){if(h>i&&(l+=1,h=s),l>o)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&&t){h=d.endColumn+1;continue}const p={row:l,col:h,value:c};return p.colSpan=d.endColumn-d.startColumn+1,p.rowSpan=d.endRow-d.startRow+1,h=d.endColumn+1,{done:!1,value:p}}if(u&&t)h+=1;else{const f={row:l,col:h,value:c};return h+=1,{done:!1,value:f}}}}}}}}iterateByColumn(n,t=!0,r=!0){const{startRow:s,startColumn:o,endRow:i,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let h=s,c=o;return{next(){for(;;){if(h>i&&(c+=1,h=s),c>a)return{done:!0,value:void 0};const u=l.getMergedCell(h,c);if(u){const p=h!==u.startRow,m=p||c!==u.startColumn;if(r&&m||!r&&p){h=u.endRow+1;continue}const S=l.getCell(u.startRow,u.startColumn);if(!S&&t){h=u.endRow+1;continue}const ee={row:h,col:u.startColumn,value:S};return ee.colSpan=u.endColumn-u.startColumn+1,ee.rowSpan=u.endRow-u.startRow+1,h=u.endRow+1,{done:!1,value:ee}}const d=l.getCell(h,c);if(!d&&t)h+=1;else{const p={row:h,col:c,value:d};return h+=1,{done:!1,value:p}}}}}}}}}function Yc(e){var r,s;if(!e)return"";const n=(s=(r=e.p)==null?void 0:r.body)==null?void 0:s.dataStream;if(n)return n;const t=e.v;return typeof t=="string"?e.t===Mt.BOOLEAN?t.toUpperCase():t.replace(/[\r\n]/g,""):typeof t=="number"?e.t===Mt.BOOLEAN?t?"TRUE":"FALSE":t.toString():typeof t=="boolean"?t?"TRUE":"FALSE":""}const Xc="0.2.5";function Qc(e="",n=Pt.ZH_CN,t=""){return{id:e,sheetOrder:[],name:t,appVersion:Xc,locale:n,styles:{},sheets:{},resources:[]}}var qc=Object.defineProperty,Zc=Object.getOwnPropertyDescriptor,Jc=(e,n,t,r)=>{for(var s=r>1?void 0:r?Zc(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&qc(n,t,s),s},eh=(e,n)=>(t,r)=>n(t,r,e);function th(e,n){return`${e.getUnitId()}|${n.getSheetId()}`}exports.Workbook=class extends Vn{constructor(t={},r){super();_(this,"type",J.UNIVER_SHEET);_(this,"_sheetCreated$",new Y.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new Y.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new Y.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");_(this,"_name$");_(this,"name$");this._logService=r;const s=Qc();x.isEmptyObject(t)?this._snapshot=s:this._snapshot=x.commonExtend(s,t);const{styles:o}=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 zi(o),this._count=1,this._worksheets=new Map,this._name$=new Y.BehaviorSubject(t.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(t){return typeof t=="string"||"startRow"in t||"row"in t}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(t){this._name$.next(t),this._snapshot.name=t}getUnitId(){return this._unitId}getRev(){var t;return(t=this._snapshot.rev)!=null?t:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(t,r,s){const{sheets:o,sheetOrder:i}=this._snapshot;if(o[t])return!1;o[t]=s,i.splice(r,0,t);const a=new ln(this._unitId,s,this._styles);return this._worksheets.set(t,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(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>s===t)}getActiveSheet(t){if(!this._activeSheet&&typeof t>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const t=this._activeSheet;if(t)return t;const r=this._snapshot.sheetOrder;for(let o=0,i=r.length;o<i;o++){const a=this._worksheets.get(r[o]);if(a&&a.isSheetHidden()!==K.TRUE)return this.setActiveSheet(a),a}const s=this._worksheets.get(r[0]);return this.setActiveSheet(s),s}setActiveSheet(t){this._activeSheet$.next(t)}removeSheet(t){const r=this._worksheets.get(t);return r?(this._worksheets.delete(t),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(t),1),delete this._snapshot.sheets[t],this._sheetDisposed$.next(r),!0):!1}getActiveSheetIndex(){const{sheetOrder:t}=this._snapshot;return t.findIndex(r=>this._worksheets.get(r)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:t}=this._snapshot;return t.map(r=>this._worksheets.get(r))}getSheetsName(){const{sheetOrder:t}=this._snapshot,r=[];return t.forEach(s=>{const o=this._worksheets.get(s);o&&r.push(o.getName())}),r}getSheetIndex(t){const{sheetOrder:r}=this._snapshot;return r.findIndex(s=>t.getSheetId()===s)}getSheetBySheetName(t){const{sheetOrder:r}=this._snapshot,s=r.find(o=>this._worksheets.get(o).getName()===t);return this._worksheets.get(s)}getSheetBySheetId(t){return this._worksheets.get(t)}getSheetByIndex(t){const{sheetOrder:r}=this._snapshot;return this._worksheets.get(r[t])}getHiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden===K.TRUE).map(t=>t.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(t=>t.getConfig().hidden!==K.TRUE).map(t=>t.getConfig().id)}load(t){this._snapshot=t}checkSheetName(t){return this.getSheetsName().includes(t)}uniqueSheetName(t="Sheet1"){let r=t;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}generateNewSheetName(t){let r=t+this._count;for(;this.checkSheetName(r);)r=t+this._count,this._count++;return r}_parseWorksheetSnapshots(){const{_snapshot:t,_worksheets:r}=this,{sheets:s,sheetOrder:o}=t;if(x.isEmptyObject(s)){const i=x.generateRandomId();s[i]={id:i}}for(const i in s){const a=s[i],{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 ln(this._unitId,a,this._styles);r.set(i,h),o.includes(i)||o.push(i)}this.ensureActiveSheet()}};exports.Workbook=Jc([eh(1,St)],exports.Workbook);class Zr extends Vn{constructor(t){var r;super();_(this,"type",J.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...Qo,...t},this._unitId=(r=this._snapshot.id)!=null?r:x.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var t;return(t=this._snapshot.body)==null?void 0:t.pages}getPageOrder(){var t;return(t=this._snapshot.body)==null?void 0:t.pageOrder}getPage(t){const r=this.getPages();return r==null?void 0:r[t]}getElementsByPage(t){var r;return(r=this.getPage(t))==null?void 0:r.pageElements}getElement(t,r){var s;return(s=this.getElementsByPage(t))==null?void 0:s[r]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:yr.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const tn="FOCUSING_SHEET",wn="FOCUSING_DOC",bn="FOCUSING_SLIDE",nh="FOCUSING_EDITOR_BUT_HIDDEN",na="EDITOR_ACTIVATED",rh="FOCUSING_EDITOR_INPUT_FORMULA",ra="FOCUSING_FORMULA_EDITOR",sh="FOCUSING_UNIVER_EDITOR",oh="FOCUSING_EDITOR_INPUT_FORMULA",ih="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",ah="FOCUSING_COMMON_DRAWINGS";var lh=Object.defineProperty,uh=Object.getOwnPropertyDescriptor,ch=(e,n,t,r)=>{for(var s=r>1?void 0:r?uh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&lh(n,t,s),s},Ts=(e,n)=>(t,r)=>n(t,r,e);const Kt=Ve("univer.current");exports.UniverInstanceService=class extends Ae{constructor(t,r){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits",new Map);_(this,"_currentUnits$",new Y.BehaviorSubject(this._currentUnits));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new Y.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new Y.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new Y.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=t,this._contextService=r}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(t){this._createHandler=t}createUnit(t,r){return this._createHandler(t,r,this._ctorByType.get(t))}registerCtorForType(t,r){return this._ctorByType.set(t,r),{dispose:()=>{this._ctorByType.delete(t)}}}getCurrentTypeOfUnit$(t){return this.currentUnits$.pipe(Y.map(r=>{var s;return(s=r.get(t))!=null?s:null}),Y.distinctUntilChanged())}getCurrentUnitForType(t){return this._currentUnits.get(t)}setCurrentUnitForType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: no document with unitId ${t}!`);this._currentUnits.set(r[1],r[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(t){this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(t){return this._unitAdded$.pipe(Y.filter(r=>r.type===t))}__addUnit(t){const r=t.type;this._unitsByType.has(r)||this._unitsByType.set(r,[]),this._unitsByType.get(r).push(t),this._unitAdded$.next(t),this.setCurrentUnitForType(t.getUnitId())}getTypeOfUnitDisposed$(t){return this.unitDisposed$.pipe(Y.filter(r=>r.type===t))}getUnit(t,r){var o;const s=(o=this._getUnitById(t))==null?void 0:o[0];return r&&(s==null?void 0:s.type)!==r?null:s}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(J.UNIVER_DOC)}getUniverDocInstance(t){return this.getUnit(t,J.UNIVER_DOC)}getUniverSheetInstance(t){return this.getUnit(t,J.UNIVER_SHEET)}getAllUnitsForType(t){var r;return(r=this._unitsByType.get(t))!=null?r:[]}changeDoc(t,r){const s=this.getAllUnitsForType(J.UNIVER_DOC),o=s.find(i=>i.getUnitId()===t);if(o!=null){const i=s.indexOf(o);s.splice(i,1)}this.__addUnit(r)}get focused(){var r;const t=this._focused$.getValue();return t?(r=this._getUnitById(t))==null?void 0:r[0]:null}focusUnit(t){this._focused$.next(t),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(tn,!0),this._contextService.setContextValue(bn,!1)):this.focused instanceof xt?(this._contextService.setContextValue(wn,!0),this._contextService.setContextValue(tn,!1),this._contextService.setContextValue(bn,!1)):this.focused instanceof Zr&&(this._contextService.setContextValue(wn,!1),this._contextService.setContextValue(tn,!1),this._contextService.setContextValue(bn,!0))}getFocusedUnit(){return this.focused}getUnitType(t){const r=this._getUnitById(t);if(!r)throw new Error(`[UniverInstanceService]: No document with unitId ${t}`);return r[1]}disposeUnit(t){const r=this._getUnitById(t);if(!r)return!1;const[s,o]=r,i=this._unitsByType.get(o),a=i.indexOf(s);return i.splice(a,1),this._removeCurrentUnitForType(o),this._focused$.next(null),this._unitDisposed$.next(s),!0}_getUnitById(t){for(const[r,s]of this._unitsByType){const o=s.find(i=>i.getUnitId()===t);if(o)return[o,r]}}};exports.UniverInstanceService=ch([Ts(0,it(pt)),Ts(1,cn)],exports.UniverInstanceService);var de=(e=>(e[e.Starting=0]="Starting",e[e.Ready=1]="Ready",e[e.Rendered=2]="Rendered",e[e.Steady=3]="Steady",e))(de||{});const hh={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},An=new Map;function sa(e,n){return function(s){Kn(e,n)}}function Kn(e,n){An.has(e)||An.set(e,[]),An.get(e).push(n)}var dh=Object.defineProperty,fh=Object.getOwnPropertyDescriptor,oa=(e,n,t,r)=>{for(var s=r>1?void 0:r?fh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&dh(n,t,s),s},ia=(e,n)=>(t,r)=>n(t,r,e);exports.LifecycleService=class extends Ae{constructor(t){super();_(this,"_lifecycle$",new Y.BehaviorSubject(de.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=t,this._reportProgress(de.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(t){if(t<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(t!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(t),this._lifecycle$.next(t),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return Y.merge(aa(this.stage),this._lifecycle$.pipe(Y.skip(1))).pipe(Ii(t=>t===de.Steady))}_reportProgress(t){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${hh[t]}".`)}};exports.LifecycleService=oa([ia(0,St)],exports.LifecycleService);exports.LifecycleInitializerService=class extends Ae{constructor(t){super();_(this,"_seenTokens",new Set);this._injector=t}initModulesOnStage(t){var r;(r=An.get(t))==null||r.forEach(s=>{this._injector.has(s)&&!this._seenTokens.has(s)&&(this._injector.get(s),this._seenTokens.add(s))})}};exports.LifecycleInitializerService=oa([ia(0,it(pt))],exports.LifecycleInitializerService);function aa(e){switch(e){case de.Starting:return Y.of(de.Starting);case de.Ready:return Y.of(de.Starting,de.Ready);case de.Rendered:return Y.of(de.Starting,de.Ready,de.Rendered);default:return Y.of(de.Starting,de.Ready,de.Rendered,de.Steady)}}class nn extends Ae{constructor(){super();_(this,"_currentLocale$",new Y.BehaviorSubject(Pt.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new Y.Subject);_(this,"t",(t,...r)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const s=t.split("."),o=this.resolveKeyPath(this._locales[this._currentLocale],s);if(typeof o=="string"){let i=o;return r.forEach((a,l)=>{i=i.replace(`{${l}}`,a)}),i}else return t});this.disposeWithMe(Ne(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(t){var r;this._locales=x.deepMerge((r=this._locales)!=null?r:{},t)}setLocale(t){this._currentLocale$.next(t),this.localeChanged$.next()}getLocales(){var t;return(t=this._locales)==null?void 0:t[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(t,r){const s=r.shift();if(s&&t&&s in t){const o=t[s];return r.length>0&&(typeof o=="object"||Array.isArray(o))?this.resolveKeyPath(o,r):o}return null}}var Jr=(e=>(e.INIT="init",e.FETCHING="fetching",e.DONE="done",e))(Jr||{});const es=Ve("univer.permission-service");Kn(de.Starting,es);class la extends Ae{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new Y.Subject);_(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(t){const r=this._permissionPointMap.get(t);r&&(r.complete(),this._permissionPointMap.delete(t))}addPermissionPoint(t){const r=t instanceof Y.BehaviorSubject,s=r?t.getValue():t;if(!s.id)return!1;if(this._permissionPointMap.get(s.id))throw new Error(`${s.id} PermissionPoint already exists`);return this._permissionPointMap.set(s.id,r?t:new Y.BehaviorSubject(s)),this._permissionPointUpdate$.next(s),!0}updatePermissionPoint(t,r){const s=this._permissionPointMap.get(t);if(!s)return;const o=s.getValue();o.value=r,o.status=Jr.DONE,s.next({...o}),this._permissionPointUpdate$.next(o)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(t){const r=this._permissionPointMap.get(t);if(r)return r.getValue()}getPermissionPoint$(t){const r=this._permissionPointMap.get(t);if(r)return r}composePermission$(t){const r=t.map(s=>{var i;const o=(i=this._permissionPointMap)==null?void 0:i.get(s);if(!o)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return o.asObservable()});return Y.combineLatest(r).pipe(Cn.map(s=>s))}composePermission(t){return t.map(s=>{var i;const o=(i=this._permissionPointMap)==null?void 0:i.get(s);if(!o)throw new Error(`[PermissionService]: ${s} permissionPoint does not exist!`);return o.getValue()})}getAllPermissionPoint(){const t=new Map;return this._permissionPointMap.forEach((r,s)=>{t.set(s,r)}),t}}class ua extends Ae{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new Y.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(t){return this.getAllResourceHooks().map(o=>{const i=o.toJson(t);return{name:o.pluginName,data:i}})}getResourcesByType(t,r){return this.getAllResourceHooks().filter(i=>i.businesses.includes(r)).map(i=>{const a=i.toJson(t);return{name:i.pluginName,data:a}})}registerPluginResource(t){const r=t.pluginName;if(this._resourceMap.has(r))throw new Error(`the pluginName is registered {${r}}`);return this._resourceMap.set(r,t),this._register$.next(t),Ne(()=>this._resourceMap.delete(r))}disposePluginResource(t){this._resourceMap.delete(t)}loadResources(t,r){this.getAllResourceHooks().forEach(s=>{var i;const o=(i=r==null?void 0:r.find(a=>a.name===s.pluginName))==null?void 0:i.data;if(o)try{const a=s.parseJson(o);s.onLoad(t,a)}catch{console.error("LoadResources Error!")}})}unloadResources(t){this.getAllResourceHooks().forEach(r=>{r.onUnLoad(t)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const zn=Ve("resource-manager-service");var _h=Object.defineProperty,gh=Object.getOwnPropertyDescriptor,ph=(e,n,t,r)=>{for(var s=r>1?void 0:r?gh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&_h(n,t,s),s},ys=(e,n)=>(t,r)=>n(t,r,e);let br=class extends Ae{constructor(n,t){super();_(this,"saveWorkbook",n=>{const t=n.getUnitId(),r=this._resourceManagerService.getResources(t)||[],s=n.getSnapshot();return s.resources=r,s});this._resourceManagerService=n,this._univerInstanceService=t,this._init()}_init(){const n=r=>{r.businesses.forEach(s=>{switch(s){case J.UNRECOGNIZED:case J.UNIVER_UNKNOWN:case J.UNIVER_SLIDE:case J.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(J.UNIVER_DOC).forEach(o=>{const a=(o.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(o.getUnitId(),l)}catch{console.error(`Load Document{${o.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}});break}case J.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(J.UNIVER_SHEET).forEach(o=>{const a=(o.getSnapshot().resources||[]).find(l=>l.name===r.pluginName);if(a)try{const l=r.parseJson(a.data);r.onLoad(o.getUnitId(),l)}catch{console.error(`Load Workbook{${o.getUnitId()}} Resources{${r.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(r=>{n(r)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(r=>{n(r)})),this.disposeWithMe(Ne(this._univerInstanceService.getTypeOfUnitAdded$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.loadResources(r.getUnitId(),r.getSnapshot().resources)}))),this.disposeWithMe(Ne(this._univerInstanceService.getTypeOfUnitDisposed$(J.UNIVER_SHEET).subscribe(r=>{this._resourceManagerService.unloadResources(r.getUnitId())})))}saveDoc(n){const t=n.getUnitId(),r=this._resourceManagerService.getResourcesByType(t,J.UNIVER_DOC)||[],s=n.getSnapshot();return s.resources=r,s}};br=ph([ys(0,it(zn)),ys(1,it(Kt))],br);const ts=Ve("resource-loader-service");Kn(de.Ready,ts);class ns extends Ae{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new Y.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(Ne(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(t){this._currentTheme=t,this._currentTheme$.next(t)}}const Yn="__INTERNAL_EDITOR__",ca=`${Yn}DOCS_NORMAL`,ha=`${Yn}DOCS_FORMULA_BAR`,mh="__defaultDocumentZenEditorSpecialUnitId_20231218__",Eh=`\r
9
+ `;function Rh(e){return`${Yn}${e}`}function Ch(e){return e.startsWith(Yn)}var Ih=Object.defineProperty,vh=Object.getOwnPropertyDescriptor,Oh=(e,n,t,r)=>{for(var s=r>1?void 0:r?vh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Ih(n,t,s),s},or=(e,n)=>(t,r)=>n(t,r,e);const Xn=Ve("univer.undo-redo.service"),Sh=20;class da{dispose(){}async dispatchToHandlers(){return!1}}const fa="univer.command.redo",_a="univer.command.undo",ga=new class extends da{constructor(){super(...arguments);_(this,"type",hn.COMMAND);_(this,"id",_a)}async handler(n){const t=n.get(Xn),r=t.pitchTopUndoElement();if(!r)return!1;const s=n.get(dn);return Hr(r.undoMutations,s)?(t.popUndoToRedo(),!0):!1}},pa=new class extends da{constructor(){super(...arguments);_(this,"type",hn.COMMAND);_(this,"id",fa)}async handler(n){const t=n.get(Xn),r=t.pitchTopRedoElement();if(!r)return!1;const s=n.get(dn);return Hr(r.redoMutations,s)?(t.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Ae{constructor(t,r,s){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new Y.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=t,this._commandService=r,this._contextService=s,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(ga)),this.disposeWithMe(this._commandService.registerCommand(pa)),this.disposeWithMe(Ne(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(Ne(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(t){const{unitID:r}=t,s=this._getRedoStack(r,!0),o=this._getUndoStack(r,!0);if(s.length=0,this._batchingStatus.has(t.unitID)){const a=this._batchingStatus.get(t.unitID),l=this._pitchUndoElement(t.unitID);a===0||!l?(i(t),this._batchingStatus.set(t.unitID,1)):this._tryBatchingElements(l,t)}else i(t);function i(a){o.push(a),o.length>Sh&&o.splice(0,1)}this._updateStatus()}clearUndoRedo(t){const r=this._getRedoStack(t);r&&(r.length=0);const s=this._getUndoStack(t);s&&(s.length=0),this._updateStatus()}pitchTopUndoElement(){const t=this._getFocusedUnitId();return this._pitchUndoElement(t)}pitchTopRedoElement(){const t=this._getFocusedUnitId();return this._pitchRedoElement(t)}_pitchUndoElement(t){const r=this._getUndoStack(t);return r!=null&&r.length?r[r.length-1]:null}_pitchRedoElement(t){const r=this._getRedoStack(t);return r!=null&&r.length?r[r.length-1]:null}popUndoToRedo(){const r=this._getUndoStackForFocused().pop();r&&(this._getRedoStackForFocused().push(r),this._updateStatus())}popRedoToUndo(){const r=this._getRedoStackForFocused().pop();r&&(this._getUndoStackForFocused().push(r),this._updateStatus())}__tempBatchingUndoRedo(t){if(this._batchingStatus.has(t))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(t,0),Ne(()=>this._batchingStatus.delete(t))}_updateStatus(){var o,i;const t=this._getFocusedUnitId(),r=t&&((o=this._undoStacks.get(t))==null?void 0:o.length)||0,s=t&&((i=this._redoStacks.get(t))==null?void 0:i.length)||0;this._undoRedoStatus$.next({undos:r,redos:s})}_getUndoStack(t,r=!1){let s=this._undoStacks.get(t);return!s&&r&&(s=[],this._undoStacks.set(t,s)),s||null}_getRedoStack(t,r=!1){let s=this._redoStacks.get(t);return!s&&r&&(s=[],this._redoStacks.set(t,s)),s||null}_getUndoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getUndoStack(t,!0)}_getRedoStackForFocused(){const t=this._getFocusedUnitId();if(!t)throw new Error("No focused univer instance!");return this._getRedoStack(t,!0)}_tryBatchingElements(t,r){t.redoMutations.push(...r.redoMutations),t.undoMutations.push(...r.undoMutations)}_getFocusedUnitId(){var i,a,l,h;let t="";const r=this._contextService.getContextValue(tn),s=this._contextService.getContextValue(ra),o=this._contextService.getContextValue(na);return r?s?t=ha:o?t=ca:t=(a=(i=this._univerInstanceService.getFocusedUnit())==null?void 0:i.getUnitId())!=null?a:"":t=(h=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?h:"",t}};exports.LocalUndoRedoService=Oh([or(0,Kt),or(1,dn),or(2,cn)],exports.LocalUndoRedoService);const ma=Symbol("DependentOn");class Ar extends Ae{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(Ar,"pluginName"),_(Ar,"type",J.UNIVER_UNKNOWN);class Nh{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 wh{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,t){this._pluginsRegistered.push({plugin:n,options:t})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var bh=Object.defineProperty,Ah=Object.getOwnPropertyDescriptor,Ea=(e,n,t,r)=>{for(var s=r>1?void 0:r?Ah(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&bh(n,t,s),s},Zt=(e,n)=>(t,r)=>n(t,r,e);const Th=4;function yh(...e){return function(n){n[ma]=e}}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(kn,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,t){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:r}=n;r===J.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,t),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(r).register(n,t)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const t=this._injector.createInstance(kn,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,t),t}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:t,pluginName:r}=n;if(t===J.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(r==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(r))throw new Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Th))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,t]of this._pluginHoldersForTypes)t.started&&t.flush()}};exports.PluginService=Ea([Zt(0,it(pt))],exports.PluginService);let kn=class extends Ae{constructor(n,t,r,s,o,i){super();_(this,"_started",!1);_(this,"_pluginRegistry",new wh);_(this,"_pluginStore",new Nh);_(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=t,this._logService=r,this._injector=s,this._lifecycleService=o,this._lifecycleInitializerService=i,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Y.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,t){this._pluginRegistry.registerPlugin(n,t)}immediateInitPlugin(n){const t=this._initPlugin(n,void 0);this._pluginsRunLifecycle([t])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:t,options:r})=>this._initPlugin(t,r));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,t){const r=n[ma];if(r){const o=()=>{const i=r.find(a=>!this._checkPluginRegistered(a));return i?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${i.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(i,void 0),!0):!1};for(;o(););}const s=this._injector.createInstance(n,t);return this._pluginStore.addPlugin(s),s}_pluginsRunLifecycle(n){aa(this._lifecycleService.stage).subscribe(t=>this._runStage(n,t)),this._awaitingPlugins.push(n)}_runStage(n,t){n.forEach(r=>{switch(t){case de.Starting:r.onStarting(this._injector);break;case de.Ready:r.onReady();break;case de.Rendered:r.onRendered();break;case de.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(t)}};kn=Ea([Zt(2,St),Zt(3,it(pt)),Zt(4,it(exports.LifecycleService)),Zt(5,it(exports.LifecycleInitializerService))],kn);function Ra(e,n){if(!n)return e;const t=[];for(const r of e){const s=n.find(([o])=>o===r[0]);if(s){if(s[1]===null)continue;t.push([r[0],s[1]])}else t.push(r)}return t}const Tr={[je.Editor]:"Editor",[je.Owner]:"Owner",[je.Reader]:"Reader",[je.UNRECOGNIZED]:"UNRECOGNIZED"},Fn=e=>e?{userID:`${Tr[e]}_${x.generateRandomId(8)}`,name:Tr[e],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},ir=(e,n)=>e.startsWith(Tr[n]);var Dh=Object.defineProperty,Mh=Object.getOwnPropertyDescriptor,Uh=(e,n,t,r)=>{for(var s=r>1?void 0:r?Mh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Dh(n,t,s),s};exports.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new Y.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new Y.BehaviorSubject(Fn()));_(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,t){const r=this._model.get(n);if(r)return r;t&&t()}delete(n){const t=this.getUser(n);this._model.delete(n),t&&this._userChange$.next({type:"delete",user:t})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}};exports.UserManagerService=Uh([sa(de.Starting,exports.UserManagerService)],exports.UserManagerService);var Lh=Object.defineProperty,xh=Object.getOwnPropertyDescriptor,Ph=(e,n,t,r)=>{for(var s=r>1?void 0:r?xh(n,t):n,o=e.length-1,i;o>=0;o--)(i=e[o])&&(s=(r?i(n,t,s):i(s))||s);return r&&s&&Lh(n,t,s),s},Ds=(e,n)=>(t,r)=>n(t,r,e);exports.AuthzIoLocalService=class{constructor(n,t){_(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=t,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(Fn(je.Owner))}_getRole(n){const t=this._userManagerService.getCurrentUser();return t?ir(t.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const t=[...this._permissionMap.keys()].reduce((r,s)=>{const o=this._permissionMap.get(s);return r[s]=o,r},{});return JSON.stringify(t)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[J.UNIVER_SHEET,J.UNIVER_DOC,J.UNIVER_SLIDE],onLoad:(n,t)=>{for(const r in t)this._permissionMap.set(r,t[r])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const t=x.generateRandomId(8);switch(n.objectType){case Nn.SelectRange:{const r=n.selectRangeObject;this._permissionMap.set(t,{...r,objectType:n.objectType});break}case Nn.Worksheet:{const r=n.worksheetObject;this._permissionMap.set(t,{...r,objectType:n.objectType,readScope:Oi.SomeCollaborator})}}return t}async allowed(n){var t;if(this._permissionMap.has(n.objectID)){const r=this._permissionMap.get(n.objectID);if(r&&r.objectType===Nn.Worksheet)return(t=r==null?void 0:r.strategies)==null?void 0:t.map(s=>({action:s.action,allowed:s.role===je.Editor}))}return n.actions.map(r=>({action:r,allowed:this._getRole(je.Owner)||this._getRole(je.Editor)}))}async batchAllowed(n){const t=this._userManagerService.getCurrentUser(),r=n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(o=>({action:o,allowed:!1}))}));return t&&(ir(t.userID,je.Owner)||ir(t.userID,je.Editor))?n.map(s=>({unitID:s.unitID,objectID:s.objectID,actions:s.actions.map(o=>({action:o,allowed:!0}))})):r}async list(n){const t=[];return n.objectIDs.forEach(r=>{const s=this._permissionMap.get(r);if(s){const o={objectID:r,unitID:n.unitID,objectType:s.objectType,name:s.name,shareOn:!1,shareRole:je.Owner,shareScope:-1,creator:Fn(je.Owner),strategies:[],actions:n.actions.map(i=>({action:i,allowed:this._getRole(je.Owner)||this._getRole(je.Editor)}))};t.push(o)}}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}};exports.AuthzIoLocalService=Ph([Ds(0,zn),Ds(1,it(exports.UserManagerService))],exports.AuthzIoLocalService);const Ca=Ve("IAuthzIoIoService");class kh{constructor(n={},t){_(this,"_startedTypes",new Set);_(this,"_injector");const r=this._injector=Fh(t,n==null?void 0:n.override),{theme:s,locale:o,locales:i,logLevel:a}=n;s&&this._injector.get(ns).setTheme(s),i&&this._injector.get(nn).load(i),o&&this._injector.get(nn).setLocale(o),a&&this._injector.get(St).setLogLevel(a),this._init(r)}get _univerInstanceService(){return this._injector.get(Kt)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(nn).setLocale(n)}createUnit(n,t){return this._univerInstanceService.createUnit(n,t)}createUniverSheet(n){return this._univerInstanceService.createUnit(J.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(J.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(J.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(J.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(J.UNIVER_DOC,xt),this._univerInstanceService.registerCtorForType(J.UNIVER_SLIDE,Zr);const t=n.get(Kt);t.__setCreateHandler((r,s,o)=>{if(!this._startedTypes.has(r)){this._pluginService.startPluginForType(r),this._startedTypes.add(r);const a=n.createInstance(o,s);return t.__addUnit(a),this._tryProgressToReady(),a}const i=n.createInstance(o,s);return t.__addUnit(i),i})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<de.Ready&&(this._injector.get(exports.LifecycleService).stage=de.Ready)}registerPlugin(n,t){this._pluginService.registerPlugin(n,t)}}function Fh(e,n){const t=Ra([[Ki],[nn],[ns],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[Kt,{useClass:exports.UniverInstanceService}],[es,{useClass:la}],[St,{useClass:Ei,lazy:!0}],[dn,{useClass:exports.CommandService}],[Xn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Gi,{useClass:Vi}],[cn,{useClass:pi}],[zn,{useClass:ua,lazy:!0}],[ts,{useClass:br,lazy:!0}],[Ca,{useClass:exports.AuthzIoLocalService,lazy:!0}]],n);return e?e.createChild(t):new pt(t)}const Hh=(e,n)=>n.length===e.length&&!e.some(t=>n.some(r=>!vt.equals(r,t))),jh=(e,n)=>n.length===e.length&&e.every((t,r)=>{const s=n[r];return s.unitId===t.unitId&&s.sheetId===t.sheetId&&vt.equals(t.range,s.range)});function $h(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||!e||typeof n!="object"||!n)return!1;const t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;const s=Object.prototype.hasOwnProperty.bind(n);for(let o=0;o<t.length;o++){const i=t[o];if(!s(i))return!1;const a=e[i],l=n[i];if(a!==l)return!1}return!0}function Ia(e){return/^-?\d+(\.\d+)?$/.test(e)}function Wh(e){return Ia(e)?Number(e)<=Number.MAX_SAFE_INTEGER:!1}function Bh(e){return["true","false"].includes(e.toLowerCase())}function Gh(e,n){return n.forEach(t=>e.add(t)),e}function Vh(e,n=16){let t=0,r=null;return function(...o){const i=Date.now();i-t<n?(r&&clearTimeout(r),r=setTimeout(()=>{t=i,e.apply(this,o)},n)):(t=i,e.apply(this,o))}}function Kh(e){const n=new MessageChannel;let t=!1;const r=()=>{t||e()};return n.port1.onmessage=r,n.port2.postMessage(null),()=>{t=!0,n.port1.close(),n.port2.close()}}var va=(e=>(e[e.TEXT=0]="TEXT",e[e.ARROW=1]="ARROW",e[e.CUSTOM=2]="CUSTOM",e))(va||{});function zh(e,n,t){if(n==="")return e;const r={id:"mock-id",body:e,documentStyle:{}},s=new xt(r),o=n.length;let i;for(;(i=s.getBody().dataStream.indexOf(n))>=0;){const l=new Ot,h=Lt.getInstance();if(i>0&&l.retain(i),t.length>0){const c=s.sliceBody(i,i+o),u={dataStream:t};Array.isArray(c==null?void 0:c.textRuns)&&c.textRuns.length&&(u.textRuns=[{...c.textRuns[0],st:0,ed:t.length}]),l.insert(t.length,u)}l.delete(o),s.apply(h.editOp(l.serialize()))}const a=s.getBody();return s.dispose(),a}class Oa{constructor(){_(this,"skipNextObservers",!1);_(this,"lastReturnValue");_(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class Yh extends Y.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(t){let r;typeof t=="function"?r={next:([o,i])=>t(o,i)}:r=t;const s=super.subscribe(r);return this._sortedObservers.push(r),this._sortedObservers.sort((o,i)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)}),s.add(()=>this._sortedObservers=this._sortedObservers.filter(o=>o!==r)),s}clearObservers(){this._sortedObservers.forEach(t=>{var r;return(r=t.complete)==null?void 0:r.call(t)}),this._sortedObservers.length=0}emitEvent(t){var r;if(!this.closed){const s=new Oa;s.lastReturnValue=t;for(const o of this._sortedObservers){const i=(r=o.next)==null?void 0:r.call(o,[t,s]);if(s.lastReturnValue=i,s.skipNextObservers)return{handled:!0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}function Xh(e){return new Y.Observable(n=>{const t=e.subscribeEvent(r=>{n.next(r)});return()=>t.unsubscribe()})}const Qh=Ve("ILocalStorageService");function qh(e){return`sheet_interceptor_${e}`}const Sa=e=>function(n,t){let r=-1;function s(o,i){if(o<=r)throw new Error("[SheetInterceptorService]: next() called multiple times!");return r=o,o===e.length?i:e[o].handler(i,t,s.bind(null,o+1))}return s(0,n)};class Zh{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const t=n,r=this._interceptorsByName.get(t);return Sa(r||[])}intercept(n,t){const r=n;this._interceptorsByName.has(r)||this._interceptorsByName.set(r,[]);const s=this._interceptorsByName.get(r);return s.push(t),this._interceptorsByName.set(r,s.sort((o,i)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)})),()=>Bn(this._interceptorsByName.get(r),t)}getInterceptPoints(){return this._interceptorPoints}}const Jh=Ve("univer.snapshot-server-service");class ed{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,t){return Promise.resolve({snapshot:{unitID:"",type:J.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Ze.OK,message:""}})}getSheetBlock(n,t){const r=this._sheetBlockCache.get(t.blockID);return Promise.resolve({block:r,error:{code:Ze.OK,message:""}})}fetchMissingChangesets(n,t){return Promise.resolve({changesets:[],error:{code:Ze.OK,message:""}})}getResourcesRequest(n,t){return Promise.resolve({resources:{},error:{code:Ze.OK,message:""}})}saveSnapshot(n,t){return Promise.resolve({error:{code:Ze.OK,message:""}})}saveSheetBlock(n,t){const{block:r}=t;return r?(this._sheetBlockCache.set(r.id,r),Promise.resolve({error:{code:Ze.OK,message:""},blockID:r.id})):Promise.resolve({error:{code:Ze.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,t){return Promise.resolve({error:{code:Ze.OK,message:""},concurrent:[]})}}function td(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(n,t)=>String.fromCharCode(Number.parseInt(t,16))))}function rs(e){return decodeURIComponent(Array.prototype.map.call(atob(e),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const fn=new TextEncoder,Qn=new TextDecoder;function Na(e){const n=x.deepClone(e);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,fn.encode(JSON.stringify(n))}function wa(e){const n=x.deepClone(e);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,fn.encode(JSON.stringify(n))}function nd(e){const n=x.deepClone(e);return delete n.id,delete n.rev,delete n.title,delete n.resources,fn.encode(JSON.stringify(n))}function Ms(e){return JSON.parse(Qn.decode(e))}function rd(e){return JSON.parse(typeof e=="string"?rs(e):Qn.decode(e))}function sd(e){return JSON.parse(typeof e=="string"?rs(e):Qn.decode(e))}const ar=256*20;function ba(e,n){const t=new ot(e),r=t.getLength(),s=[];let o=0;for(;o<r;){const i=Math.min(o+ar,r-1),a=t.getSlice(o,Math.min(o+ar,r-1),0,n),l=od(a);s.push({id:x.generateRandomId(19,"0123456789"),startRow:o,endRow:i,data:l}),o+=ar}return s}function od(e){const n=e.getData();return fn.encode(JSON.stringify(n))}async function id(e,n,t,r,s){const o={},i={};if(!await Promise.all(Object.entries(n.sheets).map(async([u,d])=>{const f={id:d.id,type:Hn.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:Na(d)};if(i[u]=f,d.cellData){const p=ba(d.cellData,d.rowCount),m=await Promise.all(p.map(S=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:S})));if(m.some(S=>{var y;return((y=S.error)==null?void 0:y.code)!==Ze.OK}))return!1;o[u]={sheetID:u,blocks:m.map(S=>S.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=wa(n),h={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:i,blockMeta:o,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:t,rev:h.rev,type:J.UNIVER_SHEET,workbook:h,doc:void 0}}}async function ad(e,n,t,r,s){var d,f;const o={},i={};if(!await Promise.all(Object.entries(n.sheets).map(async([p,m])=>{const S={id:m.id,type:Hn.GRID,name:m.name,rowCount:m.rowCount,columnCount:m.columnCount,originalMeta:Na(m)};if(i[p]=S,m.cellData){const y=ba(m.cellData,m.rowCount),ee=await Promise.all(y.map(ge=>s.saveSheetBlock(e,{unitID:t,type:J.UNIVER_SHEET,block:ge})));if(ee.some(ge=>{var ce;return((ce=ge.error)==null?void 0:ce.code)!==Ze.OK}))return!1;o[p]={sheetID:p,blocks:ee.map(ge=>ge.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=wa(n),h={unitID:n.id,rev:r,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:i,blockMeta:o,resources:n.resources||[],originalMeta:l},c={unitID:t,rev:h.rev,type:J.UNIVER_SHEET,workbook:h,doc:void 0},u=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_SHEET,snapshot:c});if(vi(u.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
10
+ ErrorCode: ${(d=u.error)==null?void 0:d.code}:${(f=u.error)==null?void 0:f.message}`);return{snapshot:c}}function ld(e,n,t){const r=e.workbook;if(!r)throw new Error("");const s={};Object.entries(r.sheets).forEach(([l,h])=>{const c=Ms(h.originalMeta);s[l]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...c}});const o=new Map;n.forEach(l=>{o.set(l.id,l)}),r.blockMeta&&Object.entries(r.blockMeta).forEach(([l,h])=>{var d;const c=s[l];c.cellData={};const u=[];(d=h.blocks)==null||d.forEach(f=>{const p=o.get(f);if(p)u.push(p);else throw new Error("")}),u.forEach(f=>{const p=rd(f.data);Object.entries(p).forEach(([m,S])=>{const y=c.cellData[+m]={};Object.entries(S).forEach(([ee,ge])=>{y[+ee]=ge})})})});const i=Ms(r.originalMeta);return{id:e.unitID,rev:r.rev,name:r.name,sheetOrder:r.sheetOrder,appVersion:"",locale:Pt.EN_US,sheets:s,styles:{},resources:r.resources||[],...i}}function ud(e){const n=e.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:t,rev:r,name:s,originalMeta:o,resources:i=[]}=n,{body:a,documentStyle:l={},settings:h={},drawings:c={},drawingsOrder:u=[]}=sd(o);return{id:t,rev:r,locale:Pt.EN_US,title:s,body:a,documentStyle:l,settings:h,drawings:c,drawingsOrder:u,resources:i}}async function cd(e,n,t,r,s){var l,h,c;const o={unitID:n.id,rev:r,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:nd(n)},i={unitID:t,rev:o.rev,type:J.UNIVER_DOC,workbook:void 0,doc:o},a=await s.saveSnapshot(e,{unitID:t,type:J.UNIVER_DOC,snapshot:i});if(vi(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
11
+ ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(c=a.error)==null?void 0:c.message}`);return{snapshot:i}}async function hd(e,n){const t=e.workbook;if(!t)throw new Error("Workbook metadata is not available");const r=[],s=[];return Object.entries(t.blockMeta).forEach(([o,i])=>{const a=i.blocks.map(async l=>{const h={unitID:t.unitID,type:J.UNIVER_SHEET,blockID:l},{block:c}=await n.getSheetBlock({},h);if(c)r.push(c);else throw new Error("Block not found")});s.push(...a)}),await Promise.all(s),r}var Aa=(e=>(e[e.INFO=0]="INFO",e[e.STOP=1]="STOP",e[e.WARNING=2]="WARNING",e))(Aa||{}),Ta=(e=>(e[e.DISABLED=0]="DISABLED",e[e.FULL_ALPHA=1]="FULL_ALPHA",e[e.FULL_HANGUL=2]="FULL_HANGUL",e[e.FULL_KATAKANA=3]="FULL_KATAKANA",e[e.HALF_ALPHA=4]="HALF_ALPHA",e[e.HALF_HANGUL=5]="HALF_HANGUL",e[e.HALF_KATAKANA=6]="HALF_KATAKANA",e[e.HIRAGANA=7]="HIRAGANA",e[e.NO_CONTROL=8]="NO_CONTROL",e[e.OFF=9]="OFF",e[e.ON=10]="ON",e))(Ta||{}),ya=(e=>(e.BETWEEN="between",e.EQUAL="equal",e.GREATER_THAN="greaterThan",e.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",e.LESS_THAN="lessThan",e.LESS_THAN_OR_EQUAL="lessThanOrEqual",e.NOT_BETWEEN="notBetween",e.NOT_EQUAL="notEqual",e))(ya||{}),Da=(e=>(e.CUSTOM="custom",e.LIST="list",e.LIST_MULTIPLE="listMultiple",e.NONE="none",e.TEXT_LENGTH="textLength",e.DATE="date",e.TIME="time",e.WHOLE="whole",e.DECIMAL="decimal",e.CHECKBOX="checkbox",e))(Da||{}),Ma=(e=>(e.VALID="valid",e.INVALID="invalid",e.VALIDATING="validating",e))(Ma||{});const dd=["script","style","meta","comment","link"];function fd(e){return!(e.length===0||e.length>31||e.startsWith("'")||e.endsWith("'")||/[:\\\/\?\*\[\]]/.test(e))}ja();exports.ABCToNumber=tu;exports.AbsoluteRefType=Se;exports.ActionIterator=wr;exports.AlignTypeH=bo;exports.AlignTypeV=Ao;exports.ArrangeTypeEnum=Do;exports.ArrowsAndMarkersShapes=qs;exports.AutoFillSeries=Fs;exports.BaselineOffset=Gt;exports.BasicShapes=Qs;exports.BlockType=ao;exports.BooleanNumber=K;exports.BorderStyleTypes=he;exports.BorderType=Hs;exports.BulletAlignment=Rt;exports.COLORS=lr;exports.CellValueType=Mt;exports.ClientSnapshotServerService=ed;exports.Color=Ut;exports.ColorBuilder=$n;exports.ColorKit=rt;exports.ColorType=qe;exports.ColumnSeparatorType=ho;exports.CommandType=hn;exports.CommonHideTypes=js;exports.ConfigService=Vi;exports.ContentAlignment=vo;exports.ContextService=pi;exports.CopyPasteType=$s;exports.CustomDecorationType=io;exports.CustomRangeType=oo;exports.DEFAULT_CELL=du;exports.DEFAULT_DOC=qr;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Wa;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Eh;exports.DEFAULT_RANGE=cu;exports.DEFAULT_RANGE_ARRAY=uu;exports.DEFAULT_SELECTION=hu;exports.DEFAULT_SLIDE=Qo;exports.DEFAULT_STYLES=vn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Xi;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Bc;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Ji;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=zc;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=qi;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Vc;exports.DEFAULT_WORKSHEET_ROW_COUNT=Yi;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Wc;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Qi;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Gc;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Zi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Kc;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ha;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=ca;exports.DOCS_ZEN_EDITOR_UNIT_ID_KEY=mh;exports.DashStyleType=Ro;exports.DataStreamTreeNodeType=Si;exports.DataStreamTreeTokenType=gt;exports.DataValidationErrorStyle=Aa;exports.DataValidationImeMode=Ta;exports.DataValidationOperator=ya;exports.DataValidationRenderMode=va;exports.DataValidationStatus=Ma;exports.DataValidationType=Da;exports.DependentOn=yh;exports.DesktopLogService=Ei;exports.DeveloperMetadataVisibility=Ws;exports.Dimension=Bs;exports.Direction=Gs;exports.Disposable=Ae;exports.DisposableCollection=Mr;exports.DocStyleType=ro;exports.DocumentDataModel=xt;exports.DocumentFlavor=lo;exports.DrawingTypeEnum=Mo;exports.EDITOR_ACTIVATED=na;exports.EXTENSION_NAMES=qo;exports.Entry=ur;exports.EntryIterator=Ko;exports.ErrorService=Ki;exports.EventState=Oa;exports.EventSubject=Yh;exports.FOCUSING_COMMON_DRAWINGS=ah;exports.FOCUSING_DOC=wn;exports.FOCUSING_EDITOR_BUT_HIDDEN=nh;exports.FOCUSING_EDITOR_INPUT_FORMULA=rh;exports.FOCUSING_EDITOR_STANDALONE=oh;exports.FOCUSING_FORMULA_EDITOR=ra;exports.FOCUSING_SHEET=tn;exports.FOCUSING_SLIDE=bn;exports.FOCUSING_UNIVER_EDITOR=sh;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=ih;exports.FollowNumberWithType=so;exports.FontItalic=Tn;exports.FontStyleType=Oo;exports.FontWeight=yn;exports.FormatType=Vs;exports.GlyphType=Jt;exports.GridType=uo;exports.HLSColor=to;exports.HorizontalAlign=Dt;exports.IAuthzIoService=Ca;exports.ICommandService=dn;exports.IConfigService=Gi;exports.IContextService=cn;exports.ILocalStorageService=Qh;exports.ILogService=St;exports.IPermissionService=es;exports.IResourceLoaderService=ts;exports.IResourceManagerService=zn;exports.ISnapshotServerService=Jh;exports.IUndoRedoService=Xn;exports.IUniverInstanceService=Kt;exports.Inject=it;exports.Injector=pt;exports.InterceptorManager=Zh;exports.InterpolationPointType=Ks;exports.JSON1=Lc;exports.JSONX=Lt;exports.KeyIterator=Go;exports.LRUHelper=qt;exports.LRUMap=zo;exports.LifecycleStages=de;exports.LocaleService=nn;exports.LocaleType=Pt;exports.LogLevel=mi;exports.MOVE_BUFFER_VALUE=Qt;exports.Many=ri;exports.MemoryCursor=$i;exports.NamedStyleType=mo;exports.NilCommand=Ri;exports.NumberUnitType=wo;exports.ObjectMatrix=ot;exports.ObjectRelativeFromH=So;exports.ObjectRelativeFromV=No;exports.OnLifecycle=sa;exports.Optional=si;exports.OtherShapes=Zs;exports.PRESET_LIST_TYPE=fc;exports.PageElementType=Uo;exports.PageOrientType=yo;exports.PageType=yr;exports.ParagraphElementType=_o;exports.PermissionService=la;exports.PermissionStatus=Jr;exports.Plugin=Ar;exports.PositionedObjectLayoutType=po;exports.PresetListType=Pn;exports.ProtectionType=zs;exports.RANGE_TYPE=oe;exports.RCDisposable=Gl;exports.RGBA_PAREN=Ya;exports.RGB_PAREN=za;exports.ROTATE_BUFFER_VALUE=xs;exports.Range=Vt;exports.Rectangle=vt;exports.RediConsumer=hi;exports.RediContext=un;exports.RediError=Le;exports.RediProvider=Fr;exports.RedoCommand=pa;exports.RedoCommandId=fa;exports.RefAlias=eu;exports.Registry=jr;exports.RegistryAsMap=$r;exports.RelativeDate=Ys;exports.RelativeSlideLink=Lo;exports.ResourceManagerService=ua;exports.RgbColor=Dn;exports.RxDisposable=Bl;exports.SectionType=co;exports.Self=li;exports.SheetTypes=Hn;exports.SheetViewModel=ta;exports.SkipSelf=ai;exports.SliceBodyType=Gr;exports.SlideDataModel=Zr;exports.SpacingRule=Eo;exports.SpecialShapes=Js;exports.Styles=zi;exports.THEME_COLORS=eo;exports.TabStopAlignment=Co;exports.TextDecoration=Xs;exports.TextDirection=on;exports.TextDirectionType=fo;exports.TextX=Ot;exports.TextXActionType=Z;exports.ThemeColor=Mn;exports.ThemeColorType=He;exports.ThemeColors=jn;exports.ThemeService=ns;exports.Tools=x;exports.UndoCommand=ga;exports.UndoCommandId=_a;exports.UnitModel=Vn;exports.Univer=kh;exports.UniverInstanceType=J;exports.UpdateDocsAttributeType=ke;exports.ValueIterator=Vo;exports.VerticalAlign=Wt;exports.WidthType=Io;exports.WithDependency=ec;exports.WithNew=ui;exports.Worksheet=ln;exports.WrapStrategy=Bt;exports.WrapTextType=go;exports.afterInitApply=dc;exports.b64DecodeUnicode=rs;exports.b64EncodeUnicode=td;exports.binarySearchArray=Ps;exports.cellToRange=Ll;exports.characterSpacingControlType=To;exports.checkForSubstrings=xl;exports.checkIfMove=Ba;exports.checkParagraphHasBullet=Pl;exports.checkParagraphHasIndent=kl;exports.checkParagraphHasIndentByStyle=jo;exports.codeToBlob=Va;exports.composeBody=Or;exports.composeInterceptors=Sa;exports.concatMatrixArray=Ql;exports.connectDependencies=qu;exports.connectInjector=Qu;exports.convertBodyToHtml=lu;exports.covertTextRunToHtml=_r;exports.createDefaultUser=Fn;exports.createIdentifier=Ve;exports.createInterceptorKey=qh;exports.createInternalEditorID=Rh;exports.createRowColIter=fr;exports.debounce=au;exports.dedupe=Vl;exports.deepCompare=Dr;exports.deleteContent=Wo;exports.extractPureTextFromCell=Yc;exports.forwardRef=wu;exports.fromCallback=Ci;exports.fromEventSubject=Xh;exports.fromObservable=Wl;exports.generateRandomId=ko;exports.generateTemporarySnap=id;exports.getArrayLength=It;exports.getBodySlice=an;exports.getBodySliceHtml=In;exports.getBorderStyleType=Dl;exports.getCellInfoInMergeData=fl;exports.getCellValueType=ul;exports.getColorStyle=ut;exports.getCustomDecorationSlice=Hi;exports.getCustomRangeSlice=Fi;exports.getDocsUpdateBody=Ml;exports.getReverseDirection=Ka;exports.getSheetBlocksFromSnapshot=hd;exports.getWorksheetUID=th;exports.groupBy=Yl;exports.handleStyleToString=yl;exports.hashAlgorithm=Hl;exports.horizontalLineSegmentsSubtraction=Wn;exports.insertMatrixArray=cr;exports.insertTextToContent=$o;exports.isAsyncDependencyItem=Er;exports.isAsyncHook=On;exports.isBlackColor=il;exports.isBooleanString=Bh;exports.isCellCoverable=bl;exports.isCellV=hl;exports.isClassDependencyItem=gr;exports.isCtor=Lr;exports.isDisposable=Cr;exports.isEmptyCell=Fo;exports.isFactoryDependencyItem=pr;exports.isFormulaId=Tl;exports.isFormulaString=Al;exports.isICellData=ll;exports.isInternalEditorID=Ch;exports.isNullCell=cl;exports.isNumeric=Ia;exports.isRangesEqual=Hh;exports.isRealNum=Fl;exports.isSafeNumeric=Wh;exports.isSameStyleTextRun=Ho;exports.isUnitRangesEqual=jh;exports.isValidRange=Ul;exports.isValueDependencyItem=mr;exports.isWhiteColor=al;exports.makeArray=Xl;exports.makeCellRangeToRangeData=wl;exports.makeCellToSelection=Nl;exports.mergeOverrideWithDependencies=Ra;exports.mergeSets=Gh;exports.mergeWorksheetSnapshotWithDefault=ea;exports.moveMatrixArray=dr;exports.moveRangeByOffset=mu;exports.nameCharacterCheck=fd;exports.normalizeBody=Nc;exports.normalizeTextRuns=Wr;exports.numberToABC=ru;exports.numberToListABC=su;exports.orderSearchArray=ks;exports.queryObjectMatrix=pu;exports.remove=Bn;exports.repeatStringNumTimes=Xo;exports.replaceInDocumentBody=zh;exports.requestImmediateMacroTask=Kh;exports.rotate=zl;exports.runOnLifecycle=Kn;exports.searchArray=Ga;exports.selectionToArray=dl;exports.sequence=gi;exports.sequenceAsync=_i;exports.sequenceExecute=Hr;exports.sequenceExecuteAsync=hc;exports.setDependencies=Bu;exports.shallowEqual=$h;exports.skipParseTagNames=dd;exports.sliceMatrixArray=ql;exports.sortRules=ou;exports.sortRulesByDesc=iu;exports.sortRulesFactory=kt;exports.spliceArray=hr;exports.takeAfter=Ii;exports.textDecoder=Qn;exports.textEncoder=fn;exports.throttle=Vh;exports.toDisposable=Ne;exports.transformDocumentDataToSnapshot=cd;exports.transformSnapshotToDocumentData=ud;exports.transformSnapshotToWorkbookData=ld;exports.transformWorkbookDataToSnapshot=ad;exports.updateAttributeByDelete=Wi;exports.updateAttributeByInsert=Bi;exports.useDependency=Yu;exports.useDependencyContext=sc;exports.useDependencyContextValue=oc;exports.useDependencyValue=fi;exports.useInjector=di;exports.useObservable=nc;exports.useUpdateBinder=rc;