@univerjs/core 0.2.4-alpha.0 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/cjs/index.js +9 -11
  2. package/lib/es/index.js +4133 -5118
  3. package/lib/types/docs/data-model/text-x/text-x.d.ts +1 -0
  4. package/lib/types/index.d.ts +0 -1
  5. package/lib/types/services/__tests__/index.d.ts +7 -7
  6. package/lib/types/services/authz-io/type.d.ts +1 -1
  7. package/lib/types/services/command/command.service.d.ts +2 -2
  8. package/lib/types/services/config/config.service.d.ts +1 -1
  9. package/lib/types/services/context/context.service.d.ts +1 -1
  10. package/lib/types/services/instance/instance.service.d.ts +2 -2
  11. package/lib/types/services/lifecycle/lifecycle.d.ts +1 -1
  12. package/lib/types/services/lifecycle/lifecycle.service.d.ts +1 -1
  13. package/lib/types/services/local-storage/local-storage.service.d.ts +1 -1
  14. package/lib/types/services/log/log.service.d.ts +1 -1
  15. package/lib/types/services/permission/type.d.ts +1 -1
  16. package/lib/types/services/plugin/plugin-override.d.ts +1 -1
  17. package/lib/types/services/plugin/plugin.d.ts +1 -1
  18. package/lib/types/services/plugin/plugin.service.d.ts +1 -1
  19. package/lib/types/services/resource-loader/type.d.ts +1 -1
  20. package/lib/types/services/resource-manager/type.d.ts +2 -2
  21. package/lib/types/services/snapshot/snapshot-server.service.d.ts +1 -1
  22. package/lib/types/services/undoredo/undoredo.service.d.ts +2 -2
  23. package/lib/types/shared/lifecycle.d.ts +1 -1
  24. package/lib/types/shared/lru/lru-map.d.ts +1 -1
  25. package/lib/types/shared/rxjs.d.ts +1 -1
  26. package/lib/types/sheets/view-model.d.ts +1 -1
  27. package/lib/types/types/interfaces/i-document-data.d.ts +3 -0
  28. package/lib/types/univer.d.ts +1 -1
  29. package/lib/umd/index.js +9 -11
  30. package/package.json +4 -4
  31. package/lib/types/common/di.d.ts +0 -17
