@univerjs/core 0.1.1 → 0.1.3

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 (44) hide show
  1. package/README.md +22 -2
  2. package/lib/cjs/index.js +8 -6
  3. package/lib/es/index.js +2262 -1685
  4. package/lib/types/common/__tests__/array.spec.d.ts +16 -0
  5. package/lib/types/common/array.d.ts +8 -0
  6. package/lib/types/common/interceptor.d.ts +1 -1
  7. package/lib/types/docs/data-model/__tests__/replacement.spec.d.ts +16 -0
  8. package/lib/types/docs/data-model/replacement.d.ts +17 -0
  9. package/lib/types/docs/data-model/text-x/text-x.d.ts +3 -3
  10. package/lib/types/index.d.ts +14 -1
  11. package/lib/types/services/command/command.service.d.ts +4 -4
  12. package/lib/types/services/context/context.d.ts +1 -0
  13. package/lib/types/services/instance/instance.service.d.ts +1 -1
  14. package/lib/types/services/locale/locale.service.d.ts +4 -2
  15. package/lib/types/services/log/context.d.ts +18 -0
  16. package/lib/types/services/snapshot/__tests__/snapshot-mock.d.ts +37 -0
  17. package/lib/types/services/snapshot/__tests__/snapshot-transform.spec.d.ts +16 -0
  18. package/lib/types/services/snapshot/snapshot-server.service.d.ts +57 -0
  19. package/lib/types/services/snapshot/snapshot-transform.d.ts +43 -0
  20. package/lib/types/services/snapshot/snapshot-utils.d.ts +34 -0
  21. package/lib/types/services/undoredo/undoredo.service.d.ts +20 -7
  22. package/lib/types/shared/coder.d.ts +17 -0
  23. package/lib/types/shared/color/color-kit.d.ts +3 -1
  24. package/lib/types/shared/compare.d.ts +1 -0
  25. package/lib/types/shared/debounce.d.ts +18 -0
  26. package/lib/types/shared/generate.d.ts +1 -1
  27. package/lib/types/shared/index.d.ts +2 -1
  28. package/lib/types/shared/locale.d.ts +2 -1
  29. package/lib/types/shared/object-matrix.d.ts +3 -0
  30. package/lib/types/shared/rxjs.d.ts +20 -0
  31. package/lib/types/shared/tools.d.ts +1 -1
  32. package/lib/types/sheets/__tests__/create-core-test-bed.d.ts +1 -2
  33. package/lib/types/sheets/__tests__/worksheet.spec.d.ts +16 -0
  34. package/lib/types/sheets/row-manager.d.ts +0 -2
  35. package/lib/types/sheets/workbook.d.ts +1 -0
  36. package/lib/types/sheets/worksheet.d.ts +29 -9
  37. package/lib/types/types/interfaces/i-cell-data.d.ts +6 -0
  38. package/lib/types/types/interfaces/i-column-data.d.ts +2 -2
  39. package/lib/types/types/interfaces/i-document-data.d.ts +3 -2
  40. package/lib/types/types/interfaces/i-range.d.ts +5 -0
  41. package/lib/types/types/interfaces/i-row-data.d.ts +2 -2
  42. package/lib/types/types/interfaces/i-selection-data.d.ts +6 -0
  43. package/lib/umd/index.js +8 -6
  44. package/package.json +8 -6
