@univerjs/core 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/lib/cjs/index.js +7 -7
  2. package/lib/es/index.js +670 -650
  3. package/lib/types/common/unit.d.ts +1 -1
  4. package/lib/types/docs/data-model/action-types.d.ts +1 -1
  5. package/lib/types/docs/data-model/apply-utils/update-apply.d.ts +1 -1
  6. package/lib/types/docs/data-model/document-data-model.d.ts +4 -5
  7. package/lib/types/docs/data-model/empty-snapshot.d.ts +1 -1
  8. package/lib/types/docs/data-model/text-x/text-x.d.ts +2 -2
  9. package/lib/types/docs/data-model/text-x/utils.d.ts +2 -2
  10. package/lib/types/observer/observable-hooks.d.ts +1 -1
  11. package/lib/types/services/command/command.service.d.ts +5 -3
  12. package/lib/types/services/context/context.service.d.ts +1 -1
  13. package/lib/types/services/floating-object/floating-object-manager.service.d.ts +3 -3
  14. package/lib/types/services/instance/instance.service.d.ts +7 -7
  15. package/lib/types/services/lifecycle/lifecycle.service.d.ts +4 -4
  16. package/lib/types/services/locale/locale.service.d.ts +6 -4
  17. package/lib/types/services/permission/permission.service.d.ts +4 -4
  18. package/lib/types/services/permission/univer.permission.service.d.ts +2 -2
  19. package/lib/types/services/plugin/plugin-holder.d.ts +5 -5
  20. package/lib/types/services/plugin/plugin.d.ts +3 -3
  21. package/lib/types/services/plugin/plugin.service.d.ts +3 -3
  22. package/lib/types/services/resource-loader/resource-loader.service.d.ts +5 -5
  23. package/lib/types/services/resource-loader/type.d.ts +1 -1
  24. package/lib/types/services/resource-manager/resource-manager.service.d.ts +2 -2
  25. package/lib/types/services/resource-manager/type.d.ts +3 -3
  26. package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +3 -3
  27. package/lib/types/services/snapshot/snapshot-server.service.d.ts +1 -1
  28. package/lib/types/services/snapshot/snapshot-transform.d.ts +4 -4
  29. package/lib/types/services/snapshot/snapshot-utils.d.ts +5 -5
  30. package/lib/types/services/theme/theme.service.d.ts +1 -1
  31. package/lib/types/services/undoredo/undoredo.service.d.ts +6 -6
  32. package/lib/types/services/user-manager/user-manager.service.d.ts +5 -0
  33. package/lib/types/shared/color/color.d.ts +1 -1
  34. package/lib/types/shared/common.d.ts +5 -5
  35. package/lib/types/shared/lifecycle.d.ts +3 -3
  36. package/lib/types/shared/object-matrix-query.d.ts +1 -1
  37. package/lib/types/shared/object-matrix.d.ts +1 -1
  38. package/lib/types/shared/rectangle.d.ts +1 -1
  39. package/lib/types/shared/rxjs.d.ts +1 -1
  40. package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -1
  41. package/lib/types/sheets/column-manager.d.ts +2 -2
  42. package/lib/types/sheets/empty-snapshot.d.ts +1 -1
  43. package/lib/types/sheets/range.d.ts +4 -4
  44. package/lib/types/sheets/row-manager.d.ts +3 -3
  45. package/lib/types/sheets/styles.d.ts +1 -1
  46. package/lib/types/sheets/view-model.d.ts +3 -3
  47. package/lib/types/sheets/workbook.d.ts +6 -6
  48. package/lib/types/sheets/worksheet.d.ts +7 -7
  49. package/lib/types/slides/slide-model.d.ts +1 -2
  50. package/lib/types/types/enum/locale-type.d.ts +2 -1
  51. package/lib/types/types/interfaces/i-cell-custom-render.d.ts +3 -3
  52. package/lib/types/types/interfaces/i-cell-data.d.ts +5 -5
  53. package/lib/types/types/interfaces/i-cell-validation-data.d.ts +1 -1
  54. package/lib/types/types/interfaces/i-data-validation.d.ts +5 -5
  55. package/lib/types/types/interfaces/i-document-data.d.ts +10 -4
  56. package/lib/types/types/interfaces/i-extra-model-data.d.ts +0 -6
  57. package/lib/types/types/interfaces/i-selection-data.d.ts +1 -1
  58. package/lib/types/types/interfaces/i-shape-properties.d.ts +1 -1
  59. package/lib/types/types/interfaces/i-slide-data.d.ts +10 -10
  60. package/lib/types/types/interfaces/i-style-data.d.ts +3 -3
  61. package/lib/types/types/interfaces/i-univer-data.d.ts +4 -4
  62. package/lib/types/types/interfaces/i-workbook-data.d.ts +4 -4
  63. package/lib/types/types/interfaces/i-worksheet-data.d.ts +6 -6
  64. package/lib/types/univer.d.ts +7 -7
  65. package/lib/umd/index.js +9 -9
  66. package/package.json +8 -8
