@univerjs/core 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +9 -9
- package/lib/es/index.js +5378 -3714
- package/lib/types/docs/data-model/document-data-model.d.ts +10 -12
- package/lib/types/docs/data-model/json-x/json-x.d.ts +38 -0
- package/lib/types/{shared/permission/index.d.ts → docs/data-model/subdocument.d.ts} +1 -12
- package/lib/types/docs/data-model/text-x/__tests__/common.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/__tests__/invert.spec.d.ts +16 -0
- package/lib/types/docs/data-model/text-x/action-iterator.d.ts +1 -1
- package/lib/types/docs/data-model/{action-types.d.ts → text-x/action-types.d.ts} +4 -2
- package/lib/types/docs/data-model/{apply-utils → text-x/apply-utils}/common.d.ts +1 -1
- package/lib/types/docs/data-model/{apply-utils → text-x/apply-utils}/delete-apply.d.ts +1 -1
- package/lib/types/docs/data-model/{apply-utils → text-x/apply-utils}/insert-apply.d.ts +1 -1
- package/lib/types/docs/data-model/{apply-utils → text-x/apply-utils}/update-apply.d.ts +2 -2
- package/lib/types/docs/data-model/text-x/apply.d.ts +4 -0
- package/lib/types/docs/data-model/text-x/text-x.d.ts +10 -2
- package/lib/types/docs/data-model/text-x/utils.d.ts +2 -2
- package/lib/types/index.d.ts +13 -5
- package/lib/types/observer/__tests__/observable.spec.d.ts +16 -0
- package/lib/types/observer/observable.d.ts +1 -20
- package/lib/types/services/__test__/index.d.ts +18 -0
- package/lib/types/services/__test__/permission.spec.d.ts +16 -0
- package/lib/types/services/authz-io/authz-io-local.service.d.ts +30 -0
- package/lib/types/services/authz-io/type.d.ts +20 -0
- package/lib/types/services/command/command.service.d.ts +3 -1
- package/lib/types/services/context/context.d.ts +4 -0
- package/lib/types/services/locale/locale.service.d.ts +3 -1
- package/lib/types/services/permission/permission.service.d.ts +12 -24
- package/lib/types/services/permission/type.d.ts +43 -0
- package/lib/types/services/user-manager/const.d.ts +4 -0
- package/lib/types/services/{permission → user-manager}/index.d.ts +1 -3
- package/lib/types/services/user-manager/user-manager.service.d.ts +8 -0
- package/lib/types/shared/check-if-move.d.ts +6 -0
- package/lib/types/shared/index.d.ts +2 -1
- package/lib/types/shared/rectangle.d.ts +12 -0
- package/lib/types/{services/floating-object/floating-object-interfaces.d.ts → shared/shape.d.ts} +5 -6
- package/lib/types/sheets/sheet-snapshot-utils.d.ts +2 -2
- package/lib/types/sheets/workbook.d.ts +6 -3
- package/lib/types/slides/slide-model.d.ts +1 -1
- package/lib/types/types/enum/index.d.ts +1 -1
- package/lib/types/types/enum/prst-geom-type.d.ts +118 -0
- package/lib/types/types/interfaces/i-cell-data.d.ts +1 -0
- package/lib/types/types/interfaces/i-cell-validation-data.d.ts +1 -0
- package/lib/types/types/interfaces/i-document-data.d.ts +58 -7
- package/lib/types/types/interfaces/i-slide-data.d.ts +3 -3
- package/lib/umd/index.js +9 -9
- package/package.json +8 -8
- package/lib/types/services/floating-object/floating-object-manager.service.d.ts +0 -82
- package/lib/types/services/permission/permission-point.d.ts +0 -9
- package/lib/types/services/permission/univer.permission.service.d.ts +0 -12
- package/lib/types/types/enum/shape-type.d.ts +0 -160
- /package/lib/types/docs/data-model/{__tests__/apply-utils.spec.d.ts → json-x/__tests__/json-x.spec.d.ts} +0 -0
- /package/lib/types/docs/data-model/{__tests__/common.spec.d.ts → text-x/__tests__/apply-utils.spec.d.ts} +0 -0
package/lib/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var ir=Object.defineProperty;var or=(t,s,e)=>s in t?ir(t,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[s]=e;var d=(t,s,e)=>(or(t,typeof s!="symbol"?s+"":s,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("rxjs"),Lt=require("rxjs/operators"),A=require("@wendellhu/redi");function ar(){lr()}const Ot=typeof global<"u"?global:typeof self<"u"?self:window;function lr(){typeof Ot.requestIdleCallback!="function"&&(Ot.requestIdleCallback=function(e){const n=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-n));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof Ot.cancelIdleCallback!="function"&&(Ot.cancelIdleCallback=function(e){clearTimeout(e)})}function Ye(t,s){let e=0,n=t.length-1;for(;e<=n;){const r=Math.floor((n+e)/2);if(s<t[r]&&(r===0||s>=t[r-1]))return r;if(s>=t[r])e=r+1;else if(s<t[r])n=r-1;else return-1}return-1}function ze(t,s){let e=0,n=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(n=t[o],o===0?r=0:r=t[o-1],s>=r&&s<=n){i=o;break}if(n=t[e],e===0?r=0:r=t[e-1],s>=r&&s<n){i=e;break}e++,o--}return i}function ur(t,s){let e=t.length-1;return s<0?-1:s<t[0]?0:s>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||s<=t[20]||s>=t[e-20]?e=ze(t,s):e=Ye(t,s),e)}function cr(t){const s=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(s)}var ye=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(ye||{}),T=(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))(T||{}),Xe=(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))(Xe||{}),W=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(W||{}),qe=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(qe||{}),Je=(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))(Je||{}),Ze=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(Ze||{}),Qe=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Qe||{}),ts=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(ts||{});function hr(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var es=(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))(es||{}),ss=(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))(ss||{}),nt=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t))(nt||{}),ns=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(ns||{}),rs=(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))(rs||{}),is=(t=>(t[t.TYPE_UNSPECIFIED=0]="TYPE_UNSPECIFIED",t[t.TEXT_BOX=1]="TEXT_BOX",t[t.RECTANGLE=2]="RECTANGLE",t[t.ROUND_RECTANGLE=3]="ROUND_RECTANGLE",t[t.ELLIPSE=4]="ELLIPSE",t[t.ARC=5]="ARC",t[t.BENT_ARROW=6]="BENT_ARROW",t[t.BENT_UP_ARROW=7]="BENT_UP_ARROW",t[t.BEVEL=8]="BEVEL",t[t.BLOCK_ARC=9]="BLOCK_ARC",t[t.BRACE_PAIR=10]="BRACE_PAIR",t[t.BRACKET_PAIR=11]="BRACKET_PAIR",t[t.CAN=12]="CAN",t[t.CHEVRON=13]="CHEVRON",t[t.CHORD=14]="CHORD",t[t.CLOUD=15]="CLOUD",t[t.CORNER=16]="CORNER",t[t.CUBE=17]="CUBE",t[t.CURVED_DOWN_ARROW=18]="CURVED_DOWN_ARROW",t[t.CURVED_LEFT_ARROW=19]="CURVED_LEFT_ARROW",t[t.CURVED_RIGHT_ARROW=20]="CURVED_RIGHT_ARROW",t[t.CURVED_UP_ARROW=21]="CURVED_UP_ARROW",t[t.DECAGON=22]="DECAGON",t[t.DIAGONAL_STRIPE=23]="DIAGONAL_STRIPE",t[t.DIAMOND=24]="DIAMOND",t[t.DODECAGON=25]="DODECAGON",t[t.DONUT=26]="DONUT",t[t.DOUBLE_WAVE=27]="DOUBLE_WAVE",t[t.DOWN_ARROW=28]="DOWN_ARROW",t[t.DOWN_ARROW_CALLOUT=29]="DOWN_ARROW_CALLOUT",t[t.FOLDED_CORNER=30]="FOLDED_CORNER",t[t.FRAME=31]="FRAME",t[t.HALF_FRAME=32]="HALF_FRAME",t[t.HEART=33]="HEART",t[t.HEPTAGON=34]="HEPTAGON",t[t.HEXAGON=35]="HEXAGON",t[t.HOME_PLATE=36]="HOME_PLATE",t[t.HORIZONTAL_SCROLL=37]="HORIZONTAL_SCROLL",t[t.IRREGULAR_SEAL_1=38]="IRREGULAR_SEAL_1",t[t.IRREGULAR_SEAL_2=39]="IRREGULAR_SEAL_2",t[t.LEFT_ARROW=40]="LEFT_ARROW",t[t.LEFT_ARROW_CALLOUT=41]="LEFT_ARROW_CALLOUT",t[t.LEFT_BRACE=42]="LEFT_BRACE",t[t.LEFT_BRACKET=43]="LEFT_BRACKET",t[t.LEFT_RIGHT_ARROW=44]="LEFT_RIGHT_ARROW",t[t.LEFT_RIGHT_ARROW_CALLOUT=45]="LEFT_RIGHT_ARROW_CALLOUT",t[t.LEFT_RIGHT_UP_ARROW=46]="LEFT_RIGHT_UP_ARROW",t[t.LEFT_UP_ARROW=47]="LEFT_UP_ARROW",t[t.LIGHTNING_BOLT=48]="LIGHTNING_BOLT",t[t.MATH_DIVIDE=49]="MATH_DIVIDE",t[t.MATH_EQUAL=50]="MATH_EQUAL",t[t.MATH_MINUS=51]="MATH_MINUS",t[t.MATH_MULTIPLY=52]="MATH_MULTIPLY",t[t.MATH_NOT_EQUAL=53]="MATH_NOT_EQUAL",t[t.MATH_PLUS=54]="MATH_PLUS",t[t.MOON=55]="MOON",t[t.NO_SMOKING=56]="NO_SMOKING",t[t.NOTCHED_RIGHT_ARROW=57]="NOTCHED_RIGHT_ARROW",t[t.OCTAGON=58]="OCTAGON",t[t.PARALLELOGRAM=59]="PARALLELOGRAM",t[t.PENTAGON=60]="PENTAGON",t[t.PIE=61]="PIE",t[t.PLAQUE=62]="PLAQUE",t[t.PLUS=63]="PLUS",t[t.QUAD_ARROW=64]="QUAD_ARROW",t[t.QUAD_ARROW_CALLOUT=65]="QUAD_ARROW_CALLOUT",t[t.RIBBON=66]="RIBBON",t[t.RIBBON_2=67]="RIBBON_2",t[t.RIGHT_ARROW=68]="RIGHT_ARROW",t[t.RIGHT_ARROW_CALLOUT=69]="RIGHT_ARROW_CALLOUT",t[t.RIGHT_BRACE=70]="RIGHT_BRACE",t[t.RIGHT_BRACKET=71]="RIGHT_BRACKET",t[t.ROUND_1_RECTANGLE=72]="ROUND_1_RECTANGLE",t[t.ROUND_2_DIAGONAL_RECTANGLE=73]="ROUND_2_DIAGONAL_RECTANGLE",t[t.ROUND_2_SAME_RECTANGLE=74]="ROUND_2_SAME_RECTANGLE",t[t.RIGHT_TRIANGLE=75]="RIGHT_TRIANGLE",t[t.SMILEY_FACE=76]="SMILEY_FACE",t[t.SNIP_1_RECTANGLE=77]="SNIP_1_RECTANGLE",t[t.SNIP_2_DIAGONAL_RECTANGLE=78]="SNIP_2_DIAGONAL_RECTANGLE",t[t.SNIP_2_SAME_RECTANGLE=79]="SNIP_2_SAME_RECTANGLE",t[t.SNIP_ROUND_RECTANGLE=80]="SNIP_ROUND_RECTANGLE",t[t.STAR_10=81]="STAR_10",t[t.STAR_12=82]="STAR_12",t[t.STAR_16=83]="STAR_16",t[t.STAR_24=84]="STAR_24",t[t.STAR_32=85]="STAR_32",t[t.STAR_4=86]="STAR_4",t[t.STAR_5=87]="STAR_5",t[t.STAR_6=88]="STAR_6",t[t.STAR_7=89]="STAR_7",t[t.STAR_8=90]="STAR_8",t[t.STRIPED_RIGHT_ARROW=91]="STRIPED_RIGHT_ARROW",t[t.SUN=92]="SUN",t[t.TRAPEZOID=93]="TRAPEZOID",t[t.TRIANGLE=94]="TRIANGLE",t[t.UP_ARROW=95]="UP_ARROW",t[t.UP_ARROW_CALLOUT=96]="UP_ARROW_CALLOUT",t[t.UP_DOWN_ARROW=97]="UP_DOWN_ARROW",t[t.UTURN_ARROW=98]="UTURN_ARROW",t[t.VERTICAL_SCROLL=99]="VERTICAL_SCROLL",t[t.WAVE=100]="WAVE",t[t.WEDGE_ELLIPSE_CALLOUT=101]="WEDGE_ELLIPSE_CALLOUT",t[t.WEDGE_RECTANGLE_CALLOUT=102]="WEDGE_RECTANGLE_CALLOUT",t[t.WEDGE_ROUND_RECTANGLE_CALLOUT=103]="WEDGE_ROUND_RECTANGLE_CALLOUT",t[t.FLOW_CHART_ALTERNATE_PROCESS=104]="FLOW_CHART_ALTERNATE_PROCESS",t[t.FLOW_CHART_COLLATE=105]="FLOW_CHART_COLLATE",t[t.FLOW_CHART_CONNECTOR=106]="FLOW_CHART_CONNECTOR",t[t.FLOW_CHART_DECISION=107]="FLOW_CHART_DECISION",t[t.FLOW_CHART_DELAY=108]="FLOW_CHART_DELAY",t[t.FLOW_CHART_DISPLAY=109]="FLOW_CHART_DISPLAY",t[t.FLOW_CHART_DOCUMENT=110]="FLOW_CHART_DOCUMENT",t[t.FLOW_CHART_EXTRACT=111]="FLOW_CHART_EXTRACT",t[t.FLOW_CHART_INPUT_OUTPUT=112]="FLOW_CHART_INPUT_OUTPUT",t[t.FLOW_CHART_INTERNAL_STORAGE=113]="FLOW_CHART_INTERNAL_STORAGE",t[t.FLOW_CHART_MAGNETIC_DISK=114]="FLOW_CHART_MAGNETIC_DISK",t[t.FLOW_CHART_MAGNETIC_DRUM=115]="FLOW_CHART_MAGNETIC_DRUM",t[t.FLOW_CHART_MAGNETIC_TAPE=116]="FLOW_CHART_MAGNETIC_TAPE",t[t.FLOW_CHART_MANUAL_INPUT=117]="FLOW_CHART_MANUAL_INPUT",t[t.FLOW_CHART_MANUAL_OPERATION=118]="FLOW_CHART_MANUAL_OPERATION",t[t.FLOW_CHART_MERGE=119]="FLOW_CHART_MERGE",t[t.FLOW_CHART_MULTIDOCUMENT=120]="FLOW_CHART_MULTIDOCUMENT",t[t.FLOW_CHART_OFFLINE_STORAGE=121]="FLOW_CHART_OFFLINE_STORAGE",t[t.FLOW_CHART_OFFPAGE_CONNECTOR=122]="FLOW_CHART_OFFPAGE_CONNECTOR",t[t.FLOW_CHART_ONLINE_STORAGE=123]="FLOW_CHART_ONLINE_STORAGE",t[t.FLOW_CHART_OR=124]="FLOW_CHART_OR",t[t.FLOW_CHART_PREDEFINED_PROCESS=125]="FLOW_CHART_PREDEFINED_PROCESS",t[t.FLOW_CHART_PREPARATION=126]="FLOW_CHART_PREPARATION",t[t.FLOW_CHART_PROCESS=127]="FLOW_CHART_PROCESS",t[t.FLOW_CHART_PUNCHED_CARD=128]="FLOW_CHART_PUNCHED_CARD",t[t.FLOW_CHART_PUNCHED_TAPE=129]="FLOW_CHART_PUNCHED_TAPE",t[t.FLOW_CHART_SORT=130]="FLOW_CHART_SORT",t[t.FLOW_CHART_SUMMING_JUNCTION=131]="FLOW_CHART_SUMMING_JUNCTION",t[t.FLOW_CHART_TERMINATOR=132]="FLOW_CHART_TERMINATOR",t[t.ARROW_EAST=133]="ARROW_EAST",t[t.ARROW_NORTH_EAST=134]="ARROW_NORTH_EAST",t[t.ARROW_NORTH=135]="ARROW_NORTH",t[t.SPEECH=136]="SPEECH",t[t.STARBURST=137]="STARBURST",t[t.TEARDROP=138]="TEARDROP",t[t.ELLIPSE_RIBBON=139]="ELLIPSE_RIBBON",t[t.ELLIPSE_RIBBON_2=140]="ELLIPSE_RIBBON_2",t[t.CLOUD_CALLOUT=141]="CLOUD_CALLOUT",t[t.CUSTOM=142]="CUSTOM",t))(is||{}),Bt=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(Bt||{}),_t=(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))(_t||{}),os=(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))(os||{}),Z=(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))(Z||{}),rt=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(rt||{}),ft=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ft||{}),Mt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(Mt||{}),Pt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(Pt||{}),it=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(it||{}),C=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(C||{}),Q=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Q||{}),H=(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))(H||{}),kt=(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))(kt||{});const as={[kt.OFFICE]:{[H.ACCENT1]:"#4472C4",[H.ACCENT2]:"#ED7D31",[H.ACCENT3]:"#A5A5A5",[H.ACCENT4]:"#70AD47",[H.ACCENT5]:"#5B9BD5",[H.ACCENT6]:"#70AD47",[H.DARK1]:"#000000",[H.DARK2]:"#44546A",[H.LIGHT1]:"#FFFFFF",[H.LIGHT2]:"#E7E6E6",[H.HYPERLINK]:"#0563C1",[H.FOLLOWED_HYPERLINK]:"#954F72"}};class Gt{constructor(){d(this,"_themeValue",H.LIGHT1);d(this,"_themeColors");d(this,"_themeTint");d(this,"_rgbValue","");d(this,"_colorType");this._colorType=W.UNSUPPORTED,this._themeColors=kt.OFFICE,this._themeTint=0}asRgbColor(){return new xt(this._rgbValue,this)}asThemeColor(){return new Ht(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case W.THEME:return this.asThemeColor();case W.RGB:return this.asRgbColor();case W.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(s){return this._colorType=W.RGB,this._rgbValue=s,this}setThemeColors(s){this._colorType=W.THEME,this._themeColors=s}setThemeTint(s){this._colorType=W.THEME,this._themeTint=s}setThemeColor(s){return this._colorType=W.THEME,this._themeValue=s,this}getColorType(){return this._colorType}}class tt{constructor(s){d(this,"_builder");this._builder=s}static rgbColorToHexValue(s){return`#${((1<<24)+(s.getRed()<<16)+(s.getGreen()<<8)+s.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(s){s?s.indexOf("#")>-1&&(s=s.substring(1)):s="#000000";const e=+`0x${s[0]}${s[1]}`,n=+`0x${s[2]}${s[3]}`,r=+`0x${s[4]}${s[5]}`;return new Gt().setRgbColor(`rgb(${e},${n},${r})`).asRgbColor()}static hexToRgbString(s){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;s=s.replace(e,(i,o,a,l)=>o+o+a+a+l+l);const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);let r=null;if(n){const i=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16),a=Number.parseInt(n[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 tt(this._builder)}equals(s){return!1}}class ls{constructor(s){d(this,"_saturation",0);d(this,"_hue",0);d(this,"_lightness",0);d(this,"_alpha",0);const e=s.getRed()/255,n=s.getGreen()/255,r=s.getBlue()/255,i=s.getAlpha()/255,o=Math.min(e,Math.min(n,r)),a=Math.max(e,Math.max(n,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=(n-r)/l),n===a&&(this._hue=2+(r-e)/l),r===a&&(this._hue=4+(e-n)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const s=new Gt;if(this._saturation===0)return s.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),s.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const n=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,n,i),a=this.setColor(e,n,r),l=r-1/3,u=this.setColor(e,n,l);return s.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(u*255)},${this._alpha*255})`),s.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(s,e,n){n<0&&(n+=1),n>1&&(n-=1);let r;return 6*n<1?r=e+(s-e)*6*n:2*n<1?r=s:3*n<2?r=e+(s-e)*(2/3-n)*6:r=e,r}setLightness(s){this._lightness=s}}const F=class F extends tt{constructor(e,n){super(n);d(this,"_cssString");d(this,"_red");d(this,"_green");d(this,"_blue");d(this,"_alpha");let r=e.match(F.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(F.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 tt.rgbColorToHexValue(this)}getRed(){let e=this._red+F.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+F.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+F.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return W.RGB}clone(){return new F(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof F?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};d(F,"RGB_COLOR_AMT",0),d(F,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),d(F,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let xt=F;const Y=class Y extends tt{constructor(e,n,r,i){super(i);d(this,"_themeColorType");d(this,"_themeTint");d(this,"_themeColors");this._themeColorType=e,this._themeTint=n,this._themeColors=r}lumValue(e,n){if(e==null)return n;let r;return e<0?r=n*(1+e):r=n*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=as[this._themeColors];if(e==null)throw new Error("not find themeColors type");const n=e[this._themeColorType];if(n==null)throw new Error("not find themeColors value");let r;if(Y._cacheThemeColor.has(this._themeColors)){if(r=Y._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,Y._cacheThemeColor.set(this._themeColors,r);const i=new ls(tt.hexValueToRgbColor(n));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new Y(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof Y?e._themeColorType===this._themeColorType:!1}getColorType(){return W.THEME}getThemeColorType(){return this._themeColorType}};d(Y,"_cacheThemeColor",new Map);let Ht=Y;const dr="rgb(",_r="rgba(",ee={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 k{constructor(s){d(this,"_color");d(this,"_rgbColor");d(this,"_isValid",!1);if(s==null){this._setNullColor();return}if(s instanceof k){this._color={...s._color},this._rgbColor={...s._rgbColor};return}const e=us(s);if(e==null){this._setNullColor();return}this._color=e;const n=mr(this._color);if(n==null){this._setNullColor();return}this._rgbColor=n,this._isValid=!0}static mix(s,e,n){var u,c;n=Math.min(1,Math.max(0,n));const r=new k(s).toRgb(),i=new k(e).toRgb(),o=(u=r.a)!=null?u:1,a=(c=i.a)!=null?c:1,l={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(a-o)*n+o};return new k(l)}static getContrastRatio(s,e){const n=new k(s).getLuminance(),r=new k(e).getLuminance();return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:s,g:e,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${s},${e},${n}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(s){const{r:e,g:n,b:r,a:i=1}=this.toRgb(),o=i<1,a=[It(Math.round(e).toString(16)),It(Math.round(n).toString(16)),It(Math.round(r).toString(16)),It(Math.round(i*255).toString(16))];return s&&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 Ar(this.toRgb())}toHsl(){return Ir(this.toRgb())}lighten(s=10){const e=this.toHsl();return e.l+=s,e.l=Math.min(Math.max(e.l,0),100),new k(e)}darken(s=10){const e=this.toHsl();return e.l-=s,e.l=Math.min(Math.max(e.l,0),100),new k(e)}setAlpha(s){return new k({...this._rgbColor,a:s})}getLuminance(){let{r:s,g:e,b:n}=this.toRgb();return s=qt(s),e=qt(e),n=qt(n),Number((.2126*s+.7152*e+.0722*n).toFixed(3))}getBrightness(){const{r:s,g:e,b:n}=this.toRgb();return(s*299+e*587+n*114)/1e3}getAlpha(){var s;return(s=this._color.a)!=null?s: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 It=t=>t.length===1?`0${t}`:t,qt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),us=t=>{if(Sr(t)){if("r"in t){const n={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(n.a=t.a),n}if("l"in t){const n={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(n.a=t.a),n}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const s=t.trim();if(ee[s]){const e=ee[s],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(s.startsWith("#"))return fr(s);if(s.startsWith("rgb"))return Er(s);if(s.startsWith("hsl"))return gr(s);if(s.startsWith("hsv"))return Rr(s)},fr=t=>{const s=t.substring(1),e=new RegExp(`.{1,${s.length>=6?2:1}}`,"g");let n=s.match(e);if(!n||n.length<3)throw new Error(`The color '${t}' is illegal hex color`);n[0].length===1&&(n=n.map(i=>i+i));const r={r:Number.parseInt(n[0],16),g:Number.parseInt(n[1],16),b:Number.parseInt(n[2],16)};return n.length>3&&(r.a=Number.parseInt(n[3],16)/255),r},Er=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const n={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},gr=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const n={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},Rr=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const n={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},mr=t=>{const s=us(t);if(s!=null)return"r"in s?s:"l"in s?Cr(s):Or(s)},Jt=(t,s,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(s-t)*6*e:e<1/2?s:e<2/3?t+(s-t)*(2/3-e)*6:t),Cr=t=>{let{h:s,s:e,l:n}=t;s/=360,e/=100,n/=100;let r=0,i=0,o=0;if(e===0)r=i=o=n;else{const l=n<.5?n*(1+e):n+e-n*e,u=2*n-l;r=Jt(u,l,s+1/3),i=Jt(u,l,s),o=Jt(u,l,s-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},Or=t=>{let{h:s,s:e,v:n}=t;s=s/360*6,e/=100,n/=100;const r=Math.floor(s),i=s-r,o=n*(1-e),a=n*(1-i*e),l=n*(1-(1-i)*e),u=r%6,c=[n,a,o,o,l,n][u],h=[l,n,n,a,o,o][u],_=[o,o,l,n,n,a][u],f={r:c*255,g:h*255,b:_*255};return t.a!==void 0&&(f.a=t.a),f},Ir=t=>{let{r:s,g:e,b:n}=t;s/=255,e/=255,n/=255;const r=Math.max(s,e,n),i=Math.min(s,e,n),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 s:a=(e-n)/c+(e<n?6:0);break;case e:a=(n-s)/c+2;break;default:a=(s-e)/c+4;break}a/=6}const u={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(u.a=t.a),u},Ar=t=>{let{r:s,g:e,b:n}=t;s/=255,e/=255,n/=255;const r=Math.max(s,e,n),i=Math.min(s,e,n);let o;const a=r,l=r-i,u=r===0?0:l/r;if(r===i)o=0;else{switch(r){case s:o=(e-n)/l+(e<n?6:0);break;case e:o=(n-s)/l+2;break;default:o=(s-e)/l+4;break}o/=6}const c={h:Math.round(o*360),s:Math.round(u*100),v:Math.round(a*100)};return t.a!==void 0&&(c.a=t.a),c},Nr=t=>t==null,Sr=t=>!Nr(t)&&typeof t=="object";function Lr(t){const s=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,n=/^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!!(s.test(t)||e.test(t)||n.test(t)||r.test(t)||i.test(t))}function Tr(t){const s=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,n=/^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!!(s.test(t)||e.test(t)||n.test(t)||r.test(t)||i.test(t))}var P=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(P||{});function br(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 wr(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Q.STRING;if(typeof t.v=="number")return Q.NUMBER;if(typeof t.v=="boolean")return Q.BOOLEAN}function vr(t){if(t==null)return!0;const{v:s,f:e,si:n,p:r,s:i,custom:o}=t;return!(!(s==null||typeof s=="string"&&s.length===0)||e!=null&&e.length>0||n!=null&&n.length>0||r!=null||o!=null)}function Ur(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var cs=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(cs||{}),hs=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(hs||{}),ut=(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))(ut||{}),K=(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))(K||{}),ds=(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))(ds||{}),_s=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(_s||{}),fs=(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))(fs||{}),Es=(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))(Es||{}),gs=(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))(gs||{}),Rs=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Rs||{}),ms=(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))(ms||{}),Cs=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(Cs||{}),Os=(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))(Os||{}),Is=(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))(Is||{}),As=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(As||{}),Ns=(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))(Ns||{}),Ss=(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))(Ss||{}),Ls=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(Ls||{}),Ts=(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))(Ts||{}),bs=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(bs||{}),ws=(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))(ws||{}),vs=(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))(vs||{}),Us=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(Us||{}),Ds=(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))(Ds||{}),ps=(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))(ps||{}),Ms=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Ms||{}),Ps=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Ps||{}),x=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(x||{}),w=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(w||{});function Dr(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}var _e=(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))(_e||{}),xs=(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))(xs||{}),Hs=(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))(Hs||{});const pr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Mr=t=>crypto.getRandomValues(new Uint8Array(t)),Pr=(t,s,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*n*s/t.length);return(i=s)=>{let o="";for(;;){let a=e(r),l=r;for(;l--;)if(o+=t[a[l]&n]||"",o.length===i)return o}}},xr=(t,s=21)=>Pr(t,s,Mr),Hr=(t=21)=>{let s="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)s+=pr[e[t]&63];return s};const Fr=/^-ms-/,Wr=/-([a-z])/g,j=["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 R{static stringAt(s){let e="",n=s;for(;n>=j.length;)n/=j.length,n-=1,e+=j[n%j.length];const r=s%j.length;return e+=j[r],e}static indexAt(s){let e=0;for(let n=0;n<s.length-1;n+=1){const r=s.charCodeAt(n)-65,i=s.length-1-n;e+=j.length**i+j.length*r}return e+=s.charCodeAt(s.length-1)-65,e}static deleteBlank(s){return R.isString(s)?s.replace(/\s/g,""):s}static getSystemType(){const s=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",n=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(n)return"Mac";if(navigator.platform==="X11"&&!e&&!n)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(s.indexOf("Windows NT 5.0")>-1||s.indexOf("Windows 2000")>-1)return"Windows 2000";if(s.indexOf("Windows NT 5.1")>-1||s.indexOf("Windows XP")>-1)return"Windows XP";if(s.indexOf("Windows NT 5.2")>-1||s.indexOf("Windows 2003")>-1)return"Windows 2003";if(s.indexOf("Windows NT 6.0")>-1||s.indexOf("Windows Vista")>-1)return"Windows Vista";if(s.indexOf("Windows NT 6.1")>-1||s.indexOf("Windows 7")>-1)return"Windows 7";if(s.indexOf("Windows NT 10")>-1||s.indexOf("Windows 10")>-1)return"Windows 10";if(s.indexOf("Windows NT 11")>-1||s.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const s=navigator.userAgent,e=s.indexOf("Opera")>-1,n=s.indexOf("compatible")>-1&&s.indexOf("MSIE")>-1&&!e,r=s.indexOf("Trident")>-1&&s.indexOf("rv:11.0")>-1,i=s.indexOf("Edge")>-1,o=s.indexOf("Firefox")>-1,a=s.indexOf("Safari")>-1&&s.indexOf("Chrome")===-1,l=s.indexOf("Chrome")>-1&&s.indexOf("Safari")>-1;if(n){new RegExp("MSIE (\\d+\\.\\d+);").test(s);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(s=21,e){return e?xr(e,s)():Hr(s)}static getClassName(s){return s.constructor.name}static deepMerge(s,...e){e.forEach(o=>o&&i(o));function n(o,a){o.forEach((l,u)=>{var c,h;if(R.isArray(l)){const _=(c=a[u])!=null?c:[];a[u]=_,n(l,_);return}if(R.isObject(l)){const _=(h=a[u])!=null?h:{};a[u]=_,r(l,_);return}a[u]=l})}function r(o,a){Object.keys(o).forEach(l=>{var c,h;const u=o[l];if(R.isObject(u)){const _=(c=a[l])!=null?c:{};a[l]=_,r(u,_);return}if(R.isArray(u)){const _=(h=a[l])!=null?h:[];a[l]=_,n(u,_);return}a[l]=u})}function i(o){Object.keys(o).forEach(a=>{var u,c;const l=o[a];if(R.isArray(l)){const h=(u=s[a])!=null?u:[];s[a]=h,n(l,h);return}if(R.isObject(l)){const h=(c=s[a])!=null?c:{};s[a]=h,r(l,h);return}s[a]=l})}return s}static numberFixed(s,e){return Number(Number(s).toFixed(e))}static diffValue(s,e){function n(o,a){const l=R.getValueType(o),u=R.getValueType(a);return l!==u?!1:R.isArray(o)?r(o,a):R.isObject(o)?i(o,a):R.isDate(o)?o.getTime()===a.getTime():R.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(s.length!==e.length)return!1;for(let l=0,u=o.length;l<u;l++){const c=o[l],h=a[l];if(!n(c,h))return!1}return!0}function i(o,a){const l=Object.keys(o),u=Object.keys(a);if(l.length!==u.length)return!1;for(const c of l){if(!u.includes(c))return!1;const h=o[c],_=a[c];if(!n(h,_))return!1}return!0}return n(s,e)}static deepClone(s){if(!this.isDefine(s))return s;if(this.isRegExp(s))return new RegExp(s);if(this.isDate(s))return new Date(s);if(this.isArray(s)){const e=[];return s.forEach((n,r)=>{e[r]=R.deepClone(n)}),e}if(this.isObject(s)){const e={};return Object.keys(s).forEach(n=>{const r=s[n];e[n]=R.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(s)),e}return s}static getLanguage(){const s="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||s}static getValueType(s){return Object.prototype.toString.apply(s)}static isDefine(s){return s!=null}static isBlank(s){return this.isDefine(s)?this.isString(s)?s.trim()==="":!1:!0}static isAssignableFrom(s,e){return s instanceof e}static isBoolean(s){return this.getValueType(s)==="[object Boolean]"}static isPlainObject(s){return this.isDefine(s)?Object.getPrototypeOf(s)===Object.getPrototypeOf({}):!1}static isFunction(s){return this.getValueType(s)==="[object Function]"}static isDate(s){return this.getValueType(s)==="[object Date]"}static isRegExp(s){return this.getValueType(s)==="[object RegExp]"}static isArray(s){return this.getValueType(s)==="[object Array]"}static isString(s){return this.getValueType(s)==="[object String]"}static isNumber(s){return this.getValueType(s)==="[object Number]"}static isStringNumber(s){return!isNaN(Number.parseFloat(s))&&isFinite(s)}static isObject(s){return this.getValueType(s)==="[object Object]"}static isEmptyObject(s){for(const e in s)return!1;return!0}static isMobile(){let s=0,e=0;return document.body.clientWidth&&(s=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||s<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 s=navigator.userAgent.toLowerCase();return String(s.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const s=navigator.userAgent;return s.indexOf("Android")>-1||s.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static itCount(s){return e=>{for(let n=0;n<s;n++)e&&e()}}static hasLength(s,e){return R.isDefine(s)?R.isDefine(e)?s.length===e:s.length>0:!1}static capitalize(s){return s.charAt(0).toUpperCase()+s.slice(1)}static fCamelCase(s,e){return e.toUpperCase()}static camelCase(s){return s.replace(Fr,"ms-").replace(Wr,this.fCamelCase)}static removeNull(s){return this.isObject(s)&&Object.keys(s).forEach(e=>{const n=s[e];n==null?delete s[e]:R.removeNull(n)}),s}static fillTwoDimensionalArray(s,e,n){return new Array(s).fill(n).map(r=>new Array(e).fill(n))}static numToWord(s){let e="";for(;s>0;){let n=s%26;n=n===0?n=26:n,e=String.fromCharCode(96+n)+e,s=(s-n)/26}return e.toLocaleUpperCase()}static ABCatNum(s){if(s==null||s.length===0)return Number.NaN;const e=s.toLowerCase().split(""),n=e.length;let r=0,i=0;for(let o=0;o<n;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(n-o-1);return r===0?Number.NaN:r-1}static chatAtABC(s){let i="";for(;s>=0;)i=String.fromCharCode(s%26+97)+i,s=Math.floor(s/26)-1;return i.toUpperCase()}static randSort(s){for(let e=0,n=s.length;e<n;e++){const r=Number.parseInt((Math.random()*n).toString()),i=s[r];s[r]=s[e],s[e]=i}return s}static commonExtend(s,e){const n={};for(const r in s)n[r]=s[r];for(const r in e)e[r]!=null&&(n[r]=e[r]);return n}static commonExtend1(s,e){for(const n in s)e[n]==null&&(e[n]=s[n]);return e}static arrayToObject(s){const e={};return s.forEach((n,r)=>{e[r]={},n.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(s,e,n,r){return e>=n&&r>=s}static isStartValidPosition(s){return/^[A-Za-z_]/.test(s)}static isValidParameter(s){const e=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(s),n=s.length<=255;return!e&&n}}function Br(t){if(!t)return;const{actualRow:s,actualColumn:e,isMerged:n,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:u}=t,c=s,h=e,_=s,f=e;if(n&&i){const{startRow:E,startColumn:g,endRow:m,endColumn:S,startY:U,endY:M,startX:V,endX:rr}=i;c=E,h=g,_=m,f=S,o=U,a=M,l=V,u=rr}return r&&(o=i.startY,a=i.endY,l=i.startX,u=i.endX,_=i.endRow,f=i.endColumn),{startRow:c,startColumn:h,endRow:_,endColumn:f,startY:o,endY:a,startX:l,endX:u}}function kr(t){if(!t)return;const{actualRow:s,actualColumn:e,isMerged:n,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let u=s,c=e,h=s,_=e;return(n||r)&&(u=i,c=o,h=a,_=l),{startRow:u,startColumn:c,endRow:h,endColumn:_}}function Gr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function $(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new Gt().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function $r(t){return R.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Vr(t){return R.isString(t)&&t.length>0}function jr(t){return""}function Kr(t,s=!1){var i;let e="";const n=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-line: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${$(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: ${$(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: ${$(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${$(t.bg)}; `)}],["bd",()=>{var o,a,l,u,c,h,_,f,E,g,m,S;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${At((a=t.bd)==null?void 0:a.b.s)} ${(l=$(t.bd.b.cl))!=null?l:""}; `),(u=t.bd)!=null&&u.t&&(e+=`border-top: ${At((c=t.bd)==null?void 0:c.t.s)} ${(h=$(t.bd.t.cl))!=null?h:""}; `),(_=t.bd)!=null&&_.r&&(e+=`border-right: ${At((f=t.bd)==null?void 0:f.r.s)} ${(E=$(t.bd.r.cl))!=null?E:""}; `),(g=t.bd)!=null&&g.l&&(e+=`border-left: ${At((m=t.bd)==null?void 0:m.l.s)} ${(S=$(t.bd.l.cl))!=null?S:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${$(t.cl)}; `)}],["va",()=>{t.va===it.SUBSCRIPT?e+="vertical-align: sub; ":t.va===it.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===_t.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===_t.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===Z.LEFT?e+="text-align: left; ":t.ht===Z.RIGHT?e+="text-align: right; ":t.ht===Z.CENTER?e+="text-align: center; ":t.ht===Z.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===rt.BOTTOM?e+="vertical-align: bottom; ":t.vt===rt.TOP?e+="vertical-align: top; ":t.vt===rt.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===ft.CLIP?e+="white-space: clip; ":t.tb===ft.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var c,h,_,f,E,g,m,S;const o=`${(c=t.pd)==null?void 0:c.b}pt`,a=`${(h=t.pd)==null?void 0:h.t}pt`,l=`${(_=t.pd)==null?void 0:_.l}pt`,u=`${(f=t.pd)==null?void 0:f.r}pt`;(E=t.pd)!=null&&E.b&&(e+=`padding-bottom: ${o}; `),(g=t.pd)!=null&&g.t&&(e+=`padding-top: ${a}; `),(m=t.pd)!=null&&m.l&&(e+=`padding-left: ${l}; `),(S=t.pd)!=null&&S.r&&(e+=`padding-right: ${u}; `)}]]),r=["bd","tr","tb"];for(const o in t)s&&r.includes(o)||(i=n.get(o))==null||i();return e}function At(t){let s="";return t===T.NONE?s="none":t===T.THIN?s="0.5pt solid":t===T.HAIR?s="0.5pt double":t===T.DOTTED?s="0.5pt dotted":t===T.DASHED||t===T.DASH_DOT?s="0.5pt dashed":t===T.DASH_DOT_DOT?s="0.5pt dotted":t===T.DOUBLE?s="0.5pt double":t===T.MEDIUM?s="1pt solid":t===T.MEDIUM_DASHED||t===T.MEDIUM_DASH_DOT?s="1pt dashed":t===T.MEDIUM_DASH_DOT_DOT?s="1pt dotted":t===T.SLANT_DASH_DOT?s="0.5pt dashed":t===T.THICK&&(s="1.5pt solid"),s}function Yr(t){let s=0;if(t=t.trim(),t==="none")s=T.NONE;else if(t==="0.5pt solid")s=T.THIN;else if(t==="0.5pt double")s=T.HAIR;else if(t==="0.5pt dotted")s=T.DOTTED;else if(t==="0.5pt dashed")s=T.DASHED;else if(t==="1pt solid")s=T.MEDIUM;else if(t==="1pt dashed")s=T.MEDIUM_DASHED;else if(t==="1pt dotted")s=T.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")s=T.THICK;else if(!t.includes("none"))s=T.THIN;else return T.NONE;return s}function Tt(t,s){let e=t.body;if(s){const{headers:n,footers:r}=t;n!=null&&n[s]?e=n[s].body:r!=null&&r[s]&&(e=r[s].body)}return e}function zr(t){const{startRow:s,endRow:e,startColumn:n,endColumn:r,rangeType:i}=t;return!(s<0||n<0||e<0||r<0||!(Number.isNaN(s)&&Number.isNaN(e))&&i===x.COLUMN||!(Number.isNaN(n)&&Number.isNaN(r))&&i===x.ROW)}function yr(t,s){return{startRow:t,endRow:t,startColumn:s,endColumn:s}}function fe(t,s){return Object.prototype.toString.call(t)===Object.prototype.toString.call(s)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(s).length?!1:Object.keys(t).every(e=>fe(t[e],s[e])):t===s:!1}function Fs(t,s){const e=t.ts||{},n=s.ts||{};return t.sId!==s.sId?!1:fe(e,n)}function Xr(t,s){return s.some(e=>t.indexOf(e)>-1)}function Ee(t,s,e,n){if(t>s&&([t,s]=[s,t]),e>n&&([e,n]=[n,e]),s<e||n<t)return[t,s];e<t&&(e=t),n>s&&(n=s);const r=n-e+1;let i=[];return t===e?i=[n+1-r,s-r]:s===n?i=[t,e-1]:i=[t,s-r],i}function qr(t){if(t==null)return!1;const s=t.bullet;return(s==null?void 0:s.listId)!=null}function Jr(t){if(t==null)return!1;const s=t.paragraphStyle;return Ws(s)}function Ws(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Bs(t,s,e){return t.slice(0,s)+e+t.slice(s)}function ks(t,s,e){return s>e?t:t.slice(0,s)+t.slice(e)}function Zr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Qr(t){let s=0;for(let e=0;e<t.length;e++)s=t.charCodeAt(e)+(s<<6)+(s<<16)-s;return s>>>0}function Pe(t){var s=typeof Symbol=="function"&&Symbol.iterator,e=s&&t[s],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function xe(t,s){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),r,i=[],o;try{for(;(s===void 0||s-- >0)&&!(r=n.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(o)throw o.error}}return i}function He(t,s,e){if(e||arguments.length===2)for(var n=0,r=s.length,i;n<r;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return t.concat(i||Array.prototype.slice.call(s))}function ct(t){return typeof t=="function"}function ti(t){var s=function(n){Error.call(n),n.stack=new Error().stack},e=t(s);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Zt=ti(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
|
-
`+
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function Fe(t,s){if(t){var e=t.indexOf(s);0<=e&&t.splice(e,1)}}var Gs=function(){function t(s){this.initialTeardown=s,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var s,e,n,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=Pe(o),l=a.next();!l.done;l=a.next()){var u=l.value;u.remove(this)}}catch(g){s={error:g}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(s)throw s.error}}else o.remove(this);var c=this.initialTeardown;if(ct(c))try{c()}catch(g){i=g instanceof Zt?g.errors:[g]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var _=Pe(h),f=_.next();!f.done;f=_.next()){var E=f.value;try{We(E)}catch(g){i=i!=null?i:[],g instanceof Zt?i=He(He([],xe(i)),xe(g.errors)):i.push(g)}}}catch(g){n={error:g}}finally{try{f&&!f.done&&(r=_.return)&&r.call(_)}finally{if(n)throw n.error}}}if(i)throw new Zt(i)}},t.prototype.add=function(s){var e;if(s&&s!==this)if(this.closed)We(s);else{if(s instanceof t){if(s.closed||s._hasParent(this))return;s._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(s)}},t.prototype._hasParent=function(s){var e=this._parentage;return e===s||Array.isArray(e)&&e.includes(s)},t.prototype._addParent=function(s){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(s),e):e?[e,s]:s},t.prototype._removeParent=function(s){var e=this._parentage;e===s?this._parentage=null:Array.isArray(e)&&Fe(e,s)},t.prototype.remove=function(s){var e=this._finalizers;e&&Fe(e,s),s instanceof t&&s._removeParent(this)},t.EMPTY=function(){var s=new t;return s.closed=!0,s}(),t}();Gs.EMPTY;function ei(t){return t instanceof Gs||t&&"closed"in t&&ct(t.remove)&&ct(t.add)&&ct(t.unsubscribe)}function We(t){ct(t)?t():t.unsubscribe()}class $s{constructor(s=!1){d(this,"skipNextObservers");d(this,"lastReturnValue");d(this,"isStopPropagation",!1);this.initialize(s)}initialize(s=!1){return this.skipNextObservers=s,this}stopPropagation(){this.isStopPropagation=!0}}function Vs(t){return t instanceof $t}class $t{constructor(s,e){d(this,"_willBeUnregistered",!1);d(this,"unregisterOnNextCall",!1);this.callback=s,this.observable=e}dispose(){this.observable.remove(this)}}class Vt{constructor(s){d(this,"_observers",new Array);d(this,"_eventState");d(this,"_onObserverAdded");this._eventState=new $s,s&&(this._onObserverAdded=s)}get observers(){return this._observers}add(s,e=!1,n=!1){if(!s)return null;const r=new $t(s,this);return r.unregisterOnNextCall=n,e?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),r}addOnce(s){return this.add(s,void 0,!0)}remove(s){return s&&this._observers.indexOf(s)!==-1?(this._deferUnregister(s),!0):!1}removeCallback(s){for(let e=0;e<this._observers.length;e++){const n=this._observers[e];if(!n._willBeUnregistered&&n.callback===s)return this._deferUnregister(n),!0}return!1}makeObserverTopPriority(s){this._remove(s),this._observers.unshift(s)}makeObserverBottomPriority(s){this._remove(s),this._observers.push(s)}notifyObservers(s){if(!this._observers.length)return null;const e=this._eventState;e.skipNextObservers=!1,e.lastReturnValue=s,e.isStopPropagation=!1;let n=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(!i._willBeUnregistered&&(e.lastReturnValue=i.callback(s,e),i.unregisterOnNextCall&&this._deferUnregister(i),e.isStopPropagation&&(n=!0),e.skipNextObservers))return{lastReturnValue:e.lastReturnValue,stopPropagation:n}}return{lastReturnValue:e.lastReturnValue,stopPropagation:n}}notifyObserversWithPromise(s){let e=Promise.resolve(s);if(!this._observers.length)return e;const n=this._eventState;n.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];n.skipNextObservers||i._willBeUnregistered||(e=e.then(()=>i.callback(s,n)),i.unregisterOnNextCall&&this._deferUnregister(i))}return e.then(()=>s)}notifyObserver(s,e){if(s._willBeUnregistered)return;const n=this._eventState;return n.skipNextObservers=!1,s.callback(e,n),s.unregisterOnNextCall&&this._deferUnregister(s),{lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const s=new Vt;return s._observers=this._observers.slice(0),s}_deferUnregister(s){s.unregisterOnNextCall=!1,s._willBeUnregistered=!0,setTimeout(()=>{this._remove(s)},0)}_remove(s){if(!s)return!1;const e=this._observers.indexOf(s);return e!==-1?(this._observers.splice(e,1),!0):!1}}function v(t){let s=!1;return t?ei(t)?{dispose:()=>t.unsubscribe()}:Vs(t)?{dispose:()=>{s||(s=!0,t.dispose())}}:typeof t=="function"?{dispose:()=>{s||(s=!0,t())}}:t:v(()=>{})}function si(t){return v(()=>{t.unsubscribe()})}class ge{constructor(){d(this,"_disposables",new Set)}add(s){const e=v(s);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(s=>{s.dispose()}),this._disposables.clear()}}class p{constructor(){d(this,"_disposed",!1);d(this,"_collection",new ge)}disposeWithMe(s){return this._collection.add(s)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class ni extends p{constructor(){super(...arguments);d(this,"dispose$",new N.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class at{static hasLength(s,e){return s.length===e}static getValueType(s){return Object.prototype.toString.apply(s)}static isObject(s){return this.getValueType(s)==="[object Object]"}static isIterable(s){return s[Symbol.iterator]!=null}static isNumber(s){return this.getValueType(s)==="[object Number]"}}function jt(t,s){const e=t.indexOf(s);return e>-1?(t.splice(e,1),!0):!1}function ri(t){const s=new Set,e=[];for(const n of t)s.has(n)||(s.add(n),e.push(n));return e}function ii(t,s){for(let e=t.length-1;e>-1;e--){const n=t[e];if(s(n,e))return n}return null}function oi(t,s){if(t.length===0)return t;const e=s%t.length;return t.slice(e).concat(t.slice(0,e))}function ai(t,s){const e=new Map;return t.forEach(n=>{const r=s(n);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(n)}),e}const L=Symbol("newer"),D=Symbol("older");class js{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[L],{done:!1,value:s.key}):{done:!0,value:void 0}}}class Ks{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[L],{done:!1,value:s.value}):{done:!0,value:void 0}}}class Ys{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[L],{done:!1,value:[s.key,s.value]}):{done:!0,value:void 0}}}var ba,wa;class se{constructor(s,e){d(this,"key");d(this,"value");d(this,ba);d(this,wa);this.key=s,this.value=e,this[L]=void 0,this[D]=void 0}toJSON(){return{key:this.key,value:this.value}}}ba=L,wa=D;class zs{constructor(...s){d(this,"_keymap");d(this,"size",0);d(this,"limit");d(this,"oldest");d(this,"newest");d(this,"_onShiftListeners",[]);if(at.hasLength(s,1)){if(at.isNumber(s[0])){const e=s[0];this._initialize(e,void 0);return}if(at.isIterable(s[0])){const e=s[0];this._initialize(0,e);return}return}if(at.hasLength(s,2)){const e=s[0],n=s[1];this._initialize(e,n)}}onShift(s){if(this._onShiftListeners.indexOf(s)===-1)return this._onShiftListeners.push(s),v(()=>jt(this._onShiftListeners,s));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(s,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=s,this._keymap=new Map,e&&(this.assign(e),s<1&&(this.limit=this.size))}_markEntryAsUsed(s){s!==this.newest&&(s[L]&&(s===this.oldest&&(this.oldest=s[L]),s[L][D]=s[D]),s[D]&&(s[D][L]=s[L]),s[L]=void 0,s[D]=this.newest,this.newest&&(this.newest[L]=s),this.newest=s)}assign(s){let e,n=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=s[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new se(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[L]=o,o[D]=e):this.oldest=o,e=o,n--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(s,e){let n=this._keymap.get(s);return n?(n.value=e,this._markEntryAsUsed(n),this):(this._keymap.set(s,n=new se(s,e)),this.newest?(this.newest[L]=n,n[D]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const s=this.oldest;if(s)return this.oldest&&this.oldest[L]?(this.oldest=this.oldest[L],this.oldest[D]=void 0):(this.oldest=void 0,this.newest=void 0),s[L]=s[D]=void 0,this._keymap.delete(s.key),--this.size,this._onShiftListeners.forEach(e=>e(s)),[s.key,s.value]}get(s){const e=this._keymap.get(s);if(e)return this._markEntryAsUsed(e),e.value}has(s){return this._keymap.has(s)}find(s){const e=this._keymap.get(s);return e?e.value:void 0}delete(s){const e=this._keymap.get(s);if(e)return this._keymap.delete(e.key),e[L]&&e[D]?(e[D][L]=e[L],e[L][D]=e[D]):e[L]?(e[L][D]=void 0,this.oldest=e[L]):e[D]?(e[D][L]=void 0,this.newest=e[D]):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 js(this.oldest)}values(){return new Ks(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ys(this.oldest)}forEach(s,e){typeof e!="object"&&(e=this);let n=this.oldest;for(;n;)s.call(e,n.value,n.key,this),n=n[L]}toJSON(){const s=new Array(this.size);let e=0,n=this.oldest;for(;n;)s[e++]={key:n.key,value:n.value},n=n[L];return s}toString(){let s="",e=this.oldest;for(;e;)s+=`${String(e.key)}:${e.value}`,e=e[L],e&&(s+=" < ");return s}}function y(t){let s=0;const e=Object.keys(t);for(const n of e){const r=Number(n);s=Math.max(s,r)}return s+1}function ne(t,s,e){const n=y(e),r=e;for(let i=n-1;i>=t;i--)r[i+1]=r[i];r[t]=s}function re(t,s,e){const n=Object.keys(e).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<n;r++)r<t+s?delete e[r]:e[r]!==void 0&&(e[r-s]=e[r],delete e[r])}function li(t,s){const e=t,n=Object.keys(e),r=n.length,i=s,o=Object.keys(i),a=o.length,l={};let u=0;for(let c=0;c<r;c++,u++){const h=n[c];l[u]=e[h]}for(let c=0;c<a;c++,u++){const h=o[c];l[u]=i[h]}return l}function ui(t,s,e){const n=e;if(y(e)>0){const i={};let o=0;for(let a=t;a<=s;a++)n[a]&&(i[o]=n[a],o++);return i}return{}}function ie(t,s,e,n){const r=t>e;if(!r&&t+s>e)throw new Error("Invalid move operation");r?ci(t,s,e,n):hi(t,s,e,n)}function ci(t,s,e,n){const r=n,i=[];for(let o=t;o<t+s;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+s]=a,a===void 0&&delete r[o+s]}i.forEach((o,a)=>{r[e+a]=o,o===void 0&&delete r[e+a]})}function hi(t,s,e,n){const r=n,i=[];for(let o=t;o<t+s;o++)i.push(r[o]);for(let o=t+s;o<e;o++){const a=r[o];r[o-s]=a,a===void 0&&delete r[o-s]}i.forEach((o,a)=>{r[e+a-s]=o,o===void 0&&delete r[e+a-s]})}class G{constructor(s={}){d(this,"_matrix");this._setOriginValue(s)}static MakeObjectMatrixSize(s){return new G({[s-1]:{}})}getMatrix(){return this._matrix}forEach(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(s(i,o)===!1)return this}return this}forRow(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(s(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const u=Number(l),c=o[Number(l)];if(s(i,u,c)===!1)return this}}return this}swapRow(s,e){const n=this._matrix[s],r=this._matrix[e];this._matrix[s]=r,this._matrix[e]=n}getRow(s){return this._matrix[s]}getRowOrCreate(s){let e=this.getRow(s);return e==null&&(e={},this._matrix[s]=e),e}reset(){this._setOriginValue({})}hasValue(){const s=this._matrix,e=Object.keys(s);if(e.length===0)return!1;for(const n of e){const r=Number(n),i=s[r];if(Object.keys(i).length>0)return!0}return!1}getValue(s,e){var n,r;return(r=(n=this._matrix)==null?void 0:n[s])==null?void 0:r[e]}setValue(s,e,n){const r=this.getRowOrCreate(s);r[e]=n}deleteValue(s,e){var n,r;(r=(n=this._matrix)==null?void 0:n[s])==null||delete r[e]}realDeleteValue(s,e){var n,r,i;if((r=(n=this._matrix)==null?void 0:n[s])==null||delete r[e],this.getRow(s)){const o=this.getRow(s);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[s])}}setRow(s,e){this._matrix[s]=e}moveRows(s,e,n){ie(s,e,n,this._matrix)}moveColumns(s,e,n){this.forEach((r,i)=>{ie(s,e,n,i)})}insertRows(s,e){for(let n=s;n<s+e;n++)ne(n,{},this._matrix)}insertColumns(s,e){for(let n=s;n<s+e;n++)this.forEach((r,i)=>{ne(n,void 0,i)})}removeRows(s,e){re(s,e,this._matrix)}removeColumns(s,e){this.forEach((n,r)=>{re(s,e,r)})}getFragment(s,e,n,r){const i=new G;let o=0;for(let a=s;a<=e;a++){const l={};let u=0;for(let c=n;c<=r;c++){const h=this.getValue(a,c);l[u]=h,u++}i.setRow(o,l),o++}return i}getSlice(s,e,n,r){const i=new G;for(let o=s;o<=e;o++)for(let a=n;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,R.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return y(this._matrix)}getRange(){const n=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=y(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:n,endColumn:r}}toNativeArray(){const s=new Array;return this.forValue((e,n,r)=>{s.push(r)}),s}toArray(){const s=[];return this.forRow((e,n)=>{s[e]==null&&(s[e]=[]),n.forEach(r=>{s[e][r]=this.getValue(e,r)})}),s}toFullArray(){const s=this.getRange(),{endColumn:e,endRow:n}=s,r=[];for(let i=0;i<=n;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 s=JSON.stringify(this._matrix);return JSON.parse(s)}getData(){const s=JSON.stringify(this._matrix);return JSON.parse(s)}getArrayData(){let s=0,e=0,n=!1,r=!1;const i=new G;return this.forEach((o,a)=>{n||(n=!0,s=o),Object.keys(a).forEach(l=>{const u=Number(l);r?u<e&&(e=u):(r=!0,e=u);const c=this.getValue(o,u);i.setValue(o-s,u-e,c)})}),i.getData()}getDataRange(){let s=0,e=0,n=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,s=a),l==null)return;const u=y(l)-1;u>n&&(n=u),Object.keys(l).forEach(c=>{const h=Number(c);o?h<e&&(e=h):(o=!0,e=h)}),a>r&&(r=a)}),{startRow:s,startColumn:e,endRow:r,endColumn:n}}getDiscreteRanges(){const s=[];return this.forEach((e,n)=>{Object.keys(n).forEach(r=>{const i=Number(r);let o=!1;for(const a of s)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||s.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),s}merge(s){this.forValue((e,n)=>{const r=s.getValue(e,n);r!=null&&this.setValue(e,n,r)})}_setOriginValue(s={}){this._matrix=s}}var Re=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(Re||{});class ys{constructor(){d(this,"status","init")}}const di=t=>t.some(s=>s.status==="init")?"init":t.some(s=>s.status==="fetching")?"fetching":"done",z=class z{static clone(s){return s.rangeType!==void 0?{startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType}:{startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn}}static equals(s,e){return s==null||e==null?!1:s.endRow===e.endRow&&s.endColumn===e.endColumn&&s.startRow===e.startRow&&s.startColumn===e.startColumn&&(s.rangeType===e.rangeType||s.rangeType===void 0&&e.rangeType===x.NORMAL||e.rangeType===void 0&&s.rangeType===x.NORMAL)}static intersects(s,e){const n=s.startRow,r=s.endRow,i=s.startColumn,o=s.endColumn,a=e.startRow,l=e.endRow,u=e.startColumn,c=e.endColumn,h=Math.abs(i+o-u-c),_=Math.abs(i-o)+Math.abs(u-c),f=Math.abs(n+r-a-l),E=Math.abs(n-r)+Math.abs(a-l);return h<=_&&f<=E}static getIntersects(s,e){const n=s.startRow,r=s.endRow,i=s.startColumn,o=s.endColumn,a=e.startRow,l=e.endRow,u=e.startColumn,c=e.endColumn;let h,_,f,E;if(a<=r)a>=n?_=a:_=n;else return null;if(l>=n)l>=r?E=r:E=l;else return null;if(u<=o)u>i?h=u:h=i;else return null;if(c>=i)c>=o?f=o:f=c;else return null;return{startRow:_,endRow:E,startColumn:h,endColumn:f,rangeType:x.NORMAL}}static contains(s,e){return s.startRow<=e.startRow&&s.endRow>=e.endRow&&s.startColumn<=e.startColumn&&s.endColumn>=e.endColumn}static realContain(s,e){return z.contains(s,e)&&(s.startRow<e.startRow||s.endRow>e.endRow||s.startColumn<e.startColumn||s.endColumn>e.endColumn)}static union(...s){return s.reduce((e,n)=>({startRow:Math.min(e.startRow,n.startRow),startColumn:Math.min(e.startColumn,n.startColumn),endRow:Math.max(e.endRow,n.endRow),endColumn:Math.max(e.endColumn,n.endColumn),rangeType:x.NORMAL}),s[0])}static subtract(s,e){if(e.startRow>s.endRow||e.endRow<s.startRow||e.startColumn>s.endColumn||e.endColumn<s.startColumn)return[s];const n=[];e.startRow>=s.startRow&&n.push({startRow:s.startRow,startColumn:s.startColumn,endRow:e.startRow-1,endColumn:s.endColumn}),e.endRow<=s.endRow&&n.push({startRow:e.endRow+1,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn});const r=Math.max(s.startRow,e.startRow),i=Math.min(s.endRow,e.endRow);return e.startColumn>=s.startColumn&&n.push({startRow:r,startColumn:s.startColumn,endRow:i,endColumn:e.startColumn-1}),e.endColumn<=s.endColumn&&n.push({startRow:r,startColumn:e.endColumn+1,endRow:i,endColumn:s.endColumn}),n.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}};d(z,"getRelativeRange",(s,e)=>({startRow:s.startRow-e.startRow,endRow:s.endRow-s.startRow,startColumn:s.startColumn-e.startColumn,endColumn:s.endColumn-s.startColumn})),d(z,"getPositionRange",(s,e,n)=>({...n||{},startRow:n&&[w.ROW,w.ALL].includes(n.startAbsoluteRefType||0)?n.startRow:s.startRow+e.startRow,endRow:n&&[w.ROW,w.ALL].includes(n.endAbsoluteRefType||0)?n.endRow:s.endRow+s.startRow+e.startRow,startColumn:n&&[w.COLUMN,w.ALL].includes(n.startAbsoluteRefType||0)?n.startColumn:s.startColumn+e.startColumn,endColumn:n&&[w.COLUMN,w.ALL].includes(n.endAbsoluteRefType||0)?n.endColumn:s.endColumn+s.startColumn+e.startColumn})),d(z,"moveHorizontal",(s,e=0,n=0)=>({...s,startColumn:s.startColumn+e,endColumn:s.endColumn+e+n})),d(z,"moveVertical",(s,e=0,n=0)=>({...s,startRow:s.startRow+e,endRow:s.endRow+e+n})),d(z,"moveOffset",(s,e,n)=>({...s,startRow:s.startRow+n,endRow:s.endRow+n,startColumn:s.startColumn+e,endColumn:s.endColumn+e}));let X=z;class _i{constructor(s,e){d(this,"_values",[]);d(this,"_keys",[]);d(this,"_keyMaps",new Map);this._values=s,this._keys=e,s.forEach(n=>{this._initKeyMap(n)})}_initKeyMap(s){this._keys.forEach(e=>{const n=s[e],r=this._keyMaps.get(e)||new Map;r.set(n,s),this._keyMaps.set(e,r)})}getValue(s,e){const n=e||this._keys;for(let r=0;r<n.length;r++){const i=this._keyMaps.get(n[r]);if(i!=null&&i.has(s))return i.get(s)}return null}hasValue(s){for(let e=0;e<this._keys.length;e++){const n=this._keyMaps.get(this._keys[e]);if(n!=null&&n.has(s))return!0}return!1}addValue(s){this._values.push(s),this._initKeyMap(s)}setValue(s,e,n){const r=this.getValue(s);r&&Object.keys(r).includes(e)&&(r[e]=n)}deleteValue(s){const e=this.getValue(s);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const n=this._values.findIndex(r=>r===e);this._values.splice(n,1)}}getValues(){return this._values}getKeyMap(s){var e;return[...((e=this._keyMaps.get(s))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function oe(t,s,e,n){return{forEach(r){for(let i=t;i<=s;i++)for(let o=e;o<=n;o++)r(i,o)}}}function fi(t){if(t==null||t.length===0)return Number.NaN;const s=t.toLowerCase().split(""),e=s.length,n=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=n(s[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const Ft=65,Xs=90,Ei=97;function gi(t){const s=Xs-Ft+1;let e="";for(;t>=0;)e=String.fromCharCode(t%s+Ft)+e,t=Math.floor(t/s)-1;return e}function qs(t,s){let e="";for(;s>0;)e+=t,s--;return e}function Ri(t,s=!1){const e=Xs-Ft+1;let n=Ei;s&&(n=Ft);const r=String.fromCharCode(t%e+n),i=Math.floor(t/e)+1;return qs(r,i)}function mi(t,s){return t.zIndex>s.zIndex?1:t.zIndex===s.zIndex?0:-1}function Ci(t,s){return t.zIndex>s.zIndex?-1:t.zIndex===s.zIndex?0:1}function ot(t="index",s=1){return(e,n)=>e[t]>n[t]?s:e[t]===n[t]?0:-s}function Oi(t,s){let e;return function(...n){const r=this,i=function(){e=null,t.apply(r,n)};clearTimeout(e),e=setTimeout(i,s)}}function bt(t,s,e){const{dataStream:n,textRuns:r=[]}=t;let i=s;const o=[];for(const a of r){const{st:l,ed:u}=a;R.hasIntersectionBetweenTwoRanges(s,e,l,u)&&(l>i?(o.push(n.slice(i,l)),o.push(ae(n,{...a,ed:Math.min(u,e)}))):o.push(ae(n,{...a,st:i,ed:Math.min(u,e)}))),i=Math.max(s,Math.min(u,e))}return i!==e&&o.push(n.slice(i,e)),o.join("")}function Ii(t,s=!0){var e;if(s&&((e=t.paragraphs)!=null&&e.length)){const{dataStream:n,paragraphs:r=[]}=t;let i="",o=-1;for(const a of r){const{startIndex:l,paragraphStyle:u={}}=a,{spaceAbove:c,spaceBelow:h,lineSpacing:_}=u,f=[];c!=null&&(typeof c=="number"?f.push(`margin-top: ${c}px`):f.push(`margin-top: ${c.v}px`)),h!=null&&(typeof h=="number"?f.push(`margin-bottom: ${h}px`):f.push(`margin-bottom: ${h.v}px`)),_!=null&&f.push(`line-height: ${_}`),l>o+1?i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${bt(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=l}return o!==n.length&&(i+=bt(t,o,n.length)),i}else return bt(t,0,t.dataStream.length)}function ae(t,s){const{st:e,ed:n,ts:r={}}=s,{ff:i,fs:o,it:a,bl:l,ul:u,st:c,ol:h,bg:_,cl:f,va:E}=r;let g=t.slice(e,n);const m=[];return a===C.TRUE&&(g=`<i>${g}</i>`),E===it.SUPERSCRIPT?g=`<sup>${g}</sup>`:E===it.SUBSCRIPT&&(g=`<sub>${g}</sub>`),(u==null?void 0:u.s)===C.TRUE&&(g=`<u>${g}</u>`),(c==null?void 0:c.s)===C.TRUE&&(g=`<s>${g}</s>`),l===C.TRUE&&(g=`<strong>${g}</strong>`),i&&m.push(`font-family: ${i}`),f&&m.push(`color: ${f.rgb}`),o&&m.push(`font-size: ${o}pt`),h&&m.push("text-decoration: overline"),_&&m.push(`background: ${_.rgb}`),m.length?`<span style="${m.join("; ")};">${g}</span>`:g}const lt={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Ai={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ni={startRow:0,startColumn:0,endRow:0,endColumn:0},Si={row:0,column:0},wt={ff:"Arial",fs:11,it:C.FALSE,bl:C.FALSE,ul:{s:C.FALSE},st:{s:C.FALSE},ol:{s:C.FALSE},tr:{a:0,v:C.FALSE},td:_t.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Z.UNSPECIFIED,vt:rt.UNSPECIFIED,tb:ft.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Js={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var Zs=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(Zs||{});function Nt(t,s){const{textRuns:e=[]}=s;let n=0;for(const i of e){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return C.FALSE;switch(t){case"bl":case"it":{if(o[t]===C.FALSE)return C.FALSE;break}case"ul":case"st":{if(o[t].s===C.FALSE)return C.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}n+=l-a}return s.dataStream.indexOf(`\r
|
|
4
|
-
`)===n?C.TRUE:C.FALSE}class et{constructor(s,e,n){d(this,"_range");d(this,"_worksheet");this._deps=n,this._range=e,this._worksheet=s}static foreach(s,e){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=s;for(let a=n;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:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=[];for(let o=s;o<=e;o++){const a=[];for(let l=n;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new G;for(let a=s;a<=e;a++)for(let l=n;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new G;for(let a=s;a<=e;a++)for(let l=n;l<=r;l++)o.setValue(a-s,l-n,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range;let i,o;return n<r?(i=R.numToWord(n+1)+(s+1),o=R.numToWord(r+1)+(e+1)):(i=R.numToWord(r+1)+(e+1),o=R.numToWord(n+1)+(s+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>{var i;const r=s.getStyleByCell(n);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||wt.bg.rgb}))}getCell(s,e){const{startRow:n,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:n+s,endRow:n+s,startColumn:i+e,endColumn:i+e};return new et(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(s={}){return this.getObjectValues(s)[0][0]}getObjectValues(s={}){var a;const{startRow:e,endRow:n,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,n,r,i).getData();if(s.isIncludeStyle){const l=this._deps.getStyles();for(let u=0;u<=n-e;u++)for(let c=0;c<=i-r;c++){if(o==null||((a=o==null?void 0:o[u])==null?void 0:a[c])==null)continue;const h=o[u][c].s;h&&(o[u][c].s=l.get(h))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>{var i;const r=s.getStyleByCell(n);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||wt.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Nt("ul",s.body)===C.TRUE?{s:C.TRUE}:{s:C.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Nt("st",s.body)===C.TRUE?{s:C.TRUE}:{s:C.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?s.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...s.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,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Nt("it",s.body)===C.TRUE?Mt.ITALIC:Mt.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Nt("bl",s.body)===C.TRUE?Pt.BOLD:Pt.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:s,_worksheet:e}=this,{startRow:n,endRow:r}=s;let i=0;for(let o=0;o<=r-n;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:s,endColumn:e}=this._range;return e-s+1}getNumRows(){const{startRow:s,endRow:e}=this._range;return e-s+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(s=>s.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 s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>s.getStyleByCell(n)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:s,_worksheet:e}=this,{startColumn:n,endColumn:r}=s;let i=0;for(let o=0;o<=r-n;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(s){et.foreach(this._range,s)}_getStyles(s){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[s]||wt[s]}))}}function Li(t,s){if(t.length===0||t[0].length===0)return null;const e=new Array(t[0].length).fill(0);let n=0,r=null;for(let i=0;i<t.length;i++){for(let a=0;a<t[0].length;a++)e[a]=s(t[i][a])?e[a]+1:0;const o=Ti(e);o.area>n&&(n=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function Ti(t){const s=[];let e=0,n={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(s.length===0||t[r]>=t[s[s.length-1]])s.push(r++);else{const i=t[s.pop()],o=s.length===0?r:r-s[s.length-1]-1;i*o>e&&(e=i*o,n={area:e,height:i,start:s.length===0?0:s[s.length-1]+1,end:r-1})}for(;s.length>0;){const i=t[s.pop()],o=s.length===0?r:r-s[s.length-1]-1;i*o>e&&(e=i*o,n={area:e,height:i,start:s.length===0?0:s[s.length-1]+1,end:r-1})}return n}function bi(t,s){et.foreach(s,(e,n)=>{t[e][n]=void 0})}function wi(t,s){const e=t.toFullArray(),n=[];for(;;){const r=Li(e,s);if(!r)break;n.push(r),bi(e,r)}return n}function vi(t,s,e,n=!1){let r={...t};const i=r.startAbsoluteRefType||w.NONE,o=r.endAbsoluteRefType||w.NONE;return!n&&i===w.ALL&&o===w.ALL?r:n||i===w.NONE&&o===w.NONE?X.moveOffset(r,s,e):(i===w.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+s}:i===w.COLUMN?r={...r,startRow:r.startRow+e}:i===w.ROW&&(r={...r,startColumn:r.startColumn+s}),o===w.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+s}:o===w.COLUMN?r={...r,endRow:r.endRow+e}:o===w.ROW&&(r={...r,endColumn:r.endColumn+s}),r)}async function Qs(t){for(const[s,e]of t.entries())try{if(!await e())return{index:s,result:!1}}catch(n){return{index:s,result:!1,error:n}}return{result:!0,index:-1}}function tn(t){for(const[s,e]of t.entries())try{if(!e())return{index:s,result:!1}}catch(n){return{index:s,result:!1,error:n}}return{result:!0,index:-1}}const gt=A.createIdentifier("univer.context-service");class en extends p{constructor(){super(...arguments);d(this,"_contextChanged$",new N.Subject);d(this,"contextChanged$",this._contextChanged$.asObservable());d(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var n;return(n=this._contextMap.get(e))!=null?n:!1}setContextValue(e,n){this._contextMap.set(e,n),this._contextChanged$.next({[e]:n})}subscribeContextValue$(e){return new N.Observable(n=>{const r=this._contextChanged$.pipe(N.filter(i=>typeof i[e]<"u")).subscribe(i=>n.next(i[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var sn=(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))(sn||{});const J=A.createIdentifier("univer.log");class nn extends p{constructor(){super(...arguments);d(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,...n){const r=n[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...n.slice(1)):e(...n)}}var Ui=Object.defineProperty,Di=Object.getOwnPropertyDescriptor,pi=(t,s,e,n)=>{for(var r=n>1?void 0:n?Di(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Ui(s,e,r),r},Be=(t,s)=>(e,n)=>s(e,n,t),Rt=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(Rt||{});const mt=A.createIdentifier("anywhere.command-service");class Mi{constructor(){d(this,"_commands",new Map)}registerCommand(s){if(this._commands.has(s.id))throw new Error(`[CommandRegistry]: command "${s.id}" has been registered before.`);return this._commands.set(s.id,s),v(()=>{var e;this._commands.delete(s.id),(e=s.onDispose)==null||e.call(s)})}hasCommand(s){return this._commands.has(s)}getCommand(s){return this._commands.has(s)?[this._commands.get(s)]:null}}const rn={id:"nil",type:0,handler:()=>!0};exports.CommandService=class{constructor(s,e){d(this,"_commandRegistry");d(this,"_beforeCommandExecutionListeners",[]);d(this,"_commandExecutedListeners",[]);d(this,"_multiCommandDisposables",new Map);d(this,"_commandExecutingLevel",0);d(this,"_commandExecutionStack",[]);this._injector=s,this._logService=e,this._commandRegistry=new Mi,this._registerCommand(rn)}hasCommand(s){return this._commandRegistry.hasCommand(s)}registerCommand(s){return this._registerCommand(s)}registerMultipleCommand(s){return this._registerMultiCommand(s)}beforeCommandExecuted(s){if(this._beforeCommandExecutionListeners.indexOf(s)===-1)return this._beforeCommandExecutionListeners.push(s),v(()=>{const e=this._beforeCommandExecutionListeners.indexOf(s);this._beforeCommandExecutionListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(s){if(this._commandExecutedListeners.indexOf(s)===-1)return this._commandExecutedListeners.push(s),v(()=>{const e=this._commandExecutedListeners.indexOf(s);this._commandExecutedListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(s,e,n){const r=this._commandRegistry.getCommand(s);if(r){const[i]=r,o={id:i.id,type:i.type,params:e},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(u=>u(o,n));const l=await this._execute(i,e,n);return this._commandExecutedListeners.forEach(u=>u(o,n)),a.dispose(),l}throw new Error(`[CommandService]: command "${s}" is not registered.`)}syncExecuteCommand(s,e,n){var i;const r=this._commandRegistry.getCommand(s);if(r){const[o]=r,a={id:o.id,type:o.type,params:e};if(o.type===2){const c=ii(this._commandExecutionStack,h=>h.type===0);c&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=c.id)}const l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(c=>c(a,n));const u=this._syncExecute(o,e,n);return this._commandExecutedListeners.forEach(c=>c(a,n)),l.dispose(),u}throw new Error(`[CommandService]: command "${s}" is not registered.`)}_pushCommandExecutionStack(s){return this._commandExecutionStack.push(s),v(()=>jt(this._commandExecutionStack,s))}_registerCommand(s){return this._commandRegistry.registerCommand(s)}_registerMultiCommand(s){const e=this._commandRegistry.getCommand(s.id);let n;if(e){if(e[0].multi!==!0)throw new Error("Command has registered as a single command.");n=e[0]}else{const i=new ge;n=new Pi(s.id),i.add(this._commandRegistry.registerCommand(n)),i.add(v(()=>{this._multiCommandDisposables.delete(s.id)})),this._multiCommandDisposables.set(s.id,i)}const r=n.registerImplementation(s);return v(()=>{var i;r.dispose(),n.hasImplementations()||(i=this._multiCommandDisposables.get(s.id))==null||i.dispose()})}async _execute(s,e,n){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${s.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(s.handler,e,n),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(s,e,n){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${s.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(s.handler,e,n),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}};exports.CommandService=pi([Be(0,A.Inject(A.Injector)),Be(1,J)],exports.CommandService);class Pi{constructor(s){d(this,"name");d(this,"multi",!0);d(this,"type",0);d(this,"priority",0);d(this,"_implementations",[]);d(this,"handler",async(s,e)=>{if(!this._implementations.length)return!1;const n=s.get(J),r=s.get(gt),i=s.get(A.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(n.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=s,this.name=s}registerImplementation(s){const e={command:s};return this._implementations.push(e),this._implementations.sort((n,r)=>r.command.priority-n.command.priority),v(()=>{var r;const n=this._implementations.indexOf(e);this._implementations.splice(n,1),(r=s.onDispose)==null||r.call(s)})}hasImplementations(){return this._implementations.length>0}}function me(t,s,e){const n=t.map(r=>()=>s.syncExecuteCommand(r.id,r.params,e));return tn(n)}function xi(t,s,e){const n=t.map(r=>()=>s.executeCommand(r.id,r.params,e));return Qs(n)}function on(t){return new N.Observable(s=>{const e=t((...n)=>s.next(n));return()=>e==null?void 0:e.dispose()})}const Hi=t=>new Promise(s=>{N.merge(on(t.onCommandExecuted).pipe(Lt.filter(([e])=>e.type===Rt.MUTATION)),N.timer(300)).pipe(Lt.debounceTime(16),Lt.first()).subscribe(()=>{s()})});var B=(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.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",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.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.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(B||{});function an(t){return!!(t&&t.code&&t.code!==B.OK&&t.code!=="OK")}var O=(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))(O||{});class Kt extends p{}class Ce{constructor(){d(this,"_data",[])}static create(){return new Ce}add(s){this._data.indexOf(s)>-1||this._data.push(s)}delete(s){const e=this._data.indexOf(s);this._data.splice(e,1)}getData(){return this._data}}class Oe{constructor(){d(this,"_data",new Map)}static create(){return new Oe}add(s,e){this._data.has(s)||this._data.set(s,e)}delete(s){this._data.delete(s)}getData(){return this._data}}class ln{constructor(){d(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(s){this.cursor+=s}moveCursorTo(s){this.cursor=s}}var un=(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))(un||{}),Ie=(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))(Ie||{});function Ae(t){const s=[];for(const e of t){const{st:n,ed:r,ts:i}=e;if(e.sId===void 0&&delete e.sId,n===r||R.isEmptyObject(i)&&e.sId==null)continue;if(s.length===0){s.push(e);continue}const o=s.pop();Fs(e,o)&&R.hasIntersectionBetweenTwoRanges(o.st,o.ed,e.st,e.ed)?s.push({...e,st:o.st,ed:r}):s.push(o,e)}return s}function cn(t,s,e,n){var u;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(u=s.textRuns)!=null?u:[];if(l.length)for(let c=0,h=l.length;c<h;c++){const _=l[c];_.st+=n,_.ed+=n}for(let c=0;c<o;c++){const h=r[c],{st:_,ed:f}=h;if(f<n)i.push(h);else if(n>=_&&n<=f)if(a)h.st+=e,h.ed+=e,i.push(h);else{a=!0,h.ed+=e;const E=[];if(l.length){const g={...h,st:_,ed:l[0].st};E.push(g),E.push(...l);const m=l[l.length-1],S={...h,st:m.ed,ed:f+e};E.push(S)}else E.push(h);i.push(...E)}else h.st+=e,h.ed+=e,a||(a=!0,i.push(...l)),i.push(h)}a||(a=!0,i.push(...l)),t.textRuns=Ae(i)}function Ne(t,s,e,n){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=s,a=[];let l=-1;for(let c=0,h=r.length;c<h;c++){const _=r[c],{startIndex:f}=_;f>=n&&(_.startIndex+=e),l===-1&&f>=n&&(l=c),a.push(_.startIndex)}let u=-1;if(i){for(let c=0,h=i.length;c<h;c++){const _=i[c];_.startIndex+=n;const f=_.startIndex;u=a.indexOf(f)}if(o===Ie.PARAGRAPH&&i.length===1){const c=r[l],h=i[0],_=c.paragraphStyle,f=c.bullet;c.paragraphStyle=h.paragraphStyle,c.bullet=h.bullet,h.paragraphStyle=_,h.bullet=f}u!==-1&&r.splice(u,1),r.push(...i),r.sort(ot("startIndex"))}}function Fi(t,s,e,n){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:u}=l;u>=n&&(l.startIndex+=e)}const i=s.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(ot("startIndex"))}}function hn(t,s,e,n){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:u}=l;u>=n&&(l.startIndex+=e)}const i=s.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(ot("startIndex"))}}function Se(t,s,e,n){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:u,endIndex:c}=l;u>n?(l.startIndex+=e,l.endIndex+=e):c>=n-1&&(l.endIndex+=e)}const i=s.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(ot("startIndex"))}}function Wi(t,s,e,n){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:u,endIndex:c}=l;u>n?(l.startIndex+=e,l.endIndex+=e):c>=n-1&&(l.endIndex+=e)}const i=s.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(ot("startIndex"))}}function dn(t,s,e){const{textRuns:n}=t,r=e,i=e+s,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{st:h,ed:_}=c;if(r<=h&&i>=_){o.push({...c,st:h-r,ed:_-r});continue}else h<=r&&_>=i?(o.push({...c,st:r-r,ed:i-r}),c.ed-=s):r>=h&&r<_?(o.push({...c,st:r-r,ed:_-r}),c.ed=r):i>h&&i<=_?(o.push({...c,st:h-r,ed:i-r}),c.st=i-s,c.ed-=s):h>=i&&(c.st-=s,c.ed-=s);a.push(c)}t.textRuns=a}return o.length===0&&o.push({st:0,ed:s,ts:{}}),o}function _n(t,s,e){const{paragraphs:n}=t,r=e,i=e+s,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{startIndex:h}=c;if(h>=r&&h<i){o.push({...c,startIndex:h-e});continue}else h>=i&&(c.startIndex-=s);a.push(c)}t.paragraphs=a}return o}function fn(t,s,e){const{sectionBreaks:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{startIndex:h}=c;if(h>=r&&h<=i){o.push({...c,startIndex:h-e});continue}else h>i&&(c.startIndex-=s);a.push(c)}t.sectionBreaks=a}return o}function En(t,s,e){const{customBlocks:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{startIndex:h}=c;if(h>=r&&h<=i){o.push({...c,startIndex:h-e});continue}else h>i&&(c.startIndex-=s);a.push(c)}t.customBlocks=a}return o}function gn(t,s,e){const{tables:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{startIndex:h,endIndex:_}=c;if(r<=h&&i>=_){o.push({...c,startIndex:h-e,endIndex:_-e});continue}else if(h<=r&&_>=i){const f=Ee(h,_,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<h&&(c.startIndex-=s,c.endIndex-=s);a.push(c)}t.tables=a}return o}function Rn(t,s,e){const{customRanges:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let l=0,u=n.length;l<u;l++){const c=n[l],{startIndex:h,endIndex:_}=c;if(r<=h&&i>=_){o.push({...c,startIndex:h-e,endIndex:_-e});continue}else if(h<=r&&_>=i){const f=Ee(h,_,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<h&&(c.startIndex-=s,c.endIndex-=s);a.push(c)}t.customRanges=a}return o}function Bi(t,s,e){const{dataStream:n}=t,r=e,i=e+s,o=dn(t,s,e),a=_n(t,s,e),l=fn(t,s,e),u=En(t,s,e),c=gn(t,s,e),h=Rn(t,s,e);let _="";return n&&(t.dataStream=ks(n,r,i),_=n.slice(r,i)),{dataStream:_,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:u,tables:c,customRanges:h}}function ki(t,s,e,n){t.dataStream=Bs(t.dataStream,n,s.dataStream),cn(t,s,e,n),Ne(t,s,e,n),Fi(t,s,e,n),hn(t,s,e,n),Se(t,s,e,n),Wi(t,s,e,n)}var Wt=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Wt||{});const Gi={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:K.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:K.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:K.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:K.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:ut.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:K.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ut.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:K.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ut.DECIMAL,hanging:21,indentStart:63}]}};function $i(t,s,e,n,r){const i=Vi(t,s,e,n,r),o=ji(t,s,e,n,r),a=Ki(t,s,e,n,r),l=Yi(t,s,e,n,r),u=zi(t,s,e,n,r),c=yi(t,s,e,n,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:u,customRanges:c}}function Vi(t,s,e,n,r){const{textRuns:i}=t,{textRuns:o}=s;if(i==null||o==null)return;const a=dn(t,e,n);if(r!==P.REPLACE){const l=mn(o,a,r);s.textRuns=l}return cn(t,s,e,n),a}function mn(t,s,e){if(s.length===0)return t;t=R.deepClone(t),s=R.deepClone(s);const n=[],r=t.length,i=s.length;let o=0,a=0,l=null;function u(){return l?(n.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:f,ed:E,ts:g}=t[o],{st:m,ed:S,ts:U,sId:M}=s[a];let V;e===P.COVER?V={...U,...g}:V={...g,...U},E<m?(u()||n.push(t[o]),o++):S<f?(u()||n.push(s[a]),a++):(n.push({st:Math.min(f,m),ed:Math.max(f,m),ts:f<m?{...g}:{...U},sId:f<m?void 0:M}),n.push({st:Math.max(f,m),ed:Math.min(E,S),ts:V,sId:M}),E<S?(o++,s[a].st=E):(a++,t[o].st=S),l={st:Math.min(E,S),ed:Math.max(E,S),ts:E<S?{...U}:{...g},sId:E<S?M:void 0})}u();const c=n[n.length-1],h=t[r-1],_=s[i-1];return c.ed!==Math.max(h.ed,_.ed)&&(h.ed>_.ed?n.push(h):n.push(_)),Ae(n)}function ji(t,s,e,n,r){const{paragraphs:i}=t,{paragraphs:o}=s;if(i==null||o==null)return;const a=_n(t,e,n);if(r!==P.REPLACE){const l=[];for(const u of o){const{startIndex:c,paragraphStyle:h,bullet:_}=u;let f=[];for(const E of a){const{startIndex:g,paragraphStyle:m,bullet:S}=E;let U,M;if(r===P.COVER?(U={...m,...h},M={listId:"",listType:Wt.BULLET_LIST,nestingLevel:0,textStyle:{},...S,..._}):(U={...h,...m},M={listId:"",listType:Wt.BULLET_LIST,nestingLevel:0,textStyle:{},..._,...S}),c===g){f.push({startIndex:c,paragraphStyle:U,bullet:M});break}}l.push(...f),f=[]}s.paragraphs=l}return Ne(t,s,e,n),a}function Ki(t,s,e,n,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=s;if(i==null||o==null)return;const a=fn(t,e,n);if(r!==P.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const _ of a){const{startIndex:f}=_;if(c===f){r===P.COVER?h.push({..._,...u}):h.push({...u,..._});break}}l.push(...h),h=[]}s.sectionBreaks=l}return Ne(t,s,e,n),a}function Yi(t,s,e,n,r){const{customBlocks:i}=t,{customBlocks:o}=s;if(i==null||o==null)return;const a=En(t,e,n);if(r!==P.REPLACE){const l=[];for(const u of o){const{startIndex:c}=u;let h=[];for(const _ of a){const{startIndex:f}=_;if(c===f){r===P.COVER?h.push({..._,...u}):h.push({...u,..._});break}}l.push(...h),h=[]}s.customBlocks=l}return hn(t,s,e,n),a}function zi(t,s,e,n,r){const{tables:i}=t,{tables:o}=s;if(i==null||o==null)return;const a=gn(t,e,n);if(r!==P.REPLACE){const l=[];for(const u of o){const{startIndex:c,endIndex:h}=u;let _=[];for(const f of a){const{startIndex:E,endIndex:g}=f;if(E>=c&&g<=h){r===P.COVER?_.push({...f,...u}):_.push({...u,...f});break}}l.push(..._),_=[]}s.tables=l}return Se(t,s,e,n),a}function yi(t,s,e,n,r){const{customRanges:i}=t,{tables:o}=s;if(i==null||o==null)return;const a=Rn(t,e,n);if(r!==P.REPLACE){const l=[];for(const u of o){const{startIndex:c,endIndex:h}=u;let _=[];for(const f of a){const{startIndex:E,endIndex:g}=f;if(E>=c&&g<=h){r===P.COVER?_.push({...f,...u}):_.push({...u,...f});break}}l.push(..._),_=[]}s.customRanges=l}return Se(t,s,e,n),a}var I=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(I||{});function Le(t,s,e){const{dataStream:n,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:n.slice(s,e)},a=[];for(const u of r){const c=R.deepClone(u),{st:h,ed:_}=c;R.hasIntersectionBetweenTwoRanges(h,_,s,e)&&(s>=h&&s<=_?a.push({...c,st:s,ed:Math.min(e,_)}):e>=h&&e<=_?a.push({...c,st:Math.max(s,h),ed:e}):a.push(c))}a.length&&(o.textRuns=a.map(u=>{const{st:c,ed:h}=u;return{...u,st:c-s,ed:h-s}}));const l=[];for(const u of i){const{startIndex:c}=u;c>=s&&c<=e&&l.push(R.deepClone(u))}return l.length&&(o.paragraphs=l.map(u=>({...u,startIndex:u.startIndex-s}))),o}function le(t,s,e=P.COVER){if(s.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const n={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=s,l=mn(o,r,e);l.length&&(n.textRuns=l);const u=[];let c=0,h=0;for(;c<i.length&&h<a.length;){const _=i[c],f=a[h],{startIndex:E}=_,{startIndex:g}=f;E===g?(u.push(R.deepMerge(_,f)),c++,h++):E<g?(u.push(R.deepClone(_)),c++):(u.push(R.deepClone(f)),h++)}return c<i.length&&u.push(...i.slice(c)),h<a.length&&u.push(...a.slice(h)),u.length&&(n.paragraphs=u),n}function Xi(t){const{body:s}=t;if(s==null)return!0;const{textRuns:e=[],paragraphs:n=[]}=s;return e.length===0&&n.length===0}function qi(t=R.generateRandomId(6),s=nt.EN_US,e=""){return{id:t,locale:s,title:e,body:{dataStream:`\r
|
|
6
|
-
`,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:5,lineSpacing:1,spaceBelow:0}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}const Te={id:"default_doc",documentStyle:{}};class Ji extends Kt{constructor(e){super();d(this,"type",O.UNIVER_DOC);d(this,"snapshot");this.snapshot={...Te,...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 body(){return this.snapshot.body}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}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:n}=this.snapshot;n.renderConfig==null?n.renderConfig=e:n.renderConfig={...n.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:n,l:r,b:i,r:o}=e,{documentStyle:a}=this.snapshot;n!=null&&(a.marginTop=n),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(e,n){const{documentStyle:r}=this.snapshot;if(!r.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,n=n!=null?n:Number.POSITIVE_INFINITY,r.pageSize={width:e,height:n};return}e!==void 0&&(r.pageSize.width=e),n!==void 0&&(r.pageSize.height=n)}updateDrawing(e,n){const{drawings:r}=this,{width:i,height:o,left:a,top:l}=n,u=r==null?void 0:r[e];if(!u)return;const c=u.objectTransform;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 st extends Ji{constructor(e){var r;super(R.isEmptyObject(e)?qi():e);d(this,"_unitId");d(this,"headerModelMap",new Map);d(this,"footerModelMap",new Map);const n=6;this._unitId=(r=this.snapshot.id)!=null?r:R.generateRandomId(n),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()})}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={...Te,...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){const n=[],r=new ln;return r.reset(),e.forEach(i=>{if(i=R.deepClone(i),i.t===I.RETAIN){const{coverType:o,body:a,len:l,segmentId:u}=i;if(a!=null){const c=this._updateApply(a,l,r.cursor,o,u);n.push({...i,t:I.RETAIN,coverType:P.REPLACE,body:c})}else n.push({...i,t:I.RETAIN});r.moveCursor(l)}else if(i.t===I.INSERT){const{body:o,len:a,segmentId:l,line:u}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),n.push({t:I.DELETE,len:a,line:u,segmentId:l})}else if(i.t===I.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);n.push({...i,t:I.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),n}sliceBody(e,n){const r=this.getBody();if(r!=null)return Le(r,e,n)}_updateApply(e,n,r,i=P.COVER,o){if(e==null)throw new Error("updateBody is none");const a=this.snapshot,l=Tt(a,o);if(l==null)throw new Error("no body has changed");return $i(l,e,n,r,i)}_deleteApply(e,n,r){const i=this.snapshot,o=Tt(i,r);if(o==null)throw new Error("no body has changed");return e<=0?{dataStream:""}:Bi(o,e,n)}_insertApply(e,n,r,i){const o=this.snapshot,a=Tt(o,i);if(n!==0){if(a==null)throw new Error("no body has changed");ki(a,e,n,r)}}_initializeHeaderFooterModel(){const{headers:e,footers:n}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new st(i))}if(n)for(const r in n){const i=n[r];this.footerModelMap.set(r,new st(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const Cn=A.createIdentifier("univer.config-service");class On{constructor(){d(this,"_config",new Map)}getConfig(s){return this._config.get(s)}setConfig(s,e){this._config.set(s,e)}deleteConfig(s){this._config.delete(s)}}class In extends p{constructor(){super(...arguments);d(this,"_error$",new N.Subject);d(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}const Zi="__default_document_sub_component_id20231101__";class An{constructor(){d(this,"_managerInfo",new Map);d(this,"_remove$",new N.Subject);d(this,"remove$",this._remove$.asObservable());d(this,"_andOrUpdate$",new N.Subject);d(this,"andOrUpdate$",this._andOrUpdate$.asObservable());d(this,"_pluginUpdate$",new N.Subject);d(this,"pluginUpdate$",this._pluginUpdate$.asObservable())}getFloatObject(s){return this._getFloatingObject(s)}getFloatObjects(s){return this._getFloatingObjects(s)}dispose(){this._remove$.complete(),this._andOrUpdate$.complete(),this._pluginUpdate$.complete(),this._managerInfo.clear()}clear(s){const e=this._clearByParam(s);this._remove$.next(e)}addOrUpdate(s){const e=this._addByParam(s);this._andOrUpdate$.next(e)}batchAddOrUpdate(s){const e=[];s.forEach(n=>{e.push(...this._addByParam(n))}),this._andOrUpdate$.next(e)}remove(s){const e=this._removeByParam(s);this._remove$.next(e)}pluginUpdateRefresh(s){this._pluginUpdate$.next(s)}_getFloatingObjects(s){var r;if(s==null)return;const{unitId:e,subUnitId:n}=s;return(r=this._managerInfo.get(e))==null?void 0:r.get(n)}_getFloatingObject(s){var i,o;if(s==null)return;const{unitId:e,subUnitId:n,floatingObjectId:r}=s;return(o=(i=this._managerInfo.get(e))==null?void 0:i.get(n))==null?void 0:o.get(r)}_addByParam(s){const{unitId:e,subUnitId:n,floatingObject:r,floatingObjectId:i,behindText:o}=s;this._managerInfo.has(e)||this._managerInfo.set(e,new Map);const a=this._managerInfo.get(e);return a.has(n)||a.set(n,new Map),a.get(n).set(i,r),[{unitId:e,subUnitId:n,floatingObjectId:i,floatingObject:r,behindText:o}]}_clearByParam(s){const e=this._getFloatingObjects(s),{unitId:n,subUnitId:r}=s,i=[];return e==null||e.forEach((o,a)=>{i.push({unitId:n,subUnitId:r,floatingObjectId:a,floatingObject:o})}),e==null||e.clear(),i}_removeByParam(s){const e=this._getFloatingObjects(s),n=e==null?void 0:e.get(s.floatingObjectId);return n==null?[]:(e==null||e.delete(s.floatingObjectId),[{...s,floatingObject:n}])}}const Nn=A.createIdentifier("univer.floating-object.service");class Sn{constructor(s={}){d(this,"_styles");d(this,"_cacheMap",new zs(1e5));this._styles=s,this._generateCacheMap()}each(s){return Object.entries(this._styles).forEach(s),this}search(s,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const n=this._getExistingStyleId(s);return n||"-1"}get(s){return typeof s!="string"?s:(s=String(s),this._styles[s])}add(s,e){const n=R.generateRandomId(6);return this._styles[n]=s,this._cacheMap.set(e,n),n}setValue(s){if(s==null)return;const e=JSON.stringify(s),n=this.search(s,e);return n!=="-1"?n:this.add(s,e)}toJSON(){return this._styles}getStyleByCell(s){let e;s&&R.isObject(s.s)?e=s.s:e=(s==null?void 0:s.s)&&this.get(s.s);const n=s==null?void 0:s.interceptorStyle;return n?{...e,...n}:e}_generateCacheMap(){const{_styles:s,_cacheMap:e}=this;for(const n in s){const r=JSON.stringify(s[n]);e.set(r,n)}}_getExistingStyleId(s){const{_styles:e}=this;for(const n in e)if(R.diffValue(e[n],s))return n;return null}}class Qi{constructor(s,e){d(this,"_columnData",{});this._config=s,this._columnData=e}getColumnData(){return this._columnData}getColVisible(s){const{_columnData:e}=this,n=e[s];return n?n.hd!==C.TRUE:!0}getHiddenCols(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,n.push({rangeType:x.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:x.COLUMN}),n}getVisibleCols(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,n.push({rangeType:x.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:x.COLUMN}),n}getColumnDatas(s,e){const n={};let r=0;for(let i=s;i<s+e;i++){const o=this.getColumnOrCreate(i);n[r]=o,r++}return n}getSize(){return y(this._columnData)}getColumnWidth(s){const{_columnData:e}=this,n=this._config;let r=0;return r=(e[s]||{hd:C.FALSE,w:n.defaultColumnWidth}).w||n.defaultColumnWidth,r}getColumn(s){const e=this._columnData[s];if(e)return e}getColumnOrCreate(s){const{_columnData:e}=this,n=this._config,r=e[s];if(r)return r;const i={w:n.defaultColumnWidth,hd:C.FALSE};return this._columnData[s]=i,i}}class to{constructor(s,e,n){d(this,"_rowData");this._config=s,this._viewModel=e,this._rowData=n}getRowData(){return this._rowData}getRowDatas(s,e){const n={};let r=0;for(let i=s;i<s+e;i++){const o=this.getRowOrCreate(i);n[r]=o,r++}return n}getRowHeight(s,e=1){const{_rowData:n}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=n[o+s]||{hd:C.FALSE,h:r.defaultRowHeight},{ia:l,ah:u,h:c=r.defaultRowHeight}=a;i+=(l==null||l===C.TRUE)&&typeof u=="number"?u:c}return i}getRow(s){return this._rowData[s]}getRowOrCreate(s){const{_rowData:e}=this,n=e[s];if(n)return n;const r=this._config,i={hd:C.FALSE,h:r.defaultRowHeight};return e[s]=i,i}getHiddenRows(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getRowRawVisible(o);r&&a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:x.ROW})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:x.ROW}),n}getVisibleRows(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:x.ROW})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:x.ROW}),n}getRowRawVisible(s){const e=this.getRow(s);return e?e.hd!==C.TRUE:!0}getSize(){return y(this._rowData)}}const eo="DEFAULT_WORKSHEET_ROW_COUNT",Ln=1e3,so="DEFAULT_WORKSHEET_COLUMN_COUNT",Tn=20,no="DEFAULT_WORKSHEET_ROW_HEIGHT",bn=19,ro="DEFAULT_WORKSHEET_COLUMN_WIDTH",wn=73,io="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",vn=46,oo="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Un=20;function Dn(t){const s={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:C.FALSE,rowCount:Ln,columnCount:Tn,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:wn,defaultRowHeight:bn,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:C.TRUE,rowHeader:{width:vn,hidden:C.FALSE},columnHeader:{height:Un,hidden:C.FALSE},selections:["A1"],rightToLeft:C.FALSE};return Object.keys(s).forEach(e=>{const n=e;typeof t[n]>"u"&&(t[n]=s[n])}),t}class pn extends p{constructor(e){super();d(this,"_cellContentInterceptor",null);d(this,"_rowFilteredInterceptor",null);this.getRawCell=e}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,n){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,n):this.getRawCell(e,n)}getRowFiltered(e){var n,r;return(r=(n=this._rowFilteredInterceptor)==null?void 0:n.getRowFiltered(e))!=null?r:!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=e,v(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,v(()=>this._rowFilteredInterceptor=null)}}class Et{constructor(s,e,n){d(this,"_sheetId");d(this,"_snapshot");d(this,"_cellData");d(this,"_rowManager");d(this,"_columnManager");d(this,"_viewModel");var a;this.unitId=s,this._styles=n,this._snapshot=Dn(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:R.generateRandomId(6),this._cellData=new G(o),this._viewModel=new pn((l,u)=>this.getCellRaw(l,u)),this._rowManager=new to(this._snapshot,this._viewModel,i),this._columnManager=new Qi(this._snapshot,r)}__interceptViewModel(s){s(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const s=this.getCellMatrix(),e=this.getMergeData();let n=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return s.forEach((u,c)=>{Object.keys(c).forEach(h=>{const _=+h,f=s.getValue(u,_),E=f!=null&&f.s?this._styles.get(f.s):null,g=(E==null?void 0:E.bd)&&(E.bd.b||E.bd.l||E.bd.r||E.bd.t||E.bd.bc_tr||E.bd.bl_tr||E.bd.ml_tr||E.bd.tl_bc||E.bd.tl_br||E.bd.tl_mr);(f&&(f.v||f.p)||E!=null&&E.bg||g)&&(a?n=Math.min(n,u):(n=u,a=!0),r=Math.max(r,u),l?i=Math.min(i,_):(l=!0,i=_),o=Math.max(o,_))})}),e.forEach(u=>{a?n=Math.min(n,u.startRow):(n=u.startRow,a=!0),r=Math.max(r,u.endRow),l?i=Math.min(i,u.startColumn):(i=u.startColumn,a=!0),o=Math.max(o,u.endColumn)}),!a||!l?null:{startColumn:i,startRow:n,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:s}=this,e=R.deepClone(s);return new Et(this.unitId,e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(s,e){const n=this._snapshot.mergeData;for(let r=0;r<n.length;r++){const i=n[r];if(X.intersects({startRow:s,startColumn:e,endRow:s,endColumn:e},i))return i}return null}getCell(s,e){return s<0||e<0?null:this._viewModel.getCell(s,e)}getCellRaw(s,e){return this.getCellMatrix().getValue(s,e)}getRowFiltered(s){return this._viewModel.getRowFiltered(s)}getMatrixWithMergedCells(s,e,n,r,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(u=>X.intersects({startRow:s,startColumn:e,endRow:n,endColumn:r},u)),l=new G;return oe(s,n,e,r).forEach((u,c)=>{const h=i?this.getCellRaw(u,c):this.getCell(u,c);h&&l.setValue(u,c,h)}),a.forEach(u=>{const{startColumn:c,startRow:h,endColumn:_,endRow:f}=u;oe(h,f,c,_).forEach((E,g)=>{E===h&&g===c&&l.setValue(E,g,{...o.getValue(E,g),rowSpan:f-h+1,colSpan:_-c+1}),(E!==h||g!==c)&&l.realDeleteValue(E,g)})}),l}getRange(s,e,n,r){return typeof s=="object"?new et(this,s,{getStyles:()=>this._styles}):new et(this,{startRow:s,startColumn:e,endColumn:r||e,endRow:n||s},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:s}=this,{columnCount:e}=s;return e}getMaxRows(){const{_snapshot:s}=this,{rowCount:e}=s;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(s){this._snapshot.rowCount=s}getColumnCount(){return this._snapshot.columnCount}setColumnCount(s){this._snapshot.columnCount=s}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:s}=this,{showGridlines:e}=s;return e===0}getTabColor(){const{_snapshot:s}=this,{tabColor:e}=s;return e}getColumnWidth(s){return this.getColumnManager().getColumnWidth(s)}getRowHeight(s){return this._viewModel.getRowFiltered(s)?0:this.getRowManager().getRowHeight(s)}getRowVisible(s){return this._viewModel.getRowFiltered(s)?!1:this.getRowRawVisible(s)}getRowRawVisible(s){return this.getRowManager().getRowRawVisible(s)}getHiddenRows(s,e){const n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(s,e);return r.forEach(i=>i.endColumn=n),r}getColVisible(s){return this._columnManager.getColVisible(s)}getHiddenCols(s,e){const n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(s,e);return r.forEach(i=>i.endRow=n),r}getVisibleRows(){const s=this.getRowCount();return this._rowManager.getVisibleRows(0,s-1)}getVisibleCols(){const s=this.getColumnCount();return this._columnManager.getVisibleCols(0,s-1)}isRightToLeft(){const{_snapshot:s}=this,{rightToLeft:e}=s;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(s){return s&&(s.v!==void 0||s.f!==void 0||s.p!==void 0)}iterateByRow(s,e=!0){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=s,a=this;return{[Symbol.iterator]:()=>{let l=n,u=r;return{next(){for(;;){if(u>o&&(l+=1,u=r),l>i)return{done:!0,value:void 0};const c=a.getCell(l,u),h=!c,_=a.getMergedCell(l,u);if(_){if(l!==_.startRow||u!==_.startColumn){u=_.endColumn+1;continue}if(h&&e){u=_.endColumn+1;continue}const E={row:l,col:u,value:c};return E.colSpan=_.endColumn-_.startColumn+1,E.rowSpan=_.endRow-_.startRow+1,u=_.endColumn+1,{done:!1,value:E}}if(h&&e)u+=1;else{const f={row:l,col:u,value:c};return u+=1,{done:!1,value:f}}}}}}}}iterateByColumn(s,e=!0,n=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=s,l=this;return{[Symbol.iterator]:()=>{let u=r,c=i;return{next(){for(;;){if(u>o&&(c+=1,u=r),c>a)return{done:!0,value:void 0};const h=l.getMergedCell(u,c);if(h){const E=u!==h.startRow,g=E||c!==h.startColumn;if(n&&g||!n&&E){u=h.endRow+1;continue}const m=l.getCell(h.startRow,h.startColumn);if(!m&&e){u=h.endRow+1;continue}const U={row:u,col:h.startColumn,value:m};return U.colSpan=h.endColumn-h.startColumn+1,U.rowSpan=h.endRow-h.startRow+1,u=h.endRow+1,{done:!1,value:U}}const _=l.getCell(u,c);if(!_&&e)u+=1;else{const E={row:u,col:c,value:_};return u+=1,{done:!1,value:E}}}}}}}}}function ao(t){var n,r;if(!t)return"";const s=(r=(n=t.p)==null?void 0:n.body)==null?void 0:r.dataStream;if(s)return s;const e=t.v;return typeof e=="string"?t.t===Q.BOOLEAN?e.toUpperCase():e:typeof e=="number"?t.t===Q.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const lo="0.1.11";function uo(t="",s=nt.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:lo,locale:s,styles:{},sheets:{},resources:[]}}var co=Object.defineProperty,ho=Object.getOwnPropertyDescriptor,_o=(t,s,e,n)=>{for(var r=n>1?void 0:n?ho(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&co(s,e,r),r},fo=(t,s)=>(e,n)=>s(e,n,t);function Eo(t,s){return`${t.getUnitId()}|${s.getSheetId()}`}exports.Workbook=class extends Kt{constructor(e={},n){super();d(this,"type",O.UNIVER_SHEET);d(this,"_sheetCreated$",new N.Subject);d(this,"sheetCreated$",this._sheetCreated$.asObservable());d(this,"_sheetDisposed$",new N.Subject);d(this,"sheetDisposed$",this._sheetDisposed$.asObservable());d(this,"_activeSheet$",new N.BehaviorSubject(null));d(this,"activeSheet$",this._activeSheet$.asObservable());d(this,"_worksheets");d(this,"_styles");d(this,"_snapshot");d(this,"_unitId");d(this,"_count");this._logService=n;const r=uo();R.isEmptyObject(e)?this._snapshot=r:this._snapshot=R.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=R.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Sn(i),this._count=1,this._worksheets=new Map,this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._snapshot.name}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete()}save(){return R.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._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,n,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(n,0,e);const a=new Et(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:n}=this._snapshot;return n.findIndex(r=>r===e)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const e=this.getRawActiveSheet();if(e)return e;const n=this._snapshot.sheetOrder;for(let i=0,o=n.length;i<o;i++){const a=this._worksheets.get(n[i]);if(a&&a.isSheetHidden()!==C.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(n[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){var r;return this._worksheets.get(e)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===e&&this.setActiveSheet(null),this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),delete this._snapshot.sheets[e],!0):!1}getActiveSheetIndex(){const{sheetOrder:e}=this._snapshot;return e.findIndex(n=>this._worksheets.get(n)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(n=>this._worksheets.get(n))}getSheetsName(){const{sheetOrder:e}=this._snapshot,n=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&n.push(i.getName())}),n}getSheetIndex(e){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:n}=this._snapshot,r=n.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:n}=this._snapshot;return this._worksheets.get(n[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===C.TRUE).map(e=>e.getConfig().id)}transformRangeType(e){if(typeof e=="string")return this._getCellRange(e);if(typeof e!="string"&&"row"in e){const n=e;return{sheetId:"",range:{startRow:n.row[0],startColumn:n.column[0],endRow:n.row[1],endColumn:n.column[1]}}}return typeof e!="string"&&"startRow"in e?{sheetId:"",range:e}:lt}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let n=e;for(;this.checkSheetName(n);)n=e+this._count,this._count++;return n}generateNewSheetName(e){let n=e+this._count;for(;this.checkSheetName(n);)n=e+this._count,this._count++;return n}_getCellRange(e){var c,h,_,f,E;let n="",r="";if(e.indexOf("!")>-1){const g=e.split("!");n=g[0],r=g[1],n=n.replace(/\\'/g,"'").replace(/''/g,"'"),n.substring(0,1)==="'"&&n.substring(n.length-1,1)==="'"&&(n=n.substring(1,n.length-1))}else r=e;if(r.indexOf(":")===-1){const g=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,m=R.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(g)&&!Number.isNaN(m)?{sheetId:n,range:{startRow:g,endRow:g,startColumn:m,endColumn:m}}:lt}r=r.split(":");const i=[0,0],o=[0,0],a=((c=this.getSheetBySheetName(n))==null?void 0:c.getMaxRows())||((h=this.getActiveSheet())==null?void 0:h.getMaxRows()),l=((_=this.getSheetBySheetName(n))==null?void 0:_.getMaxColumns())||((f=this.getActiveSheet())==null?void 0:f.getMaxColumns());return i[0]=Number.parseInt(r[0].replace(/[^0-9]/g,""),10)-1,i[1]=Number.parseInt(r[1].replace(/[^0-9]/g,""),10)-1,Number.isNaN(i[0])&&(i[0]=0),Number.isNaN(i[1])&&(i[1]=a),i[0]>i[1]||(o[0]=R.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=R.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=l),o[0]>o[1])?lt:{sheetId:((E=this.getSheetBySheetName(n))==null?void 0:E.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:e,_worksheets:n}=this,{sheets:r,sheetOrder:i}=e;if(R.isEmptyObject(r)){const o=R.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 u=new Et(this._unitId,a,this._styles);n.set(o,u),i.includes(o)||i.push(o)}}};exports.Workbook=_o([fo(1,J)],exports.Workbook);class be extends Kt{constructor(e){var n;super();d(this,"type",O.UNIVER_SLIDE);d(this,"_snapshot");d(this,"_unitId");this._snapshot={...Js,...e},this._unitId=(n=this._snapshot.id)!=null?n:R.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 n=this.getPages();return n==null?void 0:n[e]}getElementsByPage(e){var n;return(n=this.getPage(e))==null?void 0:n.pageElements}getElement(e,n){var r;return(r=this.getElementsByPage(e))==null?void 0:r[n]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:_e.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const ht="FOCUSING_SHEET",vt="FOCUSING_DOC",Ut="FOCUSING_SLIDE",go="FOCUSING_EDITOR_BUT_HIDDEN",Mn="EDITOR_ACTIVATED",Ro="FOCUSING_EDITOR_INPUT_FORMULA",Pn="FOCUSING_FORMULA_EDITOR",mo="FOCUSING_UNIVER_EDITOR",Co="FOCUSING_EDITOR_INPUT_FORMULA",Oo="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE";var Io=Object.defineProperty,Ao=Object.getOwnPropertyDescriptor,No=(t,s,e,n)=>{for(var r=n>1?void 0:n?Ao(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Io(s,e,r),r},ke=(t,s)=>(e,n)=>s(e,n,t);const q=A.createIdentifier("univer.current");exports.UniverInstanceService=class extends p{constructor(e,n){super();d(this,"_unitsByType",new Map);d(this,"_createHandler");d(this,"_ctorByType",new Map);d(this,"_currentUnits$",new N.BehaviorSubject({}));d(this,"currentUnits$",this._currentUnits$.asObservable());d(this,"_unitAdded$",new N.Subject);d(this,"unitAdded$",this._unitAdded$.asObservable());d(this,"_unitDisposed$",new N.Subject);d(this,"unitDisposed$",this._unitDisposed$.asObservable());d(this,"_focused$",new N.BehaviorSubject(null));d(this,"focused$",this._focused$.asObservable());this._injector=e,this._contextService=n}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(e){this._createHandler=e}createUnit(e,n){return this._createHandler(e,n,this._ctorByType.get(e))}registerCtorForType(e,n){return this._ctorByType.set(e,n),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(N.map(n=>{var r;return(r=n[e])!=null?r:null}),N.distinctUntilChanged())}getCurrentUnitForType(e){return this._currentUnits$.getValue()[e]}setCurrentUnitForType(e){const n=this._getUnitById(e);if(!n)throw new Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits$.next({...this._currentUnits$.getValue(),[n[1]]:n[0]})}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(N.filter(n=>n.type===e))}__addUnit(e){const n=e.type;this._unitsByType.has(n)||this._unitsByType.set(n,[]),this._unitsByType.get(n).push(e),this._currentUnits$.next({...this._currentUnits$.getValue(),[n]:e}),this._unitAdded$.next(e)}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(N.filter(n=>n.type===e))}getUnit(e,n){var i;const r=(i=this._getUnitById(e))==null?void 0:i[0];return n&&(r==null?void 0:r.type)!==n?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(O.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,O.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,O.UNIVER_SHEET)}getAllUnitsForType(e){var n;return(n=this._unitsByType.get(e))!=null?n:[]}changeDoc(e,n){const r=this.getAllUnitsForType(O.UNIVER_DOC),i=r.find(o=>o.getUnitId()===e);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(n)}get focused(){var n;const e=this._focused$.getValue();return e?(n=this._getUnitById(e))==null?void 0:n[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(vt,!1),this._contextService.setContextValue(ht,!0),this._contextService.setContextValue(Ut,!1)):this.focused instanceof st?(this._contextService.setContextValue(vt,!0),this._contextService.setContextValue(ht,!1),this._contextService.setContextValue(Ut,!1)):this.focused instanceof be&&(this._contextService.setContextValue(vt,!1),this._contextService.setContextValue(ht,!1),this._contextService.setContextValue(Ut,!0))}getFocusedUnit(){return this.focused}getUnitType(e){const n=this._getUnitById(e);if(!n)throw new Error(`[UniverInstanceService]: No document with unitId ${e}`);return n[1]}disposeUnit(e){const n=this._getUnitById(e);if(!n)return!1;const[r,i]=n,o=this._unitsByType.get(i),a=o.indexOf(r);return o.splice(a,1),this._unitDisposed$.next(r),this._currentUnits$.next({...this._currentUnits$.getValue(),[i]:null}),this._focused$.next(null),!0}_getUnitById(e){for(const[n,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===e);if(i)return[i,n]}}};exports.UniverInstanceService=No([ke(0,A.Inject(A.Injector)),ke(1,gt)],exports.UniverInstanceService);var b=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(b||{});const So={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},Dt=new Map;function we(t,s){return function(r){ve(t,s)}}function ve(t,s){Dt.has(t)||Dt.set(t,[]),Dt.get(t).push(s)}var Lo=Object.defineProperty,To=Object.getOwnPropertyDescriptor,xn=(t,s,e,n)=>{for(var r=n>1?void 0:n?To(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Lo(s,e,r),r},ue=(t,s)=>(e,n)=>s(e,n,t);exports.LifecycleService=class extends p{constructor(e){super();d(this,"_lifecycle$",new N.BehaviorSubject(b.Starting));d(this,"lifecycle$",this._lifecycle$.asObservable());d(this,"_lock",!1);this._logService=e,this._reportProgress(b.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 new N.Observable(e=>{this.stage===b.Starting||(this.stage===b.Ready?e.next(b.Starting):this.stage===b.Rendered?(e.next(b.Starting),e.next(b.Ready)):(e.next(b.Starting),e.next(b.Ready),e.next(b.Rendered))),this._lifecycle$.subscribe(n=>{e.next(n),n===b.Steady&&e.complete()})})}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${So[e]}".`)}};exports.LifecycleService=xn([ue(0,J)],exports.LifecycleService);exports.LifecycleInitializerService=class extends p{constructor(e,n){super();d(this,"_seenTokens",new Set);this._lifecycleService=e,this._injector=n}initModulesOnStage(e){var n;(n=Dt.get(e))==null||n.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}};exports.LifecycleInitializerService=xn([ue(0,A.Inject(exports.LifecycleService)),ue(1,A.Inject(A.Injector))],exports.LifecycleInitializerService);class dt extends p{constructor(){super();d(this,"_currentLocale",nt.ZH_CN);d(this,"_locales",null);d(this,"localeChanged$",new N.Subject);d(this,"t",(e,...n)=>{if(!this._locales)throw new Error("Locale not initialized");const r=e.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return n.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return e});this.disposeWithMe(v(()=>this.localeChanged$.complete()))}load(e){var n;this._locales=R.deepMerge((n=this._locales)!=null?n:{},e)}setLocale(e){this._currentLocale=e,this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(e,n){const r=n.shift();if(r&&e&&r in e){const i=e[r];return n.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,n):i}return null}}const Yt=A.createIdentifier("resource-manager-service");var bo=Object.defineProperty,wo=Object.getOwnPropertyDescriptor,vo=(t,s,e,n)=>{for(var r=n>1?void 0:n?wo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&bo(s,e,r),r},Ge=(t,s)=>(e,n)=>s(e,n,t);const Ue=A.createIdentifier("univer.permission-service");exports.PermissionService=class extends p{constructor(e,n){super();d(this,"_permissionPointMap",new Map);d(this,"deletePermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e);if(r){const i=r.get(n);i&&(i.complete(),this._permissionPointMap.delete(n))}});d(this,"addPermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e)||new Map;return r.has(n.id)?!1:(r.set(n.id,new N.BehaviorSubject(n)),this._permissionPointMap.set(e,r),!0)});d(this,"updatePermissionPoint",(e,n,r)=>{const i=this._permissionPointMap.get(e);if(!i)return;const o=i.get(n);if(o){const a=o.getValue();a.value=r,a.status=Re.DONE,o.next(a)}});d(this,"getPermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e);if(!r)return;const i=r.get(n);if(i)return i.getValue()});this._resourceManagerService=e,this._univerInstanceService=n}_toJson(e){const n=this._permissionPointMap.get(e);let r=[];return n&&(r=[...n.keys()].reduce((i,o)=>{const a=n.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(e){return JSON.parse(e)}composePermission$(e,n){const r=this._permissionPointMap.get(e),i=n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.asObservable()});return N.combineLatest(i).pipe(Lt.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(e,n){const r=this._permissionPointMap.get(e);return n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}};exports.PermissionService=vo([we(b.Starting,exports.PermissionService),Ge(0,A.Inject(Yt)),Ge(1,A.Inject(q))],exports.PermissionService);const Hn="univer.editable";class pt extends ys{constructor(e){super();d(this,"id",Hn);d(this,"value",!0);d(this,"unitID");this.unitID=e}}var Uo=Object.defineProperty,Do=Object.getOwnPropertyDescriptor,po=(t,s,e,n)=>{for(var r=n>1?void 0:n?Do(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Uo(s,e,r),r},$e=(t,s)=>(e,n)=>s(e,n,t);exports.UniverPermissionService=class extends p{constructor(s,e){super(),this._permissionService=s,this._univerInstanceService=e,this._init()}_init(){this._univerInstanceService.getTypeOfUnitAdded$(O.UNIVER_SHEET).subscribe(s=>{const e=new pt(s.getUnitId());this._permissionService.addPermissionPoint(s.getUnitId(),e)})}getEditable(s=(e=>(e=this._univerInstanceService.getCurrentUnitForType(O.UNIVER_SHEET))==null?void 0:e.getUnitId())()){if(!s)return;const n=new pt(s),r=this._permissionService.getPermissionPoint(s,n.id);return r==null?void 0:r.value}setEditable(s,e){const n=new pt(s);this._permissionService.updatePermissionPoint(s,n.id,e)}};exports.UniverPermissionService=po([we(b.Starting,exports.UniverPermissionService),$e(0,A.Inject(Ue)),$e(1,A.Inject(q))],exports.UniverPermissionService);class Fn extends p{constructor(){super(...arguments);d(this,"_resourceMap",new Map);d(this,"_register$",new N.Subject);d(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}})}registerPluginResource(e){const n=e.pluginName;if(this._resourceMap.has(n))throw new Error(`the pluginName is registered {${n}}`);return this._resourceMap.set(n,e),this._register$.next(e),v(()=>this._resourceMap.delete(n))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,n){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=n==null?void 0:n.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(n=>{n.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}var Mo=Object.defineProperty,Po=Object.getOwnPropertyDescriptor,xo=(t,s,e,n)=>{for(var r=n>1?void 0:n?Po(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Mo(s,e,r),r},Ve=(t,s)=>(e,n)=>s(e,n,t);let ce=class extends p{constructor(s,e){super();d(this,"saveWorkbook",s=>{const e=s.getUnitId(),n=this._resourceManagerService.getResources(e)||[],r=s.getSnapshot();return r.resources=n,r});this._resourceManagerService=s,this._univerInstanceService=e,this._init()}_init(){const s=n=>{n.businesses.forEach(r=>{switch(r){case O.UNRECOGNIZED:case O.UNIVER_UNKNOWN:case O.UNIVER_SLIDE:case O.UNIVER_DOC:break;case O.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(O.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===n.pluginName);if(a)try{const l=n.parseJson(a.data);n.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${n.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(n=>{s(n)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(n=>{s(n)})),this.disposeWithMe(v(this._univerInstanceService.getTypeOfUnitAdded$(O.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.loadResources(n.getUnitId(),n.getSnapshot().resources)}))),this.disposeWithMe(v(this._univerInstanceService.getTypeOfUnitDisposed$(O.UNIVER_SHEET).subscribe(n=>{this._resourceManagerService.unloadResources(n.getUnitId())})))}};ce=xo([Ve(0,A.Inject(Yt)),Ve(1,A.Inject(q))],ce);const De=A.createIdentifier("resource-loader-service");ve(b.Ready,De);class pe extends p{constructor(){super();d(this,"_currentTheme");d(this,"_currentTheme$",new N.BehaviorSubject({}));d(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(v(()=>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 Wn="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Bn="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Ho=`\r
|
|
7
|
-
`;function Fo(t){return`__internalEditorId__${t}`}function Wo(t){return t.startsWith("__")}var Bo=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,Go=(t,s,e,n)=>{for(var r=n>1?void 0:n?ko(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Bo(s,e,r),r},Qt=(t,s)=>(e,n)=>s(e,n,t);const zt=A.createIdentifier("univer.undo-redo.service"),$o=20;class kn{dispose(){}async dispatchToHandlers(){return!1}}const Gn="univer.command.redo",$n="univer.command.undo",Vn=new class extends kn{constructor(){super(...arguments);d(this,"type",Rt.COMMAND);d(this,"id",$n)}async handler(s){const e=s.get(zt),n=e.pitchTopUndoElement();if(!n)return!1;const r=s.get(mt);return me(n.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},jn=new class extends kn{constructor(){super(...arguments);d(this,"type",Rt.COMMAND);d(this,"id",Gn)}async handler(s){const e=s.get(zt),n=e.pitchTopRedoElement();if(!n)return!1;const r=s.get(mt);return me(n.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends p{constructor(e,n,r){super();d(this,"undoRedoStatus$");d(this,"_undoRedoStatus$",new N.BehaviorSubject({undos:0,redos:0}));d(this,"_undoStacks",new Map);d(this,"_redoStacks",new Map);d(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=n,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Vn)),this.disposeWithMe(this._commandService.registerCommand(jn)),this.disposeWithMe(v(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(v(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:n}=e,r=this._getRedoStack(n,!0),i=this._getUndoStack(n,!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>$o&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const n=this._getRedoStack(e);n&&(n.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 n=this._getUndoStack(e);return n!=null&&n.length?n[n.length-1]:null}_pitchRedoElement(e){const n=this._getRedoStack(e);return n!=null&&n.length?n[n.length-1]:null}popUndoToRedo(){const n=this._getUndoStackForFocused().pop();n&&(this._getRedoStackForFocused().push(n),this._updateStatus())}popRedoToUndo(){const n=this._getRedoStackForFocused().pop();n&&(this._getUndoStackForFocused().push(n),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),v(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUnitId(),n=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:n,redos:r})}_getUndoStack(e,n=!1){let r=this._undoStacks.get(e);return!r&&n&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,n=!1){let r=this._redoStacks.get(e);return!r&&n&&(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,n){e.redoMutations.push(...n.redoMutations),e.undoMutations.push(...n.undoMutations)}_getFocusedUnitId(){var o,a,l,u;let e="";const n=this._contextService.getContextValue(ht),r=this._contextService.getContextValue(Pn),i=this._contextService.getContextValue(Mn);return n?r?e=Bn:i?e=Wn:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(u=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?u:"",e}};exports.LocalUndoRedoService=Go([Qt(0,q),Qt(1,mt),Qt(2,gt)],exports.LocalUndoRedoService);class he extends p{onStarting(s){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}d(he,"pluginName"),d(he,"type",O.UNIVER_UNKNOWN);class Vo{constructor(){d(this,"_plugins",[])}addPlugin(s){this._plugins.push(s)}removePlugins(){const s=this._plugins.slice();return this._plugins.length=0,s}forEachPlugin(s){this._plugins.forEach(s)}}class jo{constructor(){d(this,"_pluginsRegistered",[])}registerPlugin(s,e){this._pluginsRegistered.push({plugin:s,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var Ko=Object.defineProperty,Yo=Object.getOwnPropertyDescriptor,zo=(t,s,e,n)=>{for(var r=n>1?void 0:n?Yo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Ko(s,e,r),r},St=(t,s)=>(e,n)=>s(e,n,t);exports.PluginHolder=class extends p{constructor(e,n,r,i){super();d(this,"_started",!1);d(this,"_pluginRegistered",new Set);d(this,"_pluginStore",new Vo);d(this,"_pluginRegistry",new jo);this._logService=e,this._injector=n,this._lifecycleService=r,this._lifecycleInitializerService=i}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(e=>e.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._pluginRegistered.clear()}registerPlugin(e,n){const{pluginName:r}=e;if(this._pluginRegistered.has(r)){this._logService.warn("[PluginService]",`plugin ${r} has already been registered. This registration will be ignored.`);return}this._pluginRegistered.add(r),this._pluginRegistry.registerPlugin(e,n)}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const e=this._pluginRegistry.getRegisterPlugins().map(({plugin:r,options:i})=>this._initPlugin(r,i));this._pluginRegistry.removePlugins();const n=this.disposeWithMe(this._lifecycleService.subscribeWithPrevious().pipe(N.finalize(()=>{Promise.resolve().then(()=>n.dispose())})).subscribe(r=>{this._pluginsRunLifecycle(e,r)}))}_pluginsRunLifecycle(e,n){e.forEach(r=>{switch(n){case b.Starting:r.onStarting(this._injector);break;case b.Ready:r.onReady();break;case b.Rendered:r.onRendered();break;case b.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(n)}_initPlugin(e,n){return this._injector.createInstance(e,n)}};exports.PluginHolder=zo([St(0,J),St(1,A.Inject(A.Injector)),St(2,A.Inject(exports.LifecycleService)),St(3,A.Inject(exports.LifecycleInitializerService))],exports.PluginHolder);var yo=Object.defineProperty,Xo=Object.getOwnPropertyDescriptor,qo=(t,s,e,n)=>{for(var r=n>1?void 0:n?Xo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&yo(s,e,r),r},Jo=(t,s)=>(e,n)=>s(e,n,t);const Zo=4;exports.PluginService=class{constructor(s){d(this,"_pluginHolderForUniver");d(this,"_pluginHoldersForTypes",new Map);d(this,"_flushTimer");this._injector=s,this._pluginHolderForUniver=this._injector.createInstance(exports.PluginHolder),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const s of this._pluginHoldersForTypes.values())s.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(s,e){this._assertPluginValid(s),this._scheduleInitPlugin();const{type:n}=s;n===O.UNIVER_UNKNOWN?(this._pluginHolderForUniver.registerPlugin(s,e),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(n).registerPlugin(s,e)}startPluginForType(s){this._ensurePluginHolderForType(s).start()}_ensurePluginHolderForType(s){if(!this._pluginHoldersForTypes.has(s)){const e=this._injector.createInstance(exports.PluginHolder);return this._pluginHoldersForTypes.set(s,e),e}return this._pluginHoldersForTypes.get(s)}_assertPluginValid(s){const{type:e,pluginName:n}=s;if(e===O.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${s}. Please assign a "type" to your plugin.`);if(n==="")throw new Error(`[PluginService]: no plugin name for ${s}. Please assign a "pluginName" to your plugin.`)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},Zo))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[s,e]of this._pluginHoldersForTypes)e.started&&e.flush()}};exports.PluginService=qo([Jo(0,A.Inject(A.Injector))],exports.PluginService);function Kn(t,s){if(!s)return t;const e=[];for(const n of t){const r=s.find(([i])=>i===n[0]);if(r){if(r[1]===null)continue;e.push([n[0],r[1]])}else e.push(n)}return e}class Yn{constructor(){d(this,"_model",new Map);d(this,"_userChange$",new N.Subject);d(this,"userChange$",this._userChange$.asObservable())}addUser(s){this._model.set(s.userID,s),this._userChange$.next({type:"add",user:s})}getUser(s,e){const n=this._model.get(s);if(n)return n;e&&e()}delete(s){const e=this.getUser(s);this._model.delete(s),e&&this._userChange$.next({type:"delete",user:e})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}}class Qo{constructor(s={},e){d(this,"_startedTypes",new Set);d(this,"_injector");const n=this._injector=ta(e,s==null?void 0:s.override),{theme:r,locale:i,locales:o,logLevel:a}=s;r&&this._injector.get(pe).setTheme(r),o&&this._injector.get(dt).load(o),i&&this._injector.get(dt).setLocale(i),a&&this._injector.get(J).setLogLevel(a),this._init(n),this._pluginService}get _univerInstanceService(){return this._injector.get(q)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(s){this._injector.get(dt).setLocale(s)}createUnit(s,e){return this._univerInstanceService.createUnit(s,e)}createUniverSheet(s){return this._univerInstanceService.createUnit(O.UNIVER_SHEET,s)}createUniverDoc(s){return this._univerInstanceService.createUnit(O.UNIVER_DOC,s)}createUniverSlide(s){return this._univerInstanceService.createUnit(O.UNIVER_SLIDE,s)}_init(s){this._univerInstanceService.registerCtorForType(O.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(O.UNIVER_DOC,st),this._univerInstanceService.registerCtorForType(O.UNIVER_SLIDE,be);const e=s.get(q);e.__setCreateHandler((n,r,i)=>{if(!this._startedTypes.has(n)){this._pluginService.startPluginForType(n),this._startedTypes.add(n);const a=s.createInstance(i,r);return e.__addUnit(a),this._tryProgressToReady(),a}const o=s.createInstance(i,r);return e.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<b.Ready&&(this._injector.get(exports.LifecycleService).stage=b.Ready)}registerPlugin(s,e){this._pluginService.registerPlugin(s,e)}}function ta(t,s){const e=Kn([[In],[dt],[pe],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.UniverPermissionService],[exports.PluginService],[Yn],[q,{useClass:exports.UniverInstanceService}],[Ue,{useClass:exports.PermissionService}],[J,{useClass:nn,lazy:!0}],[mt,{useClass:exports.CommandService,lazy:!0}],[zt,{useClass:exports.LocalUndoRedoService,lazy:!0}],[Cn,{useClass:On}],[gt,{useClass:en}],[Nn,{useClass:An,lazy:!0}],[Yt,{useClass:Fn,lazy:!0}],[De,{useClass:ce,lazy:!0}]],s);return t?t.createChild(e):new A.Injector(e)}const ea=(t,s)=>s.length===t.length&&!t.some(e=>s.some(n=>!X.equals(n,e))),sa=(t,s)=>s.length===t.length&&t.every((e,n)=>{const r=s[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&X.equals(e.range,r.range)});function na(t,s){if(Object.is(t,s))return!0;if(typeof t!="object"||!t||typeof s!="object"||!s)return!1;const e=Object.keys(t),n=Object.keys(s);if(e.length!==n.length)return!1;const r=Object.prototype.hasOwnProperty.bind(s);for(let i=0;i<e.length;i++){const o=e[i];if(!r(o))return!1;const a=t[o],l=s[o];if(a!==l)return!1}return!0}function zn(t){return/^-?\d+(\.\d+)?$/.test(t)}function ra(t){return zn(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function ia(t){return["true","false"].includes(t.toLowerCase())}function oa(t,s){return s.forEach(e=>t.add(e)),t}function aa(t,s=16){let e=0,n=null;return function(...i){const o=Date.now();o-e<s?(n&&clearTimeout(n),n=setTimeout(()=>{e=o,t.apply(this,i)},s)):(e=o,t.apply(this,i))}}function la(t){const s=new MessageChannel;let e=!1;return s.port1.onmessage=()=>{e||t()},s.port2.postMessage(null),()=>{e=!0}}var yn=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(yn||{});class de{constructor(s){d(this,"_index",0);d(this,"_offset",0);this._actions=s}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(s){s||(s=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const n=this._offset,r=e.len;return s>=r-n?(s=r-n,this._index+=1,this._offset=0):this._offset+=s,e.t===I.DELETE||e.t===I.RETAIN&&e.body==null?R.deepClone({...e,len:s}):R.deepClone({...e,len:s,body:Le(e.body,n,n+s)})}else return{t:I.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 s=this._actions[this._index];return s?s.t:I.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const s=this._offset,e=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=s,this._index=e,[n].concat(r)}}else return[]}}function je(t){return Object.keys(t).length===1}class yt{constructor(){d(this,"_actions",[])}static compose(s,e){const n=new de(s),r=new de(e),i=new yt;for(;n.hasNext()||r.hasNext();)if(r.peekType()===I.INSERT)i.push(r.next());else if(n.peekType()===I.DELETE)i.push(n.next());else{const o=Math.min(n.peekLength(),r.peekLength()),a=n.next(o),l=r.next(o);a.t===I.INSERT&&l.t===I.RETAIN?l.body==null?i.push(a):i.push({...a,body:le(a.body,l.body,l.coverType)}):a.t===I.RETAIN&&l.t===I.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:le(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===I.RETAIN&&l.t===I.DELETE?i.push(l):a.t===I.INSERT&&(l.t,I.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(s,e,n=""){const r={t:I.INSERT,body:e,len:s,line:0,segmentId:n};return this.push(r),this}retain(s,e="",n,r){const i={t:I.RETAIN,len:s,segmentId:e};return n!=null&&(i.body=n),r!=null&&(i.coverType=r),this.push(i),this}delete(s,e=""){const n={t:I.DELETE,len:s,line:0,segmentId:e};return this.push(n),this}serialize(){return this._actions}push(...s){if(s.length>1){for(const i of s)this.push(i);return this}let e=this._actions.length,n=this._actions[e-1];const r=R.deepClone(s[0]);if(r.t===I.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n=="object"){if(n.t===I.DELETE&&r.t===I.DELETE)return n.len+=r.len,this;if(n.t===I.DELETE&&r.t===I.INSERT&&(e-=1,n=this._actions[e-1],n==null))return this._actions.unshift(r),this;if(n.t===I.RETAIN&&r.t===I.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===I.INSERT&&je(n.body)&&r.t===I.INSERT&&je(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let s=this._actions[this._actions.length-1];for(;s&&s.t===I.RETAIN&&Xi(s);)this._actions.pop(),s=this._actions[this._actions.length-1];return this}}function ua(t,s,e){if(s==="")return t;const n={id:"mock-id",body:t,documentStyle:{}},r=new st(n),i=s.length;let o;for(;(o=r.getBody().dataStream.indexOf(s))>=0;){const l=new yt;if(o>0&&l.retain(o),e.length>0){const c=r.sliceBody(o,o+i),h={dataStream:e};Array.isArray(c==null?void 0:c.textRuns)&&c.textRuns.length&&(h.textRuns=[{...c.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,h)}l.delete(i);const u=l.serialize();r.apply(u)}const a=r.getBody();return r.dispose(),a}class ca extends Vt{add(s){if(!s)return null;const e=new $t(s,this);return this._observers=[e],this._onObserverAdded&&this._onObserverAdded(e),e}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const ha=A.createIdentifier("ILocalStorageService");function da(t){return`sheet_interceptor_${t}`}const Xn=t=>function(s,e){let n=-1;function r(i,o){if(i<=n)throw new Error("[SheetInterceptorService]: next() called multiple times!");return n=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,s)};class _a{constructor(s){d(this,"_interceptorsByName",new Map);d(this,"_interceptorPoints");this._interceptorPoints=s}fetchThroughInterceptors(s){const e=s,n=this._interceptorsByName.get(e);return Xn(n||[])}intercept(s,e){const n=s;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const r=this._interceptorsByName.get(n);return r.push(e),this._interceptorsByName.set(n,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>jt(this._interceptorsByName.get(n),e)}getInterceptPoints(){return this._interceptorPoints}}const fa=A.createIdentifier("univer.snapshot-server-service");class Ea{constructor(){d(this,"_sheetBlockCache",new Map)}getUnitOnRev(s,e){return Promise.resolve({snapshot:{unitID:"",type:O.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:B.OK,message:""}})}getSheetBlock(s,e){const n=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:n,error:{code:B.OK,message:""}})}fetchMissingChangesets(s,e){return Promise.resolve({changesets:[],error:{code:B.OK,message:""}})}getResourcesRequest(s,e){return Promise.resolve({resources:{},error:{code:B.OK,message:""}})}saveSnapshot(s,e){return Promise.resolve({error:{code:B.OK,message:""}})}saveSheetBlock(s,e){const{block:n}=e;return n?(this._sheetBlockCache.set(n.id,n),Promise.resolve({error:{code:B.OK,message:""},blockID:n.id})):Promise.resolve({error:{code:B.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(s,e){return Promise.resolve({error:{code:B.OK,message:""},concurrent:[]})}}function ga(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(s,e)=>String.fromCharCode(Number.parseInt(e,16))))}function Me(t){return decodeURIComponent(Array.prototype.map.call(atob(t),s=>`%${`00${s.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const Ct=new TextEncoder,Xt=new TextDecoder;function qn(t){const s=R.deepClone(t);return delete s.id,delete s.name,delete s.rowCount,delete s.columnCount,delete s.cellData,Ct.encode(JSON.stringify(s))}function Jn(t){const s=R.deepClone(t);return delete s.id,delete s.rev,delete s.name,delete s.sheetOrder,delete s.sheets,Ct.encode(JSON.stringify(s))}function Ra(t){const s=R.deepClone(t);return delete s.id,delete s.rev,delete s.title,delete s.resources,Ct.encode(JSON.stringify(s))}function Ke(t){return JSON.parse(Xt.decode(t))}function ma(t){return JSON.parse(typeof t=="string"?Me(t):Xt.decode(t))}function Ca(t){return JSON.parse(typeof t=="string"?Me(t):Xt.decode(t))}const te=256;function Zn(t,s){const e=new G(t),n=e.getLength(),r=[];let i=0;for(;i<n;){const o=Math.min(i+te,n-1),a=e.getSlice(i,Math.min(i+te,n-1),0,s),l=Oa(a);r.push({id:R.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=te}return r}function Oa(t){const s=t.getData();return Ct.encode(JSON.stringify(s))}async function Ia(t,s,e,n,r){const i={},o={};if(!await Promise.all(Object.entries(s.sheets).map(async([h,_])=>{const f={id:_.id,type:Bt.GRID,name:_.name,rowCount:_.rowCount,columnCount:_.columnCount,originalMeta:qn(_)};if(o[h]=f,_.cellData){const E=Zn(_.cellData,_.rowCount),g=await Promise.all(E.map(m=>r.saveSheetBlock(t,{unitID:e,type:O.UNIVER_SHEET,block:m})));if(g.some(m=>{var S;return((S=m.error)==null?void 0:S.code)!==B.OK}))return!1;i[h]={sheetID:h,blocks:g.map(m=>m.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Jn(s),u={unitID:s.id,rev:n,creator:"",name:s.name,sheetOrder:s.sheetOrder,sheets:o,blockMeta:i,resources:s.resources||[],originalMeta:l};return{snapshotRes:{unitID:e,rev:u.rev,type:O.UNIVER_SHEET,workbook:u,doc:void 0}}}async function Aa(t,s,e,n,r){var _,f;const i={},o={};if(!await Promise.all(Object.entries(s.sheets).map(async([E,g])=>{const m={id:g.id,type:Bt.GRID,name:g.name,rowCount:g.rowCount,columnCount:g.columnCount,originalMeta:qn(g)};if(o[E]=m,g.cellData){const S=Zn(g.cellData,g.rowCount),U=await Promise.all(S.map(M=>r.saveSheetBlock(t,{unitID:e,type:O.UNIVER_SHEET,block:M})));if(U.some(M=>{var V;return((V=M.error)==null?void 0:V.code)!==B.OK}))return!1;i[E]={sheetID:E,blocks:U.map(M=>M.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Jn(s),u={unitID:s.id,rev:n,creator:"",name:s.name,sheetOrder:s.sheetOrder,sheets:o,blockMeta:i,resources:s.resources||[],originalMeta:l},c={unitID:e,rev:u.rev,type:O.UNIVER_SHEET,workbook:u,doc:void 0},h=await r.saveSnapshot(t,{unitID:e,type:O.UNIVER_SHEET,snapshot:c});if(an(h.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
|
|
8
|
-
ErrorCode: ${(
|
|
9
|
-
ErrorCode: ${(
|
|
1
|
+
"use strict";var fo=Object.defineProperty;var _o=(t,e,n)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var _=(t,e,n)=>(_o(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const it=require("rxjs"),un=require("rxjs/operators"),at=require("@wendellhu/redi");function go(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function mo(){Eo()}const nn=typeof global<"u"?global:typeof self<"u"?self:window;function Eo(){typeof nn.requestIdleCallback!="function"&&(nn.requestIdleCallback=function(n){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));n({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof nn.cancelIdleCallback!="function"&&(nn.cancelIdleCallback=function(n){clearTimeout(n)})}const po="__default_document_sub_component_id20231101__",Fe=2,zs=1;function Ro(t,e){if(e==null||t==null)return!0;const{left:n=0,top:s=0,height:r=0,width:i=0,angle:o=0}=e,{left:l=0,top:a=0,height:h=0,width:c=0,angle:u=0}=t,d=c,f=h,m=i,E=r;return Math.abs(l-n)>Fe||Math.abs(a-s)>Fe||Math.abs(d-m)>Fe||Math.abs(f-E)>Fe||Math.abs(u-o)>zs}function Xs(t,e){let n=0,s=t.length-1;for(;n<=s;){const r=Math.floor((s+n)/2);if(e<t[r]&&(r===0||e>=t[r-1]))return r;if(e>=t[r])n=r+1;else if(e<t[r])s=r-1;else return-1}return-1}function qs(t,e){let n=0,s=0,r=0,i=-1,o=t.length-1;for(;n<t.length&&o>=0&&o>=n;){if(s=t[o],o===0?r=0:r=t[o-1],e>=r&&e<=s){i=o;break}if(s=t[n],n===0?r=0:r=t[n-1],e>=r&&e<s){i=n;break}n++,o--}return i}function Co(t,e){let n=t.length-1;return e<0?-1:e<t[0]?0:e>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||e<=t[20]||e>=t[n-20]?n=qs(t,e):n=Xs(t,e),n)}function Io(t){const e=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(e)}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||{}),Zs=(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))(Zs||{}),zt=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(zt||{}),Qs=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(Qs||{}),tr=(t=>(t[t.PASTE_NORMAL=0]="PASTE_NORMAL",t[t.PASTE_NO_BORDERS=1]="PASTE_NO_BORDERS",t[t.PASTE_FORMAT=2]="PASTE_FORMAT",t[t.PASTE_FORMULA=3]="PASTE_FORMULA",t[t.PASTE_DATA_VALIDATION=4]="PASTE_DATA_VALIDATION",t[t.PASTE_VALUES=5]="PASTE_VALUES",t[t.PASTE_CONDITIONAL_FORMATTING=6]="PASTE_CONDITIONAL_FORMATTING",t[t.PASTE_COLUMN_WIDTHS=7]="PASTE_COLUMN_WIDTHS",t))(tr||{}),er=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(er||{}),nr=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(nr||{}),sr=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(sr||{});function Oo(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var rr=(t=>(t[t.NUMBER_FORMAT_TYPE_UNSPECIFIED=0]="NUMBER_FORMAT_TYPE_UNSPECIFIED",t[t.TEXT=1]="TEXT",t[t.NUMBER=2]="NUMBER",t[t.PERCENT=3]="PERCENT",t[t.CURRENCY=4]="CURRENCY",t[t.DATE=5]="DATE",t[t.TIME=6]="TIME",t[t.DATE_TIME=7]="DATE_TIME",t[t.SCIENTIFIC=8]="SCIENTIFIC",t))(rr||{}),ir=(t=>(t[t.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]="INTERPOLATION_POINT_TYPE_UNSPECIFIED",t[t.MIN=1]="MIN",t[t.MAX=2]="MAX",t[t.NUMBER=3]="NUMBER",t[t.PERCENT=4]="PERCENT",t[t.PERCENTILE=5]="PERCENTILE",t))(ir||{}),Te=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t))(Te||{}),or=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(or||{}),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||{}),On=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(On||{}),Ye=(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))(Ye||{}),ar=(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))(ar||{}),Se=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.LEFT=1]="LEFT",t[t.CENTER=2]="CENTER",t[t.RIGHT=3]="RIGHT",t[t.JUSTIFIED=4]="JUSTIFIED",t))(Se||{}),ye=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(ye||{}),ze=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ze||{}),mn=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(mn||{}),En=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(En||{}),Pe=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Pe||{}),q=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(q||{}),Ne=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(Ne||{}),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||{}),Sn=(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))(Sn||{}),ur=(t=>(t.Line="line",t.LineInv="lineInv",t.Triangle="triangle",t.RtTriangle="rtTriangle",t.Rect="rect",t.Diamond="diamond",t.Parallelogram="parallelogram",t.Trapezoid="trapezoid",t.NonIsocelesTrapezoid="nonIsocelesTrapezoid",t.Pentagon="pentagon",t.Hexagon="hexagon",t.Heptagon="heptagon",t.Octagon="octagon",t.Decagon="decagon",t.Dodecagon="dodecagon",t.Star4="star4",t.Star5="star5",t.Star6="star6",t.Star7="star7",t.Star8="star8",t.Star10="star10",t.Star12="star12",t.Star16="star16",t.Star24="star24",t.Star32="star32",t.RoundRect="roundRect",t.Round1Rect="round1Rect",t.Round2SameRect="round2SameRect",t.Round2DiagRect="round2DiagRect",t.Ellipse="ellipse",t))(ur||{}),cr=(t=>(t.RightArrow="rightArrow",t.LeftArrow="leftArrow",t.UpArrow="upArrow",t.DownArrow="downArrow",t.LeftRightArrow="leftRightArrow",t.UpDownArrow="upDownArrow",t.QuadArrow="quadArrow",t.LeftRightUpArrow="leftRightUpArrow",t.BentArrow="bentArrow",t.UturnArrow="uturnArrow",t.CircularArrow="circularArrow",t.NotchedRightArrow="notchedRightArrow",t.HomePlate="homePlate",t.Chevron="chevron",t.LeftCircularArrow="leftCircularArrow",t.LeftRightCircularArrow="leftRightCircularArrow",t))(cr||{}),hr=(t=>(t.Plaque="plaque",t.Can="can",t.Cube="cube",t.Bevel="bevel",t.Donut="donut",t.NoSmoking="noSmoking",t.BlockArc="blockArc",t.FoldedCorner="foldedCorner",t))(hr||{}),dr=(t=>(t.SmileyFace="smileyFace",t.Heart="heart",t.LightningBolt="lightningBolt",t.Sun="sun",t.Moon="moon",t.Cloud="cloud",t.Arc="arc",t.Backpack="backpack",t.Frame="frame",t.HalfFrame="halfFrame",t.Corner="corner",t.Chord="chord",t.Pie="pie",t.Teardrop="teardrop",t.WedgeRectCallout="wedgeRectCallout",t.WedgeRRectCallout="wedgeRRectCallout",t.WedgeEllipseCallout="wedgeEllipseCallout",t.CloudCallout="cloudCallout",t.BorderCallout1="borderCallout1",t.BorderCallout2="borderCallout2",t.BorderCallout3="borderCallout3",t.AccentCallout1="accentCallout1",t.AccentCallout2="accentCallout2",t.AccentCallout3="accentCallout3",t.Callout1="callout1",t.Callout2="callout2",t.Callout3="callout3",t.ActionButtonBackPrevious="actionButtonBackPrevious",t.ActionButtonEnd="actionButtonEnd",t.ActionButtonForwardNext="actionButtonForwardNext",t.ActionButtonHelp="actionButtonHelp",t.ActionButtonHome="actionButtonHome",t.ActionButtonInformation="actionButtonInformation",t.ActionButtonMovie="actionButtonMovie",t.ActionButtonReturn="actionButtonReturn",t.ActionButtonSound="actionButtonSound",t))(dr||{});const fr={[Sn.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 Nn{constructor(){_(this,"_themeValue",Ht.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=zt.UNSUPPORTED,this._themeColors=Sn.OFFICE,this._themeTint=0}asRgbColor(){return new pn(this._rgbValue,this)}asThemeColor(){return new Rn(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(e){return this._colorType=zt.RGB,this._rgbValue=e,this}setThemeColors(e){this._colorType=zt.THEME,this._themeColors=e}setThemeTint(e){this._colorType=zt.THEME,this._themeTint=e}setThemeColor(e){return this._colorType=zt.THEME,this._themeValue=e,this}getColorType(){return this._colorType}}class be{constructor(e){_(this,"_builder");this._builder=e}static rgbColorToHexValue(e){return`#${((1<<24)+(e.getRed()<<16)+(e.getGreen()<<8)+e.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(e){e?e.indexOf("#")>-1&&(e=e.substring(1)):e="#000000";const n=+`0x${e[0]}${e[1]}`,s=+`0x${e[2]}${e[3]}`,r=+`0x${e[4]}${e[5]}`;return new Nn().setRgbColor(`rgb(${n},${s},${r})`).asRgbColor()}static hexToRgbString(e){const n=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(n,(i,o,l,a)=>o+o+l+l+a+a);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),l=Number.parseInt(s[3],16);r=`rgba(${i},${o},${l})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new be(this._builder)}equals(e){return!1}}class _r{constructor(e){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const n=e.getRed()/255,s=e.getGreen()/255,r=e.getBlue()/255,i=e.getAlpha()/255,o=Math.min(n,Math.min(s,r)),l=Math.max(n,Math.max(s,r)),a=l-o;if(l===o){this._hue=0,this._saturation=0,this._lightness=l;return}this._lightness=(o+l)/2,this._lightness<.5?this._saturation=a/(l+o):this._saturation=a/(2-l-o),n===l&&(this._hue=(s-r)/a),s===l&&(this._hue=2+(r-n)/a),r===l&&(this._hue=4+(n-s)/a),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const e=new Nn;if(this._saturation===0)return e.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),e.asRgbColor();let n;this._lightness<.5?n=this._lightness*(1+this._saturation):n=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-n,r=this._hue/360,i=r+1/3,o=this.setColor(n,s,i),l=this.setColor(n,s,r),a=r-1/3,h=this.setColor(n,s,a);return e.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(l*255)},${Math.round(h*255)},${this._alpha*255})`),e.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(e,n,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=n+(e-n)*6*s:2*s<1?r=e:3*s<2?r=n+(e-n)*(2/3-s)*6:r=n,r}setLightness(e){this._lightness=e}}const Yt=class Yt extends be{constructor(n,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=n.match(Yt.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],l=+r[3],a=+r[4];this._cssString=n,this._red=i,this._green=o,this._blue=l,this._alpha=a;return}if(r=n.match(Yt.RGB_EXTRACT),r){const i=+r[1],o=+r[2],l=+r[3];this._cssString=n,this._red=i,this._green=o,this._blue=l,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return be.rgbColorToHexValue(this)}getRed(){let n=this._red+Yt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getGreen(){let n=this._green+Yt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getBlue(){let n=this._blue+Yt.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}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(n){return n instanceof Yt?n._red===this._red&&n._blue===this._blue&&n._green===this._green&&n._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 pn=Yt;const fe=class fe extends be{constructor(n,s,r,i){super(i);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=n,this._themeTint=s,this._themeColors=r}lumValue(n,s){if(n==null)return s;let r;return n<0?r=s*(1+n):r=s*(1-n)+(255-255*(1-n)),r}asRgbColor(){const n=fr[this._themeColors];if(n==null)throw new Error("not find themeColors type");const s=n[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(fe._cacheThemeColor.has(this._themeColors)){if(r=fe._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,fe._cacheThemeColor.set(this._themeColors,r);const i=new _r(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 fe(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(n){return n instanceof fe?n._themeColorType===this._themeColorType:!1}getColorType(){return zt.THEME}getThemeColorType(){return this._themeColorType}};_(fe,"_cacheThemeColor",new Map);let Rn=fe;const So="rgb(",No="rgba(",jn={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(e){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(e==null){this._setNullColor();return}if(e instanceof te){this._color={...e._color},this._rgbColor={...e._rgbColor};return}const n=gr(e);if(n==null){this._setNullColor();return}this._color=n;const s=To(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(e,n,s){var h,c;s=Math.min(1,Math.max(0,s));const r=new te(e).toRgb(),i=new te(n).toRgb(),o=(h=r.a)!=null?h:1,l=(c=i.a)!=null?c:1,a={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(l-o)*s+o};return new te(a)}static getContrastRatio(e,n){const s=new te(e).getLuminance(),r=new te(n).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:e,g:n,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${e},${n},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(e){const{r:n,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,l=[sn(Math.round(n).toString(16)),sn(Math.round(s).toString(16)),sn(Math.round(r).toString(16)),sn(Math.round(i*255).toString(16))];return e&&l[0][0]===l[0][1]&&l[1][0]===l[1][1]&&l[2][0]===l[2][1]&&l[3][0]===l[3][1]?o?`#${l[0][0]}${l[1][0]}${l[2][0]}${l[3][0]}`:`#${l[0][0]}${l[1][0]}${l[2][0]}`:o?`#${l[0]}${l[1]}${l[2]}${l[3]}`:`#${l[0]}${l[1]}${l[2]}`}toHsv(){return Do(this.toRgb())}toHsl(){return Uo(this.toRgb())}lighten(e=10){const n=this.toHsl();return n.l+=e,n.l=Math.min(Math.max(n.l,0),100),new te(n)}darken(e=10){const n=this.toHsl();return n.l-=e,n.l=Math.min(Math.max(n.l,0),100),new te(n)}setAlpha(e){return new te({...this._rgbColor,a:e})}getLuminance(){let{r:e,g:n,b:s}=this.toRgb();return e=xn(e),n=xn(n),s=xn(s),Number((.2126*e+.7152*n+.0722*s).toFixed(3))}getBrightness(){const{r:e,g:n,b:s}=this.toRgb();return(e*299+n*587+s*114)/1e3}getAlpha(){var e;return(e=this._color.a)!=null?e:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const sn=t=>t.length===1?`0${t}`:t,xn=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),gr=t=>{if(Po(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const n={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(n.a=t.a),n}const e=t.trim();if(jn[e]){const n=jn[e],s={r:Math.round(n[0]),g:Math.round(n[1]),b:Math.round(n[2])};return s.a=n[3]||1,s}if(e.startsWith("#"))return bo(e);if(e.startsWith("rgb"))return vo(e);if(e.startsWith("hsl"))return Ao(e);if(e.startsWith("hsv"))return wo(e)},bo=t=>{const e=t.substring(1),n=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let s=e.match(n);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},vo=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal rgb color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},Ao=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsl color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},wo=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsv color`);const n=t.substring(e+1,t.length-1).split(",");if(n.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(s.a=Number.parseFloat(n[3])),s},To=t=>{const e=gr(t);if(e!=null)return"r"in e?e:"l"in e?Lo(e):Mo(e)},kn=(t,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t),Lo=t=>{let{h:e,s:n,l:s}=t;e/=360,n/=100,s/=100;let r=0,i=0,o=0;if(n===0)r=i=o=s;else{const a=s<.5?s*(1+n):s+n-s*n,h=2*s-a;r=kn(h,a,e+1/3),i=kn(h,a,e),o=kn(h,a,e-1/3)}const l={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(l.a=t.a),l},Mo=t=>{let{h:e,s:n,v:s}=t;e=e/360*6,n/=100,s/=100;const r=Math.floor(e),i=e-r,o=s*(1-n),l=s*(1-i*n),a=s*(1-(1-i)*n),h=r%6,c=[s,l,o,o,a,s][h],u=[a,s,s,l,o,o][h],d=[o,o,a,s,s,l][h],f={r:c*255,g:u*255,b:d*255};return t.a!==void 0&&(f.a=t.a),f},Uo=t=>{let{r:e,g:n,b:s}=t;e/=255,n/=255,s/=255;const r=Math.max(e,n,s),i=Math.min(e,n,s),o=(r+i)/2;let l,a;if(r===i)l=a=0;else{const c=r-i;switch(a=o>.5?c/(2-r-i):c/(r+i),r){case e:l=(n-s)/c+(n<s?6:0);break;case n:l=(s-e)/c+2;break;default:l=(e-n)/c+4;break}l/=6}const h={h:Math.round(l*360),s:Math.round(a*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},Do=t=>{let{r:e,g:n,b:s}=t;e/=255,n/=255,s/=255;const r=Math.max(e,n,s),i=Math.min(e,n,s);let o;const l=r,a=r-i,h=r===0?0:a/r;if(r===i)o=0;else{switch(r){case e:o=(n-s)/a+(n<s?6:0);break;case n:o=(s-e)/a+2;break;default:o=(e-n)/a+4;break}o/=6}const c={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(l*100)};return t.a!==void 0&&(c.a=t.a),c},yo=t=>t==null,Po=t=>!yo(t)&&typeof t=="object";function xo(t){const e=/^#(?:[0]{3}|[0]{6})\b/,n=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(e.test(t)||n.test(t)||s.test(t)||r.test(t)||i.test(t))}function ko(t){const e=/^#(?:[Ff]{3}|[Ff]{6})\b/,n=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(e.test(t)||n.test(t)||s.test(t)||r.test(t)||i.test(t))}var xt=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(xt||{});function Ho(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 Fo(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return Ne.STRING;if(typeof t.v=="number")return Ne.NUMBER;if(typeof t.v=="boolean")return Ne.BOOLEAN}function Bo(t){if(t==null)return!0;const{v:e,f:n,si:s,p:r,s:i,custom:o}=t;return!(!(e==null||typeof e=="string"&&e.length===0)||n!=null&&n.length>0||s!=null&&s.length>0||r!=null||o!=null)}function $o(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var mr=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(mr||{}),Er=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Er||{}),We=(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))(We||{}),de=(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))(de||{}),pr=(t=>(t[t.HYPERLINK=0]="HYPERLINK",t[t.FIELD=1]="FIELD",t[t.SDT=2]="SDT",t[t.BOOKMARK=3]="BOOKMARK",t[t.COMMENT=4]="COMMENT",t[t.CUSTOM=5]="CUSTOM",t[t.MENTION=6]="MENTION",t))(pr||{}),Rr=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(Rr||{}),Cr=(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))(Cr||{}),Ir=(t=>(t[t.SECTION_TYPE_UNSPECIFIED=0]="SECTION_TYPE_UNSPECIFIED",t[t.CONTINUOUS=1]="CONTINUOUS",t[t.NEXT_PAGE=2]="NEXT_PAGE",t[t.EVEN_PAGE=3]="EVEN_PAGE",t[t.ODD_PAGE=4]="ODD_PAGE",t))(Ir||{}),Or=(t=>(t[t.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]="COLUMN_SEPARATOR_STYLE_UNSPECIFIED",t[t.NONE=1]="NONE",t[t.BETWEEN_EACH_COLUMN=2]="BETWEEN_EACH_COLUMN",t))(Or||{}),Sr=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Sr||{}),Nr=(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))(Nr||{}),br=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(br||{}),vr=(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))(vr||{}),Ar=(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))(Ar||{}),wr=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(wr||{}),Tr=(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))(Tr||{}),Lr=(t=>(t[t.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]="TAB_STOP_ALIGNMENT_UNSPECIFIED",t[t.START=1]="START",t[t.CENTER=2]="CENTER",t[t.END=3]="END",t))(Lr||{}),Mr=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(Mr||{}),Ur=(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))(Ur||{}),Dr=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Dr||{}),yr=(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))(yr||{}),Pr=(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))(Pr||{}),xr=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(xr||{}),kr=(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))(kr||{}),Hr=(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))(Hr||{}),Fr=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Fr||{}),Br=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Br||{}),$r=(t=>(t[t.forward=0]="forward",t[t.backward=1]="backward",t[t.front=2]="front",t[t.back=3]="back",t))($r||{}),Wr=(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))(Wr||{}),ut=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(ut||{}),bt=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(bt||{});function Wo(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}var is=(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))(is||{}),Gr=(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))(Gr||{}),jr=(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))(jr||{});const Go="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let jo=t=>crypto.getRandomValues(new Uint8Array(t)),Vo=(t,e,n)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*e/t.length);return(i=e)=>{let o="";for(;;){let l=n(r),a=r;for(;a--;)if(o+=t[l[a]&s]||"",o.length===i)return o}}},Ko=(t,e=21)=>Vo(t,e,jo),Yo=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Go[n[t]&63];return e};const zo=/^-ms-/,Xo=/-([a-z])/g,he=["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 D{static stringAt(e){let n="",s=e;for(;s>=he.length;)s/=he.length,s-=1,n+=he[s%he.length];const r=e%he.length;return n+=he[r],n}static indexAt(e){let n=0;for(let s=0;s<e.length-1;s+=1){const r=e.charCodeAt(s)-65,i=e.length-1-s;n+=he.length**i+he.length*r}return n+=e.charCodeAt(e.length-1)-65,n}static deleteBlank(e){return D.isString(e)?e.replace(/\s/g,""):e}static getSystemType(){const e=navigator.userAgent,n=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!n&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(n){if(e.indexOf("Windows NT 5.0")>-1||e.indexOf("Windows 2000")>-1)return"Windows 2000";if(e.indexOf("Windows NT 5.1")>-1||e.indexOf("Windows XP")>-1)return"Windows XP";if(e.indexOf("Windows NT 5.2")>-1||e.indexOf("Windows 2003")>-1)return"Windows 2003";if(e.indexOf("Windows NT 6.0")>-1||e.indexOf("Windows Vista")>-1)return"Windows Vista";if(e.indexOf("Windows NT 6.1")>-1||e.indexOf("Windows 7")>-1)return"Windows 7";if(e.indexOf("Windows NT 10")>-1||e.indexOf("Windows 10")>-1)return"Windows 10";if(e.indexOf("Windows NT 11")>-1||e.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const e=navigator.userAgent,n=e.indexOf("Opera")>-1,s=e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1&&!n,r=e.indexOf("Trident")>-1&&e.indexOf("rv:11.0")>-1,i=e.indexOf("Edge")>-1,o=e.indexOf("Firefox")>-1,l=e.indexOf("Safari")>-1&&e.indexOf("Chrome")===-1,a=e.indexOf("Chrome")>-1&&e.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(e);const c=Number.parseFloat(RegExp.$1);return c===7?"IE7":c===8?"IE8":c===9?"IE9":c===10?"IE10":"0"}return o?"FF":n?"Opera":l?"Safari":a?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(e=21,n){return n?Ko(n,e)():Yo(e)}static getClassName(e){return e.constructor.name}static deepMerge(e,...n){n.forEach(o=>o&&i(o));function s(o,l){o.forEach((a,h)=>{var c,u;if(D.isArray(a)){const d=(c=l[h])!=null?c:[];l[h]=d,s(a,d);return}if(D.isObject(a)){const d=(u=l[h])!=null?u:{};l[h]=d,r(a,d);return}l[h]=a})}function r(o,l){Object.keys(o).forEach(a=>{var c,u;const h=o[a];if(D.isObject(h)){const d=(c=l[a])!=null?c:{};l[a]=d,r(h,d);return}if(D.isArray(h)){const d=(u=l[a])!=null?u:[];l[a]=d,s(h,d);return}l[a]=h})}function i(o){Object.keys(o).forEach(l=>{var h,c;const a=o[l];if(D.isArray(a)){const u=(h=e[l])!=null?h:[];e[l]=u,s(a,u);return}if(D.isObject(a)){const u=(c=e[l])!=null?c:{};e[l]=u,r(a,u);return}e[l]=a})}return e}static numberFixed(e,n){return Number(Number(e).toFixed(n))}static diffValue(e,n){function s(o,l){const a=D.getValueType(o),h=D.getValueType(l);return a!==h?!1:D.isArray(o)?r(o,l):D.isObject(o)?i(o,l):D.isDate(o)?o.getTime()===l.getTime():D.isRegExp(o)?o.toString()===l.toString():o===l}function r(o,l){if(e.length!==n.length)return!1;for(let a=0,h=o.length;a<h;a++){const c=o[a],u=l[a];if(!s(c,u))return!1}return!0}function i(o,l){const a=Object.keys(o),h=Object.keys(l);if(a.length!==h.length)return!1;for(const c of a){if(!h.includes(c))return!1;const u=o[c],d=l[c];if(!s(u,d))return!1}return!0}return s(e,n)}static deepClone(e){if(!this.isDefine(e))return e;if(this.isRegExp(e))return new RegExp(e);if(this.isDate(e))return new Date(e);if(this.isArray(e)){const n=[];return e.forEach((s,r)=>{n[r]=D.deepClone(s)}),n}if(this.isObject(e)){const n={};return Object.keys(e).forEach(s=>{const r=e[s];n[s]=D.deepClone(r)}),Object.setPrototypeOf(n,Object.getPrototypeOf(e)),n}return e}static getLanguage(){const e="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||e}static getValueType(e){return Object.prototype.toString.apply(e)}static isDefine(e){return e!=null}static isBlank(e){return this.isDefine(e)?this.isString(e)?e.trim()==="":!1:!0}static isAssignableFrom(e,n){return e instanceof n}static isBoolean(e){return this.getValueType(e)==="[object Boolean]"}static isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}static isFunction(e){return this.getValueType(e)==="[object Function]"}static isDate(e){return this.getValueType(e)==="[object Date]"}static isRegExp(e){return this.getValueType(e)==="[object RegExp]"}static isArray(e){return this.getValueType(e)==="[object Array]"}static isString(e){return this.getValueType(e)==="[object String]"}static isNumber(e){return this.getValueType(e)==="[object Number]"}static isStringNumber(e){return!isNaN(Number.parseFloat(e))&&isFinite(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isEmptyObject(e){for(const n in e)return!1;return!0}static isMobile(){let e=0,n=0;return document.body.clientWidth&&(e=document.body.clientWidth),document.body.clientHeight&&(n=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||e<350&&n<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const e=navigator.userAgent.toLowerCase();return String(e.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const e=navigator.userAgent;return e.indexOf("Android")>-1||e.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static itCount(e){return n=>{for(let s=0;s<e;s++)n&&n()}}static hasLength(e,n){return D.isDefine(e)?D.isDefine(n)?e.length===n:e.length>0:!1}static capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}static fCamelCase(e,n){return n.toUpperCase()}static camelCase(e){return e.replace(zo,"ms-").replace(Xo,this.fCamelCase)}static removeNull(e){return this.isObject(e)&&Object.keys(e).forEach(n=>{const s=e[n];s==null?delete e[n]:D.removeNull(s)}),e}static fillTwoDimensionalArray(e,n,s){return new Array(e).fill(s).map(r=>new Array(n).fill(s))}static numToWord(e){let n="";for(;e>0;){let s=e%26;s=s===0?s=26:s,n=String.fromCharCode(96+s)+n,e=(e-s)/26}return n.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return Number.NaN;const n=e.toLowerCase().split(""),s=n.length;let r=0,i=0;for(let o=0;o<s;o++)i=n[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(e){let i="";for(;e>=0;)i=String.fromCharCode(e%26+97)+i,e=Math.floor(e/26)-1;return i.toUpperCase()}static randSort(e){for(let n=0,s=e.length;n<s;n++){const r=Number.parseInt((Math.random()*s).toString()),i=e[r];e[r]=e[n],e[n]=i}return e}static commonExtend(e,n){const s={};for(const r in e)s[r]=e[r];for(const r in n)n[r]!=null&&(s[r]=n[r]);return s}static commonExtend1(e,n){for(const s in e)n[s]==null&&(n[s]=e[s]);return n}static arrayToObject(e){const n={};return e.forEach((s,r)=>{n[r]={},s.forEach((i,o)=>{n[r][o]=i})}),n}static hasIntersectionBetweenTwoRanges(e,n,s,r){return n>=s&&r>=e}static isStartValidPosition(e){return/^[A-Za-z_]/.test(e)}static isValidParameter(e){const n=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),s=e.length<=255;return!n&&s}}function qo(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:l,startX:a,endX:h}=t,c=e,u=n,d=e,f=n;if(s&&i){const{startRow:m,startColumn:E,endRow:y,endColumn:P,startY:Z,endY:gt,startX:ht,endX:p}=i;c=m,u=E,d=y,f=P,o=Z,l=gt,a=ht,h=p}return r&&(o=i.startY,l=i.endY,a=i.startX,h=i.endX,d=i.endRow,f=i.endColumn),{startRow:c,startColumn:u,endRow:d,endColumn:f,startY:o,endY:l,startX:a,endX:h}}function Jo(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:l,endColumn:a}=t;let h=e,c=n,u=e,d=n;return(s||r)&&(h=i,c=o,u=l,d=a),{startRow:h,startColumn:c,endRow:u,endColumn:d}}function Zo(t){var n;return!t||(((n=t==null?void 0:t.v)==null?void 0:n.toString())||"").length===0&&!t.p}function re(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new Nn().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Qo(t){return D.isString(t)&&t.substring(0,1)==="="&&t.length>1}function tl(t){return D.isString(t)&&t.length>0}function el(t){return""}function nl(t,e=!1){var i;let n="";const s=new Map([["ff",()=>{t.ff&&(n+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),n+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(n+="font-style: italic; ")}],["bl",()=>{t.bl&&(n+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} underline`):n+="text-decoration-line: underline; ",t.ul.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${re(t.ul.cl)}; `),t.ul.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} line-through`):n+="text-decoration-line: line-through; ",t.st.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${re(t.st.cl)}; `),t.st.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(n.indexOf("text-decoration-line")>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(l,a)=>`${a} overline`):n+="text-decoration-line: overline; ",t.ol.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${re(t.ol.cl)}; `),t.ol.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(n+=`background: ${re(t.bg)}; `)}],["bd",()=>{var o,l,a,h,c,u,d,f,m,E,y,P;(o=t.bd)!=null&&o.b&&(n+=`border-bottom: ${rn((l=t.bd)==null?void 0:l.b.s)} ${(a=re(t.bd.b.cl))!=null?a:""}; `),(h=t.bd)!=null&&h.t&&(n+=`border-top: ${rn((c=t.bd)==null?void 0:c.t.s)} ${(u=re(t.bd.t.cl))!=null?u:""}; `),(d=t.bd)!=null&&d.r&&(n+=`border-right: ${rn((f=t.bd)==null?void 0:f.r.s)} ${(m=re(t.bd.r.cl))!=null?m:""}; `),(E=t.bd)!=null&&E.l&&(n+=`border-left: ${rn((y=t.bd)==null?void 0:y.l.s)} ${(P=re(t.bd.l.cl))!=null?P:""}; `)}],["cl",()=>{t.cl&&(n+=`color: ${re(t.cl)}; `)}],["va",()=>{t.va===Pe.SUBSCRIPT?n+="vertical-align: sub; ":t.va===Pe.SUPERSCRIPT&&(n+="vertical-align: super; ")}],["td",()=>{t.td===Ye.LEFT_TO_RIGHT?n+="direction: ltr; ":t.td===Ye.RIGHT_TO_LEFT&&(n+="direction: rtl; ")}],["tr",()=>{var o,l,a;t.tr&&(n+=`data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(l=t.tr)!=null&&l.v?` ,${(a=t.tr)==null?void 0:a.v}`:""});`)}],["ht",()=>{t.ht===Se.LEFT?n+="text-align: left; ":t.ht===Se.RIGHT?n+="text-align: right; ":t.ht===Se.CENTER?n+="text-align: center; ":t.ht===Se.JUSTIFIED&&(n+="text-align: justify; ")}],["vt",()=>{t.vt===ye.BOTTOM?n+="vertical-align: bottom; ":t.vt===ye.TOP?n+="vertical-align: top; ":t.vt===ye.MIDDLE&&(n+="vertical-align: middle; ")}],["tb",()=>{t.tb===ze.CLIP?n+="white-space: clip; ":t.tb===ze.WRAP&&(n+="white-space: normal;")}],["pd",()=>{var c,u,d,f,m,E,y,P;const o=`${(c=t.pd)==null?void 0:c.b}pt`,l=`${(u=t.pd)==null?void 0:u.t}pt`,a=`${(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&&(n+=`padding-bottom: ${o}; `),(E=t.pd)!=null&&E.t&&(n+=`padding-top: ${l}; `),(y=t.pd)!=null&&y.l&&(n+=`padding-left: ${a}; `),(P=t.pd)!=null&&P.r&&(n+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)e&&r.includes(o)||(i=s.get(o))==null||i();return n}function rn(t){let e="";return t===dt.NONE?e="none":t===dt.THIN?e="0.5pt solid":t===dt.HAIR?e="0.5pt double":t===dt.DOTTED?e="0.5pt dotted":t===dt.DASHED||t===dt.DASH_DOT?e="0.5pt dashed":t===dt.DASH_DOT_DOT?e="0.5pt dotted":t===dt.DOUBLE?e="0.5pt double":t===dt.MEDIUM?e="1pt solid":t===dt.MEDIUM_DASHED||t===dt.MEDIUM_DASH_DOT?e="1pt dashed":t===dt.MEDIUM_DASH_DOT_DOT?e="1pt dotted":t===dt.SLANT_DASH_DOT?e="0.5pt dashed":t===dt.THICK&&(e="1.5pt solid"),e}function sl(t){let e=0;if(t=t.trim(),t==="none")e=dt.NONE;else if(t==="0.5pt solid")e=dt.THIN;else if(t==="0.5pt double")e=dt.HAIR;else if(t==="0.5pt dotted")e=dt.DOTTED;else if(t==="0.5pt dashed")e=dt.DASHED;else if(t==="1pt solid")e=dt.MEDIUM;else if(t==="1pt dashed")e=dt.MEDIUM_DASHED;else if(t==="1pt dotted")e=dt.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")e=dt.THICK;else if(!t.includes("none"))e=dt.THIN;else return dt.NONE;return e}function rl(t,e){let n=t.body;if(e){const{headers:s,footers:r}=t;s!=null&&s[e]?n=s[e].body:r!=null&&r[e]&&(n=r[e].body)}return n}function il(t){const{startRow:e,endRow:n,startColumn:s,endColumn:r,rangeType:i}=t;return!(e<0||s<0||n<0||r<0||!(Number.isNaN(e)&&Number.isNaN(n))&&i===ut.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===ut.ROW)}function ol(t,e){return{startRow:t,endRow:t,startColumn:e,endColumn:e}}function os(t,e){return Object.prototype.toString.call(t)===Object.prototype.toString.call(e)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(n=>os(t[n],e[n])):t===e:!1}function Vr(t,e){const n=t.ts||{},s=e.ts||{};return t.sId!==e.sId?!1:os(n,s)}function ll(t,e){return e.some(n=>t.indexOf(n)>-1)}function ls(t,e,n,s){if(t>e&&([t,e]=[e,t]),n>s&&([n,s]=[s,n]),e<n||s<t)return[t,e];n<t&&(n=t),s>e&&(s=e);const r=s-n+1;let i=[];return t===n?i=[s+1-r,e-r]:e===s?i=[t,n-1]:i=[t,e-r],i}function al(t){if(t==null)return!1;const e=t.bullet;return(e==null?void 0:e.listId)!=null}function ul(t){if(t==null)return!1;const e=t.paragraphStyle;return Kr(e)}function Kr(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Yr(t,e,n){return t.slice(0,e)+n+t.slice(e)}function zr(t,e,n){return e>n?t:t.slice(0,e)+t.slice(n)}function cl(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function hl(t){let e=0;for(let n=0;n<t.length;n++)e=t.charCodeAt(n)+(e<<6)+(e<<16)-e;return e>>>0}function Ds(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],s=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ys(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var s=n.call(t),r,i=[],o;try{for(;(e===void 0||e-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(l){o={error:l}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function Ps(t,e,n){if(n||arguments.length===2)for(var s=0,r=e.length,i;s<r;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return t.concat(i||Array.prototype.slice.call(e))}function Ge(t){return typeof t=="function"}function dl(t){var e=function(s){Error.call(s),s.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Hn=dl(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
|
+
`+n.map(function(s,r){return r+1+") "+s.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function xs(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Xr=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var l=Ds(o),a=l.next();!a.done;a=l.next()){var h=a.value;h.remove(this)}}catch(E){e={error:E}}finally{try{a&&!a.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(Ge(c))try{c()}catch(E){i=E instanceof Hn?E.errors:[E]}var u=this._finalizers;if(u){this._finalizers=null;try{for(var d=Ds(u),f=d.next();!f.done;f=d.next()){var m=f.value;try{ks(m)}catch(E){i=i!=null?i:[],E instanceof Hn?i=Ps(Ps([],ys(i)),ys(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 Hn(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)ks(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&xs(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&xs(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();Xr.EMPTY;function fl(t){return t instanceof Xr||t&&"closed"in t&&Ge(t.remove)&&Ge(t.add)&&Ge(t.unsubscribe)}function ks(t){Ge(t)?t():t.unsubscribe()}class qr{constructor(e=!1){_(this,"skipNextObservers");_(this,"lastReturnValue");_(this,"isStopPropagation",!1);this.initialize(e)}initialize(e=!1){return this.skipNextObservers=e,this}stopPropagation(){this.isStopPropagation=!0}}function Jr(t){return t instanceof bn}class bn{constructor(e,n){this.callback=e,this.observable=n}dispose(){this.observable.remove(this)}}class vn{constructor(e){_(this,"_observers",new Array);_(this,"_eventState");_(this,"_onObserverAdded");this._eventState=new qr,e&&(this._onObserverAdded=e)}get observers(){return this._observers}add(e,n=!1){if(!e)return null;const s=new bn(e,this);return n?this._observers.unshift(s):this._observers.push(s),this._onObserverAdded&&this._onObserverAdded(s),s}remove(e){return e&&this._observers.indexOf(e)!==-1?(this._remove(e),!0):!1}makeObserverTopPriority(e){this._remove(e),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e),this._observers.push(e)}notifyObservers(e){if(!this._observers.length)return null;const n=this._eventState;n.skipNextObservers=!1,n.lastReturnValue=e,n.isStopPropagation=!1;let s=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(n.lastReturnValue=i.callback(e,n),n.isStopPropagation&&(s=!0),n.skipNextObservers)return{lastReturnValue:n.lastReturnValue,stopPropagation:s}}return{lastReturnValue:n.lastReturnValue,stopPropagation:s}}notifyObserversWithPromise(e){let n=Promise.resolve(e);if(!this._observers.length)return n;const s=this._eventState;s.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];s.skipNextObservers||(n=n.then(()=>i.callback(e,s)))}return n.then(()=>e)}notifyObserver(e,n){const s=this._eventState;return s.skipNextObservers=!1,e.callback(n,s),{lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers.forEach(e=>{e.dispose()}),this._observers=new Array,this._onObserverAdded=null}clone(){const e=new vn;return e._observers=this._observers.slice(0),e}_remove(e){if(!e)return!1;const n=this._observers.indexOf(e);return n!==-1?(this._observers.splice(n,1),!0):!1}}function vt(t){let e=!1;return t?fl(t)?{dispose:()=>t.unsubscribe()}:Jr(t)?{dispose:()=>{e||(e=!0,t.dispose())}}:typeof t=="function"?{dispose:()=>{e||(e=!0,t())}}:t:vt(()=>{})}function _l(t){return vt(()=>{t.unsubscribe()})}class as{constructor(){_(this,"_disposables",new Set)}add(e){const n=vt(e);return this._disposables.add(n),{dispose:()=>{n.dispose(),this._disposables.delete(n)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}}class yt{constructor(){_(this,"_disposed",!1);_(this,"_collection",new as)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class gl extends yt{constructor(){super(...arguments);_(this,"dispose$",new it.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class Be{static hasLength(e,n){return e.length===n}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)==="[object Object]"}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)==="[object Number]"}}function An(t,e){const n=t.indexOf(e);return n>-1?(t.splice(n,1),!0):!1}function ml(t){const e=new Set,n=[];for(const s of t)e.has(s)||(e.add(s),n.push(s));return n}function El(t,e){for(let n=t.length-1;n>-1;n--){const s=t[n];if(e(s,n))return s}return null}function pl(t,e){if(t.length===0)return t;const n=e%t.length;return t.slice(n).concat(t.slice(0,n))}function Rl(t,e){const n=new Map;return t.forEach(s=>{const r=e(s);let i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(s)}),n}const ct=Symbol("newer"),Ut=Symbol("older");class Zr{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ct],{done:!1,value:e.key}):{done:!0,value:void 0}}}class Qr{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ct],{done:!1,value:e.value}):{done:!0,value:void 0}}}class ti{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[ct],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}}var Xu,qu;class Vn{constructor(e,n){_(this,"key");_(this,"value");_(this,Xu);_(this,qu);this.key=e,this.value=n,this[ct]=void 0,this[Ut]=void 0}toJSON(){return{key:this.key,value:this.value}}}Xu=ct,qu=Ut;class ei{constructor(...e){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(Be.hasLength(e,1)){if(Be.isNumber(e[0])){const n=e[0];this._initialize(n,void 0);return}if(Be.isIterable(e[0])){const n=e[0];this._initialize(0,n);return}return}if(Be.hasLength(e,2)){const n=e[0],s=e[1];this._initialize(n,s)}}onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),vt(()=>An(this._onShiftListeners,e));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(e,n){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,n&&(this.assign(n),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[ct]&&(e===this.oldest&&(this.oldest=e[ct]),e[ct][Ut]=e[Ut]),e[Ut]&&(e[Ut][ct]=e[ct]),e[ct]=void 0,e[Ut]=this.newest,this.newest&&(this.newest[ct]=e),this.newest=e)}assign(e){let n,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=e[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new Vn(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),n?(n[ct]=o,o[Ut]=n):this.oldest=o,n=o,s--===0)throw new Error("overflow")}this.newest=n,this.size=this._keymap.size}set(e,n){let s=this._keymap.get(e);return s?(s.value=n,this._markEntryAsUsed(s),this):(this._keymap.set(e,s=new Vn(e,n)),this.newest?(this.newest[ct]=s,s[Ut]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const e=this.oldest;if(e)return this.oldest&&this.oldest[ct]?(this.oldest=this.oldest[ct],this.oldest[Ut]=void 0):(this.oldest=void 0,this.newest=void 0),e[ct]=e[Ut]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(n=>n(e)),[e.key,e.value]}get(e){const n=this._keymap.get(e);if(n)return this._markEntryAsUsed(n),n.value}has(e){return this._keymap.has(e)}find(e){const n=this._keymap.get(e);return n?n.value:void 0}delete(e){const n=this._keymap.get(e);if(n)return this._keymap.delete(n.key),n[ct]&&n[Ut]?(n[Ut][ct]=n[ct],n[ct][Ut]=n[Ut]):n[ct]?(n[ct][Ut]=void 0,this.oldest=n[ct]):n[Ut]?(n[Ut][ct]=void 0,this.newest=n[Ut]):this.oldest=this.newest=void 0,this.size--,n.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new Zr(this.oldest)}values(){return new Qr(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new ti(this.oldest)}forEach(e,n){typeof n!="object"&&(n=this);let s=this.oldest;for(;s;)e.call(n,s.value,s.key,this),s=s[ct]}toJSON(){const e=new Array(this.size);let n=0,s=this.oldest;for(;s;)e[n++]={key:s.key,value:s.value},s=s[ct];return e}toString(){let e="",n=this.oldest;for(;n;)e+=`${String(n.key)}:${n.value}`,n=n[ct],n&&(e+=" < ");return e}}function _e(t){let e=0;const n=Object.keys(t);for(const s of n){const r=Number(s);e=Math.max(e,r)}return e+1}function Kn(t,e,n){const s=_e(n),r=n;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=e}function Yn(t,e,n){const s=Object.keys(n).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+e?delete n[r]:n[r]!==void 0&&(n[r-e]=n[r],delete n[r])}function Cl(t,e){const n=t,s=Object.keys(n),r=s.length,i=e,o=Object.keys(i),l=o.length,a={};let h=0;for(let c=0;c<r;c++,h++){const u=s[c];a[h]=n[u]}for(let c=0;c<l;c++,h++){const u=o[c];a[h]=i[u]}return a}function Il(t,e,n){const s=n;if(_e(n)>0){const i={};let o=0;for(let l=t;l<=e;l++)s[l]&&(i[o]=s[l],o++);return i}return{}}function zn(t,e,n,s){const r=t>n;if(!r&&t+e>n)throw new Error("Invalid move operation");r?Ol(t,e,n,s):Sl(t,e,n,s)}function Ol(t,e,n,s){const r=s,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t-1;o>=n;o--){const l=r[o];r[o+e]=l,l===void 0&&delete r[o+e]}i.forEach((o,l)=>{r[n+l]=o,o===void 0&&delete r[n+l]})}function Sl(t,e,n,s){const r=s,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t+e;o<n;o++){const l=r[o];r[o-e]=l,l===void 0&&delete r[o-e]}i.forEach((o,l)=>{r[n+l-e]=o,o===void 0&&delete r[n+l-e]})}class ee{constructor(e={}){_(this,"_matrix");this._setOriginValue(e)}static MakeObjectMatrixSize(e){return new ee({[e-1]:{}})}getMatrix(){return this._matrix}forEach(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(e(i,o)===!1)return this}return this}forRow(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(e(i,Object.keys(o).map(a=>Number(a)))===!1)return this}return this}forValue(e){const n=this._matrix,s=Object.keys(n);for(const r of s){const i=Number(r),o=n[i];if(!o)continue;const l=Object.keys(o);for(const a of l){const h=Number(a),c=o[Number(a)];if(e(i,h,c)===!1)return this}}return this}swapRow(e,n){const s=this._matrix[e],r=this._matrix[n];this._matrix[e]=r,this._matrix[n]=s}getRow(e){return this._matrix[e]}getRowOrCreate(e){let n=this.getRow(e);return n==null&&(n={},this._matrix[e]=n),n}reset(){this._setOriginValue({})}hasValue(){const e=this._matrix,n=Object.keys(e);if(n.length===0)return!1;for(const s of n){const r=Number(s),i=e[r];if(Object.keys(i).length>0)return!0}return!1}getValue(e,n){var s,r;return(r=(s=this._matrix)==null?void 0:s[e])==null?void 0:r[n]}setValue(e,n,s){const r=this.getRowOrCreate(e);r[n]=s}deleteValue(e,n){var s,r;(r=(s=this._matrix)==null?void 0:s[e])==null||delete r[n]}realDeleteValue(e,n){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[e])==null||delete r[n],this.getRow(e)){const o=this.getRow(e);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[e])}}setRow(e,n){this._matrix[e]=n}moveRows(e,n,s){zn(e,n,s,this._matrix)}moveColumns(e,n,s){this.forEach((r,i)=>{zn(e,n,s,i)})}insertRows(e,n){for(let s=e;s<e+n;s++)Kn(s,{},this._matrix)}insertColumns(e,n){for(let s=e;s<e+n;s++)this.forEach((r,i)=>{Kn(s,void 0,i)})}removeRows(e,n){Yn(e,n,this._matrix)}removeColumns(e,n){this.forEach((s,r)=>{Yn(e,n,r)})}getFragment(e,n,s,r){const i=new ee;let o=0;for(let l=e;l<=n;l++){const a={};let h=0;for(let c=s;c<=r;c++){const u=this.getValue(l,c);a[h]=u,h++}i.setRow(o,a),o++}return i}getSlice(e,n,s,r){const i=new ee;for(let o=e;o<=n;o++)for(let l=s;l<=r;l++){const a=this.getValue(o,l);a&&i.setValue(o,l,D.deepClone(a))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return _e(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const l=this.getRow(o);if(l){const a=_e(l)-1;r=a>r?a:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const e=new Array;return this.forValue((n,s,r)=>{e.push(r)}),e}toArray(){const e=[];return this.forRow((n,s)=>{e[n]==null&&(e[n]=[]),s.forEach(r=>{e[n][r]=this.getValue(n,r)})}),e}toFullArray(){const e=this.getRange(),{endColumn:n,endRow:s}=e,r=[];for(let i=0;i<=s;i++){const o=Array(n+1).fill(void 0);r.push(o)}return this.forValue((i,o,l)=>{r[i][o]=l}),r}toJSON(){return this._matrix}clone(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getData(){const e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let e=0,n=0,s=!1,r=!1;const i=new ee;return this.forEach((o,l)=>{s||(s=!0,e=o),Object.keys(l).forEach(a=>{const h=Number(a);r?h<n&&(n=h):(r=!0,n=h);const c=this.getValue(o,h);i.setValue(o-e,h-n,c)})}),i.getData()}getDataRange(){let e=0,n=0,s=0,r=-1,i=!1,o=!1;return this.forEach((l,a)=>{if(i||(i=!0,e=l),a==null)return;const h=_e(a)-1;h>s&&(s=h),Object.keys(a).forEach(c=>{const u=Number(c);o?u<n&&(n=u):(o=!0,n=u)}),l>r&&(r=l)}),{startRow:e,startColumn:n,endRow:r,endColumn:s}}getDiscreteRanges(){const e=[];return this.forEach((n,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const l of e)if(n>=l.startRow&&n<=l.endRow+1&&i>=l.startColumn&&i<=l.endColumn+1){l.endRow=Math.max(n,l.endRow),l.endColumn=Math.max(i,l.endColumn),o=!0;break}o||e.push({startRow:n,endRow:n,startColumn:i,endColumn:i})})}),e}merge(e){this.forValue((n,s)=>{const r=e.getValue(n,s);r!=null&&this.setValue(n,s,r)})}_setOriginValue(e={}){this._matrix=e}}const ue=class ue{static clone(e){return e.rangeType!==void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}static equals(e,n){return e==null||n==null?!1:e.endRow===n.endRow&&e.endColumn===n.endColumn&&e.startRow===n.startRow&&e.startColumn===n.startColumn&&(e.rangeType===n.rangeType||e.rangeType===void 0&&n.rangeType===ut.NORMAL||n.rangeType===void 0&&e.rangeType===ut.NORMAL)}static intersects(e,n){if(e.rangeType===ut.ROW&&n.rangeType===ut.COLUMN||e.rangeType===ut.COLUMN&&n.rangeType===ut.ROW)return!0;if(e.rangeType===ut.ROW&&n.rangeType===ut.ROW)return e.startRow<=n.endRow&&e.endRow>=n.startRow;if(e.rangeType===ut.COLUMN&&n.rangeType===ut.COLUMN)return e.startColumn<=n.endColumn&&e.endColumn>=n.startColumn;const s=Math.floor(Number.MAX_SAFE_INTEGER/10),r=Number.isNaN(e.startRow)?0:e.startRow,i=Number.isNaN(e.endRow)?s:e.endRow,o=Number.isNaN(e.startColumn)?0:e.startColumn,l=Number.isNaN(e.endColumn)?s:e.endColumn,a=Number.isNaN(n.startRow)?0:n.startRow,h=Number.isNaN(n.endRow)?s:n.endRow,c=Number.isNaN(n.startColumn)?0:n.startColumn,u=Number.isNaN(n.endColumn)?s:n.endColumn,d=Math.abs(o+l-c-u),f=Math.abs(o-l)+Math.abs(c-u),m=Math.abs(r+i-a-h),E=Math.abs(r-i)+Math.abs(a-h);return d<=f&&m<=E}static getIntersects(e,n){const s=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,l=n.startRow,a=n.endRow,h=n.startColumn,c=n.endColumn;let u,d,f,m;if(l<=r)l>=s?d=l:d=s;else return null;if(a>=s)a>=r?m=r:m=a;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:ut.NORMAL}}static contains(e,n){return e.startRow<=n.startRow&&e.endRow>=n.endRow&&e.startColumn<=n.startColumn&&e.endColumn>=n.endColumn}static realContain(e,n){return ue.contains(e,n)&&(e.startRow<n.startRow||e.endRow>n.endRow||e.startColumn<n.startColumn||e.endColumn>n.endColumn)}static union(...e){return e.reduce((n,s)=>({startRow:Math.min(n.startRow,s.startRow),startColumn:Math.min(n.startColumn,s.startColumn),endRow:Math.max(n.endRow,s.endRow),endColumn:Math.max(n.endColumn,s.endColumn),rangeType:ut.NORMAL}),e[0])}static realUnion(...e){const n=e.some(i=>i.rangeType===ut.COLUMN),s=e.some(i=>i.rangeType===ut.ROW),r=ue.union(...e);return{startColumn:s?Number.NaN:r.startColumn,endColumn:s?Number.NaN:r.endColumn,startRow:n?Number.NaN:r.startRow,endRow:n?Number.NaN:r.endRow,rangeType:s?ut.ROW:n?ut.COLUMN:ut.NORMAL}}static subtract(e,n){if(n.startRow>e.endRow||n.endRow<e.startRow||n.startColumn>e.endColumn||n.endColumn<e.startColumn)return[e];const s=[];n.startRow>=e.startRow&&s.push({startRow:e.startRow,startColumn:e.startColumn,endRow:n.startRow-1,endColumn:e.endColumn}),n.endRow<=e.endRow&&s.push({startRow:n.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});const r=Math.max(e.startRow,n.startRow),i=Math.min(e.endRow,n.endRow);return n.startColumn>=e.startColumn&&s.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:n.startColumn-1}),n.endColumn<=e.endColumn&&s.push({startRow:r,startColumn:n.endColumn+1,endRow:i,endColumn:e.endColumn}),s.filter(l=>l.startRow<=l.endRow&&l.startColumn<=l.endColumn)}static hasIntersectionBetweenTwoBounds(e,n){return!(e.left>n.right||e.right<n.left||e.top>n.bottom||e.bottom<n.top)}};_(ue,"getRelativeRange",(e,n)=>({startRow:e.startRow-n.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-n.startColumn,endColumn:e.endColumn-e.startColumn})),_(ue,"getPositionRange",(e,n,s)=>({...s||{},startRow:s&&[bt.ROW,bt.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:e.startRow+n.startRow,endRow:s&&[bt.ROW,bt.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:e.endRow+e.startRow+n.startRow,startColumn:s&&[bt.COLUMN,bt.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:e.startColumn+n.startColumn,endColumn:s&&[bt.COLUMN,bt.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:e.endColumn+e.startColumn+n.startColumn})),_(ue,"moveHorizontal",(e,n=0,s=0)=>({...e,startColumn:e.startColumn+n,endColumn:e.endColumn+n+s})),_(ue,"moveVertical",(e,n=0,s=0)=>({...e,startRow:e.startRow+n,endRow:e.endRow+n+s})),_(ue,"moveOffset",(e,n,s)=>({...e,startRow:e.startRow+s,endRow:e.endRow+s,startColumn:e.startColumn+n,endColumn:e.endColumn+n}));let ge=ue;class Nl{constructor(e,n){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=e,this._keys=n,e.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(e){this._keys.forEach(n=>{const s=e[n],r=this._keyMaps.get(n)||new Map;r.set(s,e),this._keyMaps.set(n,r)})}getValue(e,n){const s=n||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(e))return i.get(e)}return null}hasValue(e){for(let n=0;n<this._keys.length;n++){const s=this._keyMaps.get(this._keys[n]);if(s!=null&&s.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,n,s){const r=this.getValue(e);r&&Object.keys(r).includes(n)&&(r[n]=s)}deleteValue(e){const n=this.getValue(e);if(n){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=n[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===n);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(e){var n;return[...((n=this._keyMaps.get(e))==null?void 0:n.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function Xn(t,e,n,s){return{forEach(r){for(let i=t;i<=e;i++)for(let o=n;o<=s;o++)r(i,o)}}}function bl(t){if(t==null||t.length===0)return Number.NaN;const e=t.toLowerCase().split(""),n=e.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<n;o++)i=s(e[o]),r+=i*26**(n-o-1);return r===0?Number.NaN:r-1}const Cn=65,ni=90,vl=97;function Al(t){const e=ni-Cn+1;let n="";for(;t>=0;)n=String.fromCharCode(t%e+Cn)+n,t=Math.floor(t/e)-1;return n}function si(t,e){let n="";for(;e>0;)n+=t,e--;return n}function wl(t,e=!1){const n=ni-Cn+1;let s=vl;e&&(s=Cn);const r=String.fromCharCode(t%n+s),i=Math.floor(t/n)+1;return si(r,i)}function Tl(t,e){return t.zIndex>e.zIndex?1:t.zIndex===e.zIndex?0:-1}function Ll(t,e){return t.zIndex>e.zIndex?-1:t.zIndex===e.zIndex?0:1}function ke(t="index",e=1){return(n,s)=>n[t]>s[t]?e:n[t]===s[t]?0:-e}function Ml(t,e){let n;return function(...s){const r=this,i=function(){n=null,t.apply(r,s)};clearTimeout(n),n=setTimeout(i,e)}}function cn(t,e,n){const{dataStream:s,textRuns:r=[]}=t;let i=e;const o=[];for(const l of r){const{st:a,ed:h}=l;D.hasIntersectionBetweenTwoRanges(e,n,a,h)&&(a>i?(o.push(s.slice(i,a)),o.push(qn(s,{...l,ed:Math.min(h,n)}))):o.push(qn(s,{...l,st:i,ed:Math.min(h,n)}))),i=Math.max(e,Math.min(h,n))}return i!==n&&o.push(s.slice(i,n)),o.join("")}function Ul(t,e=!0){var n;if(e&&((n=t.paragraphs)!=null&&n.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const l of r){const{startIndex:a,paragraphStyle:h={}}=l,{spaceAbove: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}`),a>o+1?i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}>${cn(t,o+1,a)}</p>`:i+=`<p class="UniverNormal" ${f.length?`style="${f.join("; ")};"`:""}></p>`,o=a}return o!==s.length&&(i+=cn(t,o,s.length)),i}else return cn(t,0,t.dataStream.length)}function qn(t,e){const{st:n,ed:s,ts:r={}}=e,{ff:i,fs:o,it:l,bl:a,ul:h,st:c,ol:u,bg:d,cl:f,va:m}=r;let E=t.slice(n,s);const y=[];return l===q.TRUE&&(E=`<i>${E}</i>`),m===Pe.SUPERSCRIPT?E=`<sup>${E}</sup>`:m===Pe.SUBSCRIPT&&(E=`<sub>${E}</sub>`),(h==null?void 0:h.s)===q.TRUE&&(E=`<u>${E}</u>`),(c==null?void 0:c.s)===q.TRUE&&(E=`<s>${E}</s>`),a===q.TRUE&&(E=`<strong>${E}</strong>`),i&&y.push(`font-family: ${i}`),f&&y.push(`color: ${f.rgb}`),o&&y.push(`font-size: ${o}pt`),u&&y.push("text-decoration: overline"),d&&y.push(`background: ${d.rgb}`),y.length?`<span style="${y.join("; ")};">${E}</span>`:E}const $e={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Dl={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},yl={startRow:0,startColumn:0,endRow:0,endColumn:0},Pl={row:0,column:0},hn={ff:"Arial",fs:11,it:q.FALSE,bl:q.FALSE,ul:{s:q.FALSE},st:{s:q.FALSE},ol:{s:q.FALSE},tr:{a:0,v:q.FALSE},td:Ye.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Se.UNSPECIFIED,vt:ye.UNSPECIFIED,tb:ze.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},ri={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var ii=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(ii||{});function on(t,e){const{textRuns:n=[]}=e;let s=0;for(const i of n){const{ts:o={},st:l,ed:a}=i;if(o[t]==null)return q.FALSE;switch(t){case"bl":case"it":{if(o[t]===q.FALSE)return q.FALSE;break}case"ul":case"st":{if(o[t].s===q.FALSE)return q.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=a-l}return e.dataStream.indexOf(`\r
|
|
4
|
+
`)===s?q.TRUE:q.FALSE}class ve{constructor(e,n,s){_(this,"_range");_(this,"_worksheet");this._deps=s,this._range=n,this._worksheet=e}static foreach(e,n){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=e;for(let l=s;l<=i;l++)for(let a=r;a<=o;a++)n(l,a)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=[];for(let o=e;o<=n;o++){const l=[];for(let a=s;a<=r;a++)l.push(this.getMatrix().getValue(o,a)||null);i.push(l)}return i}getMatrix(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new ee;for(let l=e;l<=n;l++)for(let a=s;a<=r;a++)o.setValue(l,a,i.getValue(l,a)||null);return o}getMatrixObject(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new ee;for(let l=e;l<=n;l++)for(let a=s;a<=r;a++)o.setValue(l-e,a-s,i.getValue(l,a)||{});return o}getA1Notation(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=D.numToWord(s+1)+(e+1),o=D.numToWord(r+1)+(n+1)):(i=D.numToWord(r+1)+(n+1),o=D.numToWord(s+1)+(e+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>{var i;const r=e.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||hn.bg.rgb}))}getCell(e,n){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,l={startRow:s+e,endRow:s+e,startColumn:i+n,endColumn:i+n};return new ve(this._worksheet,l,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){var l;const{startRow:n,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(n,s,r,i).getData();if(e.isIncludeStyle){const a=this._deps.getStyles();for(let h=0;h<=s-n;h++)for(let c=0;c<=i-r;c++){if(o==null||((l=o==null?void 0:o[h])==null?void 0:l[c])==null)continue;const u=o[h][c].s;u&&(o[h][c].s=a.get(u))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>{var i;const r=e.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||hn.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?on("ul",e.body)===q.TRUE?{s:q.TRUE}:{s:q.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?on("st",e.body)===q.TRUE?{s:q.TRUE}:{s:q.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var n,s;const e=((n=this.getValue())==null?void 0:n.p)||{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?e.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...e.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?on("it",e.body)===q.TRUE?mn.ITALIC:mn.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var n,s;const{p:e}=(n=this.getValue())!=null?n:{};return e&&Array.isArray((s=e.body)==null?void 0:s.textRuns)&&e.body.textRuns.length>0?on("bl",e.body)===q.TRUE?En.BOLD:En.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:e,_worksheet:n}=this,{startRow:s,endRow:r}=e;let i=0;for(let o=0;o<=r-s;o++){const l=n.getRowHeight(o);i+=l}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:e,endColumn:n}=this._range;return n-e+1}getNumRows(){const{startRow:e,endRow:n}=this._range;return n-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(n=>(n==null?void 0:n.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(s=>e.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:e,_worksheet:n}=this,{startColumn:s,endColumn:r}=e;let i=0;for(let o=0;o<=r-s;o++)i+=n.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(e){ve.foreach(this._range,e)}_getStyles(e){const n=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=n&&n.getStyleByCell(r);return i&&i[e]||hn[e]}))}}function xl(t,e){if(t.length===0||t[0].length===0)return null;const n=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let l=0;l<t[0].length;l++)n[l]=e(t[i][l])?n[l]+1:0;const o=kl(n);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function kl(t){const e=[];let n=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(e.length===0||t[r]>=t[e[e.length-1]])e.push(r++);else{const i=t[e.pop()],o=e.length===0?r:r-e[e.length-1]-1;i*o>n&&(n=i*o,s={area:n,height:i,start:e.length===0?0:e[e.length-1]+1,end:r-1})}for(;e.length>0;){const i=t[e.pop()],o=e.length===0?r:r-e[e.length-1]-1;i*o>n&&(n=i*o,s={area:n,height:i,start:e.length===0?0:e[e.length-1]+1,end:r-1})}return s}function Hl(t,e){ve.foreach(e,(n,s)=>{t[n][s]=void 0})}function Fl(t,e){const n=t.toFullArray(),s=[];for(;;){const r=xl(n,e);if(!r)break;s.push(r),Hl(n,r)}return s}function Bl(t,e,n,s=!1){let r={...t};const i=r.startAbsoluteRefType||bt.NONE,o=r.endAbsoluteRefType||bt.NONE;return!s&&i===bt.ALL&&o===bt.ALL?r:s||i===bt.NONE&&o===bt.NONE?ge.moveOffset(r,e,n):(i===bt.NONE?r={...r,startRow:r.startRow+n,startColumn:r.startColumn+e}:i===bt.COLUMN?r={...r,startRow:r.startRow+n}:i===bt.ROW&&(r={...r,startColumn:r.startColumn+e}),o===bt.NONE?r={...r,endRow:r.endRow+n,endColumn:r.endColumn+e}:o===bt.COLUMN?r={...r,endRow:r.endRow+n}:o===bt.ROW&&(r={...r,endColumn:r.endColumn+e}),r)}async function oi(t){for(const[e,n]of t.entries())try{if(!await n())return{index:e,result:!1}}catch(s){return{index:e,result:!1,error:s}}return{result:!0,index:-1}}function li(t){for(const[e,n]of t.entries())try{if(!n())return{index:e,result:!1}}catch(s){return{index:e,result:!1,error:s}}return{result:!0,index:-1}}const Je=at.createIdentifier("univer.context-service");class ai extends yt{constructor(){super(...arguments);_(this,"_contextChanged$",new it.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(n){var s;return(s=this._contextMap.get(n))!=null?s:!1}setContextValue(n,s){this._contextMap.set(n,s),this._contextChanged$.next({[n]:s})}subscribeContextValue$(n){return new it.Observable(s=>{const r=this._contextChanged$.pipe(it.filter(i=>typeof i[n]<"u")).subscribe(i=>s.next(i[n]));return this._contextMap.has(n)&&s.next(this._contextMap.get(n)),()=>r.unsubscribe()})}}var ui=(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))(ui||{});const Ee=at.createIdentifier("univer.log");class ci extends yt{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...n){this._logLevel>=4&&this._log(console.debug,...n)}log(...n){this._logLevel>=3&&this._log(console.log,...n)}warn(...n){this._logLevel>=2&&this._log(console.warn,...n)}error(...n){this._logLevel>=1&&this._log(console.error,...n)}setLogLevel(n){this._logLevel=n}_log(n,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?n(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):n(...s)}}var $l=Object.defineProperty,Wl=Object.getOwnPropertyDescriptor,Gl=(t,e,n,s)=>{for(var r=s>1?void 0:s?Wl(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&$l(e,n,r),r},Hs=(t,e)=>(n,s)=>e(n,s,t),Ze=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(Ze||{});const Qe=at.createIdentifier("anywhere.command-service");class jl{constructor(){_(this,"_commands",new Map);_(this,"_commandTypes",new Map)}registerCommand(e){if(this._commands.has(e.id))throw new Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),vt(()=>{var n;this._commands.delete(e.id),this._commandTypes.delete(e.id),(n=e.onDispose)==null||n.call(e)})}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}}const hi={id:"nil",type:0,handler:()=>!0};exports.CommandService=class{constructor(e,n){_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=e,this._logService=n,this._commandRegistry=new jl,this._registerCommand(hi)}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),vt(()=>{const n=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(n,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),vt(()=>{const n=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(n,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,n,s){const r=this._commandRegistry.getCommand(e);if(r){const[i]=r,o={id:i.id,type:i.type,params:n},l=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(h=>h(o,s));const a=await this._execute(i,n,s);return this._commandExecutedListeners.forEach(h=>h(o,s)),l.dispose(),a}throw new Error(`[CommandService]: command "${e}" is not registered.`)}syncExecuteCommand(e,n,s){var i;const r=this._commandRegistry.getCommand(e);if(r){const[o]=r,l={id:o.id,type:o.type,params:n};if(o.type===2){const c=El(this._commandExecutionStack,u=>u.type===0);c&&(l.params=(i=l.params)!=null?i:{},l.params.trigger=c.id)}const a=this._pushCommandExecutionStack(l);this._beforeCommandExecutionListeners.forEach(c=>c(l,s));const h=this._syncExecute(o,n,s);return this._commandExecutedListeners.forEach(c=>c(l,s)),a.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),vt(()=>An(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const n=this._commandRegistry.getCommand(e.id);let s;if(n){if(n[0].multi!==!0)throw new Error("Command has registered as a single command.");s=n[0]}else{const i=new as;s=new Vl(e.id),i.add(this._commandRegistry.registerCommand(s)),i.add(vt(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,i)}const r=s.registerImplementation(e);return vt(()=>{var i;r.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(e.id))==null||i.dispose()})}async _execute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,n,s),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,n,s),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}};exports.CommandService=Gl([Hs(0,at.Inject(at.Injector)),Hs(1,Ee)],exports.CommandService);class Vl{constructor(e){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(e,n)=>{if(!this._implementations.length)return!1;const s=e.get(Ee),r=e.get(Je),i=e.get(at.Injector);for(const o of this._implementations){const l=o.command.preconditions;if((!l||l&&l(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,n)))return!0}return!1});this.id=e,this.name=e}registerImplementation(e){const n={command:e};return this._implementations.push(n),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),vt(()=>{var r;const s=this._implementations.indexOf(n);this._implementations.splice(s,1),(r=e.onDispose)==null||r.call(e)})}hasImplementations(){return this._implementations.length>0}}function us(t,e,n){const s=t.map(r=>()=>e.syncExecuteCommand(r.id,r.params,n));return li(s)}function Kl(t,e,n){const s=t.map(r=>()=>e.executeCommand(r.id,r.params,n));return oi(s)}function di(t){return new it.Observable(e=>{const n=t((...s)=>e.next(s));return()=>n==null?void 0:n.dispose()})}const Yl=t=>new Promise(e=>{it.merge(di(t.onCommandExecuted).pipe(un.filter(([n])=>n.type===Ze.MUTATION)),it.timer(300)).pipe(un.debounceTime(16),un.first()).subscribe(()=>{e()})});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.CHANGESET_REVISION_CONFILICT=5001]="CHANGESET_REVISION_CONFILICT",t[t.SNAPSHOT_INVALID_SNAPSHOT=6001]="SNAPSHOT_INVALID_SNAPSHOT",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.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Xt||{});function fi(t){return!!(t&&t.code&&t.code!==Xt.OK&&t.code!=="OK")}var et=(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))(et||{}),Ft=(t=>(t[t.Reader=0]="Reader",t[t.Editor=1]="Editor",t[t.Owner=2]="Owner",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t))(Ft||{}),dn=(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))(dn||{});class wn extends yt{}class cs{constructor(){_(this,"_data",[])}static create(){return new cs}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){const n=this._data.indexOf(e);this._data.splice(n,1)}getData(){return this._data}}class hs{constructor(){_(this,"_data",new Map)}static create(){return new hs}add(e,n){this._data.has(e)||this._data.set(e,n)}delete(e){this._data.delete(e)}getData(){return this._data}}var In=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(In||{});const zl={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:de.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:de.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:de.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:de.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:We.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:de.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:We.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:de.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:We.DECIMAL,hanging:21,indentStart:63}]}};var _i=(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))(_i||{}),ds=(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))(ds||{});function fs(t){const e=[];for(const n of t){const{ed:s,ts:r}=n;if(n.sId===void 0&&delete n.sId,D.isEmptyObject(r)&&n.sId==null)continue;if(e.length===0){e.push(n);continue}const i=e.pop();Vr(n,i)&&D.hasIntersectionBetweenTwoRanges(i.st,i.ed,n.st,n.ed)?e.push({...n,st:i.st,ed:s}):e.push(i,n)}return e}function gi(t,e,n,s){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let l=!1;const a=(h=e.textRuns)!=null?h:[];if(a.length)for(const c of a)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(l)u.st+=n,u.ed+=n,i.push(u);else{l=!0,u.ed+=n;const E=[];if(a.length){const y={...u,st:f,ed:a[0].st};y.ed>y.st&&E.push(y),E.push(...a);const P=a[a.length-1],Z={...u,st:P.ed,ed:m+n};Z.ed>Z.st&&E.push(Z)}else E.push(u);i.push(...E)}}else u.st+=n,u.ed+=n,l||(l=!0,i.push(...a)),i.push(u)}l||(l=!0,i.push(...a)),t.textRuns=fs(i)}function _s(t,e,n,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,l=[];let a=-1;for(let c=0,u=r.length;c<u;c++){const d=r[c],{startIndex:f}=d;f>=s&&(d.startIndex+=n),a===-1&&f>=s&&(a=c),l.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=l.indexOf(f)}if(o===ds.PARAGRAPH&&i.length===1){const c=r[a],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(ke("startIndex"))}}function Xl(t,e,n,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h}=a;h>=s&&(a.startIndex+=n)}const i=e.sectionBreaks;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s}r.push(...i),r.sort(ke("startIndex"))}}function mi(t,e,n,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h}=a;h>=s&&(a.startIndex+=n)}const i=e.customBlocks;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s}r.push(...i),r.sort(ke("startIndex"))}}function gs(t,e,n,s){const{tables:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h,endIndex:c}=a;h>s?(a.startIndex+=n,a.endIndex+=n):c>=s-1&&(a.endIndex+=n)}const i=e.tables;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s,a.endIndex+=s}r.push(...i),r.sort(ke("startIndex"))}}function ql(t,e,n,s){const{customRanges:r}=t;if(r==null)return;for(let o=0,l=r.length;o<l;o++){const a=r[o],{startIndex:h,endIndex:c}=a;h>s?(a.startIndex+=n,a.endIndex+=n):c>=s-1&&(a.endIndex+=n)}const i=e.customRanges;if(i){for(let o=0,l=i.length;o<l;o++){const a=i[o];a.startIndex+=s,a.endIndex+=s}r.push(...i),r.sort(ke("startIndex"))}}function Ei(t,e,n){var l;const{textRuns:s}=t,r=n,i=n+e,o=[];if(r===i&&(s!=null&&s.find(a=>a.st===n&&a.ed===n))){const a=s.find(h=>h.st===n&&h.ed===n);return o.push({...a,st:a.st-n,ed:a.ed-n}),t.textRuns=(l=t.textRuns)==null?void 0:l.filter(h=>h!==a),o}if(s){const a=[];for(let h=0,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-=e):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-e,u.ed-=e):d>=i&&(u.st-=e,u.ed-=e);a.push(u)}t.textRuns=a}return o.length===0&&o.push({st:0,ed:e,ts:{}}),o}function pi(t,e,n){const{paragraphs:s}=t,r=n,i=n+e,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const c=s[a],{startIndex:u}=c;if(u>=r&&u<i){o.push({...c,startIndex:u-n});continue}else u>=i&&(c.startIndex-=e);l.push(c)}t.paragraphs=l}return o}function Ri(t,e,n){const{sectionBreaks:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const c=s[a],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-n});continue}else u>i&&(c.startIndex-=e);l.push(c)}t.sectionBreaks=l}return o}function Ci(t,e,n){const{customBlocks:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const c=s[a],{startIndex:u}=c;if(u>=r&&u<=i){o.push({...c,startIndex:u-n});continue}else u>i&&(c.startIndex-=e);l.push(c)}t.customBlocks=l}return o}function Ii(t,e,n){const{tables:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const c=s[a],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=d){o.push({...c,startIndex:u-n,endIndex:d-n});continue}else if(u<=r&&d>=i){const f=ls(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=e,c.endIndex-=e);l.push(c)}t.tables=l}return o}function Oi(t,e,n){const{customRanges:s}=t,r=n,i=n+e-1,o=[];if(s){const l=[];for(let a=0,h=s.length;a<h;a++){const c=s[a],{startIndex:u,endIndex:d}=c;if(r<=u&&i>=d){o.push({...c,startIndex:u-n,endIndex:d-n});continue}else if(u<=r&&d>=i){const f=ls(u,d,r,i);c.startIndex=f[0],c.endIndex=f[1]}else i<u&&(c.startIndex-=e,c.endIndex-=e);l.push(c)}t.customRanges=l}return o}function Jl(t,e,n,s,r){const i=Zl(t,e,n,s,r),o=Ql(t,e,n,s,r),l=ta(t,e,n,s,r),a=ea(t,e,n,s,r),h=na(t,e,n,s,r),c=sa(t,e,n,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:l,customBlocks:a,tables:h,customRanges:c}}function Zl(t,e,n,s,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const l=Ei(t,n,s);if(r!==xt.REPLACE){const a=Si(o,l,r);e.textRuns=a}return gi(t,e,n,s),l}function Si(t,e,n){if(e.length===0)return t;t=D.deepClone(t),e=D.deepClone(e);const s=[],r=t.length,i=e.length;let o=0,l=0,a=null;function h(){return a?(s.push(a),a=null,!0):!1}for(;o<r&&l<i;){const{st:f,ed:m,ts:E}=t[o],{st:y,ed:P,ts:Z,sId:gt}=e[l];let ht;if(n===xt.COVER?ht={...Z,...E}:ht={...E,...Z},m<y)h()||s.push(t[o]),o++;else if(P<f)h()||s.push(e[l]),l++;else{const p={st:Math.min(f,y),ed:Math.max(f,y),ts:f<y?{...E}:{...Z},sId:f<y?void 0:gt};p.ed>p.st&&s.push(p),s.push({st:Math.max(f,y),ed:Math.min(m,P),ts:ht,sId:gt}),m<P?(o++,e[l].st=m,e[l].st===e[l].ed&&l++):(l++,t[o].st=P,t[o].st===t[o].ed&&o++);const O={st:Math.min(m,P),ed:Math.max(m,P),ts:m<P?{...Z}:{...E},sId:m<P?gt:void 0};a=O.ed>O.st?O:null}}h();const c=s[s.length-1],u=t[r-1],d=e[i-1];return c.ed!==Math.max(u.ed,d.ed)&&(u.ed>d.ed?s.push(u):s.push(d)),fs(s)}function Ql(t,e,n,s,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const l=pi(t,n,s);if(r!==xt.REPLACE){const a=[];for(const h of o){const{startIndex:c,paragraphStyle:u,bullet:d}=h;let f=[];for(const m of l){const{startIndex:E,paragraphStyle:y,bullet:P}=m;let Z,gt;if(r===xt.COVER?(Z={...y,...u},gt={listId:"",listType:In.BULLET_LIST,nestingLevel:0,textStyle:{},...P,...d}):(Z={...u,...y},gt={listId:"",listType:In.BULLET_LIST,nestingLevel:0,textStyle:{},...d,...P}),c===E){f.push({startIndex:c,paragraphStyle:Z,bullet:gt});break}}a.push(...f),f=[]}e.paragraphs=a}return _s(t,e,n,s),l}function ta(t,e,n,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const l=Ri(t,n,s);if(r!==xt.REPLACE){const a=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of l){const{startIndex:f}=d;if(c===f){r===xt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}a.push(...u),u=[]}e.sectionBreaks=a}return _s(t,e,n,s),l}function ea(t,e,n,s,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const l=Ci(t,n,s);if(r!==xt.REPLACE){const a=[];for(const h of o){const{startIndex:c}=h;let u=[];for(const d of l){const{startIndex:f}=d;if(c===f){r===xt.COVER?u.push({...d,...h}):u.push({...h,...d});break}}a.push(...u),u=[]}e.customBlocks=a}return mi(t,e,n,s),l}function na(t,e,n,s,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const l=Ii(t,n,s);if(r!==xt.REPLACE){const a=[];for(const h of o){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of l){const{startIndex:m,endIndex:E}=f;if(m>=c&&E<=u){r===xt.COVER?d.push({...f,...h}):d.push({...h,...f});break}}a.push(...d),d=[]}e.tables=a}return gs(t,e,n,s),l}function sa(t,e,n,s,r){const{customRanges:i}=t,{tables:o}=e;if(i==null||o==null)return;const l=Oi(t,n,s);if(r!==xt.REPLACE){const a=[];for(const h of o){const{startIndex:c,endIndex:u}=h;let d=[];for(const f of l){const{startIndex:m,endIndex:E}=f;if(m>=c&&E<=u){r===xt.COVER?d.push({...f,...h}):d.push({...h,...f});break}}a.push(...d),d=[]}e.customRanges=a}return gs(t,e,n,s),l}function Xe(t,e,n,s=!1){const{dataStream:r,textRuns:i=[],paragraphs:o=[]}=t,l={dataStream:r.slice(e,n)},a=[];for(const c of i){const u=D.deepClone(c),{st:d,ed:f}=u;D.hasIntersectionBetweenTwoRanges(d,f,e,n)&&(e>=d&&e<=f?a.push({...u,st:e,ed:Math.min(n,f)}):n>=d&&n<=f?a.push({...u,st:Math.max(e,d),ed:n}):a.push(u))}a.length?l.textRuns=a.map(c=>{const{st:u,ed:d}=c;return{...c,st:u-e,ed:d-e}}):s&&(l.textRuns=[{st:0,ed:n-e,ts:{}}]);const h=[];for(const c of o){const{startIndex:u}=c;u>=e&&u<=n&&h.push(D.deepClone(c))}return h.length&&(l.paragraphs=h.map(c=>({...c,startIndex:c.startIndex-e}))),l}function Jn(t,e,n=xt.COVER){if(e.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:l=[]}=e,a=Si(o,r,n);a.length&&(s.textRuns=a);const h=[];let c=0,u=0;for(;c<i.length&&u<l.length;){const d=i[c],f=l[u],{startIndex:m}=d,{startIndex:E}=f;m===E?(h.push(D.deepMerge(d,f)),c++,u++):m<E?(h.push(D.deepClone(d)),c++):(h.push(D.deepClone(f)),u++)}return c<i.length&&h.push(...i.slice(c)),u<l.length&&h.push(...l.slice(u)),h.length&&(s.paragraphs=h),s}function ra(t){const{body:e}=t;if(e==null)return!0;const{textRuns:n=[],paragraphs:s=[]}=e;return n.length===0&&s.length===0}function ia(t=D.generateRandomId(6),e=Te.EN_US,n=""){return{id:t,locale:e,title:n,body:{dataStream:`\r
|
|
6
|
+
`,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:5,lineSpacing:1,spaceBelow:0}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}var $t=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function oa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Bt={},Ni={},ms={};Object.defineProperty(ms,"__esModule",{value:!0});function la(t,e){if(Array.isArray(e))return!1;for(let n in t)if(!Es(t[n],e[n]))return!1;for(let n in e)if(t[n]===void 0)return!1;return!0}function aa(t,e){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Es(t[n],e[n]))return!1;return!0}function Es(t,e){return t===e?!0:t===null||e===null||typeof t!="object"||typeof e!="object"?!1:Array.isArray(t)?aa(t,e):la(t,e)}ms.default=Es;var ps={};Object.defineProperty(ps,"__esModule",{value:!0});function Zn(t){if(t===null)return null;if(Array.isArray(t))return t.map(Zn);if(typeof t=="object"){const e={};for(let n in t)e[n]=Zn(t[n]);return e}else return t}ps.default=Zn;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 e(c,u){if(!c)throw new Error(u)}const n=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(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const 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-=n(d[m-1])?2:1;return u}}class o extends i{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let u;return this.container&&this.container.length>this.idx+1&&n(u=this.container[this.idx+1])?u:null}descendFirst(){let u=this.idx+1;if(!this.container||u>=this.container.length||n(this.container[u])&&u+1>=this.container.length)return!1;n(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(e(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:(e(!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 l extends i{constructor(u=null){super(u),this.pendingDescent=[],this._op=u}flushDescent(){e(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&&n(this.container[f])&&f++,e(f===this.container.length||!n(this.container[f])),f===this.container.length)this.container.push(d),this.idx=f;else if(this.container[f]===d)this.idx=f;else{if(!Array.isArray(this.container[f])){const 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&&(e(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&&n(this.container[u]))return this.container[u];{const d={};return this.container.splice(u,0,d),d}}write(u,d){const f=this.getComponent();e(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(e(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 y=0;y<u.length;y++){const P=u[y];typeof P=="string"||typeof P=="number"?(E++,this.descend(P)):Array.isArray(P)?this.mergeTree(P,d):typeof P=="object"&&d(P,this)}for(;E--;)this.ascend();this.lcIdx=this.parents.length===m?f:-1}at(u,d){this.descendPath(u),d(this);for(let f=0;f<u.length;f++)this.ascend();return this}writeAtPath(u,d,f){return this.at(u,()=>this.write(d,f)),this.reset(),this}writeMove(u,d,f=0){return this.writeAtPath(u,"p",f).writeAtPath(d,"d",f)}getPath(){const u=super.getPath();return u.push(...this.pendingDescent),u}}t.WriteCursor=l,t.writeCursor=()=>new l,t.readCursor=c=>new o(c);function a(c,u,d){let f,m;m=f=c?c.descendFirst():!1;function E(y){let P;for(;m;){const Z=P=c.getKey();if(y!=null){let gt=!1;if(u&&typeof Z=="number"&&(P=u(Z,c.getComponent()),P<0&&(P=~P,gt=!0)),s(P,y))return null;if(P===y&&!gt)return c}d&&typeof P=="number"&&d(P,c.getComponent()),m=c.nextSibling()}return null}return E.end=()=>{f&&c.ascend()},E}t.advancer=a;function h(c,u,d){let f,m,E,y;for(f=m=c&&c.descendFirst(),E=y=u&&u.descendFirst();f||E;){let P=f?c.getKey():null,Z=E?u.getKey():null;P!==null&&Z!==null&&(s(Z,P)?Z=null:P!==Z&&(P=null)),d(P==null?Z:P,P!=null?c:null,Z!=null?u:null),P!=null&&f&&(f=c.nextSibling()),Z!=null&&E&&(E=u.nextSibling())}m&&c.ascend(),y&&u.ascend()}t.eachChildOf=h})(Rs);var Cs={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConflictType=void 0,function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"}(t.ConflictType||(t.ConflictType={}))})(Cs);var Fn={},Oe={},Fs;function Is(){return Fs||(Fs=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.uniToStrPos=Oe.strPosToUni=void 0,Oe.strPosToUni=(t,e=t.length)=>{let n=0,s=0;for(;s<e;s++){const r=t.charCodeAt(s);r>=55296&&r<=57343&&(n++,s++)}if(s!==e)throw Error("Invalid offset - splits unicode bytes");return s-n},Oe.uniToStrPos=(t,e)=>{let n=0;for(;e>0;e--){const s=t.charCodeAt(n);n+=s>=55296&&s<=57343?2:1}return n}),Oe}var Bn={},Bs;function Qn(){return Bs||(Bs=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.uniSlice=t.dlen=t.eachOp=void 0;const e=Is(),n=p=>{if(!Array.isArray(p))throw Error("Op must be an array of components");let O=null;for(let A=0;A<p.length;A++){const Y=p[A];switch(typeof Y){case"object":if(typeof Y.d!="number"&&typeof Y.d!="string")throw Error("Delete must be number or string");if(t.dlen(Y.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(Y.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(Y>0))throw Error("Skip components must be >0");if(typeof O=="number")throw Error("Adjacent skip components should be combined");break}O=Y}if(typeof O=="number")throw Error("Op has a trailing skip")};function s(p,O){let A=0,Y=0;for(let tt=0;tt<p.length;tt++){const z=p[tt];switch(O(z,A,Y),typeof z){case"object":A+=t.dlen(z.d);break;case"string":Y+=e.strPosToUni(z);break;case"number":A+=z,Y+=z;break}}}t.eachOp=s;function r(p,O){const A=[],Y=l(A);return s(p,(tt,z,Gt)=>{Y(O(tt,z,Gt))}),u(A)}const i=p=>p,o=p=>r(p,i);t.dlen=p=>typeof p=="number"?p:e.strPosToUni(p);const l=p=>O=>{if(!(!O||O.d===0||O.d===""))if(p.length===0)p.push(O);else if(typeof O==typeof p[p.length-1])if(typeof O=="object"){const A=p[p.length-1];A.d=typeof A.d=="string"&&typeof O.d=="string"?A.d+O.d:t.dlen(A.d)+t.dlen(O.d)}else p[p.length-1]+=O;else p.push(O)},a=p=>typeof p=="number"?p:typeof p=="string"?e.strPosToUni(p):typeof p.d=="number"?p.d:e.strPosToUni(p.d);t.uniSlice=(p,O,A)=>{const Y=e.uniToStrPos(p,O),tt=A==null?1/0:e.uniToStrPos(p,A);return p.slice(Y,tt)};const h=(p,O,A)=>typeof p=="number"?A==null?p-O:Math.min(p,A)-O:t.uniSlice(p,O,A),c=p=>{let O=0,A=0;return{take:(z,Gt)=>{if(O===p.length)return z===-1?null:z;const St=p[O];let ft;if(typeof St=="number")return z===-1||St-A<=z?(ft=St-A,++O,A=0,ft):(A+=z,z);if(typeof St=="string"){if(z===-1||Gt==="i"||e.strPosToUni(St.slice(A))<=z)return ft=St.slice(A),++O,A=0,ft;{const Ct=A+e.uniToStrPos(St.slice(A),z);return ft=St.slice(A,Ct),A=Ct,ft}}else{if(z===-1||Gt==="d"||t.dlen(St.d)-A<=z)return ft={d:h(St.d,A)},++O,A=0,ft;{let Ct=h(St.d,A,A+z);return A+=z,{d:Ct}}}},peek:()=>p[O]}},u=p=>(p.length>0&&typeof p[p.length-1]=="number"&&p.pop(),p);function d(p,O,A){if(A!=="left"&&A!=="right")throw Error("side ("+A+") must be 'left' or 'right'");n(p),n(O);const Y=[],tt=l(Y),{take:z,peek:Gt}=c(p);for(let ft=0;ft<O.length;ft++){const Ct=O[ft];let Tt,jt;switch(typeof Ct){case"number":for(Tt=Ct;Tt>0;)jt=z(Tt,"i"),tt(jt),typeof jt!="string"&&(Tt-=a(jt));break;case"string":A==="left"&&typeof Gt()=="string"&&tt(z(-1)),tt(e.strPosToUni(Ct));break;case"object":for(Tt=t.dlen(Ct.d);Tt>0;)switch(jt=z(Tt,"i"),typeof jt){case"number":Tt-=jt;break;case"string":tt(jt);break;case"object":Tt-=t.dlen(jt.d)}break}}let St;for(;St=z(-1);)tt(St);return u(Y)}function f(p,O){n(p),n(O);const A=[],Y=l(A),{take:tt}=c(p);for(let Gt=0;Gt<O.length;Gt++){const St=O[Gt];let ft,Ct;switch(typeof St){case"number":for(ft=St;ft>0;)Ct=tt(ft,"d"),Y(Ct),typeof Ct!="object"&&(ft-=a(Ct));break;case"string":Y(St);break;case"object":ft=t.dlen(St.d);let Tt=0;for(;Tt<ft;)switch(Ct=tt(ft-Tt,"d"),typeof Ct){case"number":Y({d:h(St.d,Tt,Tt+Ct)}),Tt+=Ct;break;case"string":Tt+=e.strPosToUni(Ct);break;case"object":Y(Ct)}break}}let z;for(;z=tt(-1);)Y(z);return u(A)}const m=(p,O)=>{let A=0;for(let Y=0;Y<O.length&&p>A;Y++){const tt=O[Y];switch(typeof tt){case"number":{A+=tt;break}case"string":const z=e.strPosToUni(tt);A+=z,p+=z;break;case"object":p-=Math.min(t.dlen(tt.d),p-A);break}}return p},E=(p,O)=>typeof p=="number"?m(p,O):p.map(A=>m(A,O));function y(p,O,A){return r(p,(Y,tt)=>typeof Y=="object"&&typeof Y.d=="number"?{d:A.slice(O,tt,tt+Y.d)}:Y)}function P(p){return r(p,O=>{switch(typeof O){case"object":if(typeof O.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return O.d;case"string":return{d:O};case"number":return O}})}function Z(p){return r(p,O=>typeof O=="object"&&typeof O.d=="string"?{d:e.strPosToUni(O.d)}:O)}function gt(p){let O=!0;return s(p,A=>{typeof A=="object"&&typeof A.d=="number"&&(O=!1)}),O}function ht(p){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:u,normalize:o,checkOp:n,create(O=""){if(typeof O!="string")throw Error("Initial data must be a string");return p.create(O)},apply(O,A){n(A);const Y=p.builder(O);for(let tt=0;tt<A.length;tt++){const z=A[tt];switch(typeof z){case"number":Y.skip(z);break;case"string":Y.append(z);break;case"object":Y.del(t.dlen(z.d));break}}return Y.build()},transform:d,compose:f,transformPosition:m,transformSelection:E,isInvertible:gt,makeInvertible(O,A){return y(O,A,p)},stripInvertible:Z,invert:P,invertWithDoc(O,A){return P(y(O,A,p))},isNoop:O=>O.length===0}}t.default=ht}(Bn)),Bn}var ln={},$s;function ua(){if($s)return ln;$s=1,Object.defineProperty(ln,"__esModule",{value:!0});const t=Qn(),e=Is();function n(s,r){return{get:s,getLength(){return s().length},insert(i,o,l){const a=e.strPosToUni(s(),i);return r([a,o],l)},remove(i,o,l){const a=e.strPosToUni(s(),i);return r([a,{d:o}],l)},_onOp(i){t.eachOp(i,(o,l,a)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(a,o);break;case"object":const h=t.dlen(o.d);this.onRemove&&this.onRemove(a,h)}})},onInsert:null,onRemove:null}}return ln.default=n,n.provides={text:!0},ln}var Ws;function ca(){return Ws||(Ws=1,function(t){var e=$t&&$t.__createBinding||(Object.create?function(d,f,m,E){E===void 0&&(E=m),Object.defineProperty(d,E,{enumerable:!0,get:function(){return f[m]}})}:function(d,f,m,E){E===void 0&&(E=m),d[E]=f[m]}),n=$t&&$t.__setModuleDefault||(Object.create?function(d,f){Object.defineProperty(d,"default",{enumerable:!0,value:f})}:function(d,f){d.default=f}),s=$t&&$t.__importStar||function(d){if(d&&d.__esModule)return d;var f={};if(d!=null)for(var m in d)Object.hasOwnProperty.call(d,m)&&e(f,d,m);return n(f,d),f},r=$t&&$t.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(t,"__esModule",{value:!0}),t.type=t.remove=t.insert=void 0;const i=Is(),o=s(Qn()),l=r(ua()),a={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(a),c=Object.assign(Object.assign({},h),{api:l.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=Qn();Object.defineProperty(t,"makeType",{enumerable:!0,get:function(){return u.default}})}(Fn)),Fn}(function(t){var e=$t&&$t.__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 n=e(ms),s=e(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:P,checkValidOp:tt,normalize:z,apply:Gt,transformPosition:St,compose:ft,tryTransform:yn,transform:co,makeInvertible:jt,invert:Ct,invertWithDoc:uo,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,L)=>Ms(g,R,N,L)})};const l=g=>g?g.getComponent():null;function a(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(a(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(a(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,L=>{L.write("r",R),L.write("i",N)}).get(),t.editOp=(g,R,N,L=!1)=>r.writeCursor().at(g,b=>O(b,R,N,L)).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,y={};function P(g){let R=g.type?g.type:g;R.name&&(y[R.name]=R),R.uri&&(y[R.uri]=R)}const Z=g=>{const R=y[g];if(R)return R;throw Error("Missing type: "+g)};P(ca());const gt=(g,R)=>g+R;P({name:"number",apply:gt,compose:gt,invert:g=>-g,transform:g=>g});const ht=g=>g==null?null:g.et?Z(g.et):g.es?y["text-unicode"]:g.ena!=null?y.number:null,p=g=>g.es?g.es:g.ena!=null?g.ena:g.e,O=(g,R,N,L=!1)=>{const[b,T]=typeof R=="string"?[Z(R),R]:[R,R.name];!L&&b.isNoop&&b.isNoop(N)||(T==="number"?g.write("ena",N):T==="text-unicode"?g.write("es",N):(g.write("et",T),g.write("e",N)))};function A(g){o(typeof g=="number"),o(g>=0),o(g===(0|g))}function Y(g){typeof g=="number"?A(g):o(typeof g=="string")}function tt(g){if(g===null)return;const R=new Set,N=new Set,L=T=>{let G=!0,$=!1;for(let C in T){const S=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")A(S),o(!R.has(S)),R.add(S),o(T.r===void 0);else if(C==="d")A(S),o(!N.has(S)),N.add(S),o(T.i===void 0);else if(C==="e"||C==="es"||C==="ena"){o(!$),$=!0;const v=ht(T);o(v,"Missing type in edit"),v.checkValidOp&&v.checkValidOp(p(T))}}o(!G)},b=(T,G,$)=>{if(!Array.isArray(T))throw Error("Op must be null or a list");if(T.length===0)throw Error("Empty descent");G||Y(T[0]);let C=1,S=0,v=0;for(let w=0;w<T.length;w++){const W=T[w];if(o(W!=null),Array.isArray(W)){const j=b(W,!1);if(S){const I=typeof v,H=typeof j;I===H?o(v<j,"descent keys are not in order"):o(I==="number"&&H==="string")}v=j,S++,C=3}else typeof W=="object"?(o(C===1,`Prev not scalar - instead ${C}`),L(W),C=2):(o(C!==3),Y(W),o(r.isValidPathItem(W),"Invalid path key"),C=1)}return o(S!==1,"Operation makes multiple descents. Remove some []"),o(C===2||C===3),T[0]};b(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 z(g){let R=0,N=[];const L=r.writeCursor();return L.mergeTree(g,(b,T)=>{const G=ht(b);if(G){const C=p(b);O(T,G,G.normalize?G.normalize(C):C)}for(const C of["r","p","i","d"])if(b[C]!==void 0){const S=C==="p"||C==="d"?($=b[C],N[$]==null&&(N[$]=R++),N[$]):b[C];T.write(C,S)}var $}),L.get()}function Gt(g,R){if(tt(R),R===null)return g;const N=[];return function L(b,T){let G=b,$=0,C={root:b},S=0,v=C,w="root";function W(){for(;S<$;S++){let j=T[S];typeof j!="object"&&(o(m(v,w)),v=v[w]=h(v[w]),w=j)}}for(;$<T.length;$++){const j=T[$];if(Array.isArray(j)){const I=L(G,j);I!==G&&I!==void 0&&(W(),G=v[w]=I)}else if(typeof j=="object"){j.d!=null?(W(),G=f(v,w,N[j.d])):j.i!==void 0&&(W(),G=f(v,w,j.i));const I=ht(j);if(I)W(),G=v[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 L(b,T){const G=[];let $=0;for(;$<T.length;$++){const w=T[$];if(Array.isArray(w))break;typeof w!="object"&&(G.push(b),b=E(b,w))}for(let w=T.length-1;w>=$;w--)b=L(b,T[w]);for(--$;$>=0;$--){const w=T[$];if(typeof w!="object"){const W=G.pop();b=b===E(W,w)?W:b===void 0?d(W,w):(S=w,v=b,(C=h(C=W))[S]=v,C)}else c(w)&&(o(b!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(N[w.p]=b),b=void 0)}var C,S,v;return b}(g,R),R)}function St(g,R){g=g.slice(),tt(R);const N=r.readCursor(R);let L,b,T=!1;const G=[];for(let C=0;;C++){const S=g[C],v=N.getComponent();if(v&&(v.r!==void 0?T=!0:v.p!=null&&(T=!1,L=v.p,b=C)),C>=g.length)break;let w=0;const W=r.advancer(N,void 0,(I,H)=>{c(H)&&w++});G.unshift(W);const j=W(S);if(typeof S=="number"&&(g[C]-=w),!j)break}if(G.forEach(C=>C.end()),T)return null;const $=()=>{let C=0;if(L!=null){const S=N.getPath();C=S.length,g=S.concat(g.slice(b))}for(;C<g.length;C++){const S=g[C],v=l(N),w=ht(v);if(w){const I=p(v);w.transformPosition&&(g[C]=w.transformPosition(g[C],I));break}let W=0;const j=r.advancer(N,(I,H)=>u(H)?~(I-W):I-W,(I,H)=>{u(H)&&W++})(S);if(typeof S=="number"&&(g[C]+=W),!j)break}};return L!=null?N.eachDrop(null,C=>{C===L&&$()}):$(),g}function ft(g,R){if(tt(g),tt(R),g==null)return R;if(R==null)return g;let N=0;const L=r.readCursor(g),b=r.readCursor(R),T=r.writeCursor(),G=[],$=[],C=[],S=[],v=[],w=[],W=new Set;L.traverse(null,I=>{I.p!=null&&(C[I.p]=L.clone())}),b.traverse(null,I=>{I.d!=null&&(S[I.d]=b.clone())});const j=r.writeCursor();return function I(H,_t,lt,X,Et,ie,Pt,Lt){o(_t||lt);const pt=l(_t),Vt=l(lt),qt=!!Vt&&Vt.r!==void 0,pe=!!pt&&pt.i!==void 0,Kt=pt?pt.d:null,Wt=Vt?Vt.p:null,oe=(ie||qt)&&Wt==null;if(Wt!=null)X=S[Wt],Pt=$[Wt]=new r.WriteCursor;else if(Vt&&Vt.r!==void 0)X=null;else{const U=l(X);U&&U.d!=null&&(X=null)}const rt=l(X);if(Kt!=null)if(H=C[Kt],Lt=G[Kt]=new r.WriteCursor,oe)ie&&!qt&&Lt.write("r",!0);else{const U=v[Kt]=N++;Pt.write("d",U)}else if(pt&&pt.i!==void 0)H=null;else{const U=l(H);U&&U.p!=null&&(H=null)}let x;pe?(o(Et===void 0),x=pt.i):x=Et;const V=(Wt==null?!pe||ie||qt:x===void 0)?null:Pt.getComponent();if(Wt!=null){if(!(Et!==void 0||pe)){const U=Kt!=null?v[Kt]:N++;w[Wt]=U,Lt.write("p",U)}}else qt&&(pe||Et!==void 0||(Vt.r,Lt.write("r",Vt.r)));const k=oe?null:ht(pt),M=ht(rt);if((k||M)&&(k&&k.name,M&&M.name),k&&M){o(k===M);const U=p(pt),K=p(rt),wt=k.compose(U,K);O(Pt,k,wt),W.add(rt)}else k?O(Pt,k,p(pt)):M&&(O(Pt,M,p(rt)),W.add(rt));const F=typeof x=="object"&&x!=null;let nt=!1,st=0,ot=0,At=0,Nt=0,Rt=0;const Dt=r.advancer(X,(U,K)=>u(K)?Nt-U-1:U-Nt,(U,K)=>{u(K)&&Nt++}),Q=r.advancer(H,(U,K)=>c(K)?st-U-1:U-st,(U,K)=>{c(K)&&st++});if(r.eachChildOf(_t,lt,(U,K,wt)=>{let kt,le,Re=U,Jt=U,He=U;if(typeof U=="number"){let Mt=U+At;le=Dt(Mt),Jt=Mt+Nt;let It=U+ot;kt=Q(It),u(l(le))&&(kt=null),Re=It+st,He=U+Rt,o(Re>=0,"p1PickKey is negative"),o(Jt>=0,"p2DropKey is negative");const Zt=u(l(K)),ae=c(l(wt));(Zt||ae&&!oe)&&Rt--,Zt&&ot--,ae&&At--}else kt=Q(U),le=Dt(U);Lt.descend(Re),Pt.descend(Jt);const Me=F&&!u(l(K))?x[He]:void 0,ne=I(kt,K,wt,le,Me,oe,Pt,Lt);var se,B,mt;F&&!oe?Me!==ne&&(nt||(x=Array.isArray(x)?x.slice():Object.assign({},x),nt=!0),se=x,mt=ne,typeof(B=He)=="number"?(o(Array.isArray(se)),o(B<se.length)):(o(!Array.isArray(se)),o(se[B]!==void 0)),mt===void 0?typeof B=="number"?se.splice(B,1):delete se[B]:se[B]=mt):o(ne===void 0),Pt.ascend(),Lt.ascend()}),Q.end(),Dt.end(),V!=null)V.i=x;else if(!ie&&!qt&&Wt==null)return x}(L,L.clone(),b,b.clone(),void 0,!1,T,j),T.reset(),T.mergeTree(j.get()),T.reset(),T.get(),G.map(I=>I.get()),$.map(I=>I.get()),L.traverse(T,(I,H)=>{const _t=I.p;if(_t!=null){const lt=v[_t];lt!=null&&H.write("p",lt);const X=G[_t];X&&X.get(),X&&H.mergeTree(X.get())}else I.r!==void 0&&H.write("r",I.r)}),T.reset(),T.get(),b.traverse(T,(I,H)=>{const _t=I.d;if(_t!=null){const X=w[_t];X!=null&&H.write("d",X);const Et=$[_t];Et&&H.mergeTree(Et.get())}else I.i!==void 0&&H.write("i",I.i);const lt=ht(I);lt&&!W.has(I)&&O(H,lt,p(I))}),T.get()}function Ct(g){if(g==null)return null;const R=new r.ReadCursor(g),N=new r.WriteCursor;let L;const b=[],T=[];return function G($,C,S){const v=$.getComponent();let w,W=!1;if(v){v.p!=null&&(C.write("d",v.p),b[v.p]=$.clone()),v.r!==void 0&&C.write("i",v.r),v.d!=null&&(C.write("p",v.d),S=void 0),v.i!==void 0&&(S=w=v.i);const I=ht(v);I&&(S===void 0?(L||(L=new Set),L.add(v)):(p(v),S=I.apply(S,p(v)),W=!0))}let j=0;for(const I of $){C.descend(I);const H=typeof I=="number"?I-j:I,_t=E(S,H);u($.getComponent())&&j++;const lt=G($,C,_t);if(S!==void 0&<!==void 0){if(W||(W=!0,S=h(S)),!m(S,H))throw Error("Cannot modify child - invalid operation");S[H]=lt}C.ascend()}if(w===void 0)return W?S:void 0;C.write("r",S)}(R,N,void 0),L&&(N.reset(),function G($,C,S){const v=C.getComponent();if(v){const I=v.d;if(I!=null&&($=b[I],S=T[I]=r.writeCursor()),L.has(v)){const H=ht(v);if(!H.invert)throw Error(`Cannot invert subtype ${H.name}`);O(S,H,H.invert(p(v)))}}let w=0,W=0;const j=r.advancer($,(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-W,_t=j(H),lt=H+w;S.descend(lt),G(_t,C,S),u(C.getComponent())&&W++,S.ascend()}else S.descend(I),G(j(I),C,S),S.ascend();j.end()}(R.clone(),R,N),T.length&&(N.reset(),R.traverse(N,(G,$)=>{const C=G.p;if(C!=null){const S=T[C];S&&S.get(),S&&$.mergeTree(S.get())}}))),N.get()}const Tt=(g,R)=>g.some(N=>typeof N=="object"&&(Array.isArray(N)?Tt(N,R):R(N)));function jt(g,R){if(g==null||!Tt(g,C=>{var S;return C.r!==void 0||((S=ht(C))===null||S===void 0?void 0:S.makeInvertible)!=null}))return g;const N=new r.ReadCursor(g),L=new r.WriteCursor;let b=!1;const T=[],G=[],$=(C,S,v)=>{const w=C.getComponent();let W=!1;if(w){w.d!=null&&S.write("d",w.d),w.i!==void 0&&S.write("i",w.i);const I=w.p;if(I!=null&&(T[I]=C.clone(),o(v!==void 0,"Operation picks up at an invalid key"),G[I]=v,S.write("p",w.p)),w.r!==void 0&&v===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const H=ht(w);H&&(H.makeInvertible?b=!0:O(S,H,p(w),!0))}let j=0;for(const I of C){S.descend(I);const H=typeof I=="number"?I-j:I,_t=E(v,H),lt=$(C,S,_t);_t!==lt&&(W||(W=!0,v=h(v)),lt===void 0?(v=d(v,H),typeof I=="number"&&j++):v[H]=lt),S.ascend()}return w&&(w.r!==void 0?(S.write("r",s.default(v)),v=void 0):w.p!=null&&(v=void 0)),v};return $(N,L,R),L.get(),b&&(L.reset(),function C(S,v,w,W,j){const I=v.getComponent();if(I){I.i!==void 0?(W=I.i,j=!0):I.d!=null&&(W=G[I.d],S=T[I.d],j=!1,I.d);let X=ht(I);if(X&&X.makeInvertible){const Et=p(I);O(w,X,X.makeInvertible(Et,W),!0)}}let H=0,_t=0;const lt=r.advancer(S,(X,Et)=>c(Et)?H-X-1:X-H,(X,Et)=>{c(Et)&&H++});for(const X of v)if(typeof X=="number"){const Et=X-_t,ie=lt(Et),Pt=Et+H,Lt=E(W,j?Et:Pt);w.descend(X),C(ie,v,w,Lt,j),u(v.getComponent())&&_t++,w.ascend()}else{const Et=E(W,X);w.descend(X),C(lt(X),v,w,Et,j),w.ascend()}lt.end()}(N.clone(),N,L,R,!1)),L.get()}function uo(g,R){return Ct(jt(g,R))}const Dn=g=>{if(g==null)return null;const R=g.slice();for(let N=0;N<g.length;N++){const L=R[N];Array.isArray(L)&&(R[N]=Dn(L))}return R};function yn(g,R,N){o(N==="left"||N==="right","Direction must be left or right");const L=N==="left"?0:1;if(R==null)return{ok:!0,result:g};tt(g),tt(R);let b=null;const T=[],G=[],$=[],C=[],S=[],v=[],w=[],W=[],j=[],I=[],H=[],_t=[],lt=[],X=[],Et=[];let ie=0;const Pt=r.readCursor(g),Lt=r.readCursor(R),pt=r.writeCursor();if(function rt(x,V=null,k){const M=l(V);M&&(M.r!==void 0?k=V.clone():M.p!=null&&(k=null,v[M.p]=x.clone()));const F=x.getComponent();let nt;F&&(nt=F.p)!=null&&(S[nt]=V?V.clone():null,$[nt]=x.clone(),k&&(I[nt]=!0,j[nt]=k),M&&M.p!=null&&(X[nt]=M.p));const st=r.advancer(V);for(const ot of x)rt(x,st(ot),k);st.end()}(Lt,Pt,null),function rt(x,V,k,M,F){const nt=k.getComponent();let st,ot=!1;nt&&((st=nt.d)!=null?(C[st]=k.clone(),M!=null&&(Et[M]==null&&(Et[M]=[]),Et[M].push(st)),x=S[st]||null,V=$[st]||null,I[st]?(F&&(H[st]=!0),F=j[st]||null):!F||L!==1&&X[st]!=null||b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.moveOp(V.getPath(),k.getPath())}),ot=!0):nt.i!==void 0&&(x=V=null,ot=!0,F&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.insertOp(k.getPath(),nt.i)})));const At=l(x);At&&(At.r!==void 0?F=x.clone():At.p!=null&&(At.p,M=At.p,F=null));const Nt=ht(nt);Nt&&F&&b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.removeOp(F.getPath()),op2:t.editOp(k.getPath(),Nt,p(nt),!0)});let Rt=0,Dt=0;const Q=r.advancer(V,(K,wt)=>c(wt)?Rt-K-1:K-Rt,(K,wt)=>{c(wt)&&Rt++}),U=r.advancer(x);for(const K of k)if(typeof K=="number"){const wt=K-Dt,kt=Q(wt);Dt+=+rt(U(wt+Rt),kt,k,M,F)}else{const wt=Q(K);rt(U(K),wt,k,M,F)}return Q.end(),U.end(),ot}(Pt,Lt,Lt.clone(),null,null),C.map(rt=>rt&&rt.get()),b)return{ok:!1,conflict:b};H.map(rt=>!!rt);const Vt=[];let qt=null;(function rt(x,V,k,M,F){let nt=!1;const st=l(V);if(c(st)){const Q=st.p;Q!=null?(k=C[Q],M=_t[Q]=r.writeCursor(),nt=!0,F=null):(k=null,F=V.clone())}else u(l(k))&&(k=null);const ot=x.getComponent();if(ot){const Q=ot.p;Q!=null?(F&&(W[Q]=F),Vt[Q]=F||L===1&&nt?null:M.getComponent(),T[Q]=x.clone(),k&&(w[Q]=k.clone())):ot.r!==void 0&&(F||M.write("r",!0),(F||nt)&&(qt==null&&(qt=new Set),qt.add(ot)))}let At=0,Nt=0;const Rt=r.advancer(V,void 0,(Q,U)=>{c(U)&&At++}),Dt=r.advancer(k,(Q,U)=>u(U)?~(Q-Nt):Q-Nt,(Q,U)=>{u(U)&&Nt++});if(x)for(const Q of x)if(typeof Q=="string"){const U=Rt(Q),K=Dt(Q);M.descend(Q),rt(x,U,K,M,F),M.ascend()}else{const U=Rt(Q),K=Q-At,wt=c(l(U))?null:Dt(K),kt=K+Nt;o(kt>=0),M.descend(kt),rt(x,U,wt,M,F),M.ascend()}Rt.end(),Dt.end()})(Pt,Lt,Lt.clone(),pt,null),pt.reset();let pe=[];if(function rt(x,V,k,M,F,nt){o(V);const st=V.getComponent();let ot=l(M),At=!1;const Nt=(B,mt,Mt)=>B?t.moveOp(B.getPath(),mt.getPath()):t.insertOp(mt.getPath(),Mt.i);if(u(st)){const B=st.d;B!=null&&(G[B]=V.clone());const mt=B!=null?Vt[B]:null;let Mt=!1;if(st.i!==void 0||B!=null&&mt){let It;ot&&(ot.i!==void 0||(It=ot.d)!=null&&!I[It])&&(Mt=It!=null?B!=null&&B===X[It]:n.default(ot.i,st.i),Mt||It!=null&&L!==1&&X[It]!=null||b==null&&(b={type:i.ConflictType.DROP_COLLISION,op1:Nt(B!=null?T[B]:null,V,st),op2:Nt(It!=null?$[It]:null,M,ot)})),Mt||(nt?b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:Nt(B!=null?T[B]:null,V,st),op2:t.removeOp(nt.getPath())}):(B!=null?(pe[ie]=B,F.write("d",mt.p=ie++)):F.write("i",s.default(st.i)),At=!0))}else if(B!=null&&!mt){const It=W[B];It&&(nt=It.clone())}B!=null?(x=T[B],k=v[B],M=w[B]):st.i!==void 0&&(x=k=null,Mt||(M=null))}else c(l(x))&&(x=k=M=null);const Rt=l(x),Dt=l(k);if(c(Dt)){const B=Dt.p;Dt.r!==void 0&&(!Rt||Rt.r===void 0)||I[B]?(M=null,nt=k.clone()):B!=null&&(M=C[B],L!==1&&X[B]!=null||((F=lt[B])||(F=lt[B]=r.writeCursor()),F.reset(),nt=null))}else!u(st)&&u(ot)&&(M=null);ot=M!=null?M.getComponent():null;const Q=ht(st);if(Q){const B=p(st);if(nt)b==null&&(b={type:i.ConflictType.RM_UNEXPECTED_CONTENT,op1:t.editOp(V.getPath(),Q,B,!0),op2:t.removeOp(nt.getPath())});else{const mt=ht(ot);let Mt;if(mt){if(Q!==mt)throw Error("Transforming incompatible types");const It=p(ot);Mt=Q.transform(B,It,N)}else Mt=s.default(B);O(F,Q,Mt)}}let U=0,K=0,wt=0,kt=0,le=0,Re=0,Jt=x!=null&&x.descendFirst(),He=Jt;const Me=r.advancer(k,void 0,(B,mt)=>{c(mt)&&wt++});let ne=M!=null&&M.descendFirst(),se=ne;for(const B of V)if(typeof B=="number"){let mt;const Mt=u(V.getComponent()),It=B-K;{let ce;for(;Jt&&typeof(ce=x.getKey())=="number";){ce+=U;const Qt=x.getComponent(),Ue=c(Qt);if(ce>It||ce===It&&(!Ue||L===0&&Mt))break;if(Ue){U--;const Ce=Qt.p;X.includes(Ce),Qt.d,l(lt[Qt.d]),c(l(lt[Qt.d])),(Qt.r===void 0||qt&&qt.has(Qt))&&(Ce==null||!Vt[Ce]||L!==1&&X.includes(Ce))||le--}Jt=x.nextSibling()}mt=Jt&&ce===It?x:null}const Zt=It-U;let ae=Me(Zt);const Pn=Zt-wt;let en=null;{let ce,Qt;for(;ne&&typeof(ce=M.getKey())=="number";){Qt=ce-kt;const Ue=M.getComponent(),Ce=u(Ue);if(Qt>Pn)break;if(Qt===Pn){if(!Ce){en=M;break}{if(L===0&&Mt){en=M;break}const Ie=ae&&c(ae.getComponent());if(L===0&&Ie)break}}if(Ce){const Ie=Ue.d;X[Ie],Ue.i===void 0&&(I[Ie]||X[Ie]!=null&&L!==1)?(I[Ie]||X[Ie]!=null&&L===0)&&(kt++,Re--):kt++}ne=M.nextSibling()}}const Us=Pn+kt+le+Re;o(Us>=0,"trying to descend to a negative index"),F.descend(Us),Mt&&(mt=ae=en=null,K++),rt(mt,V,ae,en,F,nt)&&Re++,F.ascend()}else{let mt;for(;Jt&&(mt=x.getKey(),typeof mt!="string"||!(mt>B||mt===B));)Jt=x.nextSibling();const Mt=Jt&&mt===B?x:null,It=Me(B);let Zt;for(;ne&&(Zt=M.getKey(),typeof Zt!="string"||!(Zt>B||Zt===B));)ne=M.nextSibling();const ae=ne&&Zt===B?M:null;F.descend(B),rt(Mt,V,It,ae,F,nt),F.ascend()}return Me.end(),He&&x.ascend(),se&&M.ascend(),At}(Pt,Pt.clone(),Lt,Lt.clone(),pt,null),b)return{ok:!1,conflict:b};pt.reset();const Kt=(rt,x,V)=>rt.traverse(x,(k,M)=>{k.d!=null&&V(k.d,rt,M)});(I.length||_t.length)&&(Kt(Lt,pt,(rt,x,V)=>{I[rt]&&!H[rt]&&V.write("r",!0),_t[rt]&&V.mergeTree(_t[rt].get())}),pt.reset());const Wt=[],oe=[];if((lt.length||I.length)&&!b){const rt=r.readCursor(Dn(pt.get()));if(Kt(rt,null,(x,V)=>{Wt[x]=V.clone()}),lt.forEach(x=>{x&&Kt(r.readCursor(x.get()),null,(V,k)=>{Wt[V]=k.clone()})}),function x(V,k,M,F,nt,st){const ot=l(k);if(ot&&c(ot))if(ot.p!=null){const U=ot.p;Wt[U].getPath(),M=Wt[U],F=oe[U]=r.writeCursor()}else ot.r!==void 0&&(M=null);else u(l(M))&&(M=null);const At=V.getComponent();if(At){let U;if((U=At.d)!=null){const K=lt[U];K&&(K.get(),F.mergeTree(K.get()),M=r.readCursor(K.get()))}}let Nt=0,Rt=0;const Dt=r.advancer(k,void 0,(U,K)=>{c(K)&&Nt--}),Q=r.advancer(M,(U,K)=>u(K)?-(U-Rt)-1:U-Rt,(U,K)=>{u(K)&&Rt++});for(const U of V)if(typeof U=="number"){const K=Dt(U),wt=U+Nt,kt=Q(wt),le=wt+Rt;F.descend(le),x(V,K,kt,F),F.ascend()}else F.descend(U),x(V,Dt(U),Q(U),F),F.ascend();Dt.end(),Q.end()}(Lt,rt,rt.clone(),pt),pt.reset(),b)return{ok:!1,conflict:b};if(pt.get(),oe.length){const x=oe.map(k=>k?k.get():null),V=r.readCursor(Dn(pt.get()));if(Kt(V,pt,(k,M,F)=>{const nt=x[k];nt&&(F.mergeTree(nt),x[k]=null)}),x.find(k=>k)){const k=r.writeCursor(),M=r.writeCursor();let F=0,nt=0;x.forEach(st=>{st!=null&&Kt(r.readCursor(st),null,ot=>{const At=pe[ot];k.writeMove(T[At].getPath(),G[At].getPath(),F++);const Nt=Et[At];Nt&&Nt.forEach(Rt=>{I[Rt]||L!==1&&X[Rt]!=null||M.writeMove($[Rt].getPath(),C[Rt].getPath(),nt++)})})}),b={type:i.ConflictType.BLACKHOLE,op1:k.get(),op2:M.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:pt.get()}}const Ls=g=>{const R=new Error("Transform detected write conflict");throw R.conflict=g,R.type=R.name="writeConflict",R};function co(g,R,N){const L=yn(g,R,N);if(L.ok)return L.result;Ls(L.conflict)}const Le=g=>{const R=r.writeCursor();return r.readCursor(g).traverse(R,(N,L)=>{(u(N)||ht(N))&&L.write("r",!0)}),R.get()},ho=(g,R)=>{const{type:N,op1:L,op2:b}=g;switch(N){case i.ConflictType.DROP_COLLISION:return R==="left"?[null,Le(b)]:[Le(L),null];case i.ConflictType.RM_UNEXPECTED_CONTENT:let T=!1;return r.readCursor(L).traverse(null,G=>{G.r!==void 0&&(T=!0)}),T?[null,Le(b)]:[Le(L),null];case i.ConflictType.BLACKHOLE:return[Le(L),Le(b)];default:throw Error("Unrecognised conflict: "+N)}};function Ms(g,R,N,L){let b=null;for(;;){const T=yn(R,N,L);if(T.ok)return ft(b,T.result);{const{conflict:G}=T;g(G)||Ls(G);const[$,C]=ho(G,L);R=ft(z(R),$),N=ft(z(N),C),b=ft(b,C)}}}})(Ni);(function(t){var e=$t&&$t.__createBinding||(Object.create?function(i,o,l,a){a===void 0&&(a=l),Object.defineProperty(i,a,{enumerable:!0,get:function(){return o[l]}})}:function(i,o,l,a){a===void 0&&(a=l),i[a]=o[l]}),n=$t&&$t.__exportStar||function(i,o){for(var l in i)l!=="default"&&!o.hasOwnProperty(l)&&e(o,i,l)};Object.defineProperty(t,"__esModule",{value:!0}),n(Ni,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}})})(Bt);const ha=oa(Bt),da=go({__proto__:null,default:ha},[Bt]);var J=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(J||{});class ts{constructor(e){_(this,"_index",0);_(this,"_offset",0);this._actions=e}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(e){e||(e=Number.POSITIVE_INFINITY);const n=this._actions[this._index];if(n){const s=this._offset,r=n.len;return e>=r-s?(e=r-s,this._index+=1,this._offset=0):this._offset+=e,n.t===J.DELETE||n.t===J.RETAIN&&n.body==null?D.deepClone({...n,len:e}):D.deepClone({...n,len:e,body:Xe(n.body,s,s+e)})}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 e=this._actions[this._index];return e?e.t:J.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const e=this._offset,n=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=n,[s].concat(r)}}else return[]}}class bi{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}}function fa(t,e,n){const{dataStream:s}=t,r=n,i=n+e,o=Ei(t,e,n),l=pi(t,e,n),a=Ri(t,e,n),h=Ci(t,e,n),c=Ii(t,e,n),u=Oi(t,e,n);let d="";return s&&(t.dataStream=zr(s,r,i),d=s.slice(r,i)),{dataStream:d,textRuns:o,paragraphs:l,sectionBreaks:a,customBlocks:h,tables:c,customRanges:u}}function _a(t,e,n,s){t.dataStream=Yr(t.dataStream,s,e.dataStream),gi(t,e,n,s),_s(t,e,n,s),Xl(t,e,n,s),mi(t,e,n,s),gs(t,e,n,s),ql(t,e,n,s)}function ga(t,e,n,s,r=xt.COVER){return Jl(t,e,n,s,r)}function ma(t,e,n){return e<=0?{dataStream:""}:fa(t,e,n)}function Ea(t,e,n,s){n!==0&&_a(t,e,n,s)}function pa(t,e){const n=new bi;return n.reset(),e.forEach(s=>{switch(s=D.deepClone(s),s.t){case J.RETAIN:{const{coverType:r,body:i,len:o}=s;i!=null&&ga(t,i,o,n.cursor,r),n.moveCursor(o);break}case J.INSERT:{const{body:r,len:i}=s;Ea(t,r,i,n.cursor),n.moveCursor(i);break}case J.DELETE:{const{len:r}=s;ma(t,r,n.cursor);break}default:throw new Error(`Unknown action type for action: ${s}.`)}}),t}function Gs(t){return Object.keys(t).length===1}const Ke=class Ke{constructor(){_(this,"_actions",[])}static apply(e,n){return pa(e,n)}static compose(e,n){const s=new ts(e),r=new ts(n),i=new Ke;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()),l=s.next(o),a=r.next(o);l.t===J.INSERT&&a.t===J.RETAIN?a.body==null?i.push(l):i.push({...l,body:Jn(l.body,a.body,a.coverType)}):l.t===J.RETAIN&&a.t===J.RETAIN?l.body==null&&a.body==null?i.push(l.len!==Number.POSITIVE_INFINITY?l:a):l.body&&a.body?i.push({...l,body:Jn(l.body,a.body,a.coverType)}):i.push(l.body?l:a):l.t===J.RETAIN&&a.t===J.DELETE?i.push(a):l.t===J.INSERT&&(a.t,J.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}static transform(e,n,s){throw new Error("transform is not implemented in TextX")}static isNoop(e){return e.length===0}static invert(e){const n=[];for(const s of e)if(s.t===J.INSERT)n.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.");n.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.");n.push({t:J.RETAIN,body:s.oldBody,oldBody:s.body,len:s.len,coverType:xt.REPLACE,segmentId:s.segmentId})}else n.push(s);return n}static makeInvertible(e,n){const s=[];let r=0;for(const i of e){if(i.t===J.DELETE&&i.body==null){const o=Xe(n,r,r+i.len,!1);i.body=o}if(i.t===J.RETAIN&&i.body!=null){const{textRuns:o}=Xe(n,r,r+i.len,!0);i.oldBody={dataStream:"",textRuns:o}}s.push(i),i.t!==J.INSERT&&(r+=i.len)}return s}insert(e,n,s=""){const r={t:J.INSERT,body:n,len:e,line:0,segmentId:s};return this.push(r),this}retain(e,n="",s,r){const i={t:J.RETAIN,len:e,segmentId:n};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(e,n=""){const s={t:J.DELETE,len:e,line:0,segmentId:n};return this.push(s),this}serialize(){return this._actions}push(...e){if(e.length>1){for(const i of e)this.push(i);return this}let n=this._actions.length,s=this._actions[n-1];const r=D.deepClone(e[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&&(n-=1,s=this._actions[n-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&&Gs(s.body)&&r.t===J.INSERT&&Gs(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return n===this._actions.length?this._actions.push(r):this._actions.splice(n,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===J.RETAIN&&ra(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};_(Ke,"id","text-x"),_(Ke,"uri","https://github.com/dream-num/univer#text-x");let me=Ke;Object.defineProperty(me,"name",{value:"text-x"});const De=class De{static registerSubtype(e){var n;this._subTypes.has(e.name)&&((n=this._subTypes.get(e.name))==null?void 0:n.id)!==me.id||(this._subTypes.set(e.name,e),Bt.type.registerSubtype(e))}static apply(e,n){if(!Bt.type.isNoop(n))return Bt.type.apply(e,n)}static compose(e,n){return Bt.type.compose(e,n)}static transform(e,n,s){throw new Error("transform is not implemented in JsonX")}static invertWithDoc(e,n){return Bt.type.invertWithDoc(e,n)}static isNoop(e){return Bt.type.isNoop(e)}static getInstance(){return this._instance==null&&(this._instance=new De),this._instance}removeOp(e,n){return Bt.removeOp(e,n)}moveOp(e,n){return Bt.moveOp(e,n)}insertOp(e,n){return Bt.insertOp(e,n)}replaceOp(e,n,s){return Bt.replaceOp(e,n,s)}editOp(e){return Bt.editOp(["body"],me.name,e)}};_(De,"uri","https://github.com/dream-num/univer#json-x"),_(De,"_subTypes",new Map),_(De,"_instance",null);let Ae=De;Ae.registerSubtype(me);const Os={id:"default_doc",documentStyle:{}};class Ra extends wn{constructor(n){super();_(this,"type",et.UNIVER_DOC);_(this,"snapshot");this.snapshot={...Os,...n}}getUnitId(){throw new Error("Method not implemented.")}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}resetDrawing(n,s){this.snapshot.drawings=n,this.snapshot.drawingsOrder=s}getBody(){return this.snapshot.body}getShouldRenderLoopImmediately(){return this.snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this.snapshot.container}getSnapshot(){return this.snapshot}updateDocumentId(n){this.snapshot.id=n}updateDocumentRenderConfig(n){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=n:s.renderConfig={...s.renderConfig,...n}}updateDocumentStyle(n){this.snapshot.documentStyle==null?this.snapshot.documentStyle=n:this.snapshot.documentStyle={...this.snapshot.documentStyle,...n}}updateDocumentDataMargin(n){const{t:s,l:r,b:i,r:o}=n,{documentStyle:l}=this.snapshot;s!=null&&(l.marginTop=s),r!=null&&(l.marginLeft=r),i!=null&&(l.marginBottom=i),o!=null&&(l.marginRight=o)}updateDocumentDataPageSize(n,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){n=n!=null?n:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:n,height:s};return}n!==void 0&&(r.pageSize.width=n),s!==void 0&&(r.pageSize.height=s)}updateDrawing(n,s){const{drawings:r}=this,{width:i,height:o,left:l,top:a}=s,h=r==null?void 0:r[n];if(!h)return;const c=h.docTransform;c.size.width=i,c.size.height=o,c.positionH.posOffset=l,c.positionV.posOffset=a}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}}class we extends Ra{constructor(n){var r;super(D.isEmptyObject(n)?ia():n);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:D.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()})}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getRev(){var n;return(n=this.snapshot.rev)!=null?n:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(n){if(n.id&&n.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...Os,...n},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(n){if(n!=null){if(this.headerModelMap.has(n))return this.headerModelMap.get(n);if(this.footerModelMap.has(n))return this.footerModelMap.get(n)}return this}getUnitId(){return this._unitId}apply(n){if(!Ae.isNoop(n))return Ae.apply(this.snapshot,n)}sliceBody(n,s){const r=this.getBody();if(r!=null)return Xe(r,n,s)}_initializeHeaderFooterModel(){const{headers:n,footers:s}=this.getSnapshot();if(n)for(const r in n){const i=n[r];this.headerModelMap.set(r,new we(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new we(i))}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}}const vi=at.createIdentifier("univer.config-service");class Ai{constructor(){_(this,"_config",new Map)}getConfig(e){return this._config.get(e)}setConfig(e,n){this._config.set(e,n)}deleteConfig(e){this._config.delete(e)}}class wi extends yt{constructor(){super(...arguments);_(this,"_error$",new it.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}class Ti{constructor(e={}){_(this,"_styles");_(this,"_cacheMap",new ei(1e5));this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,n){if(this._cacheMap.has(n))return this._cacheMap.get(n);const s=this._getExistingStyleId(e);return s||"-1"}get(e){return typeof e!="string"?e:(e=String(e),this._styles[e])}add(e,n){const s=D.generateRandomId(6);return this._styles[s]=e,this._cacheMap.set(n,s),s}setValue(e){if(e==null)return;const n=JSON.stringify(e),s=this.search(e,n);return s!=="-1"?s:this.add(e,n)}toJSON(){return this._styles}getStyleByCell(e){let n;e&&D.isObject(e.s)?n=e.s:n=(e==null?void 0:e.s)&&this.get(e.s);const s=e==null?void 0:e.interceptorStyle;return s?{...n,...s}:n}_generateCacheMap(){const{_styles:e,_cacheMap:n}=this;for(const s in e){const r=JSON.stringify(e[s]);n.set(r,s)}}_getExistingStyleId(e){const{_styles:n}=this;for(const s in n)if(D.diffValue(n[s],e))return s;return null}}class Ca{constructor(e,n){_(this,"_columnData",{});this._config=e,this._columnData=n}getColumnData(){return this._columnData}getColVisible(e){const{_columnData:n}=this,s=n[e];return s?s.hd!==q.TRUE:!0}getHiddenCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getColVisible(o);r&&l?(r=!1,s.push({rangeType:ut.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!l&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:ut.COLUMN}),s}getVisibleCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getColVisible(o);r&&!l?(r=!1,s.push({rangeType:ut.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&l&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:ut.COLUMN}),s}getColumnDatas(e,n){const s={};let r=0;for(let i=e;i<e+n;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return _e(this._columnData)}getColumnWidth(e){const{_columnData:n}=this,s=this._config;let r=0;return r=(n[e]||{hd:q.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(e){const n=this._columnData[e];if(n)return n}getColumnOrCreate(e){const{_columnData:n}=this,s=this._config,r=n[e];if(r)return r;const i={w:s.defaultColumnWidth,hd:q.FALSE};return this._columnData[e]=i,i}}class Ia{constructor(e,n,s){_(this,"_rowData");this._config=e,this._viewModel=n,this._rowData=s}getRowData(){return this._rowData}getRowDatas(e,n){const s={};let r=0;for(let i=e;i<e+n;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(e,n=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<n;o++){const l=s[o+e]||{hd:q.FALSE,h:r.defaultRowHeight},{ia:a,ah:h,h:c=r.defaultRowHeight}=l;i+=(a==null||a===q.TRUE)&&typeof h=="number"?h:c}return i}getRow(e){return this._rowData[e]}getRowOrCreate(e){const{_rowData:n}=this,s=n[e];if(s)return s;const r=this._config,i={hd:q.FALSE,h:r.defaultRowHeight};return n[e]=i,i}getHiddenRows(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getRowRawVisible(o);r&&l?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ut.ROW})):!r&&!l&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:ut.ROW}),s}getVisibleRows(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const l=this.getRowRawVisible(o);r&&!l?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:ut.ROW})):!r&&l&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:ut.ROW}),s}getRowRawVisible(e){const n=this.getRow(e);return n?n.hd!==q.TRUE:!0}getSize(){return _e(this._rowData)}}const Oa="DEFAULT_WORKSHEET_ROW_COUNT",Li=1e3,Sa="DEFAULT_WORKSHEET_COLUMN_COUNT",Mi=20,Na="DEFAULT_WORKSHEET_ROW_HEIGHT",Ui=24,ba="DEFAULT_WORKSHEET_COLUMN_WIDTH",Di=88,va="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",yi=46,Aa="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Pi=20;function xi(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:q.FALSE,rowCount:Li,columnCount:Mi,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Di,defaultRowHeight:Ui,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:q.TRUE,rowHeader:{width:yi,hidden:q.FALSE},columnHeader:{height:Pi,hidden:q.FALSE},selections:["A1"],rightToLeft:q.FALSE};return Object.keys(e).forEach(n=>{const s=n;typeof t[s]>"u"&&(t[s]=e[s])}),t}class ki extends yt{constructor(n){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=n}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(n,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(n,s):this.getRawCell(n,s)}getRowFiltered(n){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(n))!=null?r:!1}registerCellContentInterceptor(n){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=n,vt(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,vt(()=>this._rowFilteredInterceptor=null)}}class qe{constructor(e,n,s){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var l;this.unitId=e,this._styles=s,this._snapshot=xi(n);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(l=this._snapshot.id)!=null?l:D.generateRandomId(6),this._cellData=new ee(o),this._viewModel=new ki((a,h)=>this.getCellRaw(a,h)),this._rowManager=new Ia(this._snapshot,this._viewModel,i),this._columnManager=new Ca(this._snapshot,r)}__interceptViewModel(e){e(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const e=this.getCellMatrix(),n=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,l=!1,a=!1;return e.forEach((h,c)=>{Object.keys(c).forEach(u=>{const d=+u,f=e.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)&&(l?s=Math.min(s,h):(s=h,l=!0),r=Math.max(r,h),a?i=Math.min(i,d):(a=!0,i=d),o=Math.max(o,d))})}),n.forEach(h=>{l?s=Math.min(s,h.startRow):(s=h.startRow,l=!0),r=Math.max(r,h.endRow),a?i=Math.min(i,h.startColumn):(i=h.startColumn,l=!0),o=Math.max(o,h.endColumn)}),!l||!a?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,n=D.deepClone(e);return new qe(this.unitId,n,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(e,n){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(ge.intersects({startRow:e,startColumn:n,endRow:e,endColumn:n},i))return i}return null}getCell(e,n){return e<0||n<0?null:this._viewModel.getCell(e,n)}getCellRaw(e,n){return this.getCellMatrix().getValue(e,n)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getMatrixWithMergedCells(e,n,s,r,i=!1){const o=this.getCellMatrix(),l=this._snapshot.mergeData.filter(h=>ge.intersects({startRow:e,startColumn:n,endRow:s,endColumn:r},h)),a=new ee;return Xn(e,s,n,r).forEach((h,c)=>{const u=i?this.getCellRaw(h,c):this.getCell(h,c);u&&a.setValue(h,c,u)}),l.forEach(h=>{const{startColumn:c,startRow:u,endColumn:d,endRow:f}=h;Xn(u,f,c,d).forEach((m,E)=>{m===u&&E===c&&a.setValue(m,E,{...o.getValue(m,E),rowSpan:f-u+1,colSpan:d-c+1}),(m!==u||E!==c)&&a.realDeleteValue(m,E)})}),a}getRange(e,n,s,r){return typeof e=="object"?new ve(this,e,{getStyles:()=>this._styles}):new ve(this,{startRow:e,startColumn:n,endColumn:r||n,endRow:s||e},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:e}=this,{columnCount:n}=e;return n}getMaxRows(){const{_snapshot:e}=this,{rowCount:n}=e;return n}getRowCount(){return this._snapshot.rowCount}setRowCount(e){this._snapshot.rowCount=e}getColumnCount(){return this._snapshot.columnCount}setColumnCount(e){this._snapshot.columnCount=e}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:e}=this,{showGridlines:n}=e;return n===0}getTabColor(){const{_snapshot:e}=this,{tabColor:n}=e;return n}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}getRowVisible(e){return this._viewModel.getRowFiltered(e)?!1:this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,n){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,n);return r.forEach(i=>i.endColumn=s),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,n){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,n);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){const e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){const{_snapshot:e}=this,{rightToLeft:n}=e;return n}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,n=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=e,l=this;return{[Symbol.iterator]:()=>{let a=s,h=r;return{next(){for(;;){if(h>o&&(a+=1,h=r),a>i)return{done:!0,value:void 0};const c=l.getCell(a,h),u=!c,d=l.getMergedCell(a,h);if(d){if(a!==d.startRow||h!==d.startColumn){h=d.endColumn+1;continue}if(u&&n){h=d.endColumn+1;continue}const m={row:a,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&&n)h+=1;else{const f={row:a,col:h,value:c};return h+=1,{done:!1,value:f}}}}}}}}iterateByColumn(e,n=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:l}=e,a=this;return{[Symbol.iterator]:()=>{let h=r,c=i;return{next(){for(;;){if(h>o&&(c+=1,h=r),c>l)return{done:!0,value:void 0};const u=a.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 y=a.getCell(u.startRow,u.startColumn);if(!y&&n){h=u.endRow+1;continue}const Z={row:h,col:u.startColumn,value:y};return Z.colSpan=u.endColumn-u.startColumn+1,Z.rowSpan=u.endRow-u.startRow+1,h=u.endRow+1,{done:!1,value:Z}}const d=a.getCell(h,c);if(!d&&n)h+=1;else{const m={row:h,col:c,value:d};return h+=1,{done:!1,value:m}}}}}}}}}function wa(t){var s,r;if(!t)return"";const e=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(e)return e;const n=t.v;return typeof n=="string"?t.t===Ne.BOOLEAN?n.toUpperCase():n.replace(/[\r\n]/g,""):typeof n=="number"?t.t===Ne.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}const Ta="0.1.13";function La(t="",e=Te.ZH_CN,n=""){return{id:t,sheetOrder:[],name:n,appVersion:Ta,locale:e,styles:{},sheets:{},resources:[]}}var Ma=Object.defineProperty,Ua=Object.getOwnPropertyDescriptor,Da=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ua(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Ma(e,n,r),r},ya=(t,e)=>(n,s)=>e(n,s,t);function Pa(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}exports.Workbook=class extends wn{constructor(n={},s){super();_(this,"type",et.UNIVER_SHEET);_(this,"_sheetCreated$",new it.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new it.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new it.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=La();D.isEmptyObject(n)?this._snapshot=r:this._snapshot=D.commonExtend(r,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=D.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Ti(i),this._count=1,this._worksheets=new Map,this._name$=new it.BehaviorSubject(n.name||""),this.name$=this._name$.asObservable(),this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete()}save(){return D.deepClone(this._snapshot)}static isIRangeType(n){return typeof n=="string"||"startRow"in n||"row"in n}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}setName(n){this._name$.next(n),this._snapshot.name=n}getUnitId(){return this._unitId}getRev(){var n;return(n=this._snapshot.rev)!=null?n:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(n,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[n])return!1;i[n]=r,o.splice(s,0,n);const l=new qe(this._unitId,r,this._styles);return this._worksheets.set(n,l),this._sheetCreated$.next(l),!0}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(n){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>r===n)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const n=this.getRawActiveSheet();if(n)return n;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const l=this._worksheets.get(s[i]);if(l&&l.isSheetHidden()!==q.TRUE)return this.setActiveSheet(l),l}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(n){this._activeSheet$.next(n)}removeSheet(n){var r;return this._worksheets.get(n)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===n&&this.setActiveSheet(null),this._worksheets.delete(n),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(n),1),delete this._snapshot.sheets[n],!0):!1}getActiveSheetIndex(){const{sheetOrder:n}=this._snapshot;return n.findIndex(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:n}=this._snapshot;return n.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:n}=this._snapshot,s=[];return n.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(n){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>n.getSheetId()===r)}getSheetBySheetName(n){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===n);return this._worksheets.get(r)}getSheetBySheetId(n){return this._worksheets.get(n)}getSheetByIndex(n){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[n])}getHiddenWorksheets(){return this.getSheets().filter(n=>n.getConfig().hidden===q.TRUE).map(n=>n.getConfig().id)}transformRangeType(n){if(typeof n=="string")return this._getCellRange(n);if(typeof n!="string"&&"row"in n){const s=n;return{sheetId:"",range:{startRow:s.row[0],startColumn:s.column[0],endRow:s.row[1],endColumn:s.column[1]}}}return typeof n!="string"&&"startRow"in n?{sheetId:"",range:n}:$e}load(n){this._snapshot=n}checkSheetName(n){return this.getSheetsName().includes(n)}uniqueSheetName(n="Sheet1"){let s=n;for(;this.checkSheetName(s);)s=n+this._count,this._count++;return s}generateNewSheetName(n){let s=n+this._count;for(;this.checkSheetName(s);)s=n+this._count,this._count++;return s}_getCellRange(n){var c,u,d,f,m;let s="",r="";if(n.indexOf("!")>-1){const E=n.split("!");s=E[0],r=E[1],s=s.replace(/\\'/g,"'").replace(/''/g,"'"),s.substring(0,1)==="'"&&s.substring(s.length-1,1)==="'"&&(s=s.substring(1,s.length-1))}else r=n;if(r.indexOf(":")===-1){const E=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,y=D.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(E)&&!Number.isNaN(y)?{sheetId:s,range:{startRow:E,endRow:E,startColumn:y,endColumn:y}}:$e}r=r.split(":");const i=[0,0],o=[0,0],l=((c=this.getSheetBySheetName(s))==null?void 0:c.getMaxRows())||((u=this.getActiveSheet())==null?void 0:u.getMaxRows()),a=((d=this.getSheetBySheetName(s))==null?void 0:d.getMaxColumns())||((f=this.getActiveSheet())==null?void 0:f.getMaxColumns());return i[0]=Number.parseInt(r[0].replace(/[^0-9]/g,""),10)-1,i[1]=Number.parseInt(r[1].replace(/[^0-9]/g,""),10)-1,Number.isNaN(i[0])&&(i[0]=0),Number.isNaN(i[1])&&(i[1]=l),i[0]>i[1]||(o[0]=D.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=D.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=a),o[0]>o[1])?$e:{sheetId:((m=this.getSheetBySheetName(s))==null?void 0:m.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:n,_worksheets:s}=this,{sheets:r,sheetOrder:i}=n;if(D.isEmptyObject(r)){const o=D.generateRandomId();r[o]={id:o}}for(const o in r){const l=r[o],{name:a}=l;l.name=this.uniqueSheetName(a),l.name!==a&&this._logService.debug("[Workbook]",`The worksheet name ${a} is duplicated, we changed it to ${l.name}. Please fix the problem in your snapshot.`);const h=new qe(this._unitId,l,this._styles);s.set(o,h),i.includes(o)||i.push(o)}}};exports.Workbook=Da([ya(1,Ee)],exports.Workbook);class Ss extends wn{constructor(n){var s;super();_(this,"type",et.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...ri,...n},this._unitId=(s=this._snapshot.id)!=null?s:D.generateRandomId(6)}getContainer(){return this._snapshot.container}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var n;return(n=this._snapshot.body)==null?void 0:n.pages}getPageOrder(){var n;return(n=this._snapshot.body)==null?void 0:n.pageOrder}getPage(n){const s=this.getPages();return s==null?void 0:s[n]}getElementsByPage(n){var s;return(s=this.getPage(n))==null?void 0:s.pageElements}getElement(n,s){var r;return(r=this.getElementsByPage(n))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:is.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const je="FOCUSING_SHEET",fn="FOCUSING_DOC",_n="FOCUSING_SLIDE",xa="FOCUSING_EDITOR_BUT_HIDDEN",Hi="EDITOR_ACTIVATED",ka="FOCUSING_EDITOR_INPUT_FORMULA",Fi="FOCUSING_FORMULA_EDITOR",Ha="FOCUSING_UNIVER_EDITOR",Fa="FOCUSING_EDITOR_INPUT_FORMULA",Ba="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE",$a="FOCUSING_COMMON_DRAWINGS";var Wa=Object.defineProperty,Ga=Object.getOwnPropertyDescriptor,ja=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ga(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Wa(e,n,r),r},js=(t,e)=>(n,s)=>e(n,s,t);const xe=at.createIdentifier("univer.current");exports.UniverInstanceService=class extends yt{constructor(n,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits$",new it.BehaviorSubject({}));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new it.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new it.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new it.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=n,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(n){this._createHandler=n}createUnit(n,s){return this._createHandler(n,s,this._ctorByType.get(n))}registerCtorForType(n,s){return this._ctorByType.set(n,s),{dispose:()=>{this._ctorByType.delete(n)}}}getCurrentTypeOfUnit$(n){return this.currentUnits$.pipe(it.map(s=>{var r;return(r=s[n])!=null?r:null}),it.distinctUntilChanged())}getCurrentUnitForType(n){return this._currentUnits$.getValue()[n]}setCurrentUnitForType(n){const s=this._getUnitById(n);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${n}!`);this._currentUnits$.next({...this._currentUnits$.getValue(),[s[1]]:s[0]})}getTypeOfUnitAdded$(n){return this._unitAdded$.pipe(it.filter(s=>s.type===n))}__addUnit(n){const s=n.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(n),this._currentUnits$.next({...this._currentUnits$.getValue(),[s]:n}),this._unitAdded$.next(n)}getTypeOfUnitDisposed$(n){return this.unitDisposed$.pipe(it.filter(s=>s.type===n))}getUnit(n,s){var i;const r=(i=this._getUnitById(n))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(et.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,et.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,et.UNIVER_SHEET)}getAllUnitsForType(n){var s;return(s=this._unitsByType.get(n))!=null?s:[]}changeDoc(n,s){const r=this.getAllUnitsForType(et.UNIVER_DOC),i=r.find(o=>o.getUnitId()===n);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const n=this._focused$.getValue();return n?(s=this._getUnitById(n))==null?void 0:s[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof exports.Workbook?(this._contextService.setContextValue(fn,!1),this._contextService.setContextValue(je,!0),this._contextService.setContextValue(_n,!1)):this.focused instanceof we?(this._contextService.setContextValue(fn,!0),this._contextService.setContextValue(je,!1),this._contextService.setContextValue(_n,!1)):this.focused instanceof Ss&&(this._contextService.setContextValue(fn,!1),this._contextService.setContextValue(je,!1),this._contextService.setContextValue(_n,!0))}getFocusedUnit(){return this.focused}getUnitType(n){const s=this._getUnitById(n);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${n}`);return s[1]}disposeUnit(n){const s=this._getUnitById(n);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),l=o.indexOf(r);return o.splice(l,1),this._unitDisposed$.next(r),this._currentUnits$.next({...this._currentUnits$.getValue(),[i]:null}),this._focused$.next(null),!0}_getUnitById(n){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===n);if(i)return[i,s]}}};exports.UniverInstanceService=ja([js(0,at.Inject(at.Injector)),js(1,Je)],exports.UniverInstanceService);var Ot=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(Ot||{});const Va={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},gn=new Map;function Bi(t,e){return function(r){Tn(t,e)}}function Tn(t,e){gn.has(t)||gn.set(t,[]),gn.get(t).push(e)}var Ka=Object.defineProperty,Ya=Object.getOwnPropertyDescriptor,$i=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ya(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Ka(e,n,r),r},es=(t,e)=>(n,s)=>e(n,s,t);exports.LifecycleService=class extends yt{constructor(n){super();_(this,"_lifecycle$",new it.BehaviorSubject(Ot.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=n,this._reportProgress(Ot.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(n){if(n<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");if(n!==this.stage){if(this._lock)throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");this._lock=!0,this._reportProgress(n),this._lifecycle$.next(n),this._lock=!1}}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new it.Observable(n=>{this.stage===Ot.Starting||(this.stage===Ot.Ready?n.next(Ot.Starting):this.stage===Ot.Rendered?(n.next(Ot.Starting),n.next(Ot.Ready)):(n.next(Ot.Starting),n.next(Ot.Ready),n.next(Ot.Rendered))),this._lifecycle$.subscribe(s=>{n.next(s),s===Ot.Steady&&n.complete()})})}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Va[n]}".`)}};exports.LifecycleService=$i([es(0,Ee)],exports.LifecycleService);exports.LifecycleInitializerService=class extends yt{constructor(n,s){super();_(this,"_seenTokens",new Set);this._lifecycleService=n,this._injector=s}initModulesOnStage(n){var s;(s=gn.get(n))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}};exports.LifecycleInitializerService=$i([es(0,at.Inject(exports.LifecycleService)),es(1,at.Inject(at.Injector))],exports.LifecycleInitializerService);class Ve extends yt{constructor(){super();_(this,"_currentLocale$",new it.BehaviorSubject(Te.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new it.Subject);_(this,"t",(n,...s)=>{if(!this._locales)throw new Error("Locale not initialized");const r=n.split("."),i=this.resolveKeyPath(this._locales[this._currentLocale],r);if(typeof i=="string"){let o=i;return s.forEach((l,a)=>{o=o.replace(`{${a}}`,l)}),o}else return n});this.disposeWithMe(vt(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var s;this._locales=D.deepMerge((s=this._locales)!=null?s:{},n)}setLocale(n){this._currentLocale$.next(n),this.localeChanged$.next()}getLocales(){var n;return(n=this._locales)==null?void 0:n[this._currentLocale]}getCurrentLocale(){return this._currentLocale}resolveKeyPath(n,s){const r=s.shift();if(r&&n&&r in n){const i=n[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}var Ns=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(Ns||{});const bs=at.createIdentifier("univer.permission-service");Tn(Ot.Starting,bs);class za extends yt{constructor(){super(...arguments);_(this,"_permissionPointMap",new Map);_(this,"_permissionPointUpdate$",new it.Subject);_(this,"permissionPointUpdate$",this._permissionPointUpdate$.asObservable())}deletePermissionPoint(n){const s=this._permissionPointMap.get(n);s&&(s.complete(),this._permissionPointMap.delete(n))}addPermissionPoint(n){return n.id?(this._permissionPointMap.set(n.id,new it.BehaviorSubject(n)),this._permissionPointUpdate$.next(n),!0):!1}updatePermissionPoint(n,s){const r=this._permissionPointMap.get(n);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(n){const s=this._permissionPointMap.get(n);if(s)return s.getValue()}getPermissionPoint$(n){const s=this._permissionPointMap.get(n);if(s)return s}composePermission$(n){const s=n.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`${r} permissionPoint is not exist`);return i.asObservable()});return it.combineLatest(s).pipe(un.map(r=>r))}composePermission(n){return n.map(r=>{var o;const i=(o=this._permissionPointMap)==null?void 0:o.get(r);if(!i)throw new Error(`${r} permissionPoint is not exist`);return i.getValue()})}}class Wi extends yt{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new it.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(n){return this.getAllResourceHooks().map(i=>{const o=i.toJson(n);return{name:i.pluginName,data:o}})}registerPluginResource(n){const s=n.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,n),this._register$.next(n),vt(()=>this._resourceMap.delete(s))}disposePluginResource(n){this._resourceMap.delete(n)}loadResources(n,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(l=>l.name===r.pluginName))==null?void 0:o.data;if(i)try{const l=r.parseJson(i);r.onLoad(n,l)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}const Ln=at.createIdentifier("resource-manager-service");var Xa=Object.defineProperty,qa=Object.getOwnPropertyDescriptor,Ja=(t,e,n,s)=>{for(var r=s>1?void 0:s?qa(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&Xa(e,n,r),r},Vs=(t,e)=>(n,s)=>e(n,s,t);let ns=class extends yt{constructor(e,n){super();_(this,"saveWorkbook",e=>{const n=e.getUnitId(),s=this._resourceManagerService.getResources(n)||[],r=e.getSnapshot();return r.resources=s,r});this._resourceManagerService=e,this._univerInstanceService=n,this._init()}_init(){const e=s=>{s.businesses.forEach(r=>{switch(r){case et.UNRECOGNIZED:case et.UNIVER_UNKNOWN:case et.UNIVER_SLIDE:case et.UNIVER_DOC:break;case et.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(et.UNIVER_SHEET).forEach(i=>{const l=(i.getSnapshot().resources||[]).find(a=>a.name===s.pluginName);if(l)try{const a=s.parseJson(l.data);s.onLoad(i.getUnitId(),a)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{e(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{e(s)})),this.disposeWithMe(vt(this._univerInstanceService.getTypeOfUnitAdded$(et.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(vt(this._univerInstanceService.getTypeOfUnitDisposed$(et.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}};ns=Ja([Vs(0,at.Inject(Ln)),Vs(1,at.Inject(xe))],ns);const vs=at.createIdentifier("resource-loader-service");Tn(Ot.Ready,vs);class As extends yt{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new it.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(vt(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(n){this._currentTheme=n,this._currentTheme$.next(n)}}const Gi="__defaultDocumentNormalEditorSpecialUnitId_20231006__",ji="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Za=`\r
|
|
7
|
+
`;function Qa(t){return`__internalEditorId__${t}`}function tu(t){return t.startsWith("__")}var eu=Object.defineProperty,nu=Object.getOwnPropertyDescriptor,su=(t,e,n,s)=>{for(var r=s>1?void 0:s?nu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&eu(e,n,r),r},$n=(t,e)=>(n,s)=>e(n,s,t);const Mn=at.createIdentifier("univer.undo-redo.service"),ru=20;class Vi{dispose(){}async dispatchToHandlers(){return!1}}const Ki="univer.command.redo",Yi="univer.command.undo",zi=new class extends Vi{constructor(){super(...arguments);_(this,"type",Ze.COMMAND);_(this,"id",Yi)}async handler(e){const n=e.get(Mn),s=n.pitchTopUndoElement();if(!s)return!1;const r=e.get(Qe);return us(s.undoMutations,r)?(n.popUndoToRedo(),!0):!1}},Xi=new class extends Vi{constructor(){super(...arguments);_(this,"type",Ze.COMMAND);_(this,"id",Ki)}async handler(e){const n=e.get(Mn),s=n.pitchTopRedoElement();if(!s)return!1;const r=e.get(Qe);return us(s.redoMutations,r)?(n.popRedoToUndo(),!0):!1}};exports.LocalUndoRedoService=class extends yt{constructor(n,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new it.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=n,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(zi)),this.disposeWithMe(this._commandService.registerCommand(Xi)),this.disposeWithMe(vt(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(vt(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(n){const{unitID:s}=n,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(n.unitID)){const l=this._batchingStatus.get(n.unitID),a=this._pitchUndoElement(n.unitID);l===0||!a?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(a,n)}else o(n);function o(l){i.push(l),i.length>ru&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(n){const s=this._getRedoStack(n);s&&(s.length=0);const r=this._getUndoStack(n);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const n=this._getFocusedUnitId();return this._pitchUndoElement(n)}pitchTopRedoElement(){const n=this._getFocusedUnitId();return this._pitchRedoElement(n)}_pitchUndoElement(n){const s=this._getUndoStack(n);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(n){const s=this._getRedoStack(n);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__tempBatchingUndoRedo(n){if(this._batchingStatus.has(n))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(n,0),vt(()=>this._batchingStatus.delete(n))}_updateStatus(){var i,o;const n=this._getFocusedUnitId(),s=n&&((i=this._undoStacks.get(n))==null?void 0:i.length)||0,r=n&&((o=this._redoStacks.get(n))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(n,s=!1){let r=this._undoStacks.get(n);return!r&&s&&(r=[],this._undoStacks.set(n,r)),r||null}_getRedoStack(n,s=!1){let r=this._redoStacks.get(n);return!r&&s&&(r=[],this._redoStacks.set(n,r)),r||null}_getUndoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getUndoStack(n,!0)}_getRedoStackForFocused(){const n=this._getFocusedUnitId();if(!n)throw new Error("No focused univer instance!");return this._getRedoStack(n,!0)}_tryBatchingElements(n,s){n.redoMutations.push(...s.redoMutations),n.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,l,a,h;let n="";const s=this._contextService.getContextValue(je),r=this._contextService.getContextValue(Fi),i=this._contextService.getContextValue(Hi);return s?r?n=ji:i?n=Gi:n=(l=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?l:"":n=(h=(a=this._univerInstanceService.getFocusedUnit())==null?void 0:a.getUnitId())!=null?h:"",n}};exports.LocalUndoRedoService=su([$n(0,xe),$n(1,Qe),$n(2,Je)],exports.LocalUndoRedoService);class ss extends yt{onStarting(e){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(ss,"pluginName"),_(ss,"type",et.UNIVER_UNKNOWN);class iu{constructor(){_(this,"_plugins",[])}addPlugin(e){this._plugins.push(e)}removePlugins(){const e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}}class ou{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(e,n){this._pluginsRegistered.push({plugin:e,options:n})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var lu=Object.defineProperty,au=Object.getOwnPropertyDescriptor,uu=(t,e,n,s)=>{for(var r=s>1?void 0:s?au(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&lu(e,n,r),r},an=(t,e)=>(n,s)=>e(n,s,t);exports.PluginHolder=class extends yt{constructor(n,s,r,i){super();_(this,"_started",!1);_(this,"_pluginRegistered",new Set);_(this,"_pluginStore",new iu);_(this,"_pluginRegistry",new ou);this._logService=n,this._injector=s,this._lifecycleService=r,this._lifecycleInitializerService=i}get started(){return this._started}dispose(){super.dispose(),this._pluginStore.forEachPlugin(n=>n.dispose()),this._pluginStore.removePlugins(),this._pluginRegistry.removePlugins(),this._pluginRegistered.clear()}registerPlugin(n,s){const{pluginName:r}=n;if(this._pluginRegistered.has(r)){this._logService.warn("[PluginService]",`plugin ${r} has already been registered. This registration will be ignored.`);return}this._pluginRegistered.add(r),this._pluginRegistry.registerPlugin(n,s)}start(){this._started||(this._started=!0,this.flush())}flush(){if(!this._started)return;const n=this._pluginRegistry.getRegisterPlugins().map(({plugin:r,options:i})=>this._initPlugin(r,i));this._pluginRegistry.removePlugins();const s=this.disposeWithMe(this._lifecycleService.subscribeWithPrevious().pipe(it.finalize(()=>{Promise.resolve().then(()=>s.dispose())})).subscribe(r=>{this._pluginsRunLifecycle(n,r)}))}_pluginsRunLifecycle(n,s){n.forEach(r=>{switch(s){case Ot.Starting:r.onStarting(this._injector);break;case Ot.Ready:r.onReady();break;case Ot.Rendered:r.onRendered();break;case Ot.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(s)}_initPlugin(n,s){return this._injector.createInstance(n,s)}};exports.PluginHolder=uu([an(0,Ee),an(1,at.Inject(at.Injector)),an(2,at.Inject(exports.LifecycleService)),an(3,at.Inject(exports.LifecycleInitializerService))],exports.PluginHolder);var cu=Object.defineProperty,hu=Object.getOwnPropertyDescriptor,du=(t,e,n,s)=>{for(var r=s>1?void 0:s?hu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&cu(e,n,r),r},fu=(t,e)=>(n,s)=>e(n,s,t);const _u=4;exports.PluginService=class{constructor(e){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_flushTimer");this._injector=e,this._pluginHolderForUniver=this._injector.createInstance(exports.PluginHolder),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const e of this._pluginHoldersForTypes.values())e.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(e,n){this._assertPluginValid(e),this._scheduleInitPlugin();const{type:s}=e;s===et.UNIVER_UNKNOWN?(this._pluginHolderForUniver.registerPlugin(e,n),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).registerPlugin(e,n)}startPluginForType(e){this._ensurePluginHolderForType(e).start()}_ensurePluginHolderForType(e){if(!this._pluginHoldersForTypes.has(e)){const n=this._injector.createInstance(exports.PluginHolder);return this._pluginHoldersForTypes.set(e,n),n}return this._pluginHoldersForTypes.get(e)}_assertPluginValid(e){const{type:n,pluginName:s}=e;if(n===et.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${e}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${e}. Please assign a "pluginName" to your plugin.`)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},_u))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[e,n]of this._pluginHoldersForTypes)n.started&&n.flush()}};exports.PluginService=du([fu(0,at.Inject(at.Injector))],exports.PluginService);function qi(t,e){if(!e)return t;const n=[];for(const s of t){const r=e.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;n.push([s[0],r[1]])}else n.push(s)}return n}const rs={[Ft.Editor]:"Editor",[Ft.Owner]:"Owner",[Ft.Reader]:"Reader",[Ft.UNRECOGNIZED]:"UNRECOGNIZED"},ws=t=>({userID:`${rs[t]}_${D.generateRandomId(8)}`,name:rs[t],avatar:""}),Wn=(t,e)=>t.startsWith(rs[e]);var gu=Object.defineProperty,mu=Object.getOwnPropertyDescriptor,Eu=(t,e,n,s)=>{for(var r=s>1?void 0:s?mu(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&gu(e,n,r),r};exports.UserManagerService=class{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new it.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser$",new it.BehaviorSubject(ws(Ft.Owner)));_(this,"currentUser$",this._currentUser$.asObservable())}get currentUser(){return this._currentUser$.getValue()}set currentUser(e){this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:"add",user:e})}getUser(e,n){const s=this._model.get(e);if(s)return s;n&&n()}delete(e){const n=this.getUser(e);this._model.delete(e),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}};exports.UserManagerService=Eu([Bi(Ot.Starting,exports.UserManagerService)],exports.UserManagerService);var pu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Cu=(t,e,n,s)=>{for(var r=s>1?void 0:s?Ru(e,n):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(e,n,r):o(r))||r);return s&&r&&pu(e,n,r),r},Ks=(t,e)=>(n,s)=>e(n,s,t);exports.AuthzIoLocalService=class{constructor(e,n){_(this,"_permissionMap",new Map([]));this._resourceManagerService=e,this._userManagerService=n,this._initSnapshot()}_getRole(e){const n=this._userManagerService.currentUser;return n?Wn(n.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{const n=[...this._permissionMap.keys()].reduce((s,r)=>{const i=this._permissionMap.get(r);return s[r]=i,s},{});return JSON.stringify(n)},parseJson:e=>JSON.parse(e),pluginName:"SHEET_AuthzIoMockService_PLUGIN",businesses:[et.UNIVER_SHEET,et.UNIVER_DOC,et.UNIVER_SLIDE],onLoad:(e,n)=>{for(const s in n)this._permissionMap.set(s,n[s])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){const n=D.generateRandomId(8);switch(e.objectType){case dn.SelectRange:{const s=e.selectRangeObject;this._permissionMap.set(n,{...s,objectType:e.objectType});break}case dn.Worksheet:{const s=e.worksheetObject;this._userManagerService.currentUser,this._permissionMap.set(n,{...s,objectType:e.objectType})}}return n}async allowed(e){var n;if(this._permissionMap.has(e.objectID)){const s=this._permissionMap.get(e.objectID);if(s&&s.objectType===dn.Worksheet)return(n=s==null?void 0:s.strategies)==null?void 0:n.map(r=>({action:r.action,allowed:r.role===Ft.Editor}))}return e.actions.map(s=>({action:s,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.Editor)}))}async batchAllowed(e){const n=this._userManagerService.currentUser,s=e.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!1}))}));return n&&(Wn(n.userID,Ft.Owner)||Wn(n.userID,Ft.Editor))?e.map(r=>({unitID:r.unitID,objectID:r.objectID,actions:r.actions.map(i=>({action:i,allowed:!0}))})):s}async list(e){const n=[];return e.objectIDs.forEach(s=>{const r=this._permissionMap.get(s);if(r){const i={objectID:s,unitID:e.unitID,objectType:r.objectType,name:r.name,shareOn:!1,shareRole:Ft.Owner,creator:ws(Ft.Owner),strategies:[],actions:e.actions.map(o=>({action:o,allowed:this._getRole(Ft.Owner)||this._getRole(Ft.Editor)}))};n.push(i)}}),n}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}};exports.AuthzIoLocalService=Cu([Ks(0,Ln),Ks(1,at.Inject(exports.UserManagerService))],exports.AuthzIoLocalService);const Ji=at.createIdentifier("IAuthzIoIoService");class Iu{constructor(e={},n){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Ou(n,e==null?void 0:e.override),{theme:r,locale:i,locales:o,logLevel:l}=e;r&&this._injector.get(As).setTheme(r),o&&this._injector.get(Ve).load(o),i&&this._injector.get(Ve).setLocale(i),l&&this._injector.get(Ee).setLogLevel(l),this._init(s),this._pluginService}get _univerInstanceService(){return this._injector.get(xe)}get _pluginService(){return this._injector.get(exports.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(e){this._injector.get(Ve).setLocale(e)}createUnit(e,n){return this._univerInstanceService.createUnit(e,n)}createUniverSheet(e){return this._univerInstanceService.createUnit(et.UNIVER_SHEET,e)}createUniverDoc(e){return this._univerInstanceService.createUnit(et.UNIVER_DOC,e)}createUniverSlide(e){return this._univerInstanceService.createUnit(et.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(et.UNIVER_SHEET,exports.Workbook),this._univerInstanceService.registerCtorForType(et.UNIVER_DOC,we),this._univerInstanceService.registerCtorForType(et.UNIVER_SLIDE,Ss);const n=e.get(xe);n.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const l=e.createInstance(i,r);return n.__addUnit(l),this._tryProgressToReady(),l}const o=e.createInstance(i,r);return n.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(exports.LifecycleService).stage<Ot.Ready&&(this._injector.get(exports.LifecycleService).stage=Ot.Ready)}registerPlugin(e,n){this._pluginService.registerPlugin(e,n)}}function Ou(t,e){const n=qi([[wi],[Ve],[As],[exports.LifecycleService],[exports.LifecycleInitializerService],[exports.PluginService],[exports.UserManagerService],[xe,{useClass:exports.UniverInstanceService}],[bs,{useClass:za}],[Ee,{useClass:ci,lazy:!0}],[Qe,{useClass:exports.CommandService,lazy:!0}],[Mn,{useClass:exports.LocalUndoRedoService,lazy:!0}],[vi,{useClass:Ai}],[Je,{useClass:ai}],[Ln,{useClass:Wi,lazy:!0}],[vs,{useClass:ns,lazy:!0}],[Ji,{useClass:exports.AuthzIoLocalService,lazy:!0}]],e);return t?t.createChild(n):new at.Injector(n)}const Su=(t,e)=>e.length===t.length&&!t.some(n=>e.some(s=>!ge.equals(s,n))),Nu=(t,e)=>e.length===t.length&&t.every((n,s)=>{const r=e[s];return r.unitId===n.unitId&&r.sheetId===n.sheetId&&ge.equals(n.range,r.range)});function bu(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||!t||typeof e!="object"||!e)return!1;const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(e);for(let i=0;i<n.length;i++){const o=n[i];if(!r(o))return!1;const l=t[o],a=e[o];if(l!==a)return!1}return!0}function Zi(t){return/^-?\d+(\.\d+)?$/.test(t)}function vu(t){return Zi(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function Au(t){return["true","false"].includes(t.toLowerCase())}function wu(t,e){return e.forEach(n=>t.add(n)),t}function Tu(t,e=16){let n=0,s=null;return function(...i){const o=Date.now();o-n<e?(s&&clearTimeout(s),s=setTimeout(()=>{n=o,t.apply(this,i)},e)):(n=o,t.apply(this,i))}}function Lu(t){const e=new MessageChannel;let n=!1;return e.port1.onmessage=()=>{n||t()},e.port2.postMessage(null),()=>{n=!0}}var Qi=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(Qi||{});function Mu(t,e,n){if(e==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new we(s),i=e.length;let o;for(;(o=r.getBody().dataStream.indexOf(e))>=0;){const a=new me,h=Ae.getInstance();if(o>0&&a.retain(o),n.length>0){const u=r.sliceBody(o,o+i),d={dataStream:n};Array.isArray(u==null?void 0:u.textRuns)&&u.textRuns.length&&(d.textRuns=[{...u.textRuns[0],st:0,ed:n.length}]),a.insert(n.length,d)}a.delete(i);const c=a.serialize();r.apply(h.editOp(c))}const l=r.getBody();return r.dispose(),l}class Uu extends vn{add(e){if(!e)return null;const n=new bn(e,this);return this._observers=[n],this._onObserverAdded&&this._onObserverAdded(n),n}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const Du=at.createIdentifier("ILocalStorageService");function yu(t){return`sheet_interceptor_${t}`}const to=t=>function(e,n){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,n,r.bind(null,i+1))}return r(0,e)};class Pu{constructor(e){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=e}fetchThroughInterceptors(e){const n=e,s=this._interceptorsByName.get(n);return to(s||[])}intercept(e,n){const s=e;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(n),this._interceptorsByName.set(s,r.sort((i,o)=>{var l,a;return((l=o.priority)!=null?l:0)-((a=i.priority)!=null?a:0)})),()=>An(this._interceptorsByName.get(s),n)}getInterceptPoints(){return this._interceptorPoints}}const xu=at.createIdentifier("univer.snapshot-server-service");class ku{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(e,n){return Promise.resolve({snapshot:{unitID:"",type:et.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:Xt.OK,message:""}})}getSheetBlock(e,n){const s=this._sheetBlockCache.get(n.blockID);return Promise.resolve({block:s,error:{code:Xt.OK,message:""}})}fetchMissingChangesets(e,n){return Promise.resolve({changesets:[],error:{code:Xt.OK,message:""}})}getResourcesRequest(e,n){return Promise.resolve({resources:{},error:{code:Xt.OK,message:""}})}saveSnapshot(e,n){return Promise.resolve({error:{code:Xt.OK,message:""}})}saveSheetBlock(e,n){const{block:s}=n;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(e,n){return Promise.resolve({error:{code:Xt.OK,message:""},concurrent:[]})}}function Hu(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(e,n)=>String.fromCharCode(Number.parseInt(n,16))))}function Ts(t){return decodeURIComponent(Array.prototype.map.call(atob(t),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const tn=new TextEncoder,Un=new TextDecoder;function eo(t){const e=D.deepClone(t);return delete e.id,delete e.name,delete e.rowCount,delete e.columnCount,delete e.cellData,tn.encode(JSON.stringify(e))}function no(t){const e=D.deepClone(t);return delete e.id,delete e.rev,delete e.name,delete e.sheetOrder,delete e.sheets,tn.encode(JSON.stringify(e))}function Fu(t){const e=D.deepClone(t);return delete e.id,delete e.rev,delete e.title,delete e.resources,tn.encode(JSON.stringify(e))}function Ys(t){return JSON.parse(Un.decode(t))}function Bu(t){return JSON.parse(typeof t=="string"?Ts(t):Un.decode(t))}function $u(t){return JSON.parse(typeof t=="string"?Ts(t):Un.decode(t))}const Gn=256;function so(t,e){const n=new ee(t),s=n.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+Gn,s-1),l=n.getSlice(i,Math.min(i+Gn,s-1),0,e),a=Wu(l);r.push({id:D.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:a}),i+=Gn}return r}function Wu(t){const e=t.getData();return tn.encode(JSON.stringify(e))}async function Gu(t,e,n,s,r){const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([u,d])=>{const f={id:d.id,type:On.GRID,name:d.name,rowCount:d.rowCount,columnCount:d.columnCount,originalMeta:eo(d)};if(o[u]=f,d.cellData){const m=so(d.cellData,d.rowCount),E=await Promise.all(m.map(y=>r.saveSheetBlock(t,{unitID:n,type:et.UNIVER_SHEET,block:y})));if(E.some(y=>{var P;return((P=y.error)==null?void 0:P.code)!==Xt.OK}))return!1;i[u]={sheetID:u,blocks:E.map(y=>y.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const a=no(e),h={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:a};return{snapshotRes:{unitID:n,rev:h.rev,type:et.UNIVER_SHEET,workbook:h,doc:void 0}}}async function ju(t,e,n,s,r){var d,f;const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([m,E])=>{const y={id:E.id,type:On.GRID,name:E.name,rowCount:E.rowCount,columnCount:E.columnCount,originalMeta:eo(E)};if(o[m]=y,E.cellData){const P=so(E.cellData,E.rowCount),Z=await Promise.all(P.map(gt=>r.saveSheetBlock(t,{unitID:n,type:et.UNIVER_SHEET,block:gt})));if(Z.some(gt=>{var ht;return((ht=gt.error)==null?void 0:ht.code)!==Xt.OK}))return!1;i[m]={sheetID:m,blocks:Z.map(gt=>gt.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const a=no(e),h={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:a},c={unitID:n,rev:h.rev,type:et.UNIVER_SHEET,workbook:h,doc:void 0},u=await r.saveSnapshot(t,{unitID:n,type:et.UNIVER_SHEET,snapshot:c});if(fi(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 Vu(t,e,n){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([a,h])=>{const c=Ys(h.originalMeta);r[a]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...c}});const i=new Map;e.forEach(a=>{i.set(a.id,a)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([a,h])=>{var d;const c=r[a];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=Bu(f.data);Object.entries(m).forEach(([E,y])=>{const P=c.cellData[+E]={};Object.entries(y).forEach(([Z,gt])=>{P[+Z]=gt})})})});const o=Ys(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 Ku(t){const e=t.doc;if(e==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:n,rev:s,name:r,originalMeta:i}=e,{body:o,documentStyle:l={},settings:a={}}=$u(i);return{id:n,rev:s,locale:Te.EN_US,title:r,body:o,documentStyle:l,settings:a}}async function Yu(t,e,n,s,r){var a,h,c;const i={unitID:e.id,rev:s,creator:"",name:(a=e.title)!=null?a:"",resources:e.resources||[],originalMeta:Fu(e)},o={unitID:n,rev:i.rev,type:et.UNIVER_DOC,workbook:void 0,doc:i},l=await r.saveSnapshot(t,{unitID:n,type:et.UNIVER_DOC,snapshot:o});if(fi(l.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
|
|
9
|
+
ErrorCode: ${(h=l.error)==null?void 0:h.code}:${(c=l.error)==null?void 0:c.message}`);return{snapshot:o}}async function zu(t,e){const n=t.workbook;if(!n)throw new Error("Workbook metadata is not available");const s=[],r=[];return Object.entries(n.blockMeta).forEach(([i,o])=>{const l=o.blocks.map(async a=>{const h={unitID:n.unitID,type:et.UNIVER_SHEET,blockID:a},{block:c}=await e.getSheetBlock({},h);if(c)s.push(c);else throw new Error("Block not found")});r.push(...l)}),await Promise.all(r),s}var ro=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(ro||{}),io=(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))(io||{}),oo=(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))(oo||{}),lo=(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))(lo||{}),ao=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(ao||{});mo();exports.ABCToNumber=bl;exports.AbsoluteRefType=bt;exports.ActionIterator=ts;exports.AlignTypeH=kr;exports.AlignTypeV=Hr;exports.ArrangeTypeEnum=$r;exports.ArrowsAndMarkersShapes=cr;exports.AutoFillSeries=Js;exports.BaselineOffset=Pe;exports.BasicShapes=ur;exports.BlockType=Rr;exports.BooleanNumber=q;exports.BorderStyleTypes=dt;exports.BorderType=Zs;exports.BulletAlignment=de;exports.COLORS=jn;exports.CellValueType=Ne;exports.ClientSnapshotServerService=ku;exports.Color=be;exports.ColorBuilder=Nn;exports.ColorKit=te;exports.ColorType=zt;exports.ColumnSeparatorType=Or;exports.CommandType=Ze;exports.CommonHideTypes=Qs;exports.ConfigService=Ai;exports.ContentAlignment=Ur;exports.ContextService=ai;exports.CopyPasteType=tr;exports.CustomRangeType=pr;exports.DEFAULT_CELL=Pl;exports.DEFAULT_DOC=Os;exports.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=po;exports.DEFAULT_EMPTY_DOCUMENT_VALUE=Za;exports.DEFAULT_RANGE=Dl;exports.DEFAULT_RANGE_ARRAY=$e;exports.DEFAULT_SELECTION=yl;exports.DEFAULT_SLIDE=ri;exports.DEFAULT_STYLES=hn;exports.DEFAULT_WORKSHEET_COLUMN_COUNT=Mi;exports.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Sa;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Pi;exports.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=Aa;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH=Di;exports.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=ba;exports.DEFAULT_WORKSHEET_ROW_COUNT=Li;exports.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Oa;exports.DEFAULT_WORKSHEET_ROW_HEIGHT=Ui;exports.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Na;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=yi;exports.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=va;exports.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=ji;exports.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Gi;exports.DashStyleType=Tr;exports.DataStreamTreeNodeType=_i;exports.DataStreamTreeTokenType=ds;exports.DataValidationErrorStyle=ro;exports.DataValidationImeMode=io;exports.DataValidationOperator=oo;exports.DataValidationRenderMode=Qi;exports.DataValidationStatus=ao;exports.DataValidationType=lo;exports.DesktopLogService=ci;exports.DeveloperMetadataVisibility=er;exports.Dimension=nr;exports.Direction=sr;exports.Disposable=yt;exports.DisposableCollection=as;exports.DocStyleType=mr;exports.DocumentDataModel=we;exports.DrawingTypeEnum=Wr;exports.EDITOR_ACTIVATED=Hi;exports.EXTENSION_NAMES=ii;exports.Entry=Vn;exports.EntryIterator=ti;exports.ErrorService=wi;exports.EventState=qr;exports.FOCUSING_COMMON_DRAWINGS=$a;exports.FOCUSING_DOC=fn;exports.FOCUSING_EDITOR_BUT_HIDDEN=xa;exports.FOCUSING_EDITOR_INPUT_FORMULA=ka;exports.FOCUSING_EDITOR_STANDALONE=Fa;exports.FOCUSING_FORMULA_EDITOR=Fi;exports.FOCUSING_SHEET=je;exports.FOCUSING_SLIDE=_n;exports.FOCUSING_UNIVER_EDITOR=Ha;exports.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=Ba;exports.FollowNumberWithType=Er;exports.FontItalic=mn;exports.FontStyleType=Dr;exports.FontWeight=En;exports.FormatType=rr;exports.GlyphType=We;exports.GridType=Cr;exports.HLSColor=_r;exports.HorizontalAlign=Se;exports.IAuthzIoService=Ji;exports.ICommandService=Qe;exports.IConfigService=vi;exports.IContextService=Je;exports.ILocalStorageService=Du;exports.ILogService=Ee;exports.IPermissionService=bs;exports.IResourceLoaderService=vs;exports.IResourceManagerService=Ln;exports.ISnapshotServerService=xu;exports.IUndoRedoService=Mn;exports.IUniverInstanceService=xe;exports.InterceptorManager=Pu;exports.InterpolationPointType=ir;exports.JSON1=da;exports.JSONX=Ae;exports.KeyIterator=Zr;exports.LRUHelper=Be;exports.LRUMap=ei;exports.LifecycleStages=Ot;exports.LocaleService=Ve;exports.LocaleType=Te;exports.LogLevel=ui;exports.MOVE_BUFFER_VALUE=Fe;exports.MemoryCursor=bi;exports.NamedStyleType=Ar;exports.NilCommand=hi;exports.NumberUnitType=xr;exports.ObjectMatrix=ee;exports.ObjectRelativeFromH=yr;exports.ObjectRelativeFromV=Pr;exports.Observable=vn;exports.ObservableHooks=Uu;exports.Observer=bn;exports.OnLifecycle=Bi;exports.OtherShapes=hr;exports.PRESET_LIST_TYPE=zl;exports.PageElementType=Gr;exports.PageOrientType=Br;exports.PageType=is;exports.ParagraphElementType=Nr;exports.PermissionStatus=Ns;exports.Plugin=ss;exports.PositionedObjectLayoutType=vr;exports.PresetListType=In;exports.ProtectionType=or;exports.RANGE_TYPE=ut;exports.RGBA_PAREN=No;exports.RGB_PAREN=So;exports.ROTATE_BUFFER_VALUE=zs;exports.Range=ve;exports.Rectangle=ge;exports.RedoCommand=Xi;exports.RedoCommandId=Ki;exports.RefAlias=Nl;exports.Registry=cs;exports.RegistryAsMap=hs;exports.RelativeDate=lr;exports.RelativeSlideLink=jr;exports.ResourceManagerService=Wi;exports.RgbColor=pn;exports.RxDisposable=gl;exports.SectionType=Ir;exports.SheetTypes=On;exports.SheetViewModel=ki;exports.SlideDataModel=Ss;exports.SpacingRule=wr;exports.SpecialShapes=dr;exports.Styles=Ti;exports.THEME_COLORS=fr;exports.TabStopAlignment=Lr;exports.TextDecoration=ar;exports.TextDirection=Ye;exports.TextDirectionType=Sr;exports.TextX=me;exports.TextXActionType=J;exports.ThemeColor=Rn;exports.ThemeColorType=Ht;exports.ThemeColors=Sn;exports.ThemeService=As;exports.Tools=D;exports.UndoCommand=zi;exports.UndoCommandId=Yi;exports.UnitModel=wn;exports.Univer=Iu;exports.UniverInstanceType=et;exports.UpdateDocsAttributeType=xt;exports.ValueIterator=Qr;exports.VerticalAlign=ye;exports.WidthType=Mr;exports.Worksheet=qe;exports.WrapStrategy=ze;exports.WrapTextType=br;exports.afterInitApply=Yl;exports.b64DecodeUnicode=Ts;exports.b64EncodeUnicode=Hu;exports.binarySearchArray=Xs;exports.cellToRange=ol;exports.characterSpacingControlType=Fr;exports.checkForSubstrings=ll;exports.checkIfMove=Ro;exports.checkParagraphHasBullet=al;exports.checkParagraphHasIndent=ul;exports.checkParagraphHasIndentByStyle=Kr;exports.codeToBlob=Io;exports.composeBody=Jn;exports.composeInterceptors=to;exports.concatMatrixArray=Cl;exports.convertBodyToHtml=Ul;exports.covertTextRunToHtml=qn;exports.createDefaultUser=ws;exports.createInterceptorKey=yu;exports.createInternalEditorID=Qa;exports.createRowColIter=Xn;exports.debounce=Ml;exports.dedupe=ml;exports.deepCompare=os;exports.deleteContent=zr;exports.extractPureTextFromCell=wa;exports.fromCallback=di;exports.fromObservable=_l;exports.generateTemporarySnap=Gu;exports.getArrayLength=_e;exports.getBodySlice=Xe;exports.getBodySliceHtml=cn;exports.getBorderStyleType=sl;exports.getCellValueType=Fo;exports.getColorStyle=re;exports.getDocsUpdateBody=rl;exports.getReverseDirection=Oo;exports.getSheetBlocksFromSnapshot=zu;exports.getWorksheetUID=Pa;exports.groupBy=Rl;exports.handleJsonToDom=el;exports.handleStyleToString=nl;exports.hashAlgorithm=hl;exports.horizontalLineSegmentsSubtraction=ls;exports.insertMatrixArray=Kn;exports.insertTextToContent=Yr;exports.isBlackColor=xo;exports.isBooleanString=Au;exports.isCellV=$o;exports.isEmptyCell=Zo;exports.isFormulaId=tl;exports.isFormulaString=Qo;exports.isICellData=Ho;exports.isInternalEditorID=tu;exports.isNullCell=Bo;exports.isNumeric=Zi;exports.isObserver=Jr;exports.isRangesEqual=Su;exports.isRealNum=cl;exports.isSafeNumeric=vu;exports.isSameStyleTextRun=Vr;exports.isUnitRangesEqual=Nu;exports.isValidRange=il;exports.isWhiteColor=ko;exports.makeCellRangeToRangeData=Jo;exports.makeCellToSelection=qo;exports.mergeOverrideWithDependencies=qi;exports.mergeSets=wu;exports.mergeWorksheetSnapshotWithDefault=xi;exports.moveMatrixArray=zn;exports.moveRangeByOffset=Bl;exports.normalizeTextRuns=fs;exports.numberToABC=Al;exports.numberToListABC=wl;exports.orderSearchArray=qs;exports.queryObjectMatrix=Fl;exports.remove=An;exports.repeatStringNumTimes=si;exports.replaceInDocumentBody=Mu;exports.requestImmediateMacroTask=Lu;exports.rotate=pl;exports.runOnLifecycle=Tn;exports.searchArray=Co;exports.selectionToArray=Wo;exports.sequence=li;exports.sequenceAsync=oi;exports.sequenceExecute=us;exports.sequenceExecuteAsync=Kl;exports.shallowEqual=bu;exports.sliceMatrixArray=Il;exports.sortRules=Tl;exports.sortRulesByDesc=Ll;exports.sortRulesFactory=ke;exports.spliceArray=Yn;exports.textDecoder=Un;exports.textEncoder=tn;exports.throttle=Tu;exports.toDisposable=vt;exports.transformDocumentDataToSnapshot=Yu;exports.transformSnapshotToDocumentData=Ku;exports.transformSnapshotToWorkbookData=Vu;exports.transformWorkbookDataToSnapshot=ju;
|