package/lib/umd/index.js CHANGED
@@ -1,6 +1,8 @@
1
- (function(u,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("@wendellhu/redi"),require("rxjs"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@wendellhu/redi","rxjs","rxjs/operators"],m):(u=typeof globalThis<"u"?globalThis:u||self,m(u.UniverCore={},u["@wendellhu/redi"],u.rxjs,u.rxjs.operators))})(this,function(u,m,C,Vn){"use strict";var Io=Object.defineProperty;var Ao=(u,m,C)=>m in u?Io(u,m,{enumerable:!0,configurable:!0,writable:!0,value:C}):u[m]=C;var _=(u,m,C)=>(Ao(u,typeof m!="symbol"?m+"":m,C),C);var Ro,mo;function xn(){jn()}const gt=typeof global<"u"?global:typeof self<"u"?self:window;function jn(){typeof gt.requestIdleCallback!="function"&&(gt.requestIdleCallback=function(s){const n=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-n));s({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof gt.cancelIdleCallback!="function"&&(gt.cancelIdleCallback=function(s){clearTimeout(s)})}class $t{constructor(){_(this,"_data",[])}static create(){return new $t}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){const s=this._data.indexOf(e);this._data.splice(s,1)}getData(){return this._data}}class Vt{constructor(){_(this,"_data",new Map)}static create(){return new Vt}add(e,s){this._data.has(e)||this._data.set(e,s)}delete(e){this._data.delete(e)}getData(){return this._data}}var D=(t=>(t[t.Univer=0]="Univer",t[t.Doc=1]="Doc",t[t.Sheet=2]="Sheet",t[t.Slide=3]="Slide",t))(D||{});class ve{constructor(e){_(this,"_name");this._name=e}onStarting(e){}onReady(){}onRendered(){}onSteady(){}onDestroy(){}getPluginName(){return this._name}}_(ve,"type",0);class Kn{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 Yn{constructor(){_(this,"_pluginsRegisteredByBusiness",new Map)}registerPlugin(e,s){const n=e.type;this._pluginsRegisteredByBusiness.has(n)||this._pluginsRegisteredByBusiness.set(n,[]),this._pluginsRegisteredByBusiness.get(n).push({plugin:e,options:s})}getRegisterPlugins(e){return this._pluginsRegisteredByBusiness.get(e)||[]}clearPluginsOfType(e){this._pluginsRegisteredByBusiness.delete(e)}}function j(t,e){const s=t.indexOf(e);return s>-1?(t.splice(s,1),!0):!1}function pn(t){const e=new Set,s=[];for(const n of t)e.has(n)||(e.add(n),s.push(n));return s}function zn(t,e){for(let s=t.length-1;s>-1;s--){const n=t[s];if(e(n,s))return n}return null}async function be(t){for(const[e,s]of t.entries())try{if(!await s())return{index:e,result:!1}}catch(n){return{index:e,result:!1,error:n}}return{result:!0,index:-1}}function we(t){for(const[e,s]of t.entries())try{if(!s())return{index:e,result:!1}}catch(n){return{index:e,result:!1,error:n}}return{result:!0,index:-1}}function De(t){var e=typeof Symbol=="function"&&Symbol.iterator,s=e&&t[e],n=0;if(s)return s.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Te(t,e){var s=typeof Symbol=="function"&&t[Symbol.iterator];if(!s)return t;var n=s.call(t),r,i=[],o;try{for(;(e===void 0||e-- >0)&&!(r=n.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(o)throw o.error}}return i}function Ue(t,e,s){if(s||arguments.length===2)for(var n=0,r=e.length,i;n<r;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;function ot(t){return typeof t=="function"}function Xn(t){var e=function(n){Error.call(n),n.stack=new Error().stack},s=t(e);return s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s}var xt=Xn(function(t){return function(s){t(this),this.message=s?s.length+` errors occurred during unsubscription:
2
- `+s.map(function(n,r){return r+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=s}});function Me(t,e){if(t){var s=t.indexOf(e);0<=s&&t.splice(s,1)}}var Pe=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,s,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=De(o),l=a.next();!l.done;l=a.next()){var h=l.value;h.remove(this)}}catch(O){e={error:O}}finally{try{l&&!l.done&&(s=a.return)&&s.call(a)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(ot(c))try{c()}catch(O){i=O instanceof xt?O.errors:[O]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=De(d),E=f.next();!E.done;E=f.next()){var g=E.value;try{Fe(g)}catch(O){i=i!=null?i:[],O instanceof xt?i=Ue(Ue([],Te(i)),Te(O.errors)):i.push(O)}}}catch(O){n={error:O}}finally{try{E&&!E.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}if(i)throw new xt(i)}},t.prototype.add=function(e){var s;if(e&&e!==this)if(this.closed)Fe(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(s=this._finalizers)!==null&&s!==void 0?s:[]).push(e)}},t.prototype._hasParent=function(e){var s=this._parentage;return s===e||Array.isArray(s)&&s.includes(e)},t.prototype._addParent=function(e){var s=this._parentage;this._parentage=Array.isArray(s)?(s.push(e),s):s?[s,e]:e},t.prototype._removeParent=function(e){var s=this._parentage;s===e?this._parentage=null:Array.isArray(s)&&Me(s,e)},t.prototype.remove=function(e){var s=this._finalizers;s&&Me(s,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}();Pe.EMPTY;function He(t){return t instanceof Pe||t&&"closed"in t&&ot(t.remove)&&ot(t.add)&&ot(t.unsubscribe)}function Fe(t){ot(t)?t():t.unsubscribe()}class We{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 Be(t){return t instanceof Rt}class Rt{constructor(e,s){_(this,"_willBeUnregistered",!1);_(this,"unregisterOnNextCall",!1);this.callback=e,this.observable=s}dispose(){this.observable.remove(this)}}class mt{constructor(e){_(this,"_observers",new Array);_(this,"_eventState");_(this,"_onObserverAdded");this._eventState=new We,e&&(this._onObserverAdded=e)}get observers(){return this._observers}add(e,s=!1,n=!1){if(!e)return null;const r=new Rt(e,this);return r.unregisterOnNextCall=n,s?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 s=0;s<this._observers.length;s++){const n=this._observers[s];if(!n._willBeUnregistered&&n.callback===e)return this._deferUnregister(n),!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 s=this._eventState;s.skipNextObservers=!1,s.lastReturnValue=e,s.isStopPropagation=!1;let n=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(!i._willBeUnregistered&&(s.lastReturnValue=i.callback(e,s),i.unregisterOnNextCall&&this._deferUnregister(i),s.isStopPropagation&&(n=!0),s.skipNextObservers))return{lastReturnValue:s.lastReturnValue,stopPropagation:n}}return{lastReturnValue:s.lastReturnValue,stopPropagation:n}}notifyObserversWithPromise(e){let s=Promise.resolve(e);if(!this._observers.length)return s;const n=this._eventState;n.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];n.skipNextObservers||i._willBeUnregistered||(s=s.then(()=>i.callback(e,n)),i.unregisterOnNextCall&&this._deferUnregister(i))}return s.then(()=>e)}notifyObserver(e,s){if(e._willBeUnregistered)return;const n=this._eventState;return n.skipNextObservers=!1,e.callback(s,n),e.unregisterOnNextCall&&this._deferUnregister(e),{lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const e=new mt;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 s=this._observers.indexOf(e);return s!==-1?(this._observers.splice(s,1),!0):!1}}function L(t){let e=!1;return He(t)?{dispose:()=>{e||(e=!0,t.unsubscribe())}}:Be(t)?{dispose:()=>{e||(e=!0,t.dispose())}}:{dispose:()=>{e||(e=!0,t())}}}function qn(t){return L(()=>{t.unsubscribe()})}class jt{constructor(){_(this,"_disposables",new Set)}add(e){return this._disposables.add(e),{dispose:()=>{e.dispose(),this._disposables.delete(e)}}}dispose(){this._disposables.forEach(e=>{e.dispose(),this._disposables.delete(e)})}}class U{constructor(){_(this,"_disposed",!1);_(this,"_collection",new jt)}disposeWithMe(e){const s=He(e)?L(e):e;return this._collection.add(s)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class Qn extends U{constructor(){super(...arguments);_(this,"dispose$",new C.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}const Z=m.createIdentifier("univer.context-service");class Ge extends U{constructor(){super(...arguments);_(this,"_contextChanged$",new C.Subject);_(this,"contextChanged$",this._contextChanged$.asObservable());_(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(s){var n;return(n=this._contextMap.get(s))!=null?n:!1}setContextValue(s,n){this._contextMap.set(s,n),this._contextChanged$.next({[s]:n})}subscribeContextValue$(s){return new C.Observable(n=>{const r=this._contextChanged$.pipe(C.filter(i=>typeof i[s]<"u")).subscribe(i=>n.next(i[s]));return this._contextMap.has(s)&&n.next(this._contextMap.get(s)),()=>r.unsubscribe()})}}var ke=(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))(ke||{});const q=m.createIdentifier("univer.log");class $e extends U{constructor(){super(...arguments);_(this,"_logLevel",3)}debug(...s){this._logLevel>=4&&this._log(console.debug,...s)}log(...s){this._logLevel>=3&&this._log(console.log,...s)}warn(...s){this._logLevel>=2&&this._log(console.warn,...s)}error(...s){this._logLevel>=1&&this._log(console.error,...s)}setLogLevel(s){this._logLevel=s}_log(s,...n){const r=n[0];/^\[(.*?)\]/g.test(r)?s(`\x1B[97;104m${r}\x1B[0m`,...n.slice(1)):s(...n)}}var Jn=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,yn=(t,e,s,n)=>{for(var r=n>1?void 0:n?Zn(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Jn(e,s,r),r},Ve=(t,e)=>(s,n)=>e(s,n,t),Ot=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(Ot||{});const at=m.createIdentifier("anywhere.command-service");class tr{constructor(){_(this,"_commands",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),L(()=>{var s;this._commands.delete(e.id),(s=e.onDispose)==null||s.call(e)})}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}}u.CommandService=class{constructor(e,s){_(this,"_commandRegistry");_(this,"_beforeCommandExecutionListeners",[]);_(this,"_commandExecutedListeners",[]);_(this,"_multiCommandDisposables",new Map);_(this,"_commandExecutingLevel",0);_(this,"_commandExecutionStack",[]);this._injector=e,this._logService=s,this._commandRegistry=new tr,this._registerCommand(xe)}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),L(()=>{const s=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),L(()=>{const s=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(s,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(e,s,n){const r=this._commandRegistry.getCommand(e);if(r){const[i]=r,o={id:i.id,type:i.type,params:s},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(h=>h(o,n));const l=await this._execute(i,s);return this._commandExecutedListeners.forEach(h=>h(o,n)),a.dispose(),l}throw new Error(`[CommandService]: command "${e}" is not registered.`)}syncExecuteCommand(e,s,n){var i;const r=this._commandRegistry.getCommand(e);if(r){const[o]=r,a={id:o.id,type:o.type,params:s};if(o.type===2){const c=zn(this._commandExecutionStack,d=>d.type===0);c&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=c.id)}const l=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(c=>c(a,n));const h=this._syncExecute(o,s);return this._commandExecutedListeners.forEach(c=>c(a,n)),l.dispose(),h}throw new Error(`[CommandService]: command "${e}" is not registered.`)}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),L(()=>j(this._commandExecutionStack,e))}_registerCommand(e){return this._commandRegistry.registerCommand(e)}_registerMultiCommand(e){const s=this._commandRegistry.getCommand(e.id);let n;if(s){if(s[0].multi!==!0)throw new Error("Command has registered as a single command.");n=s[0]}else{const i=new jt;n=new er(e.id),i.add(this._commandRegistry.registerCommand(n)),i.add(L(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,i)}const r=n.registerImplementation(e);return L(()=>{var i;r.dispose(),n.hasImplementations()||(i=this._multiCommandDisposables.get(e.id))==null||i.dispose()})}async _execute(e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let n;try{n=await this._injector.invoke(e.handler,s),this._commandExecutingLevel--}catch(r){throw n=!1,this._commandExecutingLevel=0,r}return n}_syncExecute(e,s){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let n;try{if(n=this._injector.invoke(e.handler,s),n instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(r){throw n=!1,this._commandExecutingLevel=0,r}return n}},u.CommandService=yn([Ve(0,m.Inject(m.Injector)),Ve(1,q)],u.CommandService);class er{constructor(e){_(this,"name");_(this,"multi",!0);_(this,"type",0);_(this,"priority",0);_(this,"_implementations",[]);_(this,"handler",async(e,s)=>{if(!this._implementations.length)return!1;const n=e.get(q),r=e.get(Z),i=e.get(m.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(n.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,s)))return!0}return!1});this.id=e,this.name=e}registerImplementation(e){const s={command:e};return this._implementations.push(s),this._implementations.sort((n,r)=>r.command.priority-n.command.priority),L(()=>{var r;const n=this._implementations.indexOf(s);this._implementations.splice(n,1),(r=e.onDispose)==null||r.call(e)})}hasImplementations(){return this._implementations.length>0}}function Kt(t,e,s){const n=t.map(r=>()=>e.syncExecuteCommand(r.id,r.params,s));return we(n)}function sr(t,e,s){const n=t.map(r=>()=>e.executeCommand(r.id,r.params,s));return be(n)}const xe={id:"nil",type:0,handler:()=>!0},je=m.createIdentifier("univer.config-service");class nr{constructor(){_(this,"_config",new Map)}getConfig(e){return this._config.get(e)}setConfig(e,s){this._config.set(e,s)}deleteConfig(e){this._config.delete(e)}}class Ke extends U{constructor(){super(...arguments);_(this,"_error$",new C.Subject);_(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(s){this._error$.next({errorKey:s})}}const rr="__default_document_sub_component_id20231101__";class Ye{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 s=this._clearByParam(e);this._remove$.next(s)}addOrUpdate(e){const s=this._addByParam(e);this._andOrUpdate$.next(s)}BatchAddOrUpdate(e){const s=[];e.forEach(n=>{s.push(...this._addByParam(n))}),this._andOrUpdate$.next(s)}remove(e){const s=this._removeByParam(e);this._remove$.next(s)}pluginUpdateRefresh(e){this._pluginUpdate$.next(e)}_getFloatingObjects(e){var r;if(e==null)return;const{unitId:s,subUnitId:n}=e;return(r=this._managerInfo.get(s))==null?void 0:r.get(n)}_getFloatingObject(e){var i,o;if(e==null)return;const{unitId:s,subUnitId:n,floatingObjectId:r}=e;return(o=(i=this._managerInfo.get(s))==null?void 0:i.get(n))==null?void 0:o.get(r)}_addByParam(e){const{unitId:s,subUnitId:n,floatingObject:r,floatingObjectId:i}=e;this._managerInfo.has(s)||this._managerInfo.set(s,new Map);const o=this._managerInfo.get(s);return o.has(n)||o.set(n,new Map),o.get(n).set(i,r),[{unitId:s,subUnitId:n,floatingObjectId:i,floatingObject:r}]}_clearByParam(e){const s=this._getFloatingObjects(e),{unitId:n,subUnitId:r}=e,i=[];return s==null||s.forEach((o,a)=>{i.push({unitId:n,subUnitId:r,floatingObjectId:a,floatingObject:o})}),s==null||s.clear(),i}_removeByParam(e){const s=this._getFloatingObjects(e),n=s==null?void 0:s.get(e.floatingObjectId);return n==null?[]:(s==null||s.delete(e.floatingObjectId),[{...e,floatingObject:n}])}}const pe=m.createIdentifier("univer.floating-object.service");class ze{constructor(){_(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}}function Xe(t,e){let s=0,n=t.length-1;for(;s<=n;){const r=Math.floor((n+s)/2);if(e<t[r]&&(r===0||e>=t[r-1]))return r;if(e>=t[r])s=r+1;else if(e<t[r])n=r-1;else return-1}return-1}function qe(t,e){let s=0,n=0,r=0,i=-1,o=t.length-1;for(;s<t.length&&o>=0&&o>=s;){if(n=t[o],o===0?r=0:r=t[o-1],e>=r&&e<=n){i=o;break}if(n=t[s],s===0?r=0:r=t[s-1],e>=r&&e<n){i=s;break}s++,o--}return i}function ir(t,e){let s=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[s-20]?s=qe(t,e):s=Xe(t,e),s)}function or(t){const e=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(e)}var Qe=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(Qe||{}),S=(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))(S||{}),Je=(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))(Je||{}),F=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(F||{}),Ze=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(Ze||{}),ye=(t=>(t[t.CONDITION_TYPE_UNSPECIFIED=0]="CONDITION_TYPE_UNSPECIFIED",t[t.NUMNUMBER_BETWEENR_GREATER=1]="NUMNUMBER_BETWEENR_GREATER",t[t.NUMBER_GREATER_THAN_EQ=2]="NUMBER_GREATER_THAN_EQ",t[t.NUMBER_LESS=3]="NUMBER_LESS",t[t.NUMBER_LESS_THAN_EQ=4]="NUMBER_LESS_THAN_EQ",t[t.NUMBER_EQ=5]="NUMBER_EQ",t[t.NUMBER_NOT_EQ=6]="NUMBER_NOT_EQ",t[t.NUMBER_BETWEEN=7]="NUMBER_BETWEEN",t[t.NUMBER_NOT_BETWEEN=8]="NUMBER_NOT_BETWEEN",t[t.TEXT_CONTAINS=9]="TEXT_CONTAINS",t[t.TEXT_NOT_CONTAINS=10]="TEXT_NOT_CONTAINS",t[t.TEXT_STARTS_WITH=11]="TEXT_STARTS_WITH",t[t.TEXT_ENDS_WITH=12]="TEXT_ENDS_WITH",t[t.TEXT_EQ=13]="TEXT_EQ",t[t.TEXT_IS_EMAIL=14]="TEXT_IS_EMAIL",t[t.TEXT_IS_URL=15]="TEXT_IS_URL",t[t.DATE_EQ=16]="DATE_EQ",t[t.DATE_BEFORE=17]="DATE_BEFORE",t[t.DATE_AFTER=18]="DATE_AFTER",t[t.DATE_ON_OR_BEFORE=19]="DATE_ON_OR_BEFORE",t[t.DATE_ON_OR_AFTER=20]="DATE_ON_OR_AFTER",t[t.DATE_BETWEEN=21]="DATE_BETWEEN",t[t.DATE_NOT_BETWEEN=22]="DATE_NOT_BETWEEN",t[t.DATE_IS_VALID=23]="DATE_IS_VALID",t[t.ONE_OF_RANGE=24]="ONE_OF_RANGE",t[t.ONE_OF_LIST=25]="ONE_OF_LIST",t[t.BLANK=26]="BLANK",t[t.NOT_BLANK=27]="NOT_BLANK",t[t.CUSTOM_FORMULA=28]="CUSTOM_FORMULA",t[t.BOOLEAN=29]="BOOLEAN",t[t.TEXT_NOT_EQ=30]="TEXT_NOT_EQ",t[t.DATE_NOT_EQ=31]="DATE_NOT_EQ",t))(ye||{}),ts=(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))(ts||{}),es=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(es||{}),ss=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(ss||{}),ns=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(ns||{});function ar(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var rs=(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))(rs||{}),is=(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))(is||{}),It=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t))(It||{}),os=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(os||{}),as=(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))(as||{}),ls=(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))(ls||{}),us=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(us||{}),lt=(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))(lt||{}),cs=(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))(cs||{}),Q=(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))(Q||{}),y=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(y||{}),tt=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(tt||{}),At=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(At||{}),Ct=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(Ct||{}),Nt=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(Nt||{}),I=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(I||{}),ut=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(ut||{}),P=(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))(P||{}),St=(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))(St||{});const hs={[St.OFFICE]:{[P.ACCENT1]:"#4472C4",[P.ACCENT2]:"#ED7D31",[P.ACCENT3]:"#A5A5A5",[P.ACCENT4]:"#70AD47",[P.ACCENT5]:"#5B9BD5",[P.ACCENT6]:"#70AD47",[P.DARK1]:"#000000",[P.DARK2]:"#44546A",[P.LIGHT1]:"#FFFFFF",[P.LIGHT2]:"#E7E6E6",[P.HYPERLINK]:"#0563C1",[P.FOLLOWED_HYPERLINK]:"#954F72"}};class Lt{constructor(){_(this,"_themeValue",P.LIGHT1);_(this,"_themeColors");_(this,"_themeTint");_(this,"_rgbValue","");_(this,"_colorType");this._colorType=F.UNSUPPORTED,this._themeColors=St.OFFICE,this._themeTint=0}asRgbColor(){return new vt(this._rgbValue,this)}asThemeColor(){return new bt(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case F.THEME:return this.asThemeColor();case F.RGB:return this.asRgbColor();case F.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(e){return this._colorType=F.RGB,this._rgbValue=e,this}setThemeColors(e){this._colorType=F.THEME,this._themeColors=e}setThemeTint(e){this._colorType=F.THEME,this._themeTint=e}setThemeColor(e){return this._colorType=F.THEME,this._themeValue=e,this}getColorType(){return this._colorType}}class J{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 s=+`0x${e[0]}${e[1]}`,n=+`0x${e[2]}${e[3]}`,r=+`0x${e[4]}${e[5]}`;return new Lt().setRgbColor(`rgb(${s},${n},${r})`).asRgbColor()}static hexToRgbString(e){const s=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(s,(i,o,a,l)=>o+o+a+a+l+l);const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=null;if(n){const i=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16),a=Number.parseInt(n[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new J(this._builder)}equals(e){return!1}}class _s{constructor(e){_(this,"_saturation",0);_(this,"_hue",0);_(this,"_lightness",0);_(this,"_alpha",0);const s=e.getRed()/255,n=e.getGreen()/255,r=e.getBlue()/255,i=e.getAlpha()/255,o=Math.min(s,Math.min(n,r)),a=Math.max(s,Math.max(n,r)),l=a-o;if(a===o){this._hue=0,this._saturation=0,this._lightness=a;return}this._lightness=(o+a)/2,this._lightness<.5?this._saturation=l/(a+o):this._saturation=l/(2-a-o),s===a&&(this._hue=(n-r)/l),n===a&&(this._hue=2+(r-s)/l),r===a&&(this._hue=4+(s-n)/l),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const e=new Lt;if(this._saturation===0)return e.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),e.asRgbColor();let s;this._lightness<.5?s=this._lightness*(1+this._saturation):s=this._lightness+this._saturation-this._lightness*this._saturation;const n=2*this._lightness-s,r=this._hue/360,i=r+1/3,o=this.setColor(s,n,i),a=this.setColor(s,n,r),l=r-1/3,h=this.setColor(s,n,l);return e.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(h*255)},${this._alpha*255})`),e.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(e,s,n){n<0&&(n+=1),n>1&&(n-=1);let r;return 6*n<1?r=s+(e-s)*6*n:2*n<1?r=e:3*n<2?r=s+(e-s)*(2/3-n)*6:r=s,r}setLightness(e){this._lightness=e}}const W=class W extends J{constructor(s,n){super(n);_(this,"_cssString");_(this,"_red");_(this,"_green");_(this,"_blue");_(this,"_alpha");let r=s.match(W.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],l=+r[4];this._cssString=s,this._red=i,this._green=o,this._blue=a,this._alpha=l;return}if(r=s.match(W.RGB_EXTRACT),r){const i=+r[1],o=+r[2],a=+r[3];this._cssString=s,this._red=i,this._green=o,this._blue=a,this._alpha=1;return}throw new Error("Invalid rgba or rgb color")}asHexString(){return J.rgbColorToHexValue(this)}getRed(){let s=this._red+W.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getGreen(){let s=this._green+W.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getBlue(){let s=this._blue+W.RGB_COLOR_AMT;return s>255?s=255:s<0&&(s=0),s}getAlpha(){return this._alpha}getColorType(){return F.RGB}clone(){return new W(this._cssString,this._builder)}asThemeColor(){throw new Error("rgb color not support to themeColor")}equals(s){return s instanceof W?s._red===this._red&&s._blue===this._blue&&s._green===this._green&&s._alpha===this._alpha:!1}getCssString(){return this._cssString}};_(W,"RGB_COLOR_AMT",0),_(W,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),_(W,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let vt=W;const z=class z extends J{constructor(s,n,r,i){super(i);_(this,"_themeColorType");_(this,"_themeTint");_(this,"_themeColors");this._themeColorType=s,this._themeTint=n,this._themeColors=r}lumValue(s,n){if(s==null)return n;let r;return s<0?r=n*(1+s):r=n*(1-s)+(255-255*(1-s)),r}asRgbColor(){const s=hs[this._themeColors];if(s==null)throw new Error("not find themeColors type");const n=s[this._themeColorType];if(n==null)throw new Error("not find themeColors value");let r;if(z._cacheThemeColor.has(this._themeColors)){if(r=z._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,z._cacheThemeColor.set(this._themeColors,r);const i=new _s(J.hexValueToRgbColor(n));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new z(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(s){return s instanceof z?s._themeColorType===this._themeColorType:!1}getColorType(){return F.THEME}getThemeColorType(){return this._themeColorType}};_(z,"_cacheThemeColor",new Map);let bt=z;const lr="rgb(",ur="rgba(",Yt={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 B{constructor(e){_(this,"_color");_(this,"_rgbColor");_(this,"_isValid",!1);if(e==null){this._setNullColor();return}if(e instanceof B){this._color={...e._color},this._rgbColor={...e._rgbColor};return}const s=ds(e);if(s==null){this._setNullColor();return}this._color=s;const n=fr(this._color);if(n==null){this._setNullColor();return}this._rgbColor=n,this._isValid=!0}static mix(e,s,n){var h,c;n=Math.min(1,Math.max(0,n));const r=new B(e).toRgb(),i=new B(s).toRgb(),o=(h=r.a)!=null?h:1,a=(c=i.a)!=null?c:1,l={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(a-o)*n+o};return new B(l)}static getContrastRatio(e,s){const n=new B(e).getLuminance(),r=new B(s).getLuminance();return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:e,g:s,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${e},${s},${n}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(e){const{r:s,g:n,b:r,a:i=1}=this.toRgb(),o=i<1,a=[wt(Math.round(s).toString(16)),wt(Math.round(n).toString(16)),wt(Math.round(r).toString(16)),wt(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 mr(this.toRgb())}toHsl(){return Rr(this.toRgb())}lighten(e=10){const s=this.toHsl();return s.l+=e,s.l=Math.min(Math.max(s.l,0),100),new B(s)}darken(e=10){const s=this.toHsl();return s.l-=e,s.l=Math.min(Math.max(s.l,0),100),new B(s)}setAlpha(e){return new B({...this._rgbColor,a:e})}getLuminance(){let{r:e,g:s,b:n}=this.toRgb();return e=pt(e),s=pt(s),n=pt(n),Number((.2126*e+.7152*s+.0722*n).toFixed(3))}getBrightness(){const{r:e,g:s,b:n}=this.toRgb();return(e*299+s*587+n*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 wt=t=>t.length===1?`0${t}`:t,pt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),ds=t=>{if(Ir(t)){if("r"in t){const n={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(n.a=t.a),n}if("l"in t){const n={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(n.a=t.a),n}const s={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(s.a=t.a),s}const e=t.trim();if(Yt[e]){const s=Yt[e],n={r:Math.round(s[0]),g:Math.round(s[1]),b:Math.round(s[2])};return n.a=s[3]||1,n}if(e.startsWith("#"))return cr(e);if(e.startsWith("rgb"))return hr(e);if(e.startsWith("hsl"))return _r(e);if(e.startsWith("hsv"))return dr(e)},cr=t=>{const e=t.substring(1),s=new RegExp(`.{1,${e.length>=6?2:1}}`,"g");let n=e.match(s);if(!n||n.length<3)throw new Error(`The color '${t}' is illegal hex color`);n[0].length===1&&(n=n.map(i=>i+i));const r={r:Number.parseInt(n[0],16),g:Number.parseInt(n[1],16),b:Number.parseInt(n[2],16)};return n.length>3&&(r.a=Number.parseInt(n[3],16)/255),r},hr=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal rgb color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const n={r:Number.parseInt(s[0],10),g:Number.parseInt(s[1],10),b:Number.parseInt(s[2],10)};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},_r=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsl color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const n={h:Number.parseInt(s[0],10),s:Number.parseFloat(s[1]),l:Number.parseFloat(s[2])};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},dr=t=>{const e=t.indexOf("(");if(e===-1)throw new Error(`The color '${t}' is illegal hsv color`);const s=t.substring(e+1,t.length-1).split(",");if(s.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const n={h:Number.parseInt(s[0],10),s:Number.parseFloat(s[1]),v:Number.parseFloat(s[2])};return s.length>3&&(n.a=Number.parseFloat(s[3])),n},fr=t=>{const e=ds(t);if(e!=null)return"r"in e?e:"l"in e?Er(e):gr(e)},zt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+(e-t)*6*s:s<1/2?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Er=t=>{let{h:e,s,l:n}=t;e/=360,s/=100,n/=100;let r=0,i=0,o=0;if(s===0)r=i=o=n;else{const l=n<.5?n*(1+s):n+s-n*s,h=2*n-l;r=zt(h,l,e+1/3),i=zt(h,l,e),o=zt(h,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},gr=t=>{let{h:e,s,v:n}=t;e=e/360*6,s/=100,n/=100;const r=Math.floor(e),i=e-r,o=n*(1-s),a=n*(1-i*s),l=n*(1-(1-i)*s),h=r%6,c=[n,a,o,o,l,n][h],d=[l,n,n,a,o,o][h],f=[o,o,l,n,n,a][h],E={r:c*255,g:d*255,b:f*255};return t.a!==void 0&&(E.a=t.a),E},Rr=t=>{let{r:e,g:s,b:n}=t;e/=255,s/=255,n/=255;const r=Math.max(e,s,n),i=Math.min(e,s,n),o=(r+i)/2;let a,l;if(r===i)a=l=0;else{const c=r-i;switch(l=o>.5?c/(2-r-i):c/(r+i),r){case e:a=(s-n)/c+(s<n?6:0);break;case s:a=(n-e)/c+2;break;default:a=(e-s)/c+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(l*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},mr=t=>{let{r:e,g:s,b:n}=t;e/=255,s/=255,n/=255;const r=Math.max(e,s,n),i=Math.min(e,s,n);let o;const a=r,l=r-i,h=r===0?0:l/r;if(r===i)o=0;else{switch(r){case e:o=(s-n)/l+(s<n?6:0);break;case s:o=(n-e)/l+2;break;default:o=(e-s)/l+4;break}o/=6}const c={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(a*100)};return t.a!==void 0&&(c.a=t.a),c},Or=t=>t==null,Ir=t=>!Or(t)&&typeof t=="object";var M=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(M||{});const Ar="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Cr=(t=21)=>{let e="",s=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ar[s[t]&63];return e};const Nr=/^-ms-/,Sr=/-([a-z])/g,K=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class R{static stringAt(e){let s="",n=e;for(;n>=K.length;)n/=K.length,n-=1,s+=K[n%K.length];const r=e%K.length;return s+=K[r],s}static indexAt(e){let s=0;for(let n=0;n<e.length-1;n+=1){const r=e.charCodeAt(n)-65,i=e.length-1-n;s+=K.length**i+K.length*r}return s+=e.charCodeAt(e.length-1)-65,s}static deleteBlank(e){return R.isString(e)?e.replace(/\s/g,""):e}static getSystemType(){const e=navigator.userAgent,s=navigator.platform==="Win32"||navigator.platform==="Windows",n=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(n)return"Mac";if(navigator.platform==="X11"&&!s&&!n)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(s){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,s=e.indexOf("Opera")>-1,n=e.indexOf("compatible")>-1&&e.indexOf("MSIE")>-1&&!s,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(n){new RegExp("MSIE (\\d+\\.\\d+);").test(e);const c=Number.parseFloat(RegExp.$1);return c===7?"IE7":c===8?"IE8":c===9?"IE9":c===10?"IE10":"0"}return o?"FF":s?"Opera":a?"Safari":l?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(e=21){return Cr(e)}static getClassName(e){return e.constructor.name}static deepMerge(e,...s){s.forEach(o=>o&&i(o));function n(o,a){o.forEach((l,h)=>{var c,d;if(R.isArray(l)){const f=(c=a[h])!=null?c:[];a[h]=f,n(l,f);return}if(R.isObject(l)){const f=(d=a[h])!=null?d:{};a[h]=f,r(l,f);return}a[h]=l})}function r(o,a){Object.keys(o).forEach(l=>{var c,d;const h=o[l];if(R.isObject(h)){const f=(c=a[l])!=null?c:{};a[l]=f,r(h,f);return}if(R.isArray(h)){const f=(d=a[l])!=null?d:[];a[l]=f,n(h,f);return}a[l]=h})}function i(o){Object.keys(o).forEach(a=>{var h,c;const l=o[a];if(R.isArray(l)){const d=(h=e[a])!=null?h:[];e[a]=d,n(l,d);return}if(R.isObject(l)){const d=(c=e[a])!=null?c:{};e[a]=d,r(l,d);return}e[a]=l})}return e}static numberFixed(e,s){return Number(Number(e).toFixed(s))}static diffValue(e,s){function n(o,a){const l=R.getValueType(o),h=R.getValueType(a);return l!==h?!1:R.isArray(o)?r(o,a):R.isObject(o)?i(o,a):R.isDate(o)?o.getTime()===a.getTime():R.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(e.length!==s.length)return!1;for(let l=0,h=o.length;l<h;l++){const c=o[l],d=a[l];if(!n(c,d))return!1}return!0}function i(o,a){const l=Object.keys(o),h=Object.keys(a);if(l.length!==h.length)return!1;for(const c of l){if(!h.includes(c))return!1;const d=o[c],f=a[c];if(!n(d,f))return!1}return!0}return n(e,s)}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 s=[];return e.forEach((n,r)=>{s[r]=R.deepClone(n)}),s}if(this.isObject(e)){const s={};return Object.keys(e).forEach(n=>{const r=e[n];s[n]=R.deepClone(r)}),Object.setPrototypeOf(s,Object.getPrototypeOf(e)),s}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,s){return e instanceof s}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 s in e)return!1;return!0}static isMobile(){let e=0,s=0;return document.body.clientWidth&&(e=document.body.clientWidth),document.body.clientHeight&&(s=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||e<350&&s<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 s=>{for(let n=0;n<e;n++)s&&s()}}static hasLength(e,s){return R.isDefine(e)?R.isDefine(s)?e.length===s:e.length>0:!1}static capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)}static fCamelCase(e,s){return s.toUpperCase()}static camelCase(e){return e.replace(Nr,"ms-").replace(Sr,this.fCamelCase)}static removeNull(e){return this.isObject(e)&&Object.keys(e).forEach(s=>{const n=e[s];n==null?delete e[s]:R.removeNull(n)}),e}static fillTwoDimensionalArray(e,s,n){return new Array(e).fill(n).map(r=>new Array(s).fill(n))}static numToWord(e){let s="";for(;e>0;){let n=e%26;n=n===0?n=26:n,s=String.fromCharCode(96+n)+s,e=(e-n)/26}return s.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return Number.NaN;const s=e.toLowerCase().split(""),n=s.length;let r=0,i=0;for(let o=0;o<n;o++)i=s[o].charCodeAt(0)-96,r+=i*26**(n-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 s=0,n=e.length;s<n;s++){const r=Number.parseInt((Math.random()*n).toString()),i=e[r];e[r]=e[s],e[s]=i}return e}static commonExtend(e,s){const n={};for(const r in e)n[r]=e[r];for(const r in s)s[r]!=null&&(n[r]=s[r]);return n}static commonExtend1(e,s){for(const n in e)s[n]==null&&(s[n]=e[n]);return s}static arrayToObject(e){const s={};return e.forEach((n,r)=>{s[r]={},n.forEach((i,o)=>{s[r][o]=i})}),s}static hasIntersectionBetweenTwoRanges(e,s,n,r){return s>=n&&r>=e}}function Lr(t){if(!t)return;const{actualRow:e,actualColumn:s,isMerged:n,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:l,endX:h}=t,c=e,d=s,f=e,E=s;if(n&&i){const{startRow:g,startColumn:O,endRow:b,endColumn:w,startY:V,endY:x,startX:Et,endX:Oo}=i;c=g,d=O,f=b,E=w,o=V,a=x,l=Et,h=Oo}return r&&(o=i.startY,a=i.endY,l=i.startX,h=i.endX,f=i.endRow,E=i.endColumn),{startRow:c,startColumn:d,endRow:f,endColumn:E,startY:o,endY:a,startX:l,endX:h}}function vr(t){if(!t)return;const{actualRow:e,actualColumn:s,isMerged:n,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:l}=t;let h=e,c=s,d=e,f=s;return(n||r)&&(h=i,c=o,d=a,f=l),{startRow:h,startColumn:c,endRow:d,endColumn:f}}function br(t){var s;return!t||(((s=t==null?void 0:t.v)==null?void 0:s.toString())||"").length===0&&!t.p}function G(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new Lt().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function wr(t){return R.isString(t)&&t.substring(0,1)==="="&&t.length>1}function Dr(t){return R.isString(t)&&t.indexOf("=")===-1&&t.length===6}function Tr(t){return""}function Ur(t,e=!1){var i;let s="";const n=new Map([["ff",()=>{t.ff&&(s+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),s+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(s+="font-style: italic; ")}],["bl",()=>{t.bl&&(s+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," underline"):s+="text-decoration-line: underline; ",t.ul.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${G(t.ul.cl)}; `),t.ul.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.ul.t} `))}],["st",()=>{var o;(o=t.st)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," line-through"):s+="text-decoration-line: line-through; ",t.st.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${G(t.st.cl)}; `),t.st.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.st.t} `))}],["ol",()=>{var o;(o=t.ol)!=null&&o.s&&(s.indexOf("text-decoration-line")>-1?s=s.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," overline"):s+="text-decoration-line: overline; ",t.ol.cl&&s.indexOf("text-decoration-color")===-1&&(s+=`text-decoration-color: ${G(t.ol.cl)}; `),t.ol.t&&s.indexOf("text-decoration-style")===-1&&(s+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(s+=`background: ${G(t.bg)}; `)}],["bd",()=>{var o,a,l,h,c,d,f,E,g,O,b,w;(o=t.bd)!=null&&o.b&&(s+=`border-bottom: ${Dt((a=t.bd)==null?void 0:a.b.s)} ${(l=G(t.bd.b.cl))!=null?l:""}; `),(h=t.bd)!=null&&h.t&&(s+=`border-top: ${Dt((c=t.bd)==null?void 0:c.t.s)} ${(d=G(t.bd.t.cl))!=null?d:""}; `),(f=t.bd)!=null&&f.r&&(s+=`border-right: ${Dt((E=t.bd)==null?void 0:E.r.s)} ${(g=G(t.bd.r.cl))!=null?g:""}; `),(O=t.bd)!=null&&O.l&&(s+=`border-left: ${Dt((b=t.bd)==null?void 0:b.l.s)} ${(w=G(t.bd.l.cl))!=null?w:""}; `)}],["cl",()=>{t.cl&&(s+=`color: ${G(t.cl)}; `)}],["va",()=>{t.va===Nt.SUBSCRIPT?s+="vertical-align: sub; ":t.va===Nt.SUPERSCRIPT&&(s+="vertical-align: super; ")}],["td",()=>{t.td===lt.LEFT_TO_RIGHT?s+="direction: ltr; ":t.td===lt.RIGHT_TO_LEFT&&(s+="direction: rtl; ")}],["tr",()=>{var o,a,l;t.tr&&(s+=`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===Q.LEFT?s+="text-align: left; ":t.ht===Q.RIGHT?s+="text-align: right; ":t.ht===Q.CENTER?s+="text-align: center; ":t.ht===Q.JUSTIFIED&&(s+="text-align: justify; ")}],["vt",()=>{t.vt===y.BOTTOM?s+="vertical-align: bottom; ":t.vt===y.TOP?s+="vertical-align: top; ":t.vt===y.MIDDLE&&(s+="vertical-align: middle; ")}],["tb",()=>{t.tb===tt.CLIP?s+="text-overflow: clip; ":t.tb===tt.OVERFLOW?s+="text-break: overflow; ":t.tb===tt.WRAP&&(s+="word-wrap: break-word;")}],["pd",()=>{var c,d,f,E,g,O,b,w;const o=`${(c=t.pd)==null?void 0:c.b}pt`,a=`${(d=t.pd)==null?void 0:d.t}pt`,l=`${(f=t.pd)==null?void 0:f.l}pt`,h=`${(E=t.pd)==null?void 0:E.r}pt`;(g=t.pd)!=null&&g.b&&(s+=`padding-bottom: ${o}; `),(O=t.pd)!=null&&O.t&&(s+=`padding-top: ${a}; `),(b=t.pd)!=null&&b.l&&(s+=`padding-left: ${l}; `),(w=t.pd)!=null&&w.r&&(s+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)e&&r.includes(o)||(i=n.get(o))==null||i();return s}function Dt(t){let e="";return t===S.NONE?e="none":t===S.THIN?e="0.5pt solid":t===S.HAIR?e="0.5pt double":t===S.DOTTED?e="0.5pt dotted":t===S.DASHED||t===S.DASH_DOT?e="0.5pt dashed":t===S.DASH_DOT_DOT?e="0.5pt dotted":t===S.DOUBLE?e="0.5pt double":t===S.MEDIUM?e="1pt solid":t===S.MEDIUM_DASHED||t===S.MEDIUM_DASH_DOT?e="1pt dashed":t===S.MEDIUM_DASH_DOT_DOT?e="1pt dotted":t===S.SLANT_DASH_DOT?e="0.5pt dashed":t===S.THICK&&(e="1.5pt solid"),e}function Mr(t){let e=0;if(t=t.trim(),t==="none")e=S.NONE;else if(t==="0.5pt solid")e=S.THIN;else if(t==="0.5pt double")e=S.HAIR;else if(t==="0.5pt dotted")e=S.DOTTED;else if(t==="0.5pt dashed")e=S.DASHED;else if(t==="1pt solid")e=S.MEDIUM;else if(t==="1pt dashed")e=S.MEDIUM_DASHED;else if(t==="1pt dotted")e=S.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")e=S.THICK;else return S.NONE;return e}function Tt(t,e){let s=t.body;if(e){const{headers:n,footers:r}=t;n!=null&&n[e]?s=n[e].body:r!=null&&r[e]&&(s=r[e].body)}return s}function Pr(t){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=t;return!(e<0||n<0||s<0||r<0)}function Xt(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(s=>Xt(t[s],e[s])):t===e:!1}function fs(t,e){const s=t.ts||{},n=e.ts||{};return t.sId!==e.sId?!1:Xt(s,n)}function qt(t,e,s,n){if(t>e&&([t,e]=[e,t]),s>n&&([s,n]=[n,s]),e<s||n<t)return[t,e];s<t&&(s=t),n>e&&(n=e);const r=n-s+1;let i=[];return t===s?i=[n+1-r,e-r]:e===n?i=[t,s-1]:i=[t,e-r],i}function Hr(t){if(t==null)return!1;const e=t.bullet;return(e==null?void 0:e.listId)!=null}function Fr(t){if(t==null)return!1;const e=t.paragraphStyle;return Es(e)}function Es(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function gs(t,e,s){return t.slice(0,e)+s+t.slice(e)}function Rs(t,e,s){return e>s?t:t.slice(0,e)+t.slice(s)}function Wr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Br(t){let e=0;for(let s=0;s<t.length;s++)e=t.charCodeAt(s)+(e<<6)+(e<<16)-e;return e>>>0}class ct{static hasLength(e,s){return e.length===s}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]"}}const N=Symbol("newer"),T=Symbol("older");class ms{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[N],{done:!1,value:e.key}):{done:!0,value:void 0}}}class Os{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[N],{done:!1,value:e.value}):{done:!0,value:void 0}}}class Is{constructor(e){_(this,"entry");this.entry=e}[Symbol.iterator](){return this}next(){const e=this.entry;return e?(this.entry=e[N],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}}class Qt{constructor(e,s){_(this,"key");_(this,"value");_(this,Ro);_(this,mo);this.key=e,this.value=s,this[N]=void 0,this[T]=void 0}toJSON(){return{key:this.key,value:this.value}}}Ro=N,mo=T;class As{constructor(...e){_(this,"_keymap");_(this,"size",0);_(this,"limit");_(this,"oldest");_(this,"newest");_(this,"_onShiftListeners",[]);if(ct.hasLength(e,1)){if(ct.isNumber(e[0])){const s=e[0];this._initialize(s,void 0);return}if(ct.isIterable(e[0])){const s=e[0];this._initialize(0,s);return}return}if(ct.hasLength(e,2)){const s=e[0],n=e[1];this._initialize(s,n)}}onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),L(()=>j(this._onShiftListeners,e));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(e,s){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=new Map,s&&(this.assign(s),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[N]&&(e===this.oldest&&(this.oldest=e[N]),e[N][T]=e[T]),e[T]&&(e[T][N]=e[N]),e[N]=void 0,e[T]=this.newest,this.newest&&(this.newest[N]=e),this.newest=e)}assign(e){let s,n=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 Qt(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),s?(s[N]=o,o[T]=s):this.oldest=o,s=o,n--===0)throw new Error("overflow")}this.newest=s,this.size=this._keymap.size}set(e,s){let n=this._keymap.get(e);return n?(n.value=s,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new Qt(e,s)),this.newest?(this.newest[N]=n,n[T]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const e=this.oldest;if(e)return this.oldest&&this.oldest[N]?(this.oldest=this.oldest[N],this.oldest[T]=void 0):(this.oldest=void 0,this.newest=void 0),e[N]=e[T]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(s=>s(e)),[e.key,e.value]}get(e){const s=this._keymap.get(e);if(s)return this._markEntryAsUsed(s),s.value}has(e){return this._keymap.has(e)}find(e){const s=this._keymap.get(e);return s?s.value:void 0}delete(e){const s=this._keymap.get(e);if(s)return this._keymap.delete(s.key),s[N]&&s[T]?(s[T][N]=s[N],s[N][T]=s[T]):s[N]?(s[N][T]=void 0,this.oldest=s[N]):s[T]?(s[T][N]=void 0,this.newest=s[T]):this.oldest=this.newest=void 0,this.size--,s.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new ms(this.oldest)}values(){return new Os(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Is(this.oldest)}forEach(e,s){typeof s!="object"&&(s=this);let n=this.oldest;for(;n;)e.call(s,n.value,n.key,this),n=n[N]}toJSON(){const e=new Array(this.size);let s=0,n=this.oldest;for(;n;)e[s++]={key:n.key,value:n.value},n=n[N];return e}toString(){let e="",s=this.oldest;for(;s;)e+=`${String(s.key)}:${s.value}`,s=s[N],s&&(e+=" < ");return e}}function k(t){let e=0;const s=Object.keys(t);for(const n of s){const r=Number(n);e=Math.max(e,r)}return e+1}function Jt(t,e,s){const n=k(s),r=s;for(let i=n-1;i>=t;i--)r[i+1]=r[i];r[t]=e}function Zt(t,e,s,n){const r=t+e,i=k(s),o=s;let a=0;const l={};for(let f=t;f<r;f++){const E=o[f];E!==void 0&&(delete o[f],l[a]=E,a++)}const h=n?k(n):0,c=t-r+h,d=i;if(c>0)for(let f=d-1;f>=r;f--)o[f]!==void 0&&(o[f+c]=o[f],delete o[f]);else if(c<0)for(let f=r;f<d;f++)o[f]!==void 0&&(o[f+c]=o[f],delete o[f]);if(n)for(let f=0;f<h;f++)o[t+f]=n[f];return l}function Gr(t,e){const s=t,n=Object.keys(s),r=n.length,i=e,o=Object.keys(i),a=o.length,l={};let h=0;for(let c=0;c<r;c++,h++){const d=n[c];l[h]=s[d]}for(let c=0;c<a;c++,h++){const d=o[c];l[h]=i[d]}return l}function kr(t,e,s){const n=s;if(k(s)>0){const i={};let o=0;for(let a=t;a<=e;a++)n[a]&&(i[o]=n[a],o++);return i}return{}}function yt(t,e,s,n){const r=t>s;if(!r&&t+e>s)throw new Error("Invalid move operation");r?$r(t,e,s,n):Vr(t,e,s,n)}function $r(t,e,s,n){const r=n,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t-1;o>=s;o--){const a=r[o];r[o+e]=a,a==null&&delete r[o+e]}i.forEach((o,a)=>{r[s+a]=o,o==null&&delete r[s+a]})}function Vr(t,e,s,n){const r=n,i=[];for(let o=t;o<t+e;o++)i.push(r[o]);for(let o=t+e;o<s;o++){const a=r[o];r[o-e]=a,a==null&&delete r[o-e]}i.forEach((o,a)=>{r[s+a-e]=o,o==null&&delete r[s+a-e]})}class ${constructor(e={}){_(this,"_matrix");this._setOriginValue(e)}static MakeObjectMatrixSize(e){return new $({[e-1]:{}})}getMatrix(){return this._matrix}forEach(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(e(i,o)===!1)return this}return this}forRow(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(e(i,Object.keys(o).map(l=>Number(l)))===!1)return this}return this}forValue(e){const s=this._matrix,n=Object.keys(s);for(const r of n){const i=Number(r),o=s[i];if(!o)continue;const a=Object.keys(o);for(const l of a){const h=Number(l),c=o[Number(l)];if(e(i,h,c)===!1)return this}}return this}swapRow(e,s){const n=this._matrix[e],r=this._matrix[s];this._matrix[e]=r,this._matrix[s]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let s=this.getRow(e);return s==null&&(s={},this._matrix[e]=s),s}reset(){this._setOriginValue({})}hasValue(){const e=this._matrix,s=Object.keys(e);if(s.length===0)return!1;for(const n of s){const r=Number(n),i=e[r];if(Object.keys(i).length>0)return!0}return!1}getValue(e,s){var n,r;return(r=(n=this._matrix)==null?void 0:n[e])==null?void 0:r[s]}setValue(e,s,n){const r=this.getRowOrCreate(e);r[s]=n}deleteValue(e,s){var n,r;(r=(n=this._matrix)==null?void 0:n[e])==null||delete r[s]}realDeleteValue(e,s){var n,r,i;if((r=(n=this._matrix)==null?void 0:n[e])==null||delete r[s],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,s){this._matrix[e]=s}moveRows(e,s,n){yt(e,s,n,this._matrix)}moveColumns(e,s,n){this.forEach((r,i)=>{yt(e,s,n,i)})}insertRows(e,s){for(let n=e;n<e+s;n++)Jt(n,{},this._matrix)}insertColumns(e,s){for(let n=e;n<e+s;n++)this.forEach((r,i)=>{Jt(n,void 0,i)})}removeRows(e,s){Zt(e,s,this._matrix)}removeColumns(e,s){this.forEach((n,r)=>{Zt(e,s,r)})}getFragment(e,s,n,r){const i=new $;let o=0;for(let a=e;a<=s;a++){const l={};let h=0;for(let c=n;c<=r;c++){const d=this.getValue(a,c);l[h]=d,h++}i.setRow(o,l),o++}return i}getSlice(e,s,n,r){const i=new $;for(let o=e;o<=s;o++)for(let a=n;a<=r;a++){const l=this.getValue(o,a);l&&i.setValue(o,a,R.deepClone(l))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return k(this._matrix)}getRange(){const n=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const l=k(a)-1;r=l>r?l:r}}return{startRow:0,startColumn:0,endRow:n,endColumn:r}}toNativeArray(){const e=new Array;return this.forValue((s,n,r)=>{e.push(r)}),e}toArray(){const e=[];return this.forRow((s,n)=>{e[s]==null&&(e[s]=[]),n.forEach(r=>{e[s][r]=this.getValue(s,r)})}),e}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,s=0,n=!1,r=!1;const i=new $;return this.forEach((o,a)=>{n||(n=!0,e=o),Object.keys(a).forEach(l=>{const h=Number(l);r?h<s&&(s=h):(r=!0,s=h);const c=this.getValue(o,h);i.setValue(o-e,h-s,c)})}),i.getData()}getDataRange(){let e=0,s=0,n=0,r=-1,i=!1,o=!1;return this.forEach((a,l)=>{i||(i=!0,e=a);const h=k(l)-1;h>n&&(n=h),Object.keys(l).forEach(c=>{const d=Number(c);o?d<s&&(s=d):(o=!0,s=d)}),a>r&&(r=a)}),{startRow:e,startColumn:s,endRow:r,endColumn:n}}getDiscreteRanges(){const e=[];return this.forEach((s,n)=>{Object.keys(n).forEach(r=>{const i=Number(r);let o=!1;for(const a of e)if(s>=a.startRow&&s<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(s,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||e.push({startRow:s,endRow:s,startColumn:i,endColumn:i})})}),e}merge(e){this.forValue((s,n)=>{const r=e.getValue(s,n);r!=null&&this.setValue(s,n,r)})}_setOriginValue(e={}){this._matrix=e}}var te=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(te||{});class Cs{constructor(){_(this,"status","init")}}const xr=t=>t.some(e=>e.status==="init")?"init":t.some(e=>e.status==="fetching")?"fetching":"done";var H=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(H||{}),Ns=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(Ns||{});function jr(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}const X=class X{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,s){return e==null||s==null?!1:e.endRow===s.endRow&&e.endColumn===s.endColumn&&e.startRow===s.startRow&&e.startColumn===s.startColumn&&(e.rangeType===s.rangeType||e.rangeType===void 0&&s.rangeType===H.NORMAL||s.rangeType===void 0&&e.rangeType===H.NORMAL)}static intersects(e,s){const n=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=s.startRow,l=s.endRow,h=s.startColumn,c=s.endColumn,d=Math.abs(i+o-h-c),f=Math.abs(i-o)+Math.abs(h-c),E=Math.abs(n+r-a-l),g=Math.abs(n-r)+Math.abs(a-l);return d<=f&&E<=g}static getIntersects(e,s){const n=e.startRow,r=e.endRow,i=e.startColumn,o=e.endColumn,a=s.startRow,l=s.endRow,h=s.startColumn,c=s.endColumn;let d,f,E,g;if(a<=r)a>=n?f=a:f=n;else return null;if(l>=n)l>=r?g=r:g=l;else return null;if(h<=o)h>i?d=h:d=i;else return null;if(c>=i)c>=o?E=o:E=c;else return null;return{startRow:f,endRow:g,startColumn:d,endColumn:E,rangeType:H.NORMAL}}static contains(e,s){return e.startRow<=s.startRow&&e.endRow>=s.endRow&&e.startColumn<=s.startColumn&&e.endColumn>=s.endColumn}static realContain(e,s){return X.contains(e,s)&&(e.startRow<s.startRow||e.endRow>s.endRow||e.startColumn<s.startColumn||e.endColumn>s.endColumn)}static union(...e){return e.reduce((s,n)=>({startRow:Math.min(s.startRow,n.startRow),startColumn:Math.min(s.startColumn,n.startColumn),endRow:Math.max(s.endRow,n.endRow),endColumn:Math.max(s.endColumn,n.endColumn),rangeType:H.NORMAL}),e[0])}static subtract(e,s){if(s.startRow>=e.endRow||s.endRow<=e.startRow||s.startColumn>=e.endColumn||s.endColumn<=e.startColumn)return[e];const n=[];s.startRow>e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:s.startRow,endColumn:e.endColumn}),s.endRow<e.endRow&&n.push({startRow:s.endRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});const r=Math.max(e.startRow,s.startRow),i=Math.min(e.endRow,s.endRow);return s.startColumn>e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:s.startColumn}),s.endColumn<e.endColumn&&n.push({startRow:r,startColumn:s.endColumn,endRow:i,endColumn:e.endColumn}),n}};_(X,"getRelativeRange",(e,s)=>({startRow:e.startRow-s.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-s.startColumn,endColumn:e.endColumn-e.startColumn})),_(X,"getPositionRange",(e,s)=>({startRow:e.startRow+s.startRow,endRow:e.endRow+e.startRow+s.startRow,startColumn:e.startColumn+s.startColumn,endColumn:e.endColumn+e.startColumn+s.startColumn})),_(X,"moveHorizontal",(e,s=0,n=0)=>({...e,startColumn:e.startColumn+s,endColumn:e.endColumn+s+n})),_(X,"moveVertical",(e,s=0,n=0)=>({...e,startRow:e.startRow+s,endRow:e.endRow+s+n})),_(X,"moveOffset",(e,s,n)=>({...e,startRow:e.startRow+n,endRow:e.endRow+n,startColumn:e.startColumn+s,endColumn:e.endColumn+s}));let et=X;class Kr{constructor(e,s){_(this,"_values",[]);_(this,"_keys",[]);_(this,"_keyMaps",new Map);this._values=e,this._keys=s,e.forEach(n=>{this._initKeyMap(n)})}_initKeyMap(e){this._keys.forEach(s=>{const n=e[s],r=this._keyMaps.get(s)||new Map;r.set(n,e),this._keyMaps.set(s,r)})}getValue(e){for(let s=0;s<this._keys.length;s++){const n=this._keyMaps.get(this._keys[s]);if(n!=null&&n.has(e))return n.get(e)}return null}hasValue(e){for(let s=0;s<this._keys.length;s++){const n=this._keyMaps.get(this._keys[s]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,s,n){const r=this.getValue(e);r&&Object.keys(r).includes(s)&&(r[s]=n)}deleteValue(e){const s=this.getValue(e);if(s){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=s[r];i==null||i.delete(o)});const n=this._values.findIndex(r=>r===s);this._values.splice(n,1)}}getValues(){return this._values}getKeyMap(e){var s;return[...((s=this._keyMaps.get(e))==null?void 0:s.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function ee(t,e,s,n){return{forEach(r){for(let i=t;i<=e;i++)for(let o=s;o<=n;o++)r(i,o)}}}function Yr(t){if(t==null||t.length===0)return Number.NaN;const e=t.toLowerCase().split(""),s=e.length,n=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<s;o++)i=n(e[o]),r+=i*26**(s-o-1);return r===0?Number.NaN:r-1}const Ut=65,Ss=90,pr=97;function zr(t){const e=Ss-Ut+1;let s="";for(;t>=0;)s=String.fromCharCode(t%e+Ut)+s,t=Math.floor(t/e)-1;return s}function Ls(t,e){let s="";for(;e>0;)s+=t,e--;return s}function Xr(t,e=!1){const s=Ss-Ut+1;let n=pr;e&&(n=Ut);const r=String.fromCharCode(t%s+n),i=Math.floor(t/s)+1;return Ls(r,i)}function qr(t,e){return t.zIndex>e.zIndex?1:t.zIndex===e.zIndex?0:-1}function Qr(t,e){return t.zIndex>e.zIndex?-1:t.zIndex===e.zIndex?0:1}function st(t="index",e=1){return(s,n)=>s[t]>n[t]?e:s[t]===n[t]?0:-e}var vs=(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))(vs||{}),se=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
4
- `,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))(se||{});function ne(t){const e=[];for(const s of t){const{st:n,ed:r,ts:i}=s;if(s.sId===void 0&&delete s.sId,n===r||R.isEmptyObject(i)&&s.sId==null)continue;if(e.length===0){e.push(s);continue}const o=e.pop();fs(s,o)&&R.hasIntersectionBetweenTwoRanges(o.st,o.ed,s.st,s.ed)?e.push({...s,st:o.st,ed:r}):e.push(o,s)}return e}function bs(t,e,s,n){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const l=(h=e.textRuns)!=null?h:[];if(l.length)for(let c=0,d=l.length;c<d;c++){const f=l[c];f.st+=n,f.ed+=n}for(let c=0;c<o;c++){const d=r[c],{st:f,ed:E}=d;if(E<n)i.push(d);else if(n>=f&&n<=E)if(a)d.st+=s,d.ed+=s,i.push(d);else{a=!0,d.ed+=s;const g=[];if(l.length){const O={...d,st:f,ed:l[0].st};g.push(O),g.push(...l);const b=l[l.length-1],w={...d,st:b.ed,ed:E+s};g.push(w)}else g.push(d);i.push(...g)}else d.st+=s,d.ed+=s,a||(a=!0,i.push(...l)),i.push(d)}a||(a=!0,i.push(...l)),t.textRuns=ne(i)}function re(t,e,s,n){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=e,a=[];let l=-1;for(let c=0,d=r.length;c<d;c++){const f=r[c],{startIndex:E}=f;E>=n&&(f.startIndex+=s),l===-1&&E>=n&&(l=c),a.push(f.startIndex)}let h=-1;if(i){for(let c=0,d=i.length;c<d;c++){const f=i[c];f.startIndex+=n;const E=f.startIndex;h=a.indexOf(E)}if(o===se.PARAGRAPH&&i.length===1){const c=r[l],d=i[0],f=c.paragraphStyle,E=c.bullet;c.paragraphStyle=d.paragraphStyle,c.bullet=d.bullet,d.paragraphStyle=f,d.bullet=E}h!==-1&&r.splice(h,1),r.push(...i),r.sort(st("startIndex"))}}function Jr(t,e,s,n){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=n&&(l.startIndex+=s)}const i=e.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(st("startIndex"))}}function ws(t,e,s,n){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h}=l;h>=n&&(l.startIndex+=s)}const i=e.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n}r.push(...i),r.sort(st("startIndex"))}}function ie(t,e,s,n){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h,endIndex:c}=l;h>n?(l.startIndex+=s,l.endIndex+=s):c>=n-1&&(l.endIndex+=s)}const i=e.tables;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(st("startIndex"))}}function Zr(t,e,s,n){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const l=r[o],{startIndex:h,endIndex:c}=l;h>n?(l.startIndex+=s,l.endIndex+=s):c>=n-1&&(l.endIndex+=s)}const i=e.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const l=i[o];l.startIndex+=n,l.endIndex+=n}r.push(...i),r.sort(st("startIndex"))}}function Ds(t,e,s){const{textRuns:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{st:d,ed:f}=c;if(r<=d&&i>=f){o.push({...c,st:d-r,ed:f-r});continue}else d<=r&&f>=i?(o.push({...c,st:r-r,ed:i-r}),c.ed-=e):r>=d&&r<f?(o.push({...c,st:r-r,ed:f-r}),c.ed=r):i>d&&i<=f?(o.push({...c,st:d-r,ed:i-r}),c.st=i-e,c.ed-=e):d>=i&&(c.st-=e,c.ed-=e);a.push(c)}t.textRuns=a}return o}function Ts(t,e,s){const{paragraphs:n}=t,r=s,i=s+e,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{startIndex:d}=c;if(d>=r&&d<i){o.push({...c,startIndex:d-s});continue}else d>=i&&(c.startIndex-=e);a.push(c)}t.paragraphs=a}return o}function Us(t,e,s){const{sectionBreaks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{startIndex:d}=c;if(d>=r&&d<=i){o.push({...c,startIndex:d-s});continue}else d>i&&(c.startIndex-=e);a.push(c)}t.sectionBreaks=a}return o}function Ms(t,e,s){const{customBlocks:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{startIndex:d}=c;if(d>=r&&d<=i){o.push({...c,startIndex:d-s});continue}else d>i&&(c.startIndex-=e);a.push(c)}t.customBlocks=a}return o}function Ps(t,e,s){const{tables:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{startIndex:d,endIndex:f}=c;if(r<=d&&i>=f){o.push({...c,startIndex:d-s,endIndex:f-s});continue}else if(d<=r&&f>=i){const E=qt(d,f,r,i);c.startIndex=E[0],c.endIndex=E[1]}else i<d&&(c.startIndex-=e,c.endIndex-=e);a.push(c)}t.tables=a}return o}function Hs(t,e,s){const{customRanges:n}=t,r=s,i=s+e-1,o=[];if(n){const a=[];for(let l=0,h=n.length;l<h;l++){const c=n[l],{startIndex:d,endIndex:f}=c;if(r<=d&&i>=f){o.push({...c,startIndex:d-s,endIndex:f-s});continue}else if(d<=r&&f>=i){const E=qt(d,f,r,i);c.startIndex=E[0],c.endIndex=E[1]}else i<d&&(c.startIndex-=e,c.endIndex-=e);a.push(c)}t.customRanges=a}return o}function yr(t,e,s){const{dataStream:n}=t,r=s,i=s+e,o=Ds(t,e,s),a=Ts(t,e,s),l=Us(t,e,s),h=Ms(t,e,s),c=Ps(t,e,s),d=Hs(t,e,s);let f="";return n&&(t.dataStream=Rs(n,r,i),f=n.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:l,customBlocks:h,tables:c,customRanges:d}}function ti(t,e,s,n){t.dataStream=gs(t.dataStream,n,e.dataStream),bs(t,e,s,n),re(t,e,s,n),Jr(t,e,s,n),ws(t,e,s,n),ie(t,e,s,n),Zr(t,e,s,n)}var Fs=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Fs||{}),Ws=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))(Ws||{}),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||{}),Y=(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))(Y||{}),Bs=(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))(Bs||{}),Gs=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(Gs||{}),ks=(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))(ks||{}),$s=(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))($s||{}),Vs=(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))(Vs||{}),xs=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(xs||{}),js=(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))(js||{}),Ks=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(Ks||{}),Ys=(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))(Ys||{}),ps=(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))(ps||{}),zs=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(zs||{}),Xs=(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))(Xs||{}),qs=(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))(qs||{}),Qs=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(Qs||{}),Js=(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))(Js||{}),Zs=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(Zs||{}),ys=(t=>(t[t.CHARACTER=0]="CHARACTER",t[t.COLUMN=1]="COLUMN",t[t.INSIDE_MARGIN=2]="INSIDE_MARGIN",t[t.LEFT_MARGIN=3]="LEFT_MARGIN",t[t.MARGIN=4]="MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.PAGE=6]="PAGE",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(ys||{}),tn=(t=>(t[t.BOTTOM_MARGIN=0]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=1]="INSIDE_MARGIN",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.OUTSIDE_MARGIN=4]="OUTSIDE_MARGIN",t[t.PAGE=5]="PAGE",t[t.PARAGRAPH=6]="PARAGRAPH",t[t.TOP_MARGIN=7]="TOP_MARGIN",t))(tn||{}),en=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(en||{}),sn=(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))(sn||{}),nn=(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))(nn||{}),rn=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(rn||{}),on=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(on||{}),Mt=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Mt||{});const ei={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:Y.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:Y.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:Y.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:Y.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:Y.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:Y.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:ht.DECIMAL,hanging:21,indentStart:63}]}};function si(t,e,s,n,r){const i=ni(t,e,s,n,r),o=ri(t,e,s,n,r),a=ii(t,e,s,n,r),l=oi(t,e,s,n,r),h=ai(t,e,s,n,r),c=li(t,e,s,n,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:l,tables:h,customRanges:c}}function ni(t,e,s,n,r){const{textRuns:i}=t,{textRuns:o}=e;if(i==null||o==null)return;const a=Ds(t,s,n);if(r!==M.REPLACE){const l=an(o,a,r);e.textRuns=l}return bs(t,e,s,n),a}function an(t,e,s){if(e.length===0)return t;t=R.deepClone(t),e=R.deepClone(e);const n=[],r=t.length,i=e.length;let o=0,a=0,l=null;function h(){return l?(n.push(l),l=null,!0):!1}for(;o<r&&a<i;){const{st:E,ed:g,ts:O}=t[o],{st:b,ed:w,ts:V,sId:x}=e[a];let Et;s===M.COVER?Et={...V,...O}:Et={...O,...V},g<b?(h()||n.push(t[o]),o++):w<E?(h()||n.push(e[a]),a++):(n.push({st:Math.min(E,b),ed:Math.max(E,b),ts:E<b?{...O}:{...V},sId:E<b?void 0:x}),n.push({st:Math.max(E,b),ed:Math.min(g,w),ts:Et,sId:x}),g<w?(o++,e[a].st=g):(a++,t[o].st=w),l={st:Math.min(g,w),ed:Math.max(g,w),ts:g<w?{...V}:{...O},sId:g<w?x:void 0})}h();const c=n[n.length-1],d=t[r-1],f=e[i-1];return c.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?n.push(d):n.push(f)),ne(n)}function ri(t,e,s,n,r){const{paragraphs:i}=t,{paragraphs:o}=e;if(i==null||o==null)return;const a=Ts(t,s,n);if(r!==M.REPLACE){const l=[];for(const h of o){const{startIndex:c,paragraphStyle:d,bullet:f}=h;let E=[];for(const g of a){const{startIndex:O,paragraphStyle:b,bullet:w}=g;let V,x;if(r===M.COVER?(V={...b,...d},x={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...w,...f}):(V={...d,...b},x={listId:"",listType:Mt.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...w}),c===O){E.push({startIndex:c,paragraphStyle:V,bullet:x});break}}l.push(...E),E=[]}e.paragraphs=l}return re(t,e,s,n),a}function ii(t,e,s,n,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=e;if(i==null||o==null)return;const a=Us(t,s,n);if(r!==M.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let d=[];for(const f of a){const{startIndex:E}=f;if(c===E){r===M.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}e.sectionBreaks=l}return re(t,e,s,n),a}function oi(t,e,s,n,r){const{customBlocks:i}=t,{customBlocks:o}=e;if(i==null||o==null)return;const a=Ms(t,s,n);if(r!==M.REPLACE){const l=[];for(const h of o){const{startIndex:c}=h;let d=[];for(const f of a){const{startIndex:E}=f;if(c===E){r===M.COVER?d.push({...f,...h}):d.push({...h,...f});break}}l.push(...d),d=[]}e.customBlocks=l}return ws(t,e,s,n),a}function ai(t,e,s,n,r){const{tables:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=Ps(t,s,n);if(r!==M.REPLACE){const l=[];for(const h of o){const{startIndex:c,endIndex:d}=h;let f=[];for(const E of a){const{startIndex:g,endIndex:O}=E;if(g>=c&&O<=d){r===M.COVER?f.push({...E,...h}):f.push({...h,...E});break}}l.push(...f),f=[]}e.tables=l}return ie(t,e,s,n),a}function li(t,e,s,n,r){const{customRanges:i}=t,{tables:o}=e;if(i==null||o==null)return;const a=Hs(t,s,n);if(r!==M.REPLACE){const l=[];for(const h of o){const{startIndex:c,endIndex:d}=h;let f=[];for(const E of a){const{startIndex:g,endIndex:O}=E;if(g>=c&&O<=d){r===M.COVER?f.push({...E,...h}):f.push({...h,...E});break}}l.push(...f),f=[]}e.customRanges=l}return ie(t,e,s,n),a}var A=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(A||{});function oe(t,e,s){const{dataStream:n,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:n.slice(e,s)},a=[];for(const h of r){const c=R.deepClone(h),{st:d,ed:f}=c;R.hasIntersectionBetweenTwoRanges(d,f,e,s)&&(e>=d&&e<=f?a.push({...c,st:e,ed:Math.min(s,f)}):s>=d&&s<=f?a.push({...c,st:Math.max(e,d),ed:s}):a.push(c))}a.length&&(o.textRuns=a.map(h=>{const{st:c,ed:d}=h;return{...h,st:c-e,ed:d-e}}));const l=[];for(const h of i){const{startIndex:c}=h;c>=e&&c<=s&&l.push(R.deepClone(h))}return l.length&&(o.paragraphs=l.map(h=>({...h,startIndex:h.startIndex-e}))),o}function ae(t,e,s=M.COVER){if(e.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const n={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=e,l=an(o,r,s);l.length&&(n.textRuns=l);const h=[];let c=0,d=0;for(;c<i.length&&d<a.length;){const f=i[c],E=a[d],{startIndex:g}=f,{startIndex:O}=E;g===O?(h.push(R.deepMerge(f,E)),c++,d++):g<O?(h.push(R.deepClone(f)),c++):(h.push(R.deepClone(E)),d++)}return c<i.length&&h.push(...i.slice(c)),d<a.length&&h.push(...a.slice(d)),h.length&&(n.paragraphs=h),n}function ui(t){const{body:e}=t;if(e==null)return!0;const{textRuns:s=[],paragraphs:n=[]}=e;return s.length===0&&n.length===0}const le={id:"default_doc",documentStyle:{}};class ci{constructor(e){_(this,"snapshot");this.snapshot={...le,...e}}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:n,b:r,r:i}=e,{documentStyle:o}=this.snapshot;s!=null&&(o.marginTop=s),n!=null&&(o.marginLeft=n),r!=null&&(o.marginBottom=r),i!=null&&(o.marginRight=i)}updateDocumentDataPageSize(e,s){const{documentStyle:n}=this.snapshot;if(!n.pageSize){e=e!=null?e:Number.POSITIVE_INFINITY,s=s!=null?s:Number.POSITIVE_INFINITY,n.pageSize={width:e,height:s};return}e!==void 0&&(n.pageSize.width=e),s!==void 0&&(n.pageSize.height=s)}updateDrawing(e,s){const{drawings:n}=this,{width:r,height:i,left:o,top:a}=s,l=n==null?void 0:n[e];if(!l)return;const h=l.objectTransform;h.size.width=r,h.size.height=i,h.positionH.posOffset=o,h.positionV.posOffset=a}setZoomRatio(e=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:e}:this.snapshot.settings.zoomRatio=1}}class nt extends ci{constructor(s){var r;super(s);_(this,"_unitId");_(this,"headerModelMap",new Map);_(this,"footerModelMap",new Map);const n=6;this._unitId=(r=this.snapshot.id)!=null?r:R.generateRandomId(n),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(s=>{s.dispose()}),this.footerModelMap.forEach(s=>{s.dispose()})}getRev(){var s;return(s=this.snapshot.rev)!=null?s:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(s){if(s.id&&s.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...le,...s},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(s){if(s!=null){if(this.headerModelMap.has(s))return this.headerModelMap.get(s);if(this.footerModelMap.has(s))return this.footerModelMap.get(s)}return this}getUnitId(){return this._unitId}apply(s){const n=[],r=new ze;return r.reset(),s.forEach(i=>{if(i=R.deepClone(i),i.t===A.RETAIN){const{coverType:o,body:a,len:l,segmentId:h}=i;if(a!=null){const c=this._updateApply(a,l,r.cursor,o,h);n.push({...i,t:A.RETAIN,coverType:M.REPLACE,body:c})}else n.push({...i,t:A.RETAIN});r.moveCursor(l)}else if(i.t===A.INSERT){const{body:o,len:a,segmentId:l,line:h}=i;this._insertApply(o,a,r.cursor,l),r.moveCursor(a),n.push({t:A.DELETE,len:a,line:h,segmentId:l})}else if(i.t===A.DELETE){const{len:o,segmentId:a}=i,l=this._deleteApply(o,r.cursor,a);n.push({...i,t:A.INSERT,body:l})}else throw new Error(`Unknown action type for action: ${i}.`)}),n}sliceBody(s,n){const r=this.getBody();if(r!=null)return oe(r,s,n)}_updateApply(s,n,r,i=M.COVER,o){if(s==null)throw new Error("updateBody is none");const a=this.snapshot,l=Tt(a,o);if(l==null)throw new Error("no body has changed");return si(l,s,n,r,i)}_deleteApply(s,n,r){const i=this.snapshot,o=Tt(i,r);if(o==null)throw new Error("no body has changed");return s<=0?{dataStream:""}:yr(o,s,n)}_insertApply(s,n,r,i){const o=this.snapshot,a=Tt(o,i);if(n!==0){if(a==null)throw new Error("no body has changed");ti(a,s,n,r)}}_initializeHeaderFooterModel(){const{headers:s,footers:n}=this.getSnapshot();if(s)for(const r in s){const i=s[r];this.headerModelMap.set(r,new nt(i))}if(n)for(const r in n){const i=n[r];this.footerModelMap.set(r,new nt(i))}}updateDocumentId(s){super.updateDocumentId(s),this._unitId=s}}const hi="0.1.1",_t={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},_i={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},di={startRow:0,startColumn:0,endRow:0,endColumn:0},fi={row:0,column:0},ln={id:"",sheetOrder:[],name:"",appVersion:hi,locale:It.ZH_CN,styles:{},sheets:{},resources:[]},Pt={ff:"Times New Roman",fs:14,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:lt.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Q.UNSPECIFIED,vt:y.UNSPECIFIED,tb:tt.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},un={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var cn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(cn||{});class hn{constructor(e={}){_(this,"_styles");_(this,"_cacheMap",new As(1e5));this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,s){if(this._cacheMap.has(s))return this._cacheMap.get(s);const n=this._getExistingStyleId(e);return n||"-1"}get(e){return typeof e!="string"?e:(e=String(e),this._styles[e])}add(e,s){const n=R.generateRandomId(6);return this._styles[n]=e,this._cacheMap.set(s,n),n}setValue(e){if(e==null)return;const s=JSON.stringify(e),n=this.search(e,s);return n!=="-1"?n:this.add(e,s)}toJSON(){return this._styles}getStyleByCell(e){let s;e&&R.isObject(e.s)?s=e.s:s=(e==null?void 0:e.s)&&this.get(e.s);const n=e==null?void 0:e.interceptorStyle;return n?{...s,...n}:s}_generateCacheMap(){const{_styles:e,_cacheMap:s}=this;for(const n in e){const r=JSON.stringify(e[n]);s.set(r,n)}}_getExistingStyleId(e){const{_styles:s}=this;for(const n in s)if(R.diffValue(s[n],e))return n;return null}}function Ei(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 gi(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return ut.STRING;if(typeof t.v=="number")return ut.NUMBER;if(typeof t.v=="boolean")return ut.BOOLEAN}function Ri(t){if(t==null)return!0;const{v:e,f:s,si:n,p:r,s:i}=t;return!(!(e==null||typeof e=="string"&&e.length===0)||s!=null&&s.length>0||n!=null&&n.length>0||r!=null)}function mi(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var ue=(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))(ue||{}),_n=(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))(_n||{}),dn=(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))(dn||{});class Oi{constructor(e,s){_(this,"_columnData",{});this._config=e,this._columnData=s}getColumnData(){return this._columnData}getColVisible(e){const{_columnData:s}=this,n=s[e];return n?n.hd!==I.TRUE:!0}getHiddenCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&a?(r=!1,n.push({rangeType:H.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:H.COLUMN}),n}getVisibleCols(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getColVisible(o);r&&!a?(r=!1,n.push({rangeType:H.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:s,rangeType:H.COLUMN}),n}getColumnDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getColumnOrCreate(i);n[r]=o,r++}return n}getSize(){return k(this._columnData)}getColumnWidth(e){const{_columnData:s}=this,n=this._config;let r=0;return r=(s[e]||{hd:I.FALSE,w:n.defaultColumnWidth}).w||n.defaultColumnWidth,r}getColumn(e){const s=this._columnData[e];if(s)return s}getColumnOrCreate(e){const{_columnData:s}=this,n=this._config,r=s[e];if(r)return r;const i={w:n.defaultColumnWidth,hd:I.FALSE};return this._columnData[e]=i,i}}function Ht(t,e){const{textRuns:s=[]}=e;let n=0;for(const i of s){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`)}n+=l-a}return e.dataStream.indexOf(`\r
5
- `)===n?I.TRUE:I.FALSE}class rt{constructor(e,s,n){_(this,"_range");_(this,"_worksheet");this._deps=n,this._range=s,this._worksheet=e}static foreach(e,s){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=e;for(let a=n;a<=i;a++)for(let l=r;l<=o;l++)s(a,l)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=[];for(let o=e;o<=s;o++){const a=[];for(let l=n;l<=r;l++)a.push(this.getMatrix().getValue(o,l)||null);i.push(a)}return i}getMatrix(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new $;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a,l,i.getValue(a,l)||null);return o}getMatrixObject(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new $;for(let a=e;a<=s;a++)for(let l=n;l<=r;l++)o.setValue(a-e,l-n,i.getValue(a,l)||{});return o}getA1Notation(){const{startRow:e,endRow:s,startColumn:n,endColumn:r}=this._range;let i,o;return n<r?(i=R.numToWord(n+1)+(e+1),o=R.numToWord(r+1)+(s+1)):(i=R.numToWord(r+1)+(s+1),o=R.numToWord(n+1)+(e+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||Pt.bg.rgb}))}getCell(e,s){const{startRow:n,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:n+e,endRow:n+e,startColumn:i+s,endColumn:i+s};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:s,endRow:n,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(s,n,r,i).getData();if(e.isIncludeStyle){const l=this._deps.getStyles();for(let h=0;h<=n-s;h++)for(let c=0;c<=i-r;c++){if(o==null||((a=o==null?void 0:o[h])==null?void 0:a[c])==null)continue;const d=o[h][c].s;d&&(o[h][c].s=l.get(d))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const e=this._deps.getStyles();return this.getValues().map(s=>s.map(n=>{var i;const r=e.getStyleByCell(n);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||Pt.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?Ht("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 s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?Ht("st",e.body)===I.TRUE?{s:I.TRUE}:{s:I.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){return this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?Ht("it",e.body)===I.TRUE?At.ITALIC:At.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var s,n;const{p:e}=(s=this.getValue())!=null?s:{};return e&&Array.isArray((n=e.body)==null?void 0:n.textRuns)&&e.body.textRuns.length>0?Ht("bl",e.body)===I.TRUE?Ct.BOLD:Ct.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:e,_worksheet:s}=this,{startRow:n,endRow:r}=e;let i=0;for(let o=0;o<=r-n;o++){const a=s.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:s}=this._range;return s-e+1}getNumRows(){const{startRow:e,endRow:s}=this._range;return s-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.map(s=>(s==null?void 0:s.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(s=>s.map(n=>e.getStyleByCell(n)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:e,_worksheet:s}=this,{startColumn:n,endColumn:r}=e;let i=0;for(let o=0;o<=r-n;o++)i+=s.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 s=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{const i=s&&s.getStyleByCell(r);return i&&i[e]||Pt[e]}))}}class Ii{constructor(e,s){_(this,"_rowData");this._config=e,this._rowData=s}getRowData(){return this._rowData}getRowDatas(e,s){const n={};let r=0;for(let i=e;i<e+s;i++){const o=this.getRowOrCreate(i);n[r]=o,r++}return n}getRowHeight(e,s=1){const{_rowData:n}=this,r=this._config;let i=0;for(let o=0;o<s;o++){const a=n[o+e]||{hd:I.FALSE,h:r.defaultRowHeight},{ia:l,ah:h,h:c=r.defaultRowHeight}=a;i+=(l==null||l===I.TRUE)&&typeof h=="number"?h:c}return i}getRow(e){return this._rowData[e]}getRowOrCreate(e){const{_rowData:s}=this,n=s[e];if(n)return n;const r=this._config,i={hd:I.FALSE,h:r.defaultRowHeight};return s[e]=i,i}getHiddenRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:H.ROW})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:H.ROW}),n}getVisibleRows(e=0,s=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=e;o<=s;o++){const a=this.getRowVisible(o);r&&!a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:H.ROW})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:s,startColumn:0,endColumn:0,rangeType:H.ROW}),n}getRowVisible(e){const s=this.getRow(e);return s?s.hd!==I.TRUE:!0}getSize(){return k(this._rowData)}}const Ai="DEFAULT_WORKSHEET_ROW_COUNT",fn=1e3,Ci="DEFAULT_WORKSHEET_COLUMN_COUNT",En=20,Ni="DEFAULT_WORKSHEET_ROW_HEIGHT",gn=19,Si="DEFAULT_WORKSHEET_COLUMN_WIDTH",Rn=73,Li="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",mn=46,vi="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",On=20;function In(t){const e={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:I.FALSE,rowCount:fn,columnCount:En,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:Rn,defaultRowHeight:gn,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:I.TRUE,rowHeader:{width:mn,hidden:I.FALSE},columnHeader:{height:On,hidden:I.FALSE},selections:["A1"],rightToLeft:I.FALSE};return Object.keys(e).forEach(s=>{const n=s;typeof t[n]>"u"&&(t[n]=e[n])}),t}class An extends U{constructor(){super(...arguments);_(this,"_cellContentInterceptors",[]);_(this,"_rowFilteredInterceptors",[]);_(this,"_rowVisibleInterceptors",[]);_(this,"_colVisibleInterceptors",[])}dispose(){super.dispose(),this._cellContentInterceptors.length=0,this._rowFilteredInterceptors.length=0,this._rowVisibleInterceptors.length=0,this._colVisibleInterceptors.length=0}getCell(s,n){for(const r of this._cellContentInterceptors){const i=r.getCell(s,n);if(typeof i<"u")return i}return null}registerCellContentInterceptor(s){if(this._cellContentInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptors.push(s),L(()=>j(this._cellContentInterceptors,s))}registerRowFilteredInterceptor(s){if(this._rowFilteredInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptors.push(s),L(()=>j(this._rowFilteredInterceptors,s))}registerRowVisibleInterceptor(s){if(this._rowVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowVisibleInterceptors.push(s),L(()=>j(this._rowVisibleInterceptors,s))}registerColVisibleInterceptor(s){if(this._colVisibleInterceptors.includes(s))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._colVisibleInterceptors.push(s),L(()=>j(this._colVisibleInterceptors,s))}}class dt{constructor(e,s){_(this,"_initialized");_(this,"_sheetId");_(this,"_snapshot");_(this,"_cellData");_(this,"_rowManager");_(this,"_columnManager");_(this,"_viewModel");var o;this._styles=s,this._snapshot=In(e);const{columnData:n,rowData:r,cellData:i}=this._snapshot;this._sheetId=(o=this._snapshot.id)!=null?o:R.generateRandomId(6),this._initialized=!1,this._cellData=new $(i),this._rowManager=new Ii(this._snapshot,r),this._columnManager=new Oi(this._snapshot,n),this._viewModel=new An}__interceptViewModel(e){e(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const e=this.getCellMatrix(),s=this.getMergeData();let n=-1,r=-1,i=-1,o=-1,a=!1,l=!1;return e.forEach((h,c)=>{Object.keys(c).forEach(d=>{const f=+d,E=e.getValue(h,f),g=E!=null&&E.s?this._styles.get(E.s):null,O=(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||O)&&(a?n=Math.min(n,h):(n=h,a=!0),r=Math.max(r,h),l?i=Math.min(i,f):(l=!0,i=f),o=Math.max(o,f))})}),s.forEach(h=>{a?n=Math.min(n,h.startRow):(n=h.startRow,a=!0),r=Math.max(r,h.endRow),l?i=Math.min(i,h.startColumn):(i=h.startColumn,a=!0),o=Math.max(o,h.endColumn)}),!a||!l?null:{startColumn:i,startRow:n,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:e}=this,s=R.deepClone(e);return new dt(s,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCells(e,s){const n=this._snapshot.mergeData,r=[];for(let i=0;i<n.length;i++){const o=n[i];et.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},o)&&r.push(o)}return r.length?r:null}getMergedCell(e,s){const n=this._snapshot.mergeData;for(let r=0;r<n.length;r++){const i=n[r];if(et.intersects({startRow:e,startColumn:s,endRow:e,endColumn:s},i))return i}return null}getCell(e,s){return e<0||s<0?null:this._viewModel.getCell(e,s)}getCellRaw(e,s){return this.getCellMatrix().getValue(e,s)}getMatrixWithMergedCells(e,s,n,r){const i=this.getCellMatrix(),o=this._snapshot.mergeData.filter(l=>et.intersects({startRow:e,startColumn:s,endRow:n,endColumn:r},l)),a=new $;return ee(e,n,s,r).forEach((l,h)=>{const c=i.getValue(l,h);c&&a.setValue(l,h,c)}),o.forEach(l=>{const{startColumn:h,startRow:c,endColumn:d,endRow:f}=l;ee(c,f,h,d).forEach((E,g)=>{E===c&&g===h&&a.setValue(E,g,{...i.getValue(E,g),rowSpan:f-c+1,colSpan:d-h+1}),(E!==c||g!==h)&&a.realDeleteValue(E,g)})}),a}getRange(e,s,n,r){return typeof e=="object"?new rt(this,e,{getStyles:()=>this._styles}):new rt(this,{startRow:e,startColumn:s,endColumn:r||s,endRow:n||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:s}=e;return s}getMaxRows(){const{_snapshot:e}=this,{rowCount:s}=e;return s}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:s}=e;return s===0}getTabColor(){const{_snapshot:e}=this,{tabColor:s}=e;return s}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this.getRowManager().getRowHeight(e)}getRowVisible(e){return this.getRowManager().getRowVisible(e)}getHiddenRows(e,s){const n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,s);return r.forEach(i=>i.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,s){const n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,s);return r.forEach(i=>i.endRow=n),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:s}=e;return s}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)}}var bi=Object.defineProperty,wi=Object.getOwnPropertyDescriptor,Di=(t,e,s,n)=>{for(var r=n>1?void 0:n?wi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&bi(e,s,r),r},Ti=(t,e)=>(s,n)=>e(s,n,t);function Ui(t,e){return`${t.getUnitId()}|${e.getSheetId()}`}u.Workbook=class extends U{constructor(s={},n){super();_(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=n,this._snapshot=R.commonExtend(ln,s);const{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=R.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new hn(r),this._count=1,this._worksheets=new Map,this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._snapshot.name}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete()}save(){return R.deepClone(this._snapshot)}static isIRangeType(s){return typeof s=="string"||"startRow"in s||"row"in s}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}getUnitId(){return this._unitId}getRev(){var s;return(s=this._snapshot.rev)!=null?s:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(s,n,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[s])return!1;i[s]=r,o.splice(n,0,s);const a=new dt(r,this._styles);return this._worksheets.set(s,a),this._sheetCreated$.next(a),!0}getParentRenderUnitId(){return this._snapshot.parentRenderUnitId}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}getConfig(){return this._snapshot}getIndexBySheetId(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>r===s)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const s=this.getRawActiveSheet();if(!s){const n=this._worksheets.get(this._snapshot.sheetOrder[0]);return this.setActiveSheet(n),n}return s}setActiveSheet(s){this._activeSheet$.next(s)}removeSheet(s){var r;return this._worksheets.get(s)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===s&&this.setActiveSheet(null),this._worksheets.delete(s),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(s),1),delete this._snapshot.sheets[s],!0):!1}getActiveSheetIndex(){const{sheetOrder:s}=this._snapshot;return s.findIndex(n=>this._worksheets.get(n)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:s}=this._snapshot;return s.map(n=>this._worksheets.get(n))}getSheetsName(){const{sheetOrder:s}=this._snapshot,n=[];return s.forEach(r=>{const i=this._worksheets.get(r);i&&n.push(i.getName())}),n}getSheetIndex(s){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>s.getSheetId()===r)}getSheetBySheetName(s){const{sheetOrder:n}=this._snapshot,r=n.find(i=>this._worksheets.get(i).getName()===s);return this._worksheets.get(r)}getSheetBySheetId(s){return this._worksheets.get(s)}getSheetByIndex(s){const{sheetOrder:n}=this._snapshot;return this._worksheets.get(n[s])}getHiddenWorksheets(){return this.getSheets().filter(s=>s.getConfig().hidden===I.TRUE).map(s=>s.getConfig().id)}transformRangeType(s){if(typeof s=="string")return this._getCellRange(s);if(typeof s!="string"&&"row"in s){const n=s;return{sheetId:"",range:{startRow:n.row[0],startColumn:n.column[0],endRow:n.row[1],endColumn:n.column[1]}}}return typeof s!="string"&&"startRow"in s?{sheetId:"",range:s}:_t}load(s){this._snapshot=s}checkSheetName(s){return this.getSheetsName().includes(s)}uniqueSheetName(s="Sheet1"){let n=s;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}generateNewSheetName(s){let n=s+this._count;for(;this.checkSheetName(n);)n=s+this._count,this._count++;return n}_getCellRange(s){var c,d,f,E,g;let n="",r="";if(s.indexOf("!")>-1){const O=s.split("!");n=O[0],r=O[1],n=n.replace(/\\'/g,"'").replace(/''/g,"'"),n.substring(0,1)==="'"&&n.substring(n.length-1,1)==="'"&&(n=n.substring(1,n.length-1))}else r=s;if(r.indexOf(":")===-1){const O=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,b=R.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(O)&&!Number.isNaN(b)?{sheetId:n,range:{startRow:O,endRow:O,startColumn:b,endColumn:b}}:_t}r=r.split(":");const i=[0,0],o=[0,0],a=((c=this.getSheetBySheetName(n))==null?void 0:c.getMaxRows())||((d=this.getActiveSheet())==null?void 0:d.getMaxRows()),l=((f=this.getSheetBySheetName(n))==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]=R.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=R.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=l),o[0]>o[1])?_t:{sheetId:((g=this.getSheetBySheetName(n))==null?void 0:g.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:s,_worksheets:n}=this,{sheets:r,sheetOrder:i}=s;if(R.isEmptyObject(r)){const o=R.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:l}=a;a.name=this.uniqueSheetName(l),a.name!==l&&this._logService.error(`The worksheet name ${l} is duplicated, we change it to ${a.name}`);const h=new dt(a,this._styles);n.set(o,h),i.includes(o)||i.push(o)}}},u.Workbook=Di([Ti(1,q)],u.Workbook);class ce{constructor(e){_(this,"_snapshot");_(this,"_unitId");var s;this._snapshot={...un,...e},this._unitId=(s=this._snapshot.id)!=null?s:R.generateRandomId(6)}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 n;return(n=this.getElementsByPage(e))==null?void 0:n[s]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:ue.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Ft="FOCUSING_SHEET",he="FOCUSING_DOC",_e="FOCUSING_SLIDE",Mi="FOCUSING_EDITOR_BUT_HIDDEN",Cn="EDITOR_ACTIVATED",Pi="FOCUSING_EDITOR_INPUT_FORMULA",Nn="FOCUSING_FORMULA_EDITOR",Hi="FOCUSING_UNIVER_EDITOR";var Fi=Object.defineProperty,Wi=Object.getOwnPropertyDescriptor,Bi=(t,e,s,n)=>{for(var r=n>1?void 0:n?Wi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Fi(e,s,r),r},Gi=(t,e)=>(s,n)=>e(s,n,t),Sn=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.DOC=1]="DOC",t[t.SHEET=2]="SHEET",t[t.SLIDE=3]="SLIDE",t))(Sn||{});const it=m.createIdentifier("univer.current");let de=class extends U{constructor(e,s){super();_(this,"_focused",null);_(this,"_focused$",new C.BehaviorSubject(null));_(this,"focused$",this._focused$.asObservable());_(this,"_currentSheet$",new C.BehaviorSubject(null));_(this,"currentSheet$",this._currentSheet$.asObservable());_(this,"_currentDoc$",new C.BehaviorSubject(null));_(this,"currentDoc$",this._currentDoc$.asObservable());_(this,"_currentSlide$",new C.BehaviorSubject(null));_(this,"currentSlide$",this._currentSlide$.asObservable());_(this,"_sheetAdded$",new C.Subject);_(this,"sheetAdded$",this._sheetAdded$.asObservable());_(this,"_docAdded$",new C.Subject);_(this,"docAdded$",this._docAdded$.asObservable());_(this,"_slideAdded$",new C.Subject);_(this,"slideAdded$",this._slideAdded$.asObservable());_(this,"_sheetDisposed$",new C.Subject);_(this,"sheetDisposed$",this._sheetDisposed$.asObservable());_(this,"_docDisposed$",new C.Subject);_(this,"docDisposed$",this._docDisposed$.asObservable());_(this,"_slideDisposed$",new C.Subject);_(this,"slideDisposed$",this._slideDisposed$.asObservable());_(this,"_sheets",[]);_(this,"_docs",[]);_(this,"_slides",[]);this._handler=e,this._contextService=s}dispose(){super.dispose(),this._focused$.complete(),this._currentDoc$.complete(),this._currentSheet$.complete(),this._currentSlide$.complete(),this._sheetAdded$.complete(),this._docAdded$.complete(),this._slideAdded$.complete(),this._sheetDisposed$.complete(),this._docDisposed$.complete(),this._slideDisposed$.complete()}createDoc(e){return this._handler.createUniverDoc(e)}createSheet(e){return this._handler.createUniverSheet(e)}createSlide(e){return this._handler.createUniverSlide(e)}addSheet(e){this._sheets.push(e),this._sheetAdded$.next(e),this.setCurrentUniverSheetInstance(e.getUnitId())}changeDoc(e,s){const n=this._docs.find(r=>r.getUnitId()===e);if(n!=null){const r=this._docs.indexOf(n);this._docs.splice(r,1)}this.addDoc(s)}addDoc(e){this._docs.push(e),this._docAdded$.next(e),this.setCurrentUniverDocInstance(e.getUnitId())}addSlide(e){this._slides.push(e),this._slideAdded$.next(e),this.setCurrentUniverSlideInstance(e.getUnitId())}getUniverSheetInstance(e){return this._sheets.find(s=>s.getUnitId()===e)}getUniverDocInstance(e){return this._docs.find(s=>s.getUnitId()===e)}getUniverSlideInstance(e){return this._slides.find(s=>s.getUnitId()===e)}getAllUniverSheetsInstance(){return this._sheets}getAllUniverDocsInstance(){return this._docs}getAllUniverSlidesInstance(){return this._slides}setCurrentUniverSheetInstance(e){this._currentSheet$.next(this.getUniverSheetInstance(e)||null)}setCurrentUniverSlideInstance(e){this._currentSlide$.next(this.getUniverSlideInstance(e)||null)}setCurrentUniverDocInstance(e){this._currentDoc$.next(this.getUniverDocInstance(e)||null)}getCurrentUniverSheetInstance(){const e=this._currentSheet$.getValue();if(!e)throw new Error("No current sheet!");return e}getCurrentUniverDocInstance(){const e=this._currentDoc$.getValue();if(!e)throw new Error("No current doc!");return e}getCurrentUniverSlideInstance(){const e=this._currentSlide$.getValue();if(!e)throw new Error("No current slide!");return e}focusUniverInstance(e){e&&(this._focused=this.getUniverSheetInstance(e)||this.getUniverDocInstance(e)||this.getUniverSlideInstance(e)||null),this._focused$.next(e),[he,Ft,_e].forEach(s=>this._contextService.setContextValue(s,!1)),this._focused instanceof u.Workbook?this._contextService.setContextValue(Ft,!0):this._focused instanceof nt?this._contextService.setContextValue(he,!0):this._focused instanceof ce&&this._contextService.setContextValue(_e,!0)}getFocusedUniverInstance(){return this._focused}getDocumentType(e){if(this.getUniverDocInstance(e))return 1;if(this.getUniverSheetInstance(e))return 2;if(this.getUniverSlideInstance(e))return 3;throw new Error(`[UniverInstanceService]: No document with unitId ${e}`)}disposeDocument(e){const s=this.getUniverDocInstance(e);if(s){const i=this._docs.indexOf(s);return this._docs.splice(i,1),this._docDisposed$.next(s),this.focusUniverInstance(null),!0}const n=this.getUniverSheetInstance(e);if(n){const i=this._sheets.indexOf(n);return this._sheets.splice(i,1),this._sheetDisposed$.next(n),this.focusUniverInstance(null),!0}const r=this.getUniverSlideInstance(e);if(r){const i=this._slides.indexOf(r);return this._slides.splice(i,1),this._slideDisposed$.next(r),this.focusUniverInstance(null),!0}return!1}};de=Bi([Gi(1,Z)],de);var v=(t=>(t[t.Starting=0]="Starting",t[t.Ready=1]="Ready",t[t.Rendered=2]="Rendered",t[t.Steady=3]="Steady",t))(v||{});const ki={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},Wt=new Map;function fe(t,e){return function(r){Ee(t,e)}}function Ee(t,e){Wt.has(t)||Wt.set(t,[]),Wt.get(t).push(e)}var $i=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,Ln=(t,e,s,n)=>{for(var r=n>1?void 0:n?Vi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&$i(e,s,r),r},ge=(t,e)=>(s,n)=>e(s,n,t);u.LifecycleService=class extends U{constructor(s){super();_(this,"_lifecycle$",new C.BehaviorSubject(v.Starting));_(this,"lifecycle$",this._lifecycle$.asObservable());this._logService=s,this._reportProgress(v.Starting)}get stage(){return this._lifecycle$.getValue()}set stage(s){if(s<this.stage)throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");s!==this.stage&&(this._reportProgress(s),this._lifecycle$.next(s))}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new C.Observable(s=>(this.stage===v.Starting||(this.stage===v.Ready?s.next(v.Starting):this.stage===v.Rendered?(s.next(v.Starting),s.next(v.Ready)):(s.next(v.Starting),s.next(v.Ready),s.next(v.Rendered))),this._lifecycle$.subscribe(s)))}_reportProgress(s){this._logService.debug("[LifecycleService]",`lifecycle progressed to "${ki[s]}".`)}},u.LifecycleService=Ln([ge(0,q)],u.LifecycleService);let p=class extends U{constructor(e,s){super();_(this,"_started",!1);this._lifecycleService=e,this._injector=s}start(){this._started||(this._started=!0,this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(e=>this.initModulesOnStage(e)))))}initModulesOnStage(e){const s=Wt.get(e);s==null||s.forEach(n=>{this._injector.has(n)&&this._injector.get(n)})}};p=Ln([ge(0,m.Inject(u.LifecycleService)),ge(1,m.Inject(m.Injector))],p);class ft extends U{constructor(){super();_(this,"_currentLocale",It.ZH_CN);_(this,"_locales",null);_(this,"localeChanged$",new C.Subject);_(this,"t",(s,...n)=>{if(!this._locales)throw new Error("Locale not initialized");function r(a,l){const h=l.shift();if(h&&a&&h in a){const c=a[h];return l.length>0&&(typeof c=="object"||Array.isArray(c))?r(c,l):c}return null}const i=s.split("."),o=r(this._locales[this._currentLocale],i);if(typeof o=="string"){let a=o;return n.forEach((l,h)=>{a=a.replace(`{${h}}`,l)}),a}else return s});this.disposeWithMe(L(()=>this.localeChanged$.complete()))}load(s){var n;this._locales=R.deepMerge((n=this._locales)!=null?n:{},s)}setLocale(s){this._currentLocale=s,this.localeChanged$.next()}getLocales(){var s;return(s=this._locales)==null?void 0:s[this._currentLocale]}}const Re=m.createIdentifier("resource-manager-service"),vn=m.createIdentifier("ResourcePersistenceService");Ee(v.Ready,vn);var xi=Object.defineProperty,ji=Object.getOwnPropertyDescriptor,Ki=(t,e,s,n)=>{for(var r=n>1?void 0:n?ji(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&xi(e,s,r),r},bn=(t,e)=>(s,n)=>e(s,n,t);const me=m.createIdentifier("univer.permission-service"),wn="PERMISSION";u.PermissionService=class extends U{constructor(s,n){super();_(this,"_permissionPointMap",new Map);_(this,"deletePermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(r){const i=r.get(n);i&&(i.complete(),this._permissionPointMap.delete(n))}});_(this,"addPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s)||new Map;return r.has(n.id)?!1:(r.set(n.id,new C.BehaviorSubject(n)),this._permissionPointMap.set(s,r),!0)});_(this,"updatePermissionPoint",(s,n,r)=>{const i=this._permissionPointMap.get(s);if(!i)return;const o=i.get(n);if(o){const a=o.getValue();a.value=r,a.status=te.DONE,o.next(a)}});_(this,"getPermissionPoint",(s,n)=>{const r=this._permissionPointMap.get(s);if(!r)return;const i=r.get(n);if(i)return i.getValue()});this._resourceManagerService=s,this._univerInstanceService=n}_init(){this.disposeWithMe(L(this._univerInstanceService.sheetAdded$.subscribe(s=>{this._resourceManagerService.registerPluginResource(s.getUnitId(),wn,{onChange:(n,r)=>{r.forEach(i=>{this.getPermissionPoint(n,i.id)?this.updatePermissionPoint(n,i.id,i.value):this.addPermissionPoint(n,i)})},toJson:n=>this._toJson(n),parseJson:n=>this._parseJson(n)})}))),this.disposeWithMe(L(this._univerInstanceService.sheetDisposed$.subscribe(s=>{this._resourceManagerService.disposePluginResource(s.getUnitId(),wn)})))}_toJson(s){const n=this._permissionPointMap.get(s);let r=[];return n&&(r=[...n.keys()].reduce((i,o)=>{const a=n.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(s){return JSON.parse(s)}composePermission$(s,n){const r=this._permissionPointMap.get(s),i=n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.asObservable()});return C.combineLatest(i).pipe(Vn.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(s,n){const r=this._permissionPointMap.get(s);return n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}},u.PermissionService=Ki([fe(v.Starting,u.PermissionService),bn(0,m.Inject(Re)),bn(1,m.Inject(it))],u.PermissionService);const Dn="univer.editable";class Bt extends Cs{constructor(s){super();_(this,"id",Dn);_(this,"value",!0);_(this,"unitID");this.unitID=s}}var Yi=Object.defineProperty,pi=Object.getOwnPropertyDescriptor,zi=(t,e,s,n)=>{for(var r=n>1?void 0:n?pi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&Yi(e,s,r),r},Tn=(t,e)=>(s,n)=>e(s,n,t);u.UniverPermissionService=class extends U{constructor(e,s){super(),this._permissionService=e,this._univerInstanceService=s,this._init()}_init(){this._univerInstanceService.sheetAdded$.subscribe(e=>{const s=new Bt(e.getUnitId());this._permissionService.addPermissionPoint(e.getUnitId(),s)})}getEditable(e){let s=e;s||(s=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());const n=new Bt(s),r=this._permissionService.getPermissionPoint(s,n.id);return r==null?void 0:r.value}setEditable(e,s){const n=new Bt(e);this._permissionService.updatePermissionPoint(e,n.id,s)}},u.UniverPermissionService=zi([fe(v.Starting,u.UniverPermissionService),Tn(0,m.Inject(me)),Tn(1,m.Inject(it))],u.UniverPermissionService);class Un extends U{constructor(){super(...arguments);_(this,"_resourceMap",new Map);_(this,"_register$",new C.Subject);_(this,"register$",this._register$.asObservable())}getAllResource(s){const n=this._resourceMap.get(s);return n?[...n.keys()].reduce((r,i)=>{const o=n.get(i);return o&&r.push({unitID:s,resourceName:i,hook:o}),r},[]):[]}registerPluginResource(s,n,r){const i=this._resourceMap.get(s)||new Map;if(i.has(n))throw new Error("the pluginName is registered");return i.set(n,r),this._resourceMap.set(s,i),this._register$.next({unitID:s,resourceName:n,hook:r}),L(()=>i.delete(n))}disposePluginResource(s,n){const r=this._resourceMap.get(s);r==null||r.delete(n)}dispose(){this._register$.complete(),this._resourceMap.clear()}}class Oe extends U{constructor(){super();_(this,"_currentTheme");_(this,"_currentTheme$",new C.BehaviorSubject({}));_(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(L(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(s){this._currentTheme=s,this._currentTheme$.next(s)}}const Mn="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Pn="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",Xi=`\r
6
- `;var qi=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Ji=(t,e,s,n)=>{for(var r=n>1?void 0:n?Qi(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&qi(e,s,r),r},Ie=(t,e)=>(s,n)=>e(s,n,t);const Gt=m.createIdentifier("univer.undo-redo.service"),Zi=20;class Hn{dispose(){}async dispatchToHandlers(){return!1}}const Fn="univer.command.redo",Wn="univer.command.undo",Bn=new class extends Hn{constructor(){super(...arguments);_(this,"type",Ot.COMMAND);_(this,"id",Wn)}async handler(e){const s=e.get(Gt),n=s.pitchTopUndoElement();if(!n)return!1;const r=e.get(at);return(n.undo?await n.undo(n.undoMutations):Kt(n.undoMutations,r))?(s.popUndoToRedo(),!0):!1}},Gn=new class extends Hn{constructor(){super(...arguments);_(this,"type",Ot.COMMAND);_(this,"id",Fn)}async handler(e){const s=e.get(Gt),n=s.pitchTopRedoElement();if(!n)return!1;const r=e.get(at);return(n.redo?await n.redo(n.redoMutations):Kt(n.redoMutations,r))?(s.popRedoToUndo(),!0):!1}};u.LocalUndoRedoService=class extends U{constructor(s,n,r){super();_(this,"undoRedoStatus$");_(this,"_undoRedoStatus$",new C.BehaviorSubject({undos:0,redos:0}));_(this,"_undoStacks",new Map);_(this,"_redoStacks",new Map);this._univerInstanceService=s,this._commandService=n,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Bn)),this.disposeWithMe(this._commandService.registerCommand(Gn)),this.disposeWithMe(L(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(L(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(s){const{unitID:n}=s,r=this._getRedoStack(n,!0),i=this._getUndoStack(n,!0);r.length=0,i.push(s),i.length>Zi&&i.splice(0,1),this._updateStatus()}clearUndoRedo(s){const n=this._getRedoStack(s);n&&(n.length=0);const r=this._getUndoStack(s);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const s=this._getUndoStackForFocused();return s.length?s[s.length-1]:null}pitchTopRedoElement(){const s=this._getRedoStackForFocused();return s.length?s[s.length-1]:null}popUndoToRedo(){const n=this._getUndoStackForFocused().pop();n&&(this._getRedoStackForFocused().push(n),this._updateStatus())}popRedoToUndo(){const n=this._getRedoStackForFocused().pop();n&&(this._getUndoStackForFocused().push(n),this._updateStatus())}_updateStatus(){var i,o;const s=this._getFocusedUniverInstanceId(),n=s&&((i=this._undoStacks.get(s))==null?void 0:i.length)||0,r=s&&((o=this._redoStacks.get(s))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:n,redos:r})}_getUndoStack(s,n=!1){let r=this._undoStacks.get(s);return!r&&n&&(r=[],this._undoStacks.set(s,r)),r||null}_getRedoStack(s,n=!1){let r=this._redoStacks.get(s);return!r&&n&&(r=[],this._redoStacks.set(s,r)),r||null}_getUndoStackForFocused(){const s=this._getFocusedUniverInstanceId();if(!s)throw new Error("No focused univer instance!");return this._getUndoStack(s,!0)}_getRedoStackForFocused(){const s=this._getFocusedUniverInstanceId();if(!s)throw new Error("No focused univer instance!");return this._getRedoStack(s,!0)}_getFocusedUniverInstanceId(){var o,a,l,h;let s="";const n=this._contextService.getContextValue(Ft),r=this._contextService.getContextValue(Nn),i=this._contextService.getContextValue(Cn);return n?r?s=Pn:i?s=Mn:s=(a=(o=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:o.getUnitId())!=null?a:"":s=(h=(l=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:l.getUnitId())!=null?h:"",s}},u.LocalUndoRedoService=Ji([Ie(0,it),Ie(1,at),Ie(2,Z)],u.LocalUndoRedoService);class kt extends U{constructor(){super(...arguments);_(this,"_started",!1)}addPlugins(s){if(this._started){const n=s.map(([r,i])=>this._initPlugin(r,i));this._pluginsRunLifecycle(n,v.Starting),setTimeout(()=>this._takePluginsThroughLifecycle(n,!0))}else{const n=s.map(([r,i])=>this._initPlugin(r,i));this._takePluginsThroughLifecycle(n),this._started=!0}}_takePluginsThroughLifecycle(s,n=!1){this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(r=>{n&&r===v.Starting||this._pluginsRunLifecycle(s,r)})))}_pluginsRunLifecycle(s,n){s.forEach(r=>{switch(n){case v.Starting:r.onStarting(this._injector);break;case v.Ready:r.onReady();break;case v.Rendered:r.onRendered();break;case v.Steady:r.onSteady();break}}),this._lifecycleInitializerService.initModulesOnStage(n)}_initPlugin(s,n){return this._injector.createInstance(s,n)}}var yi=Object.defineProperty,to=Object.getOwnPropertyDescriptor,eo=(t,e,s,n)=>{for(var r=n>1?void 0:n?to(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&yi(e,s,r),r},Ae=(t,e)=>(s,n)=>e(s,n,t);u.UniverDoc=class extends kt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createDoc(e){return this._injector.createInstance(nt,e)}},u.UniverDoc=eo([Ae(0,m.Inject(m.Injector)),Ae(1,m.Inject(u.LifecycleService)),Ae(2,m.Inject(p))],u.UniverDoc);var so=Object.defineProperty,no=Object.getOwnPropertyDescriptor,ro=(t,e,s,n)=>{for(var r=n>1?void 0:n?no(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&so(e,s,r),r},Ce=(t,e)=>(s,n)=>e(s,n,t);u.UniverSheet=class extends kt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createSheet(e){return this._injector.createInstance(u.Workbook,e)}},u.UniverSheet=ro([Ce(0,m.Inject(m.Injector)),Ce(1,m.Inject(u.LifecycleService)),Ce(2,m.Inject(p))],u.UniverSheet);var io=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,ao=(t,e,s,n)=>{for(var r=n>1?void 0:n?oo(e,s):e,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(e,s,r):o(r))||r);return n&&r&&io(e,s,r),r},Ne=(t,e)=>(s,n)=>e(s,n,t);u.UniverSlide=class extends kt{constructor(e,s,n){super(),this._injector=e,this._lifecycleService=s,this._lifecycleInitializerService=n}createSlide(e){return this._injector.createInstance(ce,e)}},u.UniverSlide=ao([Ne(0,m.Inject(m.Injector)),Ne(1,m.Inject(u.LifecycleService)),Ne(2,m.Inject(p))],u.UniverSlide);const lo=200;class uo extends kt{constructor(s={}){super();_(this,"_injector");_(this,"_univerPluginStore",new Kn);_(this,"_univerPluginRegistry",new Yn);_(this,"_univerSheet",null);_(this,"_univerDoc",null);_(this,"_univerSlide",null);_(this,"_initLazyPluginsTimer");this._injector=this._initDependencies();const{theme:n,locale:r,locales:i,logLevel:o}=s;n&&this._injector.get(Oe).setTheme(n),i&&this._injector.get(ft).load(i),r&&this._injector.get(ft).setLocale(r),o&&this._injector.get(q).setLogLevel(o)}get _univerInstanceService(){return this._injector.get(it)}get _lifecycleService(){return this._injector.get(u.LifecycleService)}get _lifecycleInitializerService(){return this._injector.get(p)}__getInjector(){return this._injector}dispose(){this._injector.dispose(),super.dispose()}setLocale(s){this._injector.get(ft).setLocale(s)}createUniverSheet(s){let n;const r=()=>{n=this._univerSheet.createSheet(s),this._univerInstanceService.addSheet(n)};if(this._univerSheet)r();else{this._tryProgressToStart();const i=this._univerSheet=this._injector.createInstance(u.UniverSheet),o=this._univerPluginRegistry.getRegisterPlugins(D.Sheet).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(D.Sheet),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverDoc(s){let n;const r=()=>{n=this._univerDoc.createDoc(s),this._univerInstanceService.addDoc(n)};if(this._univerDoc)r();else{this._tryProgressToStart();const i=this._univerDoc=this._injector.createInstance(u.UniverDoc),o=this._univerPluginRegistry.getRegisterPlugins(D.Doc).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(D.Doc),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverSlide(s){let n;const r=()=>{n=this._univerSlide.createSlide(s),this._univerInstanceService.addSlide(n)};if(this._univerSlide)r();else{this._tryProgressToStart();const i=this._univerSlide=this._injector.createInstance(u.UniverSlide),o=this._univerPluginRegistry.getRegisterPlugins(D.Slide).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(D.Slide),i.addPlugins(o),r(),this._tryProgressToReady()}return n}_initDependencies(){return new m.Injector([[it,{useFactory:s=>new de({createUniverDoc:n=>this.createUniverDoc(n),createUniverSheet:n=>this.createUniverSheet(n),createUniverSlide:n=>this.createUniverSlide(n)},s),deps:[Z]}],[Ke],[ft],[Oe],[u.LifecycleService],[p],[me,{useClass:u.PermissionService}],[u.UniverPermissionService],[q,{useClass:$e,lazy:!0}],[at,{useClass:u.CommandService,lazy:!0}],[Gt,{useClass:u.LocalUndoRedoService,lazy:!0}],[je,{useClass:nr}],[Z,{useClass:Ge}],[pe,{useClass:Ye,lazy:!0}],[Re,{useClass:Un,lazy:!0}]])}_tryProgressToStart(){this._started||(this._injector.get(p).start(),this._started=!0)}_tryProgressToReady(){this._injector.get(u.LifecycleService).stage<v.Ready&&(this._injector.get(u.LifecycleService).stage=v.Ready,this._univerPluginStore.forEachPlugin(n=>n.onReady()))}registerPlugin(s,n){if(s.type===D.Univer)this._registerUniverPlugin(s,n);else if(s.type===D.Sheet)this._registerSheetsPlugin(s,n);else if(s.type===D.Doc)this._registerDocsPlugin(s,n);else if(s.type===D.Slide)this._registerSlidesPlugin(s,n);else throw new Error(`Unimplemented plugin system for business: "${s.type}".`);if(this._started)return this._scheduleInitPluginAfterStarted()}_scheduleInitPluginAfterStarted(){this._initLazyPluginsTimer===void 0&&(this._initLazyPluginsTimer=setTimeout(()=>this._flushLazyPlugins(),lo))}_flushLazyPlugins(){this._initLazyPluginsTimer=void 0;const s=this._univerPluginRegistry.getRegisterPlugins(D.Univer);if(s.length){this._univerPluginRegistry.clearPluginsOfType(D.Univer);const n=s.map(r=>this._injector.createInstance(r.plugin,r.options));this._takePluginsThroughLifecycle(n)}if(this._univerSheet){const n=this._univerPluginRegistry.getRegisterPlugins(D.Sheet).map(r=>[r.plugin,r.options]);n.length&&(this._univerSheet.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(D.Sheet))}if(this._univerDoc){const n=this._univerPluginRegistry.getRegisterPlugins(D.Doc).map(r=>[r.plugin,r.options]);n.length&&(this._univerDoc.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(D.Doc))}if(this._univerSlide){const n=this._univerPluginRegistry.getRegisterPlugins(D.Slide).map(r=>[r.plugin,r.options]);n.length&&(this._univerSlide.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(D.Slide))}}_registerUniverPlugin(s,n){if(this._started)this._univerPluginRegistry.registerPlugin(s,n);else{const r=this._injector.createInstance(s,n);r.onStarting(this._injector),this._univerPluginStore.addPlugin(r)}}_registerSheetsPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}_registerDocsPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}_registerSlidesPlugin(s,n){this._univerPluginRegistry.registerPlugin(s,n)}}function co(t,e=16){let s=0,n=null;return function(...i){const o=Date.now();o-s<e?(n&&clearTimeout(n),n=setTimeout(()=>{s=o,t.apply(this,i)},e)):(s=o,t.apply(this,i))}}function ho(t){const e=new MessageChannel;let s=!1;return e.port1.onmessage=()=>{s||t()},e.port2.postMessage(null),()=>{s=!0}}class Se{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 s=this._actions[this._index];if(s){const n=this._offset,r=s.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,s.t===A.DELETE||s.t===A.RETAIN&&s.body==null?R.deepClone({...s,len:e}):R.deepClone({...s,len:e,body:oe(s.body,n,n+e)})}else return{t:A.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:A.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const e=this._offset,s=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=s,[n].concat(r)}}else return[]}}function kn(t){return Object.keys(t).length===1}class Le{constructor(){_(this,"_actions",[])}static compose(e,s){const n=new Se(e),r=new Se(s),i=new Le;for(;n.hasNext()||r.hasNext();)if(r.peekType()===A.INSERT)i.push(r.next());else if(n.peekType()===A.DELETE)i.push(n.next());else{const o=Math.min(n.peekLength(),r.peekLength()),a=n.next(o),l=r.next(o);a.t===A.INSERT&&l.t===A.RETAIN?l.body==null?i.push(a):i.push({...a,body:ae(a.body,l.body,l.coverType)}):a.t===A.RETAIN&&l.t===A.RETAIN?a.body==null&&l.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:l):a.body&&l.body?i.push({...a,body:ae(a.body,l.body,l.coverType)}):i.push(a.body?a:l):a.t===A.RETAIN&&l.t===A.DELETE?i.push(l):a.t===A.INSERT&&(l.t,A.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(e,s,n){const r={t:A.INSERT,body:s,len:e,line:0,segmentId:n};return this.push(r),this}retain(e,s,n,r){const i={t:A.RETAIN,len:e,segmentId:s};return n!=null&&(i.body=n),r!=null&&(i.coverType=r),this.push(i),this}delete(e,s){const n={t:A.DELETE,len:e,line:0,segmentId:s};return this.push(n),this}serialize(){return this._actions}push(...e){if(e.length>1){for(const i of e)this.push(i);return this}let s=this._actions.length,n=this._actions[s-1];const r=R.deepClone(e[0]);if(r.t===A.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n=="object"){if(n.t===A.DELETE&&r.t===A.DELETE)return n.len+=r.len,this;if(n.t===A.DELETE&&r.t===A.INSERT&&(s-=1,n=this._actions[s-1],n==null))return this._actions.unshift(r),this;if(n.t===A.RETAIN&&r.t===A.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===A.INSERT&&kn(n.body)&&r.t===A.INSERT&&kn(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return s===this._actions.length?this._actions.push(r):this._actions.splice(s,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===A.RETAIN&&ui(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}}class _o extends mt{add(e){if(!e)return null;const s=new Rt(e,this);return this._observers=[s],this._onObserverAdded&&this._onObserverAdded(s),s}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const fo=m.createIdentifier("ILocalStorageService"),Eo=t=>`sheet_interceptor_${t}`,$n=t=>function(e,s){let n=-1;function r(i,o){if(i<=n)throw new Error("[SheetInterceptorService]: next() called multiple times!");return n=i,i===t.length?o:t[i].handler(o,s,r.bind(null,i+1))}return r(0,e)};class go{constructor(e){_(this,"_interceptorsByName",new Map);_(this,"_interceptorPoints");this._interceptorPoints=e}fetchThroughInterceptors(e){const s=e,n=this._interceptorsByName.get(s);return $n(n||[])}intercept(e,s){const n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const r=this._interceptorsByName.get(n);return r.push(s),this._interceptorsByName.set(n,r.sort((i,o)=>{var a,l;return((a=o.priority)!=null?a:0)-((l=i.priority)!=null?l:0)})),()=>j(this._interceptorsByName.get(n),s)}getInterceptPoints(){return this._interceptorPoints}}xn(),u.ABCToNumber=Yr,u.AbsoluteRefType=Ns,u.ActionIterator=Se,u.AlignTypeH=sn,u.AlignTypeV=nn,u.AutoFillSeries=Qe,u.BaselineOffset=Nt,u.BlockType=Gs,u.BooleanNumber=I,u.BorderStyleTypes=S,u.BorderType=Je,u.BulletAlignment=Y,u.COLORS=Yt,u.CellValueType=ut,u.Color=J,u.ColorBuilder=Lt,u.ColorKit=B,u.ColorType=F,u.ColumnSeparatorType=Vs,u.CommandType=Ot,u.CommonHideTypes=Ze,u.ConditionType=ye,u.ContentAlignment=Js,u.ContextService=Ge,u.CopyPasteType=ts,u.CustomRangeType=Bs,u.DEFAULT_CELL=fi,u.DEFAULT_DOC=le,u.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=rr,u.DEFAULT_EMPTY_DOCUMENT_VALUE=Xi,u.DEFAULT_RANGE=_i,u.DEFAULT_RANGE_ARRAY=_t,u.DEFAULT_SELECTION=di,u.DEFAULT_SLIDE=un,u.DEFAULT_STYLES=Pt,u.DEFAULT_WORKBOOK=ln,u.DEFAULT_WORKSHEET_COLUMN_COUNT=En,u.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=Ci,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=On,u.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=vi,u.DEFAULT_WORKSHEET_COLUMN_WIDTH=Rn,u.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=Si,u.DEFAULT_WORKSHEET_ROW_COUNT=fn,u.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Ai,u.DEFAULT_WORKSHEET_ROW_HEIGHT=gn,u.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Ni,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=mn,u.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Li,u.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Pn,u.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Mn,u.DashStyleType=Xs,u.DataStreamTreeNodeType=vs,u.DataStreamTreeTokenType=se,u.DesktopLogService=$e,u.DeveloperMetadataVisibility=es,u.Dimension=ss,u.Direction=ns,u.Disposable=U,u.DisposableCollection=jt,u.DocStyleType=Fs,u.DocumentDataModel=nt,u.EDITOR_ACTIVATED=Cn,u.EXTENSION_NAMES=cn,u.Entry=Qt,u.EntryIterator=Is,u.ErrorService=Ke,u.EventState=We,u.FOCUSING_DOC=he,u.FOCUSING_EDITOR_BUT_HIDDEN=Mi,u.FOCUSING_EDITOR_INPUT_FORMULA=Pi,u.FOCUSING_FORMULA_EDITOR=Nn,u.FOCUSING_SHEET=Ft,u.FOCUSING_SLIDE=_e,u.FOCUSING_UNIVER_EDITOR=Hi,u.FloatingObjectManagerService=Ye,u.FollowNumberWithType=Ws,u.FontItalic=At,u.FontStyleType=Zs,u.FontWeight=Ct,u.FormatType=rs,u.GlyphType=ht,u.GridType=ks,u.HLSColor=_s,u.HorizontalAlign=Q,u.ICommandService=at,u.IConfigService=je,u.IContextService=Z,u.IFloatingObjectManagerService=pe,u.ILocalStorageService=fo,u.ILogService=q,u.IPermissionService=me,u.IResourceManagerService=Re,u.ISnapshotPersistenceService=vn,u.IUndoRedoService=Gt,u.IUniverInstanceService=it,u.InterceptorManager=go,u.InterpolationPointType=is,u.KeyIterator=ms,u.LRUHelper=ct,u.LRUMap=As,u.LifecycleStages=v,u.LocaleService=ft,u.LocaleType=It,u.LogLevel=ke,u.MemoryCursor=ze,u.NamedStyleType=ps,u.NilCommand=xe,u.NumberUnitType=en,u.ObjectMatrix=$,u.ObjectRelativeFromH=ys,u.ObjectRelativeFromV=tn,u.Observable=mt,u.ObservableHooks=_o,u.Observer=Rt,u.OnLifecycle=fe,u.PRESET_LIST_TYPE=ei,u.PageElementType=_n,u.PageOrientType=on,u.PageType=ue,u.ParagraphElementType=js,u.PermissionPoint=Cs,u.PermissionStatus=te,u.Plugin=ve,u.PluginType=D,u.PositionedObjectLayoutType=Ys,u.PresetListType=Mt,u.ProtectionType=os,u.RANGE_TYPE=H,u.RGBA_PAREN=ur,u.RGB_PAREN=lr,u.Range=rt,u.Rectangle=et,u.RedoCommand=Gn,u.RedoCommandId=Fn,u.RefAlias=Kr,u.Registry=$t,u.RegistryAsMap=Vt,u.RelativeDate=as,u.RelativeSlideLink=dn,u.ResourceManagerService=Un,u.RgbColor=vt,u.RxDisposable=Qn,u.SectionType=$s,u.ShapeType=ls,u.SheetTypes=us,u.SheetViewModel=An,u.Slide=ce,u.SpacingRule=zs,u.Styles=hn,u.THEME_COLORS=hs,u.TabStopAlignment=qs,u.TextDecoration=cs,u.TextDirection=lt,u.TextDirectionType=xs,u.TextX=Le,u.TextXActionType=A,u.ThemeColor=bt,u.ThemeColorType=P,u.ThemeColors=St,u.ThemeService=Oe,u.Tools=R,u.UndoCommand=Bn,u.UndoCommandId=Wn,u.Univer=uo,u.UniverEditablePermission=Bt,u.UniverEditablePermissionPoint=Dn,u.UniverInstanceType=Sn,u.UpdateDocsAttributeType=M,u.ValueIterator=Os,u.VerticalAlign=y,u.WidthType=Qs,u.Worksheet=dt,u.WrapStrategy=tt,u.WrapTextType=Ks,u.binarySearchArray=Xe,u.characterSpacingControlType=rn,u.checkParagraphHasBullet=Hr,u.checkParagraphHasIndent=Fr,u.checkParagraphHasIndentByStyle=Es,u.codeToBlob=or,u.composeBody=ae,u.composeInterceptors=$n,u.concatMatrixArray=Gr,u.createInterceptorKey=Eo,u.createRowColIter=ee,u.dedupe=pn,u.deepCompare=Xt,u.deleteContent=Rs,u.fromObservable=qn,u.getArrayLength=k,u.getBodySlice=oe,u.getBorderStyleType=Mr,u.getCellValueType=gi,u.getColorStyle=G,u.getDocsUpdateBody=Tt,u.getReverseDirection=ar,u.getTypeFromPermissionItemList=xr,u.getWorksheetUID=Ui,u.handleJsonToDom=Tr,u.handleStyleToString=Ur,u.hashAlgorithm=Br,u.horizontalLineSegmentsSubtraction=qt,u.insertMatrixArray=Jt,u.insertTextToContent=gs,u.isCellV=mi,u.isEmptyCell=br,u.isFormulaId=Dr,u.isFormulaString=wr,u.isICellData=Ei,u.isNullCell=Ri,u.isObserver=Be,u.isRealNum=Wr,u.isSameStyleTextRun=fs,u.isValidRange=Pr,u.makeCellRangeToRangeData=vr,u.makeCellToSelection=Lr,u.mergeWorksheetSnapshotWithDefault=In,u.moveMatrixArray=yt,u.normalizeTextRuns=ne,u.numberToABC=zr,u.numberToListABC=Xr,u.orderSearchArray=qe,u.remove=j,u.repeatStringNumTimes=Ls,u.requestImmediateMacroTask=ho,u.runOnLifecycle=Ee,u.searchArray=ir,u.selectionToArray=jr,u.sequence=we,u.sequenceAsync=be,u.sequenceExecute=Kt,u.sequenceExecuteAsync=sr,u.sliceMatrixArray=kr,u.sortRules=qr,u.sortRulesByDesc=Qr,u.sortRulesFactory=st,u.spliceArray=Zt,u.throttle=co,u.toDisposable=L,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(l,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("@wendellhu/redi"),require("rxjs"),require("rxjs/operators"),require("@univerjs/protocol")):typeof define=="function"&&define.amd?define(["exports","@wendellhu/redi","rxjs","rxjs/operators","@univerjs/protocol"],O):(l=typeof globalThis<"u"?globalThis:l||self,O(l.UniverCore={},l["@wendellhu/redi"],l.rxjs,l.rxjs.operators,l.UniverProtocol))})(this,function(l,O,A,qn,D){"use strict";var Zo=Object.defineProperty;var yo=(l,O,A)=>O in l?Zo(l,O,{enumerable:!0,configurable:!0,writable:!0,value:A}):l[O]=A;var d=(l,O,A)=>(yo(l,typeof O!="symbol"?O+"":O,A),A);var qo,Jo;function Jn(){Qn()}const mt=typeof global<"u"?global:typeof self<"u"?self:window;function Qn(){typeof mt.requestIdleCallback!="function"&&(mt.requestIdleCallback=function(e){const n=Date.now();return setTimeout(function(){const i=Math.max(0,50-(Date.now()-n));e({didTimeout:i===0,timeRemaining(){return i}})},1)}),typeof mt.cancelIdleCallback!="function"&&(mt.cancelIdleCallback=function(e){clearTimeout(e)})}class jt{constructor(){d(this,"_data",[])}static create(){return new jt}add(s){this._data.indexOf(s)>-1||this._data.push(s)}delete(s){const e=this._data.indexOf(s);this._data.splice(e,1)}getData(){return this._data}}class Kt{constructor(){d(this,"_data",new Map)}static create(){return new Kt}add(s,e){this._data.has(s)||this._data.set(s,e)}delete(s){this._data.delete(s)}getData(){return this._data}}var T=(t=>(t[t.Univer=0]="Univer",t[t.Doc=1]="Doc",t[t.Sheet=2]="Sheet",t[t.Slide=3]="Slide",t))(T||{});class Te{constructor(s){d(this,"_name");this._name=s}onStarting(s){}onReady(){}onRendered(){}onSteady(){}onDestroy(){}getPluginName(){return this._name}}d(Te,"type",0);class Zn{constructor(){d(this,"_plugins",[])}addPlugin(s){this._plugins.push(s)}removePlugins(){const s=this._plugins.slice();return this._plugins.length=0,s}forEachPlugin(s){this._plugins.forEach(s)}}class yn{constructor(){d(this,"_pluginsRegisteredByBusiness",new Map)}registerPlugin(s,e){const n=s.type;this._pluginsRegisteredByBusiness.has(n)||this._pluginsRegisteredByBusiness.set(n,[]),this._pluginsRegisteredByBusiness.get(n).push({plugin:s,options:e})}getRegisterPlugins(s){return this._pluginsRegisteredByBusiness.get(s)||[]}clearPluginsOfType(s){this._pluginsRegisteredByBusiness.delete(s)}}function j(t,s){const e=t.indexOf(s);return e>-1?(t.splice(e,1),!0):!1}function tr(t){const s=new Set,e=[];for(const n of t)s.has(n)||(s.add(n),e.push(n));return e}function er(t,s){for(let e=t.length-1;e>-1;e--){const n=t[e];if(s(n,e))return n}return null}function sr(t,s){if(t.length===0)return t;const e=s%t.length;return t.slice(e).concat(t.slice(0,e))}function nr(t,s){const e=new Map;return t.forEach(n=>{const r=s(n);let i=e.get(r);e.has(r)||(i=[],e.set(r,i)),i.push(n)}),e}async function Ue(t){for(const[s,e]of t.entries())try{if(!await e())return{index:s,result:!1}}catch(n){return{index:s,result:!1,error:n}}return{result:!0,index:-1}}function Me(t){for(const[s,e]of t.entries())try{if(!e())return{index:s,result:!1}}catch(n){return{index:s,result:!1,error:n}}return{result:!0,index:-1}}function Pe(t){var s=typeof Symbol=="function"&&Symbol.iterator,e=s&&t[s],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function He(t,s){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),r,i=[],o;try{for(;(s===void 0||s-- >0)&&!(r=n.next()).done;)i.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(o)throw o.error}}return i}function Fe(t,s,e){if(e||arguments.length===2)for(var n=0,r=s.length,i;n<r;n++)(i||!(n in s))&&(i||(i=Array.prototype.slice.call(s,0,n)),i[n]=s[n]);return t.concat(i||Array.prototype.slice.call(s))}typeof SuppressedError=="function"&&SuppressedError;function at(t){return typeof t=="function"}function rr(t){var s=function(n){Error.call(n),n.stack=new Error().stack},e=t(s);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Yt=rr(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
+ `+e.map(function(n,r){return r+1+") "+n.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function We(t,s){if(t){var e=t.indexOf(s);0<=e&&t.splice(e,1)}}var Be=function(){function t(s){this.initialTeardown=s,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var s,e,n,r,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=Pe(o),c=a.next();!c.done;c=a.next()){var h=c.value;h.remove(this)}}catch(m){s={error:m}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(s)throw s.error}}else o.remove(this);var u=this.initialTeardown;if(at(u))try{u()}catch(m){i=m instanceof Yt?m.errors:[m]}var _=this._finalizers;if(_){this._finalizers=null;try{for(var f=Pe(_),E=f.next();!E.done;E=f.next()){var g=E.value;try{Ge(g)}catch(m){i=i!=null?i:[],m instanceof Yt?i=Fe(Fe([],He(i)),He(m.errors)):i.push(m)}}}catch(m){n={error:m}}finally{try{E&&!E.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}}if(i)throw new Yt(i)}},t.prototype.add=function(s){var e;if(s&&s!==this)if(this.closed)Ge(s);else{if(s instanceof t){if(s.closed||s._hasParent(this))return;s._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(s)}},t.prototype._hasParent=function(s){var e=this._parentage;return e===s||Array.isArray(e)&&e.includes(s)},t.prototype._addParent=function(s){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(s),e):e?[e,s]:s},t.prototype._removeParent=function(s){var e=this._parentage;e===s?this._parentage=null:Array.isArray(e)&&We(e,s)},t.prototype.remove=function(s){var e=this._finalizers;e&&We(e,s),s instanceof t&&s._removeParent(this)},t.EMPTY=function(){var s=new t;return s.closed=!0,s}(),t}();Be.EMPTY;function ke(t){return t instanceof Be||t&&"closed"in t&&at(t.remove)&&at(t.add)&&at(t.unsubscribe)}function Ge(t){at(t)?t():t.unsubscribe()}class $e{constructor(s=!1){d(this,"skipNextObservers");d(this,"lastReturnValue");d(this,"isStopPropagation",!1);this.initialize(s)}initialize(s=!1){return this.skipNextObservers=s,this}stopPropagation(){this.isStopPropagation=!0}}function Ve(t){return t instanceof Ot}class Ot{constructor(s,e){d(this,"_willBeUnregistered",!1);d(this,"unregisterOnNextCall",!1);this.callback=s,this.observable=e}dispose(){this.observable.remove(this)}}class It{constructor(s){d(this,"_observers",new Array);d(this,"_eventState");d(this,"_onObserverAdded");this._eventState=new $e,s&&(this._onObserverAdded=s)}get observers(){return this._observers}add(s,e=!1,n=!1){if(!s)return null;const r=new Ot(s,this);return r.unregisterOnNextCall=n,e?this._observers.unshift(r):this._observers.push(r),this._onObserverAdded&&this._onObserverAdded(r),r}addOnce(s){return this.add(s,void 0,!0)}remove(s){return s&&this._observers.indexOf(s)!==-1?(this._deferUnregister(s),!0):!1}removeCallback(s){for(let e=0;e<this._observers.length;e++){const n=this._observers[e];if(!n._willBeUnregistered&&n.callback===s)return this._deferUnregister(n),!0}return!1}makeObserverTopPriority(s){this._remove(s),this._observers.unshift(s)}makeObserverBottomPriority(s){this._remove(s),this._observers.push(s)}notifyObservers(s){if(!this._observers.length)return null;const e=this._eventState;e.skipNextObservers=!1,e.lastReturnValue=s,e.isStopPropagation=!1;let n=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];if(!i._willBeUnregistered&&(e.lastReturnValue=i.callback(s,e),i.unregisterOnNextCall&&this._deferUnregister(i),e.isStopPropagation&&(n=!0),e.skipNextObservers))return{lastReturnValue:e.lastReturnValue,stopPropagation:n}}return{lastReturnValue:e.lastReturnValue,stopPropagation:n}}notifyObserversWithPromise(s){let e=Promise.resolve(s);if(!this._observers.length)return e;const n=this._eventState;n.skipNextObservers=!1;for(let r=0;r<this._observers.length;r++){const i=this._observers[r];n.skipNextObservers||i._willBeUnregistered||(e=e.then(()=>i.callback(s,n)),i.unregisterOnNextCall&&this._deferUnregister(i))}return e.then(()=>s)}notifyObserver(s,e){if(s._willBeUnregistered)return;const n=this._eventState;return n.skipNextObservers=!1,s.callback(e,n),s.unregisterOnNextCall&&this._deferUnregister(s),{lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}hasObservers(){return this._observers.length>0}clear(){this._observers=new Array,this._onObserverAdded=null}clone(){const s=new It;return s._observers=this._observers.slice(0),s}_deferUnregister(s){s.unregisterOnNextCall=!1,s._willBeUnregistered=!0,setTimeout(()=>{this._remove(s)},0)}_remove(s){if(!s)return!1;const e=this._observers.indexOf(s);return e!==-1?(this._observers.splice(e,1),!0):!1}}function L(t){let s=!1;return ke(t)?{dispose:()=>{s||(s=!0,t.unsubscribe())}}:Ve(t)?{dispose:()=>{s||(s=!0,t.dispose())}}:{dispose:()=>{s||(s=!0,t())}}}function ir(t){return L(()=>{t.unsubscribe()})}class zt{constructor(){d(this,"_disposables",new Set)}add(s){return this._disposables.add(s),{dispose:()=>{s.dispose(),this._disposables.delete(s)}}}dispose(){this._disposables.forEach(s=>{s.dispose(),this._disposables.delete(s)})}}class M{constructor(){d(this,"_disposed",!1);d(this,"_collection",new zt)}disposeWithMe(s){const e=ke(s)?L(s):s;return this._collection.add(e)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}}class or extends M{constructor(){super(...arguments);d(this,"dispose$",new A.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}}const tt=O.createIdentifier("univer.context-service");class xe extends M{constructor(){super(...arguments);d(this,"_contextChanged$",new A.Subject);d(this,"contextChanged$",this._contextChanged$.asObservable());d(this,"_contextMap",new Map)}dispose(){super.dispose(),this._contextChanged$.complete()}getContextValue(e){var n;return(n=this._contextMap.get(e))!=null?n:!1}setContextValue(e,n){this._contextMap.set(e,n),this._contextChanged$.next({[e]:n})}subscribeContextValue$(e){return new A.Observable(n=>{const r=this._contextChanged$.pipe(A.filter(i=>typeof i[e]<"u")).subscribe(i=>n.next(i[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}}var pe=(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))(pe||{});const J=O.createIdentifier("univer.log");class je extends M{constructor(){super(...arguments);d(this,"_logLevel",3)}debug(...e){this._logLevel>=4&&this._log(console.debug,...e)}log(...e){this._logLevel>=3&&this._log(console.log,...e)}warn(...e){this._logLevel>=2&&this._log(console.warn,...e)}error(...e){this._logLevel>=1&&this._log(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...n){const r=n[0];/^\[(.*?)\]/g.test(r)?e(`\x1B[97;104m${r}\x1B[0m`,...n.slice(1)):e(...n)}}var ar=Object.defineProperty,cr=Object.getOwnPropertyDescriptor,lr=(t,s,e,n)=>{for(var r=n>1?void 0:n?cr(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&ar(s,e,r),r},Ke=(t,s)=>(e,n)=>s(e,n,t),At=(t=>(t[t.COMMAND=0]="COMMAND",t[t.OPERATION=1]="OPERATION",t[t.MUTATION=2]="MUTATION",t))(At||{});const ct=O.createIdentifier("anywhere.command-service");class ur{constructor(){d(this,"_commands",new Map)}registerCommand(s){if(this._commands.has(s.id))throw new Error(`[CommandRegistry]: command "${s.id}" has been registered before.`);return this._commands.set(s.id,s),L(()=>{var e;this._commands.delete(s.id),(e=s.onDispose)==null||e.call(s)})}getCommand(s){return this._commands.has(s)?[this._commands.get(s)]:null}}l.CommandService=class{constructor(s,e){d(this,"_commandRegistry");d(this,"_beforeCommandExecutionListeners",[]);d(this,"_commandExecutedListeners",[]);d(this,"_multiCommandDisposables",new Map);d(this,"_commandExecutingLevel",0);d(this,"_commandExecutionStack",[]);this._injector=s,this._logService=e,this._commandRegistry=new ur,this._registerCommand(Ye)}registerCommand(s){return this._registerCommand(s)}registerMultipleCommand(s){return this._registerMultiCommand(s)}beforeCommandExecuted(s){if(this._beforeCommandExecutionListeners.indexOf(s)===-1)return this._beforeCommandExecutionListeners.push(s),L(()=>{const e=this._beforeCommandExecutionListeners.indexOf(s);this._beforeCommandExecutionListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}onCommandExecuted(s){if(this._commandExecutedListeners.indexOf(s)===-1)return this._commandExecutedListeners.push(s),L(()=>{const e=this._commandExecutedListeners.indexOf(s);this._commandExecutedListeners.splice(e,1)});throw new Error("[CommandService]: could not add a listener twice.")}async executeCommand(s,e,n){const r=this._commandRegistry.getCommand(s);if(r){const[i]=r,o={id:i.id,type:i.type,params:e},a=this._pushCommandExecutionStack(o);this._beforeCommandExecutionListeners.forEach(h=>h(o,n));const c=await this._execute(i,e,n);return this._commandExecutedListeners.forEach(h=>h(o,n)),a.dispose(),c}throw new Error(`[CommandService]: command "${s}" is not registered.`)}syncExecuteCommand(s,e,n){var i;const r=this._commandRegistry.getCommand(s);if(r){const[o]=r,a={id:o.id,type:o.type,params:e};if(o.type===2){const u=er(this._commandExecutionStack,_=>_.type===0);u&&(a.params=(i=a.params)!=null?i:{},a.params.trigger=u.id)}const c=this._pushCommandExecutionStack(a);this._beforeCommandExecutionListeners.forEach(u=>u(a,n));const h=this._syncExecute(o,e,n);return this._commandExecutedListeners.forEach(u=>u(a,n)),c.dispose(),h}throw new Error(`[CommandService]: command "${s}" is not registered.`)}_pushCommandExecutionStack(s){return this._commandExecutionStack.push(s),L(()=>j(this._commandExecutionStack,s))}_registerCommand(s){return this._commandRegistry.registerCommand(s)}_registerMultiCommand(s){const e=this._commandRegistry.getCommand(s.id);let n;if(e){if(e[0].multi!==!0)throw new Error("Command has registered as a single command.");n=e[0]}else{const i=new zt;n=new hr(s.id),i.add(this._commandRegistry.registerCommand(n)),i.add(L(()=>{this._multiCommandDisposables.delete(s.id)})),this._multiCommandDisposables.set(s.id,i)}const r=n.registerImplementation(s);return L(()=>{var i;r.dispose(),n.hasImplementations()||(i=this._multiCommandDisposables.get(s.id))==null||i.dispose()})}async _execute(s,e,n){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(this._commandExecutingLevel,0))}executing command "${s.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(s.handler,e,n),this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}_syncExecute(s,e,n){this._logService.debug("[CommandService]",`${"|-".repeat(Math.max(0,this._commandExecutingLevel))}executing command "${s.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(s.handler,e,n),r instanceof Promise)throw new TypeError("[CommandService]: Command handler should not return a promise.");this._commandExecutingLevel--}catch(i){throw r=!1,this._commandExecutingLevel=0,i}return r}},l.CommandService=lr([Ke(0,O.Inject(O.Injector)),Ke(1,J)],l.CommandService);class hr{constructor(s){d(this,"name");d(this,"multi",!0);d(this,"type",0);d(this,"priority",0);d(this,"_implementations",[]);d(this,"handler",async(s,e)=>{if(!this._implementations.length)return!1;const n=s.get(J),r=s.get(tt),i=s.get(O.Injector);for(const o of this._implementations){const a=o.command.preconditions;if((!a||a&&a(r))&&(n.debug("[MultiCommand]",`executing implementation "${o.command.name}".`),await i.invoke(o.command.handler,e)))return!0}return!1});this.id=s,this.name=s}registerImplementation(s){const e={command:s};return this._implementations.push(e),this._implementations.sort((n,r)=>r.command.priority-n.command.priority),L(()=>{var r;const n=this._implementations.indexOf(e);this._implementations.splice(n,1),(r=s.onDispose)==null||r.call(s)})}hasImplementations(){return this._implementations.length>0}}function Xt(t,s,e){const n=t.map(r=>()=>s.syncExecuteCommand(r.id,r.params,e));return Me(n)}function dr(t,s,e){const n=t.map(r=>()=>s.executeCommand(r.id,r.params,e));return Ue(n)}const Ye={id:"nil",type:0,handler:()=>!0},ze=O.createIdentifier("univer.config-service");class Xe{constructor(){d(this,"_config",new Map)}getConfig(s){return this._config.get(s)}setConfig(s,e){this._config.set(s,e)}deleteConfig(s){this._config.delete(s)}}class qe extends M{constructor(){super(...arguments);d(this,"_error$",new A.Subject);d(this,"error$",this._error$.asObservable())}dispose(){this._error$.complete()}emit(e){this._error$.next({errorKey:e})}}const _r="__default_document_sub_component_id20231101__";class Je{constructor(){d(this,"_managerInfo",new Map);d(this,"_remove$",new A.Subject);d(this,"remove$",this._remove$.asObservable());d(this,"_andOrUpdate$",new A.Subject);d(this,"andOrUpdate$",this._andOrUpdate$.asObservable());d(this,"_pluginUpdate$",new A.Subject);d(this,"pluginUpdate$",this._pluginUpdate$.asObservable())}getFloatObject(s){return this._getFloatingObject(s)}getFloatObjects(s){return this._getFloatingObjects(s)}dispose(){this._remove$.complete(),this._andOrUpdate$.complete(),this._pluginUpdate$.complete(),this._managerInfo.clear()}clear(s){const e=this._clearByParam(s);this._remove$.next(e)}addOrUpdate(s){const e=this._addByParam(s);this._andOrUpdate$.next(e)}BatchAddOrUpdate(s){const e=[];s.forEach(n=>{e.push(...this._addByParam(n))}),this._andOrUpdate$.next(e)}remove(s){const e=this._removeByParam(s);this._remove$.next(e)}pluginUpdateRefresh(s){this._pluginUpdate$.next(s)}_getFloatingObjects(s){var r;if(s==null)return;const{unitId:e,subUnitId:n}=s;return(r=this._managerInfo.get(e))==null?void 0:r.get(n)}_getFloatingObject(s){var i,o;if(s==null)return;const{unitId:e,subUnitId:n,floatingObjectId:r}=s;return(o=(i=this._managerInfo.get(e))==null?void 0:i.get(n))==null?void 0:o.get(r)}_addByParam(s){const{unitId:e,subUnitId:n,floatingObject:r,floatingObjectId:i}=s;this._managerInfo.has(e)||this._managerInfo.set(e,new Map);const o=this._managerInfo.get(e);return o.has(n)||o.set(n,new Map),o.get(n).set(i,r),[{unitId:e,subUnitId:n,floatingObjectId:i,floatingObject:r}]}_clearByParam(s){const e=this._getFloatingObjects(s),{unitId:n,subUnitId:r}=s,i=[];return e==null||e.forEach((o,a)=>{i.push({unitId:n,subUnitId:r,floatingObjectId:a,floatingObject:o})}),e==null||e.clear(),i}_removeByParam(s){const e=this._getFloatingObjects(s),n=e==null?void 0:e.get(s.floatingObjectId);return n==null?[]:(e==null||e.delete(s.floatingObjectId),[{...s,floatingObject:n}])}}const Qe=O.createIdentifier("univer.floating-object.service");class Ze{constructor(){d(this,"cursor",0)}reset(){return this.cursor=0,this}moveCursor(s){this.cursor+=s}moveCursorTo(s){this.cursor=s}}function ye(t,s){let e=0,n=t.length-1;for(;e<=n;){const r=Math.floor((n+e)/2);if(s<t[r]&&(r===0||s>=t[r-1]))return r;if(s>=t[r])e=r+1;else if(s<t[r])n=r-1;else return-1}return-1}function ts(t,s){let e=0,n=0,r=0,i=-1,o=t.length-1;for(;e<t.length&&o>=0&&o>=e;){if(n=t[o],o===0?r=0:r=t[o-1],s>=r&&s<=n){i=o;break}if(n=t[e],e===0?r=0:r=t[e-1],s>=r&&s<n){i=e;break}e++,o--}return i}function fr(t,s){let e=t.length-1;return s<0?-1:s<t[0]?0:s>t[t.length-1]?Number.POSITIVE_INFINITY:(t.length<40||s<=t[20]||s>=t[e-20]?e=ts(t,s):e=ye(t,s),e)}function Er(t){const s=new Blob([t],{type:"text/javascript"});return window.URL.createObjectURL(s)}var es=(t=>(t[t.DEFAULT_SERIES=0]="DEFAULT_SERIES",t[t.ALTERNATE_SERIES=1]="ALTERNATE_SERIES",t))(es||{}),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||{}),ss=(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))(ss||{}),k=(t=>(t[t.UNSUPPORTED=0]="UNSUPPORTED",t[t.RGB=1]="RGB",t[t.HEX=2]="HEX",t[t.THEME=3]="THEME",t))(k||{}),ns=(t=>(t[t.ON=0]="ON",t[t.OFF=1]="OFF",t))(ns||{}),rs=(t=>(t[t.CONDITION_TYPE_UNSPECIFIED=0]="CONDITION_TYPE_UNSPECIFIED",t[t.NUMNUMBER_BETWEENR_GREATER=1]="NUMNUMBER_BETWEENR_GREATER",t[t.NUMBER_GREATER_THAN_EQ=2]="NUMBER_GREATER_THAN_EQ",t[t.NUMBER_LESS=3]="NUMBER_LESS",t[t.NUMBER_LESS_THAN_EQ=4]="NUMBER_LESS_THAN_EQ",t[t.NUMBER_EQ=5]="NUMBER_EQ",t[t.NUMBER_NOT_EQ=6]="NUMBER_NOT_EQ",t[t.NUMBER_BETWEEN=7]="NUMBER_BETWEEN",t[t.NUMBER_NOT_BETWEEN=8]="NUMBER_NOT_BETWEEN",t[t.TEXT_CONTAINS=9]="TEXT_CONTAINS",t[t.TEXT_NOT_CONTAINS=10]="TEXT_NOT_CONTAINS",t[t.TEXT_STARTS_WITH=11]="TEXT_STARTS_WITH",t[t.TEXT_ENDS_WITH=12]="TEXT_ENDS_WITH",t[t.TEXT_EQ=13]="TEXT_EQ",t[t.TEXT_IS_EMAIL=14]="TEXT_IS_EMAIL",t[t.TEXT_IS_URL=15]="TEXT_IS_URL",t[t.DATE_EQ=16]="DATE_EQ",t[t.DATE_BEFORE=17]="DATE_BEFORE",t[t.DATE_AFTER=18]="DATE_AFTER",t[t.DATE_ON_OR_BEFORE=19]="DATE_ON_OR_BEFORE",t[t.DATE_ON_OR_AFTER=20]="DATE_ON_OR_AFTER",t[t.DATE_BETWEEN=21]="DATE_BETWEEN",t[t.DATE_NOT_BETWEEN=22]="DATE_NOT_BETWEEN",t[t.DATE_IS_VALID=23]="DATE_IS_VALID",t[t.ONE_OF_RANGE=24]="ONE_OF_RANGE",t[t.ONE_OF_LIST=25]="ONE_OF_LIST",t[t.BLANK=26]="BLANK",t[t.NOT_BLANK=27]="NOT_BLANK",t[t.CUSTOM_FORMULA=28]="CUSTOM_FORMULA",t[t.BOOLEAN=29]="BOOLEAN",t[t.TEXT_NOT_EQ=30]="TEXT_NOT_EQ",t[t.DATE_NOT_EQ=31]="DATE_NOT_EQ",t))(rs||{}),is=(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))(is||{}),os=(t=>(t[t.DOCUMENT=0]="DOCUMENT",t[t.PROJECT=1]="PROJECT",t))(os||{}),as=(t=>(t[t.COLUMNS=0]="COLUMNS",t[t.ROWS=1]="ROWS",t))(as||{}),cs=(t=>(t[t.UP=0]="UP",t[t.RIGHT=1]="RIGHT",t[t.DOWN=2]="DOWN",t[t.LEFT=3]="LEFT",t))(cs||{});function gr(t){switch(t){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}var ls=(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))(ls||{}),us=(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))(us||{}),et=(t=>(t.EN_US="enUS",t.ZH_CN="zhCN",t))(et||{}),hs=(t=>(t[t.RANGE=0]="RANGE",t[t.SHEET=1]="SHEET",t))(hs||{}),ds=(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))(ds||{}),_s=(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))(_s||{}),Ct=(t=>(t[t.GRID=0]="GRID",t[t.KANBAN=1]="KANBAN",t[t.GANTT=2]="GANTT",t))(Ct||{}),lt=(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))(lt||{}),fs=(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))(fs||{}),Q=(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))(Q||{}),st=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TOP=1]="TOP",t[t.MIDDLE=2]="MIDDLE",t[t.BOTTOM=3]="BOTTOM",t))(st||{}),nt=(t=>(t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.OVERFLOW=1]="OVERFLOW",t[t.CLIP=2]="CLIP",t[t.WRAP=3]="WRAP",t))(nt||{}),St=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ITALIC=1]="ITALIC",t))(St||{}),Nt=(t=>(t[t.NORMAL=0]="NORMAL",t[t.BOLD=1]="BOLD",t))(Nt||{}),vt=(t=>(t[t.NORMAL=1]="NORMAL",t[t.SUBSCRIPT=2]="SUBSCRIPT",t[t.SUPERSCRIPT=3]="SUPERSCRIPT",t))(vt||{}),I=(t=>(t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t))(I||{}),ut=(t=>(t[t.STRING=1]="STRING",t[t.NUMBER=2]="NUMBER",t[t.BOOLEAN=3]="BOOLEAN",t[t.FORCE_STRING=4]="FORCE_STRING",t))(ut||{}),F=(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))(F||{}),bt=(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))(bt||{});const Es={[bt.OFFICE]:{[F.ACCENT1]:"#4472C4",[F.ACCENT2]:"#ED7D31",[F.ACCENT3]:"#A5A5A5",[F.ACCENT4]:"#70AD47",[F.ACCENT5]:"#5B9BD5",[F.ACCENT6]:"#70AD47",[F.DARK1]:"#000000",[F.DARK2]:"#44546A",[F.LIGHT1]:"#FFFFFF",[F.LIGHT2]:"#E7E6E6",[F.HYPERLINK]:"#0563C1",[F.FOLLOWED_HYPERLINK]:"#954F72"}};class Lt{constructor(){d(this,"_themeValue",F.LIGHT1);d(this,"_themeColors");d(this,"_themeTint");d(this,"_rgbValue","");d(this,"_colorType");this._colorType=k.UNSUPPORTED,this._themeColors=bt.OFFICE,this._themeTint=0}asRgbColor(){return new wt(this._rgbValue,this)}asThemeColor(){return new Dt(this._themeValue,this._themeTint,this._themeColors,this)}build(){switch(this._colorType){case k.THEME:return this.asThemeColor();case k.RGB:return this.asRgbColor();case k.UNSUPPORTED:throw new Error("unsupported color type")}}setRgbColor(s){return this._colorType=k.RGB,this._rgbValue=s,this}setThemeColors(s){this._colorType=k.THEME,this._themeColors=s}setThemeTint(s){this._colorType=k.THEME,this._themeTint=s}setThemeColor(s){return this._colorType=k.THEME,this._themeValue=s,this}getColorType(){return this._colorType}}class Z{constructor(s){d(this,"_builder");this._builder=s}static rgbColorToHexValue(s){return`#${((1<<24)+(s.getRed()<<16)+(s.getGreen()<<8)+s.getBlue()).toString(16).slice(1)}`}static hexValueToRgbColor(s){s?s.indexOf("#")>-1&&(s=s.substring(1)):s="#000000";const e=+`0x${s[0]}${s[1]}`,n=+`0x${s[2]}${s[3]}`,r=+`0x${s[4]}${s[5]}`;return new Lt().setRgbColor(`rgb(${e},${n},${r})`).asRgbColor()}static hexToRgbString(s){const e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;s=s.replace(e,(i,o,a,c)=>o+o+a+a+c+c);const n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(s);let r=null;if(n){const i=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16),a=Number.parseInt(n[3],16);r=`rgba(${i},${o},${a})`}return r}asRgbColor(){return this._builder.asRgbColor()}asThemeColor(){return this._builder.asThemeColor()}getColorType(){return this._builder.getColorType()}clone(){return new Z(this._builder)}equals(s){return!1}}class gs{constructor(s){d(this,"_saturation",0);d(this,"_hue",0);d(this,"_lightness",0);d(this,"_alpha",0);const e=s.getRed()/255,n=s.getGreen()/255,r=s.getBlue()/255,i=s.getAlpha()/255,o=Math.min(e,Math.min(n,r)),a=Math.max(e,Math.max(n,r)),c=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=c/(a+o):this._saturation=c/(2-a-o),e===a&&(this._hue=(n-r)/c),n===a&&(this._hue=2+(r-e)/c),r===a&&(this._hue=4+(e-n)/c),this._hue*=60,this._hue<0&&(this._hue+=360),this._alpha=i}asRgbColor(){const s=new Lt;if(this._saturation===0)return s.setRgbColor(`rgba(${this._lightness*255},${this._lightness*255},${this._lightness*255},${this._alpha*255})`),s.asRgbColor();let e;this._lightness<.5?e=this._lightness*(1+this._saturation):e=this._lightness+this._saturation-this._lightness*this._saturation;const n=2*this._lightness-e,r=this._hue/360,i=r+1/3,o=this.setColor(e,n,i),a=this.setColor(e,n,r),c=r-1/3,h=this.setColor(e,n,c);return s.setRgbColor(`rgba(${Math.round(o*255)},${Math.round(a*255)},${Math.round(h*255)},${this._alpha*255})`),s.asRgbColor()}getLightness(){return this._lightness}getHue(){return this._hue}getSaturation(){return this._saturation}getAlpha(){return this._alpha}setColor(s,e,n){n<0&&(n+=1),n>1&&(n-=1);let r;return 6*n<1?r=e+(s-e)*6*n:2*n<1?r=s:3*n<2?r=e+(s-e)*(2/3-n)*6:r=e,r}setLightness(s){this._lightness=s}}const G=class G extends Z{constructor(e,n){super(n);d(this,"_cssString");d(this,"_red");d(this,"_green");d(this,"_blue");d(this,"_alpha");let r=e.match(G.RGBA_EXTRACT);if(r){const i=+r[1],o=+r[2],a=+r[3],c=+r[4];this._cssString=e,this._red=i,this._green=o,this._blue=a,this._alpha=c;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 Z.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 k.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}};d(G,"RGB_COLOR_AMT",0),d(G,"RGBA_EXTRACT",new RegExp("\\s*rgba\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d.\\d|\\d\\s*)\\)\\s*")),d(G,"RGB_EXTRACT",new RegExp("\\s*rgb\\s*\\((\\s*\\d+\\s*),(\\s*\\d+\\s*),(\\s*\\d+\\s*)\\)\\s*"));let wt=G;const z=class z extends Z{constructor(e,n,r,i){super(i);d(this,"_themeColorType");d(this,"_themeTint");d(this,"_themeColors");this._themeColorType=e,this._themeTint=n,this._themeColors=r}lumValue(e,n){if(e==null)return n;let r;return e<0?r=n*(1+e):r=n*(1-e)+(255-255*(1-e)),r}asRgbColor(){const e=Es[this._themeColors];if(e==null)throw new Error("not find themeColors type");const n=e[this._themeColorType];if(n==null)throw new Error("not find themeColors value");let r;if(z._cacheThemeColor.has(this._themeColors)){if(r=z._cacheThemeColor.get(this._themeColors),r.has(this._themeColorType))return r.get(this._themeColorType)}else r=new Map,z._cacheThemeColor.set(this._themeColors,r);const i=new gs(Z.hexValueToRgbColor(n));i.setLightness(this.lumValue(this._themeTint,i.getLightness()*255)/255);const o=i.asRgbColor();return r.set(this._themeColorType,o),o}clone(){return new z(this._themeColorType,this._themeTint,this._themeColors,this._builder)}equals(e){return e instanceof z?e._themeColorType===this._themeColorType:!1}getColorType(){return k.THEME}getThemeColorType(){return this._themeColorType}};d(z,"_cacheThemeColor",new Map);let Dt=z;const Rr="rgb(",mr="rgba(",qt={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(s){d(this,"_color");d(this,"_rgbColor");d(this,"_isValid",!1);if(s==null){this._setNullColor();return}if(s instanceof $){this._color={...s._color},this._rgbColor={...s._rgbColor};return}const e=Rs(s);if(e==null){this._setNullColor();return}this._color=e;const n=Sr(this._color);if(n==null){this._setNullColor();return}this._rgbColor=n,this._isValid=!0}static mix(s,e,n){var h,u;n=Math.min(1,Math.max(0,n));const r=new $(s).toRgb(),i=new $(e).toRgb(),o=(h=r.a)!=null?h:1,a=(u=i.a)!=null?u:1,c={r:(i.r-r.r)*n+r.r,g:(i.g-r.g)*n+r.g,b:(i.b-r.b)*n+r.b,a:(a-o)*n+o};return new $(c)}static getContrastRatio(s,e){const n=new $(s).getLuminance(),r=new $(e).getLuminance();return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){const{r:s,g:e,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?"a":""}(${s},${e},${n}${i?`,${r}`:""})`}toString(){return this.toRgbString()}toHexString(s){const{r:e,g:n,b:r,a:i=1}=this.toRgb(),o=i<1,a=[Tt(Math.round(e).toString(16)),Tt(Math.round(n).toString(16)),Tt(Math.round(r).toString(16)),Tt(Math.round(i*255).toString(16))];return s&&a[0][0]===a[0][1]&&a[1][0]===a[1][1]&&a[2][0]===a[2][1]&&a[3][0]===a[3][1]?o?`#${a[0][0]}${a[1][0]}${a[2][0]}${a[3][0]}`:`#${a[0][0]}${a[1][0]}${a[2][0]}`:o?`#${a[0]}${a[1]}${a[2]}${a[3]}`:`#${a[0]}${a[1]}${a[2]}`}toHsv(){return Lr(this.toRgb())}toHsl(){return br(this.toRgb())}lighten(s=10){const e=this.toHsl();return e.l+=s,e.l=Math.min(Math.max(e.l,0),100),new $(e)}darken(s=10){const e=this.toHsl();return e.l-=s,e.l=Math.min(Math.max(e.l,0),100),new $(e)}setAlpha(s){return new $({...this._rgbColor,a:s})}getLuminance(){let{r:s,g:e,b:n}=this.toRgb();return s=Jt(s),e=Jt(e),n=Jt(n),Number((.2126*s+.7152*e+.0722*n).toFixed(3))}getBrightness(){const{r:s,g:e,b:n}=this.toRgb();return(s*299+e*587+n*114)/1e3}getAlpha(){var s;return(s=this._color.a)!=null?s:1}isDark(){return this.getBrightness()<128}isLight(){return!this.isDark()}_setNullColor(){this._isValid=!1,this._color={r:0,g:0,b:0,a:0},this._rgbColor={r:0,g:0,b:0,a:0}}}const Tt=t=>t.length===1?`0${t}`:t,Jt=t=>(t/=255,t<=.03928?t/12.92:((t+.055)/1.055)**2.4),Rs=t=>{if(Dr(t)){if("r"in t){const n={r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)};return t.a!==void 0&&(n.a=t.a),n}if("l"in t){const n={h:Math.round(t.h),s:t.s,l:t.l};return t.a!==void 0&&(n.a=t.a),n}const e={h:Math.round(t.h),s:t.s,v:t.v};return t.a!==void 0&&(e.a=t.a),e}const s=t.trim();if(qt[s]){const e=qt[s],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(s.startsWith("#"))return Or(s);if(s.startsWith("rgb"))return Ir(s);if(s.startsWith("hsl"))return Ar(s);if(s.startsWith("hsv"))return Cr(s)},Or=t=>{const s=t.substring(1),e=new RegExp(`.{1,${s.length>=6?2:1}}`,"g");let n=s.match(e);if(!n||n.length<3)throw new Error(`The color '${t}' is illegal hex color`);n[0].length===1&&(n=n.map(i=>i+i));const r={r:Number.parseInt(n[0],16),g:Number.parseInt(n[1],16),b:Number.parseInt(n[2],16)};return n.length>3&&(r.a=Number.parseInt(n[3],16)/255),r},Ir=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal rgb color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal rgb color`);const n={r:Number.parseInt(e[0],10),g:Number.parseInt(e[1],10),b:Number.parseInt(e[2],10)};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},Ar=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal hsl color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsl color`);const n={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),l:Number.parseFloat(e[2])};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},Cr=t=>{const s=t.indexOf("(");if(s===-1)throw new Error(`The color '${t}' is illegal hsv color`);const e=t.substring(s+1,t.length-1).split(",");if(e.length<3)throw new Error(`The color '${t}' is illegal hsv color`);const n={h:Number.parseInt(e[0],10),s:Number.parseFloat(e[1]),v:Number.parseFloat(e[2])};return e.length>3&&(n.a=Number.parseFloat(e[3])),n},Sr=t=>{const s=Rs(t);if(s!=null)return"r"in s?s:"l"in s?Nr(s):vr(s)},Qt=(t,s,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+(s-t)*6*e:e<1/2?s:e<2/3?t+(s-t)*(2/3-e)*6:t),Nr=t=>{let{h:s,s:e,l:n}=t;s/=360,e/=100,n/=100;let r=0,i=0,o=0;if(e===0)r=i=o=n;else{const c=n<.5?n*(1+e):n+e-n*e,h=2*n-c;r=Qt(h,c,s+1/3),i=Qt(h,c,s),o=Qt(h,c,s-1/3)}const a={r:Math.round(r*255),g:Math.round(i*255),b:Math.round(o*255)};return t.a!==void 0&&(a.a=t.a),a},vr=t=>{let{h:s,s:e,v:n}=t;s=s/360*6,e/=100,n/=100;const r=Math.floor(s),i=s-r,o=n*(1-e),a=n*(1-i*e),c=n*(1-(1-i)*e),h=r%6,u=[n,a,o,o,c,n][h],_=[c,n,n,a,o,o][h],f=[o,o,c,n,n,a][h],E={r:u*255,g:_*255,b:f*255};return t.a!==void 0&&(E.a=t.a),E},br=t=>{let{r:s,g:e,b:n}=t;s/=255,e/=255,n/=255;const r=Math.max(s,e,n),i=Math.min(s,e,n),o=(r+i)/2;let a,c;if(r===i)a=c=0;else{const u=r-i;switch(c=o>.5?u/(2-r-i):u/(r+i),r){case s:a=(e-n)/u+(e<n?6:0);break;case e:a=(n-s)/u+2;break;default:a=(s-e)/u+4;break}a/=6}const h={h:Math.round(a*360),s:Math.round(c*100),l:Math.round(o*100)};return t.a!==void 0&&(h.a=t.a),h},Lr=t=>{let{r:s,g:e,b:n}=t;s/=255,e/=255,n/=255;const r=Math.max(s,e,n),i=Math.min(s,e,n);let o;const a=r,c=r-i,h=r===0?0:c/r;if(r===i)o=0;else{switch(r){case s:o=(e-n)/c+(e<n?6:0);break;case e:o=(n-s)/c+2;break;default:o=(s-e)/c+4;break}o/=6}const u={h:Math.round(o*360),s:Math.round(h*100),v:Math.round(a*100)};return t.a!==void 0&&(u.a=t.a),u},wr=t=>t==null,Dr=t=>!wr(t)&&typeof t=="object";function Tr(t){const s=/^#(?:[0]{3}|[0]{6})\b/,e=/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/,n=/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(s.test(t)||e.test(t)||n.test(t)||r.test(t)||i.test(t))}function Ur(t){const s=/^#(?:[Ff]{3}|[Ff]{6})\b/,e=/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/,n=/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/,r=/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/,i=/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/;return!!(s.test(t)||e.test(t)||n.test(t)||r.test(t)||i.test(t))}var P=(t=>(t[t.COVER=0]="COVER",t[t.REPLACE=1]="REPLACE",t[t.INTERSECTION=2]="INTERSECTION",t))(P||{});const Mr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Pr=t=>crypto.getRandomValues(new Uint8Array(t)),Hr=(t,s,e)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,r=-~(1.6*n*s/t.length);return(i=s)=>{let o="";for(;;){let a=e(r),c=r;for(;c--;)if(o+=t[a[c]&n]||"",o.length===i)return o}}},Fr=(t,s=21)=>Hr(t,s,Pr),Wr=(t=21)=>{let s="",e=crypto.getRandomValues(new Uint8Array(t));for(;t--;)s+=Mr[e[t]&63];return s};const Br=/^-ms-/,kr=/-([a-z])/g,K=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];class R{static stringAt(s){let e="",n=s;for(;n>=K.length;)n/=K.length,n-=1,e+=K[n%K.length];const r=s%K.length;return e+=K[r],e}static indexAt(s){let e=0;for(let n=0;n<s.length-1;n+=1){const r=s.charCodeAt(n)-65,i=s.length-1-n;e+=K.length**i+K.length*r}return e+=s.charCodeAt(s.length-1)-65,e}static deleteBlank(s){return R.isString(s)?s.replace(/\s/g,""):s}static getSystemType(){const s=navigator.userAgent,e=navigator.platform==="Win32"||navigator.platform==="Windows",n=navigator.platform==="Mac68K"||navigator.platform==="MacPPC"||navigator.platform==="Macintosh"||navigator.platform==="MacIntel";if(n)return"Mac";if(navigator.platform==="X11"&&!e&&!n)return"Unix";if(String(navigator.platform).indexOf("Linux")>-1)return"Linux";if(e){if(s.indexOf("Windows NT 5.0")>-1||s.indexOf("Windows 2000")>-1)return"Windows 2000";if(s.indexOf("Windows NT 5.1")>-1||s.indexOf("Windows XP")>-1)return"Windows XP";if(s.indexOf("Windows NT 5.2")>-1||s.indexOf("Windows 2003")>-1)return"Windows 2003";if(s.indexOf("Windows NT 6.0")>-1||s.indexOf("Windows Vista")>-1)return"Windows Vista";if(s.indexOf("Windows NT 6.1")>-1||s.indexOf("Windows 7")>-1)return"Windows 7";if(s.indexOf("Windows NT 10")>-1||s.indexOf("Windows 10")>-1)return"Windows 10";if(s.indexOf("Windows NT 11")>-1||s.indexOf("Windows 11")>-1)return"Windows 11"}return"Unknown system"}static getBrowserType(){const s=navigator.userAgent,e=s.indexOf("Opera")>-1,n=s.indexOf("compatible")>-1&&s.indexOf("MSIE")>-1&&!e,r=s.indexOf("Trident")>-1&&s.indexOf("rv:11.0")>-1,i=s.indexOf("Edge")>-1,o=s.indexOf("Firefox")>-1,a=s.indexOf("Safari")>-1&&s.indexOf("Chrome")===-1,c=s.indexOf("Chrome")>-1&&s.indexOf("Safari")>-1;if(n){new RegExp("MSIE (\\d+\\.\\d+);").test(s);const u=Number.parseFloat(RegExp.$1);return u===7?"IE7":u===8?"IE8":u===9?"IE9":u===10?"IE10":"0"}return o?"FF":e?"Opera":a?"Safari":c?"Chrome":i?"Edge":r?"IE11":"Unknown browser"}static generateRandomId(s=21,e){return e?Fr(e,s)():Wr(s)}static getClassName(s){return s.constructor.name}static deepMerge(s,...e){e.forEach(o=>o&&i(o));function n(o,a){o.forEach((c,h)=>{var u,_;if(R.isArray(c)){const f=(u=a[h])!=null?u:[];a[h]=f,n(c,f);return}if(R.isObject(c)){const f=(_=a[h])!=null?_:{};a[h]=f,r(c,f);return}a[h]=c})}function r(o,a){Object.keys(o).forEach(c=>{var u,_;const h=o[c];if(R.isObject(h)){const f=(u=a[c])!=null?u:{};a[c]=f,r(h,f);return}if(R.isArray(h)){const f=(_=a[c])!=null?_:[];a[c]=f,n(h,f);return}a[c]=h})}function i(o){Object.keys(o).forEach(a=>{var h,u;const c=o[a];if(R.isArray(c)){const _=(h=s[a])!=null?h:[];s[a]=_,n(c,_);return}if(R.isObject(c)){const _=(u=s[a])!=null?u:{};s[a]=_,r(c,_);return}s[a]=c})}return s}static numberFixed(s,e){return Number(Number(s).toFixed(e))}static diffValue(s,e){function n(o,a){const c=R.getValueType(o),h=R.getValueType(a);return c!==h?!1:R.isArray(o)?r(o,a):R.isObject(o)?i(o,a):R.isDate(o)?o.getTime()===a.getTime():R.isRegExp(o)?o.toString()===a.toString():o===a}function r(o,a){if(s.length!==e.length)return!1;for(let c=0,h=o.length;c<h;c++){const u=o[c],_=a[c];if(!n(u,_))return!1}return!0}function i(o,a){const c=Object.keys(o),h=Object.keys(a);if(c.length!==h.length)return!1;for(const u of c){if(!h.includes(u))return!1;const _=o[u],f=a[u];if(!n(_,f))return!1}return!0}return n(s,e)}static deepClone(s){if(!this.isDefine(s))return s;if(this.isRegExp(s))return new RegExp(s);if(this.isDate(s))return new Date(s);if(this.isArray(s)){const e=[];return s.forEach((n,r)=>{e[r]=R.deepClone(n)}),e}if(this.isObject(s)){const e={};return Object.keys(s).forEach(n=>{const r=s[n];e[n]=R.deepClone(r)}),Object.setPrototypeOf(e,Object.getPrototypeOf(s)),e}return s}static getLanguage(){const s="en-US";return globalThis.navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||s}static getValueType(s){return Object.prototype.toString.apply(s)}static isDefine(s){return s!=null}static isBlank(s){return this.isDefine(s)?this.isString(s)?s.trim()==="":!1:!0}static isAssignableFrom(s,e){return s instanceof e}static isBoolean(s){return this.getValueType(s)==="[object Boolean]"}static isPlainObject(s){return this.isDefine(s)?Object.getPrototypeOf(s)===Object.getPrototypeOf({}):!1}static isFunction(s){return this.getValueType(s)==="[object Function]"}static isDate(s){return this.getValueType(s)==="[object Date]"}static isRegExp(s){return this.getValueType(s)==="[object RegExp]"}static isArray(s){return this.getValueType(s)==="[object Array]"}static isString(s){return this.getValueType(s)==="[object String]"}static isNumber(s){return this.getValueType(s)==="[object Number]"}static isStringNumber(s){return!isNaN(Number.parseFloat(s))&&isFinite(s)}static isObject(s){return this.getValueType(s)==="[object Object]"}static isEmptyObject(s){for(const e in s)return!1;return!0}static isMobile(){let s=0,e=0;return document.body.clientWidth&&(s=document.body.clientWidth),document.body.clientHeight&&(e=document.body.clientHeight),this.isAndroid()||this.isIPhone()||this.isTablet()||s<350&&e<500}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isWeChat(){const s=navigator.userAgent.toLowerCase();return String(s.match(/MicroMessenger/i))==="micromessenger"}static isAndroid(){const s=navigator.userAgent;return s.indexOf("Android")>-1||s.indexOf("Linux")>-1}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static itCount(s){return e=>{for(let n=0;n<s;n++)e&&e()}}static hasLength(s,e){return R.isDefine(s)?R.isDefine(e)?s.length===e:s.length>0:!1}static capitalize(s){return s.charAt(0).toUpperCase()+s.slice(1)}static fCamelCase(s,e){return e.toUpperCase()}static camelCase(s){return s.replace(Br,"ms-").replace(kr,this.fCamelCase)}static removeNull(s){return this.isObject(s)&&Object.keys(s).forEach(e=>{const n=s[e];n==null?delete s[e]:R.removeNull(n)}),s}static fillTwoDimensionalArray(s,e,n){return new Array(s).fill(n).map(r=>new Array(e).fill(n))}static numToWord(s){let e="";for(;s>0;){let n=s%26;n=n===0?n=26:n,e=String.fromCharCode(96+n)+e,s=(s-n)/26}return e.toLocaleUpperCase()}static ABCatNum(s){if(s==null||s.length===0)return Number.NaN;const e=s.toLowerCase().split(""),n=e.length;let r=0,i=0;for(let o=0;o<n;o++)i=e[o].charCodeAt(0)-96,r+=i*26**(n-o-1);return r===0?Number.NaN:r-1}static chatAtABC(s){let i="";for(;s>=0;)i=String.fromCharCode(s%26+97)+i,s=Math.floor(s/26)-1;return i.toUpperCase()}static randSort(s){for(let e=0,n=s.length;e<n;e++){const r=Number.parseInt((Math.random()*n).toString()),i=s[r];s[r]=s[e],s[e]=i}return s}static commonExtend(s,e){const n={};for(const r in s)n[r]=s[r];for(const r in e)e[r]!=null&&(n[r]=e[r]);return n}static commonExtend1(s,e){for(const n in s)e[n]==null&&(e[n]=s[n]);return e}static arrayToObject(s){const e={};return s.forEach((n,r)=>{e[r]={},n.forEach((i,o)=>{e[r][o]=i})}),e}static hasIntersectionBetweenTwoRanges(s,e,n,r){return e>=n&&r>=s}}function Gr(t){if(!t)return;const{actualRow:s,actualColumn:e,isMerged:n,isMergedMainCell:r,mergeInfo:i}=t;let{startY:o,endY:a,startX:c,endX:h}=t,u=s,_=e,f=s,E=e;if(n&&i){const{startRow:g,startColumn:m,endRow:S,endColumn:N,startY:W,endY:H,startX:q,endX:Qo}=i;u=g,_=m,f=S,E=N,o=W,a=H,c=q,h=Qo}return r&&(o=i.startY,a=i.endY,c=i.startX,h=i.endX,f=i.endRow,E=i.endColumn),{startRow:u,startColumn:_,endRow:f,endColumn:E,startY:o,endY:a,startX:c,endX:h}}function $r(t){if(!t)return;const{actualRow:s,actualColumn:e,isMerged:n,isMergedMainCell:r,startRow:i,startColumn:o,endRow:a,endColumn:c}=t;let h=s,u=e,_=s,f=e;return(n||r)&&(h=i,u=o,_=a,f=c),{startRow:h,startColumn:u,endRow:_,endColumn:f}}function Vr(t){var e;return!t||(((e=t==null?void 0:t.v)==null?void 0:e.toString())||"").length===0&&!t.p}function x(t){if(t){if(t.rgb)return t.rgb;if(t.th)return new Lt().setThemeColor(t.th).asThemeColor().asRgbColor().getCssString()}return null}function xr(t){return R.isString(t)&&t.substring(0,1)==="="&&t.length>1}function pr(t){return R.isString(t)&&t.indexOf("=")===-1&&t.length===6}function jr(t){return""}function Kr(t,s=!1){var i;let e="";const n=new Map([["ff",()=>{t.ff&&(e+=`font-family: ${t.ff}; `)}],["fs",()=>{if(t.fs){let o=t.fs;t.va&&(o/=2),e+=`font-size: ${o}pt; `}}],["it",()=>{t.it&&(e+="font-style: italic; ")}],["bl",()=>{t.bl&&(e+="font-weight: bold; ")}],["ul",()=>{var o;(o=t.ul)!=null&&o.s&&(e.indexOf("text-decoration-line")>-1?e=e.replace(/(?<=text-decoration-line:.*)\b(?=;)/g," underline"):e+="text-decoration-line: underline; ",t.ul.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${x(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:.*)\b(?=;)/g," line-through"):e+="text-decoration-line: line-through; ",t.st.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${x(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:.*)\b(?=;)/g," overline"):e+="text-decoration-line: overline; ",t.ol.cl&&e.indexOf("text-decoration-color")===-1&&(e+=`text-decoration-color: ${x(t.ol.cl)}; `),t.ol.t&&e.indexOf("text-decoration-style")===-1&&(e+=`text-decoration-style: ${t.ol.t} `))}],["bg",()=>{t.bg&&(e+=`background: ${x(t.bg)}; `)}],["bd",()=>{var o,a,c,h,u,_,f,E,g,m,S,N;(o=t.bd)!=null&&o.b&&(e+=`border-bottom: ${Ut((a=t.bd)==null?void 0:a.b.s)} ${(c=x(t.bd.b.cl))!=null?c:""}; `),(h=t.bd)!=null&&h.t&&(e+=`border-top: ${Ut((u=t.bd)==null?void 0:u.t.s)} ${(_=x(t.bd.t.cl))!=null?_:""}; `),(f=t.bd)!=null&&f.r&&(e+=`border-right: ${Ut((E=t.bd)==null?void 0:E.r.s)} ${(g=x(t.bd.r.cl))!=null?g:""}; `),(m=t.bd)!=null&&m.l&&(e+=`border-left: ${Ut((S=t.bd)==null?void 0:S.l.s)} ${(N=x(t.bd.l.cl))!=null?N:""}; `)}],["cl",()=>{t.cl&&(e+=`color: ${x(t.cl)}; `)}],["va",()=>{t.va===vt.SUBSCRIPT?e+="vertical-align: sub; ":t.va===vt.SUPERSCRIPT&&(e+="vertical-align: super; ")}],["td",()=>{t.td===lt.LEFT_TO_RIGHT?e+="direction: ltr; ":t.td===lt.RIGHT_TO_LEFT&&(e+="direction: rtl; ")}],["tr",()=>{var o,a,c;t.tr&&(e+=`data-rotate: (${(o=t.tr)==null?void 0:o.a}deg${(a=t.tr)!=null&&a.v?` ,${(c=t.tr)==null?void 0:c.v}`:""});`)}],["ht",()=>{t.ht===Q.LEFT?e+="text-align: left; ":t.ht===Q.RIGHT?e+="text-align: right; ":t.ht===Q.CENTER?e+="text-align: center; ":t.ht===Q.JUSTIFIED&&(e+="text-align: justify; ")}],["vt",()=>{t.vt===st.BOTTOM?e+="vertical-align: bottom; ":t.vt===st.TOP?e+="vertical-align: top; ":t.vt===st.MIDDLE&&(e+="vertical-align: middle; ")}],["tb",()=>{t.tb===nt.CLIP?e+="text-overflow: clip; ":t.tb===nt.OVERFLOW?e+="text-break: overflow; ":t.tb===nt.WRAP&&(e+="word-wrap: break-word;")}],["pd",()=>{var u,_,f,E,g,m,S,N;const o=`${(u=t.pd)==null?void 0:u.b}pt`,a=`${(_=t.pd)==null?void 0:_.t}pt`,c=`${(f=t.pd)==null?void 0:f.l}pt`,h=`${(E=t.pd)==null?void 0:E.r}pt`;(g=t.pd)!=null&&g.b&&(e+=`padding-bottom: ${o}; `),(m=t.pd)!=null&&m.t&&(e+=`padding-top: ${a}; `),(S=t.pd)!=null&&S.l&&(e+=`padding-left: ${c}; `),(N=t.pd)!=null&&N.r&&(e+=`padding-right: ${h}; `)}]]),r=["bd","tr","tb"];for(const o in t)s&&r.includes(o)||(i=n.get(o))==null||i();return e}function Ut(t){let s="";return t===b.NONE?s="none":t===b.THIN?s="0.5pt solid":t===b.HAIR?s="0.5pt double":t===b.DOTTED?s="0.5pt dotted":t===b.DASHED||t===b.DASH_DOT?s="0.5pt dashed":t===b.DASH_DOT_DOT?s="0.5pt dotted":t===b.DOUBLE?s="0.5pt double":t===b.MEDIUM?s="1pt solid":t===b.MEDIUM_DASHED||t===b.MEDIUM_DASH_DOT?s="1pt dashed":t===b.MEDIUM_DASH_DOT_DOT?s="1pt dotted":t===b.SLANT_DASH_DOT?s="0.5pt dashed":t===b.THICK&&(s="1.5pt solid"),s}function Yr(t){let s=0;if(t=t.trim(),t==="none")s=b.NONE;else if(t==="0.5pt solid")s=b.THIN;else if(t==="0.5pt double")s=b.HAIR;else if(t==="0.5pt dotted")s=b.DOTTED;else if(t==="0.5pt dashed")s=b.DASHED;else if(t==="1pt solid")s=b.MEDIUM;else if(t==="1pt dashed")s=b.MEDIUM_DASHED;else if(t==="1pt dotted")s=b.MEDIUM_DASH_DOT_DOT;else if(t==="1.5pt solid")s=b.THICK;else return b.NONE;return s}function Mt(t,s){let e=t.body;if(s){const{headers:n,footers:r}=t;n!=null&&n[s]?e=n[s].body:r!=null&&r[s]&&(e=r[s].body)}return e}function zr(t){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=t;return!(s<0||n<0||e<0||r<0)}function Zt(t,s){return Object.prototype.toString.call(t)===Object.prototype.toString.call(s)?Object.prototype.toString.call(t)==="[object Object]"||Object.prototype.toString.call(t)==="[object Array]"?Object.keys(t).length!==Object.keys(s).length?!1:Object.keys(t).every(e=>Zt(t[e],s[e])):t===s:!1}function ms(t,s){const e=t.ts||{},n=s.ts||{};return t.sId!==s.sId?!1:Zt(e,n)}function Xr(t,s){return s.some(e=>t.indexOf(e)>-1)}function yt(t,s,e,n){if(t>s&&([t,s]=[s,t]),e>n&&([e,n]=[n,e]),s<e||n<t)return[t,s];e<t&&(e=t),n>s&&(n=s);const r=n-e+1;let i=[];return t===e?i=[n+1-r,s-r]:s===n?i=[t,e-1]:i=[t,s-r],i}function qr(t){if(t==null)return!1;const s=t.bullet;return(s==null?void 0:s.listId)!=null}function Jr(t){if(t==null)return!1;const s=t.paragraphStyle;return Os(s)}function Os(t){return!(t==null||(t.indentStart==null||t.indentStart===0)&&t.hanging==null||t.hanging===0)}function Is(t,s,e){return t.slice(0,s)+e+t.slice(s)}function As(t,s,e){return s>e?t:t.slice(0,s)+t.slice(e)}function Qr(t){return t===null||t.toString().replace(/\s/g,"")===""||typeof t=="boolean"?!1:!isNaN(t)}function Zr(t){let s=0;for(let e=0;e<t.length;e++)s=t.charCodeAt(e)+(s<<6)+(s<<16)-s;return s>>>0}class ht{static hasLength(s,e){return s.length===e}static getValueType(s){return Object.prototype.toString.apply(s)}static isObject(s){return this.getValueType(s)==="[object Object]"}static isIterable(s){return s[Symbol.iterator]!=null}static isNumber(s){return this.getValueType(s)==="[object Number]"}}const v=Symbol("newer"),U=Symbol("older");class Cs{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[v],{done:!1,value:s.key}):{done:!0,value:void 0}}}class Ss{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[v],{done:!1,value:s.value}):{done:!0,value:void 0}}}class Ns{constructor(s){d(this,"entry");this.entry=s}[Symbol.iterator](){return this}next(){const s=this.entry;return s?(this.entry=s[v],{done:!1,value:[s.key,s.value]}):{done:!0,value:void 0}}}class te{constructor(s,e){d(this,"key");d(this,"value");d(this,qo);d(this,Jo);this.key=s,this.value=e,this[v]=void 0,this[U]=void 0}toJSON(){return{key:this.key,value:this.value}}}qo=v,Jo=U;class vs{constructor(...s){d(this,"_keymap");d(this,"size",0);d(this,"limit");d(this,"oldest");d(this,"newest");d(this,"_onShiftListeners",[]);if(ht.hasLength(s,1)){if(ht.isNumber(s[0])){const e=s[0];this._initialize(e,void 0);return}if(ht.isIterable(s[0])){const e=s[0];this._initialize(0,e);return}return}if(ht.hasLength(s,2)){const e=s[0],n=s[1];this._initialize(e,n)}}onShift(s){if(this._onShiftListeners.indexOf(s)===-1)return this._onShiftListeners.push(s),L(()=>j(this._onShiftListeners,s));throw new Error("[LRUMap]: the listener has been registered!")}_initialize(s,e){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=s,this._keymap=new Map,e&&(this.assign(e),s<1&&(this.limit=this.size))}_markEntryAsUsed(s){s!==this.newest&&(s[v]&&(s===this.oldest&&(this.oldest=s[v]),s[v][U]=s[U]),s[U]&&(s[U][v]=s[v]),s[v]=void 0,s[U]=this.newest,this.newest&&(this.newest[v]=s),this.newest=s)}assign(s){let e,n=this.limit||Number.MAX_VALUE;this._keymap.clear();const r=s[Symbol.iterator]();for(let i=r.next();!i.done;i=r.next()){const o=new te(i.value[0],i.value[1]);if(this._keymap.set(o.key,o),e?(e[v]=o,o[U]=e):this.oldest=o,e=o,n--===0)throw new Error("overflow")}this.newest=e,this.size=this._keymap.size}set(s,e){let n=this._keymap.get(s);return n?(n.value=e,this._markEntryAsUsed(n),this):(this._keymap.set(s,n=new te(s,e)),this.newest?(this.newest[v]=n,n[U]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){const s=this.oldest;if(s)return this.oldest&&this.oldest[v]?(this.oldest=this.oldest[v],this.oldest[U]=void 0):(this.oldest=void 0,this.newest=void 0),s[v]=s[U]=void 0,this._keymap.delete(s.key),--this.size,this._onShiftListeners.forEach(e=>e(s)),[s.key,s.value]}get(s){const e=this._keymap.get(s);if(e)return this._markEntryAsUsed(e),e.value}has(s){return this._keymap.has(s)}find(s){const e=this._keymap.get(s);return e?e.value:void 0}delete(s){const e=this._keymap.get(s);if(e)return this._keymap.delete(e.key),e[v]&&e[U]?(e[U][v]=e[v],e[v][U]=e[U]):e[v]?(e[v][U]=void 0,this.oldest=e[v]):e[U]?(e[U][v]=void 0,this.newest=e[U]):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 Cs(this.oldest)}values(){return new Ss(this.oldest)}entries(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ns(this.oldest)}forEach(s,e){typeof e!="object"&&(e=this);let n=this.oldest;for(;n;)s.call(e,n.value,n.key,this),n=n[v]}toJSON(){const s=new Array(this.size);let e=0,n=this.oldest;for(;n;)s[e++]={key:n.key,value:n.value},n=n[v];return s}toString(){let s="",e=this.oldest;for(;e;)s+=`${String(e.key)}:${e.value}`,e=e[v],e&&(s+=" < ");return s}}function p(t){let s=0;const e=Object.keys(t);for(const n of e){const r=Number(n);s=Math.max(s,r)}return s+1}function ee(t,s,e){const n=p(e),r=e;for(let i=n-1;i>=t;i--)r[i+1]=r[i];r[t]=s}function se(t,s,e,n){const r=t+s,i=p(e),o=e;let a=0;const c={};for(let f=t;f<r;f++){const E=o[f];E!==void 0&&(delete o[f],c[a]=E,a++)}const h=n?p(n):0,u=t-r+h,_=i;if(u>0)for(let f=_-1;f>=r;f--)o[f]!==void 0&&(o[f+u]=o[f],delete o[f]);else if(u<0)for(let f=r;f<_;f++)o[f]!==void 0&&(o[f+u]=o[f],delete o[f]);if(n)for(let f=0;f<h;f++)o[t+f]=n[f];return c}function yr(t,s){const e=t,n=Object.keys(e),r=n.length,i=s,o=Object.keys(i),a=o.length,c={};let h=0;for(let u=0;u<r;u++,h++){const _=n[u];c[h]=e[_]}for(let u=0;u<a;u++,h++){const _=o[u];c[h]=i[_]}return c}function ti(t,s,e){const n=e;if(p(e)>0){const i={};let o=0;for(let a=t;a<=s;a++)n[a]&&(i[o]=n[a],o++);return i}return{}}function ne(t,s,e,n){const r=t>e;if(!r&&t+s>e)throw new Error("Invalid move operation");r?ei(t,s,e,n):si(t,s,e,n)}function ei(t,s,e,n){const r=n,i=[];for(let o=t;o<t+s;o++)i.push(r[o]);for(let o=t-1;o>=e;o--){const a=r[o];r[o+s]=a,a==null&&delete r[o+s]}i.forEach((o,a)=>{r[e+a]=o,o==null&&delete r[e+a]})}function si(t,s,e,n){const r=n,i=[];for(let o=t;o<t+s;o++)i.push(r[o]);for(let o=t+s;o<e;o++){const a=r[o];r[o-s]=a,a==null&&delete r[o-s]}i.forEach((o,a)=>{r[e+a-s]=o,o==null&&delete r[e+a-s]})}class V{constructor(s={}){d(this,"_matrix");this._setOriginValue(s)}static MakeObjectMatrixSize(s){return new V({[s-1]:{}})}getMatrix(){return this._matrix}forEach(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(s(i,o)===!1)return this}return this}forRow(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(s(i,Object.keys(o).map(c=>Number(c)))===!1)return this}return this}forValue(s){const e=this._matrix,n=Object.keys(e);for(const r of n){const i=Number(r),o=e[i];if(!o)continue;const a=Object.keys(o);for(const c of a){const h=Number(c),u=o[Number(c)];if(s(i,h,u)===!1)return this}}return this}swapRow(s,e){const n=this._matrix[s],r=this._matrix[e];this._matrix[s]=r,this._matrix[e]=n}getRow(s){return this._matrix[s]}getRowOrCreate(s){let e=this.getRow(s);return e==null&&(e={},this._matrix[s]=e),e}reset(){this._setOriginValue({})}hasValue(){const s=this._matrix,e=Object.keys(s);if(e.length===0)return!1;for(const n of e){const r=Number(n),i=s[r];if(Object.keys(i).length>0)return!0}return!1}getValue(s,e){var n,r;return(r=(n=this._matrix)==null?void 0:n[s])==null?void 0:r[e]}setValue(s,e,n){const r=this.getRowOrCreate(s);r[e]=n}deleteValue(s,e){var n,r;(r=(n=this._matrix)==null?void 0:n[s])==null||delete r[e]}realDeleteValue(s,e){var n,r,i;if((r=(n=this._matrix)==null?void 0:n[s])==null||delete r[e],this.getRow(s)){const o=this.getRow(s);if(o==null)return;Object.keys(o).length===0&&((i=this._matrix)==null||delete i[s])}}setRow(s,e){this._matrix[s]=e}moveRows(s,e,n){ne(s,e,n,this._matrix)}moveColumns(s,e,n){this.forEach((r,i)=>{ne(s,e,n,i)})}insertRows(s,e){for(let n=s;n<s+e;n++)ee(n,{},this._matrix)}insertColumns(s,e){for(let n=s;n<s+e;n++)this.forEach((r,i)=>{ee(n,void 0,i)})}removeRows(s,e){se(s,e,this._matrix)}removeColumns(s,e){this.forEach((n,r)=>{se(s,e,r)})}getFragment(s,e,n,r){const i=new V;let o=0;for(let a=s;a<=e;a++){const c={};let h=0;for(let u=n;u<=r;u++){const _=this.getValue(a,u);c[h]=_,h++}i.setRow(o,c),o++}return i}getSlice(s,e,n,r){const i=new V;for(let o=s;o<=e;o++)for(let a=n;a<=r;a++){const c=this.getValue(o,a);c&&i.setValue(o,a,R.deepClone(c))}return i}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return p(this._matrix)}getRange(){const n=this.getLength()-1;let r=0;const i=this.getLength();for(let o=0;o<i;o++){const a=this.getRow(o);if(a){const c=p(a)-1;r=c>r?c:r}}return{startRow:0,startColumn:0,endRow:n,endColumn:r}}toNativeArray(){const s=new Array;return this.forValue((e,n,r)=>{s.push(r)}),s}toArray(){const s=[];return this.forRow((e,n)=>{s[e]==null&&(s[e]=[]),n.forEach(r=>{s[e][r]=this.getValue(e,r)})}),s}toJSON(){return this._matrix}clone(){const s=JSON.stringify(this._matrix);return JSON.parse(s)}getData(){const s=JSON.stringify(this._matrix);return JSON.parse(s)}getArrayData(){let s=0,e=0,n=!1,r=!1;const i=new V;return this.forEach((o,a)=>{n||(n=!0,s=o),Object.keys(a).forEach(c=>{const h=Number(c);r?h<e&&(e=h):(r=!0,e=h);const u=this.getValue(o,h);i.setValue(o-s,h-e,u)})}),i.getData()}getDataRange(){let s=0,e=0,n=0,r=-1,i=!1,o=!1;return this.forEach((a,c)=>{i||(i=!0,s=a);const h=p(c)-1;h>n&&(n=h),Object.keys(c).forEach(u=>{const _=Number(u);o?_<e&&(e=_):(o=!0,e=_)}),a>r&&(r=a)}),{startRow:s,startColumn:e,endRow:r,endColumn:n}}getDiscreteRanges(){const s=[];return this.forEach((e,n)=>{Object.keys(n).forEach(r=>{const i=Number(r);let o=!1;for(const a of s)if(e>=a.startRow&&e<=a.endRow+1&&i>=a.startColumn&&i<=a.endColumn+1){a.endRow=Math.max(e,a.endRow),a.endColumn=Math.max(i,a.endColumn),o=!0;break}o||s.push({startRow:e,endRow:e,startColumn:i,endColumn:i})})}),s}merge(s){this.forValue((e,n)=>{const r=s.getValue(e,n);r!=null&&this.setValue(e,n,r)})}_setOriginValue(s={}){this._matrix=s}}var re=(t=>(t.INIT="init",t.FETCHING="fetching",t.DONE="done",t))(re||{});class bs{constructor(){d(this,"status","init")}}const ni=t=>t.some(s=>s.status==="init")?"init":t.some(s=>s.status==="fetching")?"fetching":"done";var B=(t=>(t[t.NORMAL=0]="NORMAL",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(B||{}),Ls=(t=>(t[t.NONE=0]="NONE",t[t.ROW=1]="ROW",t[t.COLUMN=2]="COLUMN",t[t.ALL=3]="ALL",t))(Ls||{});function ri(t){return[t.startRow,t.startColumn,t.endRow,t.endColumn]}const X=class X{static clone(s){return s.rangeType!==void 0?{startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType}:{startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn}}static equals(s,e){return s==null||e==null?!1:s.endRow===e.endRow&&s.endColumn===e.endColumn&&s.startRow===e.startRow&&s.startColumn===e.startColumn&&(s.rangeType===e.rangeType||s.rangeType===void 0&&e.rangeType===B.NORMAL||e.rangeType===void 0&&s.rangeType===B.NORMAL)}static intersects(s,e){const n=s.startRow,r=s.endRow,i=s.startColumn,o=s.endColumn,a=e.startRow,c=e.endRow,h=e.startColumn,u=e.endColumn,_=Math.abs(i+o-h-u),f=Math.abs(i-o)+Math.abs(h-u),E=Math.abs(n+r-a-c),g=Math.abs(n-r)+Math.abs(a-c);return _<=f&&E<=g}static getIntersects(s,e){const n=s.startRow,r=s.endRow,i=s.startColumn,o=s.endColumn,a=e.startRow,c=e.endRow,h=e.startColumn,u=e.endColumn;let _,f,E,g;if(a<=r)a>=n?f=a:f=n;else return null;if(c>=n)c>=r?g=r:g=c;else return null;if(h<=o)h>i?_=h:_=i;else return null;if(u>=i)u>=o?E=o:E=u;else return null;return{startRow:f,endRow:g,startColumn:_,endColumn:E,rangeType:B.NORMAL}}static contains(s,e){return s.startRow<=e.startRow&&s.endRow>=e.endRow&&s.startColumn<=e.startColumn&&s.endColumn>=e.endColumn}static realContain(s,e){return X.contains(s,e)&&(s.startRow<e.startRow||s.endRow>e.endRow||s.startColumn<e.startColumn||s.endColumn>e.endColumn)}static union(...s){return s.reduce((e,n)=>({startRow:Math.min(e.startRow,n.startRow),startColumn:Math.min(e.startColumn,n.startColumn),endRow:Math.max(e.endRow,n.endRow),endColumn:Math.max(e.endColumn,n.endColumn),rangeType:B.NORMAL}),s[0])}static subtract(s,e){if(e.startRow>=s.endRow||e.endRow<=s.startRow||e.startColumn>=s.endColumn||e.endColumn<=s.startColumn)return[s];const n=[];e.startRow>s.startRow&&n.push({startRow:s.startRow,startColumn:s.startColumn,endRow:e.startRow,endColumn:s.endColumn}),e.endRow<s.endRow&&n.push({startRow:e.endRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn});const r=Math.max(s.startRow,e.startRow),i=Math.min(s.endRow,e.endRow);return e.startColumn>s.startColumn&&n.push({startRow:r,startColumn:s.startColumn,endRow:i,endColumn:e.startColumn}),e.endColumn<s.endColumn&&n.push({startRow:r,startColumn:e.endColumn,endRow:i,endColumn:s.endColumn}),n}};d(X,"getRelativeRange",(s,e)=>({startRow:s.startRow-e.startRow,endRow:s.endRow-s.startRow,startColumn:s.startColumn-e.startColumn,endColumn:s.endColumn-s.startColumn})),d(X,"getPositionRange",(s,e)=>({startRow:s.startRow+e.startRow,endRow:s.endRow+s.startRow+e.startRow,startColumn:s.startColumn+e.startColumn,endColumn:s.endColumn+s.startColumn+e.startColumn})),d(X,"moveHorizontal",(s,e=0,n=0)=>({...s,startColumn:s.startColumn+e,endColumn:s.endColumn+e+n})),d(X,"moveVertical",(s,e=0,n=0)=>({...s,startRow:s.startRow+e,endRow:s.endRow+e+n})),d(X,"moveOffset",(s,e,n)=>({...s,startRow:s.startRow+n,endRow:s.endRow+n,startColumn:s.startColumn+e,endColumn:s.endColumn+e}));let dt=X;class ii{constructor(s,e){d(this,"_values",[]);d(this,"_keys",[]);d(this,"_keyMaps",new Map);this._values=s,this._keys=e,s.forEach(n=>{this._initKeyMap(n)})}_initKeyMap(s){this._keys.forEach(e=>{const n=s[e],r=this._keyMaps.get(e)||new Map;r.set(n,s),this._keyMaps.set(e,r)})}getValue(s){for(let e=0;e<this._keys.length;e++){const n=this._keyMaps.get(this._keys[e]);if(n!=null&&n.has(s))return n.get(s)}return null}hasValue(s){for(let e=0;e<this._keys.length;e++){const n=this._keyMaps.get(this._keys[e]);if(n!=null&&n.has(s))return!0}return!1}addValue(s){this._values.push(s),this._initKeyMap(s)}setValue(s,e,n){const r=this.getValue(s);r&&Object.keys(r).includes(e)&&(r[e]=n)}deleteValue(s){const e=this.getValue(s);if(e){this._keys.forEach(r=>{const i=this._keyMaps.get(r),o=e[r];i==null||i.delete(o)});const n=this._values.findIndex(r=>r===e);this._values.splice(n,1)}}getValues(){return this._values}getKeyMap(s){var e;return[...((e=this._keyMaps.get(s))==null?void 0:e.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}}function ie(t,s,e,n){return{forEach(r){for(let i=t;i<=s;i++)for(let o=e;o<=n;o++)r(i,o)}}}function oi(t){if(t==null||t.length===0)return Number.NaN;const s=t.toLowerCase().split(""),e=s.length,n=o=>o.charCodeAt(0)-96;let r=0,i=0;for(let o=0;o<e;o++)i=n(s[o]),r+=i*26**(e-o-1);return r===0?Number.NaN:r-1}const Pt=65,ws=90,ai=97;function ci(t){const s=ws-Pt+1;let e="";for(;t>=0;)e=String.fromCharCode(t%s+Pt)+e,t=Math.floor(t/s)-1;return e}function Ds(t,s){let e="";for(;s>0;)e+=t,s--;return e}function li(t,s=!1){const e=ws-Pt+1;let n=ai;s&&(n=Pt);const r=String.fromCharCode(t%e+n),i=Math.floor(t/e)+1;return Ds(r,i)}function ui(t,s){return t.zIndex>s.zIndex?1:t.zIndex===s.zIndex?0:-1}function hi(t,s){return t.zIndex>s.zIndex?-1:t.zIndex===s.zIndex?0:1}function rt(t="index",s=1){return(e,n)=>e[t]>n[t]?s:e[t]===n[t]?0:-s}function di(t,s){let e;return function(...n){const r=this,i=function(){e=null,t.apply(r,n)};clearTimeout(e),e=setTimeout(i,s)}}var Ts=(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))(Ts||{}),oe=(t=>(t.PARAGRAPH="\r",t.SECTION_BREAK=`
4
+ `,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))(oe||{});function ae(t){const s=[];for(const e of t){const{st:n,ed:r,ts:i}=e;if(e.sId===void 0&&delete e.sId,n===r||R.isEmptyObject(i)&&e.sId==null)continue;if(s.length===0){s.push(e);continue}const o=s.pop();ms(e,o)&&R.hasIntersectionBetweenTwoRanges(o.st,o.ed,e.st,e.ed)?s.push({...e,st:o.st,ed:r}):s.push(o,e)}return s}function Us(t,s,e,n){var h;const{textRuns:r}=t;if(r==null)return;const i=[],o=r.length;let a=!1;const c=(h=s.textRuns)!=null?h:[];if(c.length)for(let u=0,_=c.length;u<_;u++){const f=c[u];f.st+=n,f.ed+=n}for(let u=0;u<o;u++){const _=r[u],{st:f,ed:E}=_;if(E<n)i.push(_);else if(n>=f&&n<=E)if(a)_.st+=e,_.ed+=e,i.push(_);else{a=!0,_.ed+=e;const g=[];if(c.length){const m={..._,st:f,ed:c[0].st};g.push(m),g.push(...c);const S=c[c.length-1],N={..._,st:S.ed,ed:E+e};g.push(N)}else g.push(_);i.push(...g)}else _.st+=e,_.ed+=e,a||(a=!0,i.push(...c)),i.push(_)}a||(a=!0,i.push(...c)),t.textRuns=ae(i)}function ce(t,s,e,n){const{paragraphs:r}=t;if(r==null)return;const{paragraphs:i,dataStream:o}=s,a=[];let c=-1;for(let u=0,_=r.length;u<_;u++){const f=r[u],{startIndex:E}=f;E>=n&&(f.startIndex+=e),c===-1&&E>=n&&(c=u),a.push(f.startIndex)}let h=-1;if(i){for(let u=0,_=i.length;u<_;u++){const f=i[u];f.startIndex+=n;const E=f.startIndex;h=a.indexOf(E)}if(o===oe.PARAGRAPH&&i.length===1){const u=r[c],_=i[0],f=u.paragraphStyle,E=u.bullet;u.paragraphStyle=_.paragraphStyle,u.bullet=_.bullet,_.paragraphStyle=f,_.bullet=E}h!==-1&&r.splice(h,1),r.push(...i),r.sort(rt("startIndex"))}}function _i(t,s,e,n){const{sectionBreaks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const c=r[o],{startIndex:h}=c;h>=n&&(c.startIndex+=e)}const i=s.sectionBreaks;if(i){for(let o=0,a=i.length;o<a;o++){const c=i[o];c.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ms(t,s,e,n){const{customBlocks:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const c=r[o],{startIndex:h}=c;h>=n&&(c.startIndex+=e)}const i=s.customBlocks;if(i){for(let o=0,a=i.length;o<a;o++){const c=i[o];c.startIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function le(t,s,e,n){const{tables:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const c=r[o],{startIndex:h,endIndex:u}=c;h>n?(c.startIndex+=e,c.endIndex+=e):u>=n-1&&(c.endIndex+=e)}const i=s.tables;if(i){for(let o=0,a=i.length;o<a;o++){const c=i[o];c.startIndex+=n,c.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function fi(t,s,e,n){const{customRanges:r}=t;if(r==null)return;for(let o=0,a=r.length;o<a;o++){const c=r[o],{startIndex:h,endIndex:u}=c;h>n?(c.startIndex+=e,c.endIndex+=e):u>=n-1&&(c.endIndex+=e)}const i=s.customRanges;if(i){for(let o=0,a=i.length;o<a;o++){const c=i[o];c.startIndex+=n,c.endIndex+=n}r.push(...i),r.sort(rt("startIndex"))}}function Ps(t,s,e){const{textRuns:n}=t,r=e,i=e+s,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{st:_,ed:f}=u;if(r<=_&&i>=f){o.push({...u,st:_-r,ed:f-r});continue}else _<=r&&f>=i?(o.push({...u,st:r-r,ed:i-r}),u.ed-=s):r>=_&&r<f?(o.push({...u,st:r-r,ed:f-r}),u.ed=r):i>_&&i<=f?(o.push({...u,st:_-r,ed:i-r}),u.st=i-s,u.ed-=s):_>=i&&(u.st-=s,u.ed-=s);a.push(u)}t.textRuns=a}return o}function Hs(t,s,e){const{paragraphs:n}=t,r=e,i=e+s,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{startIndex:_}=u;if(_>=r&&_<i){o.push({...u,startIndex:_-e});continue}else _>=i&&(u.startIndex-=s);a.push(u)}t.paragraphs=a}return o}function Fs(t,s,e){const{sectionBreaks:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-e});continue}else _>i&&(u.startIndex-=s);a.push(u)}t.sectionBreaks=a}return o}function Ws(t,s,e){const{customBlocks:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{startIndex:_}=u;if(_>=r&&_<=i){o.push({...u,startIndex:_-e});continue}else _>i&&(u.startIndex-=s);a.push(u)}t.customBlocks=a}return o}function Bs(t,s,e){const{tables:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{startIndex:_,endIndex:f}=u;if(r<=_&&i>=f){o.push({...u,startIndex:_-e,endIndex:f-e});continue}else if(_<=r&&f>=i){const E=yt(_,f,r,i);u.startIndex=E[0],u.endIndex=E[1]}else i<_&&(u.startIndex-=s,u.endIndex-=s);a.push(u)}t.tables=a}return o}function ks(t,s,e){const{customRanges:n}=t,r=e,i=e+s-1,o=[];if(n){const a=[];for(let c=0,h=n.length;c<h;c++){const u=n[c],{startIndex:_,endIndex:f}=u;if(r<=_&&i>=f){o.push({...u,startIndex:_-e,endIndex:f-e});continue}else if(_<=r&&f>=i){const E=yt(_,f,r,i);u.startIndex=E[0],u.endIndex=E[1]}else i<_&&(u.startIndex-=s,u.endIndex-=s);a.push(u)}t.customRanges=a}return o}function Ei(t,s,e){const{dataStream:n}=t,r=e,i=e+s,o=Ps(t,s,e),a=Hs(t,s,e),c=Fs(t,s,e),h=Ws(t,s,e),u=Bs(t,s,e),_=ks(t,s,e);let f="";return n&&(t.dataStream=As(n,r,i),f=n.slice(r,i)),{dataStream:f,textRuns:o,paragraphs:a,sectionBreaks:c,customBlocks:h,tables:u,customRanges:_}}function gi(t,s,e,n){t.dataStream=Is(t.dataStream,n,s.dataStream),Us(t,s,e,n),ce(t,s,e,n),_i(t,s,e,n),Ms(t,s,e,n),le(t,s,e,n),fi(t,s,e,n)}var Gs=(t=>(t[t.character=0]="character",t[t.paragraph=1]="paragraph",t[t.table=2]="table",t[t.numbering=3]="numbering",t))(Gs||{}),$s=(t=>(t[t.TAB=0]="TAB",t[t.SPACE=1]="SPACE",t[t.NOTHING=2]="NOTHING",t))($s||{}),_t=(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))(_t||{}),Y=(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))(Y||{}),Vs=(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))(Vs||{}),xs=(t=>(t[t.DRAWING=0]="DRAWING",t[t.CUSTOM=1]="CUSTOM",t))(xs||{}),ps=(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))(ps||{}),js=(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))(js||{}),Ks=(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))(Ks||{}),Ys=(t=>(t[t.NORMAL=0]="NORMAL",t[t.TBRL=1]="TBRL",t[t.LRTBV=2]="LRTBV",t))(Ys||{}),zs=(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))(zs||{}),Xs=(t=>(t[t.BOTH_SIDES=0]="BOTH_SIDES",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.LARGEST=3]="LARGEST",t))(Xs||{}),qs=(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))(qs||{}),Js=(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))(Js||{}),Qs=(t=>(t[t.AUTO=0]="AUTO",t[t.AT_LEAST=1]="AT_LEAST",t[t.EXACT=2]="EXACT",t))(Qs||{}),Zs=(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))(Zs||{}),ys=(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))(ys||{}),tn=(t=>(t.EVENLY_DISTRIBUTED="0",t.FIXED_WIDTH="1",t))(tn||{}),en=(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))(en||{}),sn=(t=>(t.NORMAL="normal",t.BOLD="bold",t.ITALIC="italic",t))(sn||{}),nn=(t=>(t[t.CHARACTER=0]="CHARACTER",t[t.COLUMN=1]="COLUMN",t[t.INSIDE_MARGIN=2]="INSIDE_MARGIN",t[t.LEFT_MARGIN=3]="LEFT_MARGIN",t[t.MARGIN=4]="MARGIN",t[t.OUTSIDE_MARGIN=5]="OUTSIDE_MARGIN",t[t.PAGE=6]="PAGE",t[t.RIGHT_MARGIN=7]="RIGHT_MARGIN",t))(nn||{}),rn=(t=>(t[t.BOTTOM_MARGIN=0]="BOTTOM_MARGIN",t[t.INSIDE_MARGIN=1]="INSIDE_MARGIN",t[t.LINE=2]="LINE",t[t.MARGIN=3]="MARGIN",t[t.OUTSIDE_MARGIN=4]="OUTSIDE_MARGIN",t[t.PAGE=5]="PAGE",t[t.PARAGRAPH=6]="PARAGRAPH",t[t.TOP_MARGIN=7]="TOP_MARGIN",t))(rn||{}),on=(t=>(t[t.POINT=0]="POINT",t[t.LINE=1]="LINE",t[t.CHARACTER=2]="CHARACTER",t))(on||{}),an=(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))(an||{}),cn=(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))(cn||{}),ln=(t=>(t[t.compressPunctuation=0]="compressPunctuation",t[t.compressPunctuationAndJapaneseKana=1]="compressPunctuationAndJapaneseKana",t[t.doNotCompress=2]="doNotCompress",t))(ln||{}),un=(t=>(t[t.PORTRAIT=0]="PORTRAIT",t[t.LANDSCAPE=1]="LANDSCAPE",t))(un||{}),Ht=(t=>(t.BULLET_LIST="BULLET_LIST",t.ORDER_LIST="ORDER_LIST",t))(Ht||{});const Ri={BULLET_LIST:{listType:"BULLET_LIST",nestingLevel:[{bulletAlignment:Y.START,glyphFormat:" %0",textStyle:{fs:12},startNumber:0,glyphSymbol:"●",hanging:21,indentStart:21},{bulletAlignment:Y.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"■",hanging:21,indentStart:42},{bulletAlignment:Y.START,glyphFormat:" %1",textStyle:{fs:12},startNumber:0,glyphSymbol:"◆",hanging:21,indentStart:63}]},ORDER_LIST:{listType:"ORDER_LIST",nestingLevel:[{bulletAlignment:Y.START,glyphFormat:" %1.",textStyle:{fs:12},startNumber:0,glyphType:_t.DECIMAL,hanging:21,indentStart:21},{bulletAlignment:Y.START,glyphFormat:" %1.%2)",textStyle:{fs:12},startNumber:0,glyphType:_t.DECIMAL,hanging:21,indentStart:42},{bulletAlignment:Y.START,glyphFormat:" %1.%2.%3.",textStyle:{fs:12},startNumber:0,glyphType:_t.DECIMAL,hanging:21,indentStart:63}]}};function mi(t,s,e,n,r){const i=Oi(t,s,e,n,r),o=Ii(t,s,e,n,r),a=Ai(t,s,e,n,r),c=Ci(t,s,e,n,r),h=Si(t,s,e,n,r),u=Ni(t,s,e,n,r);return{dataStream:"",textRuns:i,paragraphs:o,sectionBreaks:a,customBlocks:c,tables:h,customRanges:u}}function Oi(t,s,e,n,r){const{textRuns:i}=t,{textRuns:o}=s;if(i==null||o==null)return;const a=Ps(t,e,n);if(r!==P.REPLACE){const c=hn(o,a,r);s.textRuns=c}return Us(t,s,e,n),a}function hn(t,s,e){if(s.length===0)return t;t=R.deepClone(t),s=R.deepClone(s);const n=[],r=t.length,i=s.length;let o=0,a=0,c=null;function h(){return c?(n.push(c),c=null,!0):!1}for(;o<r&&a<i;){const{st:E,ed:g,ts:m}=t[o],{st:S,ed:N,ts:W,sId:H}=s[a];let q;e===P.COVER?q={...W,...m}:q={...m,...W},g<S?(h()||n.push(t[o]),o++):N<E?(h()||n.push(s[a]),a++):(n.push({st:Math.min(E,S),ed:Math.max(E,S),ts:E<S?{...m}:{...W},sId:E<S?void 0:H}),n.push({st:Math.max(E,S),ed:Math.min(g,N),ts:q,sId:H}),g<N?(o++,s[a].st=g):(a++,t[o].st=N),c={st:Math.min(g,N),ed:Math.max(g,N),ts:g<N?{...W}:{...m},sId:g<N?H:void 0})}h();const u=n[n.length-1],_=t[r-1],f=s[i-1];return u.ed!==Math.max(_.ed,f.ed)&&(_.ed>f.ed?n.push(_):n.push(f)),ae(n)}function Ii(t,s,e,n,r){const{paragraphs:i}=t,{paragraphs:o}=s;if(i==null||o==null)return;const a=Hs(t,e,n);if(r!==P.REPLACE){const c=[];for(const h of o){const{startIndex:u,paragraphStyle:_,bullet:f}=h;let E=[];for(const g of a){const{startIndex:m,paragraphStyle:S,bullet:N}=g;let W,H;if(r===P.COVER?(W={...S,..._},H={listId:"",listType:Ht.BULLET_LIST,nestingLevel:0,textStyle:{},...N,...f}):(W={..._,...S},H={listId:"",listType:Ht.BULLET_LIST,nestingLevel:0,textStyle:{},...f,...N}),u===m){E.push({startIndex:u,paragraphStyle:W,bullet:H});break}}c.push(...E),E=[]}s.paragraphs=c}return ce(t,s,e,n),a}function Ai(t,s,e,n,r){const{sectionBreaks:i}=t,{sectionBreaks:o}=s;if(i==null||o==null)return;const a=Fs(t,e,n);if(r!==P.REPLACE){const c=[];for(const h of o){const{startIndex:u}=h;let _=[];for(const f of a){const{startIndex:E}=f;if(u===E){r===P.COVER?_.push({...f,...h}):_.push({...h,...f});break}}c.push(..._),_=[]}s.sectionBreaks=c}return ce(t,s,e,n),a}function Ci(t,s,e,n,r){const{customBlocks:i}=t,{customBlocks:o}=s;if(i==null||o==null)return;const a=Ws(t,e,n);if(r!==P.REPLACE){const c=[];for(const h of o){const{startIndex:u}=h;let _=[];for(const f of a){const{startIndex:E}=f;if(u===E){r===P.COVER?_.push({...f,...h}):_.push({...h,...f});break}}c.push(..._),_=[]}s.customBlocks=c}return Ms(t,s,e,n),a}function Si(t,s,e,n,r){const{tables:i}=t,{tables:o}=s;if(i==null||o==null)return;const a=Bs(t,e,n);if(r!==P.REPLACE){const c=[];for(const h of o){const{startIndex:u,endIndex:_}=h;let f=[];for(const E of a){const{startIndex:g,endIndex:m}=E;if(g>=u&&m<=_){r===P.COVER?f.push({...E,...h}):f.push({...h,...E});break}}c.push(...f),f=[]}s.tables=c}return le(t,s,e,n),a}function Ni(t,s,e,n,r){const{customRanges:i}=t,{tables:o}=s;if(i==null||o==null)return;const a=ks(t,e,n);if(r!==P.REPLACE){const c=[];for(const h of o){const{startIndex:u,endIndex:_}=h;let f=[];for(const E of a){const{startIndex:g,endIndex:m}=E;if(g>=u&&m<=_){r===P.COVER?f.push({...E,...h}):f.push({...h,...E});break}}c.push(...f),f=[]}s.customRanges=c}return le(t,s,e,n),a}var C=(t=>(t.RETAIN="r",t.INSERT="i",t.DELETE="d",t))(C||{});function ue(t,s,e){const{dataStream:n,textRuns:r=[],paragraphs:i=[]}=t,o={dataStream:n.slice(s,e)},a=[];for(const h of r){const u=R.deepClone(h),{st:_,ed:f}=u;R.hasIntersectionBetweenTwoRanges(_,f,s,e)&&(s>=_&&s<=f?a.push({...u,st:s,ed:Math.min(e,f)}):e>=_&&e<=f?a.push({...u,st:Math.max(s,_),ed:e}):a.push(u))}a.length&&(o.textRuns=a.map(h=>{const{st:u,ed:_}=h;return{...h,st:u-s,ed:_-s}}));const c=[];for(const h of i){const{startIndex:u}=h;u>=s&&u<=e&&c.push(R.deepClone(h))}return c.length&&(o.paragraphs=c.map(h=>({...h,startIndex:h.startIndex-s}))),o}function he(t,s,e=P.COVER){if(s.dataStream!=="")throw new Error("Cannot compose other body with non-empty dataStream");const n={dataStream:t.dataStream},{textRuns:r=[],paragraphs:i=[]}=t,{textRuns:o=[],paragraphs:a=[]}=s,c=hn(o,r,e);c.length&&(n.textRuns=c);const h=[];let u=0,_=0;for(;u<i.length&&_<a.length;){const f=i[u],E=a[_],{startIndex:g}=f,{startIndex:m}=E;g===m?(h.push(R.deepMerge(f,E)),u++,_++):g<m?(h.push(R.deepClone(f)),u++):(h.push(R.deepClone(E)),_++)}return u<i.length&&h.push(...i.slice(u)),_<a.length&&h.push(...a.slice(_)),h.length&&(n.paragraphs=h),n}function vi(t){const{body:s}=t;if(s==null)return!0;const{textRuns:e=[],paragraphs:n=[]}=s;return e.length===0&&n.length===0}const de={id:"default_doc",documentStyle:{}};class bi{constructor(s){d(this,"snapshot");this.snapshot={...de,...s}}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 s;return((s=this.snapshot.settings)==null?void 0:s.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(s){this.snapshot.id=s}updateDocumentRenderConfig(s){const{documentStyle:e}=this.snapshot;e.renderConfig==null?e.renderConfig=s:e.renderConfig={...e.renderConfig,...s}}updateDocumentStyle(s){this.snapshot.documentStyle==null?this.snapshot.documentStyle=s:this.snapshot.documentStyle={...this.snapshot.documentStyle,...s}}updateDocumentDataMargin(s){const{t:e,l:n,b:r,r:i}=s,{documentStyle:o}=this.snapshot;e!=null&&(o.marginTop=e),n!=null&&(o.marginLeft=n),r!=null&&(o.marginBottom=r),i!=null&&(o.marginRight=i)}updateDocumentDataPageSize(s,e){const{documentStyle:n}=this.snapshot;if(!n.pageSize){s=s!=null?s:Number.POSITIVE_INFINITY,e=e!=null?e:Number.POSITIVE_INFINITY,n.pageSize={width:s,height:e};return}s!==void 0&&(n.pageSize.width=s),e!==void 0&&(n.pageSize.height=e)}updateDrawing(s,e){const{drawings:n}=this,{width:r,height:i,left:o,top:a}=e,c=n==null?void 0:n[s];if(!c)return;const h=c.objectTransform;h.size.width=r,h.size.height=i,h.positionH.posOffset=o,h.positionV.posOffset=a}setZoomRatio(s=1){this.snapshot.settings==null?this.snapshot.settings={zoomRatio:s}:this.snapshot.settings.zoomRatio=1}}class y extends bi{constructor(e){var r;super(e);d(this,"_unitId");d(this,"headerModelMap",new Map);d(this,"footerModelMap",new Map);const n=6;this._unitId=(r=this.snapshot.id)!=null?r:R.generateRandomId(n),this._initializeHeaderFooterModel()}dispose(){this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()})}getRev(){var e;return(e=this.snapshot.rev)!=null?e:1}incrementRev(){this.snapshot.rev=this.getRev()+1}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw new Error("Cannot reset a document model with a different unit id!");this.snapshot={...de,...e},this._initializeHeaderFooterModel()}getSelfOrHeaderFooterModel(e){if(e!=null){if(this.headerModelMap.has(e))return this.headerModelMap.get(e);if(this.footerModelMap.has(e))return this.footerModelMap.get(e)}return this}getUnitId(){return this._unitId}apply(e){const n=[],r=new Ze;return r.reset(),e.forEach(i=>{if(i=R.deepClone(i),i.t===C.RETAIN){const{coverType:o,body:a,len:c,segmentId:h}=i;if(a!=null){const u=this._updateApply(a,c,r.cursor,o,h);n.push({...i,t:C.RETAIN,coverType:P.REPLACE,body:u})}else n.push({...i,t:C.RETAIN});r.moveCursor(c)}else if(i.t===C.INSERT){const{body:o,len:a,segmentId:c,line:h}=i;this._insertApply(o,a,r.cursor,c),r.moveCursor(a),n.push({t:C.DELETE,len:a,line:h,segmentId:c})}else if(i.t===C.DELETE){const{len:o,segmentId:a}=i,c=this._deleteApply(o,r.cursor,a);n.push({...i,t:C.INSERT,body:c})}else throw new Error(`Unknown action type for action: ${i}.`)}),n}sliceBody(e,n){const r=this.getBody();if(r!=null)return ue(r,e,n)}_updateApply(e,n,r,i=P.COVER,o){if(e==null)throw new Error("updateBody is none");const a=this.snapshot,c=Mt(a,o);if(c==null)throw new Error("no body has changed");return mi(c,e,n,r,i)}_deleteApply(e,n,r){const i=this.snapshot,o=Mt(i,r);if(o==null)throw new Error("no body has changed");return e<=0?{dataStream:""}:Ei(o,e,n)}_insertApply(e,n,r,i){const o=this.snapshot,a=Mt(o,i);if(n!==0){if(a==null)throw new Error("no body has changed");gi(a,e,n,r)}}_initializeHeaderFooterModel(){const{headers:e,footers:n}=this.getSnapshot();if(e)for(const r in e){const i=e[r];this.headerModelMap.set(r,new y(i))}if(n)for(const r in n){const i=n[r];this.footerModelMap.set(r,new y(i))}}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}}const Li="0.1.3",ft={sheetId:"",range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},wi={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Di={startRow:0,startColumn:0,endRow:0,endColumn:0},Ti={row:0,column:0},dn={id:"",sheetOrder:[],name:"",appVersion:Li,locale:et.ZH_CN,styles:{},sheets:{},resources:[]},Ft={ff:"Times New Roman",fs:14,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:lt.UNSPECIFIED,cl:{rgb:"#000"},bg:{rgb:"#fff"},ht:Q.UNSPECIFIED,vt:st.UNSPECIFIED,tb:nt.UNSPECIFIED,pd:{t:0,r:0,b:0,l:0}},_n={id:"default_slide",title:"defaultSlide",pageSize:{width:300,height:300}};var fn=(t=>(t.ARRAY_CONVERTOR="ARRAY_CONVERTOR",t.MATRIX_CONVERTOR="MATRIX_CONVERTOR",t))(fn||{});class En{constructor(s={}){d(this,"_styles");d(this,"_cacheMap",new vs(1e5));this._styles=s,this._generateCacheMap()}each(s){return Object.entries(this._styles).forEach(s),this}search(s,e){if(this._cacheMap.has(e))return this._cacheMap.get(e);const n=this._getExistingStyleId(s);return n||"-1"}get(s){return typeof s!="string"?s:(s=String(s),this._styles[s])}add(s,e){const n=R.generateRandomId(6);return this._styles[n]=s,this._cacheMap.set(e,n),n}setValue(s){if(s==null)return;const e=JSON.stringify(s),n=this.search(s,e);return n!=="-1"?n:this.add(s,e)}toJSON(){return this._styles}getStyleByCell(s){let e;s&&R.isObject(s.s)?e=s.s:e=(s==null?void 0:s.s)&&this.get(s.s);const n=s==null?void 0:s.interceptorStyle;return n?{...e,...n}:e}_generateCacheMap(){const{_styles:s,_cacheMap:e}=this;for(const n in s){const r=JSON.stringify(s[n]);e.set(r,n)}}_getExistingStyleId(s){const{_styles:e}=this;for(const n in e)if(R.diffValue(e[n],s))return n;return null}}function Ui(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 Mi(t){if(t.t!==void 0)return t.t;if(typeof t.v=="string")return ut.STRING;if(typeof t.v=="number")return ut.NUMBER;if(typeof t.v=="boolean")return ut.BOOLEAN}function Pi(t){if(t==null)return!0;const{v:s,f:e,si:n,p:r,s:i}=t;return!(!(s==null||typeof s=="string"&&s.length===0)||e!=null&&e.length>0||n!=null&&n.length>0||r!=null)}function Hi(t){return t!=null&&(typeof t=="string"||typeof t=="number"||typeof t=="boolean")}var _e=(t=>(t[t.SLIDE=0]="SLIDE",t[t.MASTER=1]="MASTER",t[t.LAYOUT=2]="LAYOUT",t[t.HANDOUT_MASTER=3]="HANDOUT_MASTER",t[t.NOTES_MASTER=4]="NOTES_MASTER",t))(_e||{}),gn=(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))(gn||{}),Rn=(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))(Rn||{});class Fi{constructor(s,e){d(this,"_columnData",{});this._config=s,this._columnData=e}getColumnData(){return this._columnData}getColVisible(s){const{_columnData:e}=this,n=e[s];return n?n.hd!==I.TRUE:!0}getHiddenCols(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getColVisible(o);r&&a?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:B.COLUMN}),n}getVisibleCols(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getColVisible(o);r&&!a?(r=!1,n.push({rangeType:B.COLUMN,startColumn:i,endColumn:o-1,startRow:0,endRow:0})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:e,rangeType:B.COLUMN}),n}getColumnDatas(s,e){const n={};let r=0;for(let i=s;i<s+e;i++){const o=this.getColumnOrCreate(i);n[r]=o,r++}return n}getSize(){return p(this._columnData)}getColumnWidth(s){const{_columnData:e}=this,n=this._config;let r=0;return r=(e[s]||{hd:I.FALSE,w:n.defaultColumnWidth}).w||n.defaultColumnWidth,r}getColumn(s){const e=this._columnData[s];if(e)return e}getColumnOrCreate(s){const{_columnData:e}=this,n=this._config,r=e[s];if(r)return r;const i={w:n.defaultColumnWidth,hd:I.FALSE};return this._columnData[s]=i,i}}function Wt(t,s){const{textRuns:e=[]}=s;let n=0;for(const i of e){const{ts:o={},st:a,ed:c}=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`)}n+=c-a}return s.dataStream.indexOf(`\r
5
+ `)===n?I.TRUE:I.FALSE}class it{constructor(s,e,n){d(this,"_range");d(this,"_worksheet");this._deps=n,this._range=e,this._worksheet=s}static foreach(s,e){const{startRow:n,startColumn:r,endRow:i,endColumn:o}=s;for(let a=n;a<=i;a++)for(let c=r;c<=o;c++)e(a,c)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=[];for(let o=s;o<=e;o++){const a=[];for(let c=n;c<=r;c++)a.push(this.getMatrix().getValue(o,c)||null);i.push(a)}return i}getMatrix(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=s;a<=e;a++)for(let c=n;c<=r;c++)o.setValue(a,c,i.getValue(a,c)||null);return o}getMatrixObject(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),o=new V;for(let a=s;a<=e;a++)for(let c=n;c<=r;c++)o.setValue(a-s,c-n,i.getValue(a,c)||{});return o}getA1Notation(){const{startRow:s,endRow:e,startColumn:n,endColumn:r}=this._range;let i,o;return n<r?(i=R.numToWord(n+1)+(s+1),o=R.numToWord(r+1)+(e+1)):(i=R.numToWord(r+1)+(e+1),o=R.numToWord(n+1)+(s+1)),i===o?`${i}`:`${i}:${o}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){const s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>{var i;const r=s.getStyleByCell(n);return((i=r==null?void 0:r.bg)==null?void 0:i.rgb)||Ft.bg.rgb}))}getCell(s,e){const{startRow:n,endRow:r,startColumn:i,endColumn:o}=this._range,a={startRow:n+s,endRow:n+s,startColumn:i+e,endColumn:i+e};return new it(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(s={}){return this.getObjectValues(s)[0][0]}getObjectValues(s={}){var a;const{startRow:e,endRow:n,startColumn:r,endColumn:i}=this._range,o=this._worksheet.getCellMatrix().getFragment(e,n,r,i).getData();if(s.isIncludeStyle){const c=this._deps.getStyles();for(let h=0;h<=n-e;h++)for(let u=0;u<=i-r;u++){if(o==null||((a=o==null?void 0:o[h])==null?void 0:a[u])==null)continue;const _=o[h][u].s;_&&(o[h][u].s=c.get(_))}}return o}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){const s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>{var i;const r=s.getStyleByCell(n);return((i=r==null?void 0:r.cl)==null?void 0:i.rgb)||Ft.cl.rgb}))}getFontFamilies(){return this._getStyles("ff")}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles("ul")}getUnderline(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Wt("ul",s.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,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Wt("st",s.body)===I.TRUE?{s:I.TRUE}:{s:I.FALSE}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles("st")}getFontSize(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?s.body.textRuns.some(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)!=null})?Math.max(...s.body.textRuns.map(r=>{var i;return((i=r==null?void 0:r.ts)==null?void 0:i.fs)||0})):this.getFontSizes()[0][0]:this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles("fs")}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles("bd")}getFontStyle(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Wt("it",s.body)===I.TRUE?St.ITALIC:St.NORMAL:this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles("it")}getFontWeight(){var e,n;const{p:s}=(e=this.getValue())!=null?e:{};return s&&Array.isArray((n=s.body)==null?void 0:n.textRuns)&&s.body.textRuns.length>0?Wt("bl",s.body)===I.TRUE?Nt.BOLD:Nt.NORMAL:this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles("bl")}getGridId(){return this._worksheet.getSheetId()}getHeight(){const{_range:s,_worksheet:e}=this,{startRow:n,endRow:r}=s;let i=0;for(let o=0;o<=r-n;o++){const a=e.getRowHeight(o);i+=a}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles("ht")}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){const{startColumn:s,endColumn:e}=this._range;return e-s+1}getNumRows(){const{startRow:s,endRow:e}=this._range;return e-s+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(s=>s.map(e=>(e==null?void 0:e.p)||""))}getRowIndex(){return this._range.startRow}getSheet(){return this._worksheet}getTextDirection(){return this.getTextDirections()[0][0]}getTextDirections(){return this._getStyles("td")}getTextRotation(){return this.getTextRotations()[0][0]}getTextRotations(){return this._getStyles("tr")}getTextStyle(){return this.getTextStyles()[0][0]}getTextStyles(){const s=this._deps.getStyles();return this.getValues().map(e=>e.map(n=>s.getStyleByCell(n)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles("vt")}getWidth(){const{_range:s,_worksheet:e}=this,{startColumn:n,endColumn:r}=s;let i=0;for(let o=0;o<=r-n;o++)i+=e.getColumnWidth(o);return i}getWrap(){return this.getWraps()[0][0]}getWraps(){return this._getStyles("tb")}getWrapStrategies(){return this._getStyles("tb")}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(s){it.foreach(this._range,s)}_getStyles(s){const e=this._deps.getStyles();return this.getValues().map(n=>n.map(r=>{const i=e&&e.getStyleByCell(r);return i&&i[s]||Ft[s]}))}}class Wi{constructor(s,e){d(this,"_rowData");this._config=s,this._rowData=e}getRowData(){return this._rowData}getRowDatas(s,e){const n={};let r=0;for(let i=s;i<s+e;i++){const o=this.getRowOrCreate(i);n[r]=o,r++}return n}getRowHeight(s,e=1){const{_rowData:n}=this,r=this._config;let i=0;for(let o=0;o<e;o++){const a=n[o+s]||{hd:I.FALSE,h:r.defaultRowHeight},{ia:c,ah:h,h:u=r.defaultRowHeight}=a;i+=(c==null||c===I.TRUE)&&typeof h=="number"?h:u}return i}getRow(s){return this._rowData[s]}getRowOrCreate(s){const{_rowData:e}=this,n=e[s];if(n)return n;const r=this._config,i={hd:I.FALSE,h:r.defaultRowHeight};return e[s]=i,i}getHiddenRows(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getRowVisible(o);r&&a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&!a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getVisibleRows(s=0,e=this.getSize()-1){const n=[];let r=!1,i=-1;for(let o=s;o<=e;o++){const a=this.getRowVisible(o);r&&!a?(r=!1,n.push({startRow:i,endRow:o-1,startColumn:0,endColumn:0,rangeType:B.ROW})):!r&&a&&(r=!0,i=o)}return r&&n.push({startRow:i,endRow:e,startColumn:0,endColumn:0,rangeType:B.ROW}),n}getRowVisible(s){const e=this.getRow(s);return e?e.hd!==I.TRUE:!0}getSize(){return p(this._rowData)}}const Bi="DEFAULT_WORKSHEET_ROW_COUNT",mn=1e3,ki="DEFAULT_WORKSHEET_COLUMN_COUNT",On=20,Gi="DEFAULT_WORKSHEET_ROW_HEIGHT",In=19,$i="DEFAULT_WORKSHEET_COLUMN_WIDTH",An=73,Vi="DEFAULT_WORKSHEET_ROW_TITLE_WIDTH",Cn=46,xi="DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT",Sn=20;function Nn(t){const s={name:"Sheet1",id:"sheet-01",tabColor:"",hidden:I.FALSE,rowCount:mn,columnCount:On,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:An,defaultRowHeight:In,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:I.TRUE,rowHeader:{width:Cn,hidden:I.FALSE},columnHeader:{height:Sn,hidden:I.FALSE},selections:["A1"],rightToLeft:I.FALSE};return Object.keys(s).forEach(e=>{const n=e;typeof t[n]>"u"&&(t[n]=s[n])}),t}class vn extends M{constructor(){super(...arguments);d(this,"_cellContentInterceptors",[]);d(this,"_rowFilteredInterceptors",[]);d(this,"_rowVisibleInterceptors",[]);d(this,"_colVisibleInterceptors",[])}dispose(){super.dispose(),this._cellContentInterceptors.length=0,this._rowFilteredInterceptors.length=0,this._rowVisibleInterceptors.length=0,this._colVisibleInterceptors.length=0}getCell(e,n){for(const r of this._cellContentInterceptors){const i=r.getCell(e,n);if(typeof i<"u")return i}return null}registerCellContentInterceptor(e){if(this._cellContentInterceptors.includes(e))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._cellContentInterceptors.push(e),L(()=>j(this._cellContentInterceptors,e))}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptors.includes(e))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowFilteredInterceptors.push(e),L(()=>j(this._rowFilteredInterceptors,e))}registerRowVisibleInterceptor(e){if(this._rowVisibleInterceptors.includes(e))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._rowVisibleInterceptors.push(e),L(()=>j(this._rowVisibleInterceptors,e))}registerColVisibleInterceptor(e){if(this._colVisibleInterceptors.includes(e))throw new Error("[SheetViewModel]: Interceptor already registered.");return this._colVisibleInterceptors.push(e),L(()=>j(this._colVisibleInterceptors,e))}}class Et{constructor(s,e){d(this,"_sheetId");d(this,"_snapshot");d(this,"_cellData");d(this,"_rowManager");d(this,"_columnManager");d(this,"_viewModel");var o;this._styles=e,this._snapshot=Nn(s);const{columnData:n,rowData:r,cellData:i}=this._snapshot;this._sheetId=(o=this._snapshot.id)!=null?o:R.generateRandomId(6),this._cellData=new V(i),this._rowManager=new Wi(this._snapshot,r),this._columnManager=new Fi(this._snapshot,n),this._viewModel=new vn}__interceptViewModel(s){s(this._viewModel)}getSnapshot(){return this._snapshot}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){const s=this.getCellMatrix(),e=this.getMergeData();let n=-1,r=-1,i=-1,o=-1,a=!1,c=!1;return s.forEach((h,u)=>{Object.keys(u).forEach(_=>{const f=+_,E=s.getValue(h,f),g=E!=null&&E.s?this._styles.get(E.s):null,m=(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||m)&&(a?n=Math.min(n,h):(n=h,a=!0),r=Math.max(r,h),c?i=Math.min(i,f):(c=!0,i=f),o=Math.max(o,f))})}),e.forEach(h=>{a?n=Math.min(n,h.startRow):(n=h.startRow,a=!0),r=Math.max(r,h.endRow),c?i=Math.min(i,h.startColumn):(i=h.startColumn,a=!0),o=Math.max(o,h.endColumn)}),!a||!c?null:{startColumn:i,startRow:n,endColumn:o,endRow:r}}getRowManager(){return this._rowManager}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}clone(){const{_snapshot:s}=this,e=R.deepClone(s);return new Et(e,this._styles)}getMergeData(){return this._snapshot.mergeData}getMergedCell(s,e){const n=this._snapshot.mergeData;for(let r=0;r<n.length;r++){const i=n[r];if(dt.intersects({startRow:s,startColumn:e,endRow:s,endColumn:e},i))return i}return null}getCell(s,e){return s<0||e<0?null:this._viewModel.getCell(s,e)}getCellRaw(s,e){return this.getCellMatrix().getValue(s,e)}getMatrixWithMergedCells(s,e,n,r){const i=this.getCellMatrix(),o=this._snapshot.mergeData.filter(c=>dt.intersects({startRow:s,startColumn:e,endRow:n,endColumn:r},c)),a=new V;return ie(s,n,e,r).forEach((c,h)=>{const u=i.getValue(c,h);u&&a.setValue(c,h,u)}),o.forEach(c=>{const{startColumn:h,startRow:u,endColumn:_,endRow:f}=c;ie(u,f,h,_).forEach((E,g)=>{E===u&&g===h&&a.setValue(E,g,{...i.getValue(E,g),rowSpan:f-u+1,colSpan:_-h+1}),(E!==u||g!==h)&&a.realDeleteValue(E,g)})}),a}getRange(s,e,n,r){return typeof s=="object"?new it(this,s,{getStyles:()=>this._styles}):new it(this,{startRow:s,startColumn:e,endColumn:r||e,endRow:n||s},{getStyles:()=>this._styles})}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){const{_snapshot:s}=this,{columnCount:e}=s;return e}getMaxRows(){const{_snapshot:s}=this,{rowCount:e}=s;return e}getRowCount(){return this._snapshot.rowCount}setRowCount(s){this._snapshot.rowCount=s}getColumnCount(){return this._snapshot.columnCount}setColumnCount(s){this._snapshot.columnCount=s}isSheetHidden(){return this._snapshot.hidden}hasHiddenGridlines(){const{_snapshot:s}=this,{showGridlines:e}=s;return e===0}getTabColor(){const{_snapshot:s}=this,{tabColor:e}=s;return e}getColumnWidth(s){return this.getColumnManager().getColumnWidth(s)}getRowHeight(s){return this.getRowManager().getRowHeight(s)}getRowVisible(s){return this.getRowManager().getRowVisible(s)}getHiddenRows(s,e){const n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(s,e);return r.forEach(i=>i.endColumn=n),r}getColVisible(s){return this._columnManager.getColVisible(s)}getHiddenCols(s,e){const n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(s,e);return r.forEach(i=>i.endRow=n),r}getVisibleRows(){const s=this.getRowCount();return this._rowManager.getVisibleRows(0,s-1)}getVisibleCols(){const s=this.getColumnCount();return this._columnManager.getVisibleCols(0,s-1)}isRightToLeft(){const{_snapshot:s}=this,{rightToLeft:e}=s;return e}getLastRowWithContent(){return this._cellData.getLength()-1}getLastColumnWithContent(){return this._cellData.getRange().endColumn}cellHasValue(s){return s&&(s.v!==void 0||s.f!==void 0||s.p!==void 0)}iterateByRow(s){const{startRow:e,startColumn:n,endRow:r,endColumn:i}=s,o=this;let a=e,c=n;return{next(){for(;;){if(c>i&&(a+=1,c=n),a>r)return{done:!0,value:void 0};const h=o.getCell(a,c),u=o.getMergedCell(a,c);if(u&&(!h||a!==u.startRow||c!==u.startColumn))c=u.endColumn+1;else if(!h)c+=1;else{const _={row:a,col:c,value:h};return u&&(_.colSpan=u.endColumn-u.startColumn+1,_.rowSpan=u.endRow-u.startRow+1),c+=1,{done:!1,value:_}}}}}}iterateByColumn(s){const{startRow:e,startColumn:n,endRow:r,endColumn:i}=s,o=this;let a=e,c=n;return{next(){for(;;){if(a>r&&(c+=1,a=e),c>i)return{done:!0,value:void 0};const h=o.getCell(a,c),u=o.getMergedCell(a,c);if(u&&(!h||a!==u.startRow||c!==u.startColumn))a=u.endRow+1;else if(!h)a+=1;else{const _={row:a,col:c,value:h};return u&&(_.colSpan=u.endColumn-u.startColumn+1,_.rowSpan=u.endRow-u.startRow+1),a+=1,{done:!1,value:_}}}}}}}var pi=Object.defineProperty,ji=Object.getOwnPropertyDescriptor,Ki=(t,s,e,n)=>{for(var r=n>1?void 0:n?ji(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&pi(s,e,r),r},Yi=(t,s)=>(e,n)=>s(e,n,t);function zi(t,s){return`${t.getUnitId()}|${s.getSheetId()}`}l.Workbook=class extends M{constructor(e={},n){super();d(this,"_sheetCreated$",new A.Subject);d(this,"sheetCreated$",this._sheetCreated$.asObservable());d(this,"_sheetDisposed$",new A.Subject);d(this,"sheetDisposed$",this._sheetDisposed$.asObservable());d(this,"_activeSheet$",new A.BehaviorSubject(null));d(this,"activeSheet$",this._activeSheet$.asObservable());d(this,"_worksheets");d(this,"_styles");d(this,"_snapshot");d(this,"_unitId");d(this,"_count");this._logService=n,this._snapshot=R.commonExtend(dn,e);const{styles:r}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=R.generateRandomId(6)),this._unitId=this._snapshot.id,this._styles=new En(r),this._count=1,this._worksheets=new Map,this._passWorksheetSnapshots()}get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._snapshot.name}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete()}save(){return R.deepClone(this._snapshot)}static isIRangeType(e){return typeof e=="string"||"startRow"in e||"row"in e}getSnapshot(){return this._snapshot}getName(){return this._snapshot.name}getUnitId(){return this._unitId}getRev(){var e;return(e=this._snapshot.rev)!=null?e:1}incrementRev(){this._snapshot.rev=this.getRev()+1}getShouldRenderLoopImmediately(){return this._snapshot.shouldStartRenderingImmediately!==!1}getContainer(){return this._snapshot.container}addWorksheet(e,n,r){const{sheets:i,sheetOrder:o}=this._snapshot;if(i[e])return!1;i[e]=r,o.splice(n,0,e);const a=new Et(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:n}=this._snapshot;return n.findIndex(r=>r===e)}getRawActiveSheet(){return this._activeSheet}getActiveSheet(){const e=this.getRawActiveSheet();if(e)return e;const n=this._snapshot.sheetOrder;for(let i=0,o=n.length;i<o;i++){const a=this._worksheets.get(n[i]);if(a&&a.isSheetHidden()!==I.TRUE)return this.setActiveSheet(a),a}const r=this._worksheets.get(n[0]);return this.setActiveSheet(r),r}setActiveSheet(e){this._activeSheet$.next(e)}removeSheet(e){var r;return this._worksheets.get(e)?(((r=this._activeSheet)==null?void 0:r.getSheetId())===e&&this.setActiveSheet(null),this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),delete this._snapshot.sheets[e],!0):!1}getActiveSheetIndex(){const{sheetOrder:e}=this._snapshot;return e.findIndex(n=>this._worksheets.get(n)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){const{sheetOrder:e}=this._snapshot;return e.map(n=>this._worksheets.get(n))}getSheetsName(){const{sheetOrder:e}=this._snapshot,n=[];return e.forEach(r=>{const i=this._worksheets.get(r);i&&n.push(i.getName())}),n}getSheetIndex(e){const{sheetOrder:n}=this._snapshot;return n.findIndex(r=>e.getSheetId()===r)}getSheetBySheetName(e){const{sheetOrder:n}=this._snapshot,r=n.find(i=>this._worksheets.get(i).getName()===e);return this._worksheets.get(r)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){const{sheetOrder:n}=this._snapshot;return this._worksheets.get(n[e])}getHiddenWorksheets(){return this.getSheets().filter(e=>e.getConfig().hidden===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 n=e;return{sheetId:"",range:{startRow:n.row[0],startColumn:n.column[0],endRow:n.row[1],endColumn:n.column[1]}}}return typeof e!="string"&&"startRow"in e?{sheetId:"",range:e}:ft}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().includes(e)}uniqueSheetName(e="Sheet1"){let n=e;for(;this.checkSheetName(n);)n=e+this._count,this._count++;return n}generateNewSheetName(e){let n=e+this._count;for(;this.checkSheetName(n);)n=e+this._count,this._count++;return n}_getCellRange(e){var u,_,f,E,g;let n="",r="";if(e.indexOf("!")>-1){const m=e.split("!");n=m[0],r=m[1],n=n.replace(/\\'/g,"'").replace(/''/g,"'"),n.substring(0,1)==="'"&&n.substring(n.length-1,1)==="'"&&(n=n.substring(1,n.length-1))}else r=e;if(r.indexOf(":")===-1){const m=Number.parseInt(r.replace(/[^0-9]/g,""),10)-1,S=R.ABCatNum(r.replace(/[^A-Za-z]/g,""));return!Number.isNaN(m)&&!Number.isNaN(S)?{sheetId:n,range:{startRow:m,endRow:m,startColumn:S,endColumn:S}}:ft}r=r.split(":");const i=[0,0],o=[0,0],a=((u=this.getSheetBySheetName(n))==null?void 0:u.getMaxRows())||((_=this.getActiveSheet())==null?void 0:_.getMaxRows()),c=((f=this.getSheetBySheetName(n))==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]=R.ABCatNum(r[0].replace(/[^A-Za-z]/g,"")),o[1]=R.ABCatNum(r[1].replace(/[^A-Za-z]/g,"")),Number.isNaN(o[0])&&(o[0]=0),Number.isNaN(o[1])&&(o[1]=c),o[0]>o[1])?ft:{sheetId:((g=this.getSheetBySheetName(n))==null?void 0:g.getSheetId())||"",range:{startRow:i[0],endRow:i[1],startColumn:o[0],endColumn:o[1]}}}_passWorksheetSnapshots(){const{_snapshot:e,_worksheets:n}=this,{sheets:r,sheetOrder:i}=e;if(R.isEmptyObject(r)){const o=R.generateRandomId();r[o]={id:o}}for(const o in r){const a=r[o],{name:c}=a;a.name=this.uniqueSheetName(c),a.name!==c&&this._logService.debug("[Workbook]",`The worksheet name ${c} is duplicated, we changed it to ${a.name}. Please fix the problem in your snapshot.`);const h=new Et(a,this._styles);n.set(o,h),i.includes(o)||i.push(o)}}},l.Workbook=Ki([Yi(1,J)],l.Workbook);class fe{constructor(s){d(this,"_snapshot");d(this,"_unitId");var e;this._snapshot={..._n,...s},this._unitId=(e=this._snapshot.id)!=null?e:R.generateRandomId(6)}getSnapshot(){return this._snapshot}getUnitId(){return this._unitId}getPages(){var s;return(s=this._snapshot.body)==null?void 0:s.pages}getPageOrder(){var s;return(s=this._snapshot.body)==null?void 0:s.pageOrder}getPage(s){const e=this.getPages();return e==null?void 0:e[s]}getElementsByPage(s){var e;return(e=this.getPage(s))==null?void 0:e.pageElements}getElement(s,e){var n;return(n=this.getElementsByPage(s))==null?void 0:n[e]}getPageSize(){return this._snapshot.pageSize}addPage(){return{id:"cover_1",pageType:_e.SLIDE,zIndex:1,title:"cover",description:"this is first page, cover",pageBackgroundFill:{rgb:"rgb(255,255,255)"},pageElements:{}}}}const Bt="FOCUSING_SHEET",Ee="FOCUSING_DOC",ge="FOCUSING_SLIDE",Xi="FOCUSING_EDITOR_BUT_HIDDEN",bn="EDITOR_ACTIVATED",qi="FOCUSING_EDITOR_INPUT_FORMULA",Ln="FOCUSING_FORMULA_EDITOR",Ji="FOCUSING_UNIVER_EDITOR",Qi="FOCUSING_UNIVER_EDITOR_SINGLE_MODE";var Zi=Object.defineProperty,yi=Object.getOwnPropertyDescriptor,to=(t,s,e,n)=>{for(var r=n>1?void 0:n?yi(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Zi(s,e,r),r},eo=(t,s)=>(e,n)=>s(e,n,t),wn=(t=>(t[t.UNKNOWN=0]="UNKNOWN",t[t.DOC=1]="DOC",t[t.SHEET=2]="SHEET",t[t.SLIDE=3]="SLIDE",t))(wn||{});const ot=O.createIdentifier("univer.current");l.UniverInstanceService=class extends M{constructor(e,n){super();d(this,"_focused",null);d(this,"_focused$",new A.BehaviorSubject(null));d(this,"focused$",this._focused$.asObservable());d(this,"_currentSheet$",new A.BehaviorSubject(null));d(this,"currentSheet$",this._currentSheet$.asObservable());d(this,"_currentDoc$",new A.BehaviorSubject(null));d(this,"currentDoc$",this._currentDoc$.asObservable());d(this,"_currentSlide$",new A.BehaviorSubject(null));d(this,"currentSlide$",this._currentSlide$.asObservable());d(this,"_sheetAdded$",new A.Subject);d(this,"sheetAdded$",this._sheetAdded$.asObservable());d(this,"_docAdded$",new A.Subject);d(this,"docAdded$",this._docAdded$.asObservable());d(this,"_slideAdded$",new A.Subject);d(this,"slideAdded$",this._slideAdded$.asObservable());d(this,"_sheetDisposed$",new A.Subject);d(this,"sheetDisposed$",this._sheetDisposed$.asObservable());d(this,"_docDisposed$",new A.Subject);d(this,"docDisposed$",this._docDisposed$.asObservable());d(this,"_slideDisposed$",new A.Subject);d(this,"slideDisposed$",this._slideDisposed$.asObservable());d(this,"_sheets",[]);d(this,"_docs",[]);d(this,"_slides",[]);this._handler=e,this._contextService=n}dispose(){super.dispose(),this._focused$.complete(),this._currentDoc$.complete(),this._currentSheet$.complete(),this._currentSlide$.complete(),this._sheetAdded$.complete(),this._docAdded$.complete(),this._slideAdded$.complete(),this._sheetDisposed$.complete(),this._docDisposed$.complete(),this._slideDisposed$.complete()}createDoc(e){return this._handler.createUniverDoc(e)}createSheet(e){return this._handler.createUniverSheet(e)}createSlide(e){return this._handler.createUniverSlide(e)}addSheet(e){this._sheets.push(e),this._sheetAdded$.next(e),this.setCurrentUniverSheetInstance(e.getUnitId())}changeDoc(e,n){const r=this._docs.find(i=>i.getUnitId()===e);if(r!=null){const i=this._docs.indexOf(r);this._docs.splice(i,1)}this.addDoc(n)}addDoc(e){this._docs.push(e),this._docAdded$.next(e),this.setCurrentUniverDocInstance(e.getUnitId())}addSlide(e){this._slides.push(e),this._slideAdded$.next(e),this.setCurrentUniverSlideInstance(e.getUnitId())}getUniverSheetInstance(e){return this._sheets.find(n=>n.getUnitId()===e)}getUniverDocInstance(e){return this._docs.find(n=>n.getUnitId()===e)}getUniverSlideInstance(e){return this._slides.find(n=>n.getUnitId()===e)}getAllUniverSheetsInstance(){return this._sheets}getAllUniverDocsInstance(){return this._docs}getAllUniverSlidesInstance(){return this._slides}setCurrentUniverSheetInstance(e){this._currentSheet$.next(this.getUniverSheetInstance(e)||null)}setCurrentUniverSlideInstance(e){this._currentSlide$.next(this.getUniverSlideInstance(e)||null)}setCurrentUniverDocInstance(e){this._currentDoc$.next(this.getUniverDocInstance(e)||null)}getCurrentUniverSheetInstance(){const e=this._currentSheet$.getValue();if(!e)throw new Error("No current sheet!");return e}getCurrentUniverDocInstance(){const e=this._currentDoc$.getValue();if(!e)throw new Error("No current doc!");return e}getCurrentUniverSlideInstance(){const e=this._currentSlide$.getValue();if(!e)throw new Error("No current slide!");return e}focusUniverInstance(e){e&&(this._focused=this.getUniverSheetInstance(e)||this.getUniverDocInstance(e)||this.getUniverSlideInstance(e)||null),this._focused$.next(e),[Ee,Bt,ge].forEach(n=>this._contextService.setContextValue(n,!1)),this._focused instanceof l.Workbook?this._contextService.setContextValue(Bt,!0):this._focused instanceof y?this._contextService.setContextValue(Ee,!0):this._focused instanceof fe&&this._contextService.setContextValue(ge,!0)}getFocusedUniverInstance(){return this._focused}getDocumentType(e){if(this.getUniverDocInstance(e))return 1;if(this.getUniverSheetInstance(e))return 2;if(this.getUniverSlideInstance(e))return 3;throw new Error(`[UniverInstanceService]: No document with unitId ${e}`)}disposeDocument(e){const n=this.getUniverDocInstance(e);if(n){const o=this._docs.indexOf(n);return this._docs.splice(o,1),this._docDisposed$.next(n),!0}const r=this.getUniverSheetInstance(e);if(r){const o=this._sheets.indexOf(r);return this._sheets.splice(o,1),this._sheetDisposed$.next(r),!0}const i=this.getUniverSlideInstance(e);if(i){const o=this._slides.indexOf(i);return this._slides.splice(o,1),this._slideDisposed$.next(i),!0}return!1}},l.UniverInstanceService=to([eo(1,tt)],l.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 so={0:"Starting",1:"Ready",2:"Rendered",3:"Steady"},kt=new Map;function Re(t,s){return function(r){me(t,s)}}function me(t,s){kt.has(t)||kt.set(t,[]),kt.get(t).push(s)}var no=Object.defineProperty,ro=Object.getOwnPropertyDescriptor,Dn=(t,s,e,n)=>{for(var r=n>1?void 0:n?ro(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&no(s,e,r),r},Oe=(t,s)=>(e,n)=>s(e,n,t);l.LifecycleService=class extends M{constructor(e){super();d(this,"_lifecycle$",new A.BehaviorSubject(w.Starting));d(this,"lifecycle$",this._lifecycle$.asObservable());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!");e!==this.stage&&(this._reportProgress(e),this._lifecycle$.next(e))}dispose(){this._lifecycle$.complete(),super.dispose()}subscribeWithPrevious(){return new A.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 "${so[e]}".`)}},l.LifecycleService=Dn([Oe(0,J)],l.LifecycleService),l.LifecycleInitializerService=class extends M{constructor(e,n){super();d(this,"_started",!1);this._lifecycleService=e,this._injector=n}start(){this._started||(this._started=!0,this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(e=>this.initModulesOnStage(e)))))}initModulesOnStage(e){const n=kt.get(e);n==null||n.forEach(r=>{this._injector.has(r)&&this._injector.get(r)})}},l.LifecycleInitializerService=Dn([Oe(0,O.Inject(l.LifecycleService)),Oe(1,O.Inject(O.Injector))],l.LifecycleInitializerService);class gt extends M{constructor(){super();d(this,"_currentLocale",et.ZH_CN);d(this,"_locales",null);d(this,"localeChanged$",new A.Subject);d(this,"t",(e,...n)=>{if(!this._locales)throw new Error("Locale not initialized");function r(a,c){const h=c.shift();if(h&&a&&h in a){const u=a[h];return c.length>0&&(typeof u=="object"||Array.isArray(u))?r(u,c):u}return null}const i=e.split("."),o=r(this._locales[this._currentLocale],i);if(typeof o=="string"){let a=o;return n.forEach((c,h)=>{a=a.replace(`{${h}}`,c)}),a}else return e});this.disposeWithMe(L(()=>this.localeChanged$.complete()))}load(e){var n;this._locales=R.deepMerge((n=this._locales)!=null?n:{},e)}setLocale(e){this._currentLocale=e,this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}}const Ie=O.createIdentifier("resource-manager-service"),Tn=O.createIdentifier("ResourcePersistenceService");me(w.Ready,Tn);var io=Object.defineProperty,oo=Object.getOwnPropertyDescriptor,ao=(t,s,e,n)=>{for(var r=n>1?void 0:n?oo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&io(s,e,r),r},Un=(t,s)=>(e,n)=>s(e,n,t);const Ae=O.createIdentifier("univer.permission-service"),Mn="PERMISSION";l.PermissionService=class extends M{constructor(e,n){super();d(this,"_permissionPointMap",new Map);d(this,"deletePermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e);if(r){const i=r.get(n);i&&(i.complete(),this._permissionPointMap.delete(n))}});d(this,"addPermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e)||new Map;return r.has(n.id)?!1:(r.set(n.id,new A.BehaviorSubject(n)),this._permissionPointMap.set(e,r),!0)});d(this,"updatePermissionPoint",(e,n,r)=>{const i=this._permissionPointMap.get(e);if(!i)return;const o=i.get(n);if(o){const a=o.getValue();a.value=r,a.status=re.DONE,o.next(a)}});d(this,"getPermissionPoint",(e,n)=>{const r=this._permissionPointMap.get(e);if(!r)return;const i=r.get(n);if(i)return i.getValue()});this._resourceManagerService=e,this._univerInstanceService=n}_init(){this.disposeWithMe(L(this._univerInstanceService.sheetAdded$.subscribe(e=>{this._resourceManagerService.registerPluginResource(e.getUnitId(),Mn,{onChange:(n,r)=>{r.forEach(i=>{this.getPermissionPoint(n,i.id)?this.updatePermissionPoint(n,i.id,i.value):this.addPermissionPoint(n,i)})},toJson:n=>this._toJson(n),parseJson:n=>this._parseJson(n)})}))),this.disposeWithMe(L(this._univerInstanceService.sheetDisposed$.subscribe(e=>{this._resourceManagerService.disposePluginResource(e.getUnitId(),Mn)})))}_toJson(e){const n=this._permissionPointMap.get(e);let r=[];return n&&(r=[...n.keys()].reduce((i,o)=>{const a=n.get(o);return a&&i.push(a.getValue()),i},[])),JSON.stringify(r)}_parseJson(e){return JSON.parse(e)}composePermission$(e,n){const r=this._permissionPointMap.get(e),i=n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.asObservable()});return A.combineLatest(i).pipe(qn.map(o=>(o.every(a=>this._permissionPointMap.get(a.id)),o)))}composePermission(e,n){const r=this._permissionPointMap.get(e);return n.map(o=>{const a=r==null?void 0:r.get(o);if(!a)throw new Error(`${o} permissionPoint is not exist`);return a.getValue()})}},l.PermissionService=ao([Re(w.Starting,l.PermissionService),Un(0,O.Inject(Ie)),Un(1,O.Inject(ot))],l.PermissionService);const Pn="univer.editable";class Gt extends bs{constructor(e){super();d(this,"id",Pn);d(this,"value",!0);d(this,"unitID");this.unitID=e}}var co=Object.defineProperty,lo=Object.getOwnPropertyDescriptor,uo=(t,s,e,n)=>{for(var r=n>1?void 0:n?lo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&co(s,e,r),r},Hn=(t,s)=>(e,n)=>s(e,n,t);l.UniverPermissionService=class extends M{constructor(s,e){super(),this._permissionService=s,this._univerInstanceService=e,this._init()}_init(){this._univerInstanceService.sheetAdded$.subscribe(s=>{const e=new Gt(s.getUnitId());this._permissionService.addPermissionPoint(s.getUnitId(),e)})}getEditable(s){let e=s;e||(e=this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId());const n=new Gt(e),r=this._permissionService.getPermissionPoint(e,n.id);return r==null?void 0:r.value}setEditable(s,e){const n=new Gt(s);this._permissionService.updatePermissionPoint(s,n.id,e)}},l.UniverPermissionService=uo([Re(w.Starting,l.UniverPermissionService),Hn(0,O.Inject(Ae)),Hn(1,O.Inject(ot))],l.UniverPermissionService);class Fn extends M{constructor(){super(...arguments);d(this,"_resourceMap",new Map);d(this,"_register$",new A.Subject);d(this,"register$",this._register$.asObservable())}getAllResource(e){const n=this._resourceMap.get(e);return n?[...n.keys()].reduce((r,i)=>{const o=n.get(i);return o&&r.push({unitID:e,resourceName:i,hook:o}),r},[]):[]}registerPluginResource(e,n,r){const i=this._resourceMap.get(e)||new Map;if(i.has(n))throw new Error("the pluginName is registered");return i.set(n,r),this._resourceMap.set(e,i),this._register$.next({unitID:e,resourceName:n,hook:r}),L(()=>i.delete(n))}disposePluginResource(e,n){const r=this._resourceMap.get(e);r==null||r.delete(n)}dispose(){this._register$.complete(),this._resourceMap.clear()}}class Ce extends M{constructor(){super();d(this,"_currentTheme");d(this,"_currentTheme$",new A.BehaviorSubject({}));d(this,"currentTheme$",this._currentTheme$.asObservable());this.disposeWithMe(L(()=>this._currentTheme$.complete()))}getCurrentTheme(){if(!this._currentTheme)throw new Error("[ThemeService]: current theme is not set!");return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}}const Wn="__defaultDocumentNormalEditorSpecialUnitId_20231006__",Bn="__defaultDocumentFormulaBarEditorSpecialUnitId_20231012__",ho=`\r
6
+ `;var _o=Object.defineProperty,fo=Object.getOwnPropertyDescriptor,Eo=(t,s,e,n)=>{for(var r=n>1?void 0:n?fo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&_o(s,e,r),r},Se=(t,s)=>(e,n)=>s(e,n,t);const $t=O.createIdentifier("univer.undo-redo.service"),go=20;class kn{dispose(){}async dispatchToHandlers(){return!1}}const Gn="univer.command.redo",$n="univer.command.undo",Vn=new class extends kn{constructor(){super(...arguments);d(this,"type",At.COMMAND);d(this,"id",$n)}async handler(s){const e=s.get($t),n=e.pitchTopUndoElement();if(!n)return!1;const r=s.get(ct);return Xt(n.undoMutations,r)?(e.popUndoToRedo(),!0):!1}},xn=new class extends kn{constructor(){super(...arguments);d(this,"type",At.COMMAND);d(this,"id",Gn)}async handler(s){const e=s.get($t),n=e.pitchTopRedoElement();if(!n)return!1;const r=s.get(ct);return Xt(n.redoMutations,r)?(e.popRedoToUndo(),!0):!1}};l.LocalUndoRedoService=class extends M{constructor(e,n,r){super();d(this,"undoRedoStatus$");d(this,"_undoRedoStatus$",new A.BehaviorSubject({undos:0,redos:0}));d(this,"_undoStacks",new Map);d(this,"_redoStacks",new Map);d(this,"_batchingStatus",new Map);this._univerInstanceService=e,this._commandService=n,this._contextService=r,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(Vn)),this.disposeWithMe(this._commandService.registerCommand(xn)),this.disposeWithMe(L(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(L(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}pushUndoRedo(e){const{unitID:n}=e,r=this._getRedoStack(n,!0),i=this._getUndoStack(n,!0);if(r.length=0,this._batchingStatus.has(e.unitID)){const a=this._batchingStatus.get(e.unitID),c=this._pitchUndoElement(e.unitID);a===0||!c?(o(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(c,e)}else o(e);function o(a){i.push(a),i.length>go&&i.splice(0,1)}this._updateStatus()}clearUndoRedo(e){const n=this._getRedoStack(e);n&&(n.length=0);const r=this._getUndoStack(e);r&&(r.length=0),this._updateStatus()}pitchTopUndoElement(){const e=this._getFocusedUniverInstanceId();return this._pitchUndoElement(e)}pitchTopRedoElement(){const e=this._getFocusedUniverInstanceId();return this._pitchRedoElement(e)}_pitchUndoElement(e){const n=this._getUndoStack(e);return n!=null&&n.length?n[n.length-1]:null}_pitchRedoElement(e){const n=this._getRedoStack(e);return n!=null&&n.length?n[n.length-1]:null}popUndoToRedo(){const n=this._getUndoStackForFocused().pop();n&&(this._getRedoStackForFocused().push(n),this._updateStatus())}popRedoToUndo(){const n=this._getRedoStackForFocused().pop();n&&(this._getUndoStackForFocused().push(n),this._updateStatus())}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e))throw new Error("[LocalUndoRedoService]: cannot batching undo redo twice at the same time!");return this._batchingStatus.set(e,0),L(()=>this._batchingStatus.delete(e))}_updateStatus(){var i,o;const e=this._getFocusedUniverInstanceId(),n=e&&((i=this._undoStacks.get(e))==null?void 0:i.length)||0,r=e&&((o=this._redoStacks.get(e))==null?void 0:o.length)||0;this._undoRedoStatus$.next({undos:n,redos:r})}_getUndoStack(e,n=!1){let r=this._undoStacks.get(e);return!r&&n&&(r=[],this._undoStacks.set(e,r)),r||null}_getRedoStack(e,n=!1){let r=this._redoStacks.get(e);return!r&&n&&(r=[],this._redoStacks.set(e,r)),r||null}_getUndoStackForFocused(){const e=this._getFocusedUniverInstanceId();if(!e)throw new Error("No focused univer instance!");return this._getUndoStack(e,!0)}_getRedoStackForFocused(){const e=this._getFocusedUniverInstanceId();if(!e)throw new Error("No focused univer instance!");return this._getRedoStack(e,!0)}_tryBatchingElements(e,n){e.redoMutations.push(...n.redoMutations),e.undoMutations.push(...n.undoMutations)}_getFocusedUniverInstanceId(){var o,a,c,h;let e="";const n=this._contextService.getContextValue(Bt),r=this._contextService.getContextValue(Ln),i=this._contextService.getContextValue(bn);return n?r?e=Bn:i?e=Wn:e=(a=(o=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:o.getUnitId())!=null?a:"":e=(h=(c=this._univerInstanceService.getFocusedUniverInstance())==null?void 0:c.getUnitId())!=null?h:"",e}},l.LocalUndoRedoService=Eo([Se(0,ot),Se(1,ct),Se(2,tt)],l.LocalUndoRedoService);class Vt extends M{constructor(){super(...arguments);d(this,"_started",!1)}addPlugins(e){if(this._started){const n=e.map(([r,i])=>this._initPlugin(r,i));this._pluginsRunLifecycle(n,w.Starting),setTimeout(()=>this._takePluginsThroughLifecycle(n,!0))}else{const n=e.map(([r,i])=>this._initPlugin(r,i));this._takePluginsThroughLifecycle(n),this._started=!0}}_takePluginsThroughLifecycle(e,n=!1){this.disposeWithMe(L(this._lifecycleService.subscribeWithPrevious().subscribe(r=>{n&&r===w.Starting||this._pluginsRunLifecycle(e,r)})))}_pluginsRunLifecycle(e,n){e.forEach(r=>{switch(n){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(n)}_initPlugin(e,n){return this._injector.createInstance(e,n)}}var Ro=Object.defineProperty,mo=Object.getOwnPropertyDescriptor,Oo=(t,s,e,n)=>{for(var r=n>1?void 0:n?mo(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Ro(s,e,r),r},Ne=(t,s)=>(e,n)=>s(e,n,t);l.UniverDoc=class extends Vt{constructor(s,e,n){super(),this._injector=s,this._lifecycleService=e,this._lifecycleInitializerService=n}createDoc(s){return this._injector.createInstance(y,s)}},l.UniverDoc=Oo([Ne(0,O.Inject(O.Injector)),Ne(1,O.Inject(l.LifecycleService)),Ne(2,O.Inject(l.LifecycleInitializerService))],l.UniverDoc);var Io=Object.defineProperty,Ao=Object.getOwnPropertyDescriptor,Co=(t,s,e,n)=>{for(var r=n>1?void 0:n?Ao(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&Io(s,e,r),r},ve=(t,s)=>(e,n)=>s(e,n,t);l.UniverSheet=class extends Vt{constructor(s,e,n){super(),this._injector=s,this._lifecycleService=e,this._lifecycleInitializerService=n}createSheet(s){return this._injector.createInstance(l.Workbook,s)}},l.UniverSheet=Co([ve(0,O.Inject(O.Injector)),ve(1,O.Inject(l.LifecycleService)),ve(2,O.Inject(l.LifecycleInitializerService))],l.UniverSheet);var So=Object.defineProperty,No=Object.getOwnPropertyDescriptor,vo=(t,s,e,n)=>{for(var r=n>1?void 0:n?No(s,e):s,i=t.length-1,o;i>=0;i--)(o=t[i])&&(r=(n?o(s,e,r):o(r))||r);return n&&r&&So(s,e,r),r},be=(t,s)=>(e,n)=>s(e,n,t);l.UniverSlide=class extends Vt{constructor(s,e,n){super(),this._injector=s,this._lifecycleService=e,this._lifecycleInitializerService=n}createSlide(s){return this._injector.createInstance(fe,s)}},l.UniverSlide=vo([be(0,O.Inject(O.Injector)),be(1,O.Inject(l.LifecycleService)),be(2,O.Inject(l.LifecycleInitializerService))],l.UniverSlide);const bo=200;class Lo extends Vt{constructor(e={}){super();d(this,"_injector");d(this,"_univerPluginStore",new Zn);d(this,"_univerPluginRegistry",new yn);d(this,"_univerSheet",null);d(this,"_univerDoc",null);d(this,"_univerSlide",null);d(this,"_initLazyPluginsTimer");this._injector=this._initDependencies();const{theme:n,locale:r,locales:i,logLevel:o}=e;n&&this._injector.get(Ce).setTheme(n),i&&this._injector.get(gt).load(i),r&&this._injector.get(gt).setLocale(r),o&&this._injector.get(J).setLogLevel(o)}get _univerInstanceService(){return this._injector.get(ot)}get _lifecycleService(){return this._injector.get(l.LifecycleService)}get _lifecycleInitializerService(){return this._injector.get(l.LifecycleInitializerService)}__getInjector(){return this._injector}dispose(){this._injector.dispose(),super.dispose()}setLocale(e){this._injector.get(gt).setLocale(e)}createUniverSheet(e){let n;const r=()=>{n=this._univerSheet.createSheet(e),this._univerInstanceService.addSheet(n)};if(this._univerSheet)r();else{this._tryProgressToStart();const i=this._univerSheet=this._injector.createInstance(l.UniverSheet),o=this._univerPluginRegistry.getRegisterPlugins(T.Sheet).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(T.Sheet),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverDoc(e){let n;const r=()=>{n=this._univerDoc.createDoc(e),this._univerInstanceService.addDoc(n)};if(this._univerDoc)r();else{this._tryProgressToStart();const i=this._univerDoc=this._injector.createInstance(l.UniverDoc),o=this._univerPluginRegistry.getRegisterPlugins(T.Doc).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(T.Doc),i.addPlugins(o),r(),this._tryProgressToReady()}return n}createUniverSlide(e){let n;const r=()=>{n=this._univerSlide.createSlide(e),this._univerInstanceService.addSlide(n)};if(this._univerSlide)r();else{this._tryProgressToStart();const i=this._univerSlide=this._injector.createInstance(l.UniverSlide),o=this._univerPluginRegistry.getRegisterPlugins(T.Slide).map(a=>[a.plugin,a.options]);this._univerPluginRegistry.clearPluginsOfType(T.Slide),i.addPlugins(o),r(),this._tryProgressToReady()}return n}_initDependencies(){return new O.Injector([[ot,{useFactory:e=>new l.UniverInstanceService({createUniverDoc:n=>this.createUniverDoc(n),createUniverSheet:n=>this.createUniverSheet(n),createUniverSlide:n=>this.createUniverSlide(n)},e),deps:[tt]}],[qe],[gt],[Ce],[l.LifecycleService],[l.LifecycleInitializerService],[Ae,{useClass:l.PermissionService}],[l.UniverPermissionService],[J,{useClass:je,lazy:!0}],[ct,{useClass:l.CommandService,lazy:!0}],[$t,{useClass:l.LocalUndoRedoService,lazy:!0}],[ze,{useClass:Xe}],[tt,{useClass:xe}],[Qe,{useClass:Je,lazy:!0}],[Ie,{useClass:Fn,lazy:!0}]])}_tryProgressToStart(){this._started||(this._injector.get(l.LifecycleInitializerService).start(),this._started=!0)}_tryProgressToReady(){this._injector.get(l.LifecycleService).stage<w.Ready&&(this._injector.get(l.LifecycleService).stage=w.Ready,this._univerPluginStore.forEachPlugin(n=>n.onReady()))}registerPlugin(e,n){if(e.type===T.Univer)this._registerUniverPlugin(e,n);else if(e.type===T.Sheet)this._registerSheetsPlugin(e,n);else if(e.type===T.Doc)this._registerDocsPlugin(e,n);else if(e.type===T.Slide)this._registerSlidesPlugin(e,n);else throw new Error(`Unimplemented plugin system for business: "${e.type}".`);if(this._started)return this._scheduleInitPluginAfterStarted()}_scheduleInitPluginAfterStarted(){this._initLazyPluginsTimer===void 0&&(this._initLazyPluginsTimer=setTimeout(()=>this._flushLazyPlugins(),bo))}_flushLazyPlugins(){this._initLazyPluginsTimer=void 0;const e=this._univerPluginRegistry.getRegisterPlugins(T.Univer);if(e.length){this._univerPluginRegistry.clearPluginsOfType(T.Univer);const n=e.map(r=>this._injector.createInstance(r.plugin,r.options));this._takePluginsThroughLifecycle(n)}if(this._univerSheet){const n=this._univerPluginRegistry.getRegisterPlugins(T.Sheet).map(r=>[r.plugin,r.options]);n.length&&(this._univerSheet.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(T.Sheet))}if(this._univerDoc){const n=this._univerPluginRegistry.getRegisterPlugins(T.Doc).map(r=>[r.plugin,r.options]);n.length&&(this._univerDoc.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(T.Doc))}if(this._univerSlide){const n=this._univerPluginRegistry.getRegisterPlugins(T.Slide).map(r=>[r.plugin,r.options]);n.length&&(this._univerSlide.addPlugins(n),this._univerPluginRegistry.clearPluginsOfType(T.Slide))}}_registerUniverPlugin(e,n){if(this._started)this._univerPluginRegistry.registerPlugin(e,n);else{const r=this._injector.createInstance(e,n);r.onStarting(this._injector),this._univerPluginStore.addPlugin(r)}}_registerSheetsPlugin(e,n){this._univerPluginRegistry.registerPlugin(e,n)}_registerDocsPlugin(e,n){this._univerPluginRegistry.registerPlugin(e,n)}_registerSlidesPlugin(e,n){this._univerPluginRegistry.registerPlugin(e,n)}}function wo(t,s=16){let e=0,n=null;return function(...i){const o=Date.now();o-e<s?(n&&clearTimeout(n),n=setTimeout(()=>{e=o,t.apply(this,i)},s)):(e=o,t.apply(this,i))}}function Do(t){const s=new MessageChannel;let e=!1;return s.port1.onmessage=()=>{e||t()},s.port2.postMessage(null),()=>{e=!0}}class Le{constructor(s){d(this,"_index",0);d(this,"_offset",0);this._actions=s}hasNext(){return this.peekLength()<Number.POSITIVE_INFINITY}next(s){s||(s=Number.POSITIVE_INFINITY);const e=this._actions[this._index];if(e){const n=this._offset,r=e.len;return s>=r-n?(s=r-n,this._index+=1,this._offset=0):this._offset+=s,e.t===C.DELETE||e.t===C.RETAIN&&e.body==null?R.deepClone({...e,len:s}):R.deepClone({...e,len:s,body:ue(e.body,n,n+s)})}else return{t:C.RETAIN,len:Number.POSITIVE_INFINITY}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:Number.POSITIVE_INFINITY}peekType(){const s=this._actions[this._index];return s?s.t:C.RETAIN}rest(){if(this.hasNext()){if(this._offset===0)return this._actions.slice(this._index);{const s=this._offset,e=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=s,this._index=e,[n].concat(r)}}else return[]}}function pn(t){return Object.keys(t).length===1}class xt{constructor(){d(this,"_actions",[])}static compose(s,e){const n=new Le(s),r=new Le(e),i=new xt;for(;n.hasNext()||r.hasNext();)if(r.peekType()===C.INSERT)i.push(r.next());else if(n.peekType()===C.DELETE)i.push(n.next());else{const o=Math.min(n.peekLength(),r.peekLength()),a=n.next(o),c=r.next(o);a.t===C.INSERT&&c.t===C.RETAIN?c.body==null?i.push(a):i.push({...a,body:he(a.body,c.body,c.coverType)}):a.t===C.RETAIN&&c.t===C.RETAIN?a.body==null&&c.body==null?i.push(a.len!==Number.POSITIVE_INFINITY?a:c):a.body&&c.body?i.push({...a,body:he(a.body,c.body,c.coverType)}):i.push(a.body?a:c):a.t===C.RETAIN&&c.t===C.DELETE?i.push(c):a.t===C.INSERT&&(c.t,C.DELETE)}return i.trimEndUselessRetainAction(),i.serialize()}insert(s,e,n=""){const r={t:C.INSERT,body:e,len:s,line:0,segmentId:n};return this.push(r),this}retain(s,e="",n,r){const i={t:C.RETAIN,len:s,segmentId:e};return n!=null&&(i.body=n),r!=null&&(i.coverType=r),this.push(i),this}delete(s,e=""){const n={t:C.DELETE,len:s,line:0,segmentId:e};return this.push(n),this}serialize(){return this._actions}push(...s){if(s.length>1){for(const i of s)this.push(i);return this}let e=this._actions.length,n=this._actions[e-1];const r=R.deepClone(s[0]);if(r.t===C.RETAIN&&r.len===0&&r.body==null)return this;if(typeof n=="object"){if(n.t===C.DELETE&&r.t===C.DELETE)return n.len+=r.len,this;if(n.t===C.DELETE&&r.t===C.INSERT&&(e-=1,n=this._actions[e-1],n==null))return this._actions.unshift(r),this;if(n.t===C.RETAIN&&r.t===C.RETAIN&&n.body==null&&r.body==null)return n.len+=r.len,this;if(n.t===C.INSERT&&pn(n.body)&&r.t===C.INSERT&&pn(r.body))return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return e===this._actions.length?this._actions.push(r):this._actions.splice(e,0,r),this}trimEndUselessRetainAction(){let s=this._actions[this._actions.length-1];for(;s&&s.t===C.RETAIN&&vi(s);)this._actions.pop(),s=this._actions[this._actions.length-1];return this}}function To(t,s,e){if(s==="")return t;const n={id:"mock-id",body:t,documentStyle:{}},r=new y(n),i=s.length;let o;for(;(o=r.getBody().dataStream.indexOf(s))>=0;){const c=new xt;if(o>0&&c.retain(o),e.length>0){const u=r.sliceBody(o,o+i),_={dataStream:e};Array.isArray(u==null?void 0:u.textRuns)&&u.textRuns.length&&(_.textRuns=[{...u.textRuns[0],st:0,ed:e.length}]),c.insert(e.length,_)}c.delete(i);const h=c.serialize();r.apply(h)}const a=r.getBody();return r.dispose(),a}class Uo extends It{add(s){if(!s)return null;const e=new Ot(s,this);return this._observers=[e],this._onObserverAdded&&this._onObserverAdded(e),e}makeObserverTopPriority(){}makeObserverBottomPriority(){}}const Mo=O.createIdentifier("ILocalStorageService");function Po(t){return new A.Observable(s=>{const e=t((...n)=>s.next(n));return()=>e==null?void 0:e.dispose()})}const Ho=t=>`sheet_interceptor_${t}`,jn=t=>function(s,e){let n=-1;function r(i,o){if(i<=n)throw new Error("[SheetInterceptorService]: next() called multiple times!");return n=i,i===t.length?o:t[i].handler(o,e,r.bind(null,i+1))}return r(0,s)};class Fo{constructor(s){d(this,"_interceptorsByName",new Map);d(this,"_interceptorPoints");this._interceptorPoints=s}fetchThroughInterceptors(s){const e=s,n=this._interceptorsByName.get(e);return jn(n||[])}intercept(s,e){const n=s;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);const r=this._interceptorsByName.get(n);return r.push(e),this._interceptorsByName.set(n,r.sort((i,o)=>{var a,c;return((a=o.priority)!=null?a:0)-((c=i.priority)!=null?c:0)})),()=>j(this._interceptorsByName.get(n),e)}getInterceptPoints(){return this._interceptorPoints}}const Wo=O.createIdentifier("univer.snapshot-server-service");class Bo{constructor(){d(this,"_sheetBlockCache",new Map)}getUnitOnRev(s,e){return Promise.resolve({snapshot:{unitID:"",type:D.UniverType.UNIVER_SHEET,rev:0,workbook:void 0,doc:void 0},changesets:[],error:{code:D.ErrorCode.OK,message:""}})}getSheetBlock(s,e){const n=this._sheetBlockCache.get(e.blockID);return Promise.resolve({block:n,error:{code:D.ErrorCode.OK,message:""}})}fetchMissingChangesets(s,e){return Promise.resolve({changesets:[],error:{code:D.ErrorCode.OK,message:""}})}getResourcesRequest(s,e){return Promise.resolve({resources:{},error:{code:D.ErrorCode.OK,message:""}})}saveSnapshot(s,e){return Promise.resolve({error:{code:D.ErrorCode.OK,message:""}})}saveSheetBlock(s,e){const{block:n}=e;return n?(this._sheetBlockCache.set(n.id,n),Promise.resolve({error:{code:D.ErrorCode.OK,message:""},blockID:n.id})):Promise.resolve({error:{code:D.ErrorCode.UNDEFINED,message:"block is required"},blockID:""})}saveChangeset(s,e){return Promise.resolve({error:{code:D.ErrorCode.OK,message:""},concurrent:[]})}}function ko(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(s,e)=>String.fromCharCode(Number.parseInt(e,16))))}function we(t){return decodeURIComponent(Array.prototype.map.call(atob(t),s=>`%${`00${s.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}const Rt=new TextEncoder,pt=new TextDecoder;function Kn(t){const s=R.deepClone(t);return delete s.id,delete s.name,delete s.rowCount,delete s.columnCount,delete s.cellData,Rt.encode(JSON.stringify(s))}function Yn(t){const s=R.deepClone(t);return delete s.id,delete s.rev,delete s.name,delete s.sheetOrder,delete s.sheets,Rt.encode(JSON.stringify(s))}function Go(t){const s=R.deepClone(t);return delete s.id,delete s.rev,delete s.title,delete s.resources,Rt.encode(JSON.stringify(s))}function zn(t){return JSON.parse(pt.decode(t))}function $o(t){return JSON.parse(typeof t=="string"?we(t):pt.decode(t))}function Vo(t){return JSON.parse(typeof t=="string"?we(t):pt.decode(t))}const De=256;function Xn(t,s){const e=new V(t),n=e.getLength(),r=[];let i=0;for(;i<n;){const o=Math.min(i+De,n-1),a=e.getSlice(i,Math.min(i+De,n-1),0,s),c=xo(a);r.push({id:R.generateRandomId(19,"0123456789"),startRow:i,endRow:o,data:c}),i+=De}return r}function xo(t){const s=t.getData();return Rt.encode(JSON.stringify(s))}async function po(t,s,e,n,r){const i={},o={};if(!await Promise.all(Object.entries(s.sheets).map(async([_,f])=>{const E={id:f.id,type:Ct.GRID,name:f.name,rowCount:f.rowCount,columnCount:f.columnCount,originalMeta:Kn(f)};if(o[_]=E,f.cellData){const g=Xn(f.cellData,f.rowCount),m=await Promise.all(g.map(S=>r.saveSheetBlock(t,{unitID:e,type:D.UniverType.UNIVER_SHEET,block:S})));if(m.some(S=>{var N;return((N=S.error)==null?void 0:N.code)!==D.ErrorCode.OK}))return!1;i[_]={sheetID:_,blocks:m.map(S=>S.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const c=Yn(s),h={unitID:s.id,rev:n,creator:"",name:s.name,sheetOrder:s.sheetOrder,sheets:o,blockMeta:i,resources:s.resources||[],originalMeta:c};return{snapshotRes:{unitID:e,rev:h.rev,type:D.UniverType.UNIVER_SHEET,workbook:h,doc:void 0}}}async function jo(t,s,e,n,r){var f,E;const i={},o={};if(!await Promise.all(Object.entries(s.sheets).map(async([g,m])=>{const S={id:m.id,type:Ct.GRID,name:m.name,rowCount:m.rowCount,columnCount:m.columnCount,originalMeta:Kn(m)};if(o[g]=S,m.cellData){const N=Xn(m.cellData,m.rowCount),W=await Promise.all(N.map(H=>r.saveSheetBlock(t,{unitID:e,type:D.UniverType.UNIVER_SHEET,block:H})));if(W.some(H=>{var q;return((q=H.error)==null?void 0:q.code)!==D.ErrorCode.OK}))return!1;i[g]={sheetID:g,blocks:W.map(H=>H.blockID)}}return!0})))throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");const c=Yn(s),h={unitID:s.id,rev:n,creator:"",name:s.name,sheetOrder:s.sheetOrder,sheets:o,blockMeta:i,resources:s.resources||[],originalMeta:c},u={unitID:e,rev:h.rev,type:D.UniverType.UNIVER_SHEET,workbook:h,doc:void 0},_=await r.saveSnapshot(t,{unitID:e,type:D.UniverType.UNIVER_SHEET,snapshot:u});if(D.isError(_.error))throw new Error(`transformWorkbookDataToSnapshot(): Failed to save snapshot.
7
+ ErrorCode: ${(f=_.error)==null?void 0:f.code}:${(E=_.error)==null?void 0:E.message}`);return{snapshot:u}}function Ko(t,s,e){const n=t.workbook;if(!n)throw new Error("");const r={};Object.entries(n.sheets).forEach(([c,h])=>{const u=zn(h.originalMeta);r[c]={id:h.id,name:h.name,rowCount:h.rowCount,columnCount:h.columnCount,...u}});const i=new Map;s.forEach(c=>{i.set(c.id,c)}),n.blockMeta&&Object.entries(n.blockMeta).forEach(([c,h])=>{var f;const u=r[c];u.cellData={};const _=[];(f=h.blocks)==null||f.forEach(E=>{const g=i.get(E);if(g)_.push(g);else throw new Error("")}),_.forEach(E=>{const g=$o(E.data);Object.entries(g).forEach(([m,S])=>{const N=u.cellData[+m]={};Object.entries(S).forEach(([W,H])=>{N[+W]=H})})})});const o=zn(n.originalMeta);return{id:t.unitID,rev:n.rev,name:n.name,sheetOrder:n.sheetOrder,appVersion:"",locale:et.EN_US,sheets:r,styles:{},resources:n.resources||[],...o}}function Yo(t){const s=t.doc;if(s==null)throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");const{unitID:e,rev:n,name:r,originalMeta:i}=s,{body:o,documentStyle:a={},settings:c={}}=Vo(i);return{id:e,rev:n,locale:et.EN_US,title:r,body:o,documentStyle:a,settings:c}}async function zo(t,s,e,n,r){var c,h,u;const i={unitID:s.id,rev:n,creator:"",name:(c=s.title)!=null?c:"",resources:s.resources||[],originalMeta:Go(s)},o={unitID:e,rev:i.rev,type:D.UniverType.UNIVER_DOC,workbook:void 0,doc:i},a=await r.saveSnapshot(t,{unitID:e,type:D.UniverType.UNIVER_DOC,snapshot:o});if(D.isError(a.error))throw new Error(`transformDocumentDataToSnapshot(): Failed to save snapshot.
8
+ ErrorCode: ${(h=a.error)==null?void 0:h.code}:${(u=a.error)==null?void 0:u.message}`);return{snapshot:o}}async function Xo(t,s){const e=t.workbook;if(!e)throw new Error("Workbook metadata is not available");const n=[],r=[];return Object.entries(e.blockMeta).forEach(([i,o])=>{const a=o.blocks.map(async c=>{const h={unitID:e.unitID,type:D.UniverType.UNIVER_SHEET,blockID:c},{block:u}=await s.getSheetBlock({},h);if(u)n.push(u);else throw new Error("Block not found")});r.push(...a)}),await Promise.all(r),n}Jn(),l.ABCToNumber=oi,l.AbsoluteRefType=Ls,l.ActionIterator=Le,l.AlignTypeH=an,l.AlignTypeV=cn,l.AutoFillSeries=es,l.BaselineOffset=vt,l.BlockType=xs,l.BooleanNumber=I,l.BorderStyleTypes=b,l.BorderType=ss,l.BulletAlignment=Y,l.COLORS=qt,l.CellValueType=ut,l.ClientSnapshotServerService=Bo,l.Color=Z,l.ColorBuilder=Lt,l.ColorKit=$,l.ColorType=k,l.ColumnSeparatorType=Ks,l.CommandType=At,l.CommonHideTypes=ns,l.ConditionType=rs,l.ConfigService=Xe,l.ContentAlignment=en,l.ContextService=xe,l.CopyPasteType=is,l.CustomRangeType=Vs,l.DEFAULT_CELL=Ti,l.DEFAULT_DOC=de,l.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=_r,l.DEFAULT_EMPTY_DOCUMENT_VALUE=ho,l.DEFAULT_RANGE=wi,l.DEFAULT_RANGE_ARRAY=ft,l.DEFAULT_SELECTION=Di,l.DEFAULT_SLIDE=_n,l.DEFAULT_STYLES=Ft,l.DEFAULT_WORKBOOK=dn,l.DEFAULT_WORKSHEET_COLUMN_COUNT=On,l.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=ki,l.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=Sn,l.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=xi,l.DEFAULT_WORKSHEET_COLUMN_WIDTH=An,l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=$i,l.DEFAULT_WORKSHEET_ROW_COUNT=mn,l.DEFAULT_WORKSHEET_ROW_COUNT_KEY=Bi,l.DEFAULT_WORKSHEET_ROW_HEIGHT=In,l.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=Gi,l.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=Cn,l.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=Vi,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Bn,l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Wn,l.DashStyleType=Zs,l.DataStreamTreeNodeType=Ts,l.DataStreamTreeTokenType=oe,l.DesktopLogService=je,l.DeveloperMetadataVisibility=os,l.Dimension=as,l.Direction=cs,l.Disposable=M,l.DisposableCollection=zt,l.DocStyleType=Gs,l.DocumentDataModel=y,l.EDITOR_ACTIVATED=bn,l.EXTENSION_NAMES=fn,l.Entry=te,l.EntryIterator=Ns,l.ErrorService=qe,l.EventState=$e,l.FOCUSING_DOC=Ee,l.FOCUSING_EDITOR_BUT_HIDDEN=Xi,l.FOCUSING_EDITOR_INPUT_FORMULA=qi,l.FOCUSING_FORMULA_EDITOR=Ln,l.FOCUSING_SHEET=Bt,l.FOCUSING_SLIDE=ge,l.FOCUSING_UNIVER_EDITOR=Ji,l.FOCUSING_UNIVER_EDITOR_SINGLE_MODE=Qi,l.FloatingObjectManagerService=Je,l.FollowNumberWithType=$s,l.FontItalic=St,l.FontStyleType=sn,l.FontWeight=Nt,l.FormatType=ls,l.GlyphType=_t,l.GridType=ps,l.HLSColor=gs,l.HorizontalAlign=Q,l.ICommandService=ct,l.IConfigService=ze,l.IContextService=tt,l.IFloatingObjectManagerService=Qe,l.ILocalStorageService=Mo,l.ILogService=J,l.IPermissionService=Ae,l.IResourceManagerService=Ie,l.ISnapshotPersistenceService=Tn,l.ISnapshotServerService=Wo,l.IUndoRedoService=$t,l.IUniverInstanceService=ot,l.InterceptorManager=Fo,l.InterpolationPointType=us,l.KeyIterator=Cs,l.LRUHelper=ht,l.LRUMap=vs,l.LifecycleStages=w,l.LocaleService=gt,l.LocaleType=et,l.LogLevel=pe,l.MemoryCursor=Ze,l.NamedStyleType=Js,l.NilCommand=Ye,l.NumberUnitType=on,l.ObjectMatrix=V,l.ObjectRelativeFromH=nn,l.ObjectRelativeFromV=rn,l.Observable=It,l.ObservableHooks=Uo,l.Observer=Ot,l.OnLifecycle=Re,l.PRESET_LIST_TYPE=Ri,l.PageElementType=gn,l.PageOrientType=un,l.PageType=_e,l.ParagraphElementType=zs,l.PermissionPoint=bs,l.PermissionStatus=re,l.Plugin=Te,l.PluginType=T,l.PositionedObjectLayoutType=qs,l.PresetListType=Ht,l.ProtectionType=hs,l.RANGE_TYPE=B,l.RGBA_PAREN=mr,l.RGB_PAREN=Rr,l.Range=it,l.Rectangle=dt,l.RedoCommand=xn,l.RedoCommandId=Gn,l.RefAlias=ii,l.Registry=jt,l.RegistryAsMap=Kt,l.RelativeDate=ds,l.RelativeSlideLink=Rn,l.ResourceManagerService=Fn,l.RgbColor=wt,l.RxDisposable=or,l.SectionType=js,l.ShapeType=_s,l.SheetTypes=Ct,l.SheetViewModel=vn,l.Slide=fe,l.SpacingRule=Qs,l.Styles=En,l.THEME_COLORS=Es,l.TabStopAlignment=ys,l.TextDecoration=fs,l.TextDirection=lt,l.TextDirectionType=Ys,l.TextX=xt,l.TextXActionType=C,l.ThemeColor=Dt,l.ThemeColorType=F,l.ThemeColors=bt,l.ThemeService=Ce,l.Tools=R,l.UndoCommand=Vn,l.UndoCommandId=$n,l.Univer=Lo,l.UniverEditablePermission=Gt,l.UniverEditablePermissionPoint=Pn,l.UniverInstanceType=wn,l.UpdateDocsAttributeType=P,l.ValueIterator=Ss,l.VerticalAlign=st,l.WidthType=tn,l.Worksheet=Et,l.WrapStrategy=nt,l.WrapTextType=Xs,l.b64DecodeUnicode=we,l.b64EncodeUnicode=ko,l.binarySearchArray=ye,l.characterSpacingControlType=ln,l.checkForSubstrings=Xr,l.checkParagraphHasBullet=qr,l.checkParagraphHasIndent=Jr,l.checkParagraphHasIndentByStyle=Os,l.codeToBlob=Er,l.composeBody=he,l.composeInterceptors=jn,l.concatMatrixArray=yr,l.createInterceptorKey=Ho,l.createRowColIter=ie,l.debounce=di,l.dedupe=tr,l.deepCompare=Zt,l.deleteContent=As,l.fromCallback=Po,l.fromObservable=ir,l.generateTemporarySnap=po,l.getArrayLength=p,l.getBodySlice=ue,l.getBorderStyleType=Yr,l.getCellValueType=Mi,l.getColorStyle=x,l.getDocsUpdateBody=Mt,l.getReverseDirection=gr,l.getSheetBlocksFromSnapshot=Xo,l.getTypeFromPermissionItemList=ni,l.getWorksheetUID=zi,l.groupBy=nr,l.handleJsonToDom=jr,l.handleStyleToString=Kr,l.hashAlgorithm=Zr,l.horizontalLineSegmentsSubtraction=yt,l.insertMatrixArray=ee,l.insertTextToContent=Is,l.isBlackColor=Tr,l.isCellV=Hi,l.isEmptyCell=Vr,l.isFormulaId=pr,l.isFormulaString=xr,l.isICellData=Ui,l.isNullCell=Pi,l.isObserver=Ve,l.isRealNum=Qr,l.isSameStyleTextRun=ms,l.isValidRange=zr,l.isWhiteColor=Ur,l.makeCellRangeToRangeData=$r,l.makeCellToSelection=Gr,l.mergeWorksheetSnapshotWithDefault=Nn,l.moveMatrixArray=ne,l.normalizeTextRuns=ae,l.numberToABC=ci,l.numberToListABC=li,l.orderSearchArray=ts,l.remove=j,l.repeatStringNumTimes=Ds,l.replaceInDocumentBody=To,l.requestImmediateMacroTask=Do,l.rotate=sr,l.runOnLifecycle=me,l.searchArray=fr,l.selectionToArray=ri,l.sequence=Me,l.sequenceAsync=Ue,l.sequenceExecute=Xt,l.sequenceExecuteAsync=dr,l.sliceMatrixArray=ti,l.sortRules=ui,l.sortRulesByDesc=hi,l.sortRulesFactory=rt,l.spliceArray=se,l.textDecoder=pt,l.textEncoder=Rt,l.throttle=wo,l.toDisposable=L,l.transformDocumentDataToSnapshot=zo,l.transformSnapshotToDocumentData=Yo,l.transformSnapshotToWorkbookData=Ko,l.transformWorkbookDataToSnapshot=jo,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});