package/lib/umd/index.js CHANGED
@@ -1,9 +1,9 @@
1
- (function(u,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("rxjs"),require("rxjs/operators"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","@wendellhu/redi"],O):(u=typeof globalThis<"u"?globalThis:u||self,O(u.UniverCore={},u.rxjs,u.rxjs.operators,u["@wendellhu/redi"]))})(this,function(u,O,x,S){"use strict";var wa=Object.defineProperty;var va=(u,O,x)=>O in u?wa(u,O,{enumerable:!0,configurable:!0,writable:!0,value:x}):u[O]=x;var _=(u,O,x)=>(va(u,typeof O!="symbol"?O+"":O,x),x);var La,Ta;function ir(){or()}const At=typeof global<"u"?global:typeof self<"u"?self:window;function or(){typeof At.requestIdleCallback!="function"&&(At.requestIdleCallback=function(e){const s=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-s));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof At.cancelIdleCallback!="function"&&(At.cancelIdleCallback=function(e){clearTimeout(e)})}function Fe(t,n){let e=0,s=t.length-1;for(;e<=s;){const r=Math.floor((s+e)/2);if(n<t[r]&&(r===0||n>=t[r-1]))return r;if(n>=t[r])e=r+1;else if(n<t[r])s=r-1;else return-1}return-1}function pe(t,n){let e=0,s=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(s=t[o],o===0?r=0:r=t[o-1],n>=r&&n<=s){i=o;break}if(s=t[e],e===0?r=0:r=t[e-1],n>=r&&n<s){i=e;break}e++,o--}return i}function ar(t,n){let e=t.length-1;return n<0?-1:n<t[0]?0:n>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||n<=t[20]||n>=t[e-20]?e=pe(t,n):e=Fe(t,n),e)}function lr(t){const n=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(n)}var We=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(We||{}),b=(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))(b||{}),Be=(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))(Be||{}),B=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(B||{}),ke=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(ke||{}),Ge=(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))(Ge||{}),$e=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))($e||{}),Ve=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Ve||{}),xe=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(xe||{});function ur(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var je=(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))(je||{}),Ke=(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))(Ke||{}),tt=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t))(tt||{}),Ye=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(Ye||{}),ye=(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))(ye||{}),ze=(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))(ze||{}),Nt=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(Nt||{}),ut=(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))(ut||{}),Xe=(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))(Xe||{}),et=(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))(et||{}),ot=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(ot||{}),ct=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ct||{}),St=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(St||{}),Lt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(Lt||{}),at=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(at||{}),I=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(I||{}),nt=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(nt||{}),W=(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))(W||{}),Tt=(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))(Tt||{});const qe={[Tt.OFFICE]:{[W.ACCENT1]:"#4472C4",[W.ACCENT2]:"#ED7D31",[W.ACCENT3]:"#A5A5A5",[W.ACCENT4]:"#70AD47",[W.ACCENT5]:"#5B9BD5",[W.ACCENT6]:"#70AD47",[W.DARK1]:"#000000",[W.DARK2]:"#44546A",[W.LIGHT1]:"#FFFFFF",[W.LIGHT2]:"#E7E6E6",[W.HYPERLINK]:"#0563C1",[W.FOLLOWED_HYPERLINK]:"#954F72"}};class bt{constructor(){_(this,"_themeValue",W.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=B.UNSUPPORTED,this._themeColors=Tt.OFFICE,this._themeTint=0}asRgbColor(){return new wt(this._rgbValue,this)}asThemeColor(){return new vt(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case B.THEME:return this.asThemeColor();case B.RGB:return this.asRgbColor();case B.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(n){return this._colorType=B.RGB,this._rgbValue=n,this}setThemeColors(n){this._colorType=B.THEME,this._themeColors=n}setThemeTint(n){this._colorType=B.THEME,this._themeTint=n}setThemeColor(n){return this._colorType=B.THEME,this._themeValue=n,this}getColorType(){return this._colorType}}class st{constructor(n){_(this,"_builder");this._builder=n}static rgbColorToHexValue(n){return`#${((1<<24)+(n.getRed()<<16)+(n.getGreen()<<8)+n.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(n){n?n.indexOf("#")>-1&&(n=n.substring(1)):n="#000000";const e=+`0x${n[0]}${n[1]}`,s=+`0x${n[2]}${n[3]}`,r=+`0x${n[4]}${n[5]}`;return new bt().setRgbColor(`rgb(${e},${s},${r})`).asRgbColor()}static hexToRgbString(n){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;n=n.replace(e,(i,o,a,l)=>o+o+a+a+l+l);const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);let r=null;if(s){const i=Number.parseInt(s[1],16),o=Number.parseInt(s[2],16),a=Number.parseInt(s[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new st(this._builder)}equals(n){return!1}}class Je{constructor(n){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const e=n.getRed()/255,s=n.getGreen()/255,r=n.getBlue()/255,i=n.getAlpha()/255,o=Math.min(e,Math.min(s,r)),a=Math.max(e,Math.max(s,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),e===a&&(this._hue=(s-r)/l),s===a&&(this._hue=2+(r-e)/l),r===a&&(this._hue=4+(e-s)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const n=new bt;if(this._saturation===0)return n.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),n.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const s=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,s,i),a=this.setColor(e,s,r),l=r-1/3,c=this.setColor(e,s,l);return n.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(c*255)},${this._alpha*255})`),n.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(n,e,s){s<0&&(s+=1),s>1&&(s-=1);let r;return 6*s<1?r=e+(n-e)*6*s:2*s<1?r=n:3*s<2?r=e+(n-e)*(2/3-s)*6:r=e,r}setLightness(n){this._lightness=n}}const G=class G extends st{constructor(e,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=e.match(G.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(G.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 st.rgbColorToHexValue(this)}getRed(){let e=this._red+G.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getGreen(){let e=this._green+G.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getBlue(){let e=this._blue+G.RGB_COLOR_AMT;return e>255?e=255:e<0&&(e=0),e}getAlpha(){return this._alpha}getColorType(){return B.RGB}clone(){return new G(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(e){return e instanceof G?e._red===this._red&&e._blue===this._blue&&e._green===this._green&&e._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(G,"RGB_COLOR_AMT",0),_(G,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(G,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let wt=G;const J=class J extends st{constructor(e,s,r,i){super(i);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=e,this._themeTint=s,this._themeColors=r}lumValue(e,s){if(e==null)return s;let r;return e<0?r=s*(1+e):r=s*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=qe[this._themeColors];if(e==null)throw new Error("not find themeColors type");const s=e[this._themeColorType];if(s==null)throw new Error("not find themeColors value");let r;if(J._cacheThemeColor.has(this._themeColors)){if(r=J._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,J._cacheThemeColor.set(this._themeColors,r);const i=new Je(st.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 J(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof J?e._themeColorType===this._themeColorType:!1}getColorType(){return B.THEME}getThemeColorType(){return this._themeColorType}};_(J,"_cacheThemeColor",new Map);let vt=J;const cr="rgb(",hr="rgba(",Jt={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 ${constructor(n){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(n==null){this._setNullColor();return}if(n instanceof $){this._color={...n._color},this._rgbColor={...n._rgbColor};return}const e=Ze(n);if(e==null){this._setNullColor();return}this._color=e;const s=gr(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(n,e,s){var c,h;s=Math.min(1,Math.max(0,s));const r=new $(n).toRgb(),i=new $(e).toRgb(),o=(c=r.a)!=null?c:1,a=(h=i.a)!=null?h:1,l={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(a-o)*s+o};return new $(l)}static getContrastRatio(n,e){const s=new $(n).getLuminance(),r=new $(e).getLuminance();return(Math.max(s,r)+.05)/(Math.min(s,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:n,g:e,b:s,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${n},${e},${s}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(n){const{r:e,g:s,b:r,a:i=1}=this.toRgb(),o=i<1,a=[Ut(Math.round(e).toString(16)),Ut(Math.round(s).toString(16)),Ut(Math.round(r).toString(16)),Ut(Math.round(i*255).toString(16))];return n&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Or(this.toRgb())}toHsl(){return Cr(this.toRgb())}lighten(n=10){const e=this.toHsl();return e.l+=n,e.l=Math.min(Math.max(e.l,0),100),new $(e)}darken(n=10){const e=this.toHsl();return e.l-=n,e.l=Math.min(Math.max(e.l,0),100),new $(e)}setAlpha(n){return new $({...this._rgbColor,a:n})}getLuminance(){let{r:n,g:e,b:s}=this.toRgb();return n=Zt(n),e=Zt(e),s=Zt(s),Number((.2126*n+.7152*e+.0722*s).toFixed(3))}getBrightness(){const{r:n,g:e,b:s}=this.toRgb();return(n*299+e*587+s*114)/1e3}getAlpha(){var n;return(n=this._color.a)!=null?n:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const Ut=t=>t.length===1?`0${t}`:t,Zt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),Ze=t=>{if(Ar(t)){if("r"in t){const s={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(s.a=t.a),s}if("l"in t){const s={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(s.a=t.a),s}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const n=t.trim();if(Jt[n]){const e=Jt[n],s={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return s.a=e[3]||1,s}if(n.startsWith("#"))return dr(n);if(n.startsWith("rgb"))return _r(n);if(n.startsWith("hsl"))return fr(n);if(n.startsWith("hsv"))return Er(n)},dr=t=>{const n=t.substring(1),e=new RegExp(`.{1,${n.length>=6?2:1}}`,"g");let s=n.match(e);if(!s||s.length<3)throw new Error(`The color '${t}' is illegal hex color`);s[0].length===1&&(s=s.map(i=>i+i));const r={r:Number.parseInt(s[0],16),g:Number.parseInt(s[1],16),b:Number.parseInt(s[2],16)};return s.length>3&&(r.a=Number.parseInt(s[3],16)/255),r},_r=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const s={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},fr=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},Er=t=>{const n=t.indexOf("(");if(n===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(n+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const s={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(s.a=Number.parseFloat(e[3])),s},gr=t=>{const n=Ze(t);if(n!=null)return"r"in n?n:"l"in n?Rr(n):mr(n)},Qt=(t,n,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(n-t)*6*e:e<1/2?n:e<2/3?t+(n-t)*(2/3-e)*6:t),Rr=t=>{let{h:n,s:e,l:s}=t;n/=360,e/=100,s/=100;let r=0,i=0,o=0;if(e===0)r=i=o=s;else{const l=s<.5?s*(1+e):s+e-s*e,c=2*s-l;r=Qt(c,l,n+1/3),i=Qt(c,l,n),o=Qt(c,l,n-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},mr=t=>{let{h:n,s:e,v:s}=t;n=n/360*6,e/=100,s/=100;const r=Math.floor(n),i=n-r,o=s*(1-e),a=s*(1-i*e),l=s*(1-(1-i)*e),c=r%6,h=[s,a,o,o,l,s][c],d=[l,s,s,a,o,o][c],f=[o,o,l,s,s,a][c],E={r:h*255,g:d*255,b:f*255};return t.a!==void 0&&(E.a=t.a),E},Cr=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const h=r-i;switch(l=o>.5?h/(2-r-i):h/(r+i),r){case n:a=(e-s)/h+(e<s?6:0);break;case e:a=(s-n)/h+2;break;default:a=(n-e)/h+4;break}a/=6}const c={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(c.a=t.a),c},Or=t=>{let{r:n,g:e,b:s}=t;n/=255,e/=255,s/=255;const r=Math.max(n,e,s),i=Math.min(n,e,s);let o;const a=r,l=r-i,c=r===0?0:l/r;if(r===i)o=0;else{switch(r){case n:o=(e-s)/l+(e<s?6:0);break;case e:o=(s-n)/l+2;break;default:o=(n-e)/l+4;break}o/=6}const h={h:Math.round(o*360),s:Math.round(c*100),v:Math.round(a*100)};return t.a!==void 0&&(h.a=t.a),h},Ir=t=>t==null,Ar=t=>!Ir(t)&&typeof t=="object";function Nr(t){const n=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,s=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}function Sr(t){const n=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,s=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(n.test(t)||e.test(t)||s.test(t)||r.test(t)||i.test(t))}var H=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(H||{});function Lr(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 Tr(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return nt.STRING;if(typeof t.v=="number")return nt.NUMBER;if(typeof t.v=="boolean")return nt.BOOLEAN}function br(t){if(t==null)return!0;const{v:n,f:e,si:s,p:r,s:i}=t;return!(!(n==null||typeof n=="string"&&n.length===0)||e!=null&&e.length>0||s!=null&&s.length>0||r!=null)}function wr(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Qe=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Qe||{}),tn=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(tn||{}),ht=(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))(ht||{}),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||{}),en=(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))(en||{}),nn=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(nn||{}),sn=(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))(sn||{}),rn=(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))(rn||{}),on=(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))(on||{}),an=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(an||{}),ln=(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))(ln||{}),un=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(un||{}),cn=(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))(cn||{}),hn=(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))(hn||{}),dn=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(dn||{}),_n=(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))(_n||{}),fn=(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))(fn||{}),En=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(En||{}),gn=(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))(gn||{}),Rn=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Rn||{}),mn=(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))(mn||{}),Cn=(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))(Cn||{}),On=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(On||{}),In=(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))(In||{}),An=(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))(An||{}),Nn=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Nn||{}),Sn=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Sn||{}),p=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(p||{}),v=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(v||{});function vr(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}var te=(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))(te||{}),Ln=(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))(Ln||{}),Tn=(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))(Tn||{});const Ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Dr=t=>crypto.getRandomValues(new Uint8Array(t)),Mr=(t,n,e)=>{let s=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*s*n/t.length);return(i=n)=>{let o="";for(;;){let a=e(r),l=r;for(;l--;)if(o+=t[a[l]&s]||"",o.length===i)return o}}},Pr=(t,n=21)=>Mr(t,n,Dr),Hr=(t=21)=>{let n="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)n+=Ur[e[t]&63];return n};const Fr=/^-ms-/,pr=/-([a-z])/g,Y=["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 m{static stringAt(n){let e="",s=n;for(;s>=Y.length;)s/=Y.length,s-=1,e+=Y[s%Y.length];const r=n%Y.length;return e+=Y[r],e}static indexAt(n){let e=0;for(let s=0;s<n.length-1;s+=1){const r=n.charCodeAt(s)-65,i=n.length-1-s;e+=Y.length**i+Y.length*r}return e+=n.charCodeAt(n.length-1)-65,e}static deleteBlank(n){return m.isString(n)?n.replace(/\s/g,""):n}static getSystemType(){const n=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",s=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(s)return"Mac";if(navigator.platform==="X11"&&!e&&!s)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(n.indexOf("Windows NT 5.0")>-1||n.indexOf("Windows 2000")>-1)return"Windows 2000";if(n.indexOf("Windows NT 5.1")>-1||n.indexOf("Windows XP")>-1)return"Windows XP";if(n.indexOf("Windows NT 5.2")>-1||n.indexOf("Windows 2003")>-1)return"Windows 2003";if(n.indexOf("Windows NT 6.0")>-1||n.indexOf("Windows Vista")>-1)return"Windows Vista";if(n.indexOf("Windows NT 6.1")>-1||n.indexOf("Windows 7")>-1)return"Windows 7";if(n.indexOf("Windows NT 10")>-1||n.indexOf("Windows 10")>-1)return"Windows 10";if(n.indexOf("Windows NT 11")>-1||n.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const n=navigator.userAgent,e=n.indexOf("Opera")>-1,s=n.indexOf("compatible")>-1&&n.indexOf("MSIE")>-1&&!e,r=n.indexOf("Trident")>-1&&n.indexOf("rv:11.0")>-1,i=n.indexOf("Edge")>-1,o=n.indexOf("Firefox")>-1,a=n.indexOf("Safari")>-1&&n.indexOf("Chrome")===-1,l=n.indexOf("Chrome")>-1&&n.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(n);const h=Number.parseFloat(RegExp.$1);return h===7?"IE7":h===8?"IE8":h===9?"IE9":h===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(n=21,e){return e?Pr(e,n)():Hr(n)}static getClassName(n){return n.constructor.name}static deepMerge(n,...e){e.forEach(o=>o&&i(o));function s(o,a){o.forEach((l,c)=>{var h,d;if(m.isArray(l)){const f=(h=a[c])!=null?h:[];a[c]=f,s(l,f);return}if(m.isObject(l)){const f=(d=a[c])!=null?d:{};a[c]=f,r(l,f);return}a[c]=l})}function r(o,a){Object.keys(o).forEach(l=>{var h,d;const c=o[l];if(m.isObject(c)){const f=(h=a[l])!=null?h:{};a[l]=f,r(c,f);return}if(m.isArray(c)){const f=(d=a[l])!=null?d:[];a[l]=f,s(c,f);return}a[l]=c})}function i(o){Object.keys(o).forEach(a=>{var c,h;const l=o[a];if(m.isArray(l)){const d=(c=n[a])!=null?c:[];n[a]=d,s(l,d);return}if(m.isObject(l)){const d=(h=n[a])!=null?h:{};n[a]=d,r(l,d);return}n[a]=l})}return n}static numberFixed(n,e){return Number(Number(n).toFixed(e))}static diffValue(n,e){function s(o,a){const l=m.getValueType(o),c=m.getValueType(a);return l!==c?!1:m.isArray(o)?r(o,a):m.isObject(o)?i(o,a):m.isDate(o)?o.getTime()===a.getTime():m.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(n.length!==e.length)return!1;for(let l=0,c=o.length;l<c;l++){const h=o[l],d=a[l];if(!s(h,d))return!1}return!0}function i(o,a){const l=Object.keys(o),c=Object.keys(a);if(l.length!==c.length)return!1;for(const h of l){if(!c.includes(h))return!1;const d=o[h],f=a[h];if(!s(d,f))return!1}return!0}return s(n,e)}static deepClone(n){if(!this.isDefine(n))return n;if(this.isRegExp(n))return new RegExp(n);if(this.isDate(n))return new Date(n);if(this.isArray(n)){const e=[];return n.forEach((s,r)=>{e[r]=m.deepClone(s)}),e}if(this.isObject(n)){const e={};return Object.keys(n).forEach(s=>{const r=n[s];e[s]=m.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(n)),e}return n}static getLanguage(){const n="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||n}static getValueType(n){return Object.prototype.toString.apply(n)}static isDefine(n){return n!=null}static isBlank(n){return this.isDefine(n)?this.isString(n)?n.trim()==="":!1:!0}static isAssignableFrom(n,e){return n instanceof e}static isBoolean(n){return this.getValueType(n)==="[object Boolean]"}static isPlainObject(n){return this.isDefine(n)?Object.getPrototypeOf(n)===Object.getPrototypeOf({}):!1}static isFunction(n){return this.getValueType(n)==="[object Function]"}static isDate(n){return this.getValueType(n)==="[object Date]"}static isRegExp(n){return this.getValueType(n)==="[object RegExp]"}static isArray(n){return this.getValueType(n)==="[object Array]"}static isString(n){return this.getValueType(n)==="[object String]"}static isNumber(n){return this.getValueType(n)==="[object Number]"}static isStringNumber(n){return!isNaN(Number.parseFloat(n))&&isFinite(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isEmptyObject(n){for(const e in n)return!1;return!0}static isMobile(){let n=0,e=0;return document.body.clientWidth&&(n=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||n<350&&e<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const n=navigator.userAgent.toLowerCase();return String(n.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const n=navigator.userAgent;return n.indexOf("Android")>-1||n.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static itCount(n){return e=>{for(let s=0;s<n;s++)e&&e()}}static hasLength(n,e){return m.isDefine(n)?m.isDefine(e)?n.length===e:n.length>0:!1}static capitalize(n){return n.charAt(0).toUpperCase()+n.slice(1)}static fCamelCase(n,e){return e.toUpperCase()}static camelCase(n){return n.replace(Fr,"ms-").replace(pr,this.fCamelCase)}static removeNull(n){return this.isObject(n)&&Object.keys(n).forEach(e=>{const s=n[e];s==null?delete n[e]:m.removeNull(s)}),n}static fillTwoDimensionalArray(n,e,s){return new Array(n).fill(s).map(r=>new Array(e).fill(s))}static numToWord(n){let e="";for(;n>0;){let s=n%26;s=s===0?s=26:s,e=String.fromCharCode(96+s)+e,n=(n-s)/26}return e.toLocaleUpperCase()}static ABCatNum(n){if(n==null||n.length===0)return Number.NaN;const e=n.toLowerCase().split(""),s=e.length;let r=0,i=0;for(let o=0;o<s;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}static chatAtABC(n){let i="";for(;n>=0;)i=String.fromCharCode(n%26+97)+i,n=Math.floor(n/26)-1;return i.toUpperCase()}static randSort(n){for(let e=0,s=n.length;e<s;e++){const r=Number.parseInt((Math.random()*s).toString()),i=n[r];n[r]=n[e],n[e]=i}return n}static commonExtend(n,e){const s={};for(const r in n)s[r]=n[r];for(const r in e)e[r]!=null&&(s[r]=e[r]);return s}static commonExtend1(n,e){for(const s in n)e[s]==null&&(e[s]=n[s]);return e}static arrayToObject(n){const e={};return n.forEach((s,r)=>{e[r]={},s.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(n,e,s,r){return e>=s&&r>=n}static isStartValidPosition(n){return/^[A-Za-z_]/.test(n)}static isValidParameter(n){const e=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(n),s=n.length<=255;return!e&&s}}function Wr(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:c}=t,h=n,d=e,f=n,E=e;if(s&&i){const{startRow:g,startColumn:R,endRow:C,endColumn:L,startY:P,endY:F,startX:Q,endX:ba}=i;h=g,d=R,f=C,E=L,o=P,a=F,l=Q,c=ba}return r&&(o=i.startY,a=i.endY,l=i.startX,c=i.endX,f=i.endRow,E=i.endColumn),{startRow:h,startColumn:d,endRow:f,endColumn:E,startY:o,endY:a,startX:l,endX:c}}function Br(t){if(!t)return;const{actualRow:n,actualColumn:e,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let c=n,h=e,d=n,f=e;return(s||r)&&(c=i,h=o,d=a,f=l),{startRow:c,startColumn:h,endRow:d,endColumn:f}}function kr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function j(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new bt().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Gr(t){return m.isString(t)&&t.substring(0,1)==="="&&t.length>1}function $r(t){return m.isString(t)&&t.length>0}function Vr(t){return""}function xr(t,n=!1){var i;let e="";const s=new Map([["ff",()=>{t.ff&&(e+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),e+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(e+="font-style: italic; ")}],["bl",()=>{t.bl&&(e+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(a,l)=>`${l} underline`):e+="text-decoration-line: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${j(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: ${j(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: ${j(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${j(t.bg)}; `)}],["bd",()=>{var o,a,l,c,h,d,f,E,g,R,C,L;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${Dt((a=t.bd)==null?void 0:a.b.s)} ${(l=j(t.bd.b.cl))!=null?l:""}; `),(c=t.bd)!=null&&c.t&&(e+=`border-top: ${Dt((h=t.bd)==null?void 0:h.t.s)} ${(d=j(t.bd.t.cl))!=null?d:""}; `),(f=t.bd)!=null&&f.r&&(e+=`border-right: ${Dt((E=t.bd)==null?void 0:E.r.s)} ${(g=j(t.bd.r.cl))!=null?g:""}; `),(R=t.bd)!=null&&R.l&&(e+=`border-left: ${Dt((C=t.bd)==null?void 0:C.l.s)} ${(L=j(t.bd.l.cl))!=null?L:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${j(t.cl)}; `)}],["va",()=>{t.va===at.SUBSCRIPT?e+="vertical-align: sub; ":t.va===at.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===ut.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===ut.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===et.LEFT?e+="text-align: left; ":t.ht===et.RIGHT?e+="text-align: right; ":t.ht===et.CENTER?e+="text-align: center; ":t.ht===et.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===ot.BOTTOM?e+="vertical-align: bottom; ":t.vt===ot.TOP?e+="vertical-align: top; ":t.vt===ot.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===ct.CLIP?e+="white-space: clip; ":t.tb===ct.WRAP&&(e+="white-space: normal;")}],["pd",()=>{var h,d,f,E,g,R,C,L;const o=`${(h=t.pd)==null?void 0:h.b}pt`,a=`${(d=t.pd)==null?void 0:d.t}pt`,l=`${(f=t.pd)==null?void 0:f.l}pt`,c=`${(E=t.pd)==null?void 0:E.r}pt`;(g=t.pd)!=null&&g.b&&(e+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(e+=`padding-top: ${a}; `),(C=t.pd)!=null&&C.l&&(e+=`padding-left: ${l}; `),(L=t.pd)!=null&&L.r&&(e+=`padding-right: ${c}; `)}]]),r=["bd","tr","tb"];for(const o in t)n&&r.includes(o)||(i=s.get(o))==null||i();return e}function Dt(t){let n="";return t===b.NONE?n="none":t===b.THIN?n="0.5pt solid":t===b.HAIR?n="0.5pt double":t===b.DOTTED?n="0.5pt dotted":t===b.DASHED||t===b.DASH_DOT?n="0.5pt dashed":t===b.DASH_DOT_DOT?n="0.5pt dotted":t===b.DOUBLE?n="0.5pt double":t===b.MEDIUM?n="1pt solid":t===b.MEDIUM_DASHED||t===b.MEDIUM_DASH_DOT?n="1pt dashed":t===b.MEDIUM_DASH_DOT_DOT?n="1pt dotted":t===b.SLANT_DASH_DOT?n="0.5pt dashed":t===b.THICK&&(n="1.5pt solid"),n}function jr(t){let n=0;if(t=t.trim(),t==="none")n=b.NONE;else if(t==="0.5pt solid")n=b.THIN;else if(t==="0.5pt double")n=b.HAIR;else if(t==="0.5pt dotted")n=b.DOTTED;else if(t==="0.5pt dashed")n=b.DASHED;else if(t==="1pt solid")n=b.MEDIUM;else if(t==="1pt dashed")n=b.MEDIUM_DASHED;else if(t==="1pt dotted")n=b.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")n=b.THICK;else if(!t.includes("none"))n=b.THIN;else return b.NONE;return n}function Mt(t,n){let e=t.body;if(n){const{headers:s,footers:r}=t;s!=null&&s[n]?e=s[n].body:r!=null&&r[n]&&(e=r[n].body)}return e}function Kr(t){const{startRow:n,endRow:e,startColumn:s,endColumn:r,rangeType:i}=t;return!(n<0||s<0||e<0||r<0||!(Number.isNaN(n)&&Number.isNaN(e))&&i===p.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===p.ROW)}function Yr(t,n){return{startRow:t,endRow:t,startColumn:n,endColumn:n}}function ee(t,n){return Object.prototype.toString.call(t)===Object.prototype.toString.call(n)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(n).length?!1:Object.keys(t).every(e=>ee(t[e],n[e])):t===n:!1}function bn(t,n){const e=t.ts||{},s=n.ts||{};return t.sId!==n.sId?!1:ee(e,s)}function yr(t,n){return n.some(e=>t.indexOf(e)>-1)}function ne(t,n,e,s){if(t>n&&([t,n]=[n,t]),e>s&&([e,s]=[s,e]),n<e||s<t)return[t,n];e<t&&(e=t),s>n&&(s=n);const r=s-e+1;let i=[];return t===e?i=[s+1-r,n-r]:n===s?i=[t,e-1]:i=[t,n-r],i}function zr(t){if(t==null)return!1;const n=t.bullet;return(n==null?void 0:n.listId)!=null}function Xr(t){if(t==null)return!1;const n=t.paragraphStyle;return wn(n)}function wn(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function vn(t,n,e){return t.slice(0,n)+e+t.slice(n)}function Un(t,n,e){return n>e?t:t.slice(0,n)+t.slice(e)}function qr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Jr(t){let n=0;for(let e=0;e<t.length;e++)n=t.charCodeAt(e)+(n<<6)+(n<<16)-n;return n>>>0}function Dn(t){var n=typeof Symbol=="function"&&Symbol.iterator,e=n&&t[n],s=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function Mn(t,n){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var s=e.call(t),r,i=[],o;try{for(;(n===void 0||n-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=s.return)&&e.call(s)}finally{if(o)throw o.error}}return i}function Pn(t,n,e){if(e||arguments.length===2)for(var s=0,r=n.length,i;s<r;s++)(i||!(s in n))&&(i||(i=Array.prototype.slice.call(n,0,s)),i[s]=n[s]);return t.concat(i||Array.prototype.slice.call(n))}typeof SuppressedError=="function"&&SuppressedError;function dt(t){return typeof t=="function"}function Zr(t){var n=function(s){Error.call(s),s.stack=new Error().stack},e=t(n);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var se=Zr(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
- `+e.map(function(s,r){return r+1+") "+s.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function Hn(t,n){if(t){var e=t.indexOf(n);0<=e&&t.splice(e,1)}}var Fn=function(){function t(n){this.initialTeardown=n,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var n,e,s,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Dn(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(R){n={error:R}}finally{try{l&&!l.done&&(e=a.return)&&e.call(a)}finally{if(n)throw n.error}}else o.remove(this);var h=this.initialTeardown;if(dt(h))try{h()}catch(R){i=R instanceof se?R.errors:[R]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=Dn(d),E=f.next();!E.done;E=f.next()){var g=E.value;try{pn(g)}catch(R){i=i!=null?i:[],R instanceof se?i=Pn(Pn([],Mn(i)),Mn(R.errors)):i.push(R)}}}catch(R){s={error:R}}finally{try{E&&!E.done&&(r=f.return)&&r.call(f)}finally{if(s)throw s.error}}}if(i)throw new se(i)}},t.prototype.add=function(n){var e;if(n&&n!==this)if(this.closed)pn(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(n)}},t.prototype._hasParent=function(n){var e=this._parentage;return e===n||Array.isArray(e)&&e.includes(n)},t.prototype._addParent=function(n){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(n),e):e?[e,n]:n},t.prototype._removeParent=function(n){var e=this._parentage;e===n?this._parentage=null:Array.isArray(e)&&Hn(e,n)},t.prototype.remove=function(n){var e=this._finalizers;e&&Hn(e,n),n instanceof t&&n._removeParent(this)},t.EMPTY=function(){var n=new t;return n.closed=!0,n}(),t}();Fn.EMPTY;function Qr(t){return t instanceof Fn||t&&"closed"in t&&dt(t.remove)&&dt(t.add)&&dt(t.unsubscribe)}function pn(t){dt(t)?t():t.unsubscribe()}class Wn{constructor(n=!1){_(this,"skipNextObservers");_(this,"lastReturnValue");_(this,"isStopPropagation",!1);this.initialize(n)}initialize(n=!1){return this.skipNextObservers=n,this}stopPropagation(){this.isStopPropagation=!0}}function Bn(t){return t instanceof Pt}class Pt{constructor(n,e){_(this,"_willBeUnregistered",!1);_(this,"unregisterOnNextCall",!1);this.callback=n,this.observable=e}dispose(){this.observable.remove(this)}}class Ht{constructor(n){_(this,"_observers",new Array);_(this,"_eventState");_(this,"_onObserverAdded");this._eventState=new Wn,n&&(this._onObserverAdded=n)}get observers(){return this._observers}add(n,e=!1,s=!1){if(!n)return null;const r=new Pt(n,this);return r.unregisterOnNextCall=s,e?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),r}addOnce(n){return this.add(n,void 0,!0)}remove(n){return n&&this._observers.indexOf(n)!==-1?(this._deferUnregister(n),!0):!1}removeCallback(n){for(let e=0;e<this._observers.length;e++){const s=this._observers[e];if(!s._willBeUnregistered&&s.callback===n)return this._deferUnregister(s),!0}return!1}makeObserverTopPriority(n){this._remove(n),this._observers.unshift(n)}makeObserverBottomPriority(n){this._remove(n),this._observers.push(n)}notifyObservers(n){if(!this._observers.length)return null;const e=this._eventState;e.skipNextObservers=!1,e.lastReturnValue=n,e.isStopPropagation=!1;let s=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(!i._willBeUnregistered&&(e.lastReturnValue=i.callback(n,e),i.unregisterOnNextCall&&this._deferUnregister(i),e.isStopPropagation&&(s=!0),e.skipNextObservers))return{lastReturnValue:e.lastReturnValue,stopPropagation:s}}return{lastReturnValue:e.lastReturnValue,stopPropagation:s}}notifyObserversWithPromise(n){let e=Promise.resolve(n);if(!this._observers.length)return e;const s=this._eventState;s.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];s.skipNextObservers||i._willBeUnregistered||(e=e.then(()=>i.callback(n,s)),i.unregisterOnNextCall&&this._deferUnregister(i))}return e.then(()=>n)}notifyObserver(n,e){if(n._willBeUnregistered)return;const s=this._eventState;return s.skipNextObservers=!1,n.callback(e,s),n.unregisterOnNextCall&&this._deferUnregister(n),{lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const n=new Ht;return n._observers=this._observers.slice(0),n}_deferUnregister(n){n.unregisterOnNextCall=!1,n._willBeUnregistered=!0,setTimeout(()=>{this._remove(n)},0)}_remove(n){if(!n)return!1;const e=this._observers.indexOf(n);return e!==-1?(this._observers.splice(e,1),!0):!1}}function U(t){let n=!1;return t?Qr(t)?{dispose:()=>t.unsubscribe()}:Bn(t)?{dispose:()=>{n||(n=!0,t.dispose())}}:typeof t=="function"?{dispose:()=>{n||(n=!0,t())}}:t:U(()=>{})}function ti(t){return U(()=>{t.unsubscribe()})}class re{constructor(){_(this,"_disposables",new Set)}add(n){const e=U(n);return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(n=>{n.dispose()}),this._disposables.clear()}}class D{constructor(){_(this,"_disposed",!1);_(this,"_collection",new re)}disposeWithMe(n){return this._collection.add(n)}ensureNotDisposed(){if(this._disposed)throw new Error("[Disposable]: object is disposed!")}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class ei extends D{constructor(){super(...arguments);_(this,"dispose$",new O.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class _t{static hasLength(n,e){return n.length===e}static getValueType(n){return Object.prototype.toString.apply(n)}static isObject(n){return this.getValueType(n)==="[object Object]"}static isIterable(n){return n[Symbol.iterator]!=null}static isNumber(n){return this.getValueType(n)==="[object Number]"}}function Ft(t,n){const e=t.indexOf(n);return e>-1?(t.splice(e,1),!0):!1}function ni(t){const n=new Set,e=[];for(const s of t)n.has(s)||(n.add(s),e.push(s));return e}function si(t,n){for(let e=t.length-1;e>-1;e--){const s=t[e];if(n(s,e))return s}return null}function ri(t,n){if(t.length===0)return t;const e=n%t.length;return t.slice(e).concat(t.slice(0,e))}function ii(t,n){const e=new Map;return t.forEach(s=>{const r=n(s);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(s)}),e}const T=Symbol("newer"),M=Symbol("older");class kn{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[T],{done:!1,value:n.key}):{done:!0,value:void 0}}}class Gn{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[T],{done:!1,value:n.value}):{done:!0,value:void 0}}}class $n{constructor(n){_(this,"entry");this.entry=n}[Symbol.iterator](){return this}next(){const n=this.entry;return n?(this.entry=n[T],{done:!1,value:[n.key,n.value]}):{done:!0,value:void 0}}}class ie{constructor(n,e){_(this,"key");_(this,"value");_(this,La);_(this,Ta);this.key=n,this.value=e,this[T]=void 0,this[M]=void 0}toJSON(){return{key:this.key,value:this.value}}}La=T,Ta=M;class Vn{constructor(...n){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(_t.hasLength(n,1)){if(_t.isNumber(n[0])){const e=n[0];this._initialize(e,void 0);return}if(_t.isIterable(n[0])){const e=n[0];this._initialize(0,e);return}return}if(_t.hasLength(n,2)){const e=n[0],s=n[1];this._initialize(e,s)}}onShift(n){if(this._onShiftListeners.indexOf(n)===-1)return this._onShiftListeners.push(n),U(()=>Ft(this._onShiftListeners,n));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(n,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=n,this._keymap=new Map,e&&(this.assign(e),n<1&&(this.limit=this.size))}_markEntryAsUsed(n){n!==this.newest&&(n[T]&&(n===this.oldest&&(this.oldest=n[T]),n[T][M]=n[M]),n[M]&&(n[M][T]=n[T]),n[T]=void 0,n[M]=this.newest,this.newest&&(this.newest[T]=n),this.newest=n)}assign(n){let e,s=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=n[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new ie(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[T]=o,o[M]=e):this.oldest=o,e=o,s--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(n,e){let s=this._keymap.get(n);return s?(s.value=e,this._markEntryAsUsed(s),this):(this._keymap.set(n,s=new ie(n,e)),this.newest?(this.newest[T]=s,s[M]=this.newest):this.oldest=s,this.newest=s,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const n=this.oldest;if(n)return this.oldest&&this.oldest[T]?(this.oldest=this.oldest[T],this.oldest[M]=void 0):(this.oldest=void 0,this.newest=void 0),n[T]=n[M]=void 0,this._keymap.delete(n.key),--this.size,this._onShiftListeners.forEach(e=>e(n)),[n.key,n.value]}get(n){const e=this._keymap.get(n);if(e)return this._markEntryAsUsed(e),e.value}has(n){return this._keymap.has(n)}find(n){const e=this._keymap.get(n);return e?e.value:void 0}delete(n){const e=this._keymap.get(n);if(e)return this._keymap.delete(e.key),e[T]&&e[M]?(e[M][T]=e[T],e[T][M]=e[M]):e[T]?(e[T][M]=void 0,this.oldest=e[T]):e[M]?(e[M][T]=void 0,this.newest=e[M]):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 kn(this.oldest)}values(){return new Gn(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new $n(this.oldest)}forEach(n,e){typeof e!="object"&&(e=this);let s=this.oldest;for(;s;)n.call(e,s.value,s.key,this),s=s[T]}toJSON(){const n=new Array(this.size);let e=0,s=this.oldest;for(;s;)n[e++]={key:s.key,value:s.value},s=s[T];return n}toString(){let n="",e=this.oldest;for(;e;)n+=`${String(e.key)}:${e.value}`,e=e[T],e&&(n+=" < ");return n}}function y(t){let n=0;const e=Object.keys(t);for(const s of e){const r=Number(s);n=Math.max(n,r)}return n+1}function oe(t,n,e){const s=y(e),r=e;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=n}function ae(t,n,e){const s=Object.keys(e).reduce((r,i)=>Math.max(r,Number.parseInt(i)),0)+1;for(let r=t;r<s;r++)r<t+n?delete e[r]:e[r]!==void 0&&(e[r-n]=e[r],delete e[r])}function oi(t,n){const e=t,s=Object.keys(e),r=s.length,i=n,o=Object.keys(i),a=o.length,l={};let c=0;for(let h=0;h<r;h++,c++){const d=s[h];l[c]=e[d]}for(let h=0;h<a;h++,c++){const d=o[h];l[c]=i[d]}return l}function ai(t,n,e){const s=e;if(y(e)>0){const i={};let o=0;for(let a=t;a<=n;a++)s[a]&&(i[o]=s[a],o++);return i}return{}}function le(t,n,e,s){const r=t>e;if(!r&&t+n>e)throw new Error("Invalid move operation");r?li(t,n,e,s):ui(t,n,e,s)}function li(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+n]=a,a===void 0&&delete r[o+n]}i.forEach((o,a)=>{r[e+a]=o,o===void 0&&delete r[e+a]})}function ui(t,n,e,s){const r=s,i=[];for(let o=t;o<t+n;o++)i.push(r[o]);for(let o=t+n;o<e;o++){const a=r[o];r[o-n]=a,a===void 0&&delete r[o-n]}i.forEach((o,a)=>{r[e+a-n]=o,o===void 0&&delete r[e+a-n]})}class V{constructor(n={}){_(this,"_matrix");this._setOriginValue(n)}static MakeObjectMatrixSize(n){return new V({[n-1]:{}})}getMatrix(){return this._matrix}forEach(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,o)===!1)return this}return this}forRow(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(n(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(n){const e=this._matrix,s=Object.keys(e);for(const r of s){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const c=Number(l),h=o[Number(l)];if(n(i,c,h)===!1)return this}}return this}swapRow(n,e){const s=this._matrix[n],r=this._matrix[e];this._matrix[n]=r,this._matrix[e]=s}getRow(n){return this._matrix[n]}getRowOrCreate(n){let e=this.getRow(n);return e==null&&(e={},this._matrix[n]=e),e}reset(){this._setOriginValue({})}hasValue(){const n=this._matrix,e=Object.keys(n);if(e.length===0)return!1;for(const s of e){const r=Number(s),i=n[r];if(Object.keys(i).length>0)return!0}return!1}getValue(n,e){var s,r;return(r=(s=this._matrix)==null?void 0:s[n])==null?void 0:r[e]}setValue(n,e,s){const r=this.getRowOrCreate(n);r[e]=s}deleteValue(n,e){var s,r;(r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e]}realDeleteValue(n,e){var s,r,i;if((r=(s=this._matrix)==null?void 0:s[n])==null||delete r[e],this.getRow(n)){const o=this.getRow(n);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[n])}}setRow(n,e){this._matrix[n]=e}moveRows(n,e,s){le(n,e,s,this._matrix)}moveColumns(n,e,s){this.forEach((r,i)=>{le(n,e,s,i)})}insertRows(n,e){for(let s=n;s<n+e;s++)oe(s,{},this._matrix)}insertColumns(n,e){for(let s=n;s<n+e;s++)this.forEach((r,i)=>{oe(s,void 0,i)})}removeRows(n,e){ae(n,e,this._matrix)}removeColumns(n,e){this.forEach((s,r)=>{ae(n,e,r)})}getFragment(n,e,s,r){const i=new V;let o=0;for(let a=n;a<=e;a++){const l={};let c=0;for(let h=s;h<=r;h++){const d=this.getValue(a,h);l[c]=d,c++}i.setRow(o,l),o++}return i}getSlice(n,e,s,r){const i=new V;for(let o=n;o<=e;o++)for(let a=s;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,m.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return y(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=y(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:s,endColumn:r}}toNativeArray(){const n=new Array;return this.forValue((e,s,r)=>{n.push(r)}),n}toArray(){const n=[];return this.forRow((e,s)=>{n[e]==null&&(n[e]=[]),s.forEach(r=>{n[e][r]=this.getValue(e,r)})}),n}toFullArray(){const n=this.getRange(),{endColumn:e,endRow:s}=n,r=[];for(let i=0;i<=s;i++){const o=Array(e+1).fill(void 0);r.push(o)}return this.forValue((i,o,a)=>{r[i][o]=a}),r}toJSON(){return this._matrix}clone(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getData(){const n=JSON.stringify(this._matrix);return JSON.parse(n)}getArrayData(){let n=0,e=0,s=!1,r=!1;const i=new V;return this.forEach((o,a)=>{s||(s=!0,n=o),Object.keys(a).forEach(l=>{const c=Number(l);r?c<e&&(e=c):(r=!0,e=c);const h=this.getValue(o,c);i.setValue(o-n,c-e,h)})}),i.getData()}getDataRange(){let n=0,e=0,s=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,n=a),l==null)return;const c=y(l)-1;c>s&&(s=c),Object.keys(l).forEach(h=>{const d=Number(h);o?d<e&&(e=d):(o=!0,e=d)}),a>r&&(r=a)}),{startRow:n,startColumn:e,endRow:r,endColumn:s}}getDiscreteRanges(){const n=[];return this.forEach((e,s)=>{Object.keys(s).forEach(r=>{const i=Number(r);let o=!1;for(const a of n)if(e>=a.startRow&&e<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(e,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||n.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),n}merge(n){this.forValue((e,s)=>{const r=n.getValue(e,s);r!=null&&this.setValue(e,s,r)})}_setOriginValue(n={}){this._matrix=n}}var ue=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(ue||{});class xn{constructor(){_(this,"status","init")}}const ci=t=>t.some(n=>n.status==="init")?"init":t.some(n=>n.status==="fetching")?"fetching":"done",Z=class Z{static clone(n){return n.rangeType!==void 0?{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn,rangeType:n.rangeType}:{startRow:n.startRow,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn}}static equals(n,e){return n==null||e==null?!1:n.endRow===e.endRow&&n.endColumn===e.endColumn&&n.startRow===e.startRow&&n.startColumn===e.startColumn&&(n.rangeType===e.rangeType||n.rangeType===void 0&&e.rangeType===p.NORMAL||e.rangeType===void 0&&n.rangeType===p.NORMAL)}static intersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,c=e.startColumn,h=e.endColumn,d=Math.abs(i+o-c-h),f=Math.abs(i-o)+Math.abs(c-h),E=Math.abs(s+r-a-l),g=Math.abs(s-r)+Math.abs(a-l);return d<=f&&E<=g}static getIntersects(n,e){const s=n.startRow,r=n.endRow,i=n.startColumn,o=n.endColumn,a=e.startRow,l=e.endRow,c=e.startColumn,h=e.endColumn;let d,f,E,g;if(a<=r)a>=s?f=a:f=s;else return null;if(l>=s)l>=r?g=r:g=l;else return null;if(c<=o)c>i?d=c:d=i;else return null;if(h>=i)h>=o?E=o:E=h;else return null;return{startRow:f,endRow:g,startColumn:d,endColumn:E,rangeType:p.NORMAL}}static contains(n,e){return n.startRow<=e.startRow&&n.endRow>=e.endRow&&n.startColumn<=e.startColumn&&n.endColumn>=e.endColumn}static realContain(n,e){return Z.contains(n,e)&&(n.startRow<e.startRow||n.endRow>e.endRow||n.startColumn<e.startColumn||n.endColumn>e.endColumn)}static union(...n){return n.reduce((e,s)=>({startRow:Math.min(e.startRow,s.startRow),startColumn:Math.min(e.startColumn,s.startColumn),endRow:Math.max(e.endRow,s.endRow),endColumn:Math.max(e.endColumn,s.endColumn),rangeType:p.NORMAL}),n[0])}static subtract(n,e){if(e.startRow>n.endRow||e.endRow<n.startRow||e.startColumn>n.endColumn||e.endColumn<n.startColumn)return[n];const s=[];e.startRow>=n.startRow&&s.push({startRow:n.startRow,startColumn:n.startColumn,endRow:e.startRow-1,endColumn:n.endColumn}),e.endRow<=n.endRow&&s.push({startRow:e.endRow+1,startColumn:n.startColumn,endRow:n.endRow,endColumn:n.endColumn});const r=Math.max(n.startRow,e.startRow),i=Math.min(n.endRow,e.endRow);return e.startColumn>=n.startColumn&&s.push({startRow:r,startColumn:n.startColumn,endRow:i,endColumn:e.startColumn-1}),e.endColumn<=n.endColumn&&s.push({startRow:r,startColumn:e.endColumn+1,endRow:i,endColumn:n.endColumn}),s.filter(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}};_(Z,"getRelativeRange",(n,e)=>({startRow:n.startRow-e.startRow,endRow:n.endRow-n.startRow,startColumn:n.startColumn-e.startColumn,endColumn:n.endColumn-n.startColumn})),_(Z,"getPositionRange",(n,e,s)=>({...s||{},startRow:s&&[v.ROW,v.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:n.startRow+e.startRow,endRow:s&&[v.ROW,v.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:n.endRow+n.startRow+e.startRow,startColumn:s&&[v.COLUMN,v.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:n.startColumn+e.startColumn,endColumn:s&&[v.COLUMN,v.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:n.endColumn+n.startColumn+e.startColumn})),_(Z,"moveHorizontal",(n,e=0,s=0)=>({...n,startColumn:n.startColumn+e,endColumn:n.endColumn+e+s})),_(Z,"moveVertical",(n,e=0,s=0)=>({...n,startRow:n.startRow+e,endRow:n.endRow+e+s})),_(Z,"moveOffset",(n,e,s)=>({...n,startRow:n.startRow+s,endRow:n.endRow+s,startColumn:n.startColumn+e,endColumn:n.endColumn+e}));let z=Z;class hi{constructor(n,e){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=n,this._keys=e,n.forEach(s=>{this._initKeyMap(s)})}_initKeyMap(n){this._keys.forEach(e=>{const s=n[e],r=this._keyMaps.get(e)||new Map;r.set(s,n),this._keyMaps.set(e,r)})}getValue(n,e){const s=e||this._keys;for(let r=0;r<s.length;r++){const i=this._keyMaps.get(s[r]);if(i!=null&&i.has(n))return i.get(n)}return null}hasValue(n){for(let e=0;e<this._keys.length;e++){const s=this._keyMaps.get(this._keys[e]);if(s!=null&&s.has(n))return!0}return!1}addValue(n){this._values.push(n),this._initKeyMap(n)}setValue(n,e,s){const r=this.getValue(n);r&&Object.keys(r).includes(e)&&(r[e]=s)}deleteValue(n){const e=this.getValue(n);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const s=this._values.findIndex(r=>r===e);this._values.splice(s,1)}}getValues(){return this._values}getKeyMap(n){var e;return[...((e=this._keyMaps.get(n))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function ce(t,n,e,s){return{forEach(r){for(let i=t;i<=n;i++)for(let o=e;o<=s;o++)r(i,o)}}}function di(t){if(t==null||t.length===0)return Number.NaN;const n=t.toLowerCase().split(""),e=n.length,s=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=s(n[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const pt=65,jn=90,_i=97;function fi(t){const n=jn-pt+1;let e="";for(;t>=0;)e=String.fromCharCode(t%n+pt)+e,t=Math.floor(t/n)-1;return e}function Kn(t,n){let e="";for(;n>0;)e+=t,n--;return e}function Ei(t,n=!1){const e=jn-pt+1;let s=_i;n&&(s=pt);const r=String.fromCharCode(t%e+s),i=Math.floor(t/e)+1;return Kn(r,i)}function gi(t,n){return t.zIndex>n.zIndex?1:t.zIndex===n.zIndex?0:-1}function Ri(t,n){return t.zIndex>n.zIndex?-1:t.zIndex===n.zIndex?0:1}function lt(t="index",n=1){return(e,s)=>e[t]>s[t]?n:e[t]===s[t]?0:-n}function mi(t,n){let e;return function(...s){const r=this,i=function(){e=null,t.apply(r,s)};clearTimeout(e),e=setTimeout(i,n)}}function Wt(t,n,e){const{dataStream:s,textRuns:r=[]}=t;let i=n;const o=[];for(const a of r){const{st:l,ed:c}=a;m.hasIntersectionBetweenTwoRanges(n,e,l,c)&&(l>i?(o.push(s.slice(i,l)),o.push(he(s,{...a,ed:Math.min(c,e)}))):o.push(he(s,{...a,st:i,ed:Math.min(c,e)}))),i=Math.max(n,Math.min(c,e))}return i!==e&&o.push(s.slice(i,e)),o.join("")}function Ci(t,n=!0){var e;if(n&&((e=t.paragraphs)!=null&&e.length)){const{dataStream:s,paragraphs:r=[]}=t;let i="",o=-1;for(const a of r){const{startIndex:l,paragraphStyle:c={}}=a,{spaceAbove:h,spaceBelow:d,lineSpacing:f}=c,E=[];h!=null&&(typeof h=="number"?E.push(`margin-top: ${h}px`):E.push(`margin-top: ${h.v}px`)),d!=null&&(typeof d=="number"?E.push(`margin-bottom: ${d}px`):E.push(`margin-bottom: ${d.v}px`)),f!=null&&E.push(`line-height: ${f}`),l>o+1?i+=`<p class="UniverNormal" ${E.length?`style="${E.join("; ")};"`:""}>${Wt(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${E.length?`style="${E.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=Wt(t,o,s.length)),i}else return Wt(t,0,t.dataStream.length)}function he(t,n){const{st:e,ed:s,ts:r={}}=n,{ff:i,fs:o,it:a,bl:l,ul:c,st:h,ol:d,bg:f,cl:E,va:g}=r;let R=t.slice(e,s);const C=[];return a===I.TRUE&&(R=`<i>${R}</i>`),g===at.SUPERSCRIPT?R=`<sup>${R}</sup>`:g===at.SUBSCRIPT&&(R=`<sub>${R}</sub>`),(c==null?void 0:c.s)===I.TRUE&&(R=`<u>${R}</u>`),(h==null?void 0:h.s)===I.TRUE&&(R=`<s>${R}</s>`),l===I.TRUE&&(R=`<strong>${R}</strong>`),i&&C.push(`font-family: ${i}`),E&&C.push(`color: ${E.rgb}`),o&&C.push(`font-size: ${o}pt`),d&&C.push("text-decoration: overline"),f&&C.push(`background: ${f.rgb}`),C.length?`<span style="${C.join("; ")};">${R}</span>`:R}const ft={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Oi={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ii={startRow:0,startColumn:0,endRow:0,endColumn:0},Ai={row:0,column:0},Bt={ff:"Arial",fs:11,it:I.FALSE,bl:I.FALSE,ul:{s:I.FALSE},st:{s:I.FALSE},ol:{s:I.FALSE},tr:{a:0,v:I.FALSE},td:ut.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:et.UNSPECIFIED,vt:ot.UNSPECIFIED,tb:ct.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Yn={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var yn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(yn||{});function kt(t,n){const{textRuns:e=[]}=n;let s=0;for(const i of e){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return I.FALSE;switch(t){case"bl":case"it":{if(o[t]===I.FALSE)return I.FALSE;break}case"ul":case"st":{if(o[t].s===I.FALSE)return I.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return n.dataStream.indexOf(`\r
4
- `)===s?I.TRUE:I.FALSE}class rt{constructor(n,e,s){_(this,"_range");_(this,"_worksheet");this._deps=s,this._range=e,this._worksheet=n}static foreach(n,e){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n;for(let a=s;a<=i;a++)for(let l=r;l<=o;l++)e(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=[];for(let o=n;o<=e;o++){const a=[];for(let l=s;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=n;a<=e;a++)for(let l=s;l<=r;l++)o.setValue(a-n,l-s,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:n,endRow:e,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=m.numToWord(s+1)+(n+1),o=m.numToWord(r+1)+(e+1)):(i=m.numToWord(r+1)+(e+1),o=m.numToWord(s+1)+(n+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||Bt.bg.rgb}))}getCell(n,e){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:s+n,endRow:s+n,startColumn:i+e,endColumn:i+e};return new rt(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(n={}){return this.getObjectValues(n)[0][0]}getObjectValues(n={}){var a;const{startRow:e,endRow:s,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,s,r,i).getData();if(n.isIncludeStyle){const l=this._deps.getStyles();for(let c=0;c<=s-e;c++)for(let h=0;h<=i-r;h++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[h])==null)continue;const d=o[c][h].s;d&&(o[c][h].s=l.get(d))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>{var i;const r=n.getStyleByCell(s);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||Bt.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?kt("ul",n.body)===I.TRUE?{s:I.TRUE}:{s:I.FALSE}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles("ol")}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?kt("st",n.body)===I.TRUE?{s:I.TRUE}:{s:I.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?n.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...n.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?kt("it",n.body)===I.TRUE?St.ITALIC:St.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,s;const{p:n}=(e=this.getValue())!=null?e:{};return n&&Array.isArray((s=n.body)==null?void 0:s.textRuns)&&n.body.textRuns.length>0?kt("bl",n.body)===I.TRUE?Lt.BOLD:Lt.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:n,_worksheet:e}=this,{startRow:s,endRow:r}=n;let i=0;for(let o=0;o<=r-s;o++){const a=e.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:n,endColumn:e}=this._range;return e-n+1}getNumRows(){const{startRow:n,endRow:e}=this._range;return e-n+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(n=>n.map(e=>(e==null?void 0:e.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const n=this._deps.getStyles();return this.getValues().map(e=>e.map(s=>n.getStyleByCell(s)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:n,_worksheet:e}=this,{startColumn:s,endColumn:r}=n;let i=0;for(let o=0;o<=r-s;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(n){rt.foreach(this._range,n)}_getStyles(n){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[n]||Bt[n]}))}}function Ni(t,n){if(t.length===0||t[0].length===0)return null;const e=new Array(t[0].length).fill(0);let s=0,r=null;for(let i=0;i<t.length;i++){for(let a=0;a<t[0].length;a++)e[a]=n(t[i][a])?e[a]+1:0;const o=Si(e);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function Si(t){const n=[];let e=0,s={area:0,height:0,start:0,end:0},r=0;for(;r<t.length;)if(n.length===0||t[r]>=t[n[n.length-1]])n.push(r++);else{const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}for(;n.length>0;){const i=t[n.pop()],o=n.length===0?r:r-n[n.length-1]-1;i*o>e&&(e=i*o,s={area:e,height:i,start:n.length===0?0:n[n.length-1]+1,end:r-1})}return s}function Li(t,n){rt.foreach(n,(e,s)=>{t[e][s]=void 0})}function Ti(t,n){const e=t.toFullArray(),s=[];for(;;){const r=Ni(e,n);if(!r)break;s.push(r),Li(e,r)}return s}function bi(t,n,e,s=!1){let r={...t};const i=r.startAbsoluteRefType||v.NONE,o=r.endAbsoluteRefType||v.NONE;return!s&&i===v.ALL&&o===v.ALL?r:s||i===v.NONE&&o===v.NONE?z.moveOffset(r,n,e):(i===v.NONE?r={...r,startRow:r.startRow+e,startColumn:r.startColumn+n}:i===v.COLUMN?r={...r,startRow:r.startRow+e}:i===v.ROW&&(r={...r,startColumn:r.startColumn+n}),o===v.NONE?r={...r,endRow:r.endRow+e,endColumn:r.endColumn+n}:o===v.COLUMN?r={...r,endRow:r.endRow+e}:o===v.ROW&&(r={...r,endColumn:r.endColumn+n}),r)}async function zn(t){for(const[n,e]of t.entries())try{if(!await e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}function Xn(t){for(const[n,e]of t.entries())try{if(!e())return{index:n,result:!1}}catch(s){return{index:n,result:!1,error:s}}return{result:!0,index:-1}}const Et=S.createIdentifier("univer.context-service");class qn extends D{constructor(){super(...arguments);_(this,"_contextChanged$",new O.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var s;return(s=this._contextMap.get(e))!=null?s:!1}setContextValue(e,s){this._contextMap.set(e,s),this._contextChanged$.next({[e]:s})}subscribeContextValue$(e){return new O.Observable(s=>{const r=this._contextChanged$.pipe(O.filter(i=>typeof i[e]<"u")).subscribe(i=>s.next(i[e]));return this._contextMap.has(e)&&s.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var Jn=(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))(Jn||{});const X=S.createIdentifier("univer.log");class Zn extends D{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...s){const r=s[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...s.slice(1)):e(...s)}}var wi=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,Ui=(t,n,e,s)=>{for(var r=s>1?void 0:s?vi(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&wi(n,e,r),r},Qn=(t,n)=>(e,s)=>n(e,s,t),gt=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(gt||{});const Rt=S.createIdentifier("anywhere.command-service");class Di{constructor(){_(this,"_commands",new Map)}registerCommand(n){if(this._commands.has(n.id))throw new Error(`[CommandRegistry]: command "${n.id}" has been registered before.`);return this._commands.set(n.id,n),U(()=>{var e;this._commands.delete(n.id),(e=n.onDispose)==null||e.call(n)})}hasCommand(n){return this._commands.has(n)}getCommand(n){return this._commands.has(n)?[this._commands.get(n)]:null}}const ts={id:"nil",type:0,handler:()=>!0};u.CommandService=class{constructor(n,e){_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=n,this._logService=e,this._commandRegistry=new Di,this._registerCommand(ts)}hasCommand(n){return this._commandRegistry.hasCommand(n)}registerCommand(n){return this._registerCommand(n)}registerMultipleCommand(n){return this._registerMultiCommand(n)}beforeCommandExecuted(n){if(this._beforeCommandExecutionListeners.indexOf(n)===-1)return this._beforeCommandExecutionListeners.push(n),U(()=>{const e=this._beforeCommandExecutionListeners.indexOf(n);this._beforeCommandExecutionListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(n){if(this._commandExecutedListeners.indexOf(n)===-1)return this._commandExecutedListeners.push(n),U(()=>{const e=this._commandExecutedListeners.indexOf(n);this._commandExecutedListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(n,e,s){const r=this._commandRegistry.getCommand(n);if(r){const[i]=r,o={id:i.id,type:i.type,params:e},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(c=>c(o,s));const l=await this._execute(i,e,s);return this._commandExecutedListeners.forEach(c=>c(o,s)),a.dispose(),l}throw new Error(`[CommandService]: command "${n}" is not registered.`)}syncExecuteCommand(n,e,s){var i;const r=this._commandRegistry.getCommand(n);if(r){const[o]=r,a={id:o.id,type:o.type,params:e};if(o.type===2){const h=si(this._commandExecutionStack,d=>d.type===0);h&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=h.id)}const l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(h=>h(a,s));const c=this._syncExecute(o,e,s);return this._commandExecutedListeners.forEach(h=>h(a,s)),l.dispose(),c}throw new Error(`[CommandService]: command "${n}" is not registered.`)}_pushCommandExecutionStack(n){return this._commandExecutionStack.push(n),U(()=>Ft(this._commandExecutionStack,n))}_registerCommand(n){return this._commandRegistry.registerCommand(n)}_registerMultiCommand(n){const e=this._commandRegistry.getCommand(n.id);let s;if(e){if(e[0].multi!==!0)throw new Error("Command has registered as a single command.");s=e[0]}else{const i=new re;s=new Mi(n.id),i.add(this._commandRegistry.registerCommand(s)),i.add(U(()=>{this._multiCommandDisposables.delete(n.id)})),this._multiCommandDisposables.set(n.id,i)}const r=s.registerImplementation(n);return U(()=>{var i;r.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(n.id))==null||i.dispose()})}async _execute(n,e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${n.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(n.handler,e,s),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(n,e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${n.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(n.handler,e,s),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}},u.CommandService=Ui([Qn(0,S.Inject(S.Injector)),Qn(1,X)],u.CommandService);class Mi{constructor(n){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(n,e)=>{if(!this._implementations.length)return!1;const s=n.get(X),r=n.get(Et),i=n.get(S.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=n,this.name=n}registerImplementation(n){const e={command:n};return this._implementations.push(e),this._implementations.sort((s,r)=>r.command.priority-s.command.priority),U(()=>{var r;const s=this._implementations.indexOf(e);this._implementations.splice(s,1),(r=n.onDispose)==null||r.call(n)})}hasImplementations(){return this._implementations.length>0}}function de(t,n,e){const s=t.map(r=>()=>n.syncExecuteCommand(r.id,r.params,e));return Xn(s)}function Pi(t,n,e){const s=t.map(r=>()=>n.executeCommand(r.id,r.params,e));return zn(s)}function es(t){return new O.Observable(n=>{const e=t((...s)=>n.next(s));return()=>e==null?void 0:e.dispose()})}const Hi=t=>new Promise(n=>{O.merge(es(t.onCommandExecuted).pipe(x.filter(([e])=>e.type===gt.MUTATION)),O.timer(300)).pipe(x.debounceTime(16),x.first()).subscribe(()=>{n()})});var k=(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))(k||{});function ns(t){return!!(t&&t.code&&t.code!==k.OK&&t.code!=="OK")}var A=(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))(A||{});class Gt extends D{}class _e{constructor(){_(this,"_data",[])}static create(){return new _e}add(n){this._data.indexOf(n)>-1||this._data.push(n)}delete(n){const e=this._data.indexOf(n);this._data.splice(e,1)}getData(){return this._data}}class fe{constructor(){_(this,"_data",new Map)}static create(){return new fe}add(n,e){this._data.has(n)||this._data.set(n,e)}delete(n){this._data.delete(n)}getData(){return this._data}}class ss{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(n){this.cursor+=n}moveCursorTo(n){this.cursor=n}}var rs=(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))(rs||{}),Ee=(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))(Ee||{});function ge(t){const n=[];for(const e of t){const{st:s,ed:r,ts:i}=e;if(e.sId===void 0&&delete e.sId,s===r||m.isEmptyObject(i)&&e.sId==null)continue;if(n.length===0){n.push(e);continue}const o=n.pop();bn(e,o)&&m.hasIntersectionBetweenTwoRanges(o.st,o.ed,e.st,e.ed)?n.push({...e,st:o.st,ed:r}):n.push(o,e)}return n}function is(t,n,e,s){var c;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(c=n.textRuns)!=null?c:[];if(l.length)for(let h=0,d=l.length;h<d;h++){const f=l[h];f.st+=s,f.ed+=s}for(let h=0;h<o;h++){const d=r[h],{st:f,ed:E}=d;if(E<s)i.push(d);else if(s>=f&&s<=E)if(a)d.st+=e,d.ed+=e,i.push(d);else{a=!0,d.ed+=e;const g=[];if(l.length){const R={...d,st:f,ed:l[0].st};g.push(R),g.push(...l);const C=l[l.length-1],L={...d,st:C.ed,ed:E+e};g.push(L)}else g.push(d);i.push(...g)}else d.st+=e,d.ed+=e,a||(a=!0,i.push(...l)),i.push(d)}a||(a=!0,i.push(...l)),t.textRuns=ge(i)}function Re(t,n,e,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=n,a=[];let l=-1;for(let h=0,d=r.length;h<d;h++){const f=r[h],{startIndex:E}=f;E>=s&&(f.startIndex+=e),l===-1&&E>=s&&(l=h),a.push(f.startIndex)}let c=-1;if(i){for(let h=0,d=i.length;h<d;h++){const f=i[h];f.startIndex+=s;const E=f.startIndex;c=a.indexOf(E)}if(o===Ee.PARAGRAPH&&i.length===1){const h=r[l],d=i[0],f=h.paragraphStyle,E=h.bullet;h.paragraphStyle=d.paragraphStyle,h.bullet=d.bullet,d.paragraphStyle=f,d.bullet=E}c!==-1&&r.splice(c,1),r.push(...i),r.sort(lt("startIndex"))}}function Fi(t,n,e,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=s&&(l.startIndex+=e)}const i=n.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function os(t,n,e,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=s&&(l.startIndex+=e)}const i=n.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function me(t,n,e,s){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:h}=l;c>s?(l.startIndex+=e,l.endIndex+=e):h>=s-1&&(l.endIndex+=e)}const i=n.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function pi(t,n,e,s){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:h}=l;c>s?(l.startIndex+=e,l.endIndex+=e):h>=s-1&&(l.endIndex+=e)}const i=n.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function as(t,n,e){const{textRuns:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{st:d,ed:f}=h;if(r<=d&&i>=f){o.push({...h,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...h,st:r-r,ed:i-r}),h.ed-=n):r>=d&&r<f?(o.push({...h,st:r-r,ed:f-r}),h.ed=r):i>d&&i<=f?(o.push({...h,st:d-r,ed:i-r}),h.st=i-n,h.ed-=n):d>=i&&(h.st-=n,h.ed-=n);a.push(h)}t.textRuns=a}return o}function ls(t,n,e){const{paragraphs:s}=t,r=e,i=e+n,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<i){o.push({...h,startIndex:d-e});continue}else d>=i&&(h.startIndex-=n);a.push(h)}t.paragraphs=a}return o}function us(t,n,e){const{sectionBreaks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<=i){o.push({...h,startIndex:d-e});continue}else d>i&&(h.startIndex-=n);a.push(h)}t.sectionBreaks=a}return o}function cs(t,n,e){const{customBlocks:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<=i){o.push({...h,startIndex:d-e});continue}else d>i&&(h.startIndex-=n);a.push(h)}t.customBlocks=a}return o}function hs(t,n,e){const{tables:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d,endIndex:f}=h;if(r<=d&&i>=f){o.push({...h,startIndex:d-e,endIndex:f-e});continue}else if(d<=r&&f>=i){const E=ne(d,f,r,i);h.startIndex=E[0],h.endIndex=E[1]}else i<d&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.tables=a}return o}function ds(t,n,e){const{customRanges:s}=t,r=e,i=e+n-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d,endIndex:f}=h;if(r<=d&&i>=f){o.push({...h,startIndex:d-e,endIndex:f-e});continue}else if(d<=r&&f>=i){const E=ne(d,f,r,i);h.startIndex=E[0],h.endIndex=E[1]}else i<d&&(h.startIndex-=n,h.endIndex-=n);a.push(h)}t.customRanges=a}return o}function Wi(t,n,e){const{dataStream:s}=t,r=e,i=e+n,o=as(t,n,e),a=ls(t,n,e),l=us(t,n,e),c=cs(t,n,e),h=hs(t,n,e),d=ds(t,n,e);let f="";return s&&(t.dataStream=Un(s,r,i),f=s.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:h,customRanges:d}}function Bi(t,n,e,s){t.dataStream=vn(t.dataStream,s,n.dataStream),is(t,n,e,s),Re(t,n,e,s),Fi(t,n,e,s),os(t,n,e,s),me(t,n,e,s),pi(t,n,e,s)}var $t=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))($t||{});const ki={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:ht.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:K.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:K.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:63}]}};function Gi(t,n,e,s,r){const i=$i(t,n,e,s,r),o=Vi(t,n,e,s,r),a=xi(t,n,e,s,r),l=ji(t,n,e,s,r),c=Ki(t,n,e,s,r),h=Yi(t,n,e,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:h}}function $i(t,n,e,s,r){const{textRuns:i}=t,{textRuns:o}=n;if(i==null||o==null)return;const a=as(t,e,s);if(r!==H.REPLACE){const l=_s(o,a,r);n.textRuns=l}return is(t,n,e,s),a}function _s(t,n,e){if(n.length===0)return t;t=m.deepClone(t),n=m.deepClone(n);const s=[],r=t.length,i=n.length;let o=0,a=0,l=null;function c(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:E,ed:g,ts:R}=t[o],{st:C,ed:L,ts:P,sId:F}=n[a];let Q;e===H.COVER?Q={...P,...R}:Q={...R,...P},g<C?(c()||s.push(t[o]),o++):L<E?(c()||s.push(n[a]),a++):(s.push({st:Math.min(E,C),ed:Math.max(E,C),ts:E<C?{...R}:{...P},sId:E<C?void 0:F}),s.push({st:Math.max(E,C),ed:Math.min(g,L),ts:Q,sId:F}),g<L?(o++,n[a].st=g):(a++,t[o].st=L),l={st:Math.min(g,L),ed:Math.max(g,L),ts:g<L?{...P}:{...R},sId:g<L?F:void 0})}c();const h=s[s.length-1],d=t[r-1],f=n[i-1];return h.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?s.push(d):s.push(f)),ge(s)}function Vi(t,n,e,s,r){const{paragraphs:i}=t,{paragraphs:o}=n;if(i==null||o==null)return;const a=ls(t,e,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,paragraphStyle:d,bullet:f}=c;let E=[];for(const g of a){const{startIndex:R,paragraphStyle:C,bullet:L}=g;let P,F;if(r===H.COVER?(P={...C,...d},F={listId:"",listType:$t.BULLET_LIST,nestingLevel:0,textStyle:{},...L,...f}):(P={...d,...C},F={listId:"",listType:$t.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...L}),h===R){E.push({startIndex:h,paragraphStyle:P,bullet:F});break}}l.push(...E),E=[]}n.paragraphs=l}return Re(t,n,e,s),a}function xi(t,n,e,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=n;if(i==null||o==null)return;const a=us(t,e,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let d=[];for(const f of a){const{startIndex:E}=f;if(h===E){r===H.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}n.sectionBreaks=l}return Re(t,n,e,s),a}function ji(t,n,e,s,r){const{customBlocks:i}=t,{customBlocks:o}=n;if(i==null||o==null)return;const a=cs(t,e,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let d=[];for(const f of a){const{startIndex:E}=f;if(h===E){r===H.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}n.customBlocks=l}return os(t,n,e,s),a}function Ki(t,n,e,s,r){const{tables:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=hs(t,e,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,endIndex:d}=c;let f=[];for(const E of a){const{startIndex:g,endIndex:R}=E;if(g>=h&&R<=d){r===H.COVER?f.push({...E,...c}):f.push({...c,...E});break}}l.push(...f),f=[]}n.tables=l}return me(t,n,e,s),a}function Yi(t,n,e,s,r){const{customRanges:i}=t,{tables:o}=n;if(i==null||o==null)return;const a=ds(t,e,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,endIndex:d}=c;let f=[];for(const E of a){const{startIndex:g,endIndex:R}=E;if(g>=h&&R<=d){r===H.COVER?f.push({...E,...c}):f.push({...c,...E});break}}l.push(...f),f=[]}n.customRanges=l}return me(t,n,e,s),a}var N=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(N||{});function Ce(t,n,e){const{dataStream:s,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:s.slice(n,e)},a=[];for(const c of r){const h=m.deepClone(c),{st:d,ed:f}=h;m.hasIntersectionBetweenTwoRanges(d,f,n,e)&&(n>=d&&n<=f?a.push({...h,st:n,ed:Math.min(e,f)}):e>=d&&e<=f?a.push({...h,st:Math.max(n,d),ed:e}):a.push(h))}a.length&&(o.textRuns=a.map(c=>{const{st:h,ed:d}=c;return{...c,st:h-n,ed:d-n}}));const l=[];for(const c of i){const{startIndex:h}=c;h>=n&&h<=e&&l.push(m.deepClone(c))}return l.length&&(o.paragraphs=l.map(c=>({...c,startIndex:c.startIndex-n}))),o}function Oe(t,n,e=H.COVER){if(n.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const s={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=n,l=_s(o,r,e);l.length&&(s.textRuns=l);const c=[];let h=0,d=0;for(;h<i.length&&d<a.length;){const f=i[h],E=a[d],{startIndex:g}=f,{startIndex:R}=E;g===R?(c.push(m.deepMerge(f,E)),h++,d++):g<R?(c.push(m.deepClone(f)),h++):(c.push(m.deepClone(E)),d++)}return h<i.length&&c.push(...i.slice(h)),d<a.length&&c.push(...a.slice(d)),c.length&&(s.paragraphs=c),s}function yi(t){const{body:n}=t;if(n==null)return!0;const{textRuns:e=[],paragraphs:s=[]}=n;return e.length===0&&s.length===0}function zi(t=m.generateRandomId(6),n=tt.EN_US,e=""){return{id:t,locale:n,title:e,body:{dataStream:`\r
6
- `,textRuns:[],paragraphs:[{startIndex:0,paragraphStyle:{spaceAbove:5,lineSpacing:1,spaceBelow:0}}],sectionBreaks:[{startIndex:1}]},documentStyle:{pageSize:{width:793.3333333333334,height:1122.6666666666667},marginTop:50,marginBottom:50,marginRight:40,marginLeft:40,renderConfig:{vertexAngle:0,centerAngle:0}},settings:{}}}const Ie={id:"default_doc",documentStyle:{}};class Xi extends Gt{constructor(e){super();_(this,"type",A.UNIVER_DOC);_(this,"snapshot");this.snapshot={...Ie,...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}getParentRenderUnitId(){return this.snapshot.parentRenderUnitId}getSnapshot(){return this.snapshot}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){const{documentStyle:s}=this.snapshot;s.renderConfig==null?s.renderConfig=e:s.renderConfig={...s.renderConfig,...e}}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e}}updateDocumentDataMargin(e){const{t:s,l:r,b:i,r:o}=e,{documentStyle:a}=this.snapshot;s!=null&&(a.marginTop=s),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.marginRight=o)}updateDocumentDataPageSize(e,s){const{documentStyle:r}=this.snapshot;if(!r.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,r.pageSize={width:e,height:s};return}e!==void 0&&(r.pageSize.width=e),s!==void 0&&(r.pageSize.height=s)}updateDrawing(e,s){const{drawings:r}=this,{width:i,height:o,left:a,top:l}=s,c=r==null?void 0:r[e];if(!c)return;const h=c.objectTransform;h.size.width=i,h.size.height=o,h.positionH.posOffset=a,h.positionV.posOffset=l}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class it extends Xi{constructor(e){var r;super(m.isEmptyObject(e)?zi():e);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:m.generateRandomId(s),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={...Ie,...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 s=[],r=new ss;return r.reset(),e.forEach(i=>{if(i=m.deepClone(i),i.t===N.RETAIN){const{coverType:o,body:a,len:l,segmentId:c}=i;if(a!=null){const h=this._updateApply(a,l,r.cursor,o,c);s.push({...i,t:N.RETAIN,coverType:H.REPLACE,body:h})}else s.push({...i,t:N.RETAIN});r.moveCursor(l)}else if(i.t===N.INSERT){const{body:o,len:a,segmentId:l,line:c}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),s.push({t:N.DELETE,len:a,line:c,segmentId:l})}else if(i.t===N.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);s.push({...i,t:N.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),s}sliceBody(e,s){const r=this.getBody();if(r!=null)return Ce(r,e,s)}_updateApply(e,s,r,i=H.COVER,o){if(e==null)throw new Error("updateBody is none");const a=this.snapshot,l=Mt(a,o);if(l==null)throw new Error("no body has changed");return Gi(l,e,s,r,i)}_deleteApply(e,s,r){const i=this.snapshot,o=Mt(i,r);if(o==null)throw new Error("no body has changed");return e<=0?{dataStream:""}:Wi(o,e,s)}_insertApply(e,s,r,i){const o=this.snapshot,a=Mt(o,i);if(s!==0){if(a==null)throw new Error("no body has changed");Bi(a,e,s,r)}}_initializeHeaderFooterModel(){const{headers:e,footers:s}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new it(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new it(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const fs=S.createIdentifier("univer.config-service");class Es{constructor(){_(this,"_config",new Map)}getConfig(n){return this._config.get(n)}setConfig(n,e){this._config.set(n,e)}deleteConfig(n){this._config.delete(n)}}class gs extends D{constructor(){super(...arguments);_(this,"_error$",new O.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}const qi="__default_document_sub_component_id20231101__";class Rs{constructor(){_(this,"_managerInfo",new Map);_(this,"_remove$",new O.Subject);_(this,"remove$",this._remove$.asObservable());_(this,"_andOrUpdate$",new O.Subject);_(this,"andOrUpdate$",this._andOrUpdate$.asObservable());_(this,"_pluginUpdate$",new O.Subject);_(this,"pluginUpdate$",this._pluginUpdate$.asObservable())}getFloatObject(n){return this._getFloatingObject(n)}getFloatObjects(n){return this._getFloatingObjects(n)}dispose(){this._remove$.complete(),this._andOrUpdate$.complete(),this._pluginUpdate$.complete(),this._managerInfo.clear()}clear(n){const e=this._clearByParam(n);this._remove$.next(e)}addOrUpdate(n){const e=this._addByParam(n);this._andOrUpdate$.next(e)}batchAddOrUpdate(n){const e=[];n.forEach(s=>{e.push(...this._addByParam(s))}),this._andOrUpdate$.next(e)}remove(n){const e=this._removeByParam(n);this._remove$.next(e)}pluginUpdateRefresh(n){this._pluginUpdate$.next(n)}_getFloatingObjects(n){var r;if(n==null)return;const{unitId:e,subUnitId:s}=n;return(r=this._managerInfo.get(e))==null?void 0:r.get(s)}_getFloatingObject(n){var i,o;if(n==null)return;const{unitId:e,subUnitId:s,floatingObjectId:r}=n;return(o=(i=this._managerInfo.get(e))==null?void 0:i.get(s))==null?void 0:o.get(r)}_addByParam(n){const{unitId:e,subUnitId:s,floatingObject:r,floatingObjectId:i,behindText:o}=n;this._managerInfo.has(e)||this._managerInfo.set(e,new Map);const a=this._managerInfo.get(e);return a.has(s)||a.set(s,new Map),a.get(s).set(i,r),[{unitId:e,subUnitId:s,floatingObjectId:i,floatingObject:r,behindText:o}]}_clearByParam(n){const e=this._getFloatingObjects(n),{unitId:s,subUnitId:r}=n,i=[];return e==null||e.forEach((o,a)=>{i.push({unitId:s,subUnitId:r,floatingObjectId:a,floatingObject:o})}),e==null||e.clear(),i}_removeByParam(n){const e=this._getFloatingObjects(n),s=e==null?void 0:e.get(n.floatingObjectId);return s==null?[]:(e==null||e.delete(n.floatingObjectId),[{...n,floatingObject:s}])}}const ms=S.createIdentifier("univer.floating-object.service");class Cs{constructor(n={}){_(this,"_styles");_(this,"_cacheMap",new Vn(1e5));this._styles=n,this._generateCacheMap()}each(n){return Object.entries(this._styles).forEach(n),this}search(n,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const s=this._getExistingStyleId(n);return s||"-1"}get(n){return typeof n!="string"?n:(n=String(n),this._styles[n])}add(n,e){const s=m.generateRandomId(6);return this._styles[s]=n,this._cacheMap.set(e,s),s}setValue(n){if(n==null)return;const e=JSON.stringify(n),s=this.search(n,e);return s!=="-1"?s:this.add(n,e)}toJSON(){return this._styles}getStyleByCell(n){let e;n&&m.isObject(n.s)?e=n.s:e=(n==null?void 0:n.s)&&this.get(n.s);const s=n==null?void 0:n.interceptorStyle;return s?{...e,...s}:e}_generateCacheMap(){const{_styles:n,_cacheMap:e}=this;for(const s in n){const r=JSON.stringify(n[s]);e.set(r,s)}}_getExistingStyleId(n){const{_styles:e}=this;for(const s in e)if(m.diffValue(e[s],n))return s;return null}}class Ji{constructor(n,e){_(this,"_columnData",{});this._config=n,this._columnData=e}getColumnData(){return this._columnData}getColVisible(n){const{_columnData:e}=this,s=e[n];return s?s.hd!==I.TRUE:!0}getHiddenCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,s.push({rangeType:p.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:p.COLUMN}),s}getVisibleCols(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,s.push({rangeType:p.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:p.COLUMN}),s}getColumnDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getColumnOrCreate(i);s[r]=o,r++}return s}getSize(){return y(this._columnData)}getColumnWidth(n){const{_columnData:e}=this,s=this._config;let r=0;return r=(e[n]||{hd:I.FALSE,w:s.defaultColumnWidth}).w||s.defaultColumnWidth,r}getColumn(n){const e=this._columnData[n];if(e)return e}getColumnOrCreate(n){const{_columnData:e}=this,s=this._config,r=e[n];if(r)return r;const i={w:s.defaultColumnWidth,hd:I.FALSE};return this._columnData[n]=i,i}}class Zi{constructor(n,e,s){_(this,"_rowData");this._config=n,this._viewModel=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(n,e){const s={};let r=0;for(let i=n;i<n+e;i++){const o=this.getRowOrCreate(i);s[r]=o,r++}return s}getRowHeight(n,e=1){const{_rowData:s}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=s[o+n]||{hd:I.FALSE,h:r.defaultRowHeight},{ia:l,ah:c,h=r.defaultRowHeight}=a;i+=(l==null||l===I.TRUE)&&typeof c=="number"?c:h}return i}getRow(n){return this._rowData[n]}getRowOrCreate(n){const{_rowData:e}=this,s=e[n];if(s)return s;const r=this._config,i={hd:I.FALSE,h:r.defaultRowHeight};return e[n]=i,i}getHiddenRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:p.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:p.ROW}),s}getVisibleRows(n=0,e=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=n;o<=e;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:p.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:p.ROW}),s}getRowRawVisible(n){const e=this.getRow(n);return e?e.hd!==I.TRUE:!0}getSize(){return y(this._rowData)}}const Qi="DEFAULT_WORKSHEET_ROW_COUNT",Os=1e3,to="DEFAULT_WORKSHEET_COLUMN_COUNT",Is=20,eo="DEFAULT_WORKSHEET_ROW_HEIGHT",As=19,no="DEFAULT_WORKSHEET_COLUMN_WIDTH",Ns=73,so="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Ss=46,ro="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Ls=20;function Ts(t){const n={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:I.FALSE,rowCount:Os,columnCount:Is,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Ns,defaultRowHeight:As,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:I.TRUE,rowHeader:{width:Ss,hidden:I.FALSE},columnHeader:{height:Ls,hidden:I.FALSE},selections:["A1"],rightToLeft:I.FALSE};return Object.keys(n).forEach(e=>{const s=e;typeof t[s]>"u"&&(t[s]=n[s])}),t}class bs extends D{constructor(e){super();_(this,"_cellContentInterceptor",null);_(this,"_rowFilteredInterceptor",null);this.getRawCell=e}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,s){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,s):this.getRawCell(e,s)}getRowFiltered(e){var s,r;return(r=(s=this._rowFilteredInterceptor)==null?void 0:s.getRowFiltered(e))!=null?r:!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptor=e,U(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=e,U(()=>this._rowFilteredInterceptor=null)}}class mt{constructor(n,e,s){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=n,this._styles=s,this._snapshot=Ts(e);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:m.generateRandomId(6),this._cellData=new V(o),this._viewModel=new bs((l,c)=>this.getCellRaw(l,c)),this._rowManager=new Zi(this._snapshot,this._viewModel,i),this._columnManager=new Ji(this._snapshot,r)}__interceptViewModel(n){n(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const n=this.getCellMatrix(),e=this.getMergeData();let s=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return n.forEach((c,h)=>{Object.keys(h).forEach(d=>{const f=+d,E=n.getValue(c,f),g=E!=null&&E.s?this._styles.get(E.s):null,R=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(E&&(E.v||E.p)||g!=null&&g.bg||R)&&(a?s=Math.min(s,c):(s=c,a=!0),r=Math.max(r,c),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),e.forEach(c=>{a?s=Math.min(s,c.startRow):(s=c.startRow,a=!0),r=Math.max(r,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:n}=this,e=m.deepClone(n);return new mt(this.unitId,e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(n,e){const s=this._snapshot.mergeData;for(let r=0;r<s.length;r++){const i=s[r];if(z.intersects({startRow:n,startColumn:e,endRow:n,endColumn:e},i))return i}return null}getCell(n,e){return n<0||e<0?null:this._viewModel.getCell(n,e)}getCellRaw(n,e){return this.getCellMatrix().getValue(n,e)}getRowFiltered(n){return this._viewModel.getRowFiltered(n)}getMatrixWithMergedCells(n,e,s,r,i=!1){const o=this.getCellMatrix(),a=this._snapshot.mergeData.filter(c=>z.intersects({startRow:n,startColumn:e,endRow:s,endColumn:r},c)),l=new V;return ce(n,s,e,r).forEach((c,h)=>{const d=i?this.getCellRaw(c,h):this.getCell(c,h);d&&l.setValue(c,h,d)}),a.forEach(c=>{const{startColumn:h,startRow:d,endColumn:f,endRow:E}=c;ce(d,E,h,f).forEach((g,R)=>{g===d&&R===h&&l.setValue(g,R,{...o.getValue(g,R),rowSpan:E-d+1,colSpan:f-h+1}),(g!==d||R!==h)&&l.realDeleteValue(g,R)})}),l}getRange(n,e,s,r){return typeof n=="object"?new rt(this,n,{getStyles:()=>this._styles}):new rt(this,{startRow:n,startColumn:e,endColumn:r||e,endRow:s||n},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:n}=this,{columnCount:e}=n;return e}getMaxRows(){const{_snapshot:n}=this,{rowCount:e}=n;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(n){this._snapshot.rowCount=n}getColumnCount(){return this._snapshot.columnCount}setColumnCount(n){this._snapshot.columnCount=n}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:n}=this,{showGridlines:e}=n;return e===0}getTabColor(){const{_snapshot:n}=this,{tabColor:e}=n;return e}getColumnWidth(n){return this.getColumnManager().getColumnWidth(n)}getRowHeight(n){return this._viewModel.getRowFiltered(n)?0:this.getRowManager().getRowHeight(n)}getRowVisible(n){return this._viewModel.getRowFiltered(n)?!1:this.getRowRawVisible(n)}getRowRawVisible(n){return this.getRowManager().getRowRawVisible(n)}getHiddenRows(n,e){const s=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(n,e);return r.forEach(i=>i.endColumn=s),r}getColVisible(n){return this._columnManager.getColVisible(n)}getHiddenCols(n,e){const s=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(n,e);return r.forEach(i=>i.endRow=s),r}getVisibleRows(){const n=this.getRowCount();return this._rowManager.getVisibleRows(0,n-1)}getVisibleCols(){const n=this.getColumnCount();return this._columnManager.getVisibleCols(0,n-1)}isRightToLeft(){const{_snapshot:n}=this,{rightToLeft:e}=n;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(n){return n&&(n.v!==void 0||n.f!==void 0||n.p!==void 0)}iterateByRow(n,e=!0){const{startRow:s,startColumn:r,endRow:i,endColumn:o}=n,a=this;return{[Symbol.iterator]:()=>{let l=s,c=r;return{next(){for(;;){if(c>o&&(l+=1,c=r),l>i)return{done:!0,value:void 0};const h=a.getCell(l,c),d=!h,f=a.getMergedCell(l,c);if(f){if(l!==f.startRow||c!==f.startColumn){c=f.endColumn+1;continue}if(d&&e){c=f.endColumn+1;continue}const g={row:l,col:c,value:h};return g.colSpan=f.endColumn-f.startColumn+1,g.rowSpan=f.endRow-f.startRow+1,c=f.endColumn+1,{done:!1,value:g}}if(d&&e)c+=1;else{const E={row:l,col:c,value:h};return c+=1,{done:!1,value:E}}}}}}}}iterateByColumn(n,e=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=n,l=this;return{[Symbol.iterator]:()=>{let c=r,h=i;return{next(){for(;;){if(c>o&&(h+=1,c=r),h>a)return{done:!0,value:void 0};const d=l.getMergedCell(c,h);if(d){const g=c!==d.startRow,R=g||h!==d.startColumn;if(s&&R||!s&&g){c=d.endRow+1;continue}const C=l.getCell(d.startRow,d.startColumn);if(!C&&e){c=d.endRow+1;continue}const P={row:c,col:d.startColumn,value:C};return P.colSpan=d.endColumn-d.startColumn+1,P.rowSpan=d.endRow-d.startRow+1,c=d.endRow+1,{done:!1,value:P}}const f=l.getCell(c,h);if(!f&&e)c+=1;else{const g={row:c,col:h,value:f};return c+=1,{done:!1,value:g}}}}}}}}}function io(t){var s,r;if(!t)return"";const n=(r=(s=t.p)==null?void 0:s.body)==null?void 0:r.dataStream;if(n)return n;const e=t.v;return typeof e=="string"?t.t===nt.BOOLEAN?e.toUpperCase():e:typeof e=="number"?t.t===nt.BOOLEAN?e?"TRUE":"FALSE":e.toString():typeof e=="boolean"?e?"TRUE":"FALSE":""}const oo="0.1.10";function ao(t="",n=tt.ZH_CN,e=""){return{id:t,sheetOrder:[],name:e,appVersion:oo,locale:n,styles:{},sheets:{},resources:[]}}var lo=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,co=(t,n,e,s)=>{for(var r=s>1?void 0:s?uo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&lo(n,e,r),r},ho=(t,n)=>(e,s)=>n(e,s,t);function _o(t,n){return`${t.getUnitId()}|${n.getSheetId()}`}u.Workbook=class extends Gt{constructor(e={},s){super();_(this,"type",A.UNIVER_SHEET);_(this,"_sheetCreated$",new O.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new O.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new O.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");this._logService=s;const r=ao();m.isEmptyObject(e)?this._snapshot=r:this._snapshot=m.commonExtend(r,e);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=m.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Cs(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 m.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}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)!=null?e:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(e,s,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(s,0,e);const a=new mt(this._unitId,r,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getParentRenderUnitId(){return this._snapshot.parentRenderUnitId}getSheetOrders(){return this._snapshot.sheetOrder}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>r===e)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const e=this.getRawActiveSheet();if(e)return e;const s=this._snapshot.sheetOrder;for(let i=0,o=s.length;i<o;i++){const a=this._worksheets.get(s[i]);if(a&&a.isSheetHidden()!==I.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(s[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){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(s=>this._worksheets.get(s)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(s=>this._worksheets.get(s))}getSheetsName(){const{sheetOrder:e}=this._snapshot,s=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&s.push(i.getName())}),s}getSheetIndex(e){const{sheetOrder:s}=this._snapshot;return s.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:s}=this._snapshot,r=s.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:s}=this._snapshot;return this._worksheets.get(s[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===I.TRUE).map(e=>e.getConfig().id)}transformRangeType(e){if(typeof e=="string")return this._getCellRange(e);if(typeof e!="string"&&"row"in e){const s=e;return{sheetId:"",range:{startRow:s.row[0],startColumn:s.column[0],endRow:s.row[1],endColumn:s.column[1]}}}return typeof e!="string"&&"startRow"in e?{sheetId:"",range:e}:ft}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let s=e;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}generateNewSheetName(e){let s=e+this._count;for(;this.checkSheetName(s);)s=e+this._count,this._count++;return s}_getCellRange(e){var h,d,f,E,g;let s="",r="";if(e.indexOf("!")>-1){const R=e.split("!");s=R[0],r=R[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=e;if(r.indexOf(":")===-1){const R=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,C=m.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(R)&&!Number.isNaN(C)?{sheetId:s,range:{startRow:R,endRow:R,startColumn:C,endColumn:C}}:ft}r=r.split(":");const i=[0,0],o=[0,0],a=((h=this.getSheetBySheetName(s))==null?void 0:h.getMaxRows())||((d=this.getActiveSheet())==null?void 0:d.getMaxRows()),l=((f=this.getSheetBySheetName(s))==null?void 0:f.getMaxColumns())||((E=this.getActiveSheet())==null?void 0:E.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]=m.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=m.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])?ft:{sheetId:((g=this.getSheetBySheetName(s))==null?void 0:g.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:e,_worksheets:s}=this,{sheets:r,sheetOrder:i}=e;if(m.isEmptyObject(r)){const o=m.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new mt(this._unitId,a,this._styles);s.set(o,c),i.includes(o)||i.push(o)}}},u.Workbook=co([ho(1,X)],u.Workbook);class Ae extends Gt{constructor(e){var s;super();_(this,"type",A.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...Yn,...e},this._unitId=(s=this._snapshot.id)!=null?s:m.generateRandomId(6)}getContainer(){return this._snapshot.container}getParentRenderUnitId(){return this._snapshot.parentRenderUnitId}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var e;return(e=this._snapshot.body)==null?void 0:e.pages}getPageOrder(){var e;return(e=this._snapshot.body)==null?void 0:e.pageOrder}getPage(e){const s=this.getPages();return s==null?void 0:s[e]}getElementsByPage(e){var s;return(s=this.getPage(e))==null?void 0:s.pageElements}getElement(e,s){var r;return(r=this.getElementsByPage(e))==null?void 0:r[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:te.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ct="FOCUSING_SHEET",Vt="FOCUSING_DOC",xt="FOCUSING_SLIDE",fo="FOCUSING_EDITOR_BUT_HIDDEN",ws="EDITOR_ACTIVATED",Eo="FOCUSING_EDITOR_INPUT_FORMULA",vs="FOCUSING_FORMULA_EDITOR",go="FOCUSING_UNIVER_EDITOR",Ro="FOCUSING_EDITOR_INPUT_FORMULA",mo="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE";var Co=Object.defineProperty,Oo=Object.getOwnPropertyDescriptor,Io=(t,n,e,s)=>{for(var r=s>1?void 0:s?Oo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Co(n,e,r),r},Us=(t,n)=>(e,s)=>n(e,s,t);const q=S.createIdentifier("univer.current");u.UniverInstanceService=class extends D{constructor(e,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits$",new O.BehaviorSubject({}));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new O.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new O.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new O.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());this._injector=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete()}__setCreateHandler(e){this._createHandler=e}createUnit(e,s){return this._createHandler(e,s,this._ctorByType.get(e))}registerCtorForType(e,s){return this._ctorByType.set(e,s),{dispose:()=>{this._ctorByType.delete(e)}}}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe(O.map(s=>{var r;return(r=s[e])!=null?r:null}),O.distinctUntilChanged())}getCurrentUnitForType(e){return this._currentUnits$.getValue()[e]}setCurrentUnitForType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits$.next({...this._currentUnits$.getValue(),[s[1]]:s[0]})}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe(O.filter(s=>s.type===e))}__addUnit(e){const s=e.type;this._unitsByType.has(s)||this._unitsByType.set(s,[]),this._unitsByType.get(s).push(e),this._unitAdded$.next(e),this._currentUnits$.next({...this._currentUnits$.getValue(),[s]:e})}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe(O.filter(s=>s.type===e))}getUnit(e,s){var i;const r=(i=this._getUnitById(e))==null?void 0:i[0];return s&&(r==null?void 0:r.type)!==s?null:r}getCurrentUniverDocInstance(){return this.getCurrentUnitForType(A.UNIVER_DOC)}getUniverDocInstance(e){return this.getUnit(e,A.UNIVER_DOC)}getUniverSheetInstance(e){return this.getUnit(e,A.UNIVER_SHEET)}getAllUnitsForType(e){var s;return(s=this._unitsByType.get(e))!=null?s:[]}changeDoc(e,s){const r=this.getAllUnitsForType(A.UNIVER_DOC),i=r.find(o=>o.getUnitId()===e);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const e=this._focused$.getValue();return e?(s=this._getUnitById(e))==null?void 0:s[0]:null}focusUnit(e){this._focused$.next(e),this.focused instanceof u.Workbook?(this._contextService.setContextValue(Vt,!1),this._contextService.setContextValue(Ct,!0),this._contextService.setContextValue(xt,!1)):this.focused instanceof it?(this._contextService.setContextValue(Vt,!0),this._contextService.setContextValue(Ct,!1),this._contextService.setContextValue(xt,!1)):this.focused instanceof Ae&&(this._contextService.setContextValue(Vt,!1),this._contextService.setContextValue(Ct,!1),this._contextService.setContextValue(xt,!0))}getFocusedUnit(){return this.focused}getUnitType(e){const s=this._getUnitById(e);if(!s)throw new Error(`[UniverInstanceService]: No document with unitId ${e}`);return s[1]}disposeUnit(e){const s=this._getUnitById(e);if(!s)return!1;const[r,i]=s,o=this._unitsByType.get(i),a=o.indexOf(r);return o.splice(a,1),this._unitDisposed$.next(r),this._currentUnits$.next({...this._currentUnits$.getValue(),[i]:null}),this._focused$.next(null),!0}_getUnitById(e){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===e);if(i)return[i,s]}}},u.UniverInstanceService=Io([Us(0,S.Inject(S.Injector)),Us(1,Et)],u.UniverInstanceService);var w=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(w||{});const Ao={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},jt=new Map;function Ne(t,n){return function(r){Se(t,n)}}function Se(t,n){jt.has(t)||jt.set(t,[]),jt.get(t).push(n)}var No=Object.defineProperty,So=Object.getOwnPropertyDescriptor,Ds=(t,n,e,s)=>{for(var r=s>1?void 0:s?So(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&No(n,e,r),r},Le=(t,n)=>(e,s)=>n(e,s,t);u.LifecycleService=class extends D{constructor(e){super();_(this,"_lifecycle$",new O.BehaviorSubject(w.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=e,this._reportProgress(w.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 O.Observable(e=>(this.stage===w.Starting||(this.stage===w.Ready?e.next(w.Starting):this.stage===w.Rendered?(e.next(w.Starting),e.next(w.Ready)):(e.next(w.Starting),e.next(w.Ready),e.next(w.Rendered))),this._lifecycle$.subscribe(e)))}_reportProgress(e){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Ao[e]}".`)}},u.LifecycleService=Ds([Le(0,X)],u.LifecycleService),u.LifecycleInitializerService=class extends D{constructor(e,s){super();_(this,"_seenTokens",new Set);this._lifecycleService=e,this._injector=s}initModulesOnStage(e){var s;(s=jt.get(e))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}},u.LifecycleInitializerService=Ds([Le(0,S.Inject(u.LifecycleService)),Le(1,S.Inject(S.Injector))],u.LifecycleInitializerService);class Ot extends D{constructor(){super();_(this,"_currentLocale",tt.ZH_CN);_(this,"_locales",null);_(this,"localeChanged$",new O.Subject);_(this,"t",(e,...s)=>{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 s.forEach((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return e});this.disposeWithMe(U(()=>this.localeChanged$.complete()))}load(e){var s;this._locales=m.deepMerge((s=this._locales)!=null?s:{},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,s){const r=s.shift();if(r&&e&&r in e){const i=e[r];return s.length>0&&(typeof i=="object"||Array.isArray(i))?this.resolveKeyPath(i,s):i}return null}}const Kt=S.createIdentifier("resource-manager-service");var Lo=Object.defineProperty,To=Object.getOwnPropertyDescriptor,bo=(t,n,e,s)=>{for(var r=s>1?void 0:s?To(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Lo(n,e,r),r},Ms=(t,n)=>(e,s)=>n(e,s,t);const Te=S.createIdentifier("univer.permission-service");u.PermissionService=class extends D{constructor(e,s){super();_(this,"_permissionPointMap",new Map);_(this,"deletePermissionPoint",(e,s)=>{const r=this._permissionPointMap.get(e);if(r){const i=r.get(s);i&&(i.complete(),this._permissionPointMap.delete(s))}});_(this,"addPermissionPoint",(e,s)=>{const r=this._permissionPointMap.get(e)||new Map;return r.has(s.id)?!1:(r.set(s.id,new O.BehaviorSubject(s)),this._permissionPointMap.set(e,r),!0)});_(this,"updatePermissionPoint",(e,s,r)=>{const i=this._permissionPointMap.get(e);if(!i)return;const o=i.get(s);if(o){const a=o.getValue();a.value=r,a.status=ue.DONE,o.next(a)}});_(this,"getPermissionPoint",(e,s)=>{const r=this._permissionPointMap.get(e);if(!r)return;const i=r.get(s);if(i)return i.getValue()});this._resourceManagerService=e,this._univerInstanceService=s}_toJson(e){const s=this._permissionPointMap.get(e);let r=[];return s&&(r=[...s.keys()].reduce((i,o)=>{const a=s.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(e){return JSON.parse(e)}composePermission$(e,s){const r=this._permissionPointMap.get(e),i=s.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 O.combineLatest(i).pipe(x.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(e,s){const r=this._permissionPointMap.get(e);return s.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}},u.PermissionService=bo([Ne(w.Starting,u.PermissionService),Ms(0,S.Inject(Kt)),Ms(1,S.Inject(q))],u.PermissionService);const Ps="univer.editable";class Yt extends xn{constructor(e){super();_(this,"id",Ps);_(this,"value",!0);_(this,"unitID");this.unitID=e}}var wo=Object.defineProperty,vo=Object.getOwnPropertyDescriptor,Uo=(t,n,e,s)=>{for(var r=s>1?void 0:s?vo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&wo(n,e,r),r},Hs=(t,n)=>(e,s)=>n(e,s,t);u.UniverPermissionService=class extends D{constructor(n,e){super(),this._permissionService=n,this._univerInstanceService=e,this._init()}_init(){this._univerInstanceService.getTypeOfUnitAdded$(A.UNIVER_SHEET).subscribe(n=>{const e=new Yt(n.getUnitId());this._permissionService.addPermissionPoint(n.getUnitId(),e)})}getEditable(n=(e=>(e=this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET))==null?void 0:e.getUnitId())()){if(!n)return;const s=new Yt(n),r=this._permissionService.getPermissionPoint(n,s.id);return r==null?void 0:r.value}setEditable(n,e){const s=new Yt(n);this._permissionService.updatePermissionPoint(n,s.id,e)}},u.UniverPermissionService=Uo([Ne(w.Starting,u.UniverPermissionService),Hs(0,S.Inject(Te)),Hs(1,S.Inject(q))],u.UniverPermissionService);class Fs extends D{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new O.Subject);_(this,"register$",this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e){return this.getAllResourceHooks().map(i=>{const o=i.toJson(e);return{name:i.pluginName,data:o}})}registerPluginResource(e){const s=e.pluginName;if(this._resourceMap.has(s))throw new Error(`the pluginName is registered {${s}}`);return this._resourceMap.set(s,e),this._register$.next(e),U(()=>this._resourceMap.delete(s))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,s){this.getAllResourceHooks().forEach(r=>{var o;const i=(o=s==null?void 0:s.find(a=>a.name===r.pluginName))==null?void 0:o.data;if(i)try{const a=r.parseJson(i);r.onLoad(e,a)}catch{console.error("LoadResources Error!")}})}unloadResources(e){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(e)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}var Do=Object.defineProperty,Mo=Object.getOwnPropertyDescriptor,Po=(t,n,e,s)=>{for(var r=s>1?void 0:s?Mo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Do(n,e,r),r},ps=(t,n)=>(e,s)=>n(e,s,t);let be=class extends D{constructor(n,e){super();_(this,"saveWorkbook",n=>{const e=n.getUnitId(),s=this._resourceManagerService.getResources(e)||[],r=n.getSnapshot();return r.resources=s,r});this._resourceManagerService=n,this._univerInstanceService=e,this._init()}_init(){const n=s=>{s.businesses.forEach(r=>{switch(r){case A.UNRECOGNIZED:case A.UNIVER_UNKNOWN:case A.UNIVER_SLIDE:case A.UNIVER_DOC:break;case A.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(A.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{n(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{n(s)})),this.disposeWithMe(U(this._univerInstanceService.getTypeOfUnitAdded$(A.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(U(this._univerInstanceService.getTypeOfUnitDisposed$(A.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}};be=Po([ps(0,S.Inject(Kt)),ps(1,S.Inject(q))],be);const we=S.createIdentifier("resource-loader-service");Se(w.Ready,we);class ve extends D{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new O.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(U(()=>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 Ws="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Bs="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Ho=`\r
7
- `;function Fo(t){return`__internalEditorId__${t}`}function po(t){return t.startsWith("__")}var Wo=Object.defineProperty,Bo=Object.getOwnPropertyDescriptor,ko=(t,n,e,s)=>{for(var r=s>1?void 0:s?Bo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Wo(n,e,r),r},Ue=(t,n)=>(e,s)=>n(e,s,t);const yt=S.createIdentifier("univer.undo-redo.service"),Go=20;class ks{dispose(){}async dispatchToHandlers(){return!1}}const Gs="univer.command.redo",$s="univer.command.undo",Vs=new class extends ks{constructor(){super(...arguments);_(this,"type",gt.COMMAND);_(this,"id",$s)}async handler(n){const e=n.get(yt),s=e.pitchTopUndoElement();if(!s)return!1;const r=n.get(Rt);return de(s.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},xs=new class extends ks{constructor(){super(...arguments);_(this,"type",gt.COMMAND);_(this,"id",Gs)}async handler(n){const e=n.get(yt),s=e.pitchTopRedoElement();if(!s)return!1;const r=n.get(Rt);return de(s.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends D{constructor(e,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new O.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);_(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=s,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Vs)),this.disposeWithMe(this._commandService.registerCommand(xs)),this.disposeWithMe(U(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(U(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:s}=e,r=this._getRedoStack(s,!0),i=this._getUndoStack(s,!0);if(r.length=0,this._batchingStatus.has(e.unitID)){const a=this._batchingStatus.get(e.unitID),l=this._pitchUndoElement(e.unitID);a===0||!l?(o(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(l,e)}else o(e);function o(a){i.push(a),i.length>Go&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const s=this._getRedoStack(e);s&&(s.length=0);const r=this._getUndoStack(e);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){const e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){const s=this._getUndoStack(e);return s!=null&&s.length?s[s.length-1]:null}_pitchRedoElement(e){const s=this._getRedoStack(e);return s!=null&&s.length?s[s.length-1]:null}popUndoToRedo(){const s=this._getUndoStackForFocused().pop();s&&(this._getRedoStackForFocused().push(s),this._updateStatus())}popRedoToUndo(){const s=this._getRedoStackForFocused().pop();s&&(this._getUndoStackForFocused().push(s),this._updateStatus())}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(e,0),U(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUnitId(),s=e&&((i=this._undoStacks.get(e))==null?void 0:i.length)||0,r=e&&((o=this._redoStacks.get(e))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:s,redos:r})}_getUndoStack(e,s=!1){let r=this._undoStacks.get(e);return!r&&s&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,s=!1){let r=this._redoStacks.get(e);return!r&&s&&(r=[],this._redoStacks.set(e,r)),r||null}_getUndoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getUndoStack(e,!0)}_getRedoStackForFocused(){const e=this._getFocusedUnitId();if(!e)throw new Error("No focused univer instance!");return this._getRedoStack(e,!0)}_tryBatchingElements(e,s){e.redoMutations.push(...s.redoMutations),e.undoMutations.push(...s.undoMutations)}_getFocusedUnitId(){var o,a,l,c;let e="";const s=this._contextService.getContextValue(Ct),r=this._contextService.getContextValue(vs),i=this._contextService.getContextValue(ws);return s?r?e=Bs:i?e=Ws:e=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":e=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",e}},u.LocalUndoRedoService=ko([Ue(0,q),Ue(1,Rt),Ue(2,Et)],u.LocalUndoRedoService);class De extends D{onStarting(n){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(De,"pluginName"),_(De,"type",A.UNIVER_UNKNOWN);class $o{constructor(){_(this,"_plugins",[])}addPlugin(n){this._plugins.push(n)}removePlugins(){const n=this._plugins.slice();return this._plugins.length=0,n}forEachPlugin(n){this._plugins.forEach(n)}}class Vo{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(n,e){this._pluginsRegistered.push({plugin:n,options:e})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var xo=Object.defineProperty,jo=Object.getOwnPropertyDescriptor,Ko=(t,n,e,s)=>{for(var r=s>1?void 0:s?jo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&xo(n,e,r),r},zt=(t,n)=>(e,s)=>n(e,s,t);u.PluginHolder=class extends D{constructor(e,s,r,i){super();_(this,"_started",!1);_(this,"_pluginRegistered",new Set);_(this,"_pluginStore",new $o);_(this,"_pluginRegistry",new Vo);this._logService=e,this._injector=s,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,s){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,s)}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 s=this.disposeWithMe(this._lifecycleService.subscribeWithPrevious().subscribe(r=>{this._pluginsRunLifecycle(e,r),r===w.Steady&&s.dispose()}))}_pluginsRunLifecycle(e,s){e.forEach(r=>{switch(s){case w.Starting:r.onStarting(this._injector);break;case w.Ready:r.onReady();break;case w.Rendered:r.onRendered();break;case w.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(s)}_initPlugin(e,s){return this._injector.createInstance(e,s)}},u.PluginHolder=Ko([zt(0,X),zt(1,S.Inject(S.Injector)),zt(2,S.Inject(u.LifecycleService)),zt(3,S.Inject(u.LifecycleInitializerService))],u.PluginHolder);var Yo=Object.defineProperty,yo=Object.getOwnPropertyDescriptor,zo=(t,n,e,s)=>{for(var r=s>1?void 0:s?yo(n,e):n,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(s?o(n,e,r):o(r))||r);return s&&r&&Yo(n,e,r),r},Xo=(t,n)=>(e,s)=>n(e,s,t);const qo=4;u.PluginService=class{constructor(n){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_flushTimer");this._injector=n,this._pluginHolderForUniver=this._injector.createInstance(u.PluginHolder),this._pluginHolderForUniver.start()}dispose(){this._clearFlushTimer();for(const n of this._pluginHoldersForTypes.values())n.dispose();this._pluginHolderForUniver.dispose()}registerPlugin(n,e){this._assertPluginValid(n),this._scheduleInitPlugin();const{type:s}=n;s===A.UNIVER_UNKNOWN?(this._pluginHolderForUniver.registerPlugin(n,e),this._pluginHolderForUniver.flush()):this._ensurePluginHolderForType(s).registerPlugin(n,e)}startPluginForType(n){this._ensurePluginHolderForType(n).start()}_ensurePluginHolderForType(n){if(!this._pluginHoldersForTypes.has(n)){const e=this._injector.createInstance(u.PluginHolder);return this._pluginHoldersForTypes.set(n,e),e}return this._pluginHoldersForTypes.get(n)}_assertPluginValid(n){const{type:e,pluginName:s}=n;if(e===A.UNRECOGNIZED)throw new Error(`[PluginService]: invalid plugin type for ${n}. Please assign a "type" to your plugin.`);if(s==="")throw new Error(`[PluginService]: no plugin name for ${n}. Please assign a "pluginName" to your plugin.`)}_scheduleInitPlugin(){this._flushTimer===void 0&&(this._flushTimer=setTimeout(()=>{this._pluginHolderForUniver.started||this._pluginHolderForUniver.start(),this._flushPlugins(),this._clearFlushTimer()},qo))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[n,e]of this._pluginHoldersForTypes)e.started&&e.flush()}},u.PluginService=zo([Xo(0,S.Inject(S.Injector))],u.PluginService);function js(t,n){if(!n)return t;const e=[];for(const s of t){const r=n.find(([i])=>i===s[0]);if(r){if(r[1]===null)continue;e.push([s[0],r[1]])}else e.push(s)}return e}class Ks{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new O.Subject);_(this,"userChange$",this._userChange$.asObservable())}addUser(n){this._model.set(n.userID,n),this._userChange$.next({type:"add",user:n})}getUser(n,e){const s=this._model.get(n);if(s)return s;e&&e()}delete(n){const e=this.getUser(n);this._model.delete(n),e&&this._userChange$.next({type:"delete",user:e})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}}class Jo{constructor(n={},e){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Zo(e,n==null?void 0:n.override),{theme:r,locale:i,locales:o,logLevel:a}=n;r&&this._injector.get(ve).setTheme(r),o&&this._injector.get(Ot).load(o),i&&this._injector.get(Ot).setLocale(i),a&&this._injector.get(X).setLogLevel(a),this._init(s),this._pluginService}get _univerInstanceService(){return this._injector.get(q)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(n){this._injector.get(Ot).setLocale(n)}createUnit(n,e){return this._univerInstanceService.createUnit(n,e)}createUniverSheet(n){return this._univerInstanceService.createUnit(A.UNIVER_SHEET,n)}createUniverDoc(n){return this._univerInstanceService.createUnit(A.UNIVER_DOC,n)}createUniverSlide(n){return this._univerInstanceService.createUnit(A.UNIVER_SLIDE,n)}_init(n){this._univerInstanceService.registerCtorForType(A.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(A.UNIVER_DOC,it),this._univerInstanceService.registerCtorForType(A.UNIVER_SLIDE,Ae);const e=n.get(q);e.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const a=n.createInstance(i,r);return e.__addUnit(a),this._tryProgressToReady(),a}const o=n.createInstance(i,r);return e.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<w.Ready&&(this._injector.get(u.LifecycleService).stage=w.Ready)}registerPlugin(n,e){this._pluginService.registerPlugin(n,e)}}function Zo(t,n){const e=js([[gs],[Ot],[ve],[u.LifecycleService],[u.LifecycleInitializerService],[u.UniverPermissionService],[u.PluginService],[Ks],[q,{useClass:u.UniverInstanceService}],[Te,{useClass:u.PermissionService}],[X,{useClass:Zn,lazy:!0}],[Rt,{useClass:u.CommandService,lazy:!0}],[yt,{useClass:u.LocalUndoRedoService,lazy:!0}],[fs,{useClass:Es}],[Et,{useClass:qn}],[ms,{useClass:Rs,lazy:!0}],[Kt,{useClass:Fs,lazy:!0}],[we,{useClass:be,lazy:!0}]],n);return t?t.createChild(e):new S.Injector(e)}const Qo=(t,n)=>n.length===t.length&&!t.some(e=>n.some(s=>!z.equals(s,e))),ta=(t,n)=>n.length===t.length&&t.every((e,s)=>{const r=n[s];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&z.equals(e.range,r.range)});function ea(t,n){if(Object.is(t,n))return!0;if(typeof t!="object"||!t||typeof n!="object"||!n)return!1;const e=Object.keys(t),s=Object.keys(n);if(e.length!==s.length)return!1;const r=Object.prototype.hasOwnProperty.bind(n);for(let i=0;i<e.length;i++){const o=e[i];if(!r(o))return!1;const a=t[o],l=n[o];if(a!==l)return!1}return!0}function Ys(t){return/^-?\d+(\.\d+)?$/.test(t)}function na(t){return Ys(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function sa(t){return["true","false"].includes(t.toLowerCase())}function ra(t,n){return n.forEach(e=>t.add(e)),t}function ia(t,n=16){let e=0,s=null;return function(...i){const o=Date.now();o-e<n?(s&&clearTimeout(s),s=setTimeout(()=>{e=o,t.apply(this,i)},n)):(e=o,t.apply(this,i))}}function oa(t){const n=new MessageChannel;let e=!1;return n.port1.onmessage=()=>{e||t()},n.port2.postMessage(null),()=>{e=!0}}var ys=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(ys||{});class Me{constructor(n){_(this,"_index",0);_(this,"_offset",0);this._actions=n}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(n){n||(n=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const s=this._offset,r=e.len;return n>=r-s?(n=r-s,this._index+=1,this._offset=0):this._offset+=n,e.t===N.DELETE||e.t===N.RETAIN&&e.body==null?m.deepClone({...e,len:n}):m.deepClone({...e,len:n,body:Ce(e.body,s,s+n)})}else return{t:N.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const n=this._actions[this._index];return n?n.t:N.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const n=this._offset,e=this._index,s=this.next(),r=this._actions.slice(this._index);return this._offset=n,this._index=e,[s].concat(r)}}else return[]}}function zs(t){return Object.keys(t).length===1}class Xt{constructor(){_(this,"_actions",[])}static compose(n,e){const s=new Me(n),r=new Me(e),i=new Xt;for(;s.hasNext()||r.hasNext();)if(r.peekType()===N.INSERT)i.push(r.next());else if(s.peekType()===N.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===N.INSERT&&l.t===N.RETAIN?l.body==null?i.push(a):i.push({...a,body:Oe(a.body,l.body,l.coverType)}):a.t===N.RETAIN&&l.t===N.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:Oe(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===N.RETAIN&&l.t===N.DELETE?i.push(l):a.t===N.INSERT&&(l.t,N.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(n,e,s=""){const r={t:N.INSERT,body:e,len:n,line:0,segmentId:s};return this.push(r),this}retain(n,e="",s,r){const i={t:N.RETAIN,len:n,segmentId:e};return s!=null&&(i.body=s),r!=null&&(i.coverType=r),this.push(i),this}delete(n,e=""){const s={t:N.DELETE,len:n,line:0,segmentId:e};return this.push(s),this}serialize(){return this._actions}push(...n){if(n.length>1){for(const i of n)this.push(i);return this}let e=this._actions.length,s=this._actions[e-1];const r=m.deepClone(n[0]);if(r.t===N.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===N.DELETE&&r.t===N.DELETE)return s.len+=r.len,this;if(s.t===N.DELETE&&r.t===N.INSERT&&(e-=1,s=this._actions[e-1],s==null))return this._actions.unshift(r),this;if(s.t===N.RETAIN&&r.t===N.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===N.INSERT&&zs(s.body)&&r.t===N.INSERT&&zs(r.body))return s.len+=r.len,s.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let n=this._actions[this._actions.length-1];for(;n&&n.t===N.RETAIN&&yi(n);)this._actions.pop(),n=this._actions[this._actions.length-1];return this}}function aa(t,n,e){if(n==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new it(s),i=n.length;let o;for(;(o=r.getBody().dataStream.indexOf(n))>=0;){const l=new Xt;if(o>0&&l.retain(o),e.length>0){const h=r.sliceBody(o,o+i),d={dataStream:e};Array.isArray(h==null?void 0:h.textRuns)&&h.textRuns.length&&(d.textRuns=[{...h.textRuns[0],st:0,ed:e.length}]),l.insert(e.length,d)}l.delete(i);const c=l.serialize();r.apply(c)}const a=r.getBody();return r.dispose(),a}class la extends Ht{add(n){if(!n)return null;const e=new Pt(n,this);return this._observers=[e],this._onObserverAdded&&this._onObserverAdded(e),e}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const ua=S.createIdentifier("ILocalStorageService");function ca(t){return`sheet_interceptor_${t}`}const Xs=t=>function(n,e){let s=-1;function r(i,o){if(i<=s)throw new Error("[SheetInterceptorService]: next() called multiple times!");return s=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,n)};class ha{constructor(n){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=n}fetchThroughInterceptors(n){const e=n,s=this._interceptorsByName.get(e);return Xs(s||[])}intercept(n,e){const s=n;this._interceptorsByName.has(s)||this._interceptorsByName.set(s,[]);const r=this._interceptorsByName.get(s);return r.push(e),this._interceptorsByName.set(s,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ft(this._interceptorsByName.get(s),e)}getInterceptPoints(){return this._interceptorPoints}}const da=S.createIdentifier("univer.snapshot-server-service");class _a{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(n,e){return Promise.resolve({snapshot:{unitID:"",type:A.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:k.OK,message:""}})}getSheetBlock(n,e){const s=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:s,error:{code:k.OK,message:""}})}fetchMissingChangesets(n,e){return Promise.resolve({changesets:[],error:{code:k.OK,message:""}})}getResourcesRequest(n,e){return Promise.resolve({resources:{},error:{code:k.OK,message:""}})}saveSnapshot(n,e){return Promise.resolve({error:{code:k.OK,message:""}})}saveSheetBlock(n,e){const{block:s}=e;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:k.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:k.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(n,e){return Promise.resolve({error:{code:k.OK,message:""},concurrent:[]})}}function fa(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(n,e)=>String.fromCharCode(Number.parseInt(e,16))))}function Pe(t){return decodeURIComponent(Array.prototype.map.call(atob(t),n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const It=new TextEncoder,qt=new TextDecoder;function qs(t){const n=m.deepClone(t);return delete n.id,delete n.name,delete n.rowCount,delete n.columnCount,delete n.cellData,It.encode(JSON.stringify(n))}function Js(t){const n=m.deepClone(t);return delete n.id,delete n.rev,delete n.name,delete n.sheetOrder,delete n.sheets,It.encode(JSON.stringify(n))}function Ea(t){const n=m.deepClone(t);return delete n.id,delete n.rev,delete n.title,delete n.resources,It.encode(JSON.stringify(n))}function Zs(t){return JSON.parse(qt.decode(t))}function ga(t){return JSON.parse(typeof t=="string"?Pe(t):qt.decode(t))}function Ra(t){return JSON.parse(typeof t=="string"?Pe(t):qt.decode(t))}const He=256;function Qs(t,n){const e=new V(t),s=e.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+He,s-1),a=e.getSlice(i,Math.min(i+He,s-1),0,n),l=ma(a);r.push({id:m.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=He}return r}function ma(t){const n=t.getData();return It.encode(JSON.stringify(n))}async function Ca(t,n,e,s,r){const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([d,f])=>{const E={id:f.id,type:Nt.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:qs(f)};if(o[d]=E,f.cellData){const g=Qs(f.cellData,f.rowCount),R=await Promise.all(g.map(C=>r.saveSheetBlock(t,{unitID:e,type:A.UNIVER_SHEET,block:C})));if(R.some(C=>{var L;return((L=C.error)==null?void 0:L.code)!==k.OK}))return!1;i[d]={sheetID:d,blocks:R.map(C=>C.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Js(n),c={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l};return{snapshotRes:{unitID:e,rev:c.rev,type:A.UNIVER_SHEET,workbook:c,doc:void 0}}}async function Oa(t,n,e,s,r){var f,E;const i={},o={};if(!await Promise.all(Object.entries(n.sheets).map(async([g,R])=>{const C={id:R.id,type:Nt.GRID,name:R.name,rowCount:R.rowCount,columnCount:R.columnCount,originalMeta:qs(R)};if(o[g]=C,R.cellData){const L=Qs(R.cellData,R.rowCount),P=await Promise.all(L.map(F=>r.saveSheetBlock(t,{unitID:e,type:A.UNIVER_SHEET,block:F})));if(P.some(F=>{var Q;return((Q=F.error)==null?void 0:Q.code)!==k.OK}))return!1;i[g]={sheetID:g,blocks:P.map(F=>F.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Js(n),c={unitID:n.id,rev:s,creator:"",name:n.name,sheetOrder:n.sheetOrder,sheets:o,blockMeta:i,resources:n.resources||[],originalMeta:l},h={unitID:e,rev:c.rev,type:A.UNIVER_SHEET,workbook:c,doc:void 0},d=await r.saveSnapshot(t,{unitID:e,type:A.UNIVER_SHEET,snapshot:h});if(ns(d.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
- ErrorCode: ${(f=d.error)==null?void 0:f.code}:${(E=d.error)==null?void 0:E.message}`);return{snapshot:h}}function Ia(t,n,e){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,c])=>{const h=Zs(c.originalMeta);r[l]={id:c.id,name:c.name,rowCount:c.rowCount,columnCount:c.columnCount,...h}});const i=new Map;n.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,c])=>{var f;const h=r[l];h.cellData={};const d=[];(f=c.blocks)==null||f.forEach(E=>{const g=i.get(E);if(g)d.push(g);else throw new Error("")}),d.forEach(E=>{const g=ga(E.data);Object.entries(g).forEach(([R,C])=>{const L=h.cellData[+R]={};Object.entries(C).forEach(([P,F])=>{L[+P]=F})})})});const o=Zs(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:tt.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function Aa(t){const n=t.doc;if(n==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:e,rev:s,name:r,originalMeta:i}=n,{body:o,documentStyle:a={},settings:l={}}=Ra(i);return{id:e,rev:s,locale:tt.EN_US,title:r,body:o,documentStyle:a,settings:l}}async function Na(t,n,e,s,r){var l,c,h;const i={unitID:n.id,rev:s,creator:"",name:(l=n.title)!=null?l:"",resources:n.resources||[],originalMeta:Ea(n)},o={unitID:e,rev:i.rev,type:A.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:e,type:A.UNIVER_DOC,snapshot:o});if(ns(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
- ErrorCode: ${(c=a.error)==null?void 0:c.code}:${(h=a.error)==null?void 0:h.message}`);return{snapshot:o}}async function Sa(t,n){const e=t.workbook;if(!e)throw new Error("Workbook metadata is not available");const s=[],r=[];return Object.entries(e.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async l=>{const c={unitID:e.unitID,type:A.UNIVER_SHEET,blockID:l},{block:h}=await n.getSheetBlock({},c);if(h)s.push(h);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var tr=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(tr||{}),er=(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))(er||{}),nr=(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))(nr||{}),sr=(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))(sr||{}),rr=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(rr||{});ir(),u.ABCToNumber=di,u.AbsoluteRefType=v,u.ActionIterator=Me,u.AlignTypeH=In,u.AlignTypeV=An,u.AutoFillSeries=We,u.BaselineOffset=at,u.BlockType=nn,u.BooleanNumber=I,u.BorderStyleTypes=b,u.BorderType=Be,u.BulletAlignment=K,u.COLORS=Jt,u.CellValueType=nt,u.ClientSnapshotServerService=_a,u.Color=st,u.ColorBuilder=bt,u.ColorKit=$,u.ColorType=B,u.ColumnSeparatorType=on,u.CommandType=gt,u.CommonHideTypes=ke,u.ConfigService=Es,u.ContentAlignment=gn,u.ContextService=qn,u.CopyPasteType=Ge,u.CustomRangeType=en,u.DEFAULT_CELL=Ai,u.DEFAULT_DOC=Ie,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=qi,u.DEFAULT_EMPTY_DOCUMENT_VALUE=Ho,u.DEFAULT_RANGE=Oi,u.DEFAULT_RANGE_ARRAY=ft,u.DEFAULT_SELECTION=Ii,u.DEFAULT_SLIDE=Yn,u.DEFAULT_STYLES=Bt,u.DEFAULT_WORKSHEET_COLUMN_COUNT=Is,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=to,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Ls,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=ro,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=Ns,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=no,u.DEFAULT_WORKSHEET_ROW_COUNT=Os,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Qi,u.DEFAULT_WORKSHEET_ROW_HEIGHT=As,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=eo,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Ss,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=so,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Bs,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ws,u.DashStyleType=_n,u.DataStreamTreeNodeType=rs,u.DataStreamTreeTokenType=Ee,u.DataValidationErrorStyle=tr,u.DataValidationImeMode=er,u.DataValidationOperator=nr,u.DataValidationRenderMode=ys,u.DataValidationStatus=rr,u.DataValidationType=sr,u.DesktopLogService=Zn,u.DeveloperMetadataVisibility=$e,u.Dimension=Ve,u.Direction=xe,u.Disposable=D,u.DisposableCollection=re,u.DocStyleType=Qe,u.DocumentDataModel=it,u.EDITOR_ACTIVATED=ws,u.EXTENSION_NAMES=yn,u.Entry=ie,u.EntryIterator=$n,u.ErrorService=gs,u.EventState=Wn,u.FOCUSING_DOC=Vt,u.FOCUSING_EDITOR_BUT_HIDDEN=fo,u.FOCUSING_EDITOR_INPUT_FORMULA=Eo,u.FOCUSING_EDITOR_STANDALONE=Ro,u.FOCUSING_FORMULA_EDITOR=vs,u.FOCUSING_SHEET=Ct,u.FOCUSING_SLIDE=xt,u.FOCUSING_UNIVER_EDITOR=go,u.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=mo,u.FloatingObjectManagerService=Rs,u.FollowNumberWithType=tn,u.FontItalic=St,u.FontStyleType=Rn,u.FontWeight=Lt,u.FormatType=je,u.GlyphType=ht,u.GridType=sn,u.HLSColor=Je,u.HorizontalAlign=et,u.ICommandService=Rt,u.IConfigService=fs,u.IContextService=Et,u.IFloatingObjectManagerService=ms,u.ILocalStorageService=ua,u.ILogService=X,u.IPermissionService=Te,u.IResourceLoaderService=we,u.IResourceManagerService=Kt,u.ISnapshotServerService=da,u.IUndoRedoService=yt,u.IUniverInstanceService=q,u.InterceptorManager=ha,u.InterpolationPointType=Ke,u.KeyIterator=kn,u.LRUHelper=_t,u.LRUMap=Vn,u.LifecycleStages=w,u.LocaleService=Ot,u.LocaleType=tt,u.LogLevel=Jn,u.MemoryCursor=ss,u.NamedStyleType=hn,u.NilCommand=ts,u.NumberUnitType=On,u.ObjectMatrix=V,u.ObjectRelativeFromH=mn,u.ObjectRelativeFromV=Cn,u.Observable=Ht,u.ObservableHooks=la,u.Observer=Pt,u.OnLifecycle=Ne,u.PRESET_LIST_TYPE=ki,u.PageElementType=Ln,u.PageOrientType=Sn,u.PageType=te,u.ParagraphElementType=ln,u.PermissionPoint=xn,u.PermissionStatus=ue,u.Plugin=De,u.PositionedObjectLayoutType=cn,u.PresetListType=$t,u.ProtectionType=Ye,u.RANGE_TYPE=p,u.RGBA_PAREN=hr,u.RGB_PAREN=cr,u.Range=rt,u.Rectangle=z,u.RedoCommand=xs,u.RedoCommandId=Gs,u.RefAlias=hi,u.Registry=_e,u.RegistryAsMap=fe,u.RelativeDate=ye,u.RelativeSlideLink=Tn,u.ResourceManagerService=Fs,u.RgbColor=wt,u.RxDisposable=ei,u.SectionType=rn,u.ShapeType=ze,u.SheetTypes=Nt,u.SheetViewModel=bs,u.SlideDataModel=Ae,u.SpacingRule=dn,u.Styles=Cs,u.THEME_COLORS=qe,u.TabStopAlignment=fn,u.TextDecoration=Xe,u.TextDirection=ut,u.TextDirectionType=an,u.TextX=Xt,u.TextXActionType=N,u.ThemeColor=vt,u.ThemeColorType=W,u.ThemeColors=Tt,u.ThemeService=ve,u.Tools=m,u.UndoCommand=Vs,u.UndoCommandId=$s,u.UnitModel=Gt,u.Univer=Jo,u.UniverEditablePermission=Yt,u.UniverEditablePermissionPoint=Ps,u.UniverInstanceType=A,u.UpdateDocsAttributeType=H,u.UserManagerService=Ks,u.ValueIterator=Gn,u.VerticalAlign=ot,u.WidthType=En,u.Worksheet=mt,u.WrapStrategy=ct,u.WrapTextType=un,u.afterInitApply=Hi,u.b64DecodeUnicode=Pe,u.b64EncodeUnicode=fa,u.binarySearchArray=Fe,u.cellToRange=Yr,u.characterSpacingControlType=Nn,u.checkForSubstrings=yr,u.checkParagraphHasBullet=zr,u.checkParagraphHasIndent=Xr,u.checkParagraphHasIndentByStyle=wn,u.codeToBlob=lr,u.composeBody=Oe,u.composeInterceptors=Xs,u.concatMatrixArray=oi,u.convertBodyToHtml=Ci,u.covertTextRunToHtml=he,u.createInterceptorKey=ca,u.createInternalEditorID=Fo,u.createRowColIter=ce,u.debounce=mi,u.dedupe=ni,u.deepCompare=ee,u.deleteContent=Un,u.extractPureTextFromCell=io,u.fromCallback=es,u.fromObservable=ti,u.generateTemporarySnap=Ca,u.getArrayLength=y,u.getBodySlice=Ce,u.getBodySliceHtml=Wt,u.getBorderStyleType=jr,u.getCellValueType=Tr,u.getColorStyle=j,u.getDocsUpdateBody=Mt,u.getReverseDirection=ur,u.getSheetBlocksFromSnapshot=Sa,u.getTypeFromPermissionItemList=ci,u.getWorksheetUID=_o,u.groupBy=ii,u.handleJsonToDom=Vr,u.handleStyleToString=xr,u.hashAlgorithm=Jr,u.horizontalLineSegmentsSubtraction=ne,u.insertMatrixArray=oe,u.insertTextToContent=vn,u.isBlackColor=Nr,u.isBooleanString=sa,u.isCellV=wr,u.isEmptyCell=kr,u.isFormulaId=$r,u.isFormulaString=Gr,u.isICellData=Lr,u.isInternalEditorID=po,u.isNullCell=br,u.isNumeric=Ys,u.isObserver=Bn,u.isRangesEqual=Qo,u.isRealNum=qr,u.isSafeNumeric=na,u.isSameStyleTextRun=bn,u.isUnitRangesEqual=ta,u.isValidRange=Kr,u.isWhiteColor=Sr,u.makeCellRangeToRangeData=Br,u.makeCellToSelection=Wr,u.mergeOverrideWithDependencies=js,u.mergeSets=ra,u.mergeWorksheetSnapshotWithDefault=Ts,u.moveMatrixArray=le,u.moveRangeByOffset=bi,u.normalizeTextRuns=ge,u.numberToABC=fi,u.numberToListABC=Ei,u.orderSearchArray=pe,u.queryObjectMatrix=Ti,u.remove=Ft,u.repeatStringNumTimes=Kn,u.replaceInDocumentBody=aa,u.requestImmediateMacroTask=oa,u.rotate=ri,u.runOnLifecycle=Se,u.searchArray=ar,u.selectionToArray=vr,u.sequence=Xn,u.sequenceAsync=zn,u.sequenceExecute=de,u.sequenceExecuteAsync=Pi,u.shallowEqual=ea,u.sliceMatrixArray=ai,u.sortRules=gi,u.sortRulesByDesc=Ri,u.sortRulesFactory=lt,u.spliceArray=ae,u.textDecoder=qt,u.textEncoder=It,u.throttle=ia,u.toDisposable=U,u.transformDocumentDataToSnapshot=Na,u.transformSnapshotToDocumentData=Aa,u.transformSnapshotToWorkbookData=Ia,u.transformWorkbookDataToSnapshot=Oa,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("rxjs"),require("rxjs/operators"),require("@wendellhu/redi")):typeof define=="function"&&define.amd?define(["exports","rxjs","rxjs/operators","@wendellhu/redi"],C):(u=typeof globalThis<"u"?globalThis:u||self,C(u.UniverCore={},u.rxjs,u.rxjs.operators,u["@wendellhu/redi"]))})(this,function(u,C,x,S){"use strict";var wa=Object.defineProperty;var va=(u,C,x)=>C in u?wa(u,C,{enumerable:!0,configurable:!0,writable:!0,value:x}):u[C]=x;var _=(u,C,x)=>(va(u,typeof C!="symbol"?C+"":C,x),x);var La,Ta;function ir(){or()}const At=typeof global<"u"?global:typeof self<"u"?self:window;function or(){typeof At.requestIdleCallback!="function"&&(At.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 At.cancelIdleCallback!="function"&&(At.cancelIdleCallback=function(n){clearTimeout(n)})}function Fe(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 pe(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 ar(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=pe(t,e):n=Fe(t,e),n)}function lr(t){const e=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(e)}var We=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(We||{}),b=(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))(b||{}),Be=(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))(Be||{}),B=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(B||{}),ke=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(ke||{}),Ge=(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))(Ge||{}),$e=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))($e||{}),Ve=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(Ve||{}),xe=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(xe||{});function ur(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var je=(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))(je||{}),Ke=(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))(Ke||{}),tt=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t.RU_RU="ruRU",t))(tt||{}),Ye=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(Ye||{}),ye=(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))(ye||{}),ze=(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))(ze||{}),Nt=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(Nt||{}),ut=(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))(ut||{}),Xe=(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))(Xe||{}),et=(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))(et||{}),ot=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(ot||{}),ct=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(ct||{}),St=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(St||{}),Lt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(Lt||{}),at=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(at||{}),I=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(I||{}),nt=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(nt||{}),W=(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))(W||{}),Tt=(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))(Tt||{});const qe={[Tt.OFFICE]:{[W.ACCENT1]:"#4472C4",[W.ACCENT2]:"#ED7D31",[W.ACCENT3]:"#A5A5A5",[W.ACCENT4]:"#70AD47",[W.ACCENT5]:"#5B9BD5",[W.ACCENT6]:"#70AD47",[W.DARK1]:"#000000",[W.DARK2]:"#44546A",[W.LIGHT1]:"#FFFFFF",[W.LIGHT2]:"#E7E6E6",[W.HYPERLINK]:"#0563C1",[W.FOLLOWED_HYPERLINK]:"#954F72"}};class bt{constructor(){_(this,"_themeValue",W.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=B.UNSUPPORTED,this._themeColors=Tt.OFFICE,this._themeTint=0}asRgbColor(){return new wt(this._rgbValue,this)}asThemeColor(){return new vt(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case B.THEME:return this.asThemeColor();case B.RGB:return this.asRgbColor();case B.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(e){return this._colorType=B.RGB,this._rgbValue=e,this}setThemeColors(e){this._colorType=B.THEME,this._themeColors=e}setThemeTint(e){this._colorType=B.THEME,this._themeTint=e}setThemeColor(e){return this._colorType=B.THEME,this._themeValue=e,this}getColorType(){return this._colorType}}class st{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 bt().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,a,l)=>o+o+a+a+l+l);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),a=Number.parseInt(s[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new st(this._builder)}equals(e){return!1}}class Je{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)),a=Math.max(n,Math.max(s,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),n===a&&(this._hue=(s-r)/l),s===a&&(this._hue=2+(r-n)/l),r===a&&(this._hue=4+(n-s)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const e=new bt;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),a=this.setColor(n,s,r),l=r-1/3,c=this.setColor(n,s,l);return e.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(c*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 G=class G extends st{constructor(n,s){super(s);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=n.match(G.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=n,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=n.match(G.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=n,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return st.rgbColorToHexValue(this)}getRed(){let n=this._red+G.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getGreen(){let n=this._green+G.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getBlue(){let n=this._blue+G.RGB_COLOR_AMT;return n>255?n=255:n<0&&(n=0),n}getAlpha(){return this._alpha}getColorType(){return B.RGB}clone(){return new G(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(n){return n instanceof G?n._red===this._red&&n._blue===this._blue&&n._green===this._green&&n._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(G,"RGB_COLOR_AMT",0),_(G,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(G,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let wt=G;const J=class J extends st{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=qe[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(J._cacheThemeColor.has(this._themeColors)){if(r=J._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,J._cacheThemeColor.set(this._themeColors,r);const i=new Je(st.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 J(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(n){return n instanceof J?n._themeColorType===this._themeColorType:!1}getColorType(){return B.THEME}getThemeColorType(){return this._themeColorType}};_(J,"_cacheThemeColor",new Map);let vt=J;const cr="rgb(",hr="rgba(",Jt={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 ${constructor(e){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(e==null){this._setNullColor();return}if(e instanceof $){this._color={...e._color},this._rgbColor={...e._rgbColor};return}const n=Ze(e);if(n==null){this._setNullColor();return}this._color=n;const s=gr(this._color);if(s==null){this._setNullColor();return}this._rgbColor=s,this._isValid=!0}static mix(e,n,s){var c,h;s=Math.min(1,Math.max(0,s));const r=new $(e).toRgb(),i=new $(n).toRgb(),o=(c=r.a)!=null?c:1,a=(h=i.a)!=null?h:1,l={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(a-o)*s+o};return new $(l)}static getContrastRatio(e,n){const s=new $(e).getLuminance(),r=new $(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,a=[Ut(Math.round(n).toString(16)),Ut(Math.round(s).toString(16)),Ut(Math.round(r).toString(16)),Ut(Math.round(i*255).toString(16))];return e&&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 Or(this.toRgb())}toHsl(){return Cr(this.toRgb())}lighten(e=10){const n=this.toHsl();return n.l+=e,n.l=Math.min(Math.max(n.l,0),100),new $(n)}darken(e=10){const n=this.toHsl();return n.l-=e,n.l=Math.min(Math.max(n.l,0),100),new $(n)}setAlpha(e){return new $({...this._rgbColor,a:e})}getLuminance(){let{r:e,g:n,b:s}=this.toRgb();return e=Zt(e),n=Zt(n),s=Zt(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 Ut=t=>t.length===1?`0${t}`:t,Zt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),Ze=t=>{if(Ar(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(Jt[e]){const n=Jt[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 dr(e);if(e.startsWith("rgb"))return _r(e);if(e.startsWith("hsl"))return fr(e);if(e.startsWith("hsv"))return Er(e)},dr=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},_r=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},fr=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},Er=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},gr=t=>{const e=Ze(t);if(e!=null)return"r"in e?e:"l"in e?Rr(e):mr(e)},Qt=(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),Rr=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 l=s<.5?s*(1+n):s+n-s*n,c=2*s-l;r=Qt(c,l,e+1/3),i=Qt(c,l,e),o=Qt(c,l,e-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},mr=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),a=s*(1-i*n),l=s*(1-(1-i)*n),c=r%6,h=[s,a,o,o,l,s][c],d=[l,s,s,a,o,o][c],f=[o,o,l,s,s,a][c],E={r:h*255,g:d*255,b:f*255};return t.a!==void 0&&(E.a=t.a),E},Cr=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 a,l;if(r===i)a=l=0;else{const h=r-i;switch(l=o>.5?h/(2-r-i):h/(r+i),r){case e:a=(n-s)/h+(n<s?6:0);break;case n:a=(s-e)/h+2;break;default:a=(e-n)/h+4;break}a/=6}const c={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(c.a=t.a),c},Or=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 a=r,l=r-i,c=r===0?0:l/r;if(r===i)o=0;else{switch(r){case e:o=(n-s)/l+(n<s?6:0);break;case n:o=(s-e)/l+2;break;default:o=(e-n)/l+4;break}o/=6}const h={h:Math.round(o*360),s:Math.round(c*100),v:Math.round(a*100)};return t.a!==void 0&&(h.a=t.a),h},Ir=t=>t==null,Ar=t=>!Ir(t)&&typeof t=="object";function Nr(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 Sr(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 H=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(H||{});function Lr(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 Tr(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return nt.STRING;if(typeof t.v=="number")return nt.NUMBER;if(typeof t.v=="boolean")return nt.BOOLEAN}function br(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 wr(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var Qe=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Qe||{}),tn=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(tn||{}),ht=(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))(ht||{}),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||{}),en=(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))(en||{}),nn=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(nn||{}),sn=(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))(sn||{}),rn=(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))(rn||{}),on=(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))(on||{}),an=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(an||{}),ln=(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))(ln||{}),un=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(un||{}),cn=(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))(cn||{}),hn=(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))(hn||{}),dn=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(dn||{}),_n=(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))(_n||{}),fn=(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))(fn||{}),En=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(En||{}),gn=(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))(gn||{}),Rn=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Rn||{}),mn=(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))(mn||{}),Cn=(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))(Cn||{}),On=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(On||{}),In=(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))(In||{}),An=(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))(An||{}),Nn=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(Nn||{}),Sn=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(Sn||{}),p=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(p||{}),v=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(v||{});function vr(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}var te=(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))(te||{}),Ln=(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))(Ln||{}),Tn=(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))(Tn||{});const Ur="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Dr=t=>crypto.getRandomValues(new Uint8Array(t)),Mr=(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 a=n(r),l=r;for(;l--;)if(o+=t[a[l]&s]||"",o.length===i)return o}}},Pr=(t,e=21)=>Mr(t,e,Dr),Hr=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ur[n[t]&63];return e};const Fr=/^-ms-/,pr=/-([a-z])/g,Y=["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 m{static stringAt(e){let n="",s=e;for(;s>=Y.length;)s/=Y.length,s-=1,n+=Y[s%Y.length];const r=e%Y.length;return n+=Y[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+=Y.length**i+Y.length*r}return n+=e.charCodeAt(e.length-1)-65,n}static deleteBlank(e){return m.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,a=e.indexOf("Safari")>-1&&e.indexOf("Chrome")===-1,l=e.indexOf("Chrome")>-1&&e.indexOf("Safari")>-1;if(s){new RegExp("MSIE (\\d+\\.\\d+);").test(e);const h=Number.parseFloat(RegExp.$1);return h===7?"IE7":h===8?"IE8":h===9?"IE9":h===10?"IE10":"0"}return o?"FF":n?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(e=21,n){return n?Pr(n,e)():Hr(e)}static getClassName(e){return e.constructor.name}static deepMerge(e,...n){n.forEach(o=>o&&i(o));function s(o,a){o.forEach((l,c)=>{var h,d;if(m.isArray(l)){const f=(h=a[c])!=null?h:[];a[c]=f,s(l,f);return}if(m.isObject(l)){const f=(d=a[c])!=null?d:{};a[c]=f,r(l,f);return}a[c]=l})}function r(o,a){Object.keys(o).forEach(l=>{var h,d;const c=o[l];if(m.isObject(c)){const f=(h=a[l])!=null?h:{};a[l]=f,r(c,f);return}if(m.isArray(c)){const f=(d=a[l])!=null?d:[];a[l]=f,s(c,f);return}a[l]=c})}function i(o){Object.keys(o).forEach(a=>{var c,h;const l=o[a];if(m.isArray(l)){const d=(c=e[a])!=null?c:[];e[a]=d,s(l,d);return}if(m.isObject(l)){const d=(h=e[a])!=null?h:{};e[a]=d,r(l,d);return}e[a]=l})}return e}static numberFixed(e,n){return Number(Number(e).toFixed(n))}static diffValue(e,n){function s(o,a){const l=m.getValueType(o),c=m.getValueType(a);return l!==c?!1:m.isArray(o)?r(o,a):m.isObject(o)?i(o,a):m.isDate(o)?o.getTime()===a.getTime():m.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(e.length!==n.length)return!1;for(let l=0,c=o.length;l<c;l++){const h=o[l],d=a[l];if(!s(h,d))return!1}return!0}function i(o,a){const l=Object.keys(o),c=Object.keys(a);if(l.length!==c.length)return!1;for(const h of l){if(!c.includes(h))return!1;const d=o[h],f=a[h];if(!s(d,f))return!1}return!0}return s(e,n)}static deepClone(e){if(!this.isDefine(e))return e;if(this.isRegExp(e))return new RegExp(e);if(this.isDate(e))return new Date(e);if(this.isArray(e)){const n=[];return e.forEach((s,r)=>{n[r]=m.deepClone(s)}),n}if(this.isObject(e)){const n={};return Object.keys(e).forEach(s=>{const r=e[s];n[s]=m.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 m.isDefine(e)?m.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(Fr,"ms-").replace(pr,this.fCamelCase)}static removeNull(e){return this.isObject(e)&&Object.keys(e).forEach(n=>{const s=e[n];s==null?delete e[n]:m.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 Wr(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:c}=t,h=e,d=n,f=e,E=n;if(s&&i){const{startRow:g,startColumn:R,endRow:O,endColumn:L,startY:P,endY:F,startX:Q,endX:ba}=i;h=g,d=R,f=O,E=L,o=P,a=F,l=Q,c=ba}return r&&(o=i.startY,a=i.endY,l=i.startX,c=i.endX,f=i.endRow,E=i.endColumn),{startRow:h,startColumn:d,endRow:f,endColumn:E,startY:o,endY:a,startX:l,endX:c}}function Br(t){if(!t)return;const{actualRow:e,actualColumn:n,isMerged:s,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let c=e,h=n,d=e,f=n;return(s||r)&&(c=i,h=o,d=a,f=l),{startRow:c,startColumn:h,endRow:d,endColumn:f}}function kr(t){var n;return!t||(((n=t==null?void 0:t.v)==null?void 0:n.toString())||"").length===0&&!t.p}function j(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new bt().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function Gr(t){return m.isString(t)&&t.substring(0,1)==="="&&t.length>1}function $r(t){return m.isString(t)&&t.length>0}function Vr(t){return""}function xr(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,(a,l)=>`${l} underline`):n+="text-decoration-line: underline; ",t.ul.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${j(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,(a,l)=>`${l} line-through`):n+="text-decoration-line: line-through; ",t.st.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${j(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,(a,l)=>`${l} overline`):n+="text-decoration-line: overline; ",t.ol.cl&&n.indexOf("text-decoration-color")===-1&&(n+=`text-decoration-color: ${j(t.ol.cl)}; `),t.ol.t&&n.indexOf("text-decoration-style")===-1&&(n+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(n+=`background: ${j(t.bg)}; `)}],["bd",()=>{var o,a,l,c,h,d,f,E,g,R,O,L;(o=t.bd)!=null&&o.b&&(n+=`border-bottom: ${Dt((a=t.bd)==null?void 0:a.b.s)} ${(l=j(t.bd.b.cl))!=null?l:""}; `),(c=t.bd)!=null&&c.t&&(n+=`border-top: ${Dt((h=t.bd)==null?void 0:h.t.s)} ${(d=j(t.bd.t.cl))!=null?d:""}; `),(f=t.bd)!=null&&f.r&&(n+=`border-right: ${Dt((E=t.bd)==null?void 0:E.r.s)} ${(g=j(t.bd.r.cl))!=null?g:""}; `),(R=t.bd)!=null&&R.l&&(n+=`border-left: ${Dt((O=t.bd)==null?void 0:O.l.s)} ${(L=j(t.bd.l.cl))!=null?L:""}; `)}],["cl",()=>{t.cl&&(n+=`color: ${j(t.cl)}; `)}],["va",()=>{t.va===at.SUBSCRIPT?n+="vertical-align: sub; ":t.va===at.SUPERSCRIPT&&(n+="vertical-align: super; ")}],["td",()=>{t.td===ut.LEFT_TO_RIGHT?n+="direction: ltr; ":t.td===ut.RIGHT_TO_LEFT&&(n+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(n+=`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===et.LEFT?n+="text-align: left; ":t.ht===et.RIGHT?n+="text-align: right; ":t.ht===et.CENTER?n+="text-align: center; ":t.ht===et.JUSTIFIED&&(n+="text-align: justify; ")}],["vt",()=>{t.vt===ot.BOTTOM?n+="vertical-align: bottom; ":t.vt===ot.TOP?n+="vertical-align: top; ":t.vt===ot.MIDDLE&&(n+="vertical-align: middle; ")}],["tb",()=>{t.tb===ct.CLIP?n+="white-space: clip; ":t.tb===ct.WRAP&&(n+="white-space: normal;")}],["pd",()=>{var h,d,f,E,g,R,O,L;const o=`${(h=t.pd)==null?void 0:h.b}pt`,a=`${(d=t.pd)==null?void 0:d.t}pt`,l=`${(f=t.pd)==null?void 0:f.l}pt`,c=`${(E=t.pd)==null?void 0:E.r}pt`;(g=t.pd)!=null&&g.b&&(n+=`padding-bottom: ${o}; `),(R=t.pd)!=null&&R.t&&(n+=`padding-top: ${a}; `),(O=t.pd)!=null&&O.l&&(n+=`padding-left: ${l}; `),(L=t.pd)!=null&&L.r&&(n+=`padding-right: ${c}; `)}]]),r=["bd","tr","tb"];for(const o in t)e&&r.includes(o)||(i=s.get(o))==null||i();return n}function Dt(t){let e="";return t===b.NONE?e="none":t===b.THIN?e="0.5pt solid":t===b.HAIR?e="0.5pt double":t===b.DOTTED?e="0.5pt dotted":t===b.DASHED||t===b.DASH_DOT?e="0.5pt dashed":t===b.DASH_DOT_DOT?e="0.5pt dotted":t===b.DOUBLE?e="0.5pt double":t===b.MEDIUM?e="1pt solid":t===b.MEDIUM_DASHED||t===b.MEDIUM_DASH_DOT?e="1pt dashed":t===b.MEDIUM_DASH_DOT_DOT?e="1pt dotted":t===b.SLANT_DASH_DOT?e="0.5pt dashed":t===b.THICK&&(e="1.5pt solid"),e}function jr(t){let e=0;if(t=t.trim(),t==="none")e=b.NONE;else if(t==="0.5pt solid")e=b.THIN;else if(t==="0.5pt double")e=b.HAIR;else if(t==="0.5pt dotted")e=b.DOTTED;else if(t==="0.5pt dashed")e=b.DASHED;else if(t==="1pt solid")e=b.MEDIUM;else if(t==="1pt dashed")e=b.MEDIUM_DASHED;else if(t==="1pt dotted")e=b.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")e=b.THICK;else if(!t.includes("none"))e=b.THIN;else return b.NONE;return e}function Mt(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 Kr(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===p.COLUMN||!(Number.isNaN(s)&&Number.isNaN(r))&&i===p.ROW)}function Yr(t,e){return{startRow:t,endRow:t,startColumn:e,endColumn:e}}function ee(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=>ee(t[n],e[n])):t===e:!1}function bn(t,e){const n=t.ts||{},s=e.ts||{};return t.sId!==e.sId?!1:ee(n,s)}function yr(t,e){return e.some(n=>t.indexOf(n)>-1)}function ne(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 zr(t){if(t==null)return!1;const e=t.bullet;return(e==null?void 0:e.listId)!=null}function Xr(t){if(t==null)return!1;const e=t.paragraphStyle;return wn(e)}function wn(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function vn(t,e,n){return t.slice(0,e)+n+t.slice(e)}function Un(t,e,n){return e>n?t:t.slice(0,e)+t.slice(n)}function qr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Jr(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 Dn(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 Mn(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(a){o={error:a}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function Pn(t,e,n){if(n||arguments.length===2)for(var s=0,r=e.length,i;s<r;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return t.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;function dt(t){return typeof t=="function"}function Zr(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 se=Zr(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 Hn(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Fn=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 a=Dn(o),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(R){e={error:R}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if(dt(h))try{h()}catch(R){i=R instanceof se?R.errors:[R]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=Dn(d),E=f.next();!E.done;E=f.next()){var g=E.value;try{pn(g)}catch(R){i=i!=null?i:[],R instanceof se?i=Pn(Pn([],Mn(i)),Mn(R.errors)):i.push(R)}}}catch(R){s={error:R}}finally{try{E&&!E.done&&(r=f.return)&&r.call(f)}finally{if(s)throw s.error}}}if(i)throw new se(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)pn(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)&&Hn(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Hn(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();Fn.EMPTY;function Qr(t){return t instanceof Fn||t&&"closed"in t&&dt(t.remove)&&dt(t.add)&&dt(t.unsubscribe)}function pn(t){dt(t)?t():t.unsubscribe()}class Wn{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 Bn(t){return t instanceof Pt}class Pt{constructor(e,n){_(this,"_willBeUnregistered",!1);_(this,"unregisterOnNextCall",!1);this.callback=e,this.observable=n}dispose(){this.observable.remove(this)}}class Ht{constructor(e){_(this,"_observers",new Array);_(this,"_eventState");_(this,"_onObserverAdded");this._eventState=new Wn,e&&(this._onObserverAdded=e)}get observers(){return this._observers}add(e,n=!1,s=!1){if(!e)return null;const r=new Pt(e,this);return r.unregisterOnNextCall=s,n?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),r}addOnce(e){return this.add(e,void 0,!0)}remove(e){return e&&this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1}removeCallback(e){for(let n=0;n<this._observers.length;n++){const s=this._observers[n];if(!s._willBeUnregistered&&s.callback===e)return this._deferUnregister(s),!0}return!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(!i._willBeUnregistered&&(n.lastReturnValue=i.callback(e,n),i.unregisterOnNextCall&&this._deferUnregister(i),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||i._willBeUnregistered||(n=n.then(()=>i.callback(e,s)),i.unregisterOnNextCall&&this._deferUnregister(i))}return n.then(()=>e)}notifyObserver(e,n){if(e._willBeUnregistered)return;const s=this._eventState;return s.skipNextObservers=!1,e.callback(n,s),e.unregisterOnNextCall&&this._deferUnregister(e),{lastReturnValue:s.lastReturnValue,stopPropagation:s.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const e=new Ht;return e._observers=this._observers.slice(0),e}_deferUnregister(e){e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0)}_remove(e){if(!e)return!1;const n=this._observers.indexOf(e);return n!==-1?(this._observers.splice(n,1),!0):!1}}function U(t){let e=!1;return t?Qr(t)?{dispose:()=>t.unsubscribe()}:Bn(t)?{dispose:()=>{e||(e=!0,t.dispose())}}:typeof t=="function"?{dispose:()=>{e||(e=!0,t())}}:t:U(()=>{})}function ti(t){return U(()=>{t.unsubscribe()})}class re{constructor(){_(this,"_disposables",new Set)}add(e){const n=U(e);return this._disposables.add(n),{dispose:()=>{n.dispose(),this._disposables.delete(n)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}}class D{constructor(){_(this,"_disposed",!1);_(this,"_collection",new re)}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 ei extends D{constructor(){super(...arguments);_(this,"dispose$",new C.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}class _t{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 Ft(t,e){const n=t.indexOf(e);return n>-1?(t.splice(n,1),!0):!1}function ni(t){const e=new Set,n=[];for(const s of t)e.has(s)||(e.add(s),n.push(s));return n}function si(t,e){for(let n=t.length-1;n>-1;n--){const s=t[n];if(e(s,n))return s}return null}function ri(t,e){if(t.length===0)return t;const n=e%t.length;return t.slice(n).concat(t.slice(0,n))}function ii(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 T=Symbol("newer"),M=Symbol("older");class kn{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[T],{done:!1,value:e.key}):{done:!0,value:void 0}}}class Gn{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[T],{done:!1,value:e.value}):{done:!0,value:void 0}}}class $n{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[T],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}}class ie{constructor(e,n){_(this,"key");_(this,"value");_(this,La);_(this,Ta);this.key=e,this.value=n,this[T]=void 0,this[M]=void 0}toJSON(){return{key:this.key,value:this.value}}}La=T,Ta=M;class Vn{constructor(...e){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(_t.hasLength(e,1)){if(_t.isNumber(e[0])){const n=e[0];this._initialize(n,void 0);return}if(_t.isIterable(e[0])){const n=e[0];this._initialize(0,n);return}return}if(_t.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),U(()=>Ft(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[T]&&(e===this.oldest&&(this.oldest=e[T]),e[T][M]=e[M]),e[M]&&(e[M][T]=e[T]),e[T]=void 0,e[M]=this.newest,this.newest&&(this.newest[T]=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 ie(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),n?(n[T]=o,o[M]=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 ie(e,n)),this.newest?(this.newest[T]=s,s[M]=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[T]?(this.oldest=this.oldest[T],this.oldest[M]=void 0):(this.oldest=void 0,this.newest=void 0),e[T]=e[M]=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[T]&&n[M]?(n[M][T]=n[T],n[T][M]=n[M]):n[T]?(n[T][M]=void 0,this.oldest=n[T]):n[M]?(n[M][T]=void 0,this.newest=n[M]):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 kn(this.oldest)}values(){return new Gn(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new $n(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[T]}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[T];return e}toString(){let e="",n=this.oldest;for(;n;)e+=`${String(n.key)}:${n.value}`,n=n[T],n&&(e+=" < ");return e}}function y(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 oe(t,e,n){const s=y(n),r=n;for(let i=s-1;i>=t;i--)r[i+1]=r[i];r[t]=e}function ae(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 oi(t,e){const n=t,s=Object.keys(n),r=s.length,i=e,o=Object.keys(i),a=o.length,l={};let c=0;for(let h=0;h<r;h++,c++){const d=s[h];l[c]=n[d]}for(let h=0;h<a;h++,c++){const d=o[h];l[c]=i[d]}return l}function ai(t,e,n){const s=n;if(y(n)>0){const i={};let o=0;for(let a=t;a<=e;a++)s[a]&&(i[o]=s[a],o++);return i}return{}}function le(t,e,n,s){const r=t>n;if(!r&&t+e>n)throw new Error("Invalid move operation");r?li(t,e,n,s):ui(t,e,n,s)}function li(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 a=r[o];r[o+e]=a,a===void 0&&delete r[o+e]}i.forEach((o,a)=>{r[n+a]=o,o===void 0&&delete r[n+a]})}function ui(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 a=r[o];r[o-e]=a,a===void 0&&delete r[o-e]}i.forEach((o,a)=>{r[n+a-e]=o,o===void 0&&delete r[n+a-e]})}class V{constructor(e={}){_(this,"_matrix");this._setOriginValue(e)}static MakeObjectMatrixSize(e){return new V({[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(l=>Number(l)))===!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 a=Object.keys(o);for(const l of a){const c=Number(l),h=o[Number(l)];if(e(i,c,h)===!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){le(e,n,s,this._matrix)}moveColumns(e,n,s){this.forEach((r,i)=>{le(e,n,s,i)})}insertRows(e,n){for(let s=e;s<e+n;s++)oe(s,{},this._matrix)}insertColumns(e,n){for(let s=e;s<e+n;s++)this.forEach((r,i)=>{oe(s,void 0,i)})}removeRows(e,n){ae(e,n,this._matrix)}removeColumns(e,n){this.forEach((s,r)=>{ae(e,n,r)})}getFragment(e,n,s,r){const i=new V;let o=0;for(let a=e;a<=n;a++){const l={};let c=0;for(let h=s;h<=r;h++){const d=this.getValue(a,h);l[c]=d,c++}i.setRow(o,l),o++}return i}getSlice(e,n,s,r){const i=new V;for(let o=e;o<=n;o++)for(let a=s;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,m.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return y(this._matrix)}getRange(){const s=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=y(a)-1;r=l>r?l: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,a)=>{r[i][o]=a}),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 V;return this.forEach((o,a)=>{s||(s=!0,e=o),Object.keys(a).forEach(l=>{const c=Number(l);r?c<n&&(n=c):(r=!0,n=c);const h=this.getValue(o,c);i.setValue(o-e,c-n,h)})}),i.getData()}getDataRange(){let e=0,n=0,s=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{if(i||(i=!0,e=a),l==null)return;const c=y(l)-1;c>s&&(s=c),Object.keys(l).forEach(h=>{const d=Number(h);o?d<n&&(n=d):(o=!0,n=d)}),a>r&&(r=a)}),{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 a of e)if(n>=a.startRow&&n<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(n,a.endRow),a.endColumn=Math.max(i,a.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}}var ue=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(ue||{});class xn{constructor(){_(this,"status","init")}}const ci=t=>t.some(e=>e.status==="init")?"init":t.some(e=>e.status==="fetching")?"fetching":"done",Z=class Z{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===p.NORMAL||n.rangeType===void 0&&e.rangeType===p.NORMAL)}static intersects(e,n){const s=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=n.startRow,l=n.endRow,c=n.startColumn,h=n.endColumn,d=Math.abs(i+o-c-h),f=Math.abs(i-o)+Math.abs(c-h),E=Math.abs(s+r-a-l),g=Math.abs(s-r)+Math.abs(a-l);return d<=f&&E<=g}static getIntersects(e,n){const s=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=n.startRow,l=n.endRow,c=n.startColumn,h=n.endColumn;let d,f,E,g;if(a<=r)a>=s?f=a:f=s;else return null;if(l>=s)l>=r?g=r:g=l;else return null;if(c<=o)c>i?d=c:d=i;else return null;if(h>=i)h>=o?E=o:E=h;else return null;return{startRow:f,endRow:g,startColumn:d,endColumn:E,rangeType:p.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 Z.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:p.NORMAL}),e[0])}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(a=>a.startRow<=a.endRow&&a.startColumn<=a.endColumn)}};_(Z,"getRelativeRange",(e,n)=>({startRow:e.startRow-n.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-n.startColumn,endColumn:e.endColumn-e.startColumn})),_(Z,"getPositionRange",(e,n,s)=>({...s||{},startRow:s&&[v.ROW,v.ALL].includes(s.startAbsoluteRefType||0)?s.startRow:e.startRow+n.startRow,endRow:s&&[v.ROW,v.ALL].includes(s.endAbsoluteRefType||0)?s.endRow:e.endRow+e.startRow+n.startRow,startColumn:s&&[v.COLUMN,v.ALL].includes(s.startAbsoluteRefType||0)?s.startColumn:e.startColumn+n.startColumn,endColumn:s&&[v.COLUMN,v.ALL].includes(s.endAbsoluteRefType||0)?s.endColumn:e.endColumn+e.startColumn+n.startColumn})),_(Z,"moveHorizontal",(e,n=0,s=0)=>({...e,startColumn:e.startColumn+n,endColumn:e.endColumn+n+s})),_(Z,"moveVertical",(e,n=0,s=0)=>({...e,startRow:e.startRow+n,endRow:e.endRow+n+s})),_(Z,"moveOffset",(e,n,s)=>({...e,startRow:e.startRow+s,endRow:e.endRow+s,startColumn:e.startColumn+n,endColumn:e.endColumn+n}));let z=Z;class hi{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 ce(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 di(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 pt=65,jn=90,_i=97;function fi(t){const e=jn-pt+1;let n="";for(;t>=0;)n=String.fromCharCode(t%e+pt)+n,t=Math.floor(t/e)-1;return n}function Kn(t,e){let n="";for(;e>0;)n+=t,e--;return n}function Ei(t,e=!1){const n=jn-pt+1;let s=_i;e&&(s=pt);const r=String.fromCharCode(t%n+s),i=Math.floor(t/n)+1;return Kn(r,i)}function gi(t,e){return t.zIndex>e.zIndex?1:t.zIndex===e.zIndex?0:-1}function Ri(t,e){return t.zIndex>e.zIndex?-1:t.zIndex===e.zIndex?0:1}function lt(t="index",e=1){return(n,s)=>n[t]>s[t]?e:n[t]===s[t]?0:-e}function mi(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 Wt(t,e,n){const{dataStream:s,textRuns:r=[]}=t;let i=e;const o=[];for(const a of r){const{st:l,ed:c}=a;m.hasIntersectionBetweenTwoRanges(e,n,l,c)&&(l>i?(o.push(s.slice(i,l)),o.push(he(s,{...a,ed:Math.min(c,n)}))):o.push(he(s,{...a,st:i,ed:Math.min(c,n)}))),i=Math.max(e,Math.min(c,n))}return i!==n&&o.push(s.slice(i,n)),o.join("")}function Ci(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 a of r){const{startIndex:l,paragraphStyle:c={}}=a,{spaceAbove:h,spaceBelow:d,lineSpacing:f}=c,E=[];h!=null&&(typeof h=="number"?E.push(`margin-top: ${h}px`):E.push(`margin-top: ${h.v}px`)),d!=null&&(typeof d=="number"?E.push(`margin-bottom: ${d}px`):E.push(`margin-bottom: ${d.v}px`)),f!=null&&E.push(`line-height: ${f}`),l>o+1?i+=`<p class="UniverNormal" ${E.length?`style="${E.join("; ")};"`:""}>${Wt(t,o+1,l)}</p>`:i+=`<p class="UniverNormal" ${E.length?`style="${E.join("; ")};"`:""}></p>`,o=l}return o!==s.length&&(i+=Wt(t,o,s.length)),i}else return Wt(t,0,t.dataStream.length)}function he(t,e){const{st:n,ed:s,ts:r={}}=e,{ff:i,fs:o,it:a,bl:l,ul:c,st:h,ol:d,bg:f,cl:E,va:g}=r;let R=t.slice(n,s);const O=[];return a===I.TRUE&&(R=`<i>${R}</i>`),g===at.SUPERSCRIPT?R=`<sup>${R}</sup>`:g===at.SUBSCRIPT&&(R=`<sub>${R}</sub>`),(c==null?void 0:c.s)===I.TRUE&&(R=`<u>${R}</u>`),(h==null?void 0:h.s)===I.TRUE&&(R=`<s>${R}</s>`),l===I.TRUE&&(R=`<strong>${R}</strong>`),i&&O.push(`font-family: ${i}`),E&&O.push(`color: ${E.rgb}`),o&&O.push(`font-size: ${o}pt`),d&&O.push("text-decoration: overline"),f&&O.push(`background: ${f.rgb}`),O.length?`<span style="${O.join("; ")};">${R}</span>`:R}const ft={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Oi={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ii={startRow:0,startColumn:0,endRow:0,endColumn:0},Ai={row:0,column:0},Bt={ff:"Arial",fs:11,it:I.FALSE,bl:I.FALSE,ul:{s:I.FALSE},st:{s:I.FALSE},ol:{s:I.FALSE},tr:{a:0,v:I.FALSE},td:ut.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:et.UNSPECIFIED,vt:ot.UNSPECIFIED,tb:ct.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},Yn={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var yn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(yn||{});function kt(t,e){const{textRuns:n=[]}=e;let s=0;for(const i of n){const{ts:o={},st:a,ed:l}=i;if(o[t]==null)return I.FALSE;switch(t){case"bl":case"it":{if(o[t]===I.FALSE)return I.FALSE;break}case"ul":case"st":{if(o[t].s===I.FALSE)return I.FALSE;break}default:throw new Error(`unknown style key: ${t} in IStyleBase`)}s+=l-a}return e.dataStream.indexOf(`\r
4
+ `)===s?I.TRUE:I.FALSE}class rt{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 a=s;a<=i;a++)for(let l=r;l<=o;l++)n(a,l)}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 a=[];for(let l=s;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=e;a<=n;a++)for(let l=s;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=e;a<=n;a++)for(let l=s;l<=r;l++)o.setValue(a-e,l-s,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:e,endRow:n,startColumn:s,endColumn:r}=this._range;let i,o;return s<r?(i=m.numToWord(s+1)+(e+1),o=m.numToWord(r+1)+(n+1)):(i=m.numToWord(r+1)+(n+1),o=m.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)||Bt.bg.rgb}))}getCell(e,n){const{startRow:s,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:s+e,endRow:s+e,startColumn:i+n,endColumn:i+n};return new rt(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){var a;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 l=this._deps.getStyles();for(let c=0;c<=s-n;c++)for(let h=0;h<=i-r;h++){if(o==null||((a=o==null?void 0:o[c])==null?void 0:a[h])==null)continue;const d=o[c][h].s;d&&(o[c][h].s=l.get(d))}}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)||Bt.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?kt("ul",e.body)===I.TRUE?{s:I.TRUE}:{s:I.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?kt("st",e.body)===I.TRUE?{s:I.TRUE}:{s:I.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){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?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?kt("it",e.body)===I.TRUE?St.ITALIC:St.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?kt("bl",e.body)===I.TRUE?Lt.BOLD:Lt.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 a=n.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: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){rt.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]||Bt[e]}))}}function Ni(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 a=0;a<t[0].length;a++)n[a]=e(t[i][a])?n[a]+1:0;const o=Si(n);o.area>s&&(s=o.area,r={startColumn:o.start,startRow:i-o.height+1,endColumn:o.end,endRow:i})}return r}function Si(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 Li(t,e){rt.foreach(e,(n,s)=>{t[n][s]=void 0})}function Ti(t,e){const n=t.toFullArray(),s=[];for(;;){const r=Ni(n,e);if(!r)break;s.push(r),Li(n,r)}return s}function bi(t,e,n,s=!1){let r={...t};const i=r.startAbsoluteRefType||v.NONE,o=r.endAbsoluteRefType||v.NONE;return!s&&i===v.ALL&&o===v.ALL?r:s||i===v.NONE&&o===v.NONE?z.moveOffset(r,e,n):(i===v.NONE?r={...r,startRow:r.startRow+n,startColumn:r.startColumn+e}:i===v.COLUMN?r={...r,startRow:r.startRow+n}:i===v.ROW&&(r={...r,startColumn:r.startColumn+e}),o===v.NONE?r={...r,endRow:r.endRow+n,endColumn:r.endColumn+e}:o===v.COLUMN?r={...r,endRow:r.endRow+n}:o===v.ROW&&(r={...r,endColumn:r.endColumn+e}),r)}async function zn(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 Xn(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 Et=S.createIdentifier("univer.context-service");class qn extends D{constructor(){super(...arguments);_(this,"_contextChanged$",new C.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 C.Observable(s=>{const r=this._contextChanged$.pipe(C.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 Jn=(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))(Jn||{});const X=S.createIdentifier("univer.log");class Zn extends D{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 wi=Object.defineProperty,vi=Object.getOwnPropertyDescriptor,Ui=(t,e,n,s)=>{for(var r=s>1?void 0:s?vi(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&&wi(e,n,r),r},Qn=(t,e)=>(n,s)=>e(n,s,t),gt=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(gt||{});const Rt=S.createIdentifier("anywhere.command-service");class Di{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),U(()=>{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 ts={id:"nil",type:0,handler:()=>!0};u.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 Di,this._registerCommand(ts)}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),U(()=>{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),U(()=>{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},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(c=>c(o,s));const l=await this._execute(i,n,s);return this._commandExecutedListeners.forEach(c=>c(o,s)),a.dispose(),l}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,a={id:o.id,type:o.type,params:n};if(o.type===2){const h=si(this._commandExecutionStack,d=>d.type===0);h&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=h.id)}const l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(h=>h(a,s));const c=this._syncExecute(o,n,s);return this._commandExecutedListeners.forEach(h=>h(a,s)),l.dispose(),c}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),U(()=>Ft(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 re;s=new Mi(e.id),i.add(this._commandRegistry.registerCommand(s)),i.add(U(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,i)}const r=s.registerImplementation(e);return U(()=>{var i;r.dispose(),s.hasImplementations()||(i=this._multiCommandDisposables.get(e.id))==null||i.dispose()})}async _execute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,n,s),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(e,n,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,n,s),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}},u.CommandService=Ui([Qn(0,S.Inject(S.Injector)),Qn(1,X)],u.CommandService);class Mi{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(X),r=e.get(Et),i=e.get(S.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(s.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,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),U(()=>{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 de(t,e,n){const s=t.map(r=>()=>e.syncExecuteCommand(r.id,r.params,n));return Xn(s)}function Pi(t,e,n){const s=t.map(r=>()=>e.executeCommand(r.id,r.params,n));return zn(s)}function es(t){return new C.Observable(e=>{const n=t((...s)=>e.next(s));return()=>n==null?void 0:n.dispose()})}const Hi=t=>new Promise(e=>{C.merge(es(t.onCommandExecuted).pipe(x.filter(([n])=>n.type===gt.MUTATION)),C.timer(300)).pipe(x.debounceTime(16),x.first()).subscribe(()=>{e()})});var k=(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))(k||{});function ns(t){return!!(t&&t.code&&t.code!==k.OK&&t.code!=="OK")}var A=(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))(A||{});class Gt extends D{}class _e{constructor(){_(this,"_data",[])}static create(){return new _e}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 fe{constructor(){_(this,"_data",new Map)}static create(){return new fe}add(e,n){this._data.has(e)||this._data.set(e,n)}delete(e){this._data.delete(e)}getData(){return this._data}}class ss{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}}var rs=(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))(rs||{}),Ee=(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))(Ee||{});function ge(t){const e=[];for(const n of t){const{st:s,ed:r,ts:i}=n;if(n.sId===void 0&&delete n.sId,s===r||m.isEmptyObject(i)&&n.sId==null)continue;if(e.length===0){e.push(n);continue}const o=e.pop();bn(n,o)&&m.hasIntersectionBetweenTwoRanges(o.st,o.ed,n.st,n.ed)?e.push({...n,st:o.st,ed:r}):e.push(o,n)}return e}function is(t,e,n,s){var c;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(c=e.textRuns)!=null?c:[];if(l.length)for(let h=0,d=l.length;h<d;h++){const f=l[h];f.st+=s,f.ed+=s}for(let h=0;h<o;h++){const d=r[h],{st:f,ed:E}=d;if(E<s)i.push(d);else if(s>=f&&s<=E)if(a)d.st+=n,d.ed+=n,i.push(d);else{a=!0,d.ed+=n;const g=[];if(l.length){const R={...d,st:f,ed:l[0].st};g.push(R),g.push(...l);const O=l[l.length-1],L={...d,st:O.ed,ed:E+n};g.push(L)}else g.push(d);i.push(...g)}else d.st+=n,d.ed+=n,a||(a=!0,i.push(...l)),i.push(d)}a||(a=!0,i.push(...l)),t.textRuns=ge(i)}function Re(t,e,n,s){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,a=[];let l=-1;for(let h=0,d=r.length;h<d;h++){const f=r[h],{startIndex:E}=f;E>=s&&(f.startIndex+=n),l===-1&&E>=s&&(l=h),a.push(f.startIndex)}let c=-1;if(i){for(let h=0,d=i.length;h<d;h++){const f=i[h];f.startIndex+=s;const E=f.startIndex;c=a.indexOf(E)}if(o===Ee.PARAGRAPH&&i.length===1){const h=r[l],d=i[0],f=h.paragraphStyle,E=h.bullet;h.paragraphStyle=d.paragraphStyle,h.bullet=d.bullet,d.paragraphStyle=f,d.bullet=E}c!==-1&&r.splice(c,1),r.push(...i),r.sort(lt("startIndex"))}}function Fi(t,e,n,s){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=s&&(l.startIndex+=n)}const i=e.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function os(t,e,n,s){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c}=l;c>=s&&(l.startIndex+=n)}const i=e.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function me(t,e,n,s){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:h}=l;c>s?(l.startIndex+=n,l.endIndex+=n):h>=s-1&&(l.endIndex+=n)}const i=e.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function pi(t,e,n,s){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:c,endIndex:h}=l;c>s?(l.startIndex+=n,l.endIndex+=n):h>=s-1&&(l.endIndex+=n)}const i=e.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=s,l.endIndex+=s}r.push(...i),r.sort(lt("startIndex"))}}function as(t,e,n){const{textRuns:s}=t,r=n,i=n+e,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{st:d,ed:f}=h;if(r<=d&&i>=f){o.push({...h,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...h,st:r-r,ed:i-r}),h.ed-=e):r>=d&&r<f?(o.push({...h,st:r-r,ed:f-r}),h.ed=r):i>d&&i<=f?(o.push({...h,st:d-r,ed:i-r}),h.st=i-e,h.ed-=e):d>=i&&(h.st-=e,h.ed-=e);a.push(h)}t.textRuns=a}return o.length===0&&o.push({st:0,ed:e,ts:{}}),o}function ls(t,e,n){const{paragraphs:s}=t,r=n,i=n+e,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<i){o.push({...h,startIndex:d-n});continue}else d>=i&&(h.startIndex-=e);a.push(h)}t.paragraphs=a}return o}function us(t,e,n){const{sectionBreaks:s}=t,r=n,i=n+e-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<=i){o.push({...h,startIndex:d-n});continue}else d>i&&(h.startIndex-=e);a.push(h)}t.sectionBreaks=a}return o}function cs(t,e,n){const{customBlocks:s}=t,r=n,i=n+e-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d}=h;if(d>=r&&d<=i){o.push({...h,startIndex:d-n});continue}else d>i&&(h.startIndex-=e);a.push(h)}t.customBlocks=a}return o}function hs(t,e,n){const{tables:s}=t,r=n,i=n+e-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d,endIndex:f}=h;if(r<=d&&i>=f){o.push({...h,startIndex:d-n,endIndex:f-n});continue}else if(d<=r&&f>=i){const E=ne(d,f,r,i);h.startIndex=E[0],h.endIndex=E[1]}else i<d&&(h.startIndex-=e,h.endIndex-=e);a.push(h)}t.tables=a}return o}function ds(t,e,n){const{customRanges:s}=t,r=n,i=n+e-1,o=[];if(s){const a=[];for(let l=0,c=s.length;l<c;l++){const h=s[l],{startIndex:d,endIndex:f}=h;if(r<=d&&i>=f){o.push({...h,startIndex:d-n,endIndex:f-n});continue}else if(d<=r&&f>=i){const E=ne(d,f,r,i);h.startIndex=E[0],h.endIndex=E[1]}else i<d&&(h.startIndex-=e,h.endIndex-=e);a.push(h)}t.customRanges=a}return o}function Wi(t,e,n){const{dataStream:s}=t,r=n,i=n+e,o=as(t,e,n),a=ls(t,e,n),l=us(t,e,n),c=cs(t,e,n),h=hs(t,e,n),d=ds(t,e,n);let f="";return s&&(t.dataStream=Un(s,r,i),f=s.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:c,tables:h,customRanges:d}}function Bi(t,e,n,s){t.dataStream=vn(t.dataStream,s,e.dataStream),is(t,e,n,s),Re(t,e,n,s),Fi(t,e,n,s),os(t,e,n,s),me(t,e,n,s),pi(t,e,n,s)}var $t=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))($t||{});const ki={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:ht.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:K.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:K.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:63}]}};function Gi(t,e,n,s,r){const i=$i(t,e,n,s,r),o=Vi(t,e,n,s,r),a=xi(t,e,n,s,r),l=ji(t,e,n,s,r),c=Ki(t,e,n,s,r),h=Yi(t,e,n,s,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:c,customRanges:h}}function $i(t,e,n,s,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const a=as(t,n,s);if(r!==H.REPLACE){const l=_s(o,a,r);e.textRuns=l}return is(t,e,n,s),a}function _s(t,e,n){if(e.length===0)return t;t=m.deepClone(t),e=m.deepClone(e);const s=[],r=t.length,i=e.length;let o=0,a=0,l=null;function c(){return l?(s.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:E,ed:g,ts:R}=t[o],{st:O,ed:L,ts:P,sId:F}=e[a];let Q;n===H.COVER?Q={...P,...R}:Q={...R,...P},g<O?(c()||s.push(t[o]),o++):L<E?(c()||s.push(e[a]),a++):(s.push({st:Math.min(E,O),ed:Math.max(E,O),ts:E<O?{...R}:{...P},sId:E<O?void 0:F}),s.push({st:Math.max(E,O),ed:Math.min(g,L),ts:Q,sId:F}),g<L?(o++,e[a].st=g):(a++,t[o].st=L),l={st:Math.min(g,L),ed:Math.max(g,L),ts:g<L?{...P}:{...R},sId:g<L?F:void 0})}c();const h=s[s.length-1],d=t[r-1],f=e[i-1];return h.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?s.push(d):s.push(f)),ge(s)}function Vi(t,e,n,s,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const a=ls(t,n,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,paragraphStyle:d,bullet:f}=c;let E=[];for(const g of a){const{startIndex:R,paragraphStyle:O,bullet:L}=g;let P,F;if(r===H.COVER?(P={...O,...d},F={listId:"",listType:$t.BULLET_LIST,nestingLevel:0,textStyle:{},...L,...f}):(P={...d,...O},F={listId:"",listType:$t.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...L}),h===R){E.push({startIndex:h,paragraphStyle:P,bullet:F});break}}l.push(...E),E=[]}e.paragraphs=l}return Re(t,e,n,s),a}function xi(t,e,n,s,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const a=us(t,n,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let d=[];for(const f of a){const{startIndex:E}=f;if(h===E){r===H.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.sectionBreaks=l}return Re(t,e,n,s),a}function ji(t,e,n,s,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const a=cs(t,n,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h}=c;let d=[];for(const f of a){const{startIndex:E}=f;if(h===E){r===H.COVER?d.push({...f,...c}):d.push({...c,...f});break}}l.push(...d),d=[]}e.customBlocks=l}return os(t,e,n,s),a}function Ki(t,e,n,s,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=hs(t,n,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,endIndex:d}=c;let f=[];for(const E of a){const{startIndex:g,endIndex:R}=E;if(g>=h&&R<=d){r===H.COVER?f.push({...E,...c}):f.push({...c,...E});break}}l.push(...f),f=[]}e.tables=l}return me(t,e,n,s),a}function Yi(t,e,n,s,r){const{customRanges:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=ds(t,n,s);if(r!==H.REPLACE){const l=[];for(const c of o){const{startIndex:h,endIndex:d}=c;let f=[];for(const E of a){const{startIndex:g,endIndex:R}=E;if(g>=h&&R<=d){r===H.COVER?f.push({...E,...c}):f.push({...c,...E});break}}l.push(...f),f=[]}e.customRanges=l}return me(t,e,n,s),a}var N=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(N||{});function Ce(t,e,n){const{dataStream:s,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:s.slice(e,n)},a=[];for(const c of r){const h=m.deepClone(c),{st:d,ed:f}=h;m.hasIntersectionBetweenTwoRanges(d,f,e,n)&&(e>=d&&e<=f?a.push({...h,st:e,ed:Math.min(n,f)}):n>=d&&n<=f?a.push({...h,st:Math.max(e,d),ed:n}):a.push(h))}a.length&&(o.textRuns=a.map(c=>{const{st:h,ed:d}=c;return{...c,st:h-e,ed:d-e}}));const l=[];for(const c of i){const{startIndex:h}=c;h>=e&&h<=n&&l.push(m.deepClone(c))}return l.length&&(o.paragraphs=l.map(c=>({...c,startIndex:c.startIndex-e}))),o}function Oe(t,e,n=H.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:a=[]}=e,l=_s(o,r,n);l.length&&(s.textRuns=l);const c=[];let h=0,d=0;for(;h<i.length&&d<a.length;){const f=i[h],E=a[d],{startIndex:g}=f,{startIndex:R}=E;g===R?(c.push(m.deepMerge(f,E)),h++,d++):g<R?(c.push(m.deepClone(f)),h++):(c.push(m.deepClone(E)),d++)}return h<i.length&&c.push(...i.slice(h)),d<a.length&&c.push(...a.slice(d)),c.length&&(s.paragraphs=c),s}function yi(t){const{body:e}=t;if(e==null)return!0;const{textRuns:n=[],paragraphs:s=[]}=e;return n.length===0&&s.length===0}function zi(t=m.generateRandomId(6),e=tt.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:{}}}const Ie={id:"default_doc",documentStyle:{}};class Xi extends Gt{constructor(n){super();_(this,"type",A.UNIVER_DOC);_(this,"snapshot");this.snapshot={...Ie,...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 body(){return this.snapshot.body}get zoomRatio(){var n;return((n=this.snapshot.settings)==null?void 0:n.zoomRatio)||1}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:a}=this.snapshot;s!=null&&(a.marginTop=s),r!=null&&(a.marginLeft=r),i!=null&&(a.marginBottom=i),o!=null&&(a.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:a,top:l}=s,c=r==null?void 0:r[n];if(!c)return;const h=c.objectTransform;h.size.width=i,h.size.height=o,h.positionH.posOffset=a,h.positionV.posOffset=l}setZoomRatio(n=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:n}:this.snapshot.settings.zoomRatio=1}}class it extends Xi{constructor(n){var r;super(m.isEmptyObject(n)?zi():n);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const s=6;this._unitId=(r=this.snapshot.id)!=null?r:m.generateRandomId(s),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(n=>{n.dispose()}),this.footerModelMap.forEach(n=>{n.dispose()})}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={...Ie,...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){const s=[],r=new ss;return r.reset(),n.forEach(i=>{if(i=m.deepClone(i),i.t===N.RETAIN){const{coverType:o,body:a,len:l,segmentId:c}=i;if(a!=null){const h=this._updateApply(a,l,r.cursor,o,c);s.push({...i,t:N.RETAIN,coverType:H.REPLACE,body:h})}else s.push({...i,t:N.RETAIN});r.moveCursor(l)}else if(i.t===N.INSERT){const{body:o,len:a,segmentId:l,line:c}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),s.push({t:N.DELETE,len:a,line:c,segmentId:l})}else if(i.t===N.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);s.push({...i,t:N.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),s}sliceBody(n,s){const r=this.getBody();if(r!=null)return Ce(r,n,s)}_updateApply(n,s,r,i=H.COVER,o){if(n==null)throw new Error("updateBody is none");const a=this.snapshot,l=Mt(a,o);if(l==null)throw new Error("no body has changed");return Gi(l,n,s,r,i)}_deleteApply(n,s,r){const i=this.snapshot,o=Mt(i,r);if(o==null)throw new Error("no body has changed");return n<=0?{dataStream:""}:Wi(o,n,s)}_insertApply(n,s,r,i){const o=this.snapshot,a=Mt(o,i);if(s!==0){if(a==null)throw new Error("no body has changed");Bi(a,n,s,r)}}_initializeHeaderFooterModel(){const{headers:n,footers:s}=this.getSnapshot();if(n)for(const r in n){const i=n[r];this.headerModelMap.set(r,new it(i))}if(s)for(const r in s){const i=s[r];this.footerModelMap.set(r,new it(i))}}updateDocumentId(n){super.updateDocumentId(n),this._unitId=n}}const fs=S.createIdentifier("univer.config-service");class Es{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 gs extends D{constructor(){super(...arguments);_(this,"_error$",new C.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(n){this._error$.next({errorKey:n})}}const qi="__default_document_sub_component_id20231101__";class Rs{constructor(){_(this,"_managerInfo",new Map);_(this,"_remove$",new C.Subject);_(this,"remove$",this._remove$.asObservable());_(this,"_andOrUpdate$",new C.Subject);_(this,"andOrUpdate$",this._andOrUpdate$.asObservable());_(this,"_pluginUpdate$",new C.Subject);_(this,"pluginUpdate$",this._pluginUpdate$.asObservable())}getFloatObject(e){return this._getFloatingObject(e)}getFloatObjects(e){return this._getFloatingObjects(e)}dispose(){this._remove$.complete(),this._andOrUpdate$.complete(),this._pluginUpdate$.complete(),this._managerInfo.clear()}clear(e){const n=this._clearByParam(e);this._remove$.next(n)}addOrUpdate(e){const n=this._addByParam(e);this._andOrUpdate$.next(n)}batchAddOrUpdate(e){const n=[];e.forEach(s=>{n.push(...this._addByParam(s))}),this._andOrUpdate$.next(n)}remove(e){const n=this._removeByParam(e);this._remove$.next(n)}pluginUpdateRefresh(e){this._pluginUpdate$.next(e)}_getFloatingObjects(e){var r;if(e==null)return;const{unitId:n,subUnitId:s}=e;return(r=this._managerInfo.get(n))==null?void 0:r.get(s)}_getFloatingObject(e){var i,o;if(e==null)return;const{unitId:n,subUnitId:s,floatingObjectId:r}=e;return(o=(i=this._managerInfo.get(n))==null?void 0:i.get(s))==null?void 0:o.get(r)}_addByParam(e){const{unitId:n,subUnitId:s,floatingObject:r,floatingObjectId:i,behindText:o}=e;this._managerInfo.has(n)||this._managerInfo.set(n,new Map);const a=this._managerInfo.get(n);return a.has(s)||a.set(s,new Map),a.get(s).set(i,r),[{unitId:n,subUnitId:s,floatingObjectId:i,floatingObject:r,behindText:o}]}_clearByParam(e){const n=this._getFloatingObjects(e),{unitId:s,subUnitId:r}=e,i=[];return n==null||n.forEach((o,a)=>{i.push({unitId:s,subUnitId:r,floatingObjectId:a,floatingObject:o})}),n==null||n.clear(),i}_removeByParam(e){const n=this._getFloatingObjects(e),s=n==null?void 0:n.get(e.floatingObjectId);return s==null?[]:(n==null||n.delete(e.floatingObjectId),[{...e,floatingObject:s}])}}const ms=S.createIdentifier("univer.floating-object.service");class Cs{constructor(e={}){_(this,"_styles");_(this,"_cacheMap",new Vn(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=m.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&&m.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(m.diffValue(n[s],e))return s;return null}}class Ji{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!==I.TRUE:!0}getHiddenCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const a=this.getColVisible(o);r&&a?(r=!1,s.push({rangeType:p.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:p.COLUMN}),s}getVisibleCols(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const a=this.getColVisible(o);r&&!a?(r=!1,s.push({rangeType:p.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:0,endRow:0,startColumn:i,endColumn:n,rangeType:p.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 y(this._columnData)}getColumnWidth(e){const{_columnData:n}=this,s=this._config;let r=0;return r=(n[e]||{hd:I.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:I.FALSE};return this._columnData[e]=i,i}}class Zi{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 a=s[o+e]||{hd:I.FALSE,h:r.defaultRowHeight},{ia:l,ah:c,h=r.defaultRowHeight}=a;i+=(l==null||l===I.TRUE)&&typeof c=="number"?c:h}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:I.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 a=this.getRowRawVisible(o);r&&a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:p.ROW})):!r&&!a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:p.ROW}),s}getVisibleRows(e=0,n=this.getSize()-1){const s=[];let r=!1,i=-1;for(let o=e;o<=n;o++){const a=this.getRowRawVisible(o);r&&!a?(r=!1,s.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:p.ROW})):!r&&a&&(r=!0,i=o)}return r&&s.push({startRow:i,endRow:n,startColumn:0,endColumn:0,rangeType:p.ROW}),s}getRowRawVisible(e){const n=this.getRow(e);return n?n.hd!==I.TRUE:!0}getSize(){return y(this._rowData)}}const Qi="DEFAULT_WORKSHEET_ROW_COUNT",Os=1e3,to="DEFAULT_WORKSHEET_COLUMN_COUNT",Is=20,eo="DEFAULT_WORKSHEET_ROW_HEIGHT",As=19,no="DEFAULT_WORKSHEET_COLUMN_WIDTH",Ns=73,so="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Ss=46,ro="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Ls=20;function Ts(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:I.FALSE,rowCount:Os,columnCount:Is,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Ns,defaultRowHeight:As,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:I.TRUE,rowHeader:{width:Ss,hidden:I.FALSE},columnHeader:{height:Ls,hidden:I.FALSE},selections:["A1"],rightToLeft:I.FALSE};return Object.keys(e).forEach(n=>{const s=n;typeof t[s]>"u"&&(t[s]=e[s])}),t}class bs extends D{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,U(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(n){if(this._rowFilteredInterceptor)throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptor=n,U(()=>this._rowFilteredInterceptor=null)}}class mt{constructor(e,n,s){_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var a;this.unitId=e,this._styles=s,this._snapshot=Ts(n);const{columnData:r,rowData:i,cellData:o}=this._snapshot;this._sheetId=(a=this._snapshot.id)!=null?a:m.generateRandomId(6),this._cellData=new V(o),this._viewModel=new bs((l,c)=>this.getCellRaw(l,c)),this._rowManager=new Zi(this._snapshot,this._viewModel,i),this._columnManager=new Ji(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,a=!1,l=!1;return e.forEach((c,h)=>{Object.keys(h).forEach(d=>{const f=+d,E=e.getValue(c,f),g=E!=null&&E.s?this._styles.get(E.s):null,R=(g==null?void 0:g.bd)&&(g.bd.b||g.bd.l||g.bd.r||g.bd.t||g.bd.bc_tr||g.bd.bl_tr||g.bd.ml_tr||g.bd.tl_bc||g.bd.tl_br||g.bd.tl_mr);(E&&(E.v||E.p)||g!=null&&g.bg||R)&&(a?s=Math.min(s,c):(s=c,a=!0),r=Math.max(r,c),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),n.forEach(c=>{a?s=Math.min(s,c.startRow):(s=c.startRow,a=!0),r=Math.max(r,c.endRow),l?i=Math.min(i,c.startColumn):(i=c.startColumn,a=!0),o=Math.max(o,c.endColumn)}),!a||!l?null:{startColumn:i,startRow:s,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,n=m.deepClone(e);return new mt(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(z.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(),a=this._snapshot.mergeData.filter(c=>z.intersects({startRow:e,startColumn:n,endRow:s,endColumn:r},c)),l=new V;return ce(e,s,n,r).forEach((c,h)=>{const d=i?this.getCellRaw(c,h):this.getCell(c,h);d&&l.setValue(c,h,d)}),a.forEach(c=>{const{startColumn:h,startRow:d,endColumn:f,endRow:E}=c;ce(d,E,h,f).forEach((g,R)=>{g===d&&R===h&&l.setValue(g,R,{...o.getValue(g,R),rowSpan:E-d+1,colSpan:f-h+1}),(g!==d||R!==h)&&l.realDeleteValue(g,R)})}),l}getRange(e,n,s,r){return typeof e=="object"?new rt(this,e,{getStyles:()=>this._styles}):new rt(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,a=this;return{[Symbol.iterator]:()=>{let l=s,c=r;return{next(){for(;;){if(c>o&&(l+=1,c=r),l>i)return{done:!0,value:void 0};const h=a.getCell(l,c),d=!h,f=a.getMergedCell(l,c);if(f){if(l!==f.startRow||c!==f.startColumn){c=f.endColumn+1;continue}if(d&&n){c=f.endColumn+1;continue}const g={row:l,col:c,value:h};return g.colSpan=f.endColumn-f.startColumn+1,g.rowSpan=f.endRow-f.startRow+1,c=f.endColumn+1,{done:!1,value:g}}if(d&&n)c+=1;else{const E={row:l,col:c,value:h};return c+=1,{done:!1,value:E}}}}}}}}iterateByColumn(e,n=!0,s=!0){const{startRow:r,startColumn:i,endRow:o,endColumn:a}=e,l=this;return{[Symbol.iterator]:()=>{let c=r,h=i;return{next(){for(;;){if(c>o&&(h+=1,c=r),h>a)return{done:!0,value:void 0};const d=l.getMergedCell(c,h);if(d){const g=c!==d.startRow,R=g||h!==d.startColumn;if(s&&R||!s&&g){c=d.endRow+1;continue}const O=l.getCell(d.startRow,d.startColumn);if(!O&&n){c=d.endRow+1;continue}const P={row:c,col:d.startColumn,value:O};return P.colSpan=d.endColumn-d.startColumn+1,P.rowSpan=d.endRow-d.startRow+1,c=d.endRow+1,{done:!1,value:P}}const f=l.getCell(c,h);if(!f&&n)c+=1;else{const g={row:c,col:h,value:f};return c+=1,{done:!1,value:g}}}}}}}}}function io(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===nt.BOOLEAN?n.toUpperCase():n:typeof n=="number"?t.t===nt.BOOLEAN?n?"TRUE":"FALSE":n.toString():typeof n=="boolean"?n?"TRUE":"FALSE":""}const oo="0.1.12";function ao(t="",e=tt.ZH_CN,n=""){return{id:t,sheetOrder:[],name:n,appVersion:oo,locale:e,styles:{},sheets:{},resources:[]}}var lo=Object.defineProperty,uo=Object.getOwnPropertyDescriptor,co=(t,e,n,s)=>{for(var r=s>1?void 0:s?uo(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&&lo(e,n,r),r},ho=(t,e)=>(n,s)=>e(n,s,t);function _o(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}u.Workbook=class extends Gt{constructor(n={},s){super();_(this,"type",A.UNIVER_SHEET);_(this,"_sheetCreated$",new C.Subject);_(this,"sheetCreated$",this._sheetCreated$.asObservable());_(this,"_sheetDisposed$",new C.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_activeSheet$",new C.BehaviorSubject(null));_(this,"activeSheet$",this._activeSheet$.asObservable());_(this,"_worksheets");_(this,"_styles");_(this,"_snapshot");_(this,"_unitId");_(this,"_count");this._logService=s;const r=ao();m.isEmptyObject(n)?this._snapshot=r:this._snapshot=m.commonExtend(r,n);const{styles:i}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=m.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new Cs(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 m.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._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 a=new mt(this._unitId,r,this._styles);return this._worksheets.set(n,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(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 a=this._worksheets.get(s[i]);if(a&&a.isSheetHidden()!==I.TRUE)return this.setActiveSheet(a),a}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===I.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}:ft}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 h,d,f,E,g;let s="",r="";if(n.indexOf("!")>-1){const R=n.split("!");s=R[0],r=R[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 R=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,O=m.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(R)&&!Number.isNaN(O)?{sheetId:s,range:{startRow:R,endRow:R,startColumn:O,endColumn:O}}:ft}r=r.split(":");const i=[0,0],o=[0,0],a=((h=this.getSheetBySheetName(s))==null?void 0:h.getMaxRows())||((d=this.getActiveSheet())==null?void 0:d.getMaxRows()),l=((f=this.getSheetBySheetName(s))==null?void 0:f.getMaxColumns())||((E=this.getActiveSheet())==null?void 0:E.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]=m.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=m.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])?ft:{sheetId:((g=this.getSheetBySheetName(s))==null?void 0:g.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(m.isEmptyObject(r)){const o=m.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.debug("[Workbook]",`The worksheet name ${l} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const c=new mt(this._unitId,a,this._styles);s.set(o,c),i.includes(o)||i.push(o)}}},u.Workbook=co([ho(1,X)],u.Workbook);class Ae extends Gt{constructor(n){var s;super();_(this,"type",A.UNIVER_SLIDE);_(this,"_snapshot");_(this,"_unitId");this._snapshot={...Yn,...n},this._unitId=(s=this._snapshot.id)!=null?s:m.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:te.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ct="FOCUSING_SHEET",Vt="FOCUSING_DOC",xt="FOCUSING_SLIDE",fo="FOCUSING_EDITOR_BUT_HIDDEN",ws="EDITOR_ACTIVATED",Eo="FOCUSING_EDITOR_INPUT_FORMULA",vs="FOCUSING_FORMULA_EDITOR",go="FOCUSING_UNIVER_EDITOR",Ro="FOCUSING_EDITOR_INPUT_FORMULA",mo="FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE";var Co=Object.defineProperty,Oo=Object.getOwnPropertyDescriptor,Io=(t,e,n,s)=>{for(var r=s>1?void 0:s?Oo(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&&Co(e,n,r),r},Us=(t,e)=>(n,s)=>e(n,s,t);const q=S.createIdentifier("univer.current");u.UniverInstanceService=class extends D{constructor(n,s){super();_(this,"_unitsByType",new Map);_(this,"_createHandler");_(this,"_ctorByType",new Map);_(this,"_currentUnits$",new C.BehaviorSubject({}));_(this,"currentUnits$",this._currentUnits$.asObservable());_(this,"_unitAdded$",new C.Subject);_(this,"unitAdded$",this._unitAdded$.asObservable());_(this,"_unitDisposed$",new C.Subject);_(this,"unitDisposed$",this._unitDisposed$.asObservable());_(this,"_focused$",new C.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(C.map(s=>{var r;return(r=s[n])!=null?r:null}),C.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(C.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(C.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(A.UNIVER_DOC)}getUniverDocInstance(n){return this.getUnit(n,A.UNIVER_DOC)}getUniverSheetInstance(n){return this.getUnit(n,A.UNIVER_SHEET)}getAllUnitsForType(n){var s;return(s=this._unitsByType.get(n))!=null?s:[]}changeDoc(n,s){const r=this.getAllUnitsForType(A.UNIVER_DOC),i=r.find(o=>o.getUnitId()===n);if(i!=null){const o=r.indexOf(i);r.splice(o,1)}this.__addUnit(s)}get focused(){var s;const n=this._focused$.getValue();return n?(s=this._getUnitById(n))==null?void 0:s[0]:null}focusUnit(n){this._focused$.next(n),this.focused instanceof u.Workbook?(this._contextService.setContextValue(Vt,!1),this._contextService.setContextValue(Ct,!0),this._contextService.setContextValue(xt,!1)):this.focused instanceof it?(this._contextService.setContextValue(Vt,!0),this._contextService.setContextValue(Ct,!1),this._contextService.setContextValue(xt,!1)):this.focused instanceof Ae&&(this._contextService.setContextValue(Vt,!1),this._contextService.setContextValue(Ct,!1),this._contextService.setContextValue(xt,!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),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(n){for(const[s,r]of this._unitsByType){const i=r.find(o=>o.getUnitId()===n);if(i)return[i,s]}}},u.UniverInstanceService=Io([Us(0,S.Inject(S.Injector)),Us(1,Et)],u.UniverInstanceService);var w=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(w||{});const Ao={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},jt=new Map;function Ne(t,e){return function(r){Se(t,e)}}function Se(t,e){jt.has(t)||jt.set(t,[]),jt.get(t).push(e)}var No=Object.defineProperty,So=Object.getOwnPropertyDescriptor,Ds=(t,e,n,s)=>{for(var r=s>1?void 0:s?So(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&&No(e,n,r),r},Le=(t,e)=>(n,s)=>e(n,s,t);u.LifecycleService=class extends D{constructor(n){super();_(this,"_lifecycle$",new C.BehaviorSubject(w.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());_(this,"_lock",!1);this._logService=n,this._reportProgress(w.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 C.Observable(n=>{this.stage===w.Starting||(this.stage===w.Ready?n.next(w.Starting):this.stage===w.Rendered?(n.next(w.Starting),n.next(w.Ready)):(n.next(w.Starting),n.next(w.Ready),n.next(w.Rendered))),this._lifecycle$.subscribe(s=>{n.next(s),s===w.Steady&&n.complete()})})}_reportProgress(n){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${Ao[n]}".`)}},u.LifecycleService=Ds([Le(0,X)],u.LifecycleService),u.LifecycleInitializerService=class extends D{constructor(n,s){super();_(this,"_seenTokens",new Set);this._lifecycleService=n,this._injector=s}initModulesOnStage(n){var s;(s=jt.get(n))==null||s.forEach(r=>{this._injector.has(r)&&!this._seenTokens.has(r)&&(this._injector.get(r),this._seenTokens.add(r))})}},u.LifecycleInitializerService=Ds([Le(0,S.Inject(u.LifecycleService)),Le(1,S.Inject(S.Injector))],u.LifecycleInitializerService);class Ot extends D{constructor(){super();_(this,"_currentLocale$",new C.BehaviorSubject(tt.ZH_CN));_(this,"currentLocale$",this._currentLocale$.asObservable());_(this,"_locales",null);_(this,"localeChanged$",new C.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((a,l)=>{o=o.replace(`{${l}}`,a)}),o}else return n});this.disposeWithMe(U(()=>this.localeChanged$.complete()))}get _currentLocale(){return this._currentLocale$.value}load(n){var s;this._locales=m.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}}const Kt=S.createIdentifier("resource-manager-service");var Lo=Object.defineProperty,To=Object.getOwnPropertyDescriptor,bo=(t,e,n,s)=>{for(var r=s>1?void 0:s?To(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&&Lo(e,n,r),r},Ms=(t,e)=>(n,s)=>e(n,s,t);const Te=S.createIdentifier("univer.permission-service");u.PermissionService=class extends D{constructor(n,s){super();_(this,"_permissionPointMap",new Map);_(this,"deletePermissionPoint",(n,s)=>{const r=this._permissionPointMap.get(n);if(r){const i=r.get(s);i&&(i.complete(),this._permissionPointMap.delete(s))}});_(this,"addPermissionPoint",(n,s)=>{const r=this._permissionPointMap.get(n)||new Map;return r.has(s.id)?!1:(r.set(s.id,new C.BehaviorSubject(s)),this._permissionPointMap.set(n,r),!0)});_(this,"updatePermissionPoint",(n,s,r)=>{const i=this._permissionPointMap.get(n);if(!i)return;const o=i.get(s);if(o){const a=o.getValue();a.value=r,a.status=ue.DONE,o.next(a)}});_(this,"getPermissionPoint",(n,s)=>{const r=this._permissionPointMap.get(n);if(!r)return;const i=r.get(s);if(i)return i.getValue()});this._resourceManagerService=n,this._univerInstanceService=s}_toJson(n){const s=this._permissionPointMap.get(n);let r=[];return s&&(r=[...s.keys()].reduce((i,o)=>{const a=s.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(n){return JSON.parse(n)}composePermission$(n,s){const r=this._permissionPointMap.get(n),i=s.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 C.combineLatest(i).pipe(x.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(n,s){const r=this._permissionPointMap.get(n);return s.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}},u.PermissionService=bo([Ne(w.Starting,u.PermissionService),Ms(0,S.Inject(Kt)),Ms(1,S.Inject(q))],u.PermissionService);const Ps="univer.editable";class Yt extends xn{constructor(n){super();_(this,"id",Ps);_(this,"value",!0);_(this,"unitID");this.unitID=n}}var wo=Object.defineProperty,vo=Object.getOwnPropertyDescriptor,Uo=(t,e,n,s)=>{for(var r=s>1?void 0:s?vo(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&&wo(e,n,r),r},Hs=(t,e)=>(n,s)=>e(n,s,t);u.UniverPermissionService=class extends D{constructor(e,n){super(),this._permissionService=e,this._univerInstanceService=n,this._init()}_init(){this._univerInstanceService.getTypeOfUnitAdded$(A.UNIVER_SHEET).subscribe(e=>{const n=new Yt(e.getUnitId());this._permissionService.addPermissionPoint(e.getUnitId(),n)})}getEditable(e=(n=>(n=this._univerInstanceService.getCurrentUnitForType(A.UNIVER_SHEET))==null?void 0:n.getUnitId())()){if(!e)return;const s=new Yt(e),r=this._permissionService.getPermissionPoint(e,s.id);return r==null?void 0:r.value}setEditable(e,n){const s=new Yt(e);this._permissionService.updatePermissionPoint(e,s.id,n)}},u.UniverPermissionService=Uo([Ne(w.Starting,u.UniverPermissionService),Hs(0,S.Inject(Te)),Hs(1,S.Inject(q))],u.UniverPermissionService);class Fs extends D{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new C.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),U(()=>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(a=>a.name===r.pluginName))==null?void 0:o.data;if(i)try{const a=r.parseJson(i);r.onLoad(n,a)}catch{console.error("LoadResources Error!")}})}unloadResources(n){this.getAllResourceHooks().forEach(s=>{s.onUnLoad(n)})}dispose(){this._register$.complete(),this._resourceMap.clear()}}var Do=Object.defineProperty,Mo=Object.getOwnPropertyDescriptor,Po=(t,e,n,s)=>{for(var r=s>1?void 0:s?Mo(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&&Do(e,n,r),r},ps=(t,e)=>(n,s)=>e(n,s,t);let be=class extends D{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 A.UNRECOGNIZED:case A.UNIVER_UNKNOWN:case A.UNIVER_SLIDE:case A.UNIVER_DOC:break;case A.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(A.UNIVER_SHEET).forEach(i=>{const a=(i.getSnapshot().resources||[]).find(l=>l.name===s.pluginName);if(a)try{const l=s.parseJson(a.data);s.onLoad(i.getUnitId(),l)}catch{console.error(`Load Workbook{${i.getUnitId()}} Resources{${s.pluginName}} Data Error.`)}})}})};this._resourceManagerService.getAllResourceHooks().forEach(s=>{e(s)}),this.disposeWithMe(this._resourceManagerService.register$.subscribe(s=>{e(s)})),this.disposeWithMe(U(this._univerInstanceService.getTypeOfUnitAdded$(A.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.loadResources(s.getUnitId(),s.getSnapshot().resources)}))),this.disposeWithMe(U(this._univerInstanceService.getTypeOfUnitDisposed$(A.UNIVER_SHEET).subscribe(s=>{this._resourceManagerService.unloadResources(s.getUnitId())})))}};be=Po([ps(0,S.Inject(Kt)),ps(1,S.Inject(q))],be);const we=S.createIdentifier("resource-loader-service");Se(w.Ready,we);class ve extends D{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new C.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(U(()=>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 Ws="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Bs="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Ho=`\r
7
+ `;function Fo(t){return`__internalEditorId__${t}`}function po(t){return t.startsWith("__")}var Wo=Object.defineProperty,Bo=Object.getOwnPropertyDescriptor,ko=(t,e,n,s)=>{for(var r=s>1?void 0:s?Bo(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&&Wo(e,n,r),r},Ue=(t,e)=>(n,s)=>e(n,s,t);const yt=S.createIdentifier("univer.undo-redo.service"),Go=20;class ks{dispose(){}async dispatchToHandlers(){return!1}}const Gs="univer.command.redo",$s="univer.command.undo",Vs=new class extends ks{constructor(){super(...arguments);_(this,"type",gt.COMMAND);_(this,"id",$s)}async handler(e){const n=e.get(yt),s=n.pitchTopUndoElement();if(!s)return!1;const r=e.get(Rt);return de(s.undoMutations,r)?(n.popUndoToRedo(),!0):!1}},xs=new class extends ks{constructor(){super(...arguments);_(this,"type",gt.COMMAND);_(this,"id",Gs)}async handler(e){const n=e.get(yt),s=n.pitchTopRedoElement();if(!s)return!1;const r=e.get(Rt);return de(s.redoMutations,r)?(n.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends D{constructor(n,s,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new C.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(Vs)),this.disposeWithMe(this._commandService.registerCommand(xs)),this.disposeWithMe(U(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(U(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 a=this._batchingStatus.get(n.unitID),l=this._pitchUndoElement(n.unitID);a===0||!l?(o(n),this._batchingStatus.set(n.unitID,1)):this._tryBatchingElements(l,n)}else o(n);function o(a){i.push(a),i.length>Go&&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),U(()=>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,a,l,c;let n="";const s=this._contextService.getContextValue(Ct),r=this._contextService.getContextValue(vs),i=this._contextService.getContextValue(ws);return s?r?n=Bs:i?n=Ws:n=(a=(o=this._univerInstanceService.getFocusedUnit())==null?void 0:o.getUnitId())!=null?a:"":n=(c=(l=this._univerInstanceService.getFocusedUnit())==null?void 0:l.getUnitId())!=null?c:"",n}},u.LocalUndoRedoService=ko([Ue(0,q),Ue(1,Rt),Ue(2,Et)],u.LocalUndoRedoService);class De extends D{onStarting(e){}onReady(){}onRendered(){}onSteady(){}getUniverInstanceType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}}_(De,"pluginName"),_(De,"type",A.UNIVER_UNKNOWN);class $o{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 Vo{constructor(){_(this,"_pluginsRegistered",[])}registerPlugin(e,n){this._pluginsRegistered.push({plugin:e,options:n})}getRegisterPlugins(){return this._pluginsRegistered.slice()}removePlugins(){this._pluginsRegistered=[]}}var xo=Object.defineProperty,jo=Object.getOwnPropertyDescriptor,Ko=(t,e,n,s)=>{for(var r=s>1?void 0:s?jo(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&&xo(e,n,r),r},zt=(t,e)=>(n,s)=>e(n,s,t);u.PluginHolder=class extends D{constructor(n,s,r,i){super();_(this,"_started",!1);_(this,"_pluginRegistered",new Set);_(this,"_pluginStore",new $o);_(this,"_pluginRegistry",new Vo);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(C.finalize(()=>{Promise.resolve().then(()=>s.dispose())})).subscribe(r=>{this._pluginsRunLifecycle(n,r)}))}_pluginsRunLifecycle(n,s){n.forEach(r=>{switch(s){case w.Starting:r.onStarting(this._injector);break;case w.Ready:r.onReady();break;case w.Rendered:r.onRendered();break;case w.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(s)}_initPlugin(n,s){return this._injector.createInstance(n,s)}},u.PluginHolder=Ko([zt(0,X),zt(1,S.Inject(S.Injector)),zt(2,S.Inject(u.LifecycleService)),zt(3,S.Inject(u.LifecycleInitializerService))],u.PluginHolder);var Yo=Object.defineProperty,yo=Object.getOwnPropertyDescriptor,zo=(t,e,n,s)=>{for(var r=s>1?void 0:s?yo(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&&Yo(e,n,r),r},Xo=(t,e)=>(n,s)=>e(n,s,t);const qo=4;u.PluginService=class{constructor(e){_(this,"_pluginHolderForUniver");_(this,"_pluginHoldersForTypes",new Map);_(this,"_flushTimer");this._injector=e,this._pluginHolderForUniver=this._injector.createInstance(u.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===A.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(u.PluginHolder);return this._pluginHoldersForTypes.set(e,n),n}return this._pluginHoldersForTypes.get(e)}_assertPluginValid(e){const{type:n,pluginName:s}=e;if(n===A.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()},qo))}_clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}_flushPlugins(){this._pluginHolderForUniver.flush();for(const[e,n]of this._pluginHoldersForTypes)n.started&&n.flush()}},u.PluginService=zo([Xo(0,S.Inject(S.Injector))],u.PluginService);function js(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}class Ks{constructor(){_(this,"_model",new Map);_(this,"_userChange$",new C.Subject);_(this,"userChange$",this._userChange$.asObservable());_(this,"_currentUser");_(this,"_currentUser$",new C.BehaviorSubject(null));_(this,"currentUser$",this._currentUser$.asObservable())}getCurrentUser(){return this._currentUser}setCurrentUser(e){this._currentUser=e,this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:"add",user:e})}getUser(e,n){const s=this._model.get(e);if(s)return s;n&&n()}delete(e){const n=this.getUser(e);this._model.delete(e),n&&this._userChange$.next({type:"delete",user:n})}clear(){this._model.clear(),this._userChange$.next({type:"clear"})}}class Jo{constructor(e={},n){_(this,"_startedTypes",new Set);_(this,"_injector");const s=this._injector=Zo(n,e==null?void 0:e.override),{theme:r,locale:i,locales:o,logLevel:a}=e;r&&this._injector.get(ve).setTheme(r),o&&this._injector.get(Ot).load(o),i&&this._injector.get(Ot).setLocale(i),a&&this._injector.get(X).setLogLevel(a),this._init(s),this._pluginService}get _univerInstanceService(){return this._injector.get(q)}get _pluginService(){return this._injector.get(u.PluginService)}__getInjector(){return this._injector}dispose(){this._injector.dispose()}setLocale(e){this._injector.get(Ot).setLocale(e)}createUnit(e,n){return this._univerInstanceService.createUnit(e,n)}createUniverSheet(e){return this._univerInstanceService.createUnit(A.UNIVER_SHEET,e)}createUniverDoc(e){return this._univerInstanceService.createUnit(A.UNIVER_DOC,e)}createUniverSlide(e){return this._univerInstanceService.createUnit(A.UNIVER_SLIDE,e)}_init(e){this._univerInstanceService.registerCtorForType(A.UNIVER_SHEET,u.Workbook),this._univerInstanceService.registerCtorForType(A.UNIVER_DOC,it),this._univerInstanceService.registerCtorForType(A.UNIVER_SLIDE,Ae);const n=e.get(q);n.__setCreateHandler((s,r,i)=>{if(!this._startedTypes.has(s)){this._pluginService.startPluginForType(s),this._startedTypes.add(s);const a=e.createInstance(i,r);return n.__addUnit(a),this._tryProgressToReady(),a}const o=e.createInstance(i,r);return n.__addUnit(o),o})}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<w.Ready&&(this._injector.get(u.LifecycleService).stage=w.Ready)}registerPlugin(e,n){this._pluginService.registerPlugin(e,n)}}function Zo(t,e){const n=js([[gs],[Ot],[ve],[u.LifecycleService],[u.LifecycleInitializerService],[u.UniverPermissionService],[u.PluginService],[Ks],[q,{useClass:u.UniverInstanceService}],[Te,{useClass:u.PermissionService}],[X,{useClass:Zn,lazy:!0}],[Rt,{useClass:u.CommandService,lazy:!0}],[yt,{useClass:u.LocalUndoRedoService,lazy:!0}],[fs,{useClass:Es}],[Et,{useClass:qn}],[ms,{useClass:Rs,lazy:!0}],[Kt,{useClass:Fs,lazy:!0}],[we,{useClass:be,lazy:!0}]],e);return t?t.createChild(n):new S.Injector(n)}const Qo=(t,e)=>e.length===t.length&&!t.some(n=>e.some(s=>!z.equals(s,n))),ta=(t,e)=>e.length===t.length&&t.every((n,s)=>{const r=e[s];return r.unitId===n.unitId&&r.sheetId===n.sheetId&&z.equals(n.range,r.range)});function ea(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 a=t[o],l=e[o];if(a!==l)return!1}return!0}function Ys(t){return/^-?\d+(\.\d+)?$/.test(t)}function na(t){return Ys(t)?Number(t)<=Number.MAX_SAFE_INTEGER:!1}function sa(t){return["true","false"].includes(t.toLowerCase())}function ra(t,e){return e.forEach(n=>t.add(n)),t}function ia(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 oa(t){const e=new MessageChannel;let n=!1;return e.port1.onmessage=()=>{n||t()},e.port2.postMessage(null),()=>{n=!0}}var ys=(t=>(t[t.TEXT=0]="TEXT",t[t.ARROW=1]="ARROW",t[t.CUSTOM=2]="CUSTOM",t))(ys||{});class Me{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===N.DELETE||n.t===N.RETAIN&&n.body==null?m.deepClone({...n,len:e}):m.deepClone({...n,len:e,body:Ce(n.body,s,s+e)})}else return{t:N.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:N.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[]}}function zs(t){return Object.keys(t).length===1}class Xt{constructor(){_(this,"_actions",[])}static compose(e,n){const s=new Me(e),r=new Me(n),i=new Xt;for(;s.hasNext()||r.hasNext();)if(r.peekType()===N.INSERT)i.push(r.next());else if(s.peekType()===N.DELETE)i.push(s.next());else{const o=Math.min(s.peekLength(),r.peekLength()),a=s.next(o),l=r.next(o);a.t===N.INSERT&&l.t===N.RETAIN?l.body==null?i.push(a):i.push({...a,body:Oe(a.body,l.body,l.coverType)}):a.t===N.RETAIN&&l.t===N.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:Oe(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===N.RETAIN&&l.t===N.DELETE?i.push(l):a.t===N.INSERT&&(l.t,N.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(e,n,s=""){const r={t:N.INSERT,body:n,len:e,line:0,segmentId:s};return this.push(r),this}retain(e,n="",s,r){const i={t:N.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:N.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=m.deepClone(e[0]);if(r.t===N.RETAIN&&r.len===0&&r.body==null)return this;if(typeof s=="object"){if(s.t===N.DELETE&&r.t===N.DELETE)return s.len+=r.len,this;if(s.t===N.DELETE&&r.t===N.INSERT&&(n-=1,s=this._actions[n-1],s==null))return this._actions.unshift(r),this;if(s.t===N.RETAIN&&r.t===N.RETAIN&&s.body==null&&r.body==null)return s.len+=r.len,this;if(s.t===N.INSERT&&zs(s.body)&&r.t===N.INSERT&&zs(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===N.RETAIN&&yi(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}}function aa(t,e,n){if(e==="")return t;const s={id:"mock-id",body:t,documentStyle:{}},r=new it(s),i=e.length;let o;for(;(o=r.getBody().dataStream.indexOf(e))>=0;){const l=new Xt;if(o>0&&l.retain(o),n.length>0){const h=r.sliceBody(o,o+i),d={dataStream:n};Array.isArray(h==null?void 0:h.textRuns)&&h.textRuns.length&&(d.textRuns=[{...h.textRuns[0],st:0,ed:n.length}]),l.insert(n.length,d)}l.delete(i);const c=l.serialize();r.apply(c)}const a=r.getBody();return r.dispose(),a}class la extends Ht{add(e){if(!e)return null;const n=new Pt(e,this);return this._observers=[n],this._onObserverAdded&&this._onObserverAdded(n),n}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const ua=S.createIdentifier("ILocalStorageService");function ca(t){return`sheet_interceptor_${t}`}const Xs=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 ha{constructor(e){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=e}fetchThroughInterceptors(e){const n=e,s=this._interceptorsByName.get(n);return Xs(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 a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>Ft(this._interceptorsByName.get(s),n)}getInterceptPoints(){return this._interceptorPoints}}const da=S.createIdentifier("univer.snapshot-server-service");class _a{constructor(){_(this,"_sheetBlockCache",new Map)}getUnitOnRev(e,n){return Promise.resolve({snapshot:{unitID:"",type:A.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:k.OK,message:""}})}getSheetBlock(e,n){const s=this._sheetBlockCache.get(n.blockID);return Promise.resolve({block:s,error:{code:k.OK,message:""}})}fetchMissingChangesets(e,n){return Promise.resolve({changesets:[],error:{code:k.OK,message:""}})}getResourcesRequest(e,n){return Promise.resolve({resources:{},error:{code:k.OK,message:""}})}saveSnapshot(e,n){return Promise.resolve({error:{code:k.OK,message:""}})}saveSheetBlock(e,n){const{block:s}=n;return s?(this._sheetBlockCache.set(s.id,s),Promise.resolve({error:{code:k.OK,message:""},blockID:s.id})):Promise.resolve({error:{code:k.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(e,n){return Promise.resolve({error:{code:k.OK,message:""},concurrent:[]})}}function fa(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(e,n)=>String.fromCharCode(Number.parseInt(n,16))))}function Pe(t){return decodeURIComponent(Array.prototype.map.call(atob(t),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const It=new TextEncoder,qt=new TextDecoder;function qs(t){const e=m.deepClone(t);return delete e.id,delete e.name,delete e.rowCount,delete e.columnCount,delete e.cellData,It.encode(JSON.stringify(e))}function Js(t){const e=m.deepClone(t);return delete e.id,delete e.rev,delete e.name,delete e.sheetOrder,delete e.sheets,It.encode(JSON.stringify(e))}function Ea(t){const e=m.deepClone(t);return delete e.id,delete e.rev,delete e.title,delete e.resources,It.encode(JSON.stringify(e))}function Zs(t){return JSON.parse(qt.decode(t))}function ga(t){return JSON.parse(typeof t=="string"?Pe(t):qt.decode(t))}function Ra(t){return JSON.parse(typeof t=="string"?Pe(t):qt.decode(t))}const He=256;function Qs(t,e){const n=new V(t),s=n.getLength(),r=[];let i=0;for(;i<s;){const o=Math.min(i+He,s-1),a=n.getSlice(i,Math.min(i+He,s-1),0,e),l=ma(a);r.push({id:m.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:l}),i+=He}return r}function ma(t){const e=t.getData();return It.encode(JSON.stringify(e))}async function Ca(t,e,n,s,r){const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([d,f])=>{const E={id:f.id,type:Nt.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:qs(f)};if(o[d]=E,f.cellData){const g=Qs(f.cellData,f.rowCount),R=await Promise.all(g.map(O=>r.saveSheetBlock(t,{unitID:n,type:A.UNIVER_SHEET,block:O})));if(R.some(O=>{var L;return((L=O.error)==null?void 0:L.code)!==k.OK}))return!1;i[d]={sheetID:d,blocks:R.map(O=>O.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Js(e),c={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:l};return{snapshotRes:{unitID:n,rev:c.rev,type:A.UNIVER_SHEET,workbook:c,doc:void 0}}}async function Oa(t,e,n,s,r){var f,E;const i={},o={};if(!await Promise.all(Object.entries(e.sheets).map(async([g,R])=>{const O={id:R.id,type:Nt.GRID,name:R.name,rowCount:R.rowCount,columnCount:R.columnCount,originalMeta:qs(R)};if(o[g]=O,R.cellData){const L=Qs(R.cellData,R.rowCount),P=await Promise.all(L.map(F=>r.saveSheetBlock(t,{unitID:n,type:A.UNIVER_SHEET,block:F})));if(P.some(F=>{var Q;return((Q=F.error)==null?void 0:Q.code)!==k.OK}))return!1;i[g]={sheetID:g,blocks:P.map(F=>F.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const l=Js(e),c={unitID:e.id,rev:s,creator:"",name:e.name,sheetOrder:e.sheetOrder,sheets:o,blockMeta:i,resources:e.resources||[],originalMeta:l},h={unitID:n,rev:c.rev,type:A.UNIVER_SHEET,workbook:c,doc:void 0},d=await r.saveSnapshot(t,{unitID:n,type:A.UNIVER_SHEET,snapshot:h});if(ns(d.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
8
+ ErrorCode: ${(f=d.error)==null?void 0:f.code}:${(E=d.error)==null?void 0:E.message}`);return{snapshot:h}}function Ia(t,e,n){const s=t.workbook;if(!s)throw new Error("");const r={};Object.entries(s.sheets).forEach(([l,c])=>{const h=Zs(c.originalMeta);r[l]={id:c.id,name:c.name,rowCount:c.rowCount,columnCount:c.columnCount,...h}});const i=new Map;e.forEach(l=>{i.set(l.id,l)}),s.blockMeta&&Object.entries(s.blockMeta).forEach(([l,c])=>{var f;const h=r[l];h.cellData={};const d=[];(f=c.blocks)==null||f.forEach(E=>{const g=i.get(E);if(g)d.push(g);else throw new Error("")}),d.forEach(E=>{const g=ga(E.data);Object.entries(g).forEach(([R,O])=>{const L=h.cellData[+R]={};Object.entries(O).forEach(([P,F])=>{L[+P]=F})})})});const o=Zs(s.originalMeta);return{id:t.unitID,rev:s.rev,name:s.name,sheetOrder:s.sheetOrder,appVersion:"",locale:tt.EN_US,sheets:r,styles:{},resources:s.resources||[],...o}}function Aa(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:a={},settings:l={}}=Ra(i);return{id:n,rev:s,locale:tt.EN_US,title:r,body:o,documentStyle:a,settings:l}}async function Na(t,e,n,s,r){var l,c,h;const i={unitID:e.id,rev:s,creator:"",name:(l=e.title)!=null?l:"",resources:e.resources||[],originalMeta:Ea(e)},o={unitID:n,rev:i.rev,type:A.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:n,type:A.UNIVER_DOC,snapshot:o});if(ns(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
9
+ ErrorCode: ${(c=a.error)==null?void 0:c.code}:${(h=a.error)==null?void 0:h.message}`);return{snapshot:o}}async function Sa(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 a=o.blocks.map(async l=>{const c={unitID:n.unitID,type:A.UNIVER_SHEET,blockID:l},{block:h}=await e.getSheetBlock({},c);if(h)s.push(h);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),s}var tr=(t=>(t[t.INFO=0]="INFO",t[t.STOP=1]="STOP",t[t.WARNING=2]="WARNING",t))(tr||{}),er=(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))(er||{}),nr=(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))(nr||{}),sr=(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))(sr||{}),rr=(t=>(t.VALID="valid",t.INVALID="invalid",t.VALIDATING="validating",t))(rr||{});ir(),u.ABCToNumber=di,u.AbsoluteRefType=v,u.ActionIterator=Me,u.AlignTypeH=In,u.AlignTypeV=An,u.AutoFillSeries=We,u.BaselineOffset=at,u.BlockType=nn,u.BooleanNumber=I,u.BorderStyleTypes=b,u.BorderType=Be,u.BulletAlignment=K,u.COLORS=Jt,u.CellValueType=nt,u.ClientSnapshotServerService=_a,u.Color=st,u.ColorBuilder=bt,u.ColorKit=$,u.ColorType=B,u.ColumnSeparatorType=on,u.CommandType=gt,u.CommonHideTypes=ke,u.ConfigService=Es,u.ContentAlignment=gn,u.ContextService=qn,u.CopyPasteType=Ge,u.CustomRangeType=en,u.DEFAULT_CELL=Ai,u.DEFAULT_DOC=Ie,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=qi,u.DEFAULT_EMPTY_DOCUMENT_VALUE=Ho,u.DEFAULT_RANGE=Oi,u.DEFAULT_RANGE_ARRAY=ft,u.DEFAULT_SELECTION=Ii,u.DEFAULT_SLIDE=Yn,u.DEFAULT_STYLES=Bt,u.DEFAULT_WORKSHEET_COLUMN_COUNT=Is,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=to,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Ls,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=ro,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=Ns,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=no,u.DEFAULT_WORKSHEET_ROW_COUNT=Os,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Qi,u.DEFAULT_WORKSHEET_ROW_HEIGHT=As,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=eo,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Ss,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=so,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Bs,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ws,u.DashStyleType=_n,u.DataStreamTreeNodeType=rs,u.DataStreamTreeTokenType=Ee,u.DataValidationErrorStyle=tr,u.DataValidationImeMode=er,u.DataValidationOperator=nr,u.DataValidationRenderMode=ys,u.DataValidationStatus=rr,u.DataValidationType=sr,u.DesktopLogService=Zn,u.DeveloperMetadataVisibility=$e,u.Dimension=Ve,u.Direction=xe,u.Disposable=D,u.DisposableCollection=re,u.DocStyleType=Qe,u.DocumentDataModel=it,u.EDITOR_ACTIVATED=ws,u.EXTENSION_NAMES=yn,u.Entry=ie,u.EntryIterator=$n,u.ErrorService=gs,u.EventState=Wn,u.FOCUSING_DOC=Vt,u.FOCUSING_EDITOR_BUT_HIDDEN=fo,u.FOCUSING_EDITOR_INPUT_FORMULA=Eo,u.FOCUSING_EDITOR_STANDALONE=Ro,u.FOCUSING_FORMULA_EDITOR=vs,u.FOCUSING_SHEET=Ct,u.FOCUSING_SLIDE=xt,u.FOCUSING_UNIVER_EDITOR=go,u.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=mo,u.FloatingObjectManagerService=Rs,u.FollowNumberWithType=tn,u.FontItalic=St,u.FontStyleType=Rn,u.FontWeight=Lt,u.FormatType=je,u.GlyphType=ht,u.GridType=sn,u.HLSColor=Je,u.HorizontalAlign=et,u.ICommandService=Rt,u.IConfigService=fs,u.IContextService=Et,u.IFloatingObjectManagerService=ms,u.ILocalStorageService=ua,u.ILogService=X,u.IPermissionService=Te,u.IResourceLoaderService=we,u.IResourceManagerService=Kt,u.ISnapshotServerService=da,u.IUndoRedoService=yt,u.IUniverInstanceService=q,u.InterceptorManager=ha,u.InterpolationPointType=Ke,u.KeyIterator=kn,u.LRUHelper=_t,u.LRUMap=Vn,u.LifecycleStages=w,u.LocaleService=Ot,u.LocaleType=tt,u.LogLevel=Jn,u.MemoryCursor=ss,u.NamedStyleType=hn,u.NilCommand=ts,u.NumberUnitType=On,u.ObjectMatrix=V,u.ObjectRelativeFromH=mn,u.ObjectRelativeFromV=Cn,u.Observable=Ht,u.ObservableHooks=la,u.Observer=Pt,u.OnLifecycle=Ne,u.PRESET_LIST_TYPE=ki,u.PageElementType=Ln,u.PageOrientType=Sn,u.PageType=te,u.ParagraphElementType=ln,u.PermissionPoint=xn,u.PermissionStatus=ue,u.Plugin=De,u.PositionedObjectLayoutType=cn,u.PresetListType=$t,u.ProtectionType=Ye,u.RANGE_TYPE=p,u.RGBA_PAREN=hr,u.RGB_PAREN=cr,u.Range=rt,u.Rectangle=z,u.RedoCommand=xs,u.RedoCommandId=Gs,u.RefAlias=hi,u.Registry=_e,u.RegistryAsMap=fe,u.RelativeDate=ye,u.RelativeSlideLink=Tn,u.ResourceManagerService=Fs,u.RgbColor=wt,u.RxDisposable=ei,u.SectionType=rn,u.ShapeType=ze,u.SheetTypes=Nt,u.SheetViewModel=bs,u.SlideDataModel=Ae,u.SpacingRule=dn,u.Styles=Cs,u.THEME_COLORS=qe,u.TabStopAlignment=fn,u.TextDecoration=Xe,u.TextDirection=ut,u.TextDirectionType=an,u.TextX=Xt,u.TextXActionType=N,u.ThemeColor=vt,u.ThemeColorType=W,u.ThemeColors=Tt,u.ThemeService=ve,u.Tools=m,u.UndoCommand=Vs,u.UndoCommandId=$s,u.UnitModel=Gt,u.Univer=Jo,u.UniverEditablePermission=Yt,u.UniverEditablePermissionPoint=Ps,u.UniverInstanceType=A,u.UpdateDocsAttributeType=H,u.UserManagerService=Ks,u.ValueIterator=Gn,u.VerticalAlign=ot,u.WidthType=En,u.Worksheet=mt,u.WrapStrategy=ct,u.WrapTextType=un,u.afterInitApply=Hi,u.b64DecodeUnicode=Pe,u.b64EncodeUnicode=fa,u.binarySearchArray=Fe,u.cellToRange=Yr,u.characterSpacingControlType=Nn,u.checkForSubstrings=yr,u.checkParagraphHasBullet=zr,u.checkParagraphHasIndent=Xr,u.checkParagraphHasIndentByStyle=wn,u.codeToBlob=lr,u.composeBody=Oe,u.composeInterceptors=Xs,u.concatMatrixArray=oi,u.convertBodyToHtml=Ci,u.covertTextRunToHtml=he,u.createInterceptorKey=ca,u.createInternalEditorID=Fo,u.createRowColIter=ce,u.debounce=mi,u.dedupe=ni,u.deepCompare=ee,u.deleteContent=Un,u.extractPureTextFromCell=io,u.fromCallback=es,u.fromObservable=ti,u.generateTemporarySnap=Ca,u.getArrayLength=y,u.getBodySlice=Ce,u.getBodySliceHtml=Wt,u.getBorderStyleType=jr,u.getCellValueType=Tr,u.getColorStyle=j,u.getDocsUpdateBody=Mt,u.getReverseDirection=ur,u.getSheetBlocksFromSnapshot=Sa,u.getTypeFromPermissionItemList=ci,u.getWorksheetUID=_o,u.groupBy=ii,u.handleJsonToDom=Vr,u.handleStyleToString=xr,u.hashAlgorithm=Jr,u.horizontalLineSegmentsSubtraction=ne,u.insertMatrixArray=oe,u.insertTextToContent=vn,u.isBlackColor=Nr,u.isBooleanString=sa,u.isCellV=wr,u.isEmptyCell=kr,u.isFormulaId=$r,u.isFormulaString=Gr,u.isICellData=Lr,u.isInternalEditorID=po,u.isNullCell=br,u.isNumeric=Ys,u.isObserver=Bn,u.isRangesEqual=Qo,u.isRealNum=qr,u.isSafeNumeric=na,u.isSameStyleTextRun=bn,u.isUnitRangesEqual=ta,u.isValidRange=Kr,u.isWhiteColor=Sr,u.makeCellRangeToRangeData=Br,u.makeCellToSelection=Wr,u.mergeOverrideWithDependencies=js,u.mergeSets=ra,u.mergeWorksheetSnapshotWithDefault=Ts,u.moveMatrixArray=le,u.moveRangeByOffset=bi,u.normalizeTextRuns=ge,u.numberToABC=fi,u.numberToListABC=Ei,u.orderSearchArray=pe,u.queryObjectMatrix=Ti,u.remove=Ft,u.repeatStringNumTimes=Kn,u.replaceInDocumentBody=aa,u.requestImmediateMacroTask=oa,u.rotate=ri,u.runOnLifecycle=Se,u.searchArray=ar,u.selectionToArray=vr,u.sequence=Xn,u.sequenceAsync=zn,u.sequenceExecute=de,u.sequenceExecuteAsync=Pi,u.shallowEqual=ea,u.sliceMatrixArray=ai,u.sortRules=gi,u.sortRulesByDesc=Ri,u.sortRulesFactory=lt,u.spliceArray=ae,u.textDecoder=qt,u.textEncoder=It,u.throttle=ia,u.toDisposable=U,u.transformDocumentDataToSnapshot=Na,u.transformSnapshotToDocumentData=Aa,u.transformSnapshotToWorkbookData=Ia,u.transformWorkbookDataToSnapshot=Oa,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});