package/lib/cjs/index.js CHANGED
@@ -1,11 +1,9 @@
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:
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.
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;
1
+ "use strict";var Lo=Object.defineProperty;var Do=(t,n,e)=>n in t?Lo(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var _=(t,n,e)=>Do(t,typeof n!="symbol"?n+"":n,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("rxjs"),cn=require("rxjs/operators"),ut=require("@wendellhu/redi");function yo(t,n){for(var e=0;e<n.length;e++){const s=n[e];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function xo(){Po()}const rn=typeof global<"u"?global:typeof self<"u"?self:window;function Po(){typeof rn.requestIdleCallback!="function"&&(rn.requestIdleCallback=function(e){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof rn.cancelIdleCallback!="function"&&(rn.cancelIdleCallback=function(e){clearTimeout(e)})}const ko="__default_document_sub_component_id20231101__",We=2,Xs=1;function Ho(t,n){if(n==null||t==null)return!0;const{left:e=0,top:s=0,height:r=0,width:i=0,angle:o=0}=n,{left:a=0,top:l=0,height:h=0,width:c=0,angle:u=0}=t,d=c,f=h,m=i,E=r;return Math.abs(a-e)>We||Math.abs(l-s)>We||Math.abs(d-m)>We||Math.abs(f-E)>We||Math.abs(u-o)>Xs}function qs(t,n){let e=0,s=t.length-1;for(;e<=s;){const r=Math.floor((s+e)/2);if(n<t[r]&&(r===0||n>=t[r-1]))return r;if(n>=t[r])e=r+1;else if(n<t[r])s=r-1;else return-1}return-1}function Zs(t,n){let e=0,s=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(s=t[o],o===0?r=0:r=t[o-1],n>=r&&n<=s){i=o;break}if(s=t[e],e===0?r=0:r=t[e-1],n>=r&&n<s){i=e;break}e++,o--}return i}function Fo(t,n){let e=t.length-1;return n<0?-1:n<t[0]?0:n>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||n<=t[20]||n>=t[e-20]?e=Zs(t,n):e=qs(t,n),e)}function $o(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var Js=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Js||{}),dt=(t=>(t[t.NONE=0]="NONE",t[t.THIN=1]="THIN",t[t.HAIR=2]="HAIR",t[t.DOTTED=3]="DOTTED",t[t.DASHED=4]="DASHED",t[t.DASH_DOT=5]="DASH_DOT",t[t.DASH_DOT_DOT=6]="DASH_DOT_DOT",t[t.DOUBLE=7]="DOUBLE",t[t.MEDIUM=8]="MEDIUM",t[t.MEDIUM_DASHED=9]="MEDIUM_DASHED",t[t.MEDIUM_DASH_DOT=10]="MEDIUM_DASH_DOT",t[t.MEDIUM_DASH_DOT_DOT=11]="MEDIUM_DASH_DOT_DOT",t[t.SLANT_DASH_DOT=12]="SLANT_DASH_DOT",t[t.THICK=13]="THICK",t))(dt||{}),Qs=(t=>(t.TOP="top",t.BOTTOM="bottom",t.LEFT="left",t.RIGHT="right",t.NONE="none",t.ALL="all",t.OUTSIDE="outside",t.INSIDE="inside",t.HORIZONTAL="horizontal",t.VERTICAL="vertical",t.TLBR="tlbr",t.TLBC_TLMR="tlbc_tlmr",t.TLBR_TLBC_TLMR="tlbr_tlbc_tlmr",t.BLTR="bl_tr",t.MLTR_BCTR="mltr_bctr",t))(Qs||{}),zt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(zt||{}),tr=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(tr||{}),er=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(er||{}),nr=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(nr||{}),sr=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(sr||{}),rr=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(rr||{});function Wo(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var ir=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(ir||{}),or=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))(or||{}),Te=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t.ZH_TW="zhTW",t.VI_VN="viVN",t))(Te||{}),ar=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(ar||{}),lr=(t=>(t[t.RELATIVE_DATE_UNSPECIFIED=0]="RELATIVE_DATE_UNSPECIFIED",t[t.PAST_YEAR=1]="PAST_YEAR",t[t.PAST_MONTH=2]="PAST_MONTH",t[t.PAST_WEEK=3]="PAST_WEEK",t[t.YESTERDAY=4]="YESTERDAY",t[t.TODAY=5]="TODAY",t[t.TOMORROW=6]="TOMORROW",t))(lr||{}),An=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(An||{}),qe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",t))(qe||{}),ur=(t=>(t[t.DASH=0]="DASH",t[t.DASH_DOT_DOT_HEAVY=1]="DASH_DOT_DOT_HEAVY",t[t.DASH_DOT_HEAVY=2]="DASH_DOT_HEAVY",t[t.DASHED_HEAVY=3]="DASHED_HEAVY",t[t.DASH_LONG=4]="DASH_LONG",t[t.DASH_LONG_HEAVY=5]="DASH_LONG_HEAVY",t[t.DOT_DASH=6]="DOT_DASH",t[t.DOT_DOT_DASH=7]="DOT_DOT_DASH",t[t.DOTTED=8]="DOTTED",t[t.DOTTED_HEAVY=9]="DOTTED_HEAVY",t[t.DOUBLE=10]="DOUBLE",t[t.NONE=11]="NONE",t[t.SINGLE=12]="SINGLE",t[t.THICK=13]="THICK",t[t.WAVE=14]="WAVE",t[t.WAVY_DOUBLE=15]="WAVY_DOUBLE",t[t.WAVY_HEAVY=16]="WAVY_HEAVY",t[t.WORDS=17]="WORDS",t))(ur||{}),Ne=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(Ne||{}),xe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(xe||{}),Pe=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(Pe||{}),En=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(En||{}),pn=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(pn||{}),ke=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(ke||{}),K=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(K||{}),Ae=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Ae||{}),Ht=(t=>(t[t.DARK1=0]="DARK1",t[t.LIGHT1=1]="LIGHT1",t[t.DARK2=2]="DARK2",t[t.LIGHT2=3]="LIGHT2",t[t.ACCENT1=4]="ACCENT1",t[t.ACCENT2=5]="ACCENT2",t[t.ACCENT3=6]="ACCENT3",t[t.ACCENT4=7]="ACCENT4",t[t.ACCENT5=8]="ACCENT5",t[t.ACCENT6=9]="ACCENT6",t[t.HYPERLINK=10]="HYPERLINK",t[t.FOLLOWED_HYPERLINK=11]="FOLLOWED_HYPERLINK",t))(Ht||{}),bn=(t=>(t.OFFICE="Office",t.OFFICE_2007_2010="Office 2007-2010",t.GRAYSCALE="Grayscale",t.BLUE_WARM="Blue Warm",t.BLUE="Blue",t.BLUE_II="Blue II",t.BLUE_GREEN="Blue Green",t.GREEN="Green",t.GREEN_YELLOW="Green Yellow",t.YELLOW="Yellow",t.YELLOW_ORANGE="Yellow Orange",t.ORANGE="Orange",t.ORANGE_RED="Orange Red",t.RED_ORANGE="Red Orange",t.RED="Red",t.RED_VIOLET="Red Violet",t.VIOLET="Violet",t.VIOLET_II="Violet II",t.MEDIAN="Median",t.PAPER="Paper",t.MARQUEE="Marquee",t.SLIPSTREAM="Slipstream",t.Aspect="Aspect",t))(bn||{}),cr=(t=>(t.Line="line",t.LineInv="lineInv",t.Triangle="triangle",t.RtTriangle="rtTriangle",t.Rect="rect",t.Diamond="diamond",t.Parallelogram="parallelogram",t.Trapezoid="trapezoid",t.NonIsocelesTrapezoid="nonIsocelesTrapezoid",t.Pentagon="pentagon",t.Hexagon="hexagon",t.Heptagon="heptagon",t.Octagon="octagon",t.Decagon="decagon",t.Dodecagon="dodecagon",t.Star4="star4",t.Star5="star5",t.Star6="star6",t.Star7="star7",t.Star8="star8",t.Star10="star10",t.Star12="star12",t.Star16="star16",t.Star24="star24",t.Star32="star32",t.RoundRect="roundRect",t.Round1Rect="round1Rect",t.Round2SameRect="round2SameRect",t.Round2DiagRect="round2DiagRect",t.Ellipse="ellipse",t))(cr||{}),hr=(t=>(t.RightArrow="rightArrow",t.LeftArrow="leftArrow",t.UpArrow="upArrow",t.DownArrow="downArrow",t.LeftRightArrow="leftRightArrow",t.UpDownArrow="upDownArrow",t.QuadArrow="quadArrow",t.LeftRightUpArrow="leftRightUpArrow",t.BentArrow="bentArrow",t.UturnArrow="uturnArrow",t.CircularArrow="circularArrow",t.NotchedRightArrow="notchedRightArrow",t.HomePlate="homePlate",t.Chevron="chevron",t.LeftCircularArrow="leftCircularArrow",t.LeftRightCircularArrow="leftRightCircularArrow",t))(hr||{}),dr=(t=>(t.Plaque="plaque",t.Can="can",t.Cube="cube",t.Bevel="bevel",t.Donut="donut",t.NoSmoking="noSmoking",t.BlockArc="blockArc",t.FoldedCorner="foldedCorner",t))(dr||{}),fr=(t=>(t.SmileyFace="smileyFace",t.Heart="heart",t.LightningBolt="lightningBolt",t.Sun="sun",t.Moon="moon",t.Cloud="cloud",t.Arc="arc",t.Backpack="backpack",t.Frame="frame",t.HalfFrame="halfFrame",t.Corner="corner",t.Chord="chord",t.Pie="pie",t.Teardrop="teardrop",t.WedgeRectCallout="wedgeRectCallout",t.WedgeRRectCallout="wedgeRRectCallout",t.WedgeEllipseCallout="wedgeEllipseCallout",t.CloudCallout="cloudCallout",t.BorderCallout1="borderCallout1",t.BorderCallout2="borderCallout2",t.BorderCallout3="borderCallout3",t.AccentCallout1="accentCallout1",t.AccentCallout2="accentCallout2",t.AccentCallout3="accentCallout3",t.Callout1="callout1",t.Callout2="callout2",t.Callout3="callout3",t.ActionButtonBackPrevious="actionButtonBackPrevious",t.ActionButtonEnd="actionButtonEnd",t.ActionButtonForwardNext="actionButtonForwardNext",t.ActionButtonHelp="actionButtonHelp",t.ActionButtonHome="actionButtonHome",t.ActionButtonInformation="actionButtonInformation",t.ActionButtonMovie="actionButtonMovie",t.ActionButtonReturn="actionButtonReturn",t.ActionButtonSound="actionButtonSound",t))(fr||{});const _r={[bn.OFFICE]:{[Ht.ACCENT1]:"#4472C4",[Ht.ACCENT2]:"#ED7D31",[Ht.ACCENT3]:"#A5A5A5",[Ht.ACCENT4]:"#70AD47",[Ht.ACCENT5]:"#5B9BD5",[Ht.ACCENT6]:"#70AD47",[Ht.DARK1]:"#000000",[Ht.DARK2]:"#44546A",[Ht.LIGHT1]:"#FFFFFF",[Ht.LIGHT2]:"#E7E6E6",[Ht.HYPERLINK]:"#0563C1",[Ht.FOLLOWED_HYPERLINK]:"#954F72"}};class vn{constructor(){_(this,"_themeValue",Ht.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=zt.UNSUPPORTED,this._themeColors=bn.OFFICE,this._themeTint=0}asRgbColor(){return new Rn(this._rgbValue,this)}asThemeColor(){return new Cn(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case zt.THEME:return this.asThemeColor();case zt.RGB:return this.asRgbColor();case zt.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=zt.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=zt.THEME,this._themeColors=n}setThemeTint(n){this._colorType=zt.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=zt.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class be{constructor(n){_(this,"_builder");this._builder=n}static rgbColorToHexValue(n){return`#${((1<<24)+(n.getRed()<<16)+(n.getGreen()<<8)+n.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(n){n?n.indexOf("#")>-1&&(n=n.substring(1)):n="#000000";const e=+`0x${n[0]}${n[1]}`,s=+`0x${n[2]}${n[3]}`,r=+`0x${n[4]}${n[5]}`;return new vn().setRgbColor(`rgb(${e},${s},${r})`).asRgbColor()}static hexToRgbString(n){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,(i,o,a,l)=>o+o+a+a+l+l);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),a=Number.parseInt(s[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new be(this._builder)}equals(n){return!1}}class gr{constructor(n){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const e=n.getRed()/255,s=n.getGreen()/255,r=n.getBlue()/255,i=n.getAlpha()/255,o=Math.min(e,Math.min(s,r)),a=Math.max(e,Math.max(s,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),e===a&&(this._hue=(s-r)/l),s===a&&(this._hue=2+(r-e)/l),r===a&&(this._hue=4+(e-s)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const n=new vn;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,s,i),a=this.setColor(e,s,r),l=r-1/3,h=this.setColor(e,s,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(h*255)},${this._alpha*255})`),n.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(n,e,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=e+(n-e)*6*s:2*s<1?r=n:3*s<2?r=e+(n-e)*(2/3-s)*6:r=e,r}setLightness(n){this._lightness=n}}const Yt=class Yt extends be{constructor(e,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=e.match(Yt.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=e.match(Yt.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return be.rgbColorToHexValue(this)}getRed(){let e=this._red+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+Yt.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return zt.RGB}clone(){return new Yt(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof Yt?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(Yt,"RGB_COLOR_AMT",0),_(Yt,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(Yt,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let Rn=Yt;const _e=class _e extends be{constructor(e,s,r,i){super(i);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=e,this._themeTint=s,this._themeColors=r}lumValue(e,s){if(e==null)return s;let r;return e<0?r=s*(1+e):r=s*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=_r[this._themeColors];if(e==null)throw new Error("not find themeColors type");const s=e[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(_e._cacheThemeColor.has(this._themeColors)){if(r=_e._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,_e._cacheThemeColor.set(this._themeColors,r);const i=new gr(be.hexValueToRgbColor(s));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new _e(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof _e?e._themeColorType===this._themeColorType:!1}getColorType(){return zt.THEME}getThemeColorType(){return this._themeColorType}};_(_e,"_cacheThemeColor",new Map);let Cn=_e;const Bo="rgb(",Go="rgba(",Yn={aliceBlue:[240,248,255],antiqueWhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blancheAlmond:[255,235,205],blue:[0,0,255],blueViolet:[138,43,226],brown:[165,42,42],burlyWood:[222,184,135],cadetBlue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornFlowerBlue:[100,149,237],cornSilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkCyan:[0,139,139],darkGoldenrod:[184,132,11],darkGray:[169,169,169],darkGreen:[0,100,0],darkGrey:[169,169,169],darkKhaki:[189,183,107],darkMagenta:[139,0,139],darkOliveGreen:[85,107,47],darkOrange:[255,140,0],darkOrchid:[153,50,204],darkRed:[139,0,0],darkSalmon:[233,150,122],darkSeaGreen:[143,188,143],darkSlateBlue:[72,61,139],darkSlateGray:[47,79,79],darkSlateGrey:[47,79,79],darkTurquoise:[0,206,209],darkViolet:[148,0,211],deepPink:[255,20,147],deepSkyBlue:[0,191,255],dimGray:[105,105,105],dimGrey:[105,105,105],dodgerBlue:[30,144,255],firebrick:[178,34,34],floralWhite:[255,255,240],forestGreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostWhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenYellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotPink:[255,105,180],indianRed:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderBlush:[255,240,245],lawnGreen:[124,252,0],lemonChiffon:[255,250,205],lightblue:[173,216,230],lightCoral:[240,128,128],lightCyan:[224,255,255],lightGoldenrodYellow:[250,250,210],lightGray:[211,211,211],lightGreen:[144,238,144],lightGrey:[211,211,211],lightPink:[255,182,193],lightSalmon:[255,160,122],lightSeaGreen:[32,178,170],lightSkyBlue:[135,206,250],lightSlateGray:[119,136,153],lightSlateGrey:[119,136,153],lightSteelBlue:[176,196,222],lightYellow:[255,255,224],lime:[0,255,0],limeGreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumAquamarine:[102,205,170],mediumBlue:[0,0,205],mediumOrchid:[186,85,211],mediumPurple:[147,112,219],mediumSeaGreen:[60,179,113],mediumSlateBlue:[123,104,238],mediumSpringGreen:[0,250,154],mediumTurquoise:[72,209,204],mediumVioletRed:[199,21,133],midBightBlue:[25,25,112],mintCream:[245,255,250],mistyRose:[255,228,225],moccasin:[255,228,181],navajoWhite:[255,222,173],navy:[0,0,128],oldLace:[253,245,230],olive:[128,128,0],oliveDrab:[107,142,35],orange:[255,165,0],orangeRed:[255,69,0],orchid:[218,112,214],paleGoldenrod:[238,232,170],paleGreen:[152,251,152],paleTurquoise:[175,238,238],paleVioletRed:[219,112,147],papayaWhip:[255,239,213],peachPuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderBlue:[176,224,230],purple:[128,0,128],rebeccaPurple:[102,51,153],red:[255,0,0],rosyBrown:[188,143,143],royalBlue:[65,105,225],saddleBrown:[139,69,19],salmon:[250,128,114],sandyBrown:[244,164,96],seaGreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyBlue:[135,206,235],slateBlue:[106,90,205],slateGray:[119,128,144],slateGrey:[119,128,144],snow:[255,255,250],springGreen:[0,255,127],steelBlue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whiteSmoke:[245,245,245],yellow:[255,255,0],yellowGreen:[154,205,5]};class te{constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof te){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=mr(n);if(e==null){this._setNullColor();return}this._color=e;const s=zo(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var h,c;s=Math.min(1,Math.max(0,s));const r=new te(n).toRgb(),i=new te(e).toRgb(),o=(h=r.a)!=null?h:1,a=(c=i.a)!=null?c:1,l={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(a-o)*s+o};return new te(l)}static getContrastRatio(n,e){const s=new te(n).getLuminance(),r=new te(e).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:e,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${n},${e},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:e,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,a=[on(Math.round(e).toString(16)),on(Math.round(s).toString(16)),on(Math.round(r).toString(16)),on(Math.round(i*255).toString(16))];return n&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Jo(this.toRgb())}toHsl(){return Zo(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new te(e)}setAlpha(n){return new te({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:e,b:s}=this.toRgb();return n=Fn(n),e=Fn(e),s=Fn(s),Number((.2126*n+.7152*e+.0722*s).toFixed(3))}getBrightness(){const{r:n,g:e,b:s}=this.toRgb();return(n*299+e*587+s*114)/1e3}getAlpha(){var n;return(n=this._color.a)!=null?n:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const on=t=>t.length===1?`0${t}`:t,Fn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),mr=t=>{if(ta(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const n=t.trim();if(Yn[n]){const e=Yn[n],s={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return s.a=e[3]||1,s}if(n.startsWith("#"))return jo(n);if(n.startsWith("rgb"))return Vo(n);if(n.startsWith("hsl"))return Ko(n);if(n.startsWith("hsv"))return Yo(n)},jo=t=>{const n=t.substring(1),e=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let s=n.match(e);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},Vo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Ko=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Yo=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},zo=t=>{const n=mr(t);if(n!=null)return"r"in n?n:"l"in n?Xo(n):qo(n)},$n=(t,n,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t),Xo=t=>{let{h:n,s:e,l:s}=t;n/=360,e/=100,s/=100;let r=0,i=0,o=0;if(e===0)r=i=o=s;else{const l=s<.5?s*(1+e):s+e-s*e,h=2*s-l;r=$n(h,l,n+1/3),i=$n(h,l,n),o=$n(h,l,n-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},qo=t=>{let{h:n,s:e,v:s}=t;n=n/360*6,e/=100,s/=100;const r=Math.floor(n),i=n-r,o=s*(1-e),a=s*(1-i*e),l=s*(1-(1-i)*e),h=r%6,c=[s,a,o,o,l,s][h],u=[l,s,s,a,o,o][h],d=[o,o,l,s,s,a][h],f={r:c*255,g:u*255,b:d*255};return t.a!==void 0&&(f.a=t.a),f},Zo=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const c=r-i;switch(l=o>.5?c/(2-r-i):c/(r+i),r){case n:a=(e-s)/c+(e<s?6:0);break;case e:a=(s-n)/c+2;break;default:a=(n-e)/c+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},Jo=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s);let o;const a=r,l=r-i,h=r===0?0:l/r;if(r===i)o=0;else{switch(r){case n:o=(e-s)/l+(e<s?6:0);break;case e:o=(s-n)/l+2;break;default:o=(n-e)/l+4;break}o/=6}const c={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(a*100)};return t.a!==void 0&&(c.a=t.a),c},Qo=t=>t==null,ta=t=>!Qo(t)&&typeof t=="object";function ea(t){const n=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}function na(t){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}var Pt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(Pt||{});function sa(t){return t&&(t.s!==void 0||t.p!==void 0||t.v!==void 0||t.t!==void 0||t.f!==void 0||t.si!==void 0)}function ra(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Ae.STRING;if(typeof t.v=="number")return Ae.NUMBER;if(typeof t.v=="boolean")return Ae.BOOLEAN}function ia(t){if(t==null)return!0;const{v:n,f:e,si:s,p:r,s:i,custom:o}=t;return!(!(n==null||typeof n=="string"&&n.length===0)||e!=null&&e.length>0||s!=null&&s.length>0||r!=null||o!=null)}function oa(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Er=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Er||{}),pr=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(pr||{}),je=(t=>(t[t.GLYPH_TYPE_UNSPECIFIED=0]="GLYPH_TYPE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.DECIMAL=2]="DECIMAL",t[t.ZERO_DECIMAL=3]="ZERO_DECIMAL",t[t.UPPER_ALPHA=4]="UPPER_ALPHA",t[t.ALPHA=5]="ALPHA",t[t.UPPER_ROMAN=6]="UPPER_ROMAN",t[t.ROMAN=7]="ROMAN",t))(je||{}),fe=(t=>(t[t.BULLET_ALIGNMENT_UNSPECIFIED=0]="BULLET_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(fe||{}),Rr=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t[t.MENTION=6]="MENTION",t[t.UNI_FORMULA=7]="UNI_FORMULA",t))(Rr||{}),Cr=(t=>(t[t.COMMENT=0]="COMMENT",t))(Cr||{}),Ir=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(Ir||{}),Sr=(t=>(t[t.TRADITIONAL=0]="TRADITIONAL",t[t.MODERN=1]="MODERN",t))(Sr||{}),Or=(t=>(t[t.DEFAULT=0]="DEFAULT",t[t.LINES=1]="LINES",t[t.LINES_AND_CHARS=2]="LINES_AND_CHARS",t[t.SNAP_TO_CHARS=3]="SNAP_TO_CHARS",t))(Or||{}),Nr=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(Nr||{}),Ar=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(Ar||{}),br=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(br||{}),vr=(t=>(t[t.TEXT_RUN=0]="TEXT_RUN",t[t.AUTO_TEXT=1]="AUTO_TEXT",t[t.PAGE_BREAK=2]="PAGE_BREAK",t[t.COLUMN_BREAK=3]="COLUMN_BREAK",t[t.FOOT_NOTE_REFERENCE=4]="FOOT_NOTE_REFERENCE",t[t.HORIZONTAL_RULE=5]="HORIZONTAL_RULE",t[t.EQUATION=6]="EQUATION",t[t.DRAWING=7]="DRAWING",t[t.PERSON=8]="PERSON",t[t.RICH_LINK=9]="RICH_LINK",t))(vr||{}),wr=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(wr||{}),Tr=(t=>(t[t.INLINE=0]="INLINE",t[t.WRAP_NONE=1]="WRAP_NONE",t[t.WRAP_POLYGON=2]="WRAP_POLYGON",t[t.WRAP_SQUARE=3]="WRAP_SQUARE",t[t.WRAP_THROUGH=4]="WRAP_THROUGH",t[t.WRAP_TIGHT=5]="WRAP_TIGHT",t[t.WRAP_TOP_AND_BOTTOM=6]="WRAP_TOP_AND_BOTTOM",t))(Tr||{}),Mr=(t=>(t[t.NAMED_STYLE_TYPE_UNSPECIFIED=0]="NAMED_STYLE_TYPE_UNSPECIFIED",t[t.NORMAL_TEXT=1]="NORMAL_TEXT",t[t.TITLE=2]="TITLE",t[t.SUBTITLE=3]="SUBTITLE",t[t.HEADING_1=4]="HEADING_1",t[t.HEADING_2=5]="HEADING_2",t[t.HEADING_3=6]="HEADING_3",t[t.HEADING_4=7]="HEADING_4",t[t.HEADING_5=8]="HEADING_5",t[t.HEADING_6=9]="HEADING_6",t))(Mr||{}),Ur=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Ur||{}),Lr=(t=>(t[t.DASH_STYLE_UNSPECIFIED=0]="DASH_STYLE_UNSPECIFIED",t[t.SOLID=1]="SOLID",t[t.DOT=2]="DOT",t[t.DASH=3]="DASH",t))(Lr||{}),Dr=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(Dr||{}),yr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(yr||{}),xr=(t=>(t[t.CONTENT_ALIGNMENT_UNSPECIFIED=0]="CONTENT_ALIGNMENT_UNSPECIFIED",t[t.CONTENT_ALIGNMENT_UNSUPPORTED=1]="CONTENT_ALIGNMENT_UNSUPPORTED",t[t.TOP=2]="TOP",t[t.MIDDLE=3]="MIDDLE",t[t.BOTTOM=4]="BOTTOM",t))(xr||{}),Pr=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Pr||{}),kr=(t=>(t[t.PAGE=0]="PAGE",t[t.COLUMN=1]="COLUMN",t[t.CHARACTER=2]="CHARACTER",t[t.MARGIN=3]="MARGIN",t[t.INSIDE_MARGIN=4]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.LEFT_MARGIN=6]="LEFT_MARGIN",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(kr||{}),Hr=(t=>(t[t.PAGE=0]="PAGE",t[t.PARAGRAPH=1]="PARAGRAPH",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.TOP_MARGIN=4]="TOP_MARGIN",t[t.BOTTOM_MARGIN=5]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=6]="INSIDE_MARGIN",t[t.OUTSIDE_MARGIN=7]="OUTSIDE_MARGIN",t))(Hr||{}),Fr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t[t.PIXEL=3]="PIXEL",t))(Fr||{}),$r=(t=>(t[t.CENTER=0]="CENTER",t[t.INSIDE=1]="INSIDE",t[t.LEFT=2]="LEFT",t[t.OUTSIDE=3]="OUTSIDE",t[t.RIGHT=4]="RIGHT",t[t.BOTH=5]="BOTH",t[t.DISTRIBUTE=6]="DISTRIBUTE",t))($r||{}),Wr=(t=>(t[t.BOTTOM=0]="BOTTOM",t[t.CENTER=1]="CENTER",t[t.INSIDE=2]="INSIDE",t[t.OUTSIDE=3]="OUTSIDE",t[t.TOP=4]="TOP",t))(Wr||{}),Br=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Br||{}),Gr=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Gr||{}),jr=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))(jr||{}),Vr=(t=>(t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t[t.DRAWING_IMAGE=0]="DRAWING_IMAGE",t[t.DRAWING_SHAPE=1]="DRAWING_SHAPE",t[t.DRAWING_CHART=2]="DRAWING_CHART",t[t.DRAWING_TABLE=3]="DRAWING_TABLE",t[t.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",t[t.DRAWING_VIDEO=5]="DRAWING_VIDEO",t[t.DRAWING_GROUP=6]="DRAWING_GROUP",t[t.DRAWING_UNIT=7]="DRAWING_UNIT",t[t.DRAWING_DOM=8]="DRAWING_DOM",t))(Vr||{}),it=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(it||{}),At=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(At||{});function aa(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}function la(t,n,e){let s=!1,r=!1,i=t,o=n,a=t,l=n;if(e==null)return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l};for(let h=0;h<e.length;h++){const{startRow:c,endRow:u,startColumn:d,endColumn:f}=e[h];if(t===c&&n===d){i=u,o=f,a=c,l=d,r=!0;break}if(t>=c&&t<=u&&n>=d&&n<=f){i=u,o=f,a=c,l=d,s=!0;break}}return{actualRow:t,actualColumn:n,isMergedMainCell:r,isMerged:s,endRow:i,endColumn:o,startRow:a,startColumn:l}}var as=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(as||{}),Kr=(t=>(t[t.SHAPE=0]="SHAPE",t[t.IMAGE=1]="IMAGE",t[t.TEXT=2]="TEXT",t[t.SPREADSHEET=3]="SPREADSHEET",t[t.DOCUMENT=4]="DOCUMENT",t[t.SLIDE=5]="SLIDE",t))(Kr||{}),Yr=(t=>(t[t.RELATIVE_SLIDE_LINK_UNSPECIFIED=0]="RELATIVE_SLIDE_LINK_UNSPECIFIED",t[t.NEXT_SLIDE=1]="NEXT_SLIDE",t[t.PREVIOUS_SLIDE=2]="PREVIOUS_SLIDE",t[t.FIRST_SLIDE=3]="FIRST_SLIDE",t[t.LAST_SLIDE=4]="LAST_SLIDE",t))(Yr||{});const ua="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ca=t=>crypto.getRandomValues(new Uint8Array(t)),ha=(t,n,e)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*n/t.length);return(i=n)=>{let o="";for(;;){let a=e(r),l=r;for(;l--;)if(o+=t[a[l]&s]||"",o.length===i)return o}}},da=(t,n=21)=>ha(t,n,ca),fa=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=ua[e[t]&63];return n};const _a=new RegExp("^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$","i");function ga(t){return Number.isNaN(+t)?t.startsWith("http://localhost:3002")||t.startsWith("localhost:3002")?!0:_a.test(t):!1}function ma(t){return/^[a-zA-Z]+:\/\//.test(t)}function Ea(t){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(t)}function pa(t){return ma(t)?t:Ea(t)?`mailto://${t}`:`https://${t}`}const Ra=/^-ms-/,Ca=/-([a-z])/g,de=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class x{static stringAt(n){let e="",s=n;for(;s>=de.length;)s/=de.length,s-=1,e+=de[s%de.length];const r=n%de.length;return e+=de[r],e}static indexAt(n){let e=0;for(let s=0;s<n.length-1;s+=1){const r=n.charCodeAt(s)-65,i=n.length-1-s;e+=de.length**i+de.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return x.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!e&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(n.indexOf("Windows NT 5.0")>-1||n.indexOf("Windows 2000")>-1)return"Windows 2000";if(n.indexOf("Windows NT 5.1")>-1||n.indexOf("Windows XP")>-1)return"Windows XP";if(n.indexOf("Windows NT 5.2")>-1||n.indexOf("Windows 2003")>-1)return"Windows 2003";if(n.indexOf("Windows NT 6.0")>-1||n.indexOf("Windows Vista")>-1)return"Windows Vista";if(n.indexOf("Windows NT 6.1")>-1||n.indexOf("Windows 7")>-1)return"Windows 7";if(n.indexOf("Windows NT 10")>-1||n.indexOf("Windows 10")>-1)return"Windows 10";if(n.indexOf("Windows NT 11")>-1||n.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const n=navigator.userAgent,e=n.indexOf("Opera")>-1,s=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!e,r=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,i=n.indexOf("Edge")>-1,o=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(n);const c=Number.parseFloat(RegExp.$1);return c===7?"IE7":c===8?"IE8":c===9?"IE9":c===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(n=21,e){return zr(n,e)}static getClassName(n){return n.constructor.name}static deepMerge(n,...e){e.forEach(o=>o&&i(o));function s(o,a){o.forEach((l,h)=>{var c,u;if(x.isArray(l)){const d=(c=a[h])!=null?c:[];a[h]=d,s(l,d);return}if(x.isObject(l)){const d=(u=a[h])!=null?u:{};a[h]=d,r(l,d);return}a[h]=l})}function r(o,a){Object.keys(o).forEach(l=>{var c,u;const h=o[l];if(x.isObject(h)){const d=(c=a[l])!=null?c:{};a[l]=d,r(h,d);return}if(x.isArray(h)){const d=(u=a[l])!=null?u:[];a[l]=d,s(h,d);return}a[l]=h})}function i(o){Object.keys(o).forEach(a=>{var h,c;const l=o[a];if(x.isArray(l)){const u=(h=n[a])!=null?h:[];n[a]=u,s(l,u);return}if(x.isObject(l)){const u=(c=n[a])!=null?c:{};n[a]=u,r(l,u);return}n[a]=l})}return n}static numberFixed(n,e){return Number(Number(n).toFixed(e))}static diffValue(n,e){function s(o,a){const l=x.getValueType(o),h=x.getValueType(a);return l!==h?!1:x.isArray(o)?r(o,a):x.isObject(o)?i(o,a):x.isDate(o)?o.getTime()===a.getTime():x.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(n.length!==e.length)return!1;for(let l=0,h=o.length;l<h;l++){const c=o[l],u=a[l];if(!s(c,u))return!1}return!0}function i(o,a){const l=Object.keys(o),h=Object.keys(a);if(l.length!==h.length)return!1;for(const c of l){if(!h.includes(c))return!1;const u=o[c],d=a[c];if(!s(u,d))return!1}return!0}return s(n,e)}static deepClone(n){if(!this.isDefine(n))return n;if(this.isRegExp(n))return new RegExp(n);if(this.isDate(n))return new Date(n);if(this.isArray(n)){const e=[];return n.forEach((s,r)=>{e[r]=x.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=x.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}return n}static getLanguage(){const n="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||n}static getValueType(n){return Object.prototype.toString.apply(n)}static isDefine(n){return n!=null}static isBlank(n){return this.isDefine(n)?this.isString(n)?n.trim()==="":!1:!0}static isAssignableFrom(n,e){return n instanceof e}static isBoolean(n){return this.getValueType(n)==="[object Boolean]"}static isPlainObject(n){return this.isDefine(n)?Object.getPrototypeOf(n)===Object.getPrototypeOf({}):!1}static isFunction(n){return this.getValueType(n)==="[object Function]"}static isDate(n){return this.getValueType(n)==="[object Date]"}static isRegExp(n){return this.getValueType(n)==="[object RegExp]"}static isArray(n){return this.getValueType(n)==="[object Array]"}static isString(n){return this.getValueType(n)==="[object String]"}static isNumber(n){return this.getValueType(n)==="[object Number]"}static isStringNumber(n){return!isNaN(Number.parseFloat(n))&&isFinite(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isEmptyObject(n){for(const e in n)return!1;return!0}static isMobile(){let n=0,e=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&e<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const n=navigator.userAgent.toLowerCase();return String(n.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const n=navigator.userAgent;return n.indexOf("Android")>-1||n.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(n){return ga(n)}static normalizeUrl(n){return pa(n)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return x.isDefine(n)?x.isDefine(e)?n.length===e:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,e){return e.toUpperCase()}static camelCase(n){return n.replace(Ra,"ms-").replace(Ca,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:x.removeNull(s)}),n}static fillTwoDimensionalArray(n,e,s){return new Array(n).fill(s).map(r=>new Array(e).fill(s))}static numToWord(n){let e="";for(;n>0;){let s=n%26;s=s===0?s=26:s,e=String.fromCharCode(96+s)+e,n=(n-s)/26}return e.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const e=n.toLowerCase().split(""),s=e.length;let r=0,i=0;for(let o=0;o<s;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(n){let i="";for(;n>=0;)i=String.fromCharCode(n%26+97)+i,n=Math.floor(n/26)-1;return i.toUpperCase()}static randSort(n){for(let e=0,s=n.length;e<s;e++){const r=Number.parseInt((Math.random()*s).toString()),i=n[r];n[r]=n[e],n[e]=i}return n}static commonExtend(n,e){const s={};for(const r in n)s[r]=n[r];for(const r in e)e[r]!=null&&(s[r]=e[r]);return s}static commonExtend1(n,e){for(const s in n)e[s]==null&&(e[s]=n[s]);return e}static arrayToObject(n){const e={};return n.forEach((s,r)=>{e[r]={},s.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(n,e,s,r){return e>=s&&r>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const e=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),s=n.length<=255;return!e&&s}static set(n,e,s){const r=e.split("."),i=r.pop();r.forEach(o=>{n[o]||(n[o]={}),n=n[o]}),i&&(n[i]=s)}static clamp(n,e,s){return Math.max(e,Math.min(s,n))}}function zr(t=21,n){return n?da(n,t)():fa(t)}function Ia(t){const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:h}=t,c=n,u=e,d=n,f=e;if(s&&i){const{startRow:m,startColumn:E,endRow:M,endColumn:L,startY:tt,endY:mt,startX:ht,endX:p}=i;c=m,u=E,d=M,f=L,o=tt,a=mt,l=ht,h=p}return r&&(o=i.startY,a=i.endY,l=i.startX,h=i.endX,d=i.endRow,f=i.endColumn),{startRow:c,startColumn:u,endRow:d,endColumn:f,startY:o,endY:a,startX:l,endX:h}}function Sa(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let h=n,c=e,u=n,d=e;return(s||r)&&(h=i,c=o,u=a,d=l),{startRow:h,startColumn:c,endRow:u,endColumn:d}}function Xr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function Oa(t){return Xr(t)&&(t==null?void 0:t.coverable)!==!1}function re(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new vn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Na(t){return x.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Aa(t){return x.isString(t)&&t.length>0}function ba(t,n=!1){var i;let e="";const s=new Map([["ff",()=>{t.ff&&(e+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),e+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(e+="font-style: italic; ")}],["bl",()=>{t.bl&&(e+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):e+="text-decoration: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${re(t.ul.cl)}; `),t.ul.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} line-through`):e+="text-decoration-line: line-through; ",t.st.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${re(t.st.cl)}; `),t.st.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} overline`):e+="text-decoration-line: overline; ",t.ol.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${re(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${re(t.bg)}; `)}],["bd",()=>{var o,a,l,h,c,u,d,f,m,E,M,L;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${an((a=t.bd)==null?void 0:a.b.s)} ${(l=re(t.bd.b.cl))!=null?l:""}; `),(h=t.bd)!=null&&h.t&&(e+=`border-top: ${an((c=t.bd)==null?void 0:c.t.s)} ${(u=re(t.bd.t.cl))!=null?u:""}; `),(d=t.bd)!=null&&d.r&&(e+=`border-right: ${an((f=t.bd)==null?void 0:f.r.s)} ${(m=re(t.bd.r.cl))!=null?m:""}; `),(E=t.bd)!=null&&E.l&&(e+=`border-left: ${an((M=t.bd)==null?void 0:M.l.s)} ${(L=re(t.bd.l.cl))!=null?L:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${re(t.cl)}; `)}],["va",()=>{t.va===ke.SUBSCRIPT?e+="vertical-align: sub; ":t.va===ke.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===qe.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===qe.RIGHT_TO_LEFT&&(e+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(e+=`--data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(a=t.tr)!=null&&a.v?` ,${(l=t.tr)==null?void 0:l.v}`:""});`)}],["ht",()=>{t.ht===Ne.LEFT?e+="text-align: left; ":t.ht===Ne.RIGHT?e+="text-align: right; ":t.ht===Ne.CENTER?e+="text-align: center; ":t.ht===Ne.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===xe.BOTTOM?e+="vertical-align: bottom; ":t.vt===xe.TOP?e+="vertical-align: top; ":t.vt===xe.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===Pe.CLIP?e+="white-space: nowrap; overflow-x: hidden; ":t.tb===Pe.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var c,u,d,f,m,E,M,L;const o=`${(c=t.pd)==null?void 0:c.b}pt`,a=`${(u=t.pd)==null?void 0:u.t}pt`,l=`${(d=t.pd)==null?void 0:d.l}pt`,h=`${(f=t.pd)==null?void 0:f.r}pt`;(m=t.pd)!=null&&m.b&&(e+=`padding-bottom: ${o}; `),(E=t.pd)!=null&&E.t&&(e+=`padding-top: ${a}; `),(M=t.pd)!=null&&M.l&&(e+=`padding-left: ${l}; `),(L=t.pd)!=null&&L.r&&(e+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)n&&r.includes(o)||(i=s.get(o))==null||i();return e}function an(t){let n="";return t===dt.NONE?n="none":t===dt.THIN?n="0.5pt solid":t===dt.HAIR?n="0.5pt double":t===dt.DOTTED?n="0.5pt dotted":t===dt.DASHED||t===dt.DASH_DOT?n="0.5pt dashed":t===dt.DASH_DOT_DOT?n="0.5pt dotted":t===dt.DOUBLE?n="0.5pt double":t===dt.MEDIUM?n="1pt solid":t===dt.MEDIUM_DASHED||t===dt.MEDIUM_DASH_DOT?n="1pt dashed":t===dt.MEDIUM_DASH_DOT_DOT?n="1pt dotted":t===dt.SLANT_DASH_DOT?n="0.5pt dashed":t===dt.THICK&&(n="1.5pt solid"),n}function va(t){let n=0;if(t=t.trim(),t==="none")n=dt.NONE;else if(t==="0.5pt solid")n=dt.THIN;else if(t==="0.5pt double")n=dt.HAIR;else if(t==="0.5pt dotted")n=dt.DOTTED;else if(t==="0.5pt dashed")n=dt.DASHED;else if(t==="1pt solid")n=dt.MEDIUM;else if(t==="1pt dashed")n=dt.MEDIUM_DASHED;else if(t==="1pt dotted")n=dt.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")n=dt.THICK;else if(!t.includes("none"))n=dt.THIN;else return dt.NONE;return n}function wa(t,n){let e=t.body;if(n){const{headers:s,footers:r}=t;s!=null&&s[n]?e=s[n].body:r!=null&&r[n]&&(e=r[n].body)}return e}function Ta(t){const{startRow:n,endRow:e,startColumn:s,endColumn:r,rangeType:i}=t;return!(n<0||s<0||e<0||r<0||!(Number.isNaN(n)&&Number.isNaN(e))&&i===it.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===it.ROW||i!==it.ROW&&i!==it.COLUMN&&(Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(e)))}function Ma(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function ls(t,n){return Object.prototype.toString.call(t)===Object.prototype.toString.call(n)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(n).length?!1:Object.keys(t).every(e=>ls(t[e],n[e])):t===n:!1}function qr(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:ls(e,s)}function Ua(t,n){return n.some(e=>t.indexOf(e)>-1)}function wn(t,n,e,s){if(t>n&&([t,n]=[n,t]),e>s&&([e,s]=[s,e]),n<e||s<t)return[t,n];e<t&&(e=t),s>n&&(s=n);const r=s-e+1;let i=[];return t===e?i=[s+1-r,n-r]:n===s?i=[t,e-1]:i=[t,n-r],i}function La(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Da(t){if(t==null)return!1;const n=t.paragraphStyle;return Zr(n)}function Zr(t){var n;return!(t==null||(t.indentStart==null||t.indentStart.v===0)&&t.hanging==null||((n=t.hanging)==null?void 0:n.v)===0)}function Jr(t,n,e){return t.slice(0,n)+e+t.slice(n)}function Qr(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function ya(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function xa(t){let n=0;for(let e=0;e<t.length;e++)n=t.charCodeAt(e)+(n<<6)+(n<<16)-n;return n>>>0}function Ls(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],s=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ds(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var s=e.call(t),r,i=[],o;try{for(;(n===void 0||n-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return i}function ys(t,n,e){if(e||arguments.length===2)for(var s=0,r=n.length,i;s<r;s++)(i||!(s in n))&&(i||(i=Array.prototype.slice.call(n,0,s)),i[s]=n[s]);return t.concat(i||Array.prototype.slice.call(n))}function Ve(t){return typeof t=="function"}function Pa(t){var n=function(s){Error.call(s),s.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Wn=Pa(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
+ `+e.map(function(s,r){return r+1+") "+s.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function xs(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var ti=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Ls(o),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(E){n={error:E}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var c=this.initialTeardown;if(Ve(c))try{c()}catch(E){i=E instanceof Wn?E.errors:[E]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Ls(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{Ps(m)}catch(E){i=i!=null?i:[],E instanceof Wn?i=ys(ys([],Ds(i)),Ds(E.errors)):i.push(E)}}}catch(E){s={error:E}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(s)throw s.error}}}if(i)throw new Wn(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)Ps(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&xs(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&xs(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();ti.EMPTY;function ka(t){return t instanceof ti||t&&"closed"in t&&Ve(t.remove)&&Ve(t.add)&&Ve(t.unsubscribe)}function Ps(t){Ve(t)?t():t.unsubscribe()}function bt(t){let n=!1;return t?ka(t)?{dispose:()=>t.unsubscribe()}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:bt(()=>{})}function Ha(t){return bt(()=>{t.unsubscribe()})}class us{constructor(){_(this,"_disposables",new Set)}add(n){const e=bt(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class Tt{constructor(){_(this,"_disposed",!1);_(this,"_collection",new us)}disposeWithMe(n){return this._collection.add(n)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class Fa extends Tt{constructor(){super(...arguments);_(this,"dispose$",new Z.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class $a extends Tt{constructor(e){super();_(this,"_ref",0);this._rootDisposable=e}inc(){if(this._disposed)throw new Error("[RCDisposable]: should not ref to a disposed.");this._ref+=1}dec(){this._ref-=1,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}}class Be{static hasLength(n,e){return n.length===e}static getValueType(n){return Object.prototype.toString.apply(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isIterable(n){return n[Symbol.iterator]!=null}static isNumber(n){return this.getValueType(n)==="[object Number]"}}function Tn(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function Wa(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function Ba(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function Ga(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function ja(t,n){const e=new Map;return t.forEach(s=>{const r=n(s);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(s)}),e}function Va(t){return Array.isArray(t)?t:[t]}const ct=Symbol("newer"),Dt=Symbol("older");class ei{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.key}):{done:!0,value:void 0}}}class ni{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:n.value}):{done:!0,value:void 0}}}class si{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[ct],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}var Ys,zs;zs=ct,Ys=Dt;class zn{constructor(n,e){_(this,"key");_(this,"value");_(this,zs);_(this,Ys);this.key=n,this.value=e,this[ct]=void 0,this[Dt]=void 0}toJSON(){return{key:this.key,value:this.value}}}class ri{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(Be.hasLength(n,1)){if(Be.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(Be.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(Be.hasLength(n,2)){const e=n[0],s=n[1];this._initialize(e,s)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),bt(()=>Tn(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,e&&(this.assign(e),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[ct]&&(n===this.oldest&&(this.oldest=n[ct]),n[ct][Dt]=n[Dt]),n[Dt]&&(n[Dt][ct]=n[ct]),n[ct]=void 0,n[Dt]=this.newest,this.newest&&(this.newest[ct]=n),this.newest=n)}assign(n){let e,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=n[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new zn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[ct]=o,o[Dt]=e):this.oldest=o,e=o,s--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(n,e){let s=this._keymap.get(n);return s?(s.value=e,this._markEntryAsUsed(s),this):(this._keymap.set(n,s=new zn(n,e)),this.newest?(this.newest[ct]=s,s[Dt]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[ct]?(this.oldest=this.oldest[ct],this.oldest[Dt]=void 0):(this.oldest=void 0,this.newest=void 0),n[ct]=n[Dt]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(e=>e(n)),[n.key,n.value]}get(n){const e=this._keymap.get(n);if(e)return this._markEntryAsUsed(e),e.value}has(n){return this._keymap.has(n)}find(n){const e=this._keymap.get(n);return e?e.value:void 0}delete(n){const e=this._keymap.get(n);if(e)return this._keymap.delete(e.key),e[ct]&&e[Dt]?(e[Dt][ct]=e[ct],e[ct][Dt]=e[Dt]):e[ct]?(e[ct][Dt]=void 0,this.oldest=e[ct]):e[Dt]?(e[Dt][ct]=void 0,this.newest=e[Dt]):this.oldest=this.newest=void 0,this.size--,e.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new ei(this.oldest)}values(){return new ni(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new si(this.oldest)}forEach(n,e){typeof e!="object"&&(e=this);let s=this.oldest;for(;s;)n.call(e,s.value,s.key,this),s=s[ct]}toJSON(){const n=new Array(this.size);let e=0,s=this.oldest;for(;s;)n[e++]={key:s.key,value:s.value},s=s[ct];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[ct],e&&(n+=" < ");return n}}function ge(t){let n=0;const e=Object.keys(t);for(const s of e){const r=Number(s);n=Math.max(n,r)}return n+1}function Xn(t,n,e){const s=ge(e),r=e;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=n}function qn(t,n,e){const s=Object.keys(e).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+n?delete e[r]:e[r]!==void 0&&(e[r-n]=e[r],delete e[r])}function Ka(t,n){const e=t,s=Object.keys(e),r=s.length,i=n,o=Object.keys(i),a=o.length,l={};let h=0;for(let c=0;c<r;c++,h++){const u=s[c];l[h]=e[u]}for(let c=0;c<a;c++,h++){const u=o[c];l[h]=i[u]}return l}function Ya(t,n,e){const s=e;if(ge(e)>0){const i={};let o=0;for(let a=t;a<=n;a++)s[a]&&(i[o]=s[a],o++);return i}return{}}function Zn(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?za(t,n,e,s):Xa(t,n,e,s)}function za(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+n]=a,a===void 0&&delete r[o+n]}i.forEach((o,a)=>{r[e+a]=o,o===void 0&&delete r[e+a]})}function Xa(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t+n;o<e;o++){const a=r[o];r[o-n]=a,a===void 0&&delete r[o-n]}i.forEach((o,a)=>{r[e+a-n]=o,o===void 0&&delete r[e+a-n]})}class ee{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new ee({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,o)===!1)return this}return this}forRow(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const h=Number(l),c=o[Number(l)];if(n(i,h,c)===!1)return this}}return this}swapRow(n,e){const s=this._matrix[n],r=this._matrix[e];this._matrix[n]=r,this._matrix[e]=s}getRow(n){return this._matrix[n]}getRowOrCreate(n){let e=this.getRow(n);return e==null&&(e={},this._matrix[n]=e),e}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,e=Object.keys(n);if(e.length===0)return!1;for(const s of e){const r=Number(s),i=n[r];if(Object.keys(i).length>0)return!0}return!1}getValue(n,e){var s,r;return(r=(s=this._matrix)==null?void 0:s[n])==null?void 0:r[e]}setValue(n,e,s){const r=this.getRowOrCreate(n);r[e]=s}deleteValue(n,e){var s,r;(r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e]}realDeleteValue(n,e){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e],this.getRow(n)){const o=this.getRow(n);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[n])}}setRow(n,e){this._matrix[n]=e}moveRows(n,e,s){Zn(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{Zn(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)Xn(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{i&&Xn(s,void 0,i)})}removeRows(n,e){qn(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{r&&qn(n,e,r)})}getFragment(n,e,s,r){const i=new ee;let o=0;for(let a=n;a<=e;a++){const l={};let h=0;for(let c=s;c<=r;c++){const u=this.getValue(a,c);l[h]=u,h++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new ee;for(let o=n;o<=e;o++)for(let a=s;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,x.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return ge(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=ge(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const n=new Array;return this.forValue((e,s,r)=>{n.push(r)}),n}toArray(){const n=[];return this.forRow((e,s)=>{n[e]==null&&(n[e]=[]),s.forEach(r=>{n[e][r]=this.getValue(e,r)})}),n}toFullArray(){const n=this.getRange(),{endColumn:e,endRow:s}=n,r=[];for(let i=0;i<=s;i++){const o=Array(e+1).fill(void 0);r.push(o)}return this.forValue((i,o,a)=>{r[i][o]=a}),r}toJSON(){return this._matrix}clone(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getData(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getArrayData(){let n=0,e=0,s=!1,r=!1;const i=new ee;return this.forEach((o,a)=>{s||(s=!0,n=o),Object.keys(a).forEach(l=>{const h=Number(l);r?h<e&&(e=h):(r=!0,e=h);const c=this.getValue(o,h);i.setValue(o-n,h-e,c)})}),i.getData()}getDataRange(){let n=0,e=0,s=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,n=a),l==null)return;const h=ge(l)-1;h>s&&(s=h),Object.keys(l).forEach(c=>{const u=Number(c);o?u<e&&(e=u):(o=!0,e=u)}),a>r&&(r=a)}),{startRow:n,startColumn:e,endRow:r,endColumn:s}}getDiscreteRanges(){const n=[];return this.forEach((e,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const a of n)if(e>=a.startRow&&e<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(e,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||n.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),n}merge(n){this.forValue((e,s)=>{const r=n.getValue(e,s);r!=null&&this.setValue(e,s,r)})}_setOriginValue(n={}){this._matrix=n}}const ue=class ue{static clone(n){return n.rangeType!==void 0?{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:n.rangeType}:{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn}}static equals(n,e){return n==null||e==null?!1:n.endRow===e.endRow&&n.endColumn===e.endColumn&&n.startRow===e.startRow&&n.startColumn===e.startColumn&&(n.rangeType===e.rangeType||n.rangeType===void 0&&e.rangeType===it.NORMAL||e.rangeType===void 0&&n.rangeType===it.NORMAL)}static intersects(n,e){if(n.rangeType===it.ROW&&e.rangeType===it.COLUMN||n.rangeType===it.COLUMN&&e.rangeType===it.ROW)return!0;if(n.rangeType===it.ROW&&e.rangeType===it.ROW)return n.startRow<=e.endRow&&n.endRow>=e.startRow;if(n.rangeType===it.COLUMN&&e.rangeType===it.COLUMN)return n.startColumn<=e.endColumn&&n.endColumn>=e.startColumn;const s=Math.floor(Number.MAX_SAFE_INTEGER/10),r=Number.isNaN(n.startRow)?0:n.startRow,i=Number.isNaN(n.endRow)?s:n.endRow,o=Number.isNaN(n.startColumn)?0:n.startColumn,a=Number.isNaN(n.endColumn)?s:n.endColumn,l=Number.isNaN(e.startRow)?0:e.startRow,h=Number.isNaN(e.endRow)?s:e.endRow,c=Number.isNaN(e.startColumn)?0:e.startColumn,u=Number.isNaN(e.endColumn)?s:e.endColumn,d=Math.abs(o+a-c-u),f=Math.abs(o-a)+Math.abs(c-u),m=Math.abs(r+i-l-h),E=Math.abs(r-i)+Math.abs(l-h);return d<=f&&m<=E}static getIntersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,h=e.startColumn,c=e.endColumn;let u,d,f,m;if(a<=r)a>=s?d=a:d=s;else return null;if(l>=s)l>=r?m=r:m=l;else return null;if(h<=o)h>i?u=h:u=i;else return null;if(c>=i)c>=o?f=o:f=c;else return null;return{startRow:d,endRow:m,startColumn:u,endColumn:f,rangeType:it.NORMAL}}static contains(n,e){return n.startRow<=e.startRow&&n.endRow>=e.endRow&&n.startColumn<=e.startColumn&&n.endColumn>=e.endColumn}static realContain(n,e){return ue.contains(n,e)&&(n.startRow<e.startRow||n.endRow>e.endRow||n.startColumn<e.startColumn||n.endColumn>e.endColumn)}static union(...n){return n.reduce((e,s)=>({startRow:Math.min(e.startRow,s.startRow),startColumn:Math.min(e.startColumn,s.startColumn),endRow:Math.max(e.endRow,s.endRow),endColumn:Math.max(e.endColumn,s.endColumn),rangeType:it.NORMAL}),n[0])}static realUnion(...n){const e=n.some(i=>i.rangeType===it.COLUMN),s=n.some(i=>i.rangeType===it.ROW),r=ue.union(...n);return{startColumn:s?Number.NaN:r.startColumn,endColumn:s?Number.NaN:r.endColumn,startRow:e?Number.NaN:r.startRow,endRow:e?Number.NaN:r.endRow,rangeType:s?it.ROW:e?it.COLUMN:it.NORMAL}}static subtract(n,e){if(e.startRow>n.endRow||e.endRow<n.startRow||e.startColumn>n.endColumn||e.endColumn<n.startColumn)return[n];const s=[];e.startRow>=n.startRow&&s.push({startRow:n.startRow,startColumn:n.startColumn,endRow:e.startRow-1,endColumn:n.endColumn}),e.endRow<=n.endRow&&s.push({startRow:e.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const r=Math.max(n.startRow,e.startRow),i=Math.min(n.endRow,e.endRow);return e.startColumn>=n.startColumn&&s.push({startRow:r,startColumn:n.startColumn,endRow:i,endColumn:e.startColumn-1}),e.endColumn<=n.endColumn&&s.push({startRow:r,startColumn:e.endColumn+1,endRow:i,endColumn:n.endColumn}),s.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}static hasIntersectionBetweenTwoRect(n,e){return!(n.left>e.right||n.right<e.left||n.top>e.bottom||n.bottom<e.top)}static getIntersectionBetweenTwoRect(n,e){const s=Math.max(n.left,e.left),r=Math.min(n.right,e.right),i=Math.max(n.top,e.top),o=Math.min(n.bottom,e.bottom);return r<=s||o<=i?null:{left:s,right:r,top:i,bottom:o,width:r-s,height:o-i}}};_(ue,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),_(ue,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[At.ROW,At.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[At.ROW,At.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[At.COLUMN,At.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[At.COLUMN,At.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),_(ue,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),_(ue,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),_(ue,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let me=ue;class qa{constructor(n,e){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=n,this._keys=e,n.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(n){this._keys.forEach(e=>{const s=n[e],r=this._keyMaps.get(e)||new Map;r.set(s,n),this._keyMaps.set(e,r)})}getValue(n,e){const s=e||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(n))return i.get(n)}return null}hasValue(n){for(let e=0;e<this._keys.length;e++){const s=this._keyMaps.get(this._keys[e]);if(s!=null&&s.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,e,s){const r=this.getValue(n);r&&Object.keys(r).includes(e)&&(r[e]=s)}deleteValue(n){const e=this.getValue(n);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===e);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(n){var e;return[...((e=this._keyMaps.get(n))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function Jn(t,n,e,s){return{forEach(r){for(let i=t;i<=n;i++)for(let o=e;o<=s;o++)r(i,o)}}}function Za(t){if(t==null||t.length===0)return Number.NaN;const n=t.toLowerCase().split(""),e=n.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=s(n[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const In=65,ii=90,Ja=97;function Qa(t){const n=ii-In+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+In)+e,t=Math.floor(t/n)-1;return e}function oi(t,n){let e="";for(;n>0;)e+=t,n--;return e}function tl(t,n=!1){const e=ii-In+1;let s=Ja;n&&(s=In);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return oi(r,i)}function el(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function nl(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function Me(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function sl(t,n){let e;function s(...r){const i=this,o=function(){e=null,t.apply(i,r)};clearTimeout(e),e=setTimeout(o,n)}return Object.defineProperty(s,"cancel",{value:()=>{clearTimeout(e)},enumerable:!1,writable:!1}),s}function hn(t,n,e){const{dataStream:s,textRuns:r=[]}=t;let i=n;const o=[];for(const a of r){const{st:l,ed:h}=a;x.hasIntersectionBetweenTwoRanges(n,e,l,h)&&(l>i?(o.push(s.slice(i,l)),o.push(Qn(s,{...a,ed:Math.min(h,e)}))):o.push(Qn(s,{...a,st:i,ed:Math.min(h,e)}))),i=Math.max(n,Math.min(h,e))}return i!==e&&o.push(s.slice(i,e)),o.join("")}function rl(t,n=!0){var e;if(n&&((e=t.paragraphs)!=null&&e.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const a of r){const{startIndex:l,paragraphStyle:h={}}=a,{spaceAbove:c,spaceBelow:u,lineSpacing:d}=h,f=[];c!=null&&(typeof c=="number"?f.push(`margin-top: ${c}px`):f.push(`margin-top: ${c.v}px`)),u!=null&&(typeof u=="number"?f.push(`margin-bottom: ${u}px`):f.push(`margin-bottom: ${u.v}px`)),d!=null&&f.push(`line-height: ${d}`),l>o+1?i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${hn(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=hn(t,o,s.length)),i}else return hn(t,0,t.dataStream.length)}function Qn(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:h,st:c,ol:u,bg:d,cl:f,va:m}=r;let E=t.slice(e,s);const M=[];return a===K.TRUE&&(E=`<i>${E}</i>`),m===ke.SUPERSCRIPT?E=`<sup>${E}</sup>`:m===ke.SUBSCRIPT&&(E=`<sub>${E}</sub>`),(h==null?void 0:h.s)===K.TRUE&&(E=`<u>${E}</u>`),(c==null?void 0:c.s)===K.TRUE&&(E=`<s>${E}</s>`),l===K.TRUE&&(E=`<strong>${E}</strong>`),i&&M.push(`font-family: ${i}`),f&&M.push(`color: ${f.rgb}`),o&&M.push(`font-size: ${o}pt`),u&&M.push("text-decoration: overline"),d&&M.push(`background: ${d.rgb}`),M.length?`<span style="${M.join("; ")};">${E}</span>`:E}const il={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},ol={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},al={startRow:0,startColumn:0,endRow:0,endColumn:0},ll={row:0,column:0},dn={ff:"Arial",fs:11,it:K.FALSE,bl:K.FALSE,ul:{s:K.FALSE},st:{s:K.FALSE},ol:{s:K.FALSE},tr:{a:0,v:K.FALSE},td:qe.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Ne.UNSPECIFIED,vt:xe.UNSPECIFIED,tb:Pe.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},ai={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var li=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(li||{});function ln(t,n){const{textRuns:e=[]}=n;let s=0;for(const i of e){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return K.FALSE;switch(t){case"bl":case"it":{if(o[t]===K.FALSE)return K.FALSE;break}case"ul":case"st":{if(o[t].s===K.FALSE)return K.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
4
+ `)===s?K.TRUE:K.FALSE}const ze=class ze{constructor(n,e,s){_(this,"_range");_(this,"_worksheet");this._deps=s,this._range=e,this._worksheet=n}static foreach(n,e){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n;for(let a=s;a<=i;a++)for(let l=r;l<=o;l++)e(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=[];for(let o=n;o<=e;o++){const a=[];for(let l=s;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new ee;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new ee;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a-n,l-s,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=x.numToWord(s+1)+(n+1),o=x.numToWord(r+1)+(e+1)):(i=x.numToWord(r+1)+(e+1),o=x.numToWord(s+1)+(n+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||dn.bg.rgb}))}getCell(n,e){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:s+n,endRow:s+n,startColumn:i+e,endColumn:i+e};return new ze(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:e,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,s,r,i).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let h=0;h<=s-e;h++)for(let c=0;c<=i-r;c++){if(o==null||((a=o==null?void 0:o[h])==null?void 0:a[c])==null)continue;const u=o[h][c].s;u&&(o[h][c].s=l.get(u))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||dn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?ln("ul",n.body)===K.TRUE?{s:K.TRUE}:{s:K.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?ln("st",n.body)===K.TRUE?{s:K.TRUE}:{s:K.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,s;const n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...n.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?ln("it",n.body)===K.TRUE?En.ITALIC:En.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?ln("bl",n.body)===K.TRUE?pn.BOLD:pn.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:e}=this,{startRow:s,endRow:r}=n;let i=0;for(let o=0;o<=r-s;o++){const a=e.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:n,endColumn:e}=this._range;return e-n+1}getNumRows(){const{startRow:n,endRow:e}=this._range;return e-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(e=>(e==null?void 0:e.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>n.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:e}=this,{startColumn:s,endColumn:r}=n;let i=0;for(let o=0;o<=r-s;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWrapStrategy()===Pe.WRAP?K.TRUE:K.FALSE}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){ze.foreach(this._range,n)}_getStyles(n){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[n]||dn[n]}))}};_(ze,"transformRange",(n,e)=>n.rangeType===it.ALL?{startColumn:0,startRow:0,endColumn:e.getMaxColumns()-1,endRow:e.getMaxRows()-1}:n.rangeType===it.COLUMN?{startRow:0,endRow:e.getMaxRows()-1,startColumn:n.startColumn,endColumn:n.endColumn}:n.rangeType===it.ROW?{startColumn:0,endColumn:e.getMaxColumns()-1,startRow:n.startRow,endRow:n.endRow}:n);let He=ze;function ul(t,n){if(t.length===0||t[0].length===0)return null;const e=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let a=0;a<t[0].length;a++)e[a]=n(t[i][a])?e[a]+1:0;const o=cl(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function cl(t){const n=[];let e=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(n.length===0||t[r]>=t[n[n.length-1]])n.push(r++);else{const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}for(;n.length>0;){const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}return s}function hl(t,n){He.foreach(n,(e,s)=>{t[e][s]=void 0})}function dl(t,n){const e=t.toFullArray(),s=[];for(;;){const r=ul(e,n);if(!r)break;s.push(r),hl(e,r)}return s}function fl(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||At.NONE,o=r.endAbsoluteRefType||At.NONE;return!s&&i===At.ALL&&o===At.ALL?r:s||i===At.NONE&&o===At.NONE?me.moveOffset(r,n,e):(i===At.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===At.COLUMN?r={...r,startRow:r.startRow+e}:i===At.ROW&&(r={...r,startColumn:r.startColumn+n}),o===At.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===At.COLUMN?r={...r,endRow:r.endRow+e}:o===At.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function ui(t){for(const[n,e]of t.entries())try{if(!await e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}function ci(t){for(const[n,e]of t.entries())try{if(!e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}const Qe=ut.createIdentifier("univer.context-service");class hi extends Tt{constructor(){super(...arguments);_(this,"_contextChanged$",new Z.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var s;return(s=this._contextMap.get(e))!=null?s:!1}setContextValue(e,s){this._contextMap.set(e,s),this._contextChanged$.next({[e]:s})}subscribeContextValue$(e){return new Z.Observable(s=>{const r=this._contextChanged$.pipe(Z.filter(i=>typeof i[e]<"u")).subscribe(i=>s.next(i[e]));return this._contextMap.has(e)&&s.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var di=(t=>(t[t.SILENT=0]="SILENT",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.VERBOSE=4]="VERBOSE",t))(di||{});const pe=ut.createIdentifier("univer.log");class fi extends Tt{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):e(...s)}}var _l=Object.defineProperty,gl=Object.getOwnPropertyDescriptor,ml=(t,n,e,s)=>{for(var r=s>1?void 0:s?gl(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&_l(n,e,r),r},ks=(t,n)=>(e,s)=>n(e,s,t),tn=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(tn||{});const en=ut.createIdentifier("anywhere.command-service");class El{constructor(){_(this,"_commands",new Map);_(this,"_commandTypes",new Map)}registerCommand(n){if(this._commands.has(n.id))throw new Error(`[CommandRegistry]: command "${n.id}" has been registered before.`);return this._commands.set(n.id,n),this._commandTypes.set(n.id,n.type),bt(()=>{var e;this._commands.delete(n.id),this._commandTypes.delete(n.id),(e=n.onDispose)==null||e.call(n)})}hasCommand(n){return this._commands.has(n)}getCommand(n){return this._commands.has(n)?[this._commands.get(n)]:null}getCommandType(n){return this._commandTypes.get(n)}}const _i={id:"nil",type:0,handler:()=>!0};exports.CommandService=class extends Tt{constructor(e,s){super();_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=e,this._logService=s,this._commandRegistry=new El,this._registerCommand(_i)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._registerCommand(e)}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),bt(()=>{const s=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),bt(()=>{const s=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,s,r){try{const i=this._commandRegistry.getCommand(e);if(i){const[o]=i,a={id:o.id,type:o.type,params:s},l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(c=>c(a,r));const h=await this._execute(o,s,r);return this._commandExecutedListeners.forEach(c=>c(a,r)),l.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}catch(i){throw this._logService.error(i),i}}syncExecuteCommand(e,s,r){var o;const i=this._commandRegistry.getCommand(e);if(i){const[a]=i,l={id:a.id,type:a.type,params:s};if(a.type===2){const u=Ba(this._commandExecutionStack,d=>d.type===0);u&&(l.params=(o=l.params)!=null?o:{},l.params.trigger=u.id)}const h=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(u=>u(l,r));const c=this._syncExecute(a,s,r);return this._commandExecutedListeners.forEach(u=>u(l,r)),h.dispose(),c}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),bt(()=>Tn(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const s=this._commandRegistry.getCommand(e.id);let r;if(s){if(s[0].multi!==!0)throw new Error("Command has registered as a single command.");r=s[0]}else{const o=new us;r=new pl(e.id),o.add(this._commandRegistry.registerCommand(r)),o.add(bt(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,o)}const i=r.registerImplementation(e);return bt(()=>{var o;i.dispose(),r.hasImplementations()||(o=this._multiCommandDisposables.get(e.id))==null||o.dispose()})}async _execute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let i;try{i=await this._injector.invoke(e.handler,s,r),this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}_syncExecute(e,s,r){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let i;try{if(i=this._injector.invoke(e.handler,s,r),i instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(o){throw i=!1,this._commandExecutingLevel=0,o}return i}};exports.CommandService=ml([ks(0,ut.Inject(ut.Injector)),ks(1,pe)],exports.CommandService);class pl{constructor(n){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(n,e)=>{if(!this._implementations.length)return!1;const s=n.get(pe),r=n.get(Qe),i=n.get(ut.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const e={command:n};return this._implementations.push(e),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),bt(()=>{var r;const s=this._implementations.indexOf(e);this._implementations.splice(s,1),(r=n.onDispose)==null||r.call(n)})}hasImplementations(){return this._implementations.length>0}}function cs(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return ci(s)}function Rl(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return ui(s)}function gi(t){return new Z.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}function mi(t){return function(e){return new Z.Observable(s=>(e.subscribe({next:r=>{s.next(r),t(r)&&s.complete()},complete:()=>s.complete(),error:r=>s.error(r)}),()=>s.unsubscribe()))}}const Cl=t=>new Promise(n=>{Z.merge(gi(t.onCommandExecuted.bind(t)).pipe(cn.filter(([e])=>e.type===tn.MUTATION)),Z.timer(300)).pipe(cn.debounceTime(16),cn.first()).subscribe(()=>{n()})});var Xt=(t=>(t[t.UNDEFINED=0]="UNDEFINED",t[t.OK=1]="OK",t[t.INTERNAL_ERROR=2]="INTERNAL_ERROR",t[t.PERMISSION_DENIED=3]="PERMISSION_DENIED",t[t.NOT_FOUND=4]="NOT_FOUND",t[t.UNAUTHENTICATED=5]="UNAUTHENTICATED",t[t.ALREADY_EXISTS=6]="ALREADY_EXISTS",t[t.INVALID_ARGUMENT=7]="INVALID_ARGUMENT",t[t.TOO_MANY_REQUESTS=8]="TOO_MANY_REQUESTS",t[t.COMPLETION_FINISHED=9]="COMPLETION_FINISHED",t[t.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",t[t.SNAPSHOT_HAS_BEEN_REMOVED=6002]="SNAPSHOT_HAS_BEEN_REMOVED",t[t.APPLY_REJECT=7001]="APPLY_REJECT",t[t.APPLY_NON_SEQUENTIAL_REVISION=7002]="APPLY_NON_SEQUENTIAL_REVISION",t[t.APPLY_REVISION_CONFILICT=7003]="APPLY_REVISION_CONFILICT",t[t.APPLY_PERMISSION_DENIED=7004]="APPLY_PERMISSION_DENIED",t[t.CONNECTOR_DATA_TOO_LARGE=8001]="CONNECTOR_DATA_TOO_LARGE",t[t.LICENSE_MAX_UNITS_EXCEEDED=9001]="LICENSE_MAX_UNITS_EXCEEDED",t[t.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED=9002]="LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED",t[t.LICENSE_IMPORT_SIZE_EXCEEDED=9003]="LICENSE_IMPORT_SIZE_EXCEEDED",t[t.LICENSE_EXPORT_SIZE_EXCEEDED=9004]="LICENSE_EXPORT_SIZE_EXCEEDED",t[t.LICENSE_DISTRO_REJECTED=9005]="LICENSE_DISTRO_REJECTED",t[t.YUUMI_UNABLE_LOAD_URL=10001]="YUUMI_UNABLE_LOAD_URL",t[t.YUUMI_URL_COL_OUT_OF_RANGE=10002]="YUUMI_URL_COL_OUT_OF_RANGE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Xt||{});function Ei(t){return!!(t&&t.code&&t.code!==Xt.OK&&t.code!=="OK")}var Q=(t=>(t[t.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",t[t.UNIVER_DOC=1]="UNIVER_DOC",t[t.UNIVER_SHEET=2]="UNIVER_SHEET",t[t.UNIVER_SLIDE=3]="UNIVER_SLIDE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Q||{}),pi=(t=>(t[t.SomeCollaborator=0]="SomeCollaborator",t[t.AllCollaborator=1]="AllCollaborator",t[t.OneSelf=2]="OneSelf",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(pi||{}),Ft=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Ft||{}),fn=(t=>(t[t.Unkonwn=0]="Unkonwn",t[t.Workbook=1]="Workbook",t[t.Worksheet=2]="Worksheet",t[t.SelectRange=3]="SelectRange",t[t.Document=4]="Document",t[t.Slide=5]="Slide",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(fn||{});class Mn extends Tt{}class hs{constructor(){_(this,"_data",[])}static create(){return new hs}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const e=this._data.indexOf(n);this._data.splice(e,1)}getData(){return this._data}}class ds{constructor(){_(this,"_data",new Map)}static create(){return new ds}add(n,e){this._data.has(n)||this._data.set(n,e)}delete(n){this._data.delete(n)}getData(){return this._data}}var Ri=(t=>(t[t.PARAGRAPH=0]="PARAGRAPH",t[t.SECTION_BREAK=1]="SECTION_BREAK",t[t.TABLE=2]="TABLE",t[t.TABLE_ROW=3]="TABLE_ROW",t[t.TABLE_CELL=4]="TABLE_CELL",t[t.CUSTOM_BLOCK=5]="CUSTOM_BLOCK",t))(Ri||{}),ce=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
5
+ `,t.TABLE_START="",t.TABLE_ROW_START="\x1B",t.TABLE_CELL_START="",t.TABLE_CELL_END="",t.TABLE_ROW_END="",t.TABLE_END="",t.CUSTOM_RANGE_START="",t.CUSTOM_RANGE_END="",t.COLUMN_BREAK="\v",t.PAGE_BREAK="\f",t.DOCS_END="\0",t.TAB=" ",t.CUSTOM_BLOCK="\b",t.LETTER="",t.SPACE=" ",t))(ce||{}),Sn=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Sn||{});const Il={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:{v:21},indentStart:{v:63}}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:fe.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:21}},{bulletAlignment:fe.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:42}},{bulletAlignment:fe.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:je.DECIMAL,hanging:{v:21},indentStart:{v:63}}]}};function fs(t){const n=[];for(const e of t){const{ed:s,ts:r}=e;if(e.sId===void 0&&delete e.sId,x.isEmptyObject(r)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const i=n.pop();qr(e,i)&&x.hasIntersectionBetweenTwoRanges(i.st,i.ed,e.st,e.ed)?n.push({...e,st:i.st,ed:s}):n.push(i,e)}return n}function Ci(t,n,e,s){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(h=n.textRuns)!=null?h:[];if(l.length)for(const c of l)c.st+=s,c.ed+=s;for(let c=0;c<o;c++){const u=r[c],d=r[c+1],{st:f,ed:m}=u;if(m<s)i.push(u);else if(s>=f&&s<=m){if(d&&d.st===d.ed&&s===d.st){i.push(u);continue}if(a)u.st+=e,u.ed+=e,i.push(u);else{a=!0,u.ed+=e;const E=[];if(l.length){const M={...u,st:f,ed:l[0].st};M.ed>M.st&&E.push(M),E.push(...l);const L=l[l.length-1],tt={...u,st:L.ed,ed:m+e};tt.ed>tt.st&&E.push(tt)}else E.push(u);i.push(...E)}}else u.st+=e,u.ed+=e,a||(a=!0,i.push(...l)),i.push(u)}a||(a=!0,i.push(...l)),t.textRuns=fs(i)}function _s(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let c=0,u=r.length;c<u;c++){const d=r[c],{startIndex:f}=d;f>=s&&(d.startIndex+=e),l===-1&&f>=s&&(l=c),a.push(d.startIndex)}let h=-1;if(i){for(let c=0,u=i.length;c<u;c++){const d=i[c];d.startIndex+=s;const f=d.startIndex;h=a.indexOf(f)}if(o===ce.PARAGRAPH&&i.length===1){const c=r[l],u=i[0],d=c.paragraphStyle,f=c.bullet;c.paragraphStyle=u.paragraphStyle,c.bullet=u.bullet,u.paragraphStyle=d,u.bullet=f}h!==-1&&r.splice(h,1),r.push(...i),r.sort(Me("startIndex"))}}function Sl(t,n,e,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=s&&(l.startIndex+=e)}const i=n.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Me("startIndex"))}}function Ii(t,n,e,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=s&&(l.startIndex+=e)}const i=n.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(Me("startIndex"))}}function Si(t,n,e,s){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h,endIndex:c}=l;h>s?(l.startIndex+=e,l.endIndex+=e):c>=s-1&&(l.endIndex+=e)}const i=n.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(Me("startIndex"))}}function Oi(t,n,e,s){t.customRanges||(t.customRanges=[]);const{customRanges:r}=t,i={};for(let l=0,h=r.length;l<h;l++){const c=r[l];i[c.rangeId]=c;const{startIndex:u,endIndex:d}=c;u>=s?(c.startIndex+=e,c.endIndex+=e):d>s-1&&(c.endIndex+=e)}if(r.find(l=>l.startIndex>s&&l.endIndex<s))return;const a=[];if(n.customRanges){for(let l=0,h=n.customRanges.length;l<h;l++){const c=n.customRanges[l],u=i[c.rangeId];if(c.startIndex+=s,c.endIndex+=s,u){if(u.startIndex<=c.startIndex&&u.endIndex>=c.endIndex||t.dataStream[u.startIndex]===ce.CUSTOM_RANGE_START&&t.dataStream[u.endIndex]===ce.CUSTOM_RANGE_END)continue;if(t.dataStream[u.startIndex]===ce.CUSTOM_RANGE_START){u.endIndex=c.endIndex;continue}if(t.dataStream[u.endIndex]===ce.CUSTOM_RANGE_END){u.startIndex=c.startIndex;continue}}a.push(c)}r.push(...a),r.sort(Me("startIndex"))}}function Ol(t){t.sort((s,r)=>s.startIndex-r.startIndex);const n=[];let e=t[0];for(let s=1;s<t.length;s++)e.endIndex+1>=t[s].startIndex?e.endIndex=Math.max(e.endIndex,t[s].endIndex):(n.push(e),e=t[s]);return n.push(e),n}function Nl(t){const n={};for(let e=0,s=t.length;e<s;e++){const r=t[e],i=n[r.id];n[r.id]=[...i!=null?i:[],r]}return Object.keys(n).forEach(e=>{const s=n[e],r=Ol(s);n[e]=r}),Object.values(n).flat()}function Ni(t,n,e,s){t.customDecorations||(t.customDecorations=[]);const{customDecorations:r}=t;if(e>0)for(let i=0,o=r.length;i<o;i++){const a=r[i],{startIndex:l,endIndex:h}=a;l>=s?(a.startIndex+=e,a.endIndex+=e):h>s-1&&(a.endIndex+=e)}if(n.customDecorations){const i=[];for(let o=0,a=n.customDecorations.length;o<a;o++){const l=n.customDecorations[o];i.push(l),l.startIndex+=s,l.endIndex+=s}r.push(...i),t.customDecorations=Nl(r),t.customDecorations.sort(Me("startIndex"))}}function Ai(t,n,e){var a;const{textRuns:s}=t,r=e,i=e+n,o=[];if(r===i&&(s!=null&&s.find(l=>l.st===e&&l.ed===e))){const l=s.find(h=>h.st===e&&h.ed===e);return o.push({...l,st:l.st-e,ed:l.ed-e}),t.textRuns=(a=t.textRuns)==null?void 0:a.filter(h=>h!==l),o}if(s){const l=[];for(let h=0,c=s.length;h<c;h++){const u=s[h],{st:d,ed:f}=u;if(r<=d&&i>=f){o.push({...u,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=n):r>=d&&r<f?(o.push({...u,st:r-r,ed:f-r}),u.ed=r):i>d&&i<=f?(o.push({...u,st:d-r,ed:i-r}),u.st=i-n,u.ed-=n):d>=i&&(u.st-=n,u.ed-=n);l.push(u)}t.textRuns=l}return o.length===0&&o.push({st:0,ed:n,ts:{}}),o}function bi(t,n,e){const{paragraphs:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const c=s[l],{startIndex:u}=c;if(u>=r&&u<i){o.push({...c,startIndex:u-e});continue}else u>=i&&(c.startIndex-=n);a.push(c)}t.paragraphs=a}return o}function vi(t,n,e){const{sectionBreaks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const c=s[l],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-e});continue}else u>i&&(c.startIndex-=n);a.push(c)}t.sectionBreaks=a}return o}function wi(t,n,e){const{customBlocks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const c=s[l],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-e});continue}else u>i&&(c.startIndex-=n);a.push(c)}t.customBlocks=a}return o}function Ti(t,n,e){const{tables:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const c=s[l],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=d){o.push({...c,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}t.tables=a}return o}function Mi(t,n,e){const{customRanges:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,h=s.length;l<h;l++){const c=s[l],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=u){o.push({...c,startIndex:u-e,endIndex:d-e});continue}else if(u<=r&&d>=i){const f=wn(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=n,c.endIndex-=n);a.push(c)}t.customRanges=a}return o}function Ui(t,n,e,s=!0){const{customDecorations:r}=t,i=e,o=e+n-1,a=[];if(r){const l=[];for(let h=0,c=r.length;h<c;h++){const u=r[h],{startIndex:d,endIndex:f}=u;if(d>=i&&f<=o){a.push(u);continue}else if(Math.max(i,d)<=Math.min(o,f)){const m=wn(d,f,i,o);u.startIndex=m[0],u.endIndex=m[1]}else o<d&&s&&(u.startIndex-=n,u.endIndex-=n);l.push(u)}t.customDecorations=l}return a}function Al(t,n,e,s,r){const i=bl(t,n,e,s,r),o=vl(t,n,e,s,r),a=wl(t,n,e,s,r),l=Tl(t,n,e,s,r),h=Ml(t,n,e,s,r),c=Ul(t,n,e,s,r),u=Ll(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:h,customRanges:c,customDecorations:u}}function bl(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=Ai(t,e,s);if(r!==Pt.REPLACE){const l=Li(o,a,r);n.textRuns=l}return Ci(t,n,e,s),a}function Li(t,n,e){if(n.length===0)return t;t=x.deepClone(t),n=x.deepClone(n);const s=[],r=t.length,i=n.length;let o=0,a=0,l=null;function h(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:f,ed:m,ts:E}=t[o],{st:M,ed:L,ts:tt,sId:mt}=n[a];let ht;if(e===Pt.COVER?ht={...tt,...E}:ht={...E,...tt},m<M)h()||s.push(t[o]),o++;else if(L<f)h()||s.push(n[a]),a++;else{const p={st:Math.min(f,M),ed:Math.max(f,M),ts:f<M?{...E}:{...tt},sId:f<M?void 0:mt};p.ed>p.st&&s.push(p),s.push({st:Math.max(f,M),ed:Math.min(m,L),ts:ht,sId:mt}),m<L?(o++,n[a].st=m,n[a].st===n[a].ed&&a++):(a++,t[o].st=L,t[o].st===t[o].ed&&o++);const S={st:Math.min(m,L),ed:Math.max(m,L),ts:m<L?{...tt}:{...E},sId:m<L?mt:void 0};l=S.ed>S.st?S:null}}h();const c=s[s.length-1],u=t[r-1],d=n[i-1];return c.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?s.push(u):s.push(d)),fs(s)}function vl(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=bi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c,paragraphStyle:u,bullet:d}=h;let f=[];for(const m of a){const{startIndex:E,paragraphStyle:M,bullet:L}=m;let tt,mt;if(r===Pt.COVER?(tt={...M,...u},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...L,...d}):(tt={...u,...M},mt={listId:"",listType:Sn.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...L}),c===E){f.push({startIndex:c,paragraphStyle:tt,bullet:mt});break}}l.push(...f),f=[]}n.paragraphs=l}return _s(t,n,e,s),a}function wl(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=vi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){r===Pt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.sectionBreaks=l}return _s(t,n,e,s),a}function Tl(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=wi(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of a){const{startIndex:f}=d;if(c===f){r===Pt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}l.push(...u),u=[]}n.customBlocks=l}return Ii(t,n,e,s),a}function Ml(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=Ti(t,e,s);if(r!==Pt.REPLACE){const l=[];for(const h of o){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of a){const{startIndex:m,endIndex:E}=f;if(m>=c&&E<=u){r===Pt.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}n.tables=l}return Si(t,n,e,s),a}function Ul(t,n,e,s,r){t.customRanges||(t.customRanges=[]);const{customRanges:i}=t,{customRanges:o}=n;if(i==null||o==null)return;let a=[];return r===Pt.REPLACE&&(a=Mi(t,e,s)),Oi(t,n,0,s),a}function Ll(t,n,e,s,r){t.customDecorations||(t.customDecorations=[]);let i=[];return r===Pt.REPLACE&&(i=Ui(t,e,s,!1)),Ni(t,n,0,s),i}var gs=(t=>(t[t.copy=0]="copy",t[t.cut=1]="cut",t))(gs||{});function Ze(t,n,e,s=!1,r=1){const{dataStream:i,textRuns:o=[],paragraphs:a=[],customBlocks:l=[]}=t,h={dataStream:i.slice(n,e)},c=[];for(const m of o){const E=x.deepClone(m),{st:M,ed:L}=E;x.hasIntersectionBetweenTwoRanges(M,L,n,e)&&(n>=M&&n<=L?c.push({...E,st:n,ed:Math.min(e,L)}):e>=M&&e<=L?c.push({...E,st:Math.max(n,M),ed:e}):c.push(E))}c.length?h.textRuns=c.map(m=>{const{st:E,ed:M}=m;return{...m,st:E-n,ed:M-n}}):s&&(h.textRuns=[{st:0,ed:e-n,ts:{}}]);const u=[];for(const m of a){const{startIndex:E}=m;E>=n&&E<=e&&u.push(x.deepClone(m))}u.length&&(h.paragraphs=u.map(m=>({...m,startIndex:m.startIndex-n}))),r===1&&(h.customDecorations=yi(t,n,e));const{customRanges:d}=Di(t,n,e);h.customRanges=d;const f=[];for(const m of l){const{startIndex:E}=m;E>=n&&E<=e&&f.push(x.deepClone(m))}return f.length&&(h.customBlocks=f.map(m=>({...m,startIndex:m.startIndex-n}))),h}function Dl(t){const{dataStream:n,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}=t;let o=0,a=0;r==null||r.forEach(h=>{h.startIndex<0&&(o=Math.max(o,-h.startIndex)),h.endIndex>n.length-1&&(a=Math.max(a,h.endIndex-n.length+1))});const l=`${ce.CUSTOM_RANGE_START.repeat(o)}${n}${ce.CUSTOM_RANGE_END.repeat(a)}`;return e&&(e[0]&&(e[0].st=e[0].st-o),e[e.length-1]&&(e[e.length-1].ed=e[e.length-1].ed+a)),e==null||e.forEach(h=>{h.st+=o,h.ed+=o}),s==null||s.forEach(h=>{h.startIndex+=o}),r==null||r.forEach(h=>{h.startIndex+=o,h.endIndex+=o}),i==null||i.forEach(h=>{h.startIndex+=o,h.endIndex+=a}),{...t,dataStream:l,textRuns:e,paragraphs:s,customRanges:r,customDecorations:i}}function Di(t,n,e){const{customRanges:s=[]}=t;let r=0,i=0;const o=s.filter(a=>Math.max(a.startIndex,n)<=Math.min(a.endIndex,e-1)).map(a=>({...a,startIndex:a.startIndex,endIndex:a.endIndex}));if(o.length){o.forEach(a=>{a.startIndex<n&&(r+=1),a.endIndex>e-1&&(i+=1)});for(let a=0;a<r;a++){const l=o[a];l.startIndex=n-r+a}if(i){const a=[...o].sort((l,h)=>h.endIndex-l.endIndex);for(let l=0;l<i;l++){const h=a[l];h.endIndex=e+i-l-1}}}return{customRanges:o.map(a=>({...a,startIndex:a.startIndex-n,endIndex:a.endIndex-n})),leftOffset:r,rightOffset:i}}function yi(t,n,e){const{customDecorations:s=[]}=t,r=[];return s.forEach(i=>{if(Math.max(i.startIndex,n)<=Math.min(i.endIndex,e-1)){const o=x.deepClone(i);r.push({...o,startIndex:Math.max(o.startIndex-n,0),endIndex:Math.min(o.endIndex,e)-n})}}),r}function ts(t,n,e=Pt.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=n,l=Li(o,r,e);l.length&&(s.textRuns=l);const h=[];let c=0,u=0;for(;c<i.length&&u<a.length;){const d=i[c],f=a[u],{startIndex:m}=d,{startIndex:E}=f;m===E?(h.push(x.deepMerge(d,f)),c++,u++):m<E?(h.push(x.deepClone(d)),c++):(h.push(x.deepClone(f)),u++)}return c<i.length&&h.push(...i.slice(c)),u<a.length&&h.push(...a.slice(u)),h.length&&(s.paragraphs=h),s}function yl(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function xl(t=x.generateRandomId(6),n=Te.EN_US,e=""){return{id:t,locale:n,title:e,body:{dataStream:`\r
6
+ `,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:{v:5},lineSpacing:1,spaceBelow:{v:0}}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var Wt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $t={},xi={},ms={};Object.defineProperty(ms,"__esModule",{value:!0});function kl(t,n){if(Array.isArray(n))return!1;for(let e in t)if(!Es(t[e],n[e]))return!1;for(let e in n)if(t[e]===void 0)return!1;return!0}function Hl(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(!Es(t[e],n[e]))return!1;return!0}function Es(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?Hl(t,n):kl(t,n)}ms.default=Es;var ps={};Object.defineProperty(ps,"__esModule",{value:!0});function es(t){if(t===null)return null;if(Array.isArray(t))return t.map(es);if(typeof t=="object"){const n={};for(let e in t)n[e]=es(t[e]);return n}else return t}ps.default=es;var Rs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.eachChildOf=t.advancer=t.readCursor=t.writeCursor=t.WriteCursor=t.ReadCursor=t.isValidPathItem=void 0;function n(c,u){if(!c)throw new Error(u)}const e=c=>c!=null&&typeof c=="object"&&!Array.isArray(c),s=(c,u)=>typeof c==typeof u?c>u:typeof c=="string"&&typeof u=="number";function r(c,u){for(let d in c){const f=d;u.write(f,c[f])}}t.isValidPathItem=c=>typeof c=="number"||typeof c=="string"&&c!=="__proto__";class i{constructor(u=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=u}ascend(){n(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(n(this.idx>0),this.idx--,e(this.container[this.idx])&&this.idx--)}getPath(){const u=[];let d=this.container,f=this.parents.length-1,m=this.idx;for(;m>=0;)u.unshift(d[m]),m===0?(m=this.indexes[f*2],d=this.parents[f--]):m-=e(d[m-1])?2:1;return u}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return n(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let u;return this.container&&this.container.length>this.idx+1&&e(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||e(this.container[u])&&u+1>=this.container.length)return!1;e(this.container[u])&&u++;const d=this.container[u];return Array.isArray(d)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(u),this.idx=0,this.container=d):this.idx=u,!0}nextSibling(){if(n(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const u=this.indexes[this.indexes.length-1]+1,d=this.parents[this.parents.length-1];return u>=d.length?!1:(n(!isNaN(u)),this.indexes[this.indexes.length-1]=u,this.container=d[u],!0)}_init(u,d,f,m){this.container=u,this.idx=d,this.parents=f.slice(),this.indexes=m.slice()}clone(){const u=new o;return u._init(this.container,this.idx,this.parents,this.indexes),u}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(u,d){const f=this.getComponent();f&&d(f,u);for(const m of this)u&&u.descend(m),this.traverse(u,d),u&&u.ascend()}eachPick(u,d){this.traverse(u,(f,m)=>{f.p!=null&&d(f.p,m)})}eachDrop(u,d){this.traverse(u,(f,m)=>{f.d!=null&&d(f.d,m)})}}t.ReadCursor=o;class a extends i{constructor(u=null){super(u),this.pendingDescent=[],this._op=u}flushDescent(){n(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let u=0;u<this.pendingDescent.length;u++){const d=this.pendingDescent[u];let f=this.idx+1;if(f<this.container.length&&e(this.container[f])&&f++,n(f===this.container.length||!e(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const m=this.container.splice(f,this.container.length-f);this.container.push(m),this.lcIdx>-1&&(this.lcIdx=f)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(n(s(d,this.container[this.lcIdx][0])),f=this.lcIdx+1,this.lcIdx=-1);f<this.container.length&&s(d,this.container[f][0]);)f++;if(this.indexes.push(f),this.idx=0,f<this.container.length&&this.container[f][0]===d)this.container=this.container[f];else{const m=[d];this.container.splice(f,0,m),this.container=m}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const u=this.idx+1;if(u<this.container.length&&e(this.container[u]))return this.container[u];{const d={};return this.container.splice(u,0,d),d}}write(u,d){const f=this.getComponent();n(f[u]==null||f[u]===d,"Internal consistency error: Overwritten component. File a bug"),f[u]=d}get(){return this._op}descend(u){if(!t.isValidPathItem(u))throw Error("Invalid JSON key");this.pendingDescent.push(u)}descendPath(u){return this.pendingDescent.push(...u),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(u,d=r){if(u===null)return;if(n(Array.isArray(u)),u===this._op)throw Error("Cannot merge into my own tree");const f=this.lcIdx,m=this.parents.length;let E=0;for(let M=0;M<u.length;M++){const L=u[M];typeof L=="string"||typeof L=="number"?(E++,this.descend(L)):Array.isArray(L)?this.mergeTree(L,d):typeof L=="object"&&d(L,this)}for(;E--;)this.ascend();this.lcIdx=this.parents.length===m?f:-1}at(u,d){this.descendPath(u),d(this);for(let f=0;f<u.length;f++)this.ascend();return this}writeAtPath(u,d,f){return this.at(u,()=>this.write(d,f)),this.reset(),this}writeMove(u,d,f=0){return this.writeAtPath(u,"p",f).writeAtPath(d,"d",f)}getPath(){const u=super.getPath();return u.push(...this.pendingDescent),u}}t.WriteCursor=a,t.writeCursor=()=>new a,t.readCursor=c=>new o(c);function l(c,u,d){let f,m;m=f=c?c.descendFirst():!1;function E(M){let L;for(;m;){const tt=L=c.getKey();if(M!=null){let mt=!1;if(u&&typeof tt=="number"&&(L=u(tt,c.getComponent()),L<0&&(L=~L,mt=!0)),s(L,M))return null;if(L===M&&!mt)return c}d&&typeof L=="number"&&d(L,c.getComponent()),m=c.nextSibling()}return null}return E.end=()=>{f&&c.ascend()},E}t.advancer=l;function h(c,u,d){let f,m,E,M;for(f=m=c&&c.descendFirst(),E=M=u&&u.descendFirst();f||E;){let L=f?c.getKey():null,tt=E?u.getKey():null;L!==null&&tt!==null&&(s(tt,L)?tt=null:L!==tt&&(L=null)),d(L==null?tt:L,L!=null?c:null,tt!=null?u:null),L!=null&&f&&(f=c.nextSibling()),tt!=null&&E&&(E=u.nextSibling())}m&&c.ascend(),M&&u.ascend()}t.eachChildOf=h})(Rs);var Cs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConflictType=void 0,function(n){n[n.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",n[n.DROP_COLLISION=2]="DROP_COLLISION",n[n.BLACKHOLE=3]="BLACKHOLE"}(t.ConflictType||(t.ConflictType={}))})(Cs);var Bn={},Oe={},Hs;function Is(){return Hs||(Hs=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.uniToStrPos=Oe.strPosToUni=void 0,Oe.strPosToUni=(t,n=t.length)=>{let e=0,s=0;for(;s<n;s++){const r=t.charCodeAt(s);r>=55296&&r<=57343&&(e++,s++)}if(s!==n)throw Error("Invalid offset - splits unicode bytes");return s-e},Oe.uniToStrPos=(t,n)=>{let e=0;for(;n>0;n--){const s=t.charCodeAt(e);e+=s>=55296&&s<=57343?2:1}return e}),Oe}var Gn={},Fs;function ns(){return Fs||(Fs=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const n=Is(),e=p=>{if(!Array.isArray(p))throw Error("Op must be an array of components");let S=null;for(let v=0;v<p.length;v++){const z=p[v];switch(typeof z){case"object":if(typeof z.d!="number"&&typeof z.d!="string")throw Error("Delete must be number or string");if(t.dlen(z.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(z.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(z>0))throw Error("Skip components must be >0");if(typeof S=="number")throw Error("Adjacent skip components should be combined");break}S=z}if(typeof S=="number")throw Error("Op has a trailing skip")};function s(p,S){let v=0,z=0;for(let nt=0;nt<p.length;nt++){const X=p[nt];switch(S(X,v,z),typeof X){case"object":v+=t.dlen(X.d);break;case"string":z+=n.strPosToUni(X);break;case"number":v+=X,z+=X;break}}}t.eachOp=s;function r(p,S){const v=[],z=a(v);return s(p,(nt,X,Gt)=>{z(S(nt,X,Gt))}),u(v)}const i=p=>p,o=p=>r(p,i);t.dlen=p=>typeof p=="number"?p:n.strPosToUni(p);const a=p=>S=>{if(!(!S||S.d===0||S.d===""))if(p.length===0)p.push(S);else if(typeof S==typeof p[p.length-1])if(typeof S=="object"){const v=p[p.length-1];v.d=typeof v.d=="string"&&typeof S.d=="string"?v.d+S.d:t.dlen(v.d)+t.dlen(S.d)}else p[p.length-1]+=S;else p.push(S)},l=p=>typeof p=="number"?p:typeof p=="string"?n.strPosToUni(p):typeof p.d=="number"?p.d:n.strPosToUni(p.d);t.uniSlice=(p,S,v)=>{const z=n.uniToStrPos(p,S),nt=v==null?1/0:n.uniToStrPos(p,v);return p.slice(z,nt)};const h=(p,S,v)=>typeof p=="number"?v==null?p-S:Math.min(p,v)-S:t.uniSlice(p,S,v),c=p=>{let S=0,v=0;return{take:(X,Gt)=>{if(S===p.length)return X===-1?null:X;const Ot=p[S];let _t;if(typeof Ot=="number")return X===-1||Ot-v<=X?(_t=Ot-v,++S,v=0,_t):(v+=X,X);if(typeof Ot=="string"){if(X===-1||Gt==="i"||n.strPosToUni(Ot.slice(v))<=X)return _t=Ot.slice(v),++S,v=0,_t;{const It=v+n.uniToStrPos(Ot.slice(v),X);return _t=Ot.slice(v,It),v=It,_t}}else{if(X===-1||Gt==="d"||t.dlen(Ot.d)-v<=X)return _t={d:h(Ot.d,v)},++S,v=0,_t;{let It=h(Ot.d,v,v+X);return v+=X,{d:It}}}},peek:()=>p[S]}},u=p=>(p.length>0&&typeof p[p.length-1]=="number"&&p.pop(),p);function d(p,S,v){if(v!=="left"&&v!=="right")throw Error("side ("+v+") must be 'left' or 'right'");e(p),e(S);const z=[],nt=a(z),{take:X,peek:Gt}=c(p);for(let _t=0;_t<S.length;_t++){const It=S[_t];let Mt,jt;switch(typeof It){case"number":for(Mt=It;Mt>0;)jt=X(Mt,"i"),nt(jt),typeof jt!="string"&&(Mt-=l(jt));break;case"string":v==="left"&&typeof Gt()=="string"&&nt(X(-1)),nt(n.strPosToUni(It));break;case"object":for(Mt=t.dlen(It.d);Mt>0;)switch(jt=X(Mt,"i"),typeof jt){case"number":Mt-=jt;break;case"string":nt(jt);break;case"object":Mt-=t.dlen(jt.d)}break}}let Ot;for(;Ot=X(-1);)nt(Ot);return u(z)}function f(p,S){e(p),e(S);const v=[],z=a(v),{take:nt}=c(p);for(let Gt=0;Gt<S.length;Gt++){const Ot=S[Gt];let _t,It;switch(typeof Ot){case"number":for(_t=Ot;_t>0;)It=nt(_t,"d"),z(It),typeof It!="object"&&(_t-=l(It));break;case"string":z(Ot);break;case"object":_t=t.dlen(Ot.d);let Mt=0;for(;Mt<_t;)switch(It=nt(_t-Mt,"d"),typeof It){case"number":z({d:h(Ot.d,Mt,Mt+It)}),Mt+=It;break;case"string":Mt+=n.strPosToUni(It);break;case"object":z(It)}break}}let X;for(;X=nt(-1);)z(X);return u(v)}const m=(p,S)=>{let v=0;for(let z=0;z<S.length&&p>v;z++){const nt=S[z];switch(typeof nt){case"number":{v+=nt;break}case"string":const X=n.strPosToUni(nt);v+=X,p+=X;break;case"object":p-=Math.min(t.dlen(nt.d),p-v);break}}return p},E=(p,S)=>typeof p=="number"?m(p,S):p.map(v=>m(v,S));function M(p,S,v){return r(p,(z,nt)=>typeof z=="object"&&typeof z.d=="number"?{d:v.slice(S,nt,nt+z.d)}:z)}function L(p){return r(p,S=>{switch(typeof S){case"object":if(typeof S.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return S.d;case"string":return{d:S};case"number":return S}})}function tt(p){return r(p,S=>typeof S=="object"&&typeof S.d=="string"?{d:n.strPosToUni(S.d)}:S)}function mt(p){let S=!0;return s(p,v=>{typeof v=="object"&&typeof v.d=="number"&&(S=!1)}),S}function ht(p){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:o,checkOp:e,create(S=""){if(typeof S!="string")throw Error("Initial data must be a string");return p.create(S)},apply(S,v){e(v);const z=p.builder(S);for(let nt=0;nt<v.length;nt++){const X=v[nt];switch(typeof X){case"number":z.skip(X);break;case"string":z.append(X);break;case"object":z.del(t.dlen(X.d));break}}return z.build()},transform:d,compose:f,transformPosition:m,transformSelection:E,isInvertible:mt,makeInvertible(S,v){return M(S,v,p)},stripInvertible:tt,invert:L,invertWithDoc(S,v){return L(M(S,v,p))},isNoop:S=>S.length===0}}t.default=ht}(Gn)),Gn}var un={},$s;function Fl(){if($s)return un;$s=1,Object.defineProperty(un,"__esModule",{value:!0});const t=ns(),n=Is();function e(s,r){return{get:s,getLength(){return s().length},insert(i,o,a){const l=n.strPosToUni(s(),i);return r([l,o],a)},remove(i,o,a){const l=n.strPosToUni(s(),i);return r([l,{d:o}],a)},_onOp(i){t.eachOp(i,(o,a,l)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(l,o);break;case"object":const h=t.dlen(o.d);this.onRemove&&this.onRemove(l,h)}})},onInsert:null,onRemove:null}}return un.default=e,e.provides={text:!0},un}var Ws;function $l(){return Ws||(Ws=1,function(t){var n=Wt&&Wt.__createBinding||(Object.create?function(d,f,m,E){E===void 0&&(E=m),Object.defineProperty(d,E,{enumerable:!0,get:function(){return f[m]}})}:function(d,f,m,E){E===void 0&&(E=m),d[E]=f[m]}),e=Wt&&Wt.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),s=Wt&&Wt.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var m in d)Object.hasOwnProperty.call(d,m)&&n(f,d,m);return e(f,d),f},r=Wt&&Wt.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=Is(),o=s(ns()),a=r(Fl()),l={create(d){return d},toString(d){return d},builder(d){if(typeof d!="string")throw Error("Invalid document snapshot: "+d);const f=[];return{skip(m){let E=i.uniToStrPos(d,m);if(E>d.length)throw Error("The op is too long for this document");f.push(d.slice(0,E)),d=d.slice(E)},append(m){f.push(m)},del(m){d=d.slice(i.uniToStrPos(d,m))},build(){return f.join("")+d}}},slice:o.uniSlice},h=o.default(l),c=Object.assign(Object.assign({},h),{api:a.default});t.type=c,t.insert=(d,f)=>f.length===0?[]:d===0?[f]:[d,f],t.remove=(d,f)=>o.dlen(f)===0?[]:d===0?[{d:f}]:[d,{d:f}];var u=ns();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return u.default}})}(Bn)),Bn}(function(t){var n=Wt&&Wt.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(t,"__esModule",{value:!0}),t.editOp=t.replaceOp=t.insertOp=t.moveOp=t.removeOp=t.type=void 0;const e=n(ms),s=n(ps),r=Rs,i=Cs;function o(g,R){if(!g)throw new Error(R)}t.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:g=>g,isNoop:g=>g==null,setDebug(g){},registerSubtype:L,checkValidOp:nt,normalize:X,apply:Gt,transformPosition:Ot,compose:_t,tryTransform:kn,transform:Mo,makeInvertible:jt,invert:It,invertWithDoc:To,RM_UNEXPECTED_CONTENT:i.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:i.ConflictType.DROP_COLLISION,BLACKHOLE:i.ConflictType.BLACKHOLE,transformNoConflict:(g,R,N)=>Ms(()=>!0,g,R,N),typeAllowingConflictsPred:g=>Object.assign(Object.assign({},t.type),{transform:(R,N,U)=>Ms(g,R,N,U)})};const a=g=>g?g.getComponent():null;function l(g){return g&&typeof g=="object"&&!Array.isArray(g)}const h=g=>Array.isArray(g)?g.slice():g!==null&&typeof g=="object"?Object.assign({},g):g,c=g=>g&&(g.p!=null||g.r!==void 0),u=g=>g&&(g.d!=null||g.i!==void 0);function d(g,R){return o(g!=null),typeof R=="number"?(o(Array.isArray(g),"Invalid key - child is not an array"),(g=g.slice()).splice(R,1)):(o(l(g),"Invalid key - child is not an object"),delete(g=Object.assign({},g))[R]),g}function f(g,R,N){return typeof R=="number"?(o(g!=null,"Container is missing for key"),o(Array.isArray(g),"Cannot use numerical key for object container"),o(g.length>=R,"Cannot insert into out of bounds index"),g.splice(R,0,N)):(o(l(g),"Cannot insert into missing item"),o(g[R]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),g[R]=N),N}t.removeOp=(g,R=!0)=>r.writeCursor().writeAtPath(g,"r",R).get(),t.moveOp=(g,R)=>r.writeCursor().writeMove(g,R).get(),t.insertOp=(g,R)=>r.writeCursor().writeAtPath(g,"i",R).get(),t.replaceOp=(g,R,N)=>r.writeCursor().at(g,U=>{U.write("r",R),U.write("i",N)}).get(),t.editOp=(g,R,N,U=!1)=>r.writeCursor().at(g,A=>S(A,R,N,U)).get();const m=(g,R)=>g!=null&&(typeof R=="number"?Array.isArray(g):typeof g=="object"),E=(g,R)=>m(g,R)?g[R]:void 0,M={};function L(g){let R=g.type?g.type:g;R.name&&(M[R.name]=R),R.uri&&(M[R.uri]=R)}const tt=g=>{const R=M[g];if(R)return R;throw Error("Missing type: "+g)};L($l());const mt=(g,R)=>g+R;L({name:"number",apply:mt,compose:mt,invert:g=>-g,transform:g=>g});const ht=g=>g==null?null:g.et?tt(g.et):g.es?M["text-unicode"]:g.ena!=null?M.number:null,p=g=>g.es?g.es:g.ena!=null?g.ena:g.e,S=(g,R,N,U=!1)=>{const[A,T]=typeof R=="string"?[tt(R),R]:[R,R.name];!U&&A.isNoop&&A.isNoop(N)||(T==="number"?g.write("ena",N):T==="text-unicode"?g.write("es",N):(g.write("et",T),g.write("e",N)))};function v(g){o(typeof g=="number"),o(g>=0),o(g===(0|g))}function z(g){typeof g=="number"?v(g):o(typeof g=="string")}function nt(g){if(g===null)return;const R=new Set,N=new Set,U=T=>{let G=!0,W=!1;for(let C in T){const O=T[C];if(G=!1,o(C==="p"||C==="r"||C==="d"||C==="i"||C==="e"||C==="es"||C==="ena"||C==="et","Invalid component item '"+C+"'"),C==="p")v(O),o(!R.has(O)),R.add(O),o(T.r===void 0);else if(C==="d")v(O),o(!N.has(O)),N.add(O),o(T.i===void 0);else if(C==="e"||C==="es"||C==="ena"){o(!W),W=!0;const b=ht(T);o(b,"Missing type in edit"),b.checkValidOp&&b.checkValidOp(p(T))}}o(!G)},A=(T,G,W)=>{if(!Array.isArray(T))throw Error("Op must be null or a list");if(T.length===0)throw Error("Empty descent");G||z(T[0]);let C=1,O=0,b=0;for(let w=0;w<T.length;w++){const B=T[w];if(o(B!=null),Array.isArray(B)){const j=A(B,!1);if(O){const I=typeof b,H=typeof j;I===H?o(b<j,"descent keys are not in order"):o(I==="number"&&H==="string")}b=j,O++,C=3}else typeof B=="object"?(o(C===1,`Prev not scalar - instead ${C}`),U(B),C=2):(o(C!==3),z(B),o(r.isValidPathItem(B),"Invalid path key"),C=1)}return o(O!==1,"Operation makes multiple descents. Remove some []"),o(C===2||C===3),T[0]};A(g,!0),o(R.size===N.size,"Mismatched picks and drops in op");for(let T=0;T<R.size;T++)o(R.has(T)),o(N.has(T))}function X(g){let R=0,N=[];const U=r.writeCursor();return U.mergeTree(g,(A,T)=>{const G=ht(A);if(G){const C=p(A);S(T,G,G.normalize?G.normalize(C):C)}for(const C of["r","p","i","d"])if(A[C]!==void 0){const O=C==="p"||C==="d"?(W=A[C],N[W]==null&&(N[W]=R++),N[W]):A[C];T.write(C,O)}var W}),U.get()}function Gt(g,R){if(nt(R),R===null)return g;const N=[];return function U(A,T){let G=A,W=0,C={root:A},O=0,b=C,w="root";function B(){for(;O<W;O++){let j=T[O];typeof j!="object"&&(o(m(b,w)),b=b[w]=h(b[w]),w=j)}}for(;W<T.length;W++){const j=T[W];if(Array.isArray(j)){const I=U(G,j);I!==G&&I!==void 0&&(B(),G=b[w]=I)}else if(typeof j=="object"){j.d!=null?(B(),G=f(b,w,N[j.d])):j.i!==void 0&&(B(),G=f(b,w,j.i));const I=ht(j);if(I)B(),G=b[w]=I.apply(G,p(j));else if(j.e!==void 0)throw Error("Subtype "+j.et+" undefined")}else G=E(G,j)}return C.root}(g=function U(A,T){const G=[];let W=0;for(;W<T.length;W++){const w=T[W];if(Array.isArray(w))break;typeof w!="object"&&(G.push(A),A=E(A,w))}for(let w=T.length-1;w>=W;w--)A=U(A,T[w]);for(--W;W>=0;W--){const w=T[W];if(typeof w!="object"){const B=G.pop();A=A===E(B,w)?B:A===void 0?d(B,w):(O=w,b=A,(C=h(C=B))[O]=b,C)}else c(w)&&(o(A!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(N[w.p]=A),A=void 0)}var C,O,b;return A}(g,R),R)}function Ot(g,R){g=g.slice(),nt(R);const N=r.readCursor(R);let U,A,T=!1;const G=[];for(let C=0;;C++){const O=g[C],b=N.getComponent();if(b&&(b.r!==void 0?T=!0:b.p!=null&&(T=!1,U=b.p,A=C)),C>=g.length)break;let w=0;const B=r.advancer(N,void 0,(I,H)=>{c(H)&&w++});G.unshift(B);const j=B(O);if(typeof O=="number"&&(g[C]-=w),!j)break}if(G.forEach(C=>C.end()),T)return null;const W=()=>{let C=0;if(U!=null){const O=N.getPath();C=O.length,g=O.concat(g.slice(A))}for(;C<g.length;C++){const O=g[C],b=a(N),w=ht(b);if(w){const I=p(b);w.transformPosition&&(g[C]=w.transformPosition(g[C],I));break}let B=0;const j=r.advancer(N,(I,H)=>u(H)?~(I-B):I-B,(I,H)=>{u(H)&&B++})(O);if(typeof O=="number"&&(g[C]+=B),!j)break}};return U!=null?N.eachDrop(null,C=>{C===U&&W()}):W(),g}function _t(g,R){if(nt(g),nt(R),g==null)return R;if(R==null)return g;let N=0;const U=r.readCursor(g),A=r.readCursor(R),T=r.writeCursor(),G=[],W=[],C=[],O=[],b=[],w=[],B=new Set;U.traverse(null,I=>{I.p!=null&&(C[I.p]=U.clone())}),A.traverse(null,I=>{I.d!=null&&(O[I.d]=A.clone())});const j=r.writeCursor();return function I(H,gt,lt,q,pt,ie,xt,Ut){o(gt||lt);const Rt=a(gt),Vt=a(lt),qt=!!Vt&&Vt.r!==void 0,Re=!!Rt&&Rt.i!==void 0,Kt=Rt?Rt.d:null,Bt=Vt?Vt.p:null,oe=(ie||qt)&&Bt==null;if(Bt!=null)q=O[Bt],xt=W[Bt]=new r.WriteCursor;else if(Vt&&Vt.r!==void 0)q=null;else{const y=a(q);y&&y.d!=null&&(q=null)}const ot=a(q);if(Kt!=null)if(H=C[Kt],Ut=G[Kt]=new r.WriteCursor,oe)ie&&!qt&&Ut.write("r",!0);else{const y=b[Kt]=N++;xt.write("d",y)}else if(Rt&&Rt.i!==void 0)H=null;else{const y=a(H);y&&y.p!=null&&(H=null)}let P;Re?(o(pt===void 0),P=Rt.i):P=pt;const V=(Bt==null?!Re||ie||qt:P===void 0)?null:xt.getComponent();if(Bt!=null){if(!(pt!==void 0||Re)){const y=Kt!=null?b[Kt]:N++;w[Bt]=y,Ut.write("p",y)}}else qt&&(Re||pt!==void 0||(Vt.r,Ut.write("r",Vt.r)));const k=oe?null:ht(Rt),D=ht(ot);if((k||D)&&(k&&k.name,D&&D.name),k&&D){o(k===D);const y=p(Rt),Y=p(ot),wt=k.compose(y,Y);S(xt,k,wt),B.add(ot)}else k?S(xt,k,p(Rt)):D&&(S(xt,D,p(ot)),B.add(ot));const F=typeof P=="object"&&P!=null;let st=!1,rt=0,at=0,vt=0,Nt=0,Ct=0;const yt=r.advancer(q,(y,Y)=>u(Y)?Nt-y-1:y-Nt,(y,Y)=>{u(Y)&&Nt++}),et=r.advancer(H,(y,Y)=>c(Y)?rt-y-1:y-rt,(y,Y)=>{c(Y)&&rt++});if(r.eachChildOf(gt,lt,(y,Y,wt)=>{let kt,ae,Ce=y,Zt=y,$e=y;if(typeof y=="number"){let Lt=y+vt;ae=yt(Lt),Zt=Lt+Nt;let St=y+at;kt=et(St),u(a(ae))&&(kt=null),Ce=St+rt,$e=y+Ct,o(Ce>=0,"p1PickKey is negative"),o(Zt>=0,"p2DropKey is negative");const Jt=u(a(Y)),le=c(a(wt));(Jt||le&&!oe)&&Ct--,Jt&&at--,le&&vt--}else kt=et(y),ae=yt(y);Ut.descend(Ce),xt.descend(Zt);const Le=F&&!u(a(Y))?P[$e]:void 0,ne=I(kt,Y,wt,ae,Le,oe,xt,Ut);var se,$,Et;F&&!oe?Le!==ne&&(st||(P=Array.isArray(P)?P.slice():Object.assign({},P),st=!0),se=P,Et=ne,typeof($=$e)=="number"?(o(Array.isArray(se)),o($<se.length)):(o(!Array.isArray(se)),o(se[$]!==void 0)),Et===void 0?typeof $=="number"?se.splice($,1):delete se[$]:se[$]=Et):o(ne===void 0),xt.ascend(),Ut.ascend()}),et.end(),yt.end(),V!=null)V.i=P;else if(!ie&&!qt&&Bt==null)return P}(U,U.clone(),A,A.clone(),void 0,!1,T,j),T.reset(),T.mergeTree(j.get()),T.reset(),T.get(),G.map(I=>I.get()),W.map(I=>I.get()),U.traverse(T,(I,H)=>{const gt=I.p;if(gt!=null){const lt=b[gt];lt!=null&&H.write("p",lt);const q=G[gt];q&&q.get(),q&&H.mergeTree(q.get())}else I.r!==void 0&&H.write("r",I.r)}),T.reset(),T.get(),A.traverse(T,(I,H)=>{const gt=I.d;if(gt!=null){const q=w[gt];q!=null&&H.write("d",q);const pt=W[gt];pt&&H.mergeTree(pt.get())}else I.i!==void 0&&H.write("i",I.i);const lt=ht(I);lt&&!B.has(I)&&S(H,lt,p(I))}),T.get()}function It(g){if(g==null)return null;const R=new r.ReadCursor(g),N=new r.WriteCursor;let U;const A=[],T=[];return function G(W,C,O){const b=W.getComponent();let w,B=!1;if(b){b.p!=null&&(C.write("d",b.p),A[b.p]=W.clone()),b.r!==void 0&&C.write("i",b.r),b.d!=null&&(C.write("p",b.d),O=void 0),b.i!==void 0&&(O=w=b.i);const I=ht(b);I&&(O===void 0?(U||(U=new Set),U.add(b)):(p(b),O=I.apply(O,p(b)),B=!0))}let j=0;for(const I of W){C.descend(I);const H=typeof I=="number"?I-j:I,gt=E(O,H);u(W.getComponent())&&j++;const lt=G(W,C,gt);if(O!==void 0&&lt!==void 0){if(B||(B=!0,O=h(O)),!m(O,H))throw Error("Cannot modify child - invalid operation");O[H]=lt}C.ascend()}if(w===void 0)return B?O:void 0;C.write("r",O)}(R,N,void 0),U&&(N.reset(),function G(W,C,O){const b=C.getComponent();if(b){const I=b.d;if(I!=null&&(W=A[I],O=T[I]=r.writeCursor()),U.has(b)){const H=ht(b);if(!H.invert)throw Error(`Cannot invert subtype ${H.name}`);S(O,H,H.invert(p(b)))}}let w=0,B=0;const j=r.advancer(W,(I,H)=>c(H)?w-I-1:I-w,(I,H)=>{c(H)&&w++});for(const I of C)if(typeof I=="number"){const H=I-B,gt=j(H),lt=H+w;O.descend(lt),G(gt,C,O),u(C.getComponent())&&B++,O.ascend()}else O.descend(I),G(j(I),C,O),O.ascend();j.end()}(R.clone(),R,N),T.length&&(N.reset(),R.traverse(N,(G,W)=>{const C=G.p;if(C!=null){const O=T[C];O&&O.get(),O&&W.mergeTree(O.get())}}))),N.get()}const Mt=(g,R)=>g.some(N=>typeof N=="object"&&(Array.isArray(N)?Mt(N,R):R(N)));function jt(g,R){if(g==null||!Mt(g,C=>{var O;return C.r!==void 0||((O=ht(C))===null||O===void 0?void 0:O.makeInvertible)!=null}))return g;const N=new r.ReadCursor(g),U=new r.WriteCursor;let A=!1;const T=[],G=[],W=(C,O,b)=>{const w=C.getComponent();let B=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const I=w.p;if(I!=null&&(T[I]=C.clone(),o(b!==void 0,"Operation picks up at an invalid key"),G[I]=b,O.write("p",w.p)),w.r!==void 0&&b===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const H=ht(w);H&&(H.makeInvertible?A=!0:S(O,H,p(w),!0))}let j=0;for(const I of C){O.descend(I);const H=typeof I=="number"?I-j:I,gt=E(b,H),lt=W(C,O,gt);gt!==lt&&(B||(B=!0,b=h(b)),lt===void 0?(b=d(b,H),typeof I=="number"&&j++):b[H]=lt),O.ascend()}return w&&(w.r!==void 0?(O.write("r",s.default(b)),b=void 0):w.p!=null&&(b=void 0)),b};return W(N,U,R),U.get(),A&&(U.reset(),function C(O,b,w,B,j){const I=b.getComponent();if(I){I.i!==void 0?(B=I.i,j=!0):I.d!=null&&(B=G[I.d],O=T[I.d],j=!1,I.d);let q=ht(I);if(q&&q.makeInvertible){const pt=p(I);S(w,q,q.makeInvertible(pt,B),!0)}}let H=0,gt=0;const lt=r.advancer(O,(q,pt)=>c(pt)?H-q-1:q-H,(q,pt)=>{c(pt)&&H++});for(const q of b)if(typeof q=="number"){const pt=q-gt,ie=lt(pt),xt=pt+H,Ut=E(B,j?pt:xt);w.descend(q),C(ie,b,w,Ut,j),u(b.getComponent())&&gt++,w.ascend()}else{const pt=E(B,q);w.descend(q),C(lt(q),b,w,pt,j),w.ascend()}lt.end()}(N.clone(),N,U,R,!1)),U.get()}function To(g,R){return It(jt(g,R))}const Pn=g=>{if(g==null)return null;const R=g.slice();for(let N=0;N<g.length;N++){const U=R[N];Array.isArray(U)&&(R[N]=Pn(U))}return R};function kn(g,R,N){o(N==="left"||N==="right","Direction must be left or right");const U=N==="left"?0:1;if(R==null)return{ok:!0,result:g};nt(g),nt(R);let A=null;const T=[],G=[],W=[],C=[],O=[],b=[],w=[],B=[],j=[],I=[],H=[],gt=[],lt=[],q=[],pt=[];let ie=0;const xt=r.readCursor(g),Ut=r.readCursor(R),Rt=r.writeCursor();if(function ot(P,V=null,k){const D=a(V);D&&(D.r!==void 0?k=V.clone():D.p!=null&&(k=null,b[D.p]=P.clone()));const F=P.getComponent();let st;F&&(st=F.p)!=null&&(O[st]=V?V.clone():null,W[st]=P.clone(),k&&(I[st]=!0,j[st]=k),D&&D.p!=null&&(q[st]=D.p));const rt=r.advancer(V);for(const at of P)ot(P,rt(at),k);rt.end()}(Ut,xt,null),function ot(P,V,k,D,F){const st=k.getComponent();let rt,at=!1;st&&((rt=st.d)!=null?(C[rt]=k.clone(),D!=null&&(pt[D]==null&&(pt[D]=[]),pt[D].push(rt)),P=O[rt]||null,V=W[rt]||null,I[rt]?(F&&(H[rt]=!0),F=j[rt]||null):!F||U!==1&&q[rt]!=null||A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.moveOp(V.getPath(),k.getPath())}),at=!0):st.i!==void 0&&(P=V=null,at=!0,F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.insertOp(k.getPath(),st.i)})));const vt=a(P);vt&&(vt.r!==void 0?F=P.clone():vt.p!=null&&(vt.p,D=vt.p,F=null));const Nt=ht(st);Nt&&F&&A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.editOp(k.getPath(),Nt,p(st),!0)});let Ct=0,yt=0;const et=r.advancer(V,(Y,wt)=>c(wt)?Ct-Y-1:Y-Ct,(Y,wt)=>{c(wt)&&Ct++}),y=r.advancer(P);for(const Y of k)if(typeof Y=="number"){const wt=Y-yt,kt=et(wt);yt+=+ot(y(wt+Ct),kt,k,D,F)}else{const wt=et(Y);ot(y(Y),wt,k,D,F)}return et.end(),y.end(),at}(xt,Ut,Ut.clone(),null,null),C.map(ot=>ot&&ot.get()),A)return{ok:!1,conflict:A};H.map(ot=>!!ot);const Vt=[];let qt=null;(function ot(P,V,k,D,F){let st=!1;const rt=a(V);if(c(rt)){const et=rt.p;et!=null?(k=C[et],D=gt[et]=r.writeCursor(),st=!0,F=null):(k=null,F=V.clone())}else u(a(k))&&(k=null);const at=P.getComponent();if(at){const et=at.p;et!=null?(F&&(B[et]=F),Vt[et]=F||U===1&&st?null:D.getComponent(),T[et]=P.clone(),k&&(w[et]=k.clone())):at.r!==void 0&&(F||D.write("r",!0),(F||st)&&(qt==null&&(qt=new Set),qt.add(at)))}let vt=0,Nt=0;const Ct=r.advancer(V,void 0,(et,y)=>{c(y)&&vt++}),yt=r.advancer(k,(et,y)=>u(y)?~(et-Nt):et-Nt,(et,y)=>{u(y)&&Nt++});if(P)for(const et of P)if(typeof et=="string"){const y=Ct(et),Y=yt(et);D.descend(et),ot(P,y,Y,D,F),D.ascend()}else{const y=Ct(et),Y=et-vt,wt=c(a(y))?null:yt(Y),kt=Y+Nt;o(kt>=0),D.descend(kt),ot(P,y,wt,D,F),D.ascend()}Ct.end(),yt.end()})(xt,Ut,Ut.clone(),Rt,null),Rt.reset();let Re=[];if(function ot(P,V,k,D,F,st){o(V);const rt=V.getComponent();let at=a(D),vt=!1;const Nt=($,Et,Lt)=>$?t.moveOp($.getPath(),Et.getPath()):t.insertOp(Et.getPath(),Lt.i);if(u(rt)){const $=rt.d;$!=null&&(G[$]=V.clone());const Et=$!=null?Vt[$]:null;let Lt=!1;if(rt.i!==void 0||$!=null&&Et){let St;at&&(at.i!==void 0||(St=at.d)!=null&&!I[St])&&(Lt=St!=null?$!=null&&$===q[St]:e.default(at.i,rt.i),Lt||St!=null&&U!==1&&q[St]!=null||A==null&&(A={type:i.ConflictType.DROP_COLLISION,op1:Nt($!=null?T[$]:null,V,rt),op2:Nt(St!=null?W[St]:null,D,at)})),Lt||(st?A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Nt($!=null?T[$]:null,V,rt),op2:t.removeOp(st.getPath())}):($!=null?(Re[ie]=$,F.write("d",Et.p=ie++)):F.write("i",s.default(rt.i)),vt=!0))}else if($!=null&&!Et){const St=B[$];St&&(st=St.clone())}$!=null?(P=T[$],k=b[$],D=w[$]):rt.i!==void 0&&(P=k=null,Lt||(D=null))}else c(a(P))&&(P=k=D=null);const Ct=a(P),yt=a(k);if(c(yt)){const $=yt.p;yt.r!==void 0&&(!Ct||Ct.r===void 0)||I[$]?(D=null,st=k.clone()):$!=null&&(D=C[$],U!==1&&q[$]!=null||((F=lt[$])||(F=lt[$]=r.writeCursor()),F.reset(),st=null))}else!u(rt)&&u(at)&&(D=null);at=D!=null?D.getComponent():null;const et=ht(rt);if(et){const $=p(rt);if(st)A==null&&(A={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(V.getPath(),et,$,!0),op2:t.removeOp(st.getPath())});else{const Et=ht(at);let Lt;if(Et){if(et!==Et)throw Error("Transforming incompatible types");const St=p(at);Lt=et.transform($,St,N)}else Lt=s.default($);S(F,et,Lt)}}let y=0,Y=0,wt=0,kt=0,ae=0,Ce=0,Zt=P!=null&&P.descendFirst(),$e=Zt;const Le=r.advancer(k,void 0,($,Et)=>{c(Et)&&wt++});let ne=D!=null&&D.descendFirst(),se=ne;for(const $ of V)if(typeof $=="number"){let Et;const Lt=u(V.getComponent()),St=$-Y;{let he;for(;Zt&&typeof(he=P.getKey())=="number";){he+=y;const Qt=P.getComponent(),De=c(Qt);if(he>St||he===St&&(!De||U===0&&Lt))break;if(De){y--;const Ie=Qt.p;q.includes(Ie),Qt.d,a(lt[Qt.d]),c(a(lt[Qt.d])),(Qt.r===void 0||qt&&qt.has(Qt))&&(Ie==null||!Vt[Ie]||U!==1&&q.includes(Ie))||ae--}Zt=P.nextSibling()}Et=Zt&&he===St?P:null}const Jt=St-y;let le=Le(Jt);const Hn=Jt-wt;let sn=null;{let he,Qt;for(;ne&&typeof(he=D.getKey())=="number";){Qt=he-kt;const De=D.getComponent(),Ie=u(De);if(Qt>Hn)break;if(Qt===Hn){if(!Ie){sn=D;break}{if(U===0&&Lt){sn=D;break}const Se=le&&c(le.getComponent());if(U===0&&Se)break}}if(Ie){const Se=De.d;q[Se],De.i===void 0&&(I[Se]||q[Se]!=null&&U!==1)?(I[Se]||q[Se]!=null&&U===0)&&(kt++,Ce--):kt++}ne=D.nextSibling()}}const Us=Hn+kt+ae+Ce;o(Us>=0,"trying to descend to a negative index"),F.descend(Us),Lt&&(Et=le=sn=null,Y++),ot(Et,V,le,sn,F,st)&&Ce++,F.ascend()}else{let Et;for(;Zt&&(Et=P.getKey(),typeof Et!="string"||!(Et>$||Et===$));)Zt=P.nextSibling();const Lt=Zt&&Et===$?P:null,St=Le($);let Jt;for(;ne&&(Jt=D.getKey(),typeof Jt!="string"||!(Jt>$||Jt===$));)ne=D.nextSibling();const le=ne&&Jt===$?D:null;F.descend($),ot(Lt,V,St,le,F,st),F.ascend()}return Le.end(),$e&&P.ascend(),se&&D.ascend(),vt}(xt,xt.clone(),Ut,Ut.clone(),Rt,null),A)return{ok:!1,conflict:A};Rt.reset();const Kt=(ot,P,V)=>ot.traverse(P,(k,D)=>{k.d!=null&&V(k.d,ot,D)});(I.length||gt.length)&&(Kt(Ut,Rt,(ot,P,V)=>{I[ot]&&!H[ot]&&V.write("r",!0),gt[ot]&&V.mergeTree(gt[ot].get())}),Rt.reset());const Bt=[],oe=[];if((lt.length||I.length)&&!A){const ot=r.readCursor(Pn(Rt.get()));if(Kt(ot,null,(P,V)=>{Bt[P]=V.clone()}),lt.forEach(P=>{P&&Kt(r.readCursor(P.get()),null,(V,k)=>{Bt[V]=k.clone()})}),function P(V,k,D,F,st,rt){const at=a(k);if(at&&c(at))if(at.p!=null){const y=at.p;Bt[y].getPath(),D=Bt[y],F=oe[y]=r.writeCursor()}else at.r!==void 0&&(D=null);else u(a(D))&&(D=null);const vt=V.getComponent();if(vt){let y;if((y=vt.d)!=null){const Y=lt[y];Y&&(Y.get(),F.mergeTree(Y.get()),D=r.readCursor(Y.get()))}}let Nt=0,Ct=0;const yt=r.advancer(k,void 0,(y,Y)=>{c(Y)&&Nt--}),et=r.advancer(D,(y,Y)=>u(Y)?-(y-Ct)-1:y-Ct,(y,Y)=>{u(Y)&&Ct++});for(const y of V)if(typeof y=="number"){const Y=yt(y),wt=y+Nt,kt=et(wt),ae=wt+Ct;F.descend(ae),P(V,Y,kt,F),F.ascend()}else F.descend(y),P(V,yt(y),et(y),F),F.ascend();yt.end(),et.end()}(Ut,ot,ot.clone(),Rt),Rt.reset(),A)return{ok:!1,conflict:A};if(Rt.get(),oe.length){const P=oe.map(k=>k?k.get():null),V=r.readCursor(Pn(Rt.get()));if(Kt(V,Rt,(k,D,F)=>{const st=P[k];st&&(F.mergeTree(st),P[k]=null)}),P.find(k=>k)){const k=r.writeCursor(),D=r.writeCursor();let F=0,st=0;P.forEach(rt=>{rt!=null&&Kt(r.readCursor(rt),null,at=>{const vt=Re[at];k.writeMove(T[vt].getPath(),G[vt].getPath(),F++);const Nt=pt[vt];Nt&&Nt.forEach(Ct=>{I[Ct]||U!==1&&q[Ct]!=null||D.writeMove(W[Ct].getPath(),C[Ct].getPath(),st++)})})}),A={type:i.ConflictType.BLACKHOLE,op1:k.get(),op2:D.get()}}}}return A?{ok:!1,conflict:A}:{ok:!0,result:Rt.get()}}const Ts=g=>{const R=new Error("Transform detected write conflict");throw R.conflict=g,R.type=R.name="writeConflict",R};function Mo(g,R,N){const U=kn(g,R,N);if(U.ok)return U.result;Ts(U.conflict)}const Ue=g=>{const R=r.writeCursor();return r.readCursor(g).traverse(R,(N,U)=>{(u(N)||ht(N))&&U.write("r",!0)}),R.get()},Uo=(g,R)=>{const{type:N,op1:U,op2:A}=g;switch(N){case i.ConflictType.DROP_COLLISION:return R==="left"?[null,Ue(A)]:[Ue(U),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let T=!1;return r.readCursor(U).traverse(null,G=>{G.r!==void 0&&(T=!0)}),T?[null,Ue(A)]:[Ue(U),null];case i.ConflictType.BLACKHOLE:return[Ue(U),Ue(A)];default:throw Error("Unrecognised conflict: "+N)}};function Ms(g,R,N,U){let A=null;for(;;){const T=kn(R,N,U);if(T.ok)return _t(A,T.result);{const{conflict:G}=T;g(G)||Ts(G);const[W,C]=Uo(G,U);R=_t(X(R),W),N=_t(X(N),C),A=_t(A,C)}}}})(xi);(function(t){var n=Wt&&Wt.__createBinding||(Object.create?function(i,o,a,l){l===void 0&&(l=a),Object.defineProperty(i,l,{enumerable:!0,get:function(){return o[a]}})}:function(i,o,a,l){l===void 0&&(l=a),i[l]=o[a]}),e=Wt&&Wt.__exportStar||function(i,o){for(var a in i)a!=="default"&&!o.hasOwnProperty(a)&&n(o,i,a)};Object.defineProperty(t,"__esModule",{value:!0}),e(xi,t);var s=Rs;Object.defineProperty(t,"ReadCursor",{enumerable:!0,get:function(){return s.ReadCursor}}),Object.defineProperty(t,"WriteCursor",{enumerable:!0,get:function(){return s.WriteCursor}});var r=Cs;Object.defineProperty(t,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})})($t);const Wl=Pl($t),Bl=yo({__proto__:null,default:Wl},[$t]);var J=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(J||{});class ss{constructor(n){_(this,"_index",0);_(this,"_offset",0);this._actions=n}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(n){n||(n=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const s=this._offset,r=e.len;return n>=r-s?(n=r-s,this._index+=1,this._offset=0):this._offset+=n,e.t===J.DELETE||e.t===J.RETAIN&&e.body==null?x.deepClone({...e,len:n}):x.deepClone({...e,len:n,body:Ze(e.body,s,s+n)})}else return{t:J.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:J.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,e=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=n,this._index=e,[s].concat(r)}}else return[]}}class Pi{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}function ki(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=Ai(t,n,e),a=bi(t,n,e),l=vi(t,n,e),h=wi(t,n,e),c=Ti(t,n,e),u=Mi(t,n,e),d=Ui(t,n,e);let f="";return s&&(t.dataStream=Qr(s,r,i),f=s.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:c,customRanges:u,customDecorations:d}}function Hi(t,n,e,s){t.dataStream=Jr(t.dataStream,s,n.dataStream),Ci(t,n,e,s),_s(t,n,e,s),Sl(t,n,e,s),Ii(t,n,e,s),Si(t,n,e,s),Oi(t,n,e,s),Ni(t,n,e,s)}function Gl(t,n,e,s,r=Pt.COVER){return Al(t,n,e,s,r)}function jl(t,n,e){return n<=0?{dataStream:""}:ki(t,n,e)}function Vl(t,n,e,s){e!==0&&Hi(t,n,e,s)}function Kl(t,n){const e=new Pi;return e.reset(),n.forEach(s=>{switch(s=x.deepClone(s),s.t){case J.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&Gl(t,i,o,e.cursor,r),e.moveCursor(o);break}case J.INSERT:{const{body:r,len:i}=s;Vl(t,r,i,e.cursor),e.moveCursor(i);break}case J.DELETE:{const{len:r}=s;jl(t,r,e.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function Bs(t){return Object.keys(t).length===1}const Xe=class Xe{constructor(){_(this,"_actions",[])}static apply(n,e){return Kl(n,e)}static compose(n,e){const s=new ss(n),r=new ss(e),i=new Xe;for(;s.hasNext()||r.hasNext();)if(r.peekType()===J.INSERT)i.push(r.next());else if(s.peekType()===J.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===J.INSERT&&l.t===J.RETAIN?l.body==null?i.push(a):i.push({...a,body:ts(a.body,l.body,l.coverType)}):a.t===J.RETAIN&&l.t===J.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:ts(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===J.RETAIN&&l.t===J.DELETE?i.push(l):a.t===J.INSERT&&(l.t,J.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(n,e,s){throw new Error("transform is not implemented in TextX")}static isNoop(n){return n.length===0}static invert(n){const e=[];for(const s of n)if(s.t===J.INSERT)e.push({t:J.DELETE,len:s.len,line:0,body:s.body,segmentId:s.segmentId});else if(s.t===J.DELETE){if(s.body==null)throw new Error("Can not invert DELETE action without body property, makeInvertible must be called first.");e.push({t:J.INSERT,body:s.body,len:s.len,line:0,segmentId:s.segmentId})}else if(s.body!=null){if(s.oldBody==null)throw new Error("Can not invert RETAIN action without oldBody property, makeInvertible must be called first.");e.push({t:J.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:Pt.REPLACE,segmentId:s.segmentId})}else e.push(s);return e}static makeInvertible(n,e){const s=[];let r=0;for(const i of n){if(i.t===J.DELETE&&i.body==null){const o=Ze(e,r,r+i.len,!1);i.len=o.dataStream.length,i.body=o}if(i.t===J.RETAIN&&i.body!=null){const o=Ze(e,r,r+i.len,!0);i.oldBody={...o,dataStream:""},i.len=o.dataStream.length}s.push(i),i.t!==J.INSERT&&(r+=i.len)}return s}insert(n,e,s=""){const r={t:J.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:J.RETAIN,len:n,segmentId:e};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(n,e=""){const s={t:J.DELETE,len:n,line:0,segmentId:e};return this.push(s),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...n){if(n.length>1){for(const i of n)this.push(i);return this}let e=this._actions.length,s=this._actions[e-1];const r=x.deepClone(n[0]);if(r.t===J.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===J.DELETE&&r.t===J.DELETE)return s.len+=r.len,this;if(s.t===J.DELETE&&r.t===J.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===J.RETAIN&&r.t===J.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===J.INSERT&&Bs(s.body)&&r.t===J.INSERT&&Bs(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===J.RETAIN&&yl(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}};_(Xe,"id","text-x"),_(Xe,"uri","https://github.com/dream-num/univer#text-x");let Ee=Xe;Object.defineProperty(Ee,"name",{value:"text-x"});const ye=class ye{static registerSubtype(n){var e;this._subTypes.has(n.name)&&((e=this._subTypes.get(n.name))==null?void 0:e.id)!==Ee.id||(this._subTypes.set(n.name,n),$t.type.registerSubtype(n))}static apply(n,e){if(!$t.type.isNoop(e))return $t.type.apply(n,e)}static compose(n,e){return $t.type.compose(n,e)}static transform(n,e,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(n,e){return $t.type.invertWithDoc(n,e)}static isNoop(n){return $t.type.isNoop(n)}static getInstance(){return this._instance==null&&(this._instance=new ye),this._instance}removeOp(n,e){return $t.removeOp(n,e)}moveOp(n,e){return $t.moveOp(n,e)}insertOp(n,e){return $t.insertOp(n,e)}replaceOp(n,e,s){return $t.replaceOp(n,e,s)}editOp(n,e=["body"]){return $t.editOp(e,Ee.name,n)}};_(ye,"uri","https://github.com/dream-num/univer#json-x"),_(ye,"_subTypes",new Map),_(ye,"_instance",null);let ve=ye;ve.registerSubtype(Ee);const Ss={id:"default_doc",documentStyle:{}};class Yl extends Mn{constructor(e){super();_(this,"type",Q.UNIVER_DOC);_(this,"snapshot");this.snapshot={...Ss,...e}}getUnitId(){throw new Error("Method not implemented.")}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,s){this.snapshot.drawings=e,this.snapshot.drawingsOrder=s}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:s,l:r,b:i,r:o}=e,{documentStyle:a}=this.snapshot;s!=null&&(a.marginTop=s),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(e,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:e,height:s};return}e!==void 0&&(r.pageSize.width=e),s!==void 0&&(r.pageSize.height=s)}updateDrawing(e,s){const{drawings:r}=this,{width:i,height:o,left:a,top:l}=s,h=r==null?void 0:r[e];if(!h)return;const c=h.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=a,c.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class we extends Yl{constructor(e){var r;super(x.isEmptyObject(e)?xl():e);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:x.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getRev(){var e;return(e=this.snapshot.rev)!=null?e:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Ss,...e},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){if(!ve.isNoop(e))return this.snapshot=ve.apply(this.snapshot,e),e!=null&&e.some(s=>Array.isArray(s)&&((s==null?void 0:s[0])==="headers"||(s==null?void 0:s[0])==="footers"))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.snapshot}sliceBody(e,s,r=gs.copy){const i=this.getBody();if(i!=null)return Ze(i,e,s,!1,r)}_initializeHeaderFooterModel(){const{headers:e,footers:s}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new we(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new we(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const Fi=ut.createIdentifier("univer.config-service");class $i{constructor(){_(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,e){this._config.set(n,e)}deleteConfig(n){this._config.delete(n)}}class Wi extends Tt{constructor(){super(...arguments);_(this,"_error$",new Z.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}class Bi{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new ri(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const s=this._getExistingStyleId(n);return s||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,e){const s=x.generateRandomId(6);return this._styles[s]=n,this._cacheMap.set(e,s),s}setValue(n){if(n==null)return;const e=JSON.stringify(n),s=this.search(n,e);return s!=="-1"?s:this.add(n,e)}toJSON(){return this._styles}getStyleByCell(n){let e;n&&x.isObject(n.s)?e=n.s:e=(n==null?void 0:n.s)&&this.get(n.s);const s=n==null?void 0:n.interceptorStyle;return s?{...e,...s}:e}_generateCacheMap(){const{_styles:n,_cacheMap:e}=this;for(const s in n){const r=JSON.stringify(n[s]);e.set(r,s)}}_getExistingStyleId(n){const{_styles:e}=this;for(const s in e)if(x.diffValue(e[s],n))return s;return null}}class zl{constructor(n,e){_(this,"_columnData",{});this._config=n,this._columnData=e}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:e}=this,s=e[n];return s?s.hd!==K.TRUE:!0}getHiddenCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,s.push({rangeType:it.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:it.COLUMN}),s}getVisibleCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,s.push({rangeType:it.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:it.COLUMN}),s}getColumnDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return ge(this._columnData)}getColumnWidth(n){const{_columnData:e}=this,s=this._config;let r=0;return r=(e[n]||{hd:K.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(n){const e=this._columnData[n];if(e)return e}getColumnOrCreate(n){const{_columnData:e}=this,s=this._config,r=e[n];if(r)return r;const i={w:s.defaultColumnWidth,hd:K.FALSE};return this._columnData[n]=i,i}}class Xl{constructor(n,e,s){_(this,"_rowData");this._config=n,this._viewModel=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(n,e=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=s[o+n]||{hd:K.FALSE,h:r.defaultRowHeight},{ia:l,ah:h,h:c=r.defaultRowHeight}=a;i+=(l==null||l===K.TRUE)&&typeof h=="number"?h:c}return i}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:e}=this,s=e[n];if(s)return s;const r=this._config,i={hd:K.FALSE,h:r.defaultRowHeight};return e[n]=i,i}getHiddenRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:it.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.ROW}),s}getVisibleRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:it.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:it.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==K.TRUE:!0}getSize(){return ge(this._rowData)}}const ql="DEFAULT_WORKSHEET_ROW_COUNT",Gi=1e3,Zl="DEFAULT_WORKSHEET_COLUMN_COUNT",ji=20,Jl="DEFAULT_WORKSHEET_ROW_HEIGHT",Vi=24,Ql="DEFAULT_WORKSHEET_COLUMN_WIDTH",Ki=88,tu="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Yi=46,eu="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",zi=20;function Xi(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:K.FALSE,rowCount:Gi,columnCount:ji,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Ki,defaultRowHeight:Vi,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:K.TRUE,rowHeader:{width:Yi,hidden:K.FALSE},columnHeader:{height:zi,hidden:K.FALSE},selections:["A1"],rightToLeft:K.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class qi extends Tt{constructor(e){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=e}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,s):this.getRawCell(e,s)}getRowFiltered(e){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(e))!=null?r:!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=e,bt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,bt(()=>this._rowFilteredInterceptor=null)}}class Je{constructor(n,e,s){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=n,this._styles=s,this._snapshot=Xi(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:x.generateRandomId(6),this._cellData=new ee(o),this._viewModel=new qi((l,h)=>this.getCellRaw(l,h)),this._rowManager=new Xl(this._snapshot,this._viewModel,i),this._columnManager=new zl(this._snapshot,r)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),e=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return n.forEach((h,c)=>{Object.keys(c).forEach(u=>{const d=+u,f=n.getValue(h,d),m=f!=null&&f.s?this._styles.get(f.s):null,E=(m==null?void 0:m.bd)&&(m.bd.b||m.bd.l||m.bd.r||m.bd.t||m.bd.bc_tr||m.bd.bl_tr||m.bd.ml_tr||m.bd.tl_bc||m.bd.tl_br||m.bd.tl_mr);(f&&(f.v||f.p)||m!=null&&m.bg||E)&&(a?s=Math.min(s,h):(s=h,a=!0),r=Math.max(r,h),l?i=Math.min(i,d):(l=!0,i=d),o=Math.max(o,d))})}),e.forEach(h=>{a?s=Math.min(s,h.startRow):(s=h.startRow,a=!0),r=Math.max(r,h.endRow),l?i=Math.min(i,h.startColumn):(i=h.startColumn,a=!0),o=Math.max(o,h.endColumn)}),!a||!l?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,e=x.deepClone(n);return new Je(this.unitId,e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,e){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(me.intersects({startRow:n,startColumn:e,endRow:n,endColumn:e},i))return i}return null}getCell(n,e){return n<0||e<0?null:this._viewModel.getCell(n,e)}getCellRaw(n,e){return this.getCellMatrix().getValue(n,e)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,e,s,r,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(h=>me.intersects({startRow:n,startColumn:e,endRow:s,endColumn:r},h)),l=new ee;return Jn(n,s,e,r).forEach((h,c)=>{const u=i?this.getCellRaw(h,c):this.getCell(h,c);u&&l.setValue(h,c,u)}),a.forEach(h=>{const{startColumn:c,startRow:u,endColumn:d,endRow:f}=h;Jn(u,f,c,d).forEach((m,E)=>{m===u&&E===c&&l.setValue(m,E,{...o.getValue(m,E),rowSpan:f-u+1,colSpan:d-c+1}),(m!==u||E!==c)&&l.realDeleteValue(m,E)})}),l}getRange(n,e,s,r){return typeof n=="object"?new He(this,n,{getStyles:()=>this._styles}):new He(this,{startRow:n,startColumn:e,endColumn:r||e,endRow:s||n},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:n}=this,{columnCount:e}=n;return e}getMaxRows(){const{_snapshot:n}=this,{rowCount:e}=n;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(n){this._snapshot.rowCount=n}getColumnCount(){return this._snapshot.columnCount}setColumnCount(n){this._snapshot.columnCount=n}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:n}=this,{showGridlines:e}=n;return e===0}getTabColor(){const{_snapshot:n}=this,{tabColor:e}=n;return e}getColumnWidth(n){return this.getColumnManager().getColumnWidth(n)}getRowHeight(n){return this._viewModel.getRowFiltered(n)?0:this.getRowManager().getRowHeight(n)}getRowVisible(n){return this._viewModel.getRowFiltered(n)?!1:this.getRowRawVisible(n)}getRowRawVisible(n){return this.getRowManager().getRowRawVisible(n)}getHiddenRows(n,e){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(n,e);return r.forEach(i=>i.endColumn=s),r}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,e){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(n,e);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const n=this.getRowCount();return this._rowManager.getVisibleRows(0,n-1)}getVisibleCols(){const n=this.getColumnCount();return this._columnManager.getVisibleCols(0,n-1)}isRightToLeft(){const{_snapshot:n}=this,{rightToLeft:e}=n;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(n){return n&&(n.v!==void 0||n.f!==void 0||n.p!==void 0)}iterateByRow(n,e=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n,a=this;return{[Symbol.iterator]:()=>{let l=s,h=r;return{next(){for(;;){if(h>o&&(l+=1,h=r),l>i)return{done:!0,value:void 0};const c=a.getCell(l,h),u=!c,d=a.getMergedCell(l,h);if(d){if(l!==d.startRow||h!==d.startColumn){h=d.endColumn+1;continue}if(u&&e){h=d.endColumn+1;continue}const m={row:l,col:h,value:c};return m.colSpan=d.endColumn-d.startColumn+1,m.rowSpan=d.endRow-d.startRow+1,h=d.endColumn+1,{done:!1,value:m}}if(u&&e)h+=1;else{const f={row:l,col:h,value:c};return h+=1,{done:!1,value:f}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let h=r,c=i;return{next(){for(;;){if(h>o&&(c+=1,h=r),c>a)return{done:!0,value:void 0};const u=l.getMergedCell(h,c);if(u){const m=h!==u.startRow,E=m||c!==u.startColumn;if(s&&E||!s&&m){h=u.endRow+1;continue}const M=l.getCell(u.startRow,u.startColumn);if(!M&&e){h=u.endRow+1;continue}const tt={row:h,col:u.startColumn,value:M};return tt.colSpan=u.endColumn-u.startColumn+1,tt.rowSpan=u.endRow-u.startRow+1,h=u.endRow+1,{done:!1,value:tt}}const d=l.getCell(h,c);if(!d&&e)h+=1;else{const m={row:h,col:c,value:d};return h+=1,{done:!1,value:m}}}}}}}}}function nu(t){var s,r;if(!t)return"";const n=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(n)return n;const e=t.v;return typeof e=="string"?t.t===Ae.BOOLEAN?e.toUpperCase():e.replace(/[\r\n]/g,""):typeof e=="number"?t.t===Ae.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const su="0.2.4";function ru(t="",n=Te.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:su,locale:n,styles:{},sheets:{},resources:[]}}var iu=Object.defineProperty,ou=Object.getOwnPropertyDescriptor,au=(t,n,e,s)=>{for(var r=s>1?void 0:s?ou(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&iu(n,e,r),r},lu=(t,n)=>(e,s)=>n(e,s,t);function uu(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}exports.Workbook=class extends Mn{constructor(e={},s){super();_(this,"type",Q.UNIVER_SHEET);_(this,"_sheetCreated$",new Z.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new Z.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new Z.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");_(this,"_name$");_(this,"name$");this._logService=s;const r=ru();x.isEmptyObject(e)?this._snapshot=r:this._snapshot=x.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=x.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Bi(i),this._count=1,this._worksheets=new Map,this._name$=new Z.BehaviorSubject(e.name||""),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return x.deepClone(this._snapshot)}static isIRangeType(e){return typeof e=="string"||"startRow"in e||"row"in e}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)!=null?e:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(e,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(s,0,e);const a=new Je(this._unitId,r,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>r===e)}getActiveSheet(e){if(!this._activeSheet&&typeof e>"u")throw new Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){const e=this._activeSheet;if(e)return e;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const a=this._worksheets.get(s[i]);if(a&&a.isSheetHidden()!==K.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){const s=this._worksheets.get(e);return s?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),delete this._snapshot.sheets[e],this._sheetDisposed$.next(s),!0):!1}getActiveSheetIndex(){const{sheetOrder:e}=this._snapshot;return e.findIndex(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:e}=this._snapshot,s=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===K.TRUE).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden!==K.TRUE).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let s=e;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}generateNewSheetName(e){let s=e+this._count;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}_parseWorksheetSnapshots(){const{_snapshot:e,_worksheets:s}=this,{sheets:r,sheetOrder:i}=e;if(x.isEmptyObject(r)){const o=x.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const h=new Je(this._unitId,a,this._styles);s.set(o,h),i.includes(o)||i.push(o)}this.ensureActiveSheet()}};exports.Workbook=au([lu(1,pe)],exports.Workbook);class Os extends Mn{constructor(e){var s;super();_(this,"type",Q.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...ai,...e},this._unitId=(s=this._snapshot.id)!=null?s:x.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var r;return(r=this.getElementsByPage(e))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:as.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ke="FOCUSING_SHEET",_n="FOCUSING_DOC",gn="FOCUSING_SLIDE",cu="FOCUSING_EDITOR_BUT_HIDDEN",Zi="EDITOR_ACTIVATED",hu="FOCUSING_EDITOR_INPUT_FORMULA",Ji="FOCUSING_FORMULA_EDITOR",du="FOCUSING_UNIVER_EDITOR",fu="FOCUSING_EDITOR_INPUT_FORMULA",_u="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",gu="FOCUSING_COMMON_DRAWINGS";var mu=Object.defineProperty,Eu=Object.getOwnPropertyDescriptor,pu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Eu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&mu(n,e,r),r},Gs=(t,n)=>(e,s)=>n(e,s,t);const Fe=ut.createIdentifier("univer.current");exports.UniverInstanceService=class extends Tt{constructor(e,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits",new Map);_(this,"_currentUnits$",new Z.BehaviorSubject(this._currentUnits));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new Z.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new Z.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new Z.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(e){this._createHandler=e}createUnit(e,s){return this._createHandler(e,s,this._ctorByType.get(e))}registerCtorForType(e,s){return this._ctorByType.set(e,s),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(Z.map(s=>{var r;return(r=s.get(e))!=null?r:null}),Z.distinctUntilChanged())}getCurrentUnitForType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.set(s[1],s[0]),this._currentUnits$.next(this._currentUnits)}_removeCurrentUnitForType(e){this._currentUnits.set(e,null),this._currentUnits$.next(this._currentUnits)}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(Z.filter(s=>s.type===e))}__addUnit(e){const s=e.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(e),this._unitAdded$.next(e),this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(Z.filter(s=>s.type===e))}getUnit(e,s){var i;const r=(i=this._getUnitById(e))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(Q.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,Q.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,Q.UNIVER_SHEET)}getAllUnitsForType(e){var s;return(s=this._unitsByType.get(e))!=null?s:[]}changeDoc(e,s){const r=this.getAllUnitsForType(Q.UNIVER_DOC),i=r.find(o=>o.getUnitId()===e);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const e=this._focused$.getValue();return e?(s=this._getUnitById(e))==null?void 0:s[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(_n,!1),this._contextService.setContextValue(Ke,!0),this._contextService.setContextValue(gn,!1)):this.focused instanceof we?(this._contextService.setContextValue(_n,!0),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(gn,!1)):this.focused instanceof Os&&(this._contextService.setContextValue(_n,!1),this._contextService.setContextValue(Ke,!1),this._contextService.setContextValue(gn,!0))}getFocusedUnit(){return this.focused}getUnitType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${e}`);return s[1]}disposeUnit(e){const s=this._getUnitById(e);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),a=o.indexOf(r);return o.splice(a,1),this._removeCurrentUnitForType(i),this._focused$.next(null),this._unitDisposed$.next(r),!0}_getUnitById(e){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===e);if(i)return[i,s]}}};exports.UniverInstanceService=pu([Gs(0,ut.Inject(ut.Injector)),Gs(1,Qe)],exports.UniverInstanceService);var ft=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(ft||{});const Ru={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},mn=new Map;function Qi(t,n){return function(r){Un(t,n)}}function Un(t,n){mn.has(t)||mn.set(t,[]),mn.get(t).push(n)}var Cu=Object.defineProperty,Iu=Object.getOwnPropertyDescriptor,to=(t,n,e,s)=>{for(var r=s>1?void 0:s?Iu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Cu(n,e,r),r},eo=(t,n)=>(e,s)=>n(e,s,t);exports.LifecycleService=class extends Tt{constructor(e){super();_(this,"_lifecycle$",new Z.BehaviorSubject(ft.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=e,this._reportProgress(ft.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(e<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(e!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return Z.merge(no(this.stage),this._lifecycle$.pipe(Z.skip(1))).pipe(mi(e=>e===ft.Steady))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Ru[e]}".`)}};exports.LifecycleService=to([eo(0,pe)],exports.LifecycleService);exports.LifecycleInitializerService=class extends Tt{constructor(e){super();_(this,"_seenTokens",new Set);this._injector=e}initModulesOnStage(e){var s;(s=mn.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}};exports.LifecycleInitializerService=to([eo(0,ut.Inject(ut.Injector))],exports.LifecycleInitializerService);function no(t){switch(t){case ft.Starting:return Z.of(ft.Starting);case ft.Ready:return Z.of(ft.Starting,ft.Ready);case ft.Rendered:return Z.of(ft.Starting,ft.Ready,ft.Rendered);default:return Z.of(ft.Starting,ft.Ready,ft.Rendered,ft.Steady)}}class Ye extends Tt{constructor(){super();_(this,"_currentLocale$",new Z.BehaviorSubject(Te.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new Z.Subject);_(this,"t",(e,...s)=>{if(!this._locales)throw new Error("[LocaleService]: Locale not initialized");const r=e.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return s.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return e});this.disposeWithMe(bt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(e){var s;this._locales=x.deepMerge((s=this._locales)!=null?s:{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,s){const r=s.shift();if(r&&e&&r in e){const i=e[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}var Ns=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(Ns||{});const As=ut.createIdentifier("univer.permission-service");Un(ft.Starting,As);class so extends Tt{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new Z.Subject);_(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(e){const s=this._permissionPointMap.get(e);s&&(s.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){const s=e instanceof Z.BehaviorSubject,r=s?e.getValue():e;if(!r.id)return!1;if(this._permissionPointMap.get(r.id))throw new Error(`${r.id} PermissionPoint already exists`);return this._permissionPointMap.set(r.id,s?e:new Z.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0}updatePermissionPoint(e,s){const r=this._permissionPointMap.get(e);if(!r)return;const i=r.getValue();i.value=s,i.status=Ns.DONE,r.next({...i}),this._permissionPointUpdate$.next(i)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){const s=this._permissionPointMap.get(e);if(s)return s.getValue()}getPermissionPoint$(e){const s=this._permissionPointMap.get(e);if(s)return s}composePermission$(e){const s=e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.asObservable()});return Z.combineLatest(s).pipe(cn.map(r=>r))}composePermission(e){return e.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`[PermissionService]: ${r} permissionPoint does not exist!`);return i.getValue()})}getAllPermissionPoint(){const e=new Map;return this._permissionPointMap.forEach((s,r)=>{e.set(r,s)}),e}}class ro extends Tt{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new Z.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e){return this.getAllResourceHooks().map(i=>{const o=i.toJson(e);return{name:i.pluginName,data:o}})}getResourcesByType(e,s){return this.getAllResourceHooks().filter(o=>o.businesses.includes(s)).map(o=>{const a=o.toJson(e);return{name:o.pluginName,data:a}})}registerPluginResource(e){const s=e.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,e),this._register$.next(e),bt(()=>this._resourceMap.delete(s))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(a=>a.name===r.pluginName))==null?void 0:o.data;if(i)try{const a=r.parseJson(i);r.onLoad(e,a)}catch{console.error("LoadResources Error!")}})}unloadResources(e){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Ln=ut.createIdentifier("resource-manager-service");var Su=Object.defineProperty,Ou=Object.getOwnPropertyDescriptor,Nu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Ou(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Su(n,e,r),r},js=(t,n)=>(e,s)=>n(e,s,t);let rs=class extends Tt{constructor(n,e){super();_(this,"saveWorkbook",n=>{const e=n.getUnitId(),s=this._resourceManagerService.getResources(e)||[],r=n.getSnapshot();return r.resources=s,r});this._resourceManagerService=n,this._univerInstanceService=e,this._init()}_init(){const n=s=>{s.businesses.forEach(r=>{switch(r){case Q.UNRECOGNIZED:case Q.UNIVER_UNKNOWN:case Q.UNIVER_SLIDE:case Q.UNIVER_DOC:{this._univerInstanceService.getAllUnitsForType(Q.UNIVER_DOC).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Document{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}});break}case Q.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(Q.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{n(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{n(s)})),this.disposeWithMe(bt(this._univerInstanceService.getTypeOfUnitAdded$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(bt(this._univerInstanceService.getTypeOfUnitDisposed$(Q.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}saveDoc(n){const e=n.getUnitId(),s=this._resourceManagerService.getResourcesByType(e,Q.UNIVER_DOC)||[],r=n.getSnapshot();return r.resources=s,r}};rs=Nu([js(0,ut.Inject(Ln)),js(1,ut.Inject(Fe))],rs);const bs=ut.createIdentifier("resource-loader-service");Un(ft.Ready,bs);class vs extends Tt{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new Z.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(bt(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}}const Dn="__INTERNAL_EDITOR__",io=`${Dn}DOCS_NORMAL`,oo=`${Dn}DOCS_FORMULA_BAR`,Au=`\r
7
+ `;function bu(t){return`${Dn}${t}`}function vu(t){return t.startsWith(Dn)}var wu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,Mu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Tu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&wu(n,e,r),r},jn=(t,n)=>(e,s)=>n(e,s,t);const yn=ut.createIdentifier("univer.undo-redo.service"),Uu=20;class ao{dispose(){}async dispatchToHandlers(){return!1}}const lo="univer.command.redo",uo="univer.command.undo",co=new class extends ao{constructor(){super(...arguments);_(this,"type",tn.COMMAND);_(this,"id",uo)}async handler(n){const e=n.get(yn),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(en);return cs(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},ho=new class extends ao{constructor(){super(...arguments);_(this,"type",tn.COMMAND);_(this,"id",lo)}async handler(n){const e=n.get(yn),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(en);return cs(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends Tt{constructor(e,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new Z.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(co)),this.disposeWithMe(this._commandService.registerCommand(ho)),this.disposeWithMe(bt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(bt(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:s}=e,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(e.unitID)){const a=this._batchingStatus.get(e.unitID),l=this._pitchUndoElement(e.unitID);a===0||!l?(o(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(l,e)}else o(e);function o(a){i.push(a),i.length>Uu&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const s=this._getRedoStack(e);s&&(s.length=0);const r=this._getUndoStack(e);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){const e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){const s=this._getUndoStack(e);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(e){const s=this._getRedoStack(e);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(e,0),bt(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUnitId(),s=e&&((i=this._undoStacks.get(e))==null?void 0:i.length)||0,r=e&&((o=this._redoStacks.get(e))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(e,s=!1){let r=this._undoStacks.get(e);return!r&&s&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,s=!1){let r=this._redoStacks.get(e);return!r&&s&&(r=[],this._redoStacks.set(e,r)),r||null}_getUndoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getUndoStack(e,!0)}_getRedoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getRedoStack(e,!0)}_tryBatchingElements(e,s){e.redoMutations.push(...s.redoMutations),e.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,a,l,h;let e="";const s=this._contextService.getContextValue(Ke),r=this._contextService.getContextValue(Ji),i=this._contextService.getContextValue(Zi);return s?r?e=oo:i?e=io:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(h=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?h:"",e}};exports.LocalUndoRedoService=Mu([jn(0,Fe),jn(1,en),jn(2,Qe)],exports.LocalUndoRedoService);const fo=Symbol("DependentOn");class is extends Tt{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(is,"pluginName"),_(is,"type",Q.UNIVER_UNKNOWN);class Lu{constructor(){_(this,"_plugins",[])}addPlugin(n){this._plugins.push(n)}removePlugins(){const n=this._plugins.slice();return this._plugins.length=0,n}forEachPlugin(n){this._plugins.forEach(n)}}class Du{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var yu=Object.defineProperty,xu=Object.getOwnPropertyDescriptor,_o=(t,n,e,s)=>{for(var r=s>1?void 0:s?xu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&yu(n,e,r),r},Ge=(t,n)=>(e,s)=>n(e,s,t);const Pu=4;function ku(...t){return function(n){n[fo]=t}}exports.PluginService=class{constructor(n){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_seenPlugins",new Set);_(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(On,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this)),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const n of this._pluginHoldersForTypes.values())n.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(n,e){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:s}=n;s===Q.UNIVER_UNKNOWN?(this._pluginHolderForUniver.register(n,e),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).register(n,e)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const e=this._injector.createInstance(On,this._checkPluginSeen.bind(this),this._immediateInitPlugin.bind(this));return this._pluginHoldersForTypes.set(n,e),e}return this._pluginHoldersForTypes.get(n)}_immediateInitPlugin(n){this._seenPlugins.add(n.pluginName),this._ensurePluginHolderForType(n.type).immediateInitPlugin(n)}_checkPluginSeen(n){return this._seenPlugins.has(n.pluginName)}_assertPluginValid(n){const{type:e,pluginName:s}=n;if(e===Q.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`);if(this._seenPlugins.has(s))throw new Error(`[PluginService]: duplicated plugin name for "${s}". Maybe a plugin that dependents on "${s} has already registered it. In that case please register "${s}" before the that plugin.`);this._seenPlugins.add(n.pluginName)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Pu))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,e]of this._pluginHoldersForTypes)e.started&&e.flush()}};exports.PluginService=_o([Ge(0,ut.Inject(ut.Injector))],exports.PluginService);let On=class extends Tt{constructor(n,e,s,r,i,o){super();_(this,"_started",!1);_(this,"_pluginRegistry",new Du);_(this,"_pluginStore",new Lu);_(this,"_awaitingPlugins",[]);this._checkPluginRegistered=n,this._registerPlugin=e,this._logService=s,this._injector=r,this._lifecycleService=i,this._lifecycleInitializerService=o,this.disposeWithMe(this._lifecycleService.lifecycle$.pipe(Z.skip(1)).subscribe(a=>{this._awaitingPlugins.forEach(l=>this._runStage(l,a))}))}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(n=>n.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._awaitingPlugins.length=0}register(n,e){this._pluginRegistry.registerPlugin(n,e)}immediateInitPlugin(n){const e=this._initPlugin(n,void 0);this._pluginsRunLifecycle([e])}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:e,options:s})=>this._initPlugin(e,s));n.length&&(this._pluginsRunLifecycle(n),this._pluginRegistry.removePlugins())}_initPlugin(n,e){const s=n[fo];if(s){const i=()=>{const o=s.find(a=>!this._checkPluginRegistered(a));return o?(this._logService.warn("[PluginService]",`plugin "${n.pluginName}" depends on "${o.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._registerPlugin(o,void 0),!0):!1};for(;i(););}const r=this._injector.createInstance(n,e);return this._pluginStore.addPlugin(r),r}_pluginsRunLifecycle(n){no(this._lifecycleService.stage).subscribe(e=>this._runStage(n,e)),this._awaitingPlugins.push(n)}_runStage(n,e){n.forEach(s=>{switch(e){case ft.Starting:s.onStarting(this._injector);break;case ft.Ready:s.onReady();break;case ft.Rendered:s.onRendered();break;case ft.Steady:s.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(e)}};On=_o([Ge(2,pe),Ge(3,ut.Inject(ut.Injector)),Ge(4,ut.Inject(exports.LifecycleService)),Ge(5,ut.Inject(exports.LifecycleInitializerService))],On);function go(t,n){if(!n)return t;const e=[];for(const s of t){const r=n.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;e.push([s[0],r[1]])}else e.push(s)}return e}const os={[Ft.Editor]:"Editor",[Ft.Owner]:"Owner",[Ft.Reader]:"Reader",[Ft.UNRECOGNIZED]:"UNRECOGNIZED"},Nn=t=>t?{userID:`${os[t]}_${x.generateRandomId(8)}`,name:os[t],avatar:""}:{userID:"",name:"",avatar:"",anonymous:!0,canBindAnonymous:!1},Vn=(t,n)=>t.startsWith(os[n]);var Hu=Object.defineProperty,Fu=Object.getOwnPropertyDescriptor,$u=(t,n,e,s)=>{for(var r=s>1?void 0:s?Fu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Hu(n,e,r),r};exports.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new Z.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new Z.BehaviorSubject(Nn()));_(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(n){this.addUser(n),this._currentUser$.next(n)}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,e){const s=this._model.get(n);if(s)return s;e&&e()}delete(n){const e=this.getUser(n);this._model.delete(n),e&&this._userChange$.next({type:"delete",user:e})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}list(){return Array.from(this._model.values())}};exports.UserManagerService=$u([Qi(ft.Starting,exports.UserManagerService)],exports.UserManagerService);var Wu=Object.defineProperty,Bu=Object.getOwnPropertyDescriptor,Gu=(t,n,e,s)=>{for(var r=s>1?void 0:s?Bu(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Wu(n,e,r),r},Vs=(t,n)=>(e,s)=>n(e,s,t);exports.AuthzIoLocalService=class{constructor(n,e){_(this,"_permissionMap",new Map([]));this._resourceManagerService=n,this._userManagerService=e,this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){const n=this._userManagerService.getCurrentUser();n&&n.userID||this._userManagerService.setCurrentUser(Nn(Ft.Owner))}_getRole(n){const e=this._userManagerService.getCurrentUser();return e?Vn(e.userID,n):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:n=>{const e=[...this._permissionMap.keys()].reduce((s,r)=>{const i=this._permissionMap.get(r);return s[r]=i,s},{});return JSON.stringify(e)},parseJson:n=>JSON.parse(n),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[Q.UNIVER_SHEET,Q.UNIVER_DOC,Q.UNIVER_SLIDE],onLoad:(n,e)=>{for(const s in e)this._permissionMap.set(s,e[s])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(n){const e=x.generateRandomId(8);switch(n.objectType){case fn.SelectRange:{const s=n.selectRangeObject;this._permissionMap.set(e,{...s,objectType:n.objectType});break}case fn.Worksheet:{const s=n.worksheetObject;this._permissionMap.set(e,{...s,objectType:n.objectType,readScope:pi.SomeCollaborator})}}return e}async allowed(n){var e;if(this._permissionMap.has(n.objectID)){const s=this._permissionMap.get(n.objectID);if(s&&s.objectType===fn.Worksheet)return(e=s==null?void 0:s.strategies)==null?void 0:e.map(r=>({action:r.action,allowed:r.role===Ft.Editor}))}return n.actions.map(s=>({action:s,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.Editor)}))}async batchAllowed(n){const e=this._userManagerService.getCurrentUser(),s=n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!1}))}));return e&&(Vn(e.userID,Ft.Owner)||Vn(e.userID,Ft.Editor))?n.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!0}))})):s}async list(n){const e=[];return n.objectIDs.forEach(s=>{const r=this._permissionMap.get(s);if(r){const i={objectID:s,unitID:n.unitID,objectType:r.objectType,name:r.name,shareOn:!1,shareRole:Ft.Owner,shareScope:-1,creator:Nn(Ft.Owner),strategies:[],actions:n.actions.map(o=>({action:o,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.Editor)}))};e.push(i)}}),e}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(n){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(n){}};exports.AuthzIoLocalService=Gu([Vs(0,Ln),Vs(1,ut.Inject(exports.UserManagerService))],exports.AuthzIoLocalService);const mo=ut.createIdentifier("IAuthzIoIoService");class ju{constructor(n={},e){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Vu(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(vs).setTheme(r),o&&this._injector.get(Ye).load(o),i&&this._injector.get(Ye).setLocale(i),a&&this._injector.get(pe).setLogLevel(a),this._init(s)}get _univerInstanceService(){return this._injector.get(Fe)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Ye).setLocale(n)}createUnit(n,e){return this._univerInstanceService.createUnit(n,e)}createUniverSheet(n){return this._univerInstanceService.createUnit(Q.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(Q.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(Q.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(Q.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(Q.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(Q.UNIVER_SLIDE,Os);const e=n.get(Fe);e.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const a=n.createInstance(i,r);return e.__addUnit(a),this._tryProgressToReady(),a}const o=n.createInstance(i,r);return e.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<ft.Ready&&(this._injector.get(exports.LifecycleService).stage=ft.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Vu(t,n){const e=go([[Wi],[Ye],[vs],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[Fe,{useClass:exports.UniverInstanceService}],[As,{useClass:so}],[pe,{useClass:fi,lazy:!0}],[en,{useClass:exports.CommandService}],[yn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Fi,{useClass:$i}],[Qe,{useClass:hi}],[Ln,{useClass:ro,lazy:!0}],[bs,{useClass:rs,lazy:!0}],[mo,{useClass:exports.AuthzIoLocalService,lazy:!0}]],n);return t?t.createChild(e):new ut.Injector(e)}const Ku=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!me.equals(s,e))),Yu=(t,n)=>n.length===t.length&&t.every((e,s)=>{const r=n[s];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&me.equals(e.range,r.range)});function zu(t,n){if(Object.is(t,n))return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;const e=Object.keys(t),s=Object.keys(n);if(e.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(n);for(let i=0;i<e.length;i++){const o=e[i];if(!r(o))return!1;const a=t[o],l=n[o];if(a!==l)return!1}return!0}function Eo(t){return/^-?\d+(\.\d+)?$/.test(t)}function Xu(t){return Eo(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function qu(t){return["true","false"].includes(t.toLowerCase())}function Zu(t,n){return n.forEach(e=>t.add(e)),t}function Ju(t,n=16){let e=0,s=null;return function(...i){const o=Date.now();o-e<n?(s&&clearTimeout(s),s=setTimeout(()=>{e=o,t.apply(this,i)},n)):(e=o,t.apply(this,i))}}function Qu(t){const n=new MessageChannel;let e=!1;const s=()=>{e||t()};return n.port1.onmessage=s,n.port2.postMessage(null),()=>{e=!0,n.port1.close(),n.port2.close()}}var po=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(po||{});function tc(t,n,e){if(n==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new we(s),i=n.length;let o;for(;(o=r.getBody().dataStream.indexOf(n))>=0;){const l=new Ee,h=ve.getInstance();if(o>0&&l.retain(o),e.length>0){const c=r.sliceBody(o,o+i),u={dataStream:e};Array.isArray(c==null?void 0:c.textRuns)&&c.textRuns.length&&(u.textRuns=[{...c.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,u)}l.delete(i),r.apply(h.editOp(l.serialize()))}const a=r.getBody();return r.dispose(),a}class Ro{constructor(){_(this,"skipNextObservers",!1);_(this,"lastReturnValue");_(this,"isStopPropagation",!1)}stopPropagation(){this.isStopPropagation=!0}}class ec extends Z.Subject{constructor(){super(...arguments);_(this,"_sortedObservers",[])}subscribe(){throw new Error("[EventSubject]: please use `subscribeEvent` instead of `subscribe` method for `EventSubject`.")}next(){throw new Error("[EventSubject]: please use `emitEvent` instead of `next` method for `EventSubject`.")}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let s;typeof e=="function"?s={next:([i,o])=>e(i,o)}:s=e;const r=super.subscribe(s);return this._sortedObservers.push(s),this._sortedObservers.sort((i,o)=>{var a,l;return((a=i.priority)!=null?a:0)-((l=o.priority)!=null?l:0)}),r.add(()=>this._sortedObservers=this._sortedObservers.filter(i=>i!==s)),r}clearObservers(){this._sortedObservers.forEach(e=>{var s;return(s=e.complete)==null?void 0:s.call(e)}),this._sortedObservers.length=0}emitEvent(e){var s;if(!this.closed){const r=new Ro;r.lastReturnValue=e;for(const i of this._sortedObservers){const o=(s=i.next)==null?void 0:s.call(i,[e,r]);if(r.lastReturnValue=o,r.skipNextObservers)return{handled:!0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:r.lastReturnValue,stopPropagation:r.isStopPropagation}}throw new Error("[EventSubject]: cannot emit event on a closed subject.")}}const nc=ut.createIdentifier("ILocalStorageService");function sc(t){return`sheet_interceptor_${t}`}const Co=t=>function(n,e){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,n)};class rc{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return Co(s||[])}intercept(n,e){const s=n;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(e),this._interceptorsByName.set(s,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Tn(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const ic=ut.createIdentifier("univer.snapshot-server-service");class oc{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,e){return Promise.resolve({snapshot:{unitID:"",type:Q.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Xt.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:Xt.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:Xt.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:Xt.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:Xt.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:Xt.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:Xt.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:Xt.OK,message:""},concurrent:[]})}}function ac(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function ws(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const nn=new TextEncoder,xn=new TextDecoder;function Io(t){const n=x.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,nn.encode(JSON.stringify(n))}function So(t){const n=x.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,nn.encode(JSON.stringify(n))}function lc(t){const n=x.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,nn.encode(JSON.stringify(n))}function Ks(t){return JSON.parse(xn.decode(t))}function uc(t){return JSON.parse(typeof t=="string"?ws(t):xn.decode(t))}function cc(t){return JSON.parse(typeof t=="string"?ws(t):xn.decode(t))}const Kn=256*20;function Oo(t,n){const e=new ee(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+Kn,s-1),a=e.getSlice(i,Math.min(i+Kn,s-1),0,n),l=hc(a);r.push({id:x.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=Kn}return r}function hc(t){const n=t.getData();return nn.encode(JSON.stringify(n))}async function dc(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([u,d])=>{const f={id:d.id,type:An.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:Io(d)};if(o[u]=f,d.cellData){const m=Oo(d.cellData,d.rowCount),E=await Promise.all(m.map(M=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:M})));if(E.some(M=>{var L;return((L=M.error)==null?void 0:L.code)!==Xt.OK}))return!1;i[u]={sheetID:u,blocks:E.map(M=>M.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=So(n),h={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:e,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0}}}async function fc(t,n,e,s,r){var d,f;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([m,E])=>{const M={id:E.id,type:An.GRID,name:E.name,rowCount:E.rowCount,columnCount:E.columnCount,originalMeta:Io(E)};if(o[m]=M,E.cellData){const L=Oo(E.cellData,E.rowCount),tt=await Promise.all(L.map(mt=>r.saveSheetBlock(t,{unitID:e,type:Q.UNIVER_SHEET,block:mt})));if(tt.some(mt=>{var ht;return((ht=mt.error)==null?void 0:ht.code)!==Xt.OK}))return!1;i[m]={sheetID:m,blocks:tt.map(mt=>mt.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=So(n),h={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},c={unitID:e,rev:h.rev,type:Q.UNIVER_SHEET,workbook:h,doc:void 0},u=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_SHEET,snapshot:c});if(Ei(u.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
+ ErrorCode: ${(d=u.error)==null?void 0:d.code}:${(f=u.error)==null?void 0:f.message}`);return{snapshot:c}}function _c(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,h])=>{const c=Ks(h.originalMeta);r[l]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...c}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,h])=>{var d;const c=r[l];c.cellData={};const u=[];(d=h.blocks)==null||d.forEach(f=>{const m=i.get(f);if(m)u.push(m);else throw new Error("")}),u.forEach(f=>{const m=uc(f.data);Object.entries(m).forEach(([E,M])=>{const L=c.cellData[+E]={};Object.entries(M).forEach(([tt,mt])=>{L[+tt]=mt})})})});const o=Ks(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:Te.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function gc(t){const n=t.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:e,rev:s,name:r,originalMeta:i,resources:o=[]}=n,{body:a,documentStyle:l={},settings:h={},drawings:c={},drawingsOrder:u=[]}=cc(i);return{id:e,rev:s,locale:Te.EN_US,title:r,body:a,documentStyle:l,settings:h,drawings:c,drawingsOrder:u,resources:o}}async function mc(t,n,e,s,r){var l,h,c;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:lc(n)},o={unitID:e,rev:i.rev,type:Q.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:e,type:Q.UNIVER_DOC,snapshot:o});if(Ei(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
+ ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(c=a.error)==null?void 0:c.message}`);return{snapshot:o}}async function Ec(t,n){const e=t.workbook;if(!e)throw new Error("Workbook metadata is not available");const s=[],r=[];return Object.entries(e.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async l=>{const h={unitID:e.unitID,type:Q.UNIVER_SHEET,blockID:l},{block:c}=await n.getSheetBlock({},h);if(c)s.push(c);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var No=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(No||{}),Ao=(t=>(t[t.DISABLED=0]="DISABLED",t[t.FULL_ALPHA=1]="FULL_ALPHA",t[t.FULL_HANGUL=2]="FULL_HANGUL",t[t.FULL_KATAKANA=3]="FULL_KATAKANA",t[t.HALF_ALPHA=4]="HALF_ALPHA",t[t.HALF_HANGUL=5]="HALF_HANGUL",t[t.HALF_KATAKANA=6]="HALF_KATAKANA",t[t.HIRAGANA=7]="HIRAGANA",t[t.NO_CONTROL=8]="NO_CONTROL",t[t.OFF=9]="OFF",t[t.ON=10]="ON",t))(Ao||{}),bo=(t=>(t.BETWEEN="between",t.EQUAL="equal",t.GREATER_THAN="greaterThan",t.GREATER_THAN_OR_EQUAL="greaterThanOrEqual",t.LESS_THAN="lessThan",t.LESS_THAN_OR_EQUAL="lessThanOrEqual",t.NOT_BETWEEN="notBetween",t.NOT_EQUAL="notEqual",t))(bo||{}),vo=(t=>(t.CUSTOM="custom",t.LIST="list",t.LIST_MULTIPLE="listMultiple",t.NONE="none",t.TEXT_LENGTH="textLength",t.DATE="date",t.TIME="time",t.WHOLE="whole",t.DECIMAL="decimal",t.CHECKBOX="checkbox",t))(vo||{}),wo=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(wo||{});const pc=["script","style","meta","comment","link"];function Rc(t){return!(t.length===0||t.length>31||t.startsWith("'")||t.endsWith("'")||/[:\\\/\?\*\[\]]/.test(t))}xo();exports.ABCToNumber=Za;exports.AbsoluteRefType=At;exports.ActionIterator=ss;exports.AlignTypeH=$r;exports.AlignTypeV=Wr;exports.ArrangeTypeEnum=jr;exports.ArrowsAndMarkersShapes=hr;exports.AutoFillSeries=Js;exports.BaselineOffset=ke;exports.BasicShapes=cr;exports.BlockType=Ir;exports.BooleanNumber=K;exports.BorderStyleTypes=dt;exports.BorderType=Qs;exports.BulletAlignment=fe;exports.COLORS=Yn;exports.CellValueType=Ae;exports.ClientSnapshotServerService=oc;exports.Color=be;exports.ColorBuilder=vn;exports.ColorKit=te;exports.ColorType=zt;exports.ColumnSeparatorType=Ar;exports.CommandType=tn;exports.CommonHideTypes=tr;exports.ConfigService=$i;exports.ContentAlignment=xr;exports.ContextService=hi;exports.CopyPasteType=er;exports.CustomDecorationType=Cr;exports.CustomRangeType=Rr;exports.DEFAULT_CELL=ll;exports.DEFAULT_DOC=Ss;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=ko;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Au;exports.DEFAULT_RANGE=ol;exports.DEFAULT_RANGE_ARRAY=il;exports.DEFAULT_SELECTION=al;exports.DEFAULT_SLIDE=ai;exports.DEFAULT_STYLES=dn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=ji;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Zl;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=zi;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=eu;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Ki;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Ql;exports.DEFAULT_WORKSHEET_ROW_COUNT=Gi;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=ql;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Vi;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Jl;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Yi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=tu;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=oo;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=io;exports.DashStyleType=Lr;exports.DataStreamTreeNodeType=Ri;exports.DataStreamTreeTokenType=ce;exports.DataValidationErrorStyle=No;exports.DataValidationImeMode=Ao;exports.DataValidationOperator=bo;exports.DataValidationRenderMode=po;exports.DataValidationStatus=wo;exports.DataValidationType=vo;exports.DependentOn=ku;exports.DesktopLogService=fi;exports.DeveloperMetadataVisibility=nr;exports.Dimension=sr;exports.Direction=rr;exports.Disposable=Tt;exports.DisposableCollection=us;exports.DocStyleType=Er;exports.DocumentDataModel=we;exports.DocumentFlavor=Sr;exports.DrawingTypeEnum=Vr;exports.EDITOR_ACTIVATED=Zi;exports.EXTENSION_NAMES=li;exports.Entry=zn;exports.EntryIterator=si;exports.ErrorService=Wi;exports.EventState=Ro;exports.EventSubject=ec;exports.FOCUSING_COMMON_DRAWINGS=gu;exports.FOCUSING_DOC=_n;exports.FOCUSING_EDITOR_BUT_HIDDEN=cu;exports.FOCUSING_EDITOR_INPUT_FORMULA=hu;exports.FOCUSING_EDITOR_STANDALONE=fu;exports.FOCUSING_FORMULA_EDITOR=Ji;exports.FOCUSING_SHEET=Ke;exports.FOCUSING_SLIDE=gn;exports.FOCUSING_UNIVER_EDITOR=du;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=_u;exports.FollowNumberWithType=pr;exports.FontItalic=En;exports.FontStyleType=Pr;exports.FontWeight=pn;exports.FormatType=ir;exports.GlyphType=je;exports.GridType=Or;exports.HLSColor=gr;exports.HorizontalAlign=Ne;exports.IAuthzIoService=mo;exports.ICommandService=en;exports.IConfigService=Fi;exports.IContextService=Qe;exports.ILocalStorageService=nc;exports.ILogService=pe;exports.IPermissionService=As;exports.IResourceLoaderService=bs;exports.IResourceManagerService=Ln;exports.ISnapshotServerService=ic;exports.IUndoRedoService=yn;exports.IUniverInstanceService=Fe;exports.InterceptorManager=rc;exports.InterpolationPointType=or;exports.JSON1=Bl;exports.JSONX=ve;exports.KeyIterator=ei;exports.LRUHelper=Be;exports.LRUMap=ri;exports.LifecycleStages=ft;exports.LocaleService=Ye;exports.LocaleType=Te;exports.LogLevel=di;exports.MOVE_BUFFER_VALUE=We;exports.MemoryCursor=Pi;exports.NamedStyleType=Mr;exports.NilCommand=_i;exports.NumberUnitType=Fr;exports.ObjectMatrix=ee;exports.ObjectRelativeFromH=kr;exports.ObjectRelativeFromV=Hr;exports.OnLifecycle=Qi;exports.OtherShapes=dr;exports.PRESET_LIST_TYPE=Il;exports.PageElementType=Kr;exports.PageOrientType=Gr;exports.PageType=as;exports.ParagraphElementType=vr;exports.PermissionService=so;exports.PermissionStatus=Ns;exports.Plugin=is;exports.PositionedObjectLayoutType=Tr;exports.PresetListType=Sn;exports.ProtectionType=ar;exports.RANGE_TYPE=it;exports.RCDisposable=$a;exports.RGBA_PAREN=Go;exports.RGB_PAREN=Bo;exports.ROTATE_BUFFER_VALUE=Xs;exports.Range=He;exports.Rectangle=me;exports.RedoCommand=ho;exports.RedoCommandId=lo;exports.RefAlias=qa;exports.Registry=hs;exports.RegistryAsMap=ds;exports.RelativeDate=lr;exports.RelativeSlideLink=Yr;exports.ResourceManagerService=ro;exports.RgbColor=Rn;exports.RxDisposable=Fa;exports.SectionType=Nr;exports.SheetTypes=An;exports.SheetViewModel=qi;exports.SliceBodyType=gs;exports.SlideDataModel=Os;exports.SpacingRule=Ur;exports.SpecialShapes=fr;exports.Styles=Bi;exports.THEME_COLORS=_r;exports.TabStopAlignment=Dr;exports.TextDecoration=ur;exports.TextDirection=qe;exports.TextDirectionType=br;exports.TextX=Ee;exports.TextXActionType=J;exports.ThemeColor=Cn;exports.ThemeColorType=Ht;exports.ThemeColors=bn;exports.ThemeService=vs;exports.Tools=x;exports.UndoCommand=co;exports.UndoCommandId=uo;exports.UnitModel=Mn;exports.Univer=ju;exports.UniverInstanceType=Q;exports.UpdateDocsAttributeType=Pt;exports.ValueIterator=ni;exports.VerticalAlign=xe;exports.WidthType=yr;exports.Worksheet=Je;exports.WrapStrategy=Pe;exports.WrapTextType=wr;exports.afterInitApply=Cl;exports.b64DecodeUnicode=ws;exports.b64EncodeUnicode=ac;exports.binarySearchArray=qs;exports.cellToRange=Ma;exports.characterSpacingControlType=Br;exports.checkForSubstrings=Ua;exports.checkIfMove=Ho;exports.checkParagraphHasBullet=La;exports.checkParagraphHasIndent=Da;exports.checkParagraphHasIndentByStyle=Zr;exports.codeToBlob=$o;exports.composeBody=ts;exports.composeInterceptors=Co;exports.concatMatrixArray=Ka;exports.convertBodyToHtml=rl;exports.covertTextRunToHtml=Qn;exports.createDefaultUser=Nn;exports.createInterceptorKey=sc;exports.createInternalEditorID=bu;exports.createRowColIter=Jn;exports.debounce=sl;exports.dedupe=Wa;exports.deepCompare=ls;exports.deleteContent=Qr;exports.extractPureTextFromCell=nu;exports.fromCallback=gi;exports.fromObservable=Ha;exports.generateRandomId=zr;exports.generateTemporarySnap=dc;exports.getArrayLength=ge;exports.getBodySlice=Ze;exports.getBodySliceHtml=hn;exports.getBorderStyleType=va;exports.getCellInfoInMergeData=la;exports.getCellValueType=ra;exports.getColorStyle=re;exports.getCustomDecorationSlice=yi;exports.getCustomRangeSlice=Di;exports.getDocsUpdateBody=wa;exports.getReverseDirection=Wo;exports.getSheetBlocksFromSnapshot=Ec;exports.getWorksheetUID=uu;exports.groupBy=ja;exports.handleStyleToString=ba;exports.hashAlgorithm=xa;exports.horizontalLineSegmentsSubtraction=wn;exports.insertMatrixArray=Xn;exports.insertTextToContent=Jr;exports.isBlackColor=ea;exports.isBooleanString=qu;exports.isCellCoverable=Oa;exports.isCellV=oa;exports.isEmptyCell=Xr;exports.isFormulaId=Aa;exports.isFormulaString=Na;exports.isICellData=sa;exports.isInternalEditorID=vu;exports.isNullCell=ia;exports.isNumeric=Eo;exports.isRangesEqual=Ku;exports.isRealNum=ya;exports.isSafeNumeric=Xu;exports.isSameStyleTextRun=qr;exports.isUnitRangesEqual=Yu;exports.isValidRange=Ta;exports.isWhiteColor=na;exports.makeArray=Va;exports.makeCellRangeToRangeData=Sa;exports.makeCellToSelection=Ia;exports.mergeOverrideWithDependencies=go;exports.mergeSets=Zu;exports.mergeWorksheetSnapshotWithDefault=Xi;exports.moveMatrixArray=Zn;exports.moveRangeByOffset=fl;exports.nameCharacterCheck=Rc;exports.normalizeBody=Dl;exports.normalizeTextRuns=fs;exports.numberToABC=Qa;exports.numberToListABC=tl;exports.orderSearchArray=Zs;exports.queryObjectMatrix=dl;exports.remove=Tn;exports.repeatStringNumTimes=oi;exports.replaceInDocumentBody=tc;exports.requestImmediateMacroTask=Qu;exports.rotate=Ga;exports.runOnLifecycle=Un;exports.searchArray=Fo;exports.selectionToArray=aa;exports.sequence=ci;exports.sequenceAsync=ui;exports.sequenceExecute=cs;exports.sequenceExecuteAsync=Rl;exports.shallowEqual=zu;exports.skipParseTagNames=pc;exports.sliceMatrixArray=Ya;exports.sortRules=el;exports.sortRulesByDesc=nl;exports.sortRulesFactory=Me;exports.spliceArray=qn;exports.takeAfter=mi;exports.textDecoder=xn;exports.textEncoder=nn;exports.throttle=Ju;exports.toDisposable=bt;exports.transformDocumentDataToSnapshot=mc;exports.transformSnapshotToDocumentData=gc;exports.transformSnapshotToWorkbookData=_c;exports.transformWorkbookDataToSnapshot=fc;exports.updateAttributeByDelete=ki;exports.updateAttributeByInsert=Hi;