@univerjs/core 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +6 -6
- package/lib/cjs/index.js +1170 -778
- package/lib/es/facade.js +6 -6
- package/lib/es/index.js +1165 -779
- package/lib/facade.js +6 -6
- package/lib/index.js +1165 -779
- package/lib/types/docs/data-model/document-data-model.d.ts +1 -1
- package/lib/types/docs/data-model/index.d.ts +0 -2
- package/lib/types/docs/data-model/paragraph-style.d.ts +10 -1
- package/lib/types/docs/data-model/rich-text-builder.d.ts +3 -3
- package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
- package/lib/types/docs/data-model/text-x/utils.d.ts +2 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/services/instance/instance.service.d.ts +2 -0
- package/lib/types/services/locale/currency-symbol.d.ts +17 -0
- package/lib/types/services/undoredo/undoredo.service.d.ts +1 -1
- package/lib/types/shared/common.d.ts +8 -5
- package/lib/types/sheets/typedef.d.ts +4 -0
- package/lib/types/sheets/worksheet.d.ts +2 -2
- package/lib/types/types/interfaces/i-document-data.d.ts +137 -9
- package/lib/umd/index.js +26 -26
- package/package.json +6 -6
package/lib/umd/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("rxjs"),require("@univerjs/protocol"),require("rxjs/operators"),require("@wendellhu/redi"),require("@univerjs/themes")):typeof define==`function`&&define.amd?define([`exports`,`rxjs`,`@univerjs/protocol`,`rxjs/operators`,`@wendellhu/redi`,`@univerjs/themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore={},e.rxjs,e.UniverProtocol,e.rxjs.operators,e[`@wendellhu/redi`],e.UniverThemes))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),p=(e,t)=>{let n=Object.setPrototypeOf({},null);for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t&1||s(n,Symbol.toStringTag,{value:`Module`}),t&2?n:Object.preventExtensions(n)},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:o(u(e)),m(t||!e||!e.__esModule||!d.call(e,`default`)?s(n,`default`,{value:e,enumerable:!0}):n,e));let g=typeof global<`u`?global:typeof self<`u`?self:window;function _(){let e=/* @__PURE__ */ new Map,t=0;typeof g.requestIdleCallback!=`function`&&(g.requestIdleCallback=function(n){let r=Date.now(),i=++t,a=setTimeout(function(){e.delete(i);let t=Math.max(0,50-(Date.now()-r));n({didTimeout:t===0,timeRemaining(){return t}})},1);return e.set(i,a),i}),typeof g.cancelIdleCallback!=`function`&&(g.cancelIdleCallback=function(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))})}function v(){typeof g.queueMicrotask!=`function`&&(g.queueMicrotask=function(e){Promise.resolve().then(e).catch(e=>{setTimeout(()=>{throw e},0)})})}function y(){typeof g.Array.prototype.findLastIndex!=`function`&&(g.Array.prototype.findLastIndex=function(e,t){if(this==null)throw TypeError(`Array.prototype.findLastIndex called on null or undefined`);if(typeof e!=`function`)throw TypeError(`callback must be a function`);let n=this.length>>>0;for(let r=n-1;r>=0;r--)if(r in this&&e.call(t,this[r],r,this))return r;return-1}),typeof g.Array.prototype.findLast!=`function`&&(g.Array.prototype.findLast=function(e,t){let n=this.findLastIndex(e,t);return n===-1?void 0:this[n]})}function b(){typeof g.String.prototype.at!=`function`&&(g.String.prototype.at=function(e){if(this==null)throw TypeError(`String.prototype.at called on null or undefined`);let t=this.length;if(e<0&&(e=t+e),!(e<0||e>=t))return this.charAt(e)})}function x(){_(),v(),y(),b()}function S(e){"@babel/helpers - typeof";return S=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},S(e)}function C(e,t){if(S(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(S(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function w(e){var t=C(e,`string`);return S(t)==`symbol`?t:t+``}function T(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){return e instanceof t.Subscription||e instanceof t.Subject||e&&`closed`in e&&e.unsubscribe!==void 0}function D(e){let t=!1;return e?E(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:D(()=>{})}var O=class{constructor(){T(this,`_disposables`,/* @__PURE__ */ new Set)}add(e){let t=D(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},k=class{constructor(){T(this,`_disposed`,!1),T(this,`_collection`,new O)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},A=class extends k{constructor(...e){super(...e),T(this,`dispose$`,new t.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},j=class extends k{constructor(e){super(),this._rootDisposable=e,T(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},M=class extends k{};let N=/* @__PURE__ */ new Set(/* @__PURE__ */ `ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),P=/* @__PURE__ */ RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function F(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:5173`)||e.startsWith(`localhost:5173`))return!0;if(P.test(e)){if(I(e))return!0;try{let t=new URL(ee(e)).hostname.split(`.`).pop();if(t&&N.has(t))return!0}catch{return!1}}return!1}function I(e){return/^[a-zA-Z]+:\/\//.test(e)}function L(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function ee(e){return I(e)?e:L(e)?`mailto://${e}`:`https://${e}`}function R(e){if(!e||typeof e!=`string`)return!1;try{let t=typeof window<`u`&&window.location?window.location.origin:`http://localhost`,n=new URL(e,t);return[`http:`,`https:`,`mailto:`].includes(n.protocol)}catch{return!1}}function te(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function ne(e,t){return z.getValueType(e)===z.getValueType(t)?z.isArray(e)?re(e,t):z.isObject(e)?ie(e,t):z.isDate(e)?e.getTime()===t.getTime():z.isRegExp(e)?e.toString()===t.toString():e===t:!1}function re(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!ne(r,i))return!1}return!0}function ie(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(t,r))return!1;let n=e[r],i=t[r];if(!ne(n,i))return!1}return!0}var z=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=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`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){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(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){(/* @__PURE__ */ RegExp(`MSIE (\\d+\\.\\d+);`)).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static diffValue(e,t){return ne(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n=t,r={};for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=e.deepClone(n[t]));return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}return t}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 isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}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(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return F(e)}static normalizeUrl(e){return ee(e)}static topLevelDomainCombiningString(){return[...N].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function ae(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}let oe=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,se=/* @__PURE__ */ function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),ce=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),le=/* @__PURE__ */ function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),ue=/* @__PURE__ */ function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),de=/* @__PURE__ */ function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),fe=/* @__PURE__ */ function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),pe=/* @__PURE__ */ function(e){return e.Date1900=`date1900`,e.Date1904=`date1904`,e}({}),me=/* @__PURE__ */ function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),he=/* @__PURE__ */ function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),ge=/* @__PURE__ */ function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),_e=/* @__PURE__ */ function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function ve(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}let ye=/* @__PURE__ */ function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),be=/* @__PURE__ */ function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.ZH_HK=`zhHK`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e.PT_BR=`ptBR`,e.DE_DE=`deDE`,e.IT_IT=`itIT`,e.ID_ID=`idID`,e.PL_PL=`plPL`,e.AR_SA=`arSA`,e}({}),xe={enUS:{name:`English`,tag:`en-US`,direction:`ltr`},frFR:{name:`Français`,tag:`fr-FR`,direction:`ltr`},zhCN:{name:`简体中文`,tag:`zh-CN`,direction:`ltr`},ruRU:{name:`Русский`,tag:`ru-RU`,direction:`ltr`},zhTW:{name:`繁體中文`,tag:`zh-TW`,direction:`ltr`},zhHK:{name:`繁體中文(香港)`,tag:`zh-HK`,direction:`ltr`},viVN:{name:`Tiếng Việt`,tag:`vi-VN`,direction:`ltr`},faIR:{name:`فارسی`,tag:`fa-IR`,direction:`rtl`,numberingSystem:`arabext`},jaJP:{name:`日本語`,tag:`ja-JP`,direction:`ltr`},koKR:{name:`한국어`,tag:`ko-KR`,direction:`ltr`},esES:{name:`Español`,tag:`es-ES`,direction:`ltr`},caES:{name:`Català`,tag:`ca-ES`,direction:`ltr`},skSK:{name:`Slovenčina`,tag:`sk-SK`,direction:`ltr`},ptBR:{name:`Português (Brasil)`,tag:`pt-BR`,direction:`ltr`},deDE:{name:`Deutsch`,tag:`de-DE`,direction:`ltr`},itIT:{name:`Italiano`,tag:`it-IT`,direction:`ltr`},idID:{name:`Bahasa Indonesia`,tag:`id-ID`,direction:`ltr`},plPL:{name:`Polski`,tag:`pl-PL`,direction:`ltr`},arSA:{name:`العربية`,tag:`ar-SA`,direction:`rtl`,numberingSystem:`arab`}},Se=/* @__PURE__ */ function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Ce=/* @__PURE__ */ function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),we=/* @__PURE__ */ function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),Te=/* @__PURE__ */ function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e[e.CHART=3]=`CHART`,e}({}),Ee=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),De=/* @__PURE__ */ function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e[e.SINGLE_ACCOUNTING=18]=`SINGLE_ACCOUNTING`,e[e.DOUBLE_ACCOUNTING=19]=`DOUBLE_ACCOUNTING`,e}({}),Oe=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),ke=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),Ae=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),je=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),Me=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),Ne=/* @__PURE__ */ function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),Pe=/* @__PURE__ */ function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),Fe=/* @__PURE__ */ function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),Ie=/* @__PURE__ */ function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),Le=/* @__PURE__ */ function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({});var Re=`@univerjs/core`,ze=`1.5.2`;function Be(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}function Ve(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function He(e,t){let n=/* @__PURE__ */ new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function Ue(e,t){for(let n=e.length-1;n>-1;n--){let r=e[n];if(t(r,n))return r}return null}function We(e,t){if(e.length===0)return e;let n=t%e.length;return e.slice(n).concat(e.slice(0,n))}function Ge(e,t){let n=/* @__PURE__ */ new Map;return e.forEach(e=>{let r=t(e),i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(e)}),n}function Ke(e){return Array.isArray(e)?e:[e]}function qe(e,t){t.forEach(t=>e.add(t))}function Je(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}var Ye=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Xe=class extends Ye{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};async function Ze(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function Qe(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}var $e=typeof global==`object`&&global&&global.Object===Object&&global,et=typeof self==`object`&&self&&self.Object===Object&&self,tt=$e||et||Function(`return this`)(),nt=tt.Symbol,rt=Object.prototype,it=rt.hasOwnProperty,at=rt.toString,ot=nt?nt.toStringTag:void 0;function st(e){var t=it.call(e,ot),n=e[ot];try{e[ot]=void 0;var r=!0}catch{}var i=at.call(e);return r&&(t?e[ot]=n:delete e[ot]),i}var ct=Object.prototype.toString;function lt(e){return ct.call(e)}var ut=`[object Null]`,dt=`[object Undefined]`,ft=nt?nt.toStringTag:void 0;function pt(e){return e==null?e===void 0?dt:ut:ft&&ft in Object(e)?st(e):lt(e)}function mt(e){return typeof e==`object`&&!!e}var ht=`[object Symbol]`;function gt(e){return typeof e==`symbol`||mt(e)&&pt(e)==ht}function _t(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var vt=Array.isArray,yt=1/0,bt=nt?nt.prototype:void 0,xt=bt?bt.toString:void 0;function St(e){if(typeof e==`string`)return e;if(vt(e))return _t(e,St)+``;if(gt(e))return xt?xt.call(e):``;var t=e+``;return t==`0`&&1/e==-yt?`-0`:t}var Ct=/\s/;function wt(e){for(var t=e.length;t--&&Ct.test(e.charAt(t)););return t}var Tt=/^\s+/;function Et(e){return e&&e.slice(0,wt(e)+1).replace(Tt,``)}function Dt(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Ot=NaN,kt=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,jt=/^0o[0-7]+$/i,Mt=parseInt;function Nt(e){if(typeof e==`number`)return e;if(gt(e))return Ot;if(Dt(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Dt(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Et(e);var n=At.test(e);return n||jt.test(e)?Mt(e.slice(2),n?2:8):kt.test(e)?Ot:+e}function Pt(e){return e}var Ft=`[object AsyncFunction]`,It=`[object Function]`,Lt=`[object GeneratorFunction]`,Rt=`[object Proxy]`;function zt(e){if(!Dt(e))return!1;var t=pt(e);return t==It||t==Lt||t==Ft||t==Rt}var Bt=tt[`__core-js_shared__`],Vt=function(){var e=/[^.]+$/.exec(Bt&&Bt.keys&&Bt.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Ht(e){return!!Vt&&Vt in e}var Ut=Function.prototype.toString;function Wt(e){if(e!=null){try{return Ut.call(e)}catch{}try{return e+``}catch{}}return``}var Gt=/[\\^$.*+?()[\]{}|]/g,Kt=/^\[object .+?Constructor\]$/,qt=Function.prototype,Jt=Object.prototype,Yt=qt.toString,Xt=Jt.hasOwnProperty,Zt=RegExp(`^`+Yt.call(Xt).replace(Gt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Qt(e){return!Dt(e)||Ht(e)?!1:(zt(e)?Zt:Kt).test(Wt(e))}function $t(e,t){return e==null?void 0:e[t]}function en(e,t){var n=$t(e,t);return Qt(n)?n:void 0}var tn=Object.create,nn=function(){function e(){}return function(t){if(!Dt(t))return{};if(tn)return tn(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function rn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function an(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var on=800,sn=16,cn=Date.now;function ln(e){var t=0,n=0;return function(){var r=cn(),i=sn-(r-n);if(n=r,i>0){if(++t>=on)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function un(e){return function(){return e}}var dn=function(){try{var e=en(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),fn=ln(dn?function(e,t){return dn(e,`toString`,{configurable:!0,enumerable:!1,value:un(t),writable:!0})}:Pt),pn=9007199254740991,mn=/^(?:0|[1-9]\d*)$/;function hn(e,t){var n=typeof e;return t??=pn,!!t&&(n==`number`||n!=`symbol`&&mn.test(e))&&e>-1&&e%1==0&&e<t}function gn(e,t,n){t==`__proto__`&&dn?dn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function _n(e,t){return e===t||e!==e&&t!==t}var vn=Object.prototype.hasOwnProperty;function yn(e,t,n){var r=e[t];(!(vn.call(e,t)&&_n(r,n))||n===void 0&&!(t in e))&&gn(e,t,n)}function bn(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?gn(n,s,c):yn(n,s,c)}return n}var xn=Math.max;function Sn(e,t,n){return t=xn(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=xn(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),rn(e,this,s)}}function Cn(e,t){return fn(Sn(e,t,Pt),e+``)}var wn=9007199254740991;function Tn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=wn}function En(e){return e!=null&&Tn(e.length)&&!zt(e)}function Dn(e,t,n){if(!Dt(n))return!1;var r=typeof t;return(r==`number`?En(n)&&hn(t,n.length):r==`string`&&t in n)?_n(n[t],e):!1}function On(e){return Cn(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Dn(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var kn=Object.prototype;function An(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||kn)}function jn(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Mn=`[object Arguments]`;function Nn(e){return mt(e)&&pt(e)==Mn}var Pn=Object.prototype,Fn=Pn.hasOwnProperty,In=Pn.propertyIsEnumerable,Ln=Nn(function(){return arguments}())?Nn:function(e){return mt(e)&&Fn.call(e,`callee`)&&!In.call(e,`callee`)};function Rn(){return!1}var zn=typeof e==`object`&&e&&!e.nodeType&&e,Bn=zn&&typeof module==`object`&&module&&!module.nodeType&&module,Vn=Bn&&Bn.exports===zn?tt.Buffer:void 0,Hn=(Vn?Vn.isBuffer:void 0)||Rn,Un=`[object Arguments]`,Wn=`[object Array]`,Gn=`[object Boolean]`,Kn=`[object Date]`,qn=`[object Error]`,Jn=`[object Function]`,Yn=`[object Map]`,Xn=`[object Number]`,Zn=`[object Object]`,Qn=`[object RegExp]`,$n=`[object Set]`,er=`[object String]`,tr=`[object WeakMap]`,nr=`[object ArrayBuffer]`,rr=`[object DataView]`,ir=`[object Float32Array]`,ar=`[object Float64Array]`,or=`[object Int8Array]`,sr=`[object Int16Array]`,cr=`[object Int32Array]`,lr=`[object Uint8Array]`,ur=`[object Uint8ClampedArray]`,dr=`[object Uint16Array]`,fr=`[object Uint32Array]`,B={};B[ir]=B[ar]=B[or]=B[sr]=B[cr]=B[lr]=B[ur]=B[dr]=B[fr]=!0,B[Un]=B[Wn]=B[nr]=B[Gn]=B[rr]=B[Kn]=B[qn]=B[Jn]=B[Yn]=B[Xn]=B[Zn]=B[Qn]=B[$n]=B[er]=B[tr]=!1;function pr(e){return mt(e)&&Tn(e.length)&&!!B[pt(e)]}function mr(e){return function(t){return e(t)}}var hr=typeof e==`object`&&e&&!e.nodeType&&e,gr=hr&&typeof module==`object`&&module&&!module.nodeType&&module,_r=gr&&gr.exports===hr&&$e.process,vr=function(){try{return gr&&gr.require&&gr.require(`util`).types||_r&&_r.binding&&_r.binding(`util`)}catch{}}(),yr=vr&&vr.isTypedArray,br=yr?mr(yr):pr,xr=Object.prototype.hasOwnProperty;function Sr(e,t){var n=vt(e),r=!n&&Ln(e),i=!n&&!r&&Hn(e),a=!n&&!r&&!i&&br(e),o=n||r||i||a,s=o?jn(e.length,String):[],c=s.length;for(var l in e)(t||xr.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||hn(l,c)))&&s.push(l);return s}function Cr(e,t){return function(n){return e(t(n))}}function wr(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Tr=Object.prototype.hasOwnProperty;function Er(e){if(!Dt(e))return wr(e);var t=An(e),n=[];for(var r in e)(r!=`constructor`||!t&&Tr.call(e,r))&&n.push(r);return n}function Dr(e){return En(e)?Sr(e,!0):Er(e)}var Or=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kr=/^\w*$/;function Ar(e,t){if(vt(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||gt(e)?!0:kr.test(e)||!Or.test(e)||t!=null&&e in Object(t)}var jr=en(Object,`create`);function Mr(){this.__data__=jr?jr(null):{},this.size=0}function Nr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Pr=`__lodash_hash_undefined__`,Fr=Object.prototype.hasOwnProperty;function Ir(e){var t=this.__data__;if(jr){var n=t[e];return n===Pr?void 0:n}return Fr.call(t,e)?t[e]:void 0}var Lr=Object.prototype.hasOwnProperty;function Rr(e){var t=this.__data__;return jr?t[e]!==void 0:Lr.call(t,e)}var zr=`__lodash_hash_undefined__`;function Br(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=jr&&t===void 0?zr:t,this}function Vr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Vr.prototype.clear=Mr,Vr.prototype.delete=Nr,Vr.prototype.get=Ir,Vr.prototype.has=Rr,Vr.prototype.set=Br;function Hr(){this.__data__=[],this.size=0}function Ur(e,t){for(var n=e.length;n--;)if(_n(e[n][0],t))return n;return-1}var Wr=Array.prototype.splice;function Gr(e){var t=this.__data__,n=Ur(t,e);return n<0?!1:(n==t.length-1?t.pop():Wr.call(t,n,1),--this.size,!0)}function Kr(e){var t=this.__data__,n=Ur(t,e);return n<0?void 0:t[n][1]}function qr(e){return Ur(this.__data__,e)>-1}function Jr(e,t){var n=this.__data__,r=Ur(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Yr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Yr.prototype.clear=Hr,Yr.prototype.delete=Gr,Yr.prototype.get=Kr,Yr.prototype.has=qr,Yr.prototype.set=Jr;var Xr=en(tt,`Map`);function Zr(){this.size=0,this.__data__={hash:new Vr,map:new(Xr||Yr),string:new Vr}}function Qr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function $r(e,t){var n=e.__data__;return Qr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function ei(e){var t=$r(this,e).delete(e);return this.size-=+!!t,t}function ti(e){return $r(this,e).get(e)}function ni(e){return $r(this,e).has(e)}function ri(e,t){var n=$r(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ii(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ii.prototype.clear=Zr,ii.prototype.delete=ei,ii.prototype.get=ti,ii.prototype.has=ni,ii.prototype.set=ri;var ai=`Expected a function`;function oi(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ai);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(oi.Cache||ii),n}oi.Cache=ii;var si=500;function ci(e){var t=oi(e,function(e){return n.size===si&&n.clear(),e}),n=t.cache;return t}var li=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ui=/\\(\\)?/g,di=ci(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(li,function(e,n,r,i){t.push(r?i.replace(ui,`$1`):n||e)}),t});function fi(e){return e==null?``:St(e)}function pi(e,t){return vt(e)?e:Ar(e,t)?[e]:di(fi(e))}var mi=1/0;function hi(e){if(typeof e==`string`||gt(e))return e;var t=e+``;return t==`0`&&1/e==-mi?`-0`:t}function gi(e,t){t=pi(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[hi(t[n++])];return n&&n==r?e:void 0}function _i(e,t,n){var r=e==null?void 0:gi(e,t);return r===void 0?n:r}var vi=Cr(Object.getPrototypeOf,Object),yi=`[object Object]`,bi=Function.prototype,xi=Object.prototype,Si=bi.toString,Ci=xi.hasOwnProperty,wi=Si.call(Object);function Ti(e){if(!mt(e)||pt(e)!=yi)return!1;var t=vi(e);if(t===null)return!0;var n=Ci.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Si.call(n)==wi}function Ei(){this.__data__=new Yr,this.size=0}function Di(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Oi(e){return this.__data__.get(e)}function ki(e){return this.__data__.has(e)}var Ai=200;function ji(e,t){var n=this.__data__;if(n instanceof Yr){var r=n.__data__;if(!Xr||r.length<Ai-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ii(r)}return n.set(e,t),this.size=n.size,this}function Mi(e){var t=this.__data__=new Yr(e);this.size=t.size}Mi.prototype.clear=Ei,Mi.prototype.delete=Di,Mi.prototype.get=Oi,Mi.prototype.has=ki,Mi.prototype.set=ji;var Ni=typeof e==`object`&&e&&!e.nodeType&&e,Pi=Ni&&typeof module==`object`&&module&&!module.nodeType&&module,Fi=Pi&&Pi.exports===Ni?tt.Buffer:void 0,Ii=Fi?Fi.allocUnsafe:void 0;function Li(e,t){if(t)return e.slice();var n=e.length,r=Ii?Ii(n):new e.constructor(n);return e.copy(r),r}var Ri=tt.Uint8Array;function zi(e){var t=new e.constructor(e.byteLength);return new Ri(t).set(new Ri(e)),t}function Bi(e,t){var n=t?zi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Vi(e){return typeof e.constructor==`function`&&!An(e)?nn(vi(e)):{}}function Hi(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Ui=Hi(),Wi=function(){return tt.Date.now()},Gi=`Expected a function`,Ki=Math.max,qi=Math.min;function Ji(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Gi);t=Nt(t)||0,Dt(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Ki(Nt(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?qi(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Wi();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Wi())}function x(){var e=Wi(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Yi(e,t,n){(n!==void 0&&!_n(e[t],n)||n===void 0&&!(t in e))&&gn(e,t,n)}function Xi(e){return mt(e)&&En(e)}function Zi(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}function Qi(e){return bn(e,Dr(e))}function $i(e,t,n,r,i,a,o){var s=Zi(e,n),c=Zi(t,n),l=o.get(c);if(l)Yi(e,n,l);else{var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=vt(c),p=!f&&Hn(c),m=!f&&!p&&br(c);u=c,f||p||m?vt(s)?u=s:Xi(s)?u=an(s):p?(d=!1,u=Li(c,!0)):m?(d=!1,u=Bi(c,!0)):u=[]:Ti(c)||Ln(c)?(u=s,Ln(s)?u=Qi(s):(!Dt(s)||zt(s))&&(u=Vi(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Yi(e,n,u)}}function ea(e,t,n,r,i){e!==t&&Ui(t,function(a,o){if(i||=new Mi,Dt(a))$i(e,t,o,n,ea,r,i);else{var s=r?r(Zi(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Yi(e,o,s)}},Dr)}var ta=On(function(e,t,n,r){ea(e,t,n,r)}),na=On(function(e,t,n){ea(e,t,n)});function ra(e,t,n,r){if(!Dt(e))return e;t=pi(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=hi(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=Dt(u)?u:hn(t[i+1])?[]:{})}yn(s,c,l),s=s[c]}return e}function ia(e,t,n){return e==null?e:ra(e,t,n)}function aa(e,t,n,r){return r=typeof r==`function`?r:void 0,e==null?e:ra(e,t,n,r)}let oa=(0,i.createIdentifier)(`univer.config-service`);var sa=class{constructor(){T(this,`_configChanged$`,new t.Subject),T(this,`configChanged$`,this._configChanged$.asObservable()),T(this,`_config`,/* @__PURE__ */ new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){let{merge:r=!1}=n||{},i=this._config.get(e)??{};i=r?na(i,t):t,this._config.set(e,i),this._configChanged$.next({[e]:i})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new t.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,e)&&n.next(this._config.get(e));let r=this.configChanged$.pipe((0,t.filter)(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(t=>n.next(t[e]));return()=>r.unsubscribe()})}};let ca=(0,i.createIdentifier)(`univer.context-service`);var la=class extends k{constructor(...e){super(...e),T(this,`_contextChanged$`,new t.Subject),T(this,`contextChanged$`,this._contextChanged$.asObservable()),T(this,`_contextMap`,/* @__PURE__ */ new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){return this._contextMap.get(e)??!1}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new t.Observable(n=>{let r=this._contextChanged$.pipe((0,t.filter)(t=>t[e]!==void 0)).subscribe(t=>n.next(t[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}};let ua=/* @__PURE__ */ function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({}),da=(0,i.createIdentifier)(`univer.log`);var fa=class extends k{constructor(...e){super(...e),T(this,`_logLevel`,3),T(this,`_deduction`,/* @__PURE__ */ new Set)}dispose(){super.dispose(),this._logLevel=3,this._deduction.clear()}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)}deprecate(...e){this._logLevel>=2&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=pa(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function pa(...e){return e.map(e=>JSON.stringify(e)).join(``)}function V(e,t){return function(n,r){t(n,r,e)}}function ma(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let ha=`command.logExecution`,ga=/* @__PURE__ */ function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({}),_a=(0,i.createIdentifier)(`univer.core.command-service`);var va=class{constructor(){T(this,`_commands`,/* @__PURE__ */ new Map),T(this,`_commandTypes`,/* @__PURE__ */ new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),D(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};let ya={id:`nil`,type:0,handler:()=>!0},ba=class extends k{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,T(this,`_commandRegistry`,void 0),T(this,`_beforeCommandExecutionListeners`,[]),T(this,`_commandExecutedListeners`,[]),T(this,`_collabMutationListeners`,[]),T(this,`_multiCommandDisposables`,/* @__PURE__ */ new Map),T(this,`_commandExecutingLevel`,0),T(this,`_commandExecutionStack`,[]),this._commandRegistry=new va,this.registerCommand(ya)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}_warnCommandSkippedAfterDisposed(e){this._logService.warn(`[CommandService]`,`command "${e}" skipped because CommandService is disposed.`)}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),D(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),D(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),D(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=await this._execute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}syncExecuteCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=this._syncExecute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),D(()=>Be(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(t){let e=t[0];if(!(e instanceof xa))throw TypeError(`Command has registered as a single command.`);n=e}else{n=new xa(e.id);let t=new O;t.add(this._commandRegistry.registerCommand(n)),t.add(D(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}let r=n.registerImplementation(e);return D(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}_attachMutationTrigger(e,t){if(e.type!==2||!t)return;let n=Ue(this._commandExecutionStack,e=>e.type===0);if(n){this._setMutationTrigger(t,n.id);return}if(`trigger`in t&&t.trigger!==void 0)return;let r=Ue(this._commandExecutionStack,e=>e.type===1);r&&this._setMutationTrigger(t,r.id)}_setMutationTrigger(e,t){Object.assign(e,{trigger:t})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};ba=ma([V(0,(0,i.Inject)(i.Injector)),V(1,da),V(2,oa)],ba);var xa=class{constructor(e){this.id=e,T(this,`name`,void 0),T(this,`multi`,!0),T(this,`type`,0),T(this,`priority`,0),T(this,`_implementations`,[]),T(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(da),r=e.get(ca),a=e.get(i.Injector);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),D(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function Sa(e,t,n){return Qe(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function Ca(e,t,n){return Ze(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function wa(e){return new t.Observable(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function Ta(e){return function(n){return n.pipe((0,t.takeWhile)(t=>!e(t),!0))}}function Ea(e=0){return n=>{let r=[];return n.pipe((0,t.tap)(e=>r.push(e)),(0,t.debounceTime)(e),(0,t.map)(()=>r),(0,t.tap)(()=>r=[]))}}function Da(e){let n=new t.ReplaySubject(1);return setTimeout(()=>n.next(),e),n.pipe((0,t.take)(1))}function Oa(e,n){let r=new t.BehaviorSubject(n),i=e.subscribe(r),a=r.complete.bind(r);return r.complete=()=>{i.unsubscribe(),a()},r}let ka=e=>new Promise(n=>{(0,t.merge)(wa(e.onCommandExecuted.bind(e)).pipe((0,r.filter)(([e])=>e.type===2)),(0,t.timer)(300)).pipe((0,r.debounceTime)(16),(0,r.first)()).subscribe(()=>{n()})});function Aa(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function ja(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function Ma(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function Na(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?Aa(e,t):Ma(e,t),n){let t=e[r];return e.indexOf(t)}return r}function Pa(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}function Fa(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}let Ia={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],darkyellow:[139,128,0],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]};var La=class e{static mix(t,n,r){r=Math.min(1,Math.max(0,r));let i=new e(t).toRgb(),a=new e(n).toRgb(),o=i.a??1,s=a.a??1,c={r:(a.r-i.r)*r+i.r,g:(a.g-i.g)*r+i.g,b:(a.b-i.b)*r+i.b,a:(s-o)*r+o};return new e(c)}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(T(this,`_color`,void 0),T(this,`_rgbColor`,void 0),T(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=Ba(t);if(n==null){this._setNullColor();return}this._color=n;let r=Ga(this._color);r==null?this._setNullColor():(this._rgbColor=r,this._isValid=!0)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[Ra(Math.round(t).toString(16)),Ra(Math.round(n).toString(16)),Ra(Math.round(r).toString(16)),Ra(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Xa(this.toRgb())}toHsl(){return Ya(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=za(e),t=za(t),n=za(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){return this._color.a??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}}};let Ra=e=>e.length===1?`0${e}`:e,za=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),Ba=e=>{if(Qa(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(Ia[t]){let e=Ia[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]||1,n}if(t.startsWith(`#`))return Va(t);if(t.startsWith(`rgb`))return Ha(t);if(t.startsWith(`hsl`))return Ua(t);if(t.startsWith(`hsv`))return Wa(t)},Va=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Ha=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ua=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Wa=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ga=e=>{let t=Ba(e);if(t!=null)return`r`in t?t:`l`in t?qa(t):Ja(t)},Ka=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),qa=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=Ka(s,e,t+1/3),a=Ka(s,e,t),o=Ka(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},Ja=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Ya=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Xa=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Za=e=>e==null,Qa=e=>!Za(e)&&typeof e==`object`;function $a(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function eo(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}let to=/* @__PURE__ */ function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({}),no=/* @__PURE__ */ function(e){return e[e.VISIBLE=0]=`VISIBLE`,e[e.HIDDEN=1]=`HIDDEN`,e[e.VERY_HIDDEN=2]=`VERY_HIDDEN`,e}({}),ro=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.SHARED=1]=`SHARED`,e[e.ARRAY=2]=`ARRAY`,e[e.DATA_TABLE=3]=`DATA_TABLE`,e}({});function io(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.ft!==void 0||e.fd!==void 0||e.si!==void 0||e.custom!==void 0)}function ao(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return 1;if(typeof e.v==`number`)return 2;if(typeof e.v==`boolean`)return 3}function oo(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null)}function so(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let co=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),lo=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function uo(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let fo=/* @__PURE__ */ function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),po=/* @__PURE__ */ function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({}),mo=/* @__PURE__ */ function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({}),ho={Office:{4:`#4472C4`,5:`#ED7D31`,6:`#A5A5A5`,7:`#70AD47`,8:`#5B9BD5`,9:`#70AD47`,0:`#000000`,2:`#44546A`,1:`#FFFFFF`,3:`#E7E6E6`,10:`#0563C1`,11:`#954F72`}},go=`general`,_o=`hash`,vo=`zero`,yo=`qmark`,bo=`slash`,xo=`group`,So=`scale`,Co=`comma`,wo=`break`,To=`text`,Eo=`plus`,Do=`minus`,Oo=`point`,ko=`space`,Ao=`percent`,jo=`digit`,Mo=`calendar`,No=`error`,Po=`datetime`,Fo=`duration`,Io=`condition`,Lo=`dbnum`,Ro=`natnum`,zo=`locale`,Bo=`color`,Vo=`modifier`,Ho=`ampm`,Uo=`escaped`,Wo=`string`,Go=`skip`,Ko=`fill`,qo=`paren`,Jo=`char`,Yo=/* @__PURE__ */ `#000000.#FFFFFF.#FF0000.#00FF00.#0000FF.#FFFF00.#FF00FF.#00FFFF.#800000.#008000.#000080.#808000.#800080.#008080.#C0C0C0.#808080.#9999FF.#993366.#FFFFCC.#CCFFFF.#660066.#FF8080.#0066CC.#CCCCFF.#000080.#FF00FF.#FFFF00.#00FFFF.#800080.#800000.#008080.#0000FF.#00CCFF.#CCFFFF.#CCFFCC.#FFFF99.#99CCFF.#FF99CC.#CC99FF.#FFCC99.#3366FF.#33CCCC.#99CC00.#FFCC00.#FF9900.#FF6600.#666699.#969696.#003366.#339966.#003300.#333300.#993300.#993366.#333399.#333333`.split(`.`),Xo=/* @__PURE__ */ `¤.$.£.¥.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿`.split(`.`),Zo=RegExp(`[${Xo.join(``)}]`);function Qo(e){if(!Number.isFinite(e))throw RangeError(`decimalFromNumber requires a finite number`);let t=e<0||Object.is(e,-0);if(e===0)return{negative:t,digits:`0`,exponent:0};let[n,r]=Math.abs(e).toExponential(14).split(`e`);return{negative:t,digits:n.replace(`.`,``).replace(/0+$/,``)||`0`,exponent:Number(r)}}function $o(e,t){return{...e,exponent:e.digits===`0`?0:e.exponent+Math.trunc(t)}}function es(e){let t=[...e];for(let e=t.length-1;e>=0;e--){if(t[e]!==`9`)return t[e]=String(Number(t[e])+1),t.join(``);t[e]=`0`}return`1${t.join(``)}`}function ts(e,t=0){let n=Math.trunc(t),r=e.exponent+1+n,i;if(r<0?i=`0`:r===0?i=e.digits[0]>=`5`?`1`:`0`:(i=e.digits.slice(0,r).padEnd(r,`0`)||`0`,r<e.digits.length&&e.digits[r]>=`5`&&(i=es(i))),/^0+$/.test(i))return{negative:e.negative,integer:`0`,fraction:``,zero:!0};if(n<=0)return{negative:e.negative,integer:i+`0`.repeat(-n),fraction:``,zero:!1};let a=i.padStart(n+1,`0`);return{negative:e.negative,integer:a.slice(0,-n),fraction:a.slice(-n).replace(/0+$/,``),zero:!1}}function ns(e){let t=Number(e.fraction?`${e.integer}.${e.fraction}`:e.integer);return e.negative&&!e.zero?-t:t}function rs(e){return`${e.negative&&!e.zero?`-`:``}${e.integer}${e.fraction?`.${e.fraction}`:``}`}function is(e,t,n,r){if(e.digits===`0`)return{exponent:0,rounded:ts(e,r)};let i=t>1?Math.floor(e.exponent/t)*t:e.exponent;n||i++;let a=ts($o(e,-i),r);return t===1&&a.integer.length>1&&(i++,a=ts($o(e,-i),r)),{exponent:i,rounded:a}}let as=Object.freeze({1078:`af`,1052:`sq`,1118:`am`,5121:`ar_DZ`,15361:`ar_BH`,3073:`ar_EG`,2049:`ar_IQ`,11265:`ar_JO`,13313:`ar_KW`,12289:`ar_LB`,4097:`ar_LY`,6145:`ar_MA`,8193:`ar_OM`,16385:`ar_QA`,1025:`ar_SA`,10241:`ar_SY`,7169:`ar_TN`,14337:`ar_AE`,9217:`ar_YE`,1067:`hy`,1101:`as`,2092:`az_AZ`,1068:`az_AZ`,1069:`eu`,1059:`be`,2117:`bn`,1093:`bn_IN`,5146:`bs`,1026:`bg`,1109:`my`,1027:`ca`,2052:`zh_CN`,3076:`zh_HK`,5124:`zh_MO`,4100:`zh_SG`,1028:`zh_TW`,1050:`hr`,1029:`cs`,1030:`da`,1125:`dv`,2067:`nl_BE`,1043:`nl_NL`,1126:`bin`,3081:`en_AU`,10249:`en_BZ`,4105:`en_CA`,9225:`en_CB`,2057:`en_GB`,16393:`en_IN`,6153:`en_IE`,8201:`en_JM`,5129:`en_NZ`,13321:`en_PH`,7177:`en_ZA`,11273:`en_TT`,1033:`en_US`,12297:`en_ZW`,1061:`et`,1071:`mk`,1080:`fo`,1065:`fa`,1124:`fil`,1035:`fi`,2060:`fr_BE`,11276:`fr_CM`,3084:`fr_CA`,9228:`fr_CG`,12300:`fr_CI`,1036:`fr_FR`,5132:`fr_LU`,13324:`fr_ML`,6156:`fr_MC`,14348:`fr_MA`,10252:`fr_SN`,4108:`fr_CH`,7180:`fr`,1122:`fy_NL`,2108:`gd_IE`,1084:`gd`,1110:`gl`,1079:`ka`,3079:`de_AT`,1031:`de_DE`,5127:`de_LI`,4103:`de_LU`,2055:`de_CH`,1032:`el`,1140:`gn`,1095:`gu`,1279:`en`,1037:`he`,1081:`hi`,1038:`hu`,1039:`is`,1136:`ig_NG`,1057:`id`,1040:`it_IT`,2064:`it_CH`,1041:`ja`,1099:`kn`,1120:`ks`,1087:`kk`,1107:`km`,1111:`kok`,1042:`ko`,1088:`ky`,1108:`lo`,1142:`la`,1062:`lv`,1063:`lt`,2110:`ms_BN`,1086:`ms_MY`,1100:`ml`,1082:`mt`,1112:`mni`,1153:`mi`,1102:`mr`,1104:`mn`,2128:`mn`,1121:`ne`,1044:`no_NO`,2068:`no_NO`,1096:`or`,1045:`pl`,1046:`pt_BR`,2070:`pt_PT`,1094:`pa`,1047:`rm`,2072:`ro_MO`,1048:`ro_RO`,1049:`ru`,2073:`ru_MO`,1083:`se`,1103:`sa`,3098:`sr_SP`,2074:`sr_SP`,1072:`st`,1074:`tn`,1113:`sd`,1115:`si`,1051:`sk`,1060:`sl`,1143:`so`,1070:`sb`,11274:`es_AR`,16394:`es_BO`,13322:`es_CL`,9226:`es_CO`,5130:`es_CR`,7178:`es_DO`,12298:`es_EC`,17418:`es_SV`,4106:`es_GT`,18442:`es_HN`,2058:`es_MX`,19466:`es_NI`,6154:`es_PA`,15370:`es_PY`,10250:`es_PE`,20490:`es_PR`,1034:`es_ES`,14346:`es_UY`,8202:`es_VE`,1089:`sw`,2077:`sv_FI`,1053:`sv_SE`,1114:`syc`,1064:`tg`,1097:`ta`,1092:`tt`,1098:`te`,1054:`th`,1105:`bo`,1073:`ts`,1055:`tr`,1090:`tk`,1058:`uk`,1056:`ur`,2115:`uz_UZ`,1091:`uz_UZ`,1075:`ve`,1066:`vi`,1106:`cy`,1076:`xh`,1085:`yi`,1077:`zu`}),os=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,ss={},H=(e,t=``)=>e.replace(/~/g,t).split(`;`),U=(e,t=0,n=0)=>(e.mmm||=t<1?e.mmmm.concat():e.mmmm.map(e=>{let n=e.slice(0,t%10);return n+(t<10||e===n?``:`.`)}),e.ddd||=n<1?e.dddd.concat():e.dddd.map(e=>{let t=e.slice(0,n%10);return t+(n<10||e===t?``:`.`)}),!e.mmm6&&e.mmmm6&&(e.mmm6=e.mmmm6),e),cs={group:`\xA0`,decimal:`.`,positive:`+`,negative:`-`,percent:`%`,exponent:`E`,nan:`NaN`,infinity:`∞`,ampm:H(`AM;PM`),mmmm6:H(`Muharram;Safar;Rabiʻ I;Rabiʻ II;Jumada I;Jumada II;Rajab;Shaʻban;Ramadan;Shawwal;Dhuʻl-Qiʻdah;Dhuʻl-Hijjah`),mmm6:H(`Muh.;Saf.;Rab. I;Rab. II;Jum. I;Jum. II;Raj.;Sha.;Ram.;Shaw.;Dhuʻl-Q.;Dhuʻl-H.`),mmmm:H(`January;February;March;April;May;June;July;August;September;October;November;December`),mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec`),dddd:H(`Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday`),ddd:H(`Sun;Mon;Tue;Wed;Thu;Fri;Sat`),bool:H(`TRUE;FALSE`),preferMDY:!1};function ls(e){let t=os.exec(e);if(!t)throw SyntaxError(`Malformed locale: ${e}`);return{lang:t[1]+(t[2]?`_${t[2]}`:``),language:t[1],territory:t[2]||``}}function us(e){if(typeof e==`number`)return as[e&65535]||null;let t=Number.parseInt(e,16);return Number.isFinite(t)&&as[t&65535]?as[t&65535]||null:os.test(e)?e:null}function ds(e){let t=us(e),n=null;if(t){let e=ls(t);n=ss[e.lang]||ss[e.language]||null}return n}function fs(e){return Object.assign({},cs,e)}function W(e,t){let n=typeof t==`object`?t:ls(t);return ss[n.lang]=fs(e),n.language!==n.lang&&!ss[n.language]&&(ss[n.language]=fs(e)),ss[n.lang]}let ps=fs({group:`,`,preferMDY:!0});ps.isDefault=!0,W({group:`,`,ampm:H(`上午;下午`),mmmm:H(`一月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)},`zh_CN`);let ms={group:`,`,ampm:H(`上午;下午`),mmmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)};W({...ms,nan:`非數值`,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_TW`),W({...ms,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_HK`),W({...ms,ampm:H(`午前;午後`),dddd:H(`日~;月~;火~;水~;木~;金~;土~`,`曜日`),ddd:H(`日;月;火;水;木;金;土`)},`ja`),W({group:`,`,ampm:H(`오전;오후`),mmmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),mmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),dddd:H(`일요일;월요일;화요일;수요일;목요일;금요일;토요일`),ddd:H(`일;월;화;수;목;금;토`)},`ko`),W({group:`,`,ampm:H(`ก่อนเที่ยง;หลังเที่ยง`),mmmm:H(`มกร~;กุมภาพันธ์;มีน~;เมษายน;พฤษภ~;มิถุนายน;กรกฎ~;สิงห~;กันยายน;ตุล~;พฤศจิกายน;ธันว~`,`าคม`),mmm:H(`ม.ค.;ก.พ.;มี.ค.;เม.ย.;พ.ค.;มิ.ย.;ก.ค.;ส.ค.;ก.ย.;ต.ค.;พ.ย.;ธ.ค.`),dddd:H(`วันอาทิตย์;วันจันทร์;วันอังคาร;วันพุธ;วันพฤหัสบดี;วันศุกร์;วันเสาร์`),ddd:H(`อา.;จ.;อ.;พ.;พฤ.;ศ.;ส.`)},`th`),W(U({decimal:`,`,ampm:H(`dop.;odp.`),mmmm:H(`ledna;února;března;dubna;května;června;července;srpna;září;října;listopadu;prosince`),mmm:H(`I;II;III;IV;V;VI;VII;VIII;IX;X;XI;XII`),dddd:H(`neděle;pondělí;úterý;středa;čtvrtek;pátek;sobota`),bool:H(`PRAVDA;NEPRAVDA`)},-1,2),`cs`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marts;april;maj;juni;juli;august;september;oktober;november;december`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SAND;FALSK`)},13,13),`da`),W(U({group:`.`,decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januari;februari;maart;april;mei;juni;juli;augustus;september;oktober;november;december`),mmm:H(`jan.;feb.;mrt.;apr.;mei;jun.;jul.;aug.;sep.;okt.;nov.;dec.`),dddd:H(`zondag;maandag;dinsdag;woensdag;donderdag;vrijdag;zaterdag`),bool:H(`WAAR;ONWAAR`)},-1,2),`nl`),W({group:`,`,preferMDY:!0},`en`),W({group:`,`,preferMDY:!0},`en_US`),W({group:`,`},`en_AU`),W({group:`,`},`en_CA`),W({group:`,`},`en_GB`),W({group:`,`,mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sept;Oct;Nov;Dec`)},`en_IE`),W(U({decimal:`,`,nan:`epäluku`,ampm:H(`ap.;ip.`),mmmm:H(`tammi~;helmi~;maalis~;huhti~;touko~;kesä~;heinä~;elo~;syys~;loka~;marras~;joulu~`,`kuuta`),mmm:H(`tammik.;helmik.;maalisk.;huhtik.;toukok.;kesäk.;heinäk.;elok.;syysk.;lokak.;marrask.;jouluk.`),dddd:H(`sunnun~;maanan~;tiis~;keskiviikkona;tors~;perjan~;lauan~`,`taina`),bool:H(`TOSI;EPÄTOSI`)},-1,2),`fi`);let hs=U({group:` `,decimal:`,`,mmmm:H(`janvier;février;mars;avril;mai;juin;juillet;août;septembre;octobre;novembre;décembre`),mmm:H(`janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.`),dddd:H(`~manche;lun~;mar~;mercre~;jeu~;vendre~;same~`,`di`),bool:H(`VRAI;FAUX`)},-1,13);W({...hs},`fr`),W({...hs,mmm:H(`janv.;févr.;mars;avr.;mai;juin;juill.;août;sept.;oct.;nov.;déc.`)},`fr_CA`),W({group:`'`,decimal:`.`,...hs},`fr_CH`);let gs=U({mmmm:H(`Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember`),mmm:H(`Jan.;Feb.;März;Apr.;Mai;Juni;Juli;Aug.;Sept.;Okt.;Nov.;Dez.`),dddd:H(`Sonn~;Mon~;Diens~;Mittwoch;Donners~;Frei~;Sams~`,`tag`),bool:H(`WAHR;FALSCH`)},-1,12);W({group:`.`,decimal:`,`,...gs},`de`),W({group:`'`,decimal:`.`,...gs},`de_CH`),W(U({group:`.`,decimal:`,`,ampm:H(`π.μ.;μ.μ.`),mmmm:H(`Ιανουαρ~;Φεβρουαρ~;Μαρτ~;Απριλ~;Μαΐου;Ιουν~;Ιουλ~;Αυγούστου;Σεπτεμβρ~;Οκτωβρ~;Νοεμβρ~;Δεκεμβρ~`,`ίου`),mmm:H(`Ιαν;Φεβ;Μαρ;Απρ;Μαΐ;Ιουν;Ιουλ;Αυγ;Σεπ;Οκτ;Νοε;Δεκ`),dddd:H(`Κυριακή;Δευτέρα;Τρίτη;Τετάρτη;Πέμπτη;Παρασκευή;Σάββατο`)},-1,3),`el`),W({decimal:`,`,ampm:H(`de.;du.`),mmmm:H(`január;február;március;április;május;június;július;augusztus;szeptember;október;november;december`),mmm:H(`jan.;febr.;márc.;ápr.;máj.;jún.;júl.;aug.;szept.;okt.;nov.;dec.`),dddd:H(`vasárnap;hétfő;kedd;szerda;csütörtök;péntek;szombat`),ddd:H(`V;H;K;Sze;Cs;P;Szo`),bool:H(`IGAZ;HAMIS`)},`hu`),W(U({group:`.`,decimal:`,`,ampm:H(`f.h.;e.h.`),mmmm:H(`janúar;febrúar;mars;apríl;maí;júní;júlí;ágúst;september;október;nóvember;desember`),dddd:H(`sunnu~;mánu~;þriðju~;miðviku~;fimmtu~;föstu~;laugar~`,`dagur`)},13,13),`is`),W(U({group:`.`,decimal:`,`,mmmm:H(`Januari;Februari;Maret;April;Mei;Juni;Juli;Agustus;September;Oktober;November;Desember`),dddd:H(`Minggu;Senin;Selasa;Rabu;Kamis;Jumat;Sabtu`)},3,3),`id`);let _s=U({mmmm:H(`gennaio;febbraio;marzo;aprile;maggio;giugno;luglio;agosto;settembre;ottobre;novembre;dicembre`),dddd:H(`domenica;lunedì;martedì;mercoledì;giovedì;venerdì;sabato`),bool:H(`VERO;FALSO`)},3,3);W({group:`.`,decimal:`,`,..._s},`it`),W({group:`'`,decimal:`.`,..._s},`it_CH`);let vs={decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januar;februar;mars;april;mai;juni;juli;august;september;oktober;november;desember`),mmm:H(`jan.;feb.;mar.;apr.;mai;jun.;jul.;aug.;sep.;okt.;nov.;des.`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SANN;USANN`)};W(U({...vs},-1,13),`nb`),W(U({...vs},-1,13),`no`),W(U({decimal:`,`,mmmm:H(`stycznia;lutego;marca;kwietnia;maja;czerwca;lipca;sierpnia;września;października;listopada;grudnia`),dddd:H(`niedziela;poniedziałek;wtorek;środa;czwartek;piątek;sobota`),ddd:H(`niedz.;pon.;wt.;śr.;czw.;pt.;sob.`),bool:H(`PRAWDA;FAŁSZ`)},3,-1),`pl`);let ys={group:`.`,decimal:`,`,mmmm:H(`janeiro;fevereiro;março;abril;maio;junho;julho;agosto;setembro;outubro;novembro;dezembro`),dddd:H(`domingo;segunda-feira;terça-feira;quarta-feira;quinta-feira;sexta-feira;sábado`),bool:H(`VERDADEIRO;FALSO`)};W(U(ys,13,13),`pt`),W(U(ys,13,13),`pt_BR`),W({decimal:`,`,nan:`не\xA0число`,mmmm:H(`января;февраля;марта;апреля;мая;июня;июля;августа;сентября;октября;ноября;декабря`),mmm:H(`янв.;февр.;мар.;апр.;мая;июн.;июл.;авг.;сент.;окт.;нояб.;дек.`),dddd:H(`воскресенье;понедельник;вторник;среда;четверг;пятница;суббота`),ddd:H(`вс;пн;вт;ср;чт;пт;сб`),mmmm6:H(`рамадан;шавваль;зуль-каада;зуль-хиджжа;мухаррам;раби-уль-авваль;раби-уль-ахир;джумад-уль-авваль;джумад-уль-ахир;раджаб;шаабан;рамадан`),mmm6:H(`рам.;шав.;зуль-к.;зуль-х.;мух.;раб. I;раб. II;джум. I;джум. II;радж.;шааб.;рам.`),bool:H(`ИСТИНА;ЛОЖЬ`)},`ru`),W(U({decimal:`,`,mmmm:H(`januára;februára;marca;apríla;mája;júna;júla;augusta;septembra;októbra;novembra;decembra`),dddd:H(`nedeľa;pondelok;utorok;streda;štvrtok;piatok;sobota`)},3,2),`sk`);let bs={group:`.`,decimal:`,`,ampm:H(`a.\xA0m.;p.\xA0m.`),mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;septiem~;octu~;noviem~;diciem~`,`bre`),mmm:H(`ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic`),dddd:H(`domingo;lunes;martes;miércoles;jueves;viernes;sábado`),ddd:H(`dom;lun;mar;mié;jue;vie;sáb`),bool:H(`VERDADERO;FALSO`)},xs=H(`ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic`),Ss=H(`ene.;feb.;mar.;abr.;may.;jun.;jul.;ago.;sept.;oct.;nov.;dic.`);W({...bs},`es`),W({...bs},`es_AR`),W({...bs},`es_BO`),W({...bs},`es_CL`),W({...bs},`es_CO`),W({...bs},`es_EC`),W({...bs,mmm:xs,ampm:H(`a.m.;p.m.`)},`es_MX`),W({...bs,mmm:Ss},`es_PY`),W({...bs,mmm:Ss},`es_UY`),W({...bs,mmm:Ss,mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;setiembre;octubre;noviembre;diciembre`)},`es_VE`),W({decimal:`,`,ampm:H(`fm;em`),mmmm:H(`januari;februari;mars;april;maj;juni;juli;augusti;september;oktober;november;december`),mmm:H(`jan.;feb.;mars;apr.;maj;juni;juli;aug.;sep.;okt.;nov.;dec.`),dddd:H(`sön~;mån~;tis~;ons~;tors~;fre~;lör~`,`dag`),ddd:H(`sön;mån;tis;ons;tors;fre;lör`)},`sv`),W(U({group:`.`,decimal:`,`,ampm:H(`ÖÖ;ÖS`),mmmm:H(`Ocak;Şubat;Mart;Nisan;Mayıs;Haziran;Temmuz;Ağustos;Eylül;Ekim;Kasım;Aralık`),mmm:H(`Oca;Şub;Mar;Nis;May;Haz;Tem;Ağu;Eyl;Eki;Kas;Ara`),dddd:H(`Pazar;Pazartesi;Salı;Çarşamba;Perşembe;Cuma;Cumartesi`),ddd:H(`Paz;Pzt;Sal;Çar;Per;Cum;Cmt`),bool:H(`DOĞRU;YANLIŞ`)},3,-1),`tr`),W({group:`,`,ampm:H(`yb;yh`),mmmm:H(`Ionawr;Chwefror;Mawrth;Ebrill;Mai;Mehefin;Gorffennaf;Awst;Medi;Hydref;Tachwedd;Rhagfyr`),mmm:H(`Ion;Chwef;Maw;Ebr;Mai;Meh;Gorff;Awst;Medi;Hyd;Tach;Rhag`),dddd:H(`Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn`),ddd:H(`Sul;Llun;Maw;Mer;Iau;Gwen;Sad`)},`cy`),W({group:`.`,decimal:`,`,mmmm:H(`yanvar;fevral;mart;aprel;may;iyun;iyul;avqust;sentyabr;oktyabr;noyabr;dekabr`),mmm:H(`yan;fev;mar;apr;may;iyn;iyl;avq;sen;okt;noy;dek`),dddd:H(`bazar;bazar ertəsi;çərşənbə axşamı;çərşənbə;cümə axşamı;cümə;şənbə`),ddd:H(`B.;B.e.;Ç.a.;Ç.;C.a.;C.;Ş.`)},`az`),W(U({decimal:`,`,mmmm:H(`студзеня;лютага;сакавіка;красавіка;мая;чэрвеня;ліпеня;жніўня;верасня;кастрычніка;лістапада;снежня`),dddd:H(`нядзеля;панядзелак;аўторак;серада;чацвер;пятніца;субота`),ddd:H(`нд;пн;аў;ср;чц;пт;сб`)},3,-1),`be`),W({decimal:`,`,ampm:H(`пр.об.;сл.об.`),mmmm:H(`януари;февруари;март;април;май;юни;юли;август;септември;октомври;ноември;декември`),mmm:H(`яну;фев;март;апр;май;юни;юли;авг;сеп;окт;ное;дек`),dddd:H(`неделя;понеделник;вторник;сряда;четвъртък;петък;събота`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),bool:H(`ИСТИНА;ЛОЖЬ`)},`bg`),W({group:`.`,decimal:`,`,mmmm:H(`de gener;de febrer;de març;d’abril;de maig;de juny;de juliol;d’agost;de setembre;d’octubre;de novembre;de desembre`),mmm:H(`de gen.;de febr.;de març;d’abr.;de maig;de juny;de jul.;d’ag.;de set.;d’oct.;de nov.;de des.`),dddd:H(`diumenge;dilluns;dimarts;dimecres;dijous;divendres;dissabte`),ddd:H(`dg.;dl.;dt.;dc.;dj.;dv.;ds.`),ampm:H(`a.\xA0m.;p.\xA0m.`)},`ca`),W(U({group:`,`,decimal:`.`,mmmm:H(`Enero;Pebrero;Marso;Abril;Mayo;Hunyo;Hulyo;Agosto;Setyembre;Oktubre;Nobyembre;Disyembre`),dddd:H(`Linggo;Lunes;Martes;Miyerkules;Huwebes;Biyernes;Sabado`)},3,3),`fil`),W({group:`,`,decimal:`.`,mmmm:H(`જાન્યુઆરી;ફેબ્રુઆરી;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટેમ્બર;ઑક્ટોબર;નવેમ્બર;ડિસેમ્બર`),mmm:H(`જાન્યુ;ફેબ્રુ;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટે;ઑક્ટો;નવે;ડિસે`),dddd:H(`રવિ~;સોમ~;મંગળ~;બુધ~;ગુરુ~;શુક્ર~;શનિ~`,`વાર`),ddd:H(`રવિ;સોમ;મંગળ;બુધ;ગુરુ;શુક્ર;શનિ`)},`gu`),W({group:`,`,decimal:`.`,ampm:H(`לפנה״צ;אחה״צ`),dddd:H(`~ראשון;~שני;~שלישי;~רביעי;~חמישי;~שישי;~שבת`,`יום `),ddd:H(`~א׳;~ב׳;~ג׳;~ד׳;~ה׳;~ו׳;שבת`,`יום `),mmmm:H(`ינואר;פברואר;מרץ;אפריל;מאי;יוני;יולי;אוגוסט;ספטמבר;אוקטובר;נובמבר;דצמבר`),mmm:H(`ינו׳;פבר׳;מרץ;אפר׳;מאי;יוני;יולי;אוג׳;ספט׳;אוק׳;נוב׳;דצמ׳`),mmmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע אל־אוול;רביע א־ת׳אני;ג׳ומאדא אל־אולא;ג׳ומאדא א־ת׳אניה;רג׳ב;שעבאן;רמדאן`),mmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע א׳;רביע ב׳;ג׳ומאדא א׳;ג׳ומאדא ב׳;רג׳ב;שעבאן;רמדאן`)},`he`),W(U({group:`.`,decimal:`,`,mmmm:H(`siječnja;veljače;ožujka;travnja;svibnja;lipnja;srpnja;kolovoza;rujna;listopada;studenoga;prosinca`),mmm:H(`sij;velj;ožu;tra;svi;lip;srp;kol;ruj;lis;stu;pro`),dddd:H(`nedjelja;ponedjeljak;utorak;srijeda;četvrtak;petak;subota`)},-1,3),`hr`),W({decimal:`,`,mmmm:H(`հունվարի;փետրվարի;մարտի;ապրիլի;մայիսի;հունիսի;հուլիսի;օգոստոսի;սեպտեմբերի;հոկտեմբերի;նոյեմբերի;դեկտեմբերի`),mmm:H(`հնվ;փտվ;մրտ;ապր;մյս;հնս;հլս;օգս;սեպ;հոկ;նոյ;դեկ`),dddd:H(`կիրակի;երկուշաբթի;երեքշաբթի;չորեքշաբթի;հինգշաբթի;ուրբաթ;շաբաթ`),ddd:H(`կիր;երկ;երք;չրք;հնգ;ուր;շբթ`)},`hy`),W(U({decimal:`,`,mmmm:H(`იანვარი;თებერვალი;მარტი;აპრილი;მაისი;ივნისი;ივლისი;აგვისტო;სექტემბერი;ოქტომბერი;ნოემბერი;დეკემბერი`),dddd:H(`კვირა;ორშაბათი;სამშაბათი;ოთხშაბათი;ხუთშაბათი;პარასკევი;შაბათი`)},3,3),`ka`),W(U({decimal:`,`,mmmm:H(`қаңтар;ақпан;наурыз;сәуір;мамыр;маусым;шілде;тамыз;қыркүйек;қазан;қараша;желтоқсан`),dddd:H(`жексенбі;дүйсенбі;сейсенбі;сәрсенбі;бейсенбі;жұма;сенбі`),ddd:H(`жс;дс;сс;ср;бс;жм;сб`)},13,-1),`kk`),W({group:`,`,mmmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿಲ್;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂಬರ್;ಅಕ್ಟೋಬರ್;ನವೆಂಬರ್;ಡಿಸೆಂಬರ್`),mmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿ;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂ;ಅಕ್ಟೋ;ನವೆಂ;ಡಿಸೆಂ`),dddd:H(`ಭಾನು~;ಸೋಮ~;ಮಂಗಳ~;ಬುಧ~;ಗುರು~;ಶುಕ್ರ~;ಶನಿ~`,`ವಾರ`),ddd:H(`ಭಾನು;ಸೋಮ;ಮಂಗಳ;ಬುಧ;ಗುರು;ಶುಕ್ರ;ಶನಿ`),ampm:H(`ಪೂರ್ವಾಹ್ನ;ಅಪರಾಹ್ನ`)},`kn`),W({decimal:`,`,mmmm:H(`sausio;vasario;kovo;balandžio;gegužės;birželio;liepos;rugpjūčio;rugsėjo;spalio;lapkričio;gruodžio`),mmm:H(`saus.;vas.;kov.;bal.;geg.;birž.;liep.;rugp.;rugs.;spal.;lapkr.;gruod.`),dddd:H(`sekmadienis;pirmadienis;antradienis;trečiadienis;ketvirtadienis;penktadienis;šeštadienis`),ddd:H(`sk;pr;an;tr;kt;pn;št`),ampm:H(`priešpiet;popiet`)},`lt`),W({decimal:`,`,mmmm:H(`janvāris;februāris;marts;aprīlis;maijs;jūnijs;jūlijs;augusts;septembris;oktobris;novembris;decembris`),mmm:H(`janv.;febr.;marts;apr.;maijs;jūn.;jūl.;aug.;sept.;okt.;nov.;dec.`),dddd:H(`svētdiena;pirmdiena;otrdiena;trešdiena;ceturtdiena;piektdiena;sestdiena`),ddd:H(`svētd.;pirmd.;otrd.;trešd.;ceturtd.;piektd.;sestd.`),ampm:H(`priekšpusdienā;pēcpusdienā`)},`lv`),W({group:`,`,decimal:`.`,mmmm:H(`ജനുവരി;ഫെബ്രുവരി;മാർച്ച്;ഏപ്രിൽ;മേയ്;ജൂൺ;ജൂലൈ;ഓഗസ്റ്റ്;സെപ്റ്റംബർ;ഒക്ടോബർ;നവംബർ;ഡിസംബർ`),mmm:H(`ജനു;ഫെബ്രു;മാർ;ഏപ്രി;മേയ്;ജൂൺ;ജൂലൈ;ഓഗ;സെപ്റ്റം;ഒക്ടോ;നവം;ഡിസം`),dddd:H(`ഞായറാഴ്ച;തിങ്കളാഴ്ച;ചൊവ്വാഴ്ച;ബുധനാഴ്ച;വ്യാഴാഴ്ച;വെള്ളിയാഴ്ച;ശനിയാഴ്ച`),ddd:H(`ഞായർ;തിങ്കൾ;ചൊവ്വ;ബുധൻ;വ്യാഴം;വെള്ളി;ശനി`)},`ml`),W({group:`,`,decimal:`.`,mmmm:H(`нэгдүгээ~;хоёрдугаа~;гуравдугаа~;дөрөвдүгээ~;тавдугаа~;зургаадугаа~;долоодугаа~;наймдугаа~;есдүгээ~;аравдугаа~;арван нэгдүгээ~;арван хоёрдугаа~`,`р сар`),mmm:H(`1~;2~;3~;4~;5~;6~;7~;8~;9~;10~;11~;12~`,`-р сар`),dddd:H(`ням;даваа;мягмар;лхагва;пүрэв;баасан;бямба`),ddd:H(`Ня;Да;Мя;Лх;Пү;Ба;Бя`),ampm:H(`ү.ө.;ү.х.`)},`mn`),W({group:`,`,decimal:`.`,mmmm:H(`जानेवारी;फेब्रुवारी;मार्च;एप्रिल;मे;जून;जुलै;ऑगस्ट;सप्टेंबर;ऑक्टोबर;नोव्हेंबर;डिसेंबर`),mmm:H(`जाने;फेब्रु;मार्च;एप्रि;मे;जून;जुलै;ऑग;सप्टें;ऑक्टो;नोव्हें;डिसें`),dddd:H(`रविवार;सोमवार;मंगळवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगळ;बुध;गुरु;शुक्र;शनि`)},`mr`),W(U({group:`,`,decimal:`.`,mmmm:H(`ဇန်နဝါရီ;ဖေဖော်ဝါရီ;မတ်;ဧပြီ;မေ;ဇွန်;ဇူလိုင်;ဩဂုတ်;စက်တင်ဘာ;အောက်တိုဘာ;နိုဝင်ဘာ;ဒီဇင်ဘာ`),mmm:H(`ဇန်;ဖေ;မတ်;ဧ;မေ;ဇွန်;ဇူ;ဩ;စက်;အောက်;နို;ဒီ`),dddd:H(`တနင်္ဂနွေ;တနင်္လာ;အင်္ဂါ;ဗုဒ္ဓဟူး;ကြာသပတေး;သောကြာ;စနေ`),ampm:H(`နံနက်;ညနေ`)},-1,0),`my`),W({group:`,`,decimal:`.`,mmmm:H(`ਜਨਵਰੀ;ਫ਼ਰਵਰੀ;ਮਾਰਚ;ਅਪ੍ਰੈਲ;ਮਈ;ਜੂਨ;ਜੁਲਾਈ;ਅਗਸਤ;ਸਤੰਬਰ;ਅਕਤੂਬਰ;ਨਵੰਬਰ;ਦਸੰਬਰ`),mmm:H(`ਜਨ;ਫ਼ਰ;ਮਾਰਚ;ਅਪ੍ਰੈ;ਮਈ;ਜੂਨ;ਜੁਲਾ;ਅਗ;ਸਤੰ;ਅਕਤੂ;ਨਵੰ;ਦਸੰ`),dddd:H(`ਐਤਵਾਰ;ਸੋਮਵਾਰ;ਮੰਗਲਵਾਰ;ਬੁੱਧਵਾਰ;ਵੀਰਵਾਰ;ਸ਼ੁੱਕਰਵਾਰ;ਸ਼ਨਿੱਚਰਵਾਰ`),ddd:H(`ਐਤ;ਸੋਮ;ਮੰਗਲ;ਬੁੱਧ;ਵੀਰ;ਸ਼ੁੱਕਰ;ਸ਼ਨਿੱਚਰ`),ampm:H(`ਪੂ.ਦੁ.;ਬਾ.ਦੁ.`)},`pa`),W({group:`.`,decimal:`,`,mmmm:H(`ianuarie;februarie;martie;aprilie;mai;iunie;iulie;august;septem~;octom~;noiem~;decem~`,`brie`),mmm:H(`ian.;feb.;mar.;apr.;mai;iun.;iul.;aug.;sept.;oct.;nov.;dec.`),dddd:H(`duminică;luni;marți;miercuri;joi;vineri;sâmbătă`),ddd:H(`dum.;lun.;mar.;mie.;joi;vin.;sâm.`),ampm:H(`a.m.;p.m.`)},`ro`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marec;april;maj;junij;julij;avgust;september;oktober;november;december`),mmm:H(`jan.;feb.;mar.;apr.;maj;jun.;jul.;avg.;sep.;okt.;nov.;dec.`),dddd:H(`nedelja;ponedeljek;torek;sreda;četrtek;petek;sobota`),ampm:H(`dop.;pop.`)},-1,13),`sl`),W(U({group:`.`,decimal:`,`,mmmm:H(`јануар;фебруар;март;април;мај;јун;јул;август;септембар;октобар;новембар;децембар`),dddd:H(`недеља;понедељак;уторак;среда;четвртак;петак;субота`)},3,3),`sr`),W({group:`,`,decimal:`.`,mmmm:H(`ஜனவரி;பிப்ரவரி;மார்ச்;ஏப்ரல்;மே;ஜூன்;ஜூலை;ஆகஸ்ட்;செப்டம்பர்;அக்டோபர்;நவம்பர்;டிசம்பர்`),mmm:H(`ஜன.;பிப்.;மார்.;ஏப்.;மே;ஜூன்;ஜூலை;ஆக.;செப்.;அக்.;நவ.;டிச.`),dddd:H(`ஞாயிறு;திங்கள்;செவ்வாய்;புதன்;வியாழன்;வெள்ளி;சனி`),ddd:H(`ஞாயி.;திங்.;செவ்.;புத.;வியா.;வெள்.;சனி`)},`ta`),W({group:`,`,decimal:`.`,mmmm:H(`జనవరి;ఫిబ్రవరి;మార్చి;ఏప్రిల్;మే;జూన్;జులై;ఆగస్టు;సెప్టెంబర్;అక్టోబర్;నవంబర్;డిసెంబర్`),mmm:H(`జన;ఫిబ్ర;మార్చి;ఏప్రి;మే;జూన్;జులై;ఆగ;సెప్టెం;అక్టో;నవం;డిసెం`),dddd:H(`ఆదివారం;సోమవారం;మంగళవారం;బుధవారం;గురువారం;శుక్రవారం;శనివారం`),ddd:H(`ఆది;సోమ;మంగళ;బుధ;గురు;శుక్ర;శని`)},`te`),W({decimal:`,`,mmmm:H(`січня;лютого;березня;квітня;травня;червня;липня;серпня;вересня;жовтня;листопада;грудня`),mmm:H(`січ.;лют.;бер.;квіт.;трав.;черв.;лип.;серп.;вер.;жовт.;лист.;груд.`),dddd:H(`неділю;понеділок;вівторок;середу;четвер;пʼятницю;суботу`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),ampm:H(`дп;пп`)},`uk`),W({group:`.`,decimal:`,`,mmmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`tháng `),mmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`thg `),dddd:H(`Chủ Nhật;Thứ Hai;Thứ Ba;Thứ Tư;Thứ Năm;Thứ Sáu;Thứ Bảy`),ddd:H(`CN;Th 2;Th 3;Th 4;Th 5;Th 6;Th 7`),ampm:H(`SA;CH`)},`vi`),W(U({group:`٬`,decimal:`٫`,ampm:H(`ص;م`),mmmm:H(`يناير;فبراير;مارس;أبريل;مايو;يونيو;يوليو;أغسطس;سبتمبر;أكتوبر;نوفمبر;ديسمبر`),dddd:H(`الأحد;الاثنين;الثلاثاء;الأربعاء;الخميس;الجمعة;السبت`),mmmm6:H(`رمضان;شوال;ذو القعدة;ذو الحجة;محرم;ربيع الأول;ربيع الآخرة;جمادى الأولى;جمادى الآخرة;رجب;شعبان;رمضان`)},0,0),`ar`),W({group:`,`,decimal:`.`,mmmm:H(`জানুয়ারী;ফেব্রুয়ারী;মার্চ;এপ্রিল;মে;জুন;জুলাই;আগস্ট;সেপ্টেম্বর;অক্টোবর;নভেম্বর;ডিসেম্বর`),mmm:H(`জানু;ফেব;মার্চ;এপ্রি;মে;জুন;জুল;আগ;সেপ্টেঃ;অক্টোঃ;নভেঃ;ডিসেঃ`),dddd:H(`রবিবার;সোমবার;মঙ্গলবার;বুধবার;বৃহস্পতিবার;শুক্রবার;শনিবার`),ddd:H(`রবি;সোম;মঙ্গল;বুধ;বৃহস্পতি;শুক্র;শনি`)},`bn`),W({group:`,`,decimal:`.`,mmmm:H(`जनवरी;फ़रवरी;मार्च;अप्रैल;मई;जून;जुलाई;अगस्त;सितंबर;अक्तूबर;नवंबर;दिसंबर`),mmm:H(`जन॰;फ़र॰;मार्च;अप्रैल;मई;जून;जुल॰;अग॰;सित॰;अक्तू॰;नव॰;दिस॰`),dddd:H(`रविवार;सोमवार;मंगलवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगल;बुध;गुरु;शुक्र;शनि`),ampm:H(`am;pm`)},`hi`);function Cs(e,t){switch(t){case`int`:return e.int_pattern;case`frac`:return e.frac_pattern;case`man`:return e.man_pattern;case`den`:return e.den_pattern;case`num`:return e.num_pattern}}function ws(e,t,n){let r=e.length,i=e.replace(/#/g,``).length;switch(n){case`int`:t.int_max=r,t.int_min=i;break;case`frac`:t.frac_max=r,t.frac_min=i;break;case`man`:t.man_max=r,t.man_min=i;break;case`den`:t.den_max=r,t.den_min=i;break;case`num`:t.num_max=r,t.num_min=i}return t}function G(e,t){typeof e==`string`?t.push({type:`string`,value:e}):t.push(e)}function Ts(e,t){let n=e==null?void 0:e.type;return n===`hash`||n===`zero`||n===`qmark`||n===`digit`&&t===`den`}function Es(e){if(e===null)throw TypeError(`Cannot read properties of null (reading 'num')`)}function Ds(e){let t=[],n={scale:1,scaleExponent:0,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:t,tokensUsed:0,pattern:``,int_max:0,int_min:0,frac_max:0,frac_min:0,man_max:0,man_min:0,num_max:0,num_min:0,den_max:0,den_min:0,int_p:``,man_p:``,num_p:``,den_p:``,integer:!1},r=`int`,i=null,a=[],o,s=!1,c=-1,l=!1,u=``,d=!1;for(;++c<e.length&&!l;){var f;let h=e[c],g=h.type||`error`;if(u+=h.raw,g===`general`)n.general=!0,G(h,t);else if(Ts(h,r)){let e=Cs(n,r);Ts(o,r)||(o==null?void 0:o.type)===`group`?(e.push((e.pop()||``)+h.value),Es(i),i.num+=h.value):(e.push(h.value),i={type:r,num:h.value},G(i,t))}else if(g===`paren`)h.value===`(`&&(n.parens=!0),G(h.value,t);else if(g===`digit`)G(h.value,t);else if(g===`slash`){d=!0;let e=Cs(n,r);if(e.length){if(!i)throw SyntaxError(`Format pattern is missing a numerator`);n.fractions=!0;let a=e.pop();if(a===void 0)throw SyntaxError(`Format pattern is missing a numerator`);n.num_pattern.push(a),i.type=`num`,r=`den`,G({type:`div`},t)}else G(h.value,t)}else if(g===`comma`)G(`,`,t);else if(g===`scale`)n.scale=.001**h.raw.length,n.scaleExponent=-3*h.raw.length;else if(g===`group`){if(r===`int`&&(n.grouping=!0),r===`den`)throw SyntaxError(`Cannot group denominator digits`)}else if(g===`space`)G(h,t);else if(g===`break`){l=!0;break}else if(g===`text`)n.text=!0,G(h,t);else if(g===`plus`||g===`minus`)G(h,t);else if(g===`duration`){let e=h.value.toLowerCase(),r=e[0],i={type:``,size:0,date:1,pad:e.length};r===`h`?(i.size=16,i.type=`hour-elap`):r===`m`?(i.size=32,i.type=`min-elap`):(i.size=64,i.type=`sec-elap`),n.date|=i.size,a.push(i),G(i,t)}else if(n.date&&g===`point`&&((f=e[c+1])==null?void 0:f.type)===`zero`){var p,m;let r=1;c++;let i=`0`;((p=e[c+1])==null?void 0:p.type)===`zero`&&(i+=`0`,r=2,c++),((m=e[c+1])==null?void 0:m.type)===`zero`&&(i+=`0`,r=3,c++),u+=i;let a=[64,128,256,512][r];n.date|=a,n.date_eval=!0,n.sec_decimals=Math.max(n.sec_decimals,r),G({type:`subsec`,size:a,decimals:r,date:1},t)}else if(g===`calendar`)s||(n.date_system=h.value===`B2`||h.value===`b2`?6:1);else if(g===`datetime`){let e={type:``,size:0,date:1},r=h.value.toLowerCase(),i=r[0];if(r===`y`||r===`yy`)e.size=2,e.type=`year-short`;else if(i===`y`||i===`e`)e.size=2,e.type=`year`;else if(r===`b`||r===`bb`)e.size=2,e.type=`b-year-short`;else if(i===`b`)e.size=2,e.type=`b-year`;else if(r===`d`||r===`dd`)e.size=8,e.type=`day`,e.pad=/dd/.test(r);else if(r===`ddd`||r===`aaa`)e.size=8,e.type=`weekday-short`;else if(i===`d`||i===`a`)e.size=8,e.type=`weekday`;else if(i===`h`)e.size=16,e.type=`hour`,e.pad=/hh/i.test(r);else if(i===`m`){r.length===3?(e.size=4,e.type=`monthname-short`):r.length===5?(e.size=4,e.type=`monthname-single`):r.length>=4&&(e.size=4,e.type=`monthname`);let t=a[a.length-1];!e.type&&t&&!t.used&&t.size&80&&(t.used=!0,e.size=32,e.type=`min`,e.pad=/mm/.test(r)),e.type||(e.size=4,e.type=`month`,e.pad=/mm/.test(r),e.indeterminate=!0)}else if(i===`s`){e.size=64,e.type=`sec`,e.pad=/ss/.test(r);let t=a[a.length-1];t&&t.size&32?e.used=!0:t!=null&&t.indeterminate&&(delete t.indeterminate,t.size=32,t.type=`min`,e.used=!0)}n.date|=e.size,n.date_eval=!0,a.push(e),G(e,t)}else if(g===`ampm`)n.clock=12,n.date|=16,n.date_eval=!0,h.short=h.value===`A/P`,G(h,t);else if(g===`string`||g===`escaped`||g===`char`)G(h.value,t);else if(g===`condition`)n.condition=[h.value[0],Number.parseFloat(h.value[1])];else if(g===`locale`){let e=h.value.split(`-`),r=e.length<2?``:e.slice(1).join(`-`),i=e[0];i&&G(i,t);let a=us(r);a&&(n.locale=a);let o=Number.parseInt(r,16);Number.isFinite(o)&&o&16711680&&(o>>16&255)==6&&(n.date_system=6),s=!0}else if(g===`color`){let e=h.value.toLowerCase(),t=e,r=/^color\s*(\d+)$/i.exec(e);r&&(t=Number.parseInt(r[1],10)),n.color=t}else if(g===`percent`)n.scale=100,n.scaleExponent=2,n.percent=!0,G(`%`,t);else if(g===`point`)G(h,t),n.date||(n.dec_fractions=!0,r=`frac`);else if(g===`exp`)n.exponential=!0,n.exp_plus=h.value.includes(`+`),r=`man`,G({type:`exp`,plus:n.exp_plus},t);else if(g===`skip`||g===`fill`)G(h,t);else if(g!==`dbnum`&&g!==`natnum`)throw SyntaxError(g===`error`?`Illegal character: ${u}`:`Unknown token ${g} in ${u}`);o=h}if(n.tokensUsed=c,n.pattern=u,/^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(n.pattern)&&G({type:`text`},t),n.fractions&&n.dec_fractions||n.grouping&&!n.int_pattern.length||n.fractions&&n.exponential||n.fractions&&n.den_pattern.length*n.num_pattern.length===0||d&&!n.fractions&&!n.date||n.exponential&&(n.int_pattern.length||n.frac_pattern.length)*n.man_pattern.length===0)throw SyntaxError(`Invalid pattern: ${u}`);let h=n.int_pattern.join(``),g=n.man_pattern.join(``),_=n.frac_pattern.join(``);ws(h,n,`int`);let v=0;for(let e=0;e<h.length;e++){let t=h[h.length-1-e];/^[0-9?]/.test(t)&&(v=e+1)}n.int_min=v,ws(_,n,`frac`),ws(g,n,`man`);let y=n.num_pattern.join(``),b=n.den_pattern[0]||``;if(b.includes(`?`)||y.includes(`?`)?(b=b.replace(/\d/g,`?`),b=b.replace(/#$/g,`?`),ws(y,n,`num`),ws(b,n,`den`),y=y.replace(/#$/g,`?`)):(ws(y,n,`num`),ws(b,n,`den`)),n.int_p=h,n.man_p=g,n.num_p=y,n.den_p=b,n.den_pattern.length&&(n.denominator=Number.parseInt(n.den_pattern.join(``).replace(/\D/g,``),10)),n.integer=!!h.length,!n.integer&&!n.exponential&&_.length){let e=n.tokens.findIndex(e=>e.type===`point`);n.tokens.splice(e,0,{type:`int`,value:`#`}),n.integer=!0,n.int_pattern=[`#`],n.int_p=`#`}if(n.fractions)for(let e=0;e<t.length-1;e++){let n=t[e];if(n.type!==`string`&&n.type!==`space`)continue;let r=t[e+1].type;r===`num`?n.rule=`num+int`:r===`div`?n.rule=`num`:r===`den`&&(n.rule=`den`)}return n.grouping&&n.int_pattern.length>1&&(n.grouping=!1),n}function Os(e){if(e===0)return e;let t=Math.ceil(Math.log10(e<0?-e:e)),n=10**(16-Math.floor(t));return isFinite(n)?Math.round(e*n)/n:0}function ks(e,t=2,n=2){let r=e<0?-1:1,i=10**(t||2),a=10**(n||2),o=Math.abs(e),s=0,c=0,l=0,u=1,d,f;if(e=o,e%1==0)f=[e*r,1];else if(e<1e-19)f=[r,0x8ac7230489e80000];else if(e>0x8ac7230489e80000)f=[0x8ac7230489e80000*r,1];else{do if(o=1/(o-Math.floor(o)),d=u,u=u*Math.floor(o)+s,s=d,c=l,l=Math.floor(e*u+.5),l>=i||u>=a)return[r*c,s];while(Math.abs(e-l/u)>=1e-13&&o!==Math.floor(o));f=[r*l,u]}return f}let As={total:1,sign:0,period:0,int:1,frac:0};function js(e,t=!0){let n=Qo(e);if(n.digits===`0`)return As;let r=n.exponent+1,i=Math.max(r,1),a=Math.max(0,n.digits.length-r),o=t&&n.negative?1:0,s=+(a>0);return{total:o+i+s+a,digits:Math.max(r,0)+a,sign:o,period:s,int:i,frac:a}}function Ms(e,t=0){let n=Math.floor(Math.log10(e));return t>1?Math.floor(n/t)*t:n}function Ns(e,t=1){return t<-300?Number.parseFloat(e.toExponential().split(`e`)[0]):e*10**-t}function Ps(e,t=0){if(e<0)return-Ps(-e,t);if(t){let n=10**t||1;return Ps(e*n,0)/n}return Math.round(e)}function Fs(e,t=0){if(typeof e!=`number`)return e;if(!Number.isFinite(e)||e===0)return e===0?0:e;if(!Number.isFinite(t))return Ps(e,t);let n=Math.trunc(t);if(Number.isInteger(e)&&n>=0||n>324)return e;let r=ns(ts(Qo(e),n));return Number.isFinite(r)?r:e}function Is(e,t){return e.replace(/\./,t.decimal)}function Ls(e){return e?e.negative?{...e,negative:!1}:e:null}function Rs(e){return(e==null?void 0:e.exponent)??0}function zs(e){return!e||e.exponent<-308}function Bs(e,t){let n=is(e,1,!0,5),r=n.exponent,i=Math.abs(r);return[Is(rs(n.rounded),t),t.exponent,r<0?t.negative:t.positive,i<10?`0`:``,i]}function Vs(e,t,n){let r=Math.abs(t),i=e===1?e:Math.round(e*1e5)/1e5;return[Is(String(i),n),n.exponent,t<0?n.negative:n.positive,r<10?`0`:``,r]}function Hs(e,t,n,r,i=null){let a=typeof n==`number`?n|0:0;if(typeof n==`string`)e.push(n);else if(n===a)e.push(Math.abs(a));else{let t=Math.abs(n),a=Ls(i),o=Rs(a),s=null;zs(a)&&(o=Ms(t),s=Ns(t,o),s===10&&(s=1,o++));let c=js(t);if(o>=-4&&o<=-1){let n=t.toPrecision(10+o).replace(/\.?0+$/,``);e.push(Is(n,r))}else if(o===10){let n=t.toFixed(10).slice(0,12).replace(/\.$/,``);e.push(Is(n,r))}else if(Math.abs(o)<=9){if(c.total<=11){let n=Fs(t,9).toFixed(c.frac);e.push(Is(n,r))}else o===9?e.push(Math.floor(t)):o>=0&&o<9?e.push(Is(String(Fs(t,9-o)),r)):e.push(...s===null?Bs(a,r):Vs(s,o,r))}else c.total>=12?e.push(...s===null?Bs(a,r):Vs(s,o,r)):e.push(Is(Fs(t,9).toFixed(c.frac),r))}return e}function Us(e,t=!1){return e===`0`?`0`:e===`?`?t?`\xA0`:` `:``}let Ws=Math.floor;function Gs(e,t=!0){if(t&&e>=0){if(e===0)return[1900,1,0];if(e===60)return[1900,2,29];if(e<60)return[1900,e<32?1:2,(e-1)%31+1]}let n=e+68569+2415019,r=Ws(4*n/146097);n-=Ws((146097*r+3)/4);let i=Ws(4e3*(n+1)/1461001);n=n-Ws(1461*i/4)+31;let a=Ws(80*n/2447),o=n-Ws(2447*a/80);n=Ws(a/11);let s=a+2-12*n;return[100*(r-49)+i+n|0,s|0,o|0]}function Ks(e){return Gs(e+1462)}function qs(e){if(e===60)throw Error(`#VALUE!`);if(e<=1)return[1317,8,29];if(e<60)return[1317,e<32?9:10,1+(e-2)%30];let t=10631/30,n=8.01/60,r=e+466935,i=Ws(r/10631);r-=10631*i;let a=Ws((r-n)/t);r-=Ws(a*t+n);let o=Ws((r+28.5001)/29.5);return o===13?[30*i+a,12,30]:[30*i+a,o,r-Ws(29.5001*o-29)]}function Js(e,t=0,n=!0){let r=Ws(e);return t===6?qs(r):t===-1?Ks(r):Gs(r,n)}let Ys=Math.floor,Xs=86400,Zs=Date.UTC,Qs=1462,$s=9999;function ec(e=`date1900`){return e===`date1904`?2957003:2958465}function tc(e){return e%4==0&&(e%100!=0||e%400==0)}function nc(e,t,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||e<1||e>$s||t<1||t>12)return!1;let r=[31,tc(e)?29:28,31,30,31,30,31,31,30,31,30,31];return n>=1&&n<=r[t-1]}function rc(e,t,n){let r=e-+(t<=2),i=Math.floor(r/400),a=r-i*400,o=t+(t>2?-3:9),s=Math.floor((153*o+2)/5)+n-1,c=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return i*146097+c-719468}function ic(e,t,n){if(e===1900&&t===1&&n===0)return 0;if(e===1900&&t===2&&n===29)return 60;if(!nc(e,t,n))return null;let r=rc(e,t,n);return r+(r<=-25509?25568:25569)}function ac(e,t){if(!Number.isFinite(e)||e<0||e>=ec(t.dateSystem)+1)return null;let n=Math.floor(e),[r,i,a]=Js(t.dateSystem===`date1904`?n+Qs:n,0,!0);if(r>$s)return null;let o=(e-n)*Xs,s=Math.floor(o);return{year:r,month:i,day:a,hours:Math.floor(s/3600),minutes:Math.floor(s/60)%60,seconds:s%60,fractionalSecond:o-s}}function oc(e,t){let n=e.year===1900&&e.month===2&&e.day===29?28:e.day;return new Date(Date.UTC(e.year,e.month-1,n,t?e.hours:0,t?e.minutes:0,t?e.seconds:0,t?Math.round(e.fractionalSecond*1e3):0))}function sc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!1):/* @__PURE__ */ new Date(NaN)}function cc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!0):/* @__PURE__ */ new Date(NaN)}function lc(e,t){let{year:n,month:r,day:i,hours:a,minutes:o,seconds:s,fractionalSecond:c}=e;if(!Number.isInteger(a)||a<0||a>23||!Number.isInteger(o)||o<0||o>59||!Number.isInteger(s)||s<0||s>59||!Number.isFinite(c)||c<0||c>=1||t.dateSystem===`date1900`&&n<1900)return null;let l=ic(n,r,i);if(l==null)return null;if(t.dateSystem===`date1904`){if(n===1900&&r===1&&i===0||n===1900&&r===2&&i===29)return null;l-=Qs}return l<0?null:l+(a*3600+o*60+s+c)/Xs}function uc(e,t,n){return Number.isFinite(e.getTime())?lc({year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hours:t?e.getUTCHours():0,minutes:t?e.getUTCMinutes():0,seconds:t?e.getUTCSeconds():0,fractionalSecond:t?e.getUTCMilliseconds()/1e3:0},{dateSystem:n})??((t?e.getTime():Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))-(n===`date1904`?Date.UTC(1904,0,1):Date.UTC(1899,11,31)))/864e5:NaN}function dc(e,t=`date1900`){return uc(e,!1,t)}function fc(e,t=`date1900`){return uc(e,!0,t)}function pc(e,t){let n=null;if(Array.isArray(e)){let[t,r,i,a,o,s]=e;n=Zs(t,r==null?0:r-1,i??1,a||0,o||0,s||0)}else if(e instanceof Date&&(n=e.getTime(),!(t!=null&&t.ignoreTimezone))){let t=/* @__PURE__ */ new Date;t.setUTCFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t.setUTCHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n=t.getTime()}if(n!=null&&Number.isFinite(n)){let e=n/864e5;return e-(e<=-25509?-25568:-25569)}return null}function mc(e,t){let n=e|0,r=Xs*(e-n),i=Ys(r);r-i>.9999&&(i+=1,i===Xs&&(i=0,n+=1));let a=i<0?Xs+i:i,[o,s,c]=Js(e,0,t==null?void 0:t.leap1900);return[o,s,c,Ys(a/60/60)%60,Ys(a/60)%60,Ys(a)%60]}let hc=86400;function gc(e,t,n,r){if(n)return e<-694324||t>=35830291;let i=ec(r)+1;return e<0||t>=i}function _c(e,t=0){if(e<0)return-_c(-e,t);if(t){let n=10**t||1;return _c(e*n,0)/n}return Math.round(e)}function vc(e,t,n,r,i=null){let a=t,o=e,s=e,c=``,l=``,u=``,d=``,f=``,p=``,m=0,h=null,g=0;if(typeof o==`bigint`){if(o<=2**53-1&&o>=-(2**53-1))s=Number(o),o=s;else return n.bigintErrorNumber?String(o):n.overflow;g=s}else g=Math.trunc(s);let _=0,v=0,y=1,b=0,x=0,S=0,C=0,w=0,T=0,E=r||ps,D=i;if(!D&&typeof e==`number`&&Number.isFinite(e)&&(D=Qo(e)),D&&!a.text&&a.scaleExponent&&(D=$o(D,a.scaleExponent)),!a.text&&Number.isFinite(a.scale)&&a.scale!==1&&(s=Os(s*a.scale),o=s),a.exponential&&D&&D.exponent>=-308){let e=is(D,a.int_max,!!a.integer,a.frac_max);m=e.exponent,h=e.rounded,c+=Math.abs(m)}else if(a.exponential){let e=Math.abs(s);e&&(m=Ms(e,a.int_max)),s&&!a.integer&&m++,e=Ns(e,m),a.int_max===1&&_c(e,a.frac_max)===10&&(e=1,m++),s=s<0?-e:e,o=s,c+=Math.abs(m)}let O=!Number.isSafeInteger(s)||!!a.scaleExponent;if(h||=D&&O&&!a.date&&!a.fractions&&!a.exponential&&(a.integer||a.dec_fractions)?ts(D,a.frac_max):null,a.integer){if(h)p=h.integer===`0`?``:h.integer;else{let e=a.fractions?1:a.frac_max,t=Math.abs(Number.isSafeInteger(s)&&e===0?s:_c(s,e));p+=t<1?``:Math.floor(t)}}let k=n.grouping[0]??3,A=n.grouping[1]??k;a.dec_fractions&&(f=h?h.fraction:String(_c(s,a.frac_max)).split(`.`)[1]||``);let j=!a.error&&(a.num_p.includes(`0`)||a.den_p.includes(`0`)),M=j;if(a.fractions){M=j||!!(s%1);let e=Math.abs(a.integer?s%1:s);if(e){if(M=!0,a.denominator&&Number.isFinite(a.denominator))d+=a.denominator,u+=_c(e*a.denominator),u===`0`&&(u=``,d=``,M=j);else{let t=ks(e,1/0,a.den_max);u+=t[0],d+=t[1],a.integer&&u===`0`&&(u=``,d=``,M=j)}}else!s&&!a.integer&&(M=!0,u=`0`,d=`1`);a.integer&&!M&&!Math.trunc(s)&&(p=`0`)}if(a.date){g=Math.trunc(s);let e=hc*(s-g);if(_=Math.floor(e),T=e-_,Math.abs(T)<1e-6?T=0:T>.9999&&(T=0,_+=1,_===hc&&(_=0,g+=1)),T){let e=a.date&512||a.date&256||a.date&128;(e===512&&T>.9995||e===256&&T>.995||e===128&&T>.95||!e&&T>=.5)&&(_++,T=0)}let t=a.date_system===6?6:n.dateSystem===`date1904`?-1:a.date_system;if(g||a.date_system){let e=Js(s,t,n.leap1900);v=e[0],y=e[1],b=e[2]}if(_){let e=_<0?hc+_:_;w=Math.floor(e)%60,C=Math.floor(e/60)%60,S=Math.floor(e/60/60)%60}if(x=((t===-1?5:6)+g)%7,a.date_eval&&gc(s,g+_/hc,n.dateSpanLarge,n.dateSystem)){if(n.dateErrorThrows)throw Error(`Date out of bounds`);return n.dateErrorNumber?Hs(s<0?[E.negative]:[],{},s,E,D).join(``):n.overflow}}let N=Us(`?`,n.nbsp);m<0?l=`-`:a.exp_plus&&(l=`+`);let P=[],F=(e,t,r,i)=>{let a=i,o=!a&&e.length>t.length?r.length+e.length-t.length:r.length;e.length<t.length&&(a+=e.length-t.length);for(let t=0;t<o;t++)P.push(e[t+a]||Us(r[t],n.nbsp));return o},I=!1,L={int:0,frac:0,man:0,num:0,den:0};for(let e=0,t=a.tokens.length;e<t;e++){let t=a.tokens[e],i=t.type,m=t.num?t.num.length:0;if(i===`string`){let e=t.value;t.rule?t.rule===`num`?M?P.push(e.replace(/ /g,N)):(a.num_min>0||a.den_min>0)&&P.push(e.replace(/./g,N)):t.rule===`num+int`?M&&p?P.push(e.replace(/ /g,N)):a.den_min>0&&(p||a.num_min)&&P.push(e.replace(/./g,N)):t.rule===`den`&&(M?P.push(e.replace(/ /g,N)):a.den_min>0&&P.push(e.replace(/./g,N))):P.push(e.replace(/ /g,N))}else if(i===`space`)t.rule===`num+int`?(M||a.num_min||a.den_min)&&(p||a.num_min)&&P.push(N):P.push(N);else if(i===`error`)P.push(n.invalid);else if(i===`point`)P.push(a.date?t.value:E.decimal);else if(i===`general`)Hs(P,a,o,E,D);else if(i===`exp`)P.push(E.exponent);else if(i===`minus`)t.volatile&&a.date||(t.volatile&&h?h.negative&&!h.zero&&P.push(E.negative):t.volatile&&(s>=0||typeof o!=`number`)||(t.volatile&&!a.fractions&&(a.integer||a.dec_fractions)?(s<0&&p&&p!==`0`||f)&&P.push(E.negative):P.push(E.negative)));else if(i===`plus`)P.push(E.positive);else if(i===`text`)P.push(o);else if(i===`fill`)n.fillChar&&P.push(n.fillChar,t.value);else if(i===`skip`)n.skipChar?P.push(n.skipChar,t.value):P.push(n.nbsp?`\xA0`:` `);else if(i===`div`)M?P.push(`/`):a.num_min>0||a.den_min>0?P.push(N):P.push(Us(`#`,n.nbsp));else if(i===`int`){if(a.int_pattern.length===1){let e=a.int_p,t=Math.max(a.int_min,p.length),r=``;for(let i=t;i>0;i--){let t=p.charAt(p.length-i),o=t?``:e.charAt(e.length-i)||e[0],s=``;if(a.grouping){let e=i-1-k;e>=0&&!(e%A)&&(s=t||o===`0`?E.group:Us(`?`,n.nbsp))}r+=(t||Us(o,n.nbsp))+s}P.push(r)}else L.int+=F(p,a.int_p,t.num,L.int)}else if(i===`frac`){let e=L.frac;for(let r=0;r<m;r++)P.push(f[r+e]||Us(t.num[r],n.nbsp));L.frac+=m}else if(i===`man`)!L[i]&&!L.man&&P.push(l),L.man+=F(c,a.man_p,t.num,L.man);else if(i===`num`)L.num+=F(u,a.num_p,t.num,L.num);else if(i===`den`){let e=L.den;for(let r=0;r<m;r++){let i=d[r+e];if(!i){let e=t.num[r];`123456789`.includes(e)||I&&e===`0`?(I=!0,i=n.nbsp?`\xA0`:` `):i=!I&&r===m-1&&e===`0`&&!d?`1`:Us(e,n.nbsp)}P.push(i)}L.den+=m}else if(i===`year`)v<0&&P.push(E.negative),P.push(String(Math.abs(v)).padStart(4,`0`));else if(i===`year-short`){let e=v%100;P.push(e<10?`0`:``,e)}else if(i===`month`)P.push(t.pad&&y<10?`0`:``,y);else if(i===`monthname-single`)a.date_system===6?P.push(E.mmmm6[y-1].charAt(0)):P.push(E.mmmm[y-1].charAt(0));else if(i===`monthname-short`)a.date_system===6?P.push(E.mmm6[y-1]):P.push(E.mmm[y-1]);else if(i===`monthname`)a.date_system===6?P.push(E.mmmm6[y-1]):P.push(E.mmmm[y-1]);else if(t.type===`weekday-short`)P.push(E.ddd[x]);else if(i===`weekday`)P.push(E.dddd[x]);else if(i===`day`)P.push(t.pad&&b<10?`0`:``,b);else if(i===`hour`){let e=S%a.clock||(a.clock<24?a.clock:0);P.push(t.pad&&e<10?`0`:``,e)}else if(i===`min`)P.push(t.pad&&C<10?`0`:``,C);else if(i===`sec`)P.push(t.pad&&w<10?`0`:``,w);else if(i===`subsec`){P.push(E.decimal);let e=T.toFixed(a.sec_decimals);P.push(e.slice(2,2+t.decimals))}else if(i===`ampm`){let e=S<12?0:1;t.short&&!r?P.push(`AP`[e]):P.push(E.ampm[e])}else if(i===`hour-elap`){s<0&&P.push(E.negative);let e=g*24+Math.floor(Math.abs(_)/3600);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`min-elap`){s<0&&P.push(E.negative);let e=g*1440+Math.floor(Math.abs(_)/60);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`sec-elap`){s<0&&P.push(E.negative);let e=g*hc+Math.abs(_);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`b-year`)P.push(v+543);else if(i===`b-year-short`){let e=(v+543)%100;P.push(e<10?`0`:``,e)}}return P.join(``)}let yc=Ds([{type:To,value:`@`,raw:`@`}]);function bc(e){return!!e&&`scale`in e}function xc(e,t){for(let n=0;n<3;n++){let r=t[n];if(bc(r)){let t;if(r.condition){let n=r.condition[0],i=r.condition[1];n===`=`?t=e===i:n===`>`?t=e>i:n===`<`?t=e<i:n===`>=`?t=e>=i:n===`<=`?t=e<=i:n===`<>`&&(t=e!==i)}else t=!0;if(t)return r}else if(r)return r}}function Sc(e,t,n){let r=t.partitions,i=r[3],a=null;return(typeof e==`number`||typeof e==`bigint`)&&isFinite(e)&&(i=xc(e,r)),bc(i)&&i.color&&(a=i.color),a&&typeof a==`number`&&n.indexColors&&(a=Yo[a-1]||`#000`),a}function Cc(e,t,n){let r=t.partitions,i=ds(t.locale||n.locale),a=e,o=r[3]?r[3]:yc;if(typeof a==`boolean`&&(a=(i||ps).bool[+!a]),a==null)return``;let s=typeof a==`bigint`;if(typeof a!=`number`&&!s)return vc(a,o,n,i);if(!s&&!Number.isFinite(a)){let e=i||ps;return Number.isNaN(a)?e.nan:(a<0?e.negative:``)+e.infinity}let c=xc(e,r),l=c&&typeof e==`number`&&Number.isFinite(e)?Qo(e):null;return c?vc(e,c,n,i,l):n.overflow}function wc(e){return!!e&&`scale`in e}function Tc(e,t){return e.type===`year`||e.type===`year-short`?{type:`year`,pattern:`yyyy`,tokenIndex:t}:e.type===`month`?{type:`month`,pattern:e.pad?`mm`:`m`,tokenIndex:t}:e.type===`day`?{type:`day`,pattern:e.pad?`dd`:`d`,tokenIndex:t}:null}function Ec(e){return e.type.startsWith(`b-year`)||e.type.startsWith(`monthname`)||e.type.startsWith(`weekday`)}function Dc(e,t,n){if(n!==t+2)return null;let r=e[t+1];return r.value===`-`||r.value===`/`?r.value:null}function Oc(e,t){let n=e.find(e=>e.type===(t===`day`?`month`:`day`)),r=(n==null?void 0:n.pattern.length)===2;return t===`day`?r?`dd`:`d`:r?`mm`:`m`}function kc(e,t){let n=e.map(e=>e.type).join(``);if(new Set(e.map(e=>e.type)).size!==e.length)return null;let r=new Map(e.map(e=>[e.type,e.pattern]));r.set(`year`,`yyyy`),r.has(`month`)||r.set(`month`,Oc(e,`month`)),r.has(`day`)||r.set(`day`,Oc(e,`day`));let i={daymonth:[`day`,`month`,`year`],daymonthyear:[`day`,`month`,`year`],dayyear:[`day`,`month`,`year`],monthday:[`year`,`month`,`day`],monthdayyear:[`month`,`day`,`year`],monthyear:[`month`,`day`,`year`],yearmonth:[`year`,`month`,`day`],yearmonthday:[`year`,`month`,`day`],yearday:[`year`,`month`,`day`]}[n];return i?i.map(e=>r.get(e)).join(t):null}function Ac(e){let t=e.tokens.map((e,t)=>Tc(e,t)).filter(e=>e!==null);if(!t.length)return null;if(t.length<2||t.length>3||e.locale||e.date_system!==1||e.tokens.some(Ec))return`yyyy/mm/dd`;let n=t.slice(1).map((n,r)=>Dc(e.tokens,t[r].tokenIndex,n.tokenIndex)),r=n[0];return!r||n.some(e=>e!==r)?`yyyy/mm/dd`:kc(t,r)??`yyyy/mm/dd`}function jc(e){let t=e.tokens.findIndex(e=>e.type===`hour`),n=e.tokens.find(e=>e.type===`min`),r=e.tokens.findIndex(e=>e.type===`ampm`),i=r<0?void 0:e.tokens[r];if(!(t>=0||n||e.tokens.some(e=>e.type===`sec`)||i))return null;let a=t<0?void 0:e.tokens[t],o=`${a!=null&&a.pad?`hh`:`h`}:${(n==null?void 0:n.pad)===!1?`m`:`mm`}:ss`;return!i||typeof i.value!=`string`?o:r<t?`${i.value} ${o}`:`${o} ${i.value}`}function Mc(e,t){let n=xc(t,e);if(!wc(n)||n.tokens.some(e=>e.type.endsWith(`-elap`)))return null;let r=Ac(n),i=jc(n);return r&&i?`${r} ${i}`:r??i}function Nc(e){return!!e&&`scale`in e}function Pc(e){return!!e&&`generated`in e&&!!e.generated}function Fc(e){return!!(Nc(e[0])&&e[0].percent||Nc(e[1])&&e[1].percent||Nc(e[2])&&e[2].percent||Nc(e[3])&&e[3].percent)}function Ic(e){return!!(Nc(e[0])&&e[0].date||Nc(e[1])&&e[1].date||Nc(e[2])&&e[2].date||Nc(e[3])&&e[3].date)}function Lc(e){let[t,n,r,i]=e;return!(t&&!Pc(t)||n&&!Pc(n)||r&&!Pc(r)||!Nc(i)||!i.text||Pc(i))}let Rc={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},zc=[[`DMY`,1],[`DM`,2],[`MY`,3],[`MDY`,4],[`MD`,5],[`hmsa`,6],[`hma`,7],[`hms`,8],[`hm`,9]];function Bc(e,t=null){let[n,r]=e;if(!n)throw TypeError(`Cannot read properties of undefined (reading 'frac_max')`);let i=Nc(n)?n:void 0,a=Nc(r)?r:void 0,o=`error`in n,s=i==null?void 0:i.frac_max,c={type:`general`,isDate:Ic(e),isText:Lc(e),isPercent:Fc(e),maxDecimals:i!=null&&i.general?9:s??0,scale:(i==null?void 0:i.scale)??1,color:0,parentheses:0,grouped:i!=null&&i.grouping?1:0,code:``,level:0},l=!c.isDate&&!c.isText&&!o&&n.tokens.some(e=>e.type===`string`&&typeof e.value==`string`&&(t?e.value===t:Zo.test(e.value))),u=`G`,d=s!==void 0&&s>=0?Math.min(15,s):``,f=``,p=``;if(a!=null&&a.color&&(p=`-`,c.color=1),i!=null&&i.parens&&(f=`()`,c.parentheses=1),l)u=`C`,c.type=`currency`;else if(o)c.type=`error`,c.maxDecimals=0;else if(c.isDate){let e=0,t=0,r=``;n.tokens.forEach(n=>{let i=n.type;/^(b-)?year/.test(i)?(r+=`Y`,t++):i.startsWith(`month`)?(r+=`M`,t++):/^(week)?day/.test(i)?(r+=`D`,t++):(i===`hour`||i===`min`||i===`sec`||i===`ampm`)&&(r+=i[0],e++)}),c.type=`date`,t&&e?c.type=`datetime`:!t&&e&&(c.type=`time`);let i=zc.find(([e])=>r.startsWith(e));u=i?`D`:`G`,d=i?i[1]:``}else c.isText?(u=`G`,c.type=`text`,d=``,c.maxDecimals=0):i!=null&&i.general?(u=`G`,c.type=`general`,d=``):i!=null&&i.fractions?(u=`G`,c.type=`fraction`,d=``):i!=null&&i.exponential?(u=`S`,c.type=`scientific`):c.isPercent?(u=`P`,c.type=`percent`):i!=null&&i.grouping?(u=`,`,c.type=`grouped`):i&&(i.int_max||s)&&(u=`F`,c.type=`number`);return c.code=u+d+p+f,c.level=Rc[c.type],Object.freeze(c)}function Vc(e){let[t]=e;if(!t)throw TypeError(`Cannot read properties of undefined (reading 'date')`);let n=Nc(t)?t:void 0,r=(n==null?void 0:n.date)??0;return{year:!!(r&2),month:!!(r&4),day:!!(r&8),hours:!!(r&16),minutes:!!(r&32),seconds:!!(r&64),isDuration:(n==null?void 0:n.tokens.some(e=>e.type.endsWith(`-elap`)))??!1,clockType:(n==null?void 0:n.clock)===12?12:24}}let Hc={overflow:`######`,dateErrorThrows:!1,dateErrorNumber:!1,bigintErrorNumber:!1,dateSpanLarge:!1,leap1900:!0,dateSystem:`date1900`,nbsp:!1,throws:!0,invalid:`######`,locale:``,ignoreTimezone:!1,grouping:[3,3],indexColors:!0,skipChar:``,fillChar:``},Uc=[[go,/^General/i,0],[_o,/^#/,0],[vo,/^0/,0],[yo,/^\?/,0],[bo,/^\//,0],[wo,/^;/,0],[To,/^@/,0],[Eo,/^\+/,0],[Do,/^-/,0],[Oo,/^\./,0],[ko,/^ /,0],[Ao,/^%/,0],[jo,/^[1-9]/,0],[Mo,/^(?:B[12])/i,0],[No,/^B$/,0],[Po,/^(?:[hH]+|[mM]+|[sS]+|[yY]+|[bB]+|[dD]+|[gG]+|[aA]{3,}|e+)/,0],[Fo,/^(?:\[(h+|m+|s+)\])/i,1],[Io,/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/,[1,2]],[Lo,/^\[(DBNum[0-4]?\d)\]/i,1],[Ro,/^\[(NatNum[0-4]?\d)\]/i,1],[zo,/^\[\$([^\]]+)\]/,1],[Bo,/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*\d+)\]/i,1],[Vo,/^\[([^\]]+)\]/,1],[Ho,/^(?:AM\/PM|am\/pm|A\/P)/,0],[Uo,/^\\([\s\S])/,1],[Wo,/^"([^"]*?)"/,1],[Go,/^_(\\.|.)/,1],[`exp`,/^[Ee]([+-])/,1],[Ko,/^\*(\\.|.)/,1],[qo,/^[()]/,0],[No,/^[EÈÉÊËèéêëĒēĔĕĖėĘęĚěȄȅȆȇȨȩNnÑñŃńŅņŇňǸǹ["*/\\_]/,0],[Jo,/^./,0]],Wc=e=>{let t=(e||`\0`).charCodeAt(0);return t===63||t===35||t>=48&&t<=57};function Gc(e){let t=0,n=[],r=[];for(;t<e.length;){let i=e.slice(t),a=0,o=/^(,+)(.)?/.exec(i);if(o){let i=o[1];a=i.length;let s=e[t-1]||``,c=!1,l=!1;Wc(s)?(c=!0,l=!0):s===`.`&&(l=!0);let u=o[2]||``;if(c&&(!u||u===`;`)&&(c=!1),l&&Wc(u)&&(l=!1),c&&!l)n.push({type:xo,value:`,`,raw:i});else if(!c&&l)n.push({type:So,value:`,`,raw:i});else if(c&&l){let e={type:So,value:`,`,raw:i};n.push(e),r.push(e)}else n.push({type:Co,value:`,`,raw:i})}else{let e;for(let[t,r,o]of Uc){let s=r.exec(i);if(s){e={type:t,value:typeof o==`number`?s[o||0]:o.map(e=>s[e]),raw:s[0]},n.push(e),a=s[0].length;break}}r.length&&(e==null?void 0:e.raw)===`;`&&(r.length=0),r.length&&Wc(e==null?void 0:e.raw)&&(r.forEach(e=>e.type=xo),r.length=0)}if(!a){let e=i[0];a=1,n.push({type:Jo,value:e,raw:e})}t+=a}return n}function Kc(e){var t,n;let r=(t=e.condition)==null?void 0:t[0],i=(n=e.condition)==null?void 0:n[1];typeof i==`number`&&i<0&&(r===`<`||r===`<=`||r===`=`)||i===0&&r===`<`||e.tokens.unshift({type:`minus`,volatile:!0})}function qc(e,t=null){let n={...e,int_pattern:[...e.int_pattern],frac_pattern:[...e.frac_pattern],man_pattern:[...e.man_pattern],den_pattern:[...e.den_pattern],num_pattern:[...e.num_pattern],tokens:[...e.tokens]};return e.condition&&(n.condition=[...e.condition]),t&&n.tokens.unshift(t),n.generated=!0,n}function Jc(e){let t=[],n=!1,r,i=null,a=0,o=0,s=0,c=Gc(e);do{var l;let e=Ds(c);if((e.date||e.general)&&(e.int_pattern.length||e.frac_pattern.length||e.scale!==1||e.text))throw Error(`Illegal format`);if(e.condition&&(s++,n=!0),e.text){if(i)throw Error(`Unexpected partition`);i=e}e.locale&&(r=us(e.locale)),t.push(e),a=+(((l=c[e.tokensUsed])==null?void 0:l.type)===`break`),c=c.slice(e.tokensUsed+a),o++}while(a&&o<4&&s<3);if(a)throw Error(`Unexpected partition`);if(s>2)throw Error(`Unexpected condition`);let u=t[3];if(u&&(u.int_pattern.length||u.frac_pattern.length||u.date))throw Error(`Unexpected partition`);if(n){t[0].condition||(t[0].condition=[`>`,0]);let e=t.length;if(e===1){let e=Ds(Gc(`General`));e.generated=!0,t[1]=e}if(e<3){let e=t[0],n=t[1];if(Kc(e),n.condition)Kc(n);else{let t=e.condition;((t==null?void 0:t[0])===`=`||typeof(t==null?void 0:t[1])==`number`&&t[1]>=0&&(t[0]===`>`||t[0]===`>=`))&&n.tokens.unshift({type:`minus`,volatile:!0})}}else t.forEach(Kc)}else{if(t.length<4&&i)for(let e=0,n=t.length;e<n;e++)t[e]===i&&t.splice(e,1);if(t.length<1&&i){let e=Ds(Gc(`General`));e.generated=!0,t[0]=e}if(t.length<2&&t.push(qc(t[0],{type:`minus`,volatile:!0})),t.length<3&&t.push(qc(t[0])),t.length<4){if(i)t.push(i);else{let e=Ds(Gc(`@`));e.generated=!0,t.push(e)}}t[0].condition=[`>`,0],t[1].condition=[`<`,0],t[2].condition=null}return{pattern:e,partitions:t,locale:r}}let Yc=/* @__PURE__ */ `!d-m-y.!d-m-Y.!j-m-y.!j-m-Y.!d-n-y.!d-n-Y.!j-n-y.!j-n-Y.?m-d-y.?m-d-Y.?m-j-y.?m-j-Y.?n-d-y.?n-d-Y.?n-j-y.?n-j-Y.d-M-y.d-M-Y.j-M-y.j-M-Y.M-d-y.M-d-Y.M-j-y.M-j-Y.d-F-y.d-F-Y.F-d-y.F-d-Y.F-j-y.F-j-Y.j-F-y.j-F-Y.y-F-d.y-F-j.y-M-d.y-M-j.Y-F-d.Y-F-j.Y-M-d.Y-m-d.Y-M-j.Y-m-j.Y-n-d.Y-n-j.j-F.j-M.d-F.d-M.n-d.n-j.n-Y.m-d.m-j.m-Y.M-Y.M-y.F-y.F-Y.Y-M.Y-n.Y-m.Y-F.Y-M`.split(`.`),Xc={j:`d`,d:`d`,D:`ddd`,l:`dddd`,n:`m`,m:`m`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Zc={j:`dd`,d:`dd`,D:`ddd`,l:`dddd`,n:`mm`,m:`mm`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Qc={},$c={};function el(e,t,n=1){if(e){let r=e[0],i=e.slice(1);if(r===`!`)el(i,t,4);else if(r===`?`)el(i,t,2);else{let e=t[r];typeof e!=`object`&&(e={},t[r]=e),el(i,e,n)}}else t.$=n}function tl(e,t){el(e,t),el(`${e} x`,t),el(`${e} l`,t),el(`${e} l x`,t),el(`l ${e}`,t),el(`l ${e} x`,t),el(`${e} D`,t),el(`${e} D x`,t),el(`D ${e}`,t),el(`D ${e} x`,t)}Yc.forEach(e=>{e.startsWith(`?`)||tl(e,Qc),e.startsWith(`!`)||tl(e,$c)});let nl={".":[`,`,`\xA0`,` `,`'`,`٬`],",":[`.`,`\xA0`,` `,`'`,`٬`],"٫":[`.`,`\xA0`,` `,`'`,`٬`]},rl=e=>(e==null?void 0:e.length)===1&&e>=`0`&&e<=`9`;function il(e,t={}){let n=ds(t.locale||``)||ps,r=n.decimal,i=[...nl[r]||[`'`,`٬`]];!i.includes(n.group)&&n.group!==` `&&n.group!==r&&i.push(n.group);let a=``,o=``,s=1,c=``,l=!1,u=!1,d=!1,f=!1,p=!1,m=``,h=!1,g=0,_=[` `,`\xA0`,` `,`+`,`%`,`(`,`-`].concat(Xo);for(;_.includes(e.charAt(g));){let t=e.charAt(g);if(t===`-`){if(l||u)return null;l=!0,s=-1}else if(Zo.test(t)){if(p)return null;p=!0,m=t}else if(t===`(`){if(u||l)return null;u=!0,s=-1}else if(t===`%`){if(f)return null;f=!0}g++}let v=!1,y;if(e.charAt(g)===r||rl(e.charAt(g)))for(;g<e.length;){let t=e.charAt(g);if(!y&&i.includes(t))y=t;else if(!(y&&y===t)){if(t===r){if(v)break;a+=`.`,v=!0}else if(rl(t))a+=t;else break}g++}if(e.charAt(g)===`e`||e.charAt(g)===`E`){o+=e.charAt(g),g++,(e.charAt(g)===`+`||e.charAt(g)===`-`)&&(o+=e.charAt(g),g++);let t=g;for(;rl(e.charAt(g));)o+=e.charAt(g),g++;if(t===g)return null}let b=[` `,`\xA0`,` `,`%`,`$`,`)`].concat(Xo);for(;b.includes(e.charAt(g));){let t=e.charAt(g);if(Zo.test(t)){if(p)return null;p=!0,m=t,h=!0}else if(t===`)`){if(d||!u)return null;d=!0}else if(t===`%`){if(f)return null;f=!0}g++}if(g!==e.length)return null;let x=Number.parseFloat(a+o);if(!Number.isFinite(x))return null;if(o){if(f||p)return null;c=`0.00E+00`}else if(f){if(p)return null;c=a.includes(`.`)?`0.00%`:`0%`,x*=.01}else if(p){let e=a.includes(`.`)?`#,##0.00`:`#,##0`;c=h?e+m:m+e}else y&&(c=a.includes(`.`)?`#,##0.00`:`#,##0`);let S={v:x*s};return c&&(S.z=c),S}function al(e,t,n){if(n<1||t<1||t>12)return!1;if(t===2){if(n>(e%4==0&&e%100!=0||e%400==0||e===1900?29:28))return!1}else if((t===4||t===6||t===9||t===11)&&n>30||(t===1||t===3||t===5||t===7||t===8||t===10||t===12)&&n>31)return!1;return!0}let ol=/* @__PURE__ */ new WeakMap,sl=(e,t,n=!1)=>{for(let r of t)if(e.startsWith(r[0])){let t=r[0].length;return n&&(r[2]===`D`||r[2]===`M`)&&e[t]===`.`&&t++,[e.slice(0,t),r]}return[``,null]},cl=(e,t,n,r)=>{let i=n.path||``,a=Object.keys(t);for(let o of a){let a=t[o],s;if(!a)continue;if(o===`$`||o===`€`)e||(s=n);else{if(typeof a!=`object`)continue;if(o===`-`){let t=/^(\s*([./-]|,\s)\s*|\s+)/.exec(e);if(t){let o=t[1]===`-`||t[1]===`/`||t[1]===`.`?t[1]:` `;if(!n.sep||n.sep===o){let c=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,sep:o,path:i+c},r)}}}else if(o===` `){let t=/^[,.]?\s+/.exec(e);if(t){let o=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,path:i+o},r)}}else if(o===`j`||o===`d`){let t=/^(0{1,2}|0?[1-9]|1\d|2\d|3[01])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,day:t[0],path:i+o},r))}else if(o===`n`||o===`m`){let t=/^(0?[1-9]|1[012])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,month:+t[0],_mon:t[0],path:i+o},r))}else if(o===`F`||o===`M`){let[t,c]=sl(e,r.mon,r.mp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,month:c[1],_mon:t,path:i+o},r))}else if(o===`l`||o===`D`){let[t,c]=sl(e,r.day,r.dp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,path:i+o},r))}else if(o===`y`){let t=/^\d\d\b/.exec(e);if(t){let c=+t[0]>=30?+t[0]+1900:+t[0]+2e3;s=cl(e.slice(t[0].length),a,{...n,year:c,path:i+o},r)}}else if(o===`Y`){let t=/^\d\d\d\d\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,year:+t[0],path:i+o},r))}else if(o===`x`){let t=hl(e,{locale:r.locale});t&&(s=cl(``,a,{...n,time:t.v,tf:t.z,path:i+o},r))}else throw Error(`Unknown date token "${o}"`)}let c=(s==null?void 0:s.year)||1916,l=(s==null?void 0:s.month)||1,u=s!=null&&s.day?+s.day:1,d=r.dateSystem===`date1900`&&c===1900&&l===1&&u===0;if(s&&(d||al(c,l,u)))return s}},ll=e=>e.replace(/\s+/g,` `).trim().replace(/’/,`'`).replace(/\.$/,``).toLowerCase(),ul=(e,t)=>{let n=e.map((e,n)=>[ll(e),n+1,t]);return n.sort((e,t)=>t[0].length-e[0].length),n},dl=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),fl=e=>{let t=ol.get(e);return t&&dl(e.mmmm,t.mmmm)&&dl(e.mmm,t.mmm)&&dl(e.dddd,t.dddd)&&dl(e.ddd,t.ddd)||(t={lookups:{mon:ul(e.mmmm,`F`).concat(ul(e.mmm,`M`)),mp:e.mmm[0].endsWith(`.`),day:ul(e.dddd,`l`).concat(ul(e.ddd,`D`)),dp:e.ddd[0].endsWith(`.`)},mmmm:[...e.mmmm],mmm:[...e.mmm],dddd:[...e.dddd],ddd:[...e.ddd]},ol.set(e,t)),t.lookups};function pl(e,t={}){let n=ds(t.locale||``)||ps,r={...fl(n),locale:t.locale,dateSystem:t.dateSystem??`date1900`},i=cl(ll(e),n.preferMDY?$c:Qc,{path:``},r);if(!i||i.sep===`.`&&i.path.length===3||i.month==null||i._mon==null)return null;let a=+(i.year??(/* @__PURE__ */ new Date()).getUTCFullYear()),o=i.day??`1`,s=t.dateSystem??`date1900`,c=lc({year:a,month:i.month,day:+o,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s});if(c==null)return null;let l=c+(i.time||0);if(l>=lc({year:9999,month:12,day:31,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s})+1)return null;let u=i._mon[0]===`0`||o[0]===`0`||i._mon.length===2&&o.length===2;return{v:l,z:i.path.replace(/[jdlDnmMFyYx]/g,e=>e===`x`?i.tf||``:(u?Zc[e]:Xc[e])||e)}}let ml=e=>e.replace(/\s+/g,``).trim().replace(/\./g,``).toLowerCase();function hl(e,t={}){let n=ds(t.locale||``)||ps,r=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?=\s*[^\s\d]|$)/.exec(e),i=``;if(r){let t=ml(e.slice(r[0].length));if(t===ml(n.ampm[0])||t===`a`||t===`am`)i=`a`;else if(t===ml(n.ampm[1])||t===`p`||t===`pm`)i=`p`;else if(t===`:`)r[3]||=`0`,r[2]||=`0`;else if(t)return null}if(!r)return null;let[,a,o,s,c]=r;if(c&&!s||!i&&!o&&!s)return null;let l=+(a||0);if(i){if(l>=13)return null;i===`a`?l===12&&(l=0):i===`p`&&l!==12&&(l+=12)}let u=+(o||0),d=+(s||0),f=+(c||0),p=a.length===2?`hh`:`h`,m=s?`:ss`:``,h=i?` AM/PM`:``;return{v:(l*60*60+u*60+d+f)/86400,z:`${p}:mm${m}${h}`}}function gl(e,t={}){let n=ds(t.locale||``)||ps,r=e.trim().toLowerCase(),i=n.bool[0].toLowerCase();if(r===`true`||r===i)return{v:!0};let a=n.bool[1].toLowerCase();return r===`false`||r===a?{v:!1}:null}function _l(e,t){return il(e,t)??pl(e,t)??hl(e,t)??gl(e,t)}var vl=/* @__PURE__ */ p({addLocale:()=>W,dateFromSerial:()=>mc,dateToSerial:()=>pc,dec2frac:()=>ks,format:()=>xl,formatColor:()=>Sl,getDateTimeEditPattern:()=>kl,getFormatDateInfo:()=>Ol,getFormatInfo:()=>Dl,getLocale:()=>ds,isDateFormat:()=>Cl,isPercentFormat:()=>wl,isTextFormat:()=>Tl,isValidFormat:()=>El,parseBool:()=>gl,parseDate:()=>pl,parseLocale:()=>ls,parseNumber:()=>il,parseTime:()=>hl,parseValue:()=>_l,round:()=>Fs,tokenTypes:()=>Al,tokenize:()=>Gc});let yl=Object.create({});function bl(e,t=!1){let n=e||`General`,r=yl[n];if(!r)try{r=Jc(n),yl[n]=r}catch(e){if(t)throw e;let i=e instanceof Error?e.message:String(e),a={tokens:[{type:`error`}],error:i};r={pattern:n,partitions:[a,a,a,a],error:i,locale:null}}return r}function xl(e,t,n={}){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Cc(pc(t,r)??t,i,r)}function Sl(e,t,n){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Sc(pc(t,r)??t,i,r)}function Cl(e){return Ic(bl(e,!1).partitions)}function wl(e){return Fc(bl(e,!1).partitions)}function Tl(e){return Lc(bl(e,!1).partitions)}function El(e){try{return bl(e,!0),!0}catch{return!1}}function Dl(e,t={}){let n=bl(e,!1);return n.info||=Bc(n.partitions,t==null?void 0:t.currency),n.info}function Ol(e){let t=bl(e,!1);return t.dateInfo||=Vc(t.partitions),t.dateInfo}function kl(e,t){return Mc(bl(e,!1).partitions,t)}let Al=Object.freeze({AMPM:Ho,BREAK:wo,CALENDAR:Mo,CHAR:Jo,COLOR:Bo,COMMA:Co,CONDITION:Io,DATETIME:Po,DBNUM:Lo,DIGIT:jo,DURATION:Fo,ERROR:No,ESCAPED:Uo,EXP:`exp`,FILL:Ko,GENERAL:go,GROUP:xo,HASH:_o,LOCALE:zo,MINUS:Do,MODIFIER:Vo,NATNUM:Ro,PAREN:qo,PERCENT:Ao,PLUS:Eo,POINT:Oo,QMARK:yo,SCALE:So,SKIP:Go,SLASH:bo,SPACE:ko,STRING:Wo,TEXT:To,ZERO:vo}),jl=/* @__PURE__ */ new Set([`d`,`g`,`i`,`m`,`s`,`u`,`v`,`y`]);function Ml(e,t){let n=Nl(t);return new RegExp(e,n)}function Nl(e){if(e===void 0)return;let t=/* @__PURE__ */ new Set;for(let n of e){if(!jl.has(n)||t.has(n))throw SyntaxError(`Invalid regular expression flags: ${e}`);t.add(n)}return e}var Pl=class e{constructor(...e){T(this,`data`,void 0),this.data=Rl(e.flatMap(e=>Il(e)))}union(...t){return new e(this,...t)}subtract(...t){let n=Rl(t.flatMap(e=>Il(e))),r=this.data.slice();for(let[e,t]of n){let n=[];for(let[i,a]of r)t<i||e>a?n.push([i,a]):(e>i&&n.push([i,e-1]),t<a&&n.push([t+1,a]));r=n}return new e(...r)}intersect(...t){let n=Rl(t.flatMap(e=>Il(e))),r=[];for(let[e,t]of this.data)for(let[i,a]of n){let n=Math.max(e,i),o=Math.min(t,a);n<=o&&r.push([n,o])}return new e(...r)}isEmpty(){return this.data.length===0}toString(){return this.isEmpty()?`(?!)`:`[${this.data.map(zl).join(``)}]`}toRegExp(e){return Ml(this.toString(),e)}};let Fl=(...e)=>new Pl(...e);function Il(e){if(e instanceof Pl)return e.data;if(Array.isArray(e)){let t=Ll(e[0]),n=Ll(e[1]);return[[Math.min(t,n),Math.max(t,n)]]}let t=Ll(e);return[[t,t]]}function Ll(e){if(typeof e==`number`){if(!Number.isInteger(e)||e<0||e>1114111)throw RangeError(`Invalid code point: ${e}`);return e}let t=e.codePointAt(0);if(t==null||String.fromCodePoint(t)!==e)throw RangeError(`Charset string inputs must contain exactly one code point: ${e}`);return t}function Rl(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]),n=[];for(let[e,r]of t){let t=n[n.length-1];!t||e>t[1]+1?n.push([e,r]):t[1]=Math.max(t[1],r)}return n}function zl([e,t]){return e===t?Bl(e):`${Bl(e)}-${Bl(t)}`}function Bl(e){let t=String.fromCodePoint(e);return t===`\\`||t===`]`||t===`-`||t===`^`?`\\${t}`:e<=31||e===127?`\\u${e.toString(16).padStart(4,`0`)}`:t}function Vl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hl(e,t){return Ml(Vl(e),t)}function Ul(e){return Ml(`^${Vl(e).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`)}$`,`i`)}var Wl=class e{constructor(...t){T(this,`charset`,void 0),T(this,`strings`,void 0);let n=[],r=[];for(let i of t)i instanceof e?(n.push(i.charset),r.push(...i.strings)):i instanceof Pl||typeof i==`number`||Array.isArray(i)?n.push(i):r.push(i);this.charset=Fl(...n),this.strings=Array.from(new Set(r))}union(...t){return new e(this,...t)}subtract(...t){let n=new e(...t),r=this.strings.filter(e=>!n.strings.includes(e));return new e(this.charset.subtract(n.charset),...r)}isEmpty(){return this.charset.isEmpty()&&this.strings.length===0}toString(){if(this.isEmpty())return`(?!)`;let e=[...this.charset.isEmpty()?[]:[this.charset.toString()],...this.strings.map(Vl)];return e.length===1?e[0]:`(?:${e.join(`|`)})`}toRegExp(e){return Ml(this.toString(),e)}};let Gl={Charset:Pl,Or:Wl,charset:Fl,or:(...e)=>new Wl(...e),createRegExpFromSafeFragment:Ml,escapeRegExp:Vl,createLiteralRegExp:Hl,createFromWildcard:Ul};function Kl(e){return e===`@@@`||e===`@`}function ql(e){return e==null||e===`General`}function Jl(e){switch(e){case`frFR`:return`fr`;case`ruRU`:return`ru`;case`viVN`:return`vi`;case`zhCN`:return`zh-CN`;case`koKR`:return`ko`;case`zhTW`:return`zh-TW`;case`zhHK`:return`zh-HK`;case`esES`:case`caES`:return`es`;case`skSK`:return`sk`;case`jaJP`:return`ja`;case`ptBR`:return`pt`;case`deDE`:return`de`;case`itIT`:return`it`;case`idID`:return`id`;case`plPL`:return`pl`;case`arSA`:return`ar`;default:return`en`}}let Yl=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Gc(e),n=``,r=!1,i=!1;for(let e of t)e.type===Al.POINT?r=!0:i&&e.type===Al.MINUS||e.type!==Al.SKIP&&(e.type===Al.COLOR?i=!0:(i=!1,r&&e.type===Al.ZERO||(r=!1,r||(n+=e.value||``))));return n};return n(e)===n(t)},Xl=/* @__PURE__ */ new Set([`m d`]),Zl=/* @__PURE__ */ new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),Ql=/* @__PURE__ */ `Rp.zł.NT$.R$.HK$.$.£.¥.¤.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿.﷼`.split(`.`),$l=RegExp(`^${Gl.charset(...Array.from(new Set(Ql.join(``))))}+`),eu=(e,t={})=>{let n=pl(e,t)??hl(e,t)??il(e,t);if(!n)return null;let{z:r}=n;if(r){if(Xl.has(r)||Zl.has(r)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(r.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e.replace($l,``).trim();if(t.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(t))return null}}return n};function tu(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function nu(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}let ru=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function iu(e,t,n){let r=nu(n),i=n;for(let t=r-1;t>=e;t--)ru(i[t])?delete i[t+1]:i[t+1]=i[t];ru(t)||(i[e]=t)}function au(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function ou(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++){let t=r[e];c[l]=n[t]}for(let e=0;e<s;e++,l++){let t=o[e];c[l]=a[t]}return c}function su(e,t,n){let r=n;if(nu(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function cu(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?lu(e,t,n,r):uu(e,t,n,r)}function lu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function uu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var du=class e{constructor(e={}){T(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t??(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){cu(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{cu(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){au(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&au(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++){let r=this.getValue(e,a);t[n]=r,n++}a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,z.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return nu(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=nu(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]??(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.clone()}getStartEndScope(){let e=-1,t=-1,n=-1,r=-1,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=n===-1?+t[0]:Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=nu(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function fu(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}function pu(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function mu(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function hu(e){return mu(e)&&(e==null?void 0:e.coverable)!==!1}function gu(e){if(e){if(e.rgb)return new La(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=ho.Office)==null?void 0:t[e.th];if(n)return new La(n).toRgbString()}}return null}function _u(e){return z.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function vu(e){return z.isString(e)&&e.length>0}function yu(e,t=!1){let n=``,r=/* @__PURE__ */ new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(n.indexOf(`text-decoration-line`)>-1?n=n.replace(/(text-decoration-line:\s*[^;]+)(?=;)/g,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${gu(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o;n+=`border-bottom: ${bu((o=e.bd)==null?void 0:o.b.s)} ${gu(e.bd.b.cl)??``}; `}if((r=e.bd)!=null&&r.t){var s;n+=`border-top: ${bu((s=e.bd)==null?void 0:s.t.s)} ${gu(e.bd.t.cl)??``}; `}if((i=e.bd)!=null&&i.r){var c;n+=`border-right: ${bu((c=e.bd)==null?void 0:c.r.s)} ${gu(e.bd.r.cl)??``}; `}if((a=e.bd)!=null&&a.l){var l;n+=`border-left: ${bu((l=e.bd)==null?void 0:l.l.s)} ${gu(e.bd.l.cl)??``}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${gu(e.cl)}; `)}],[`va`,()=>{e.va===2?n+=`vertical-align: sub; `:e.va===3&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===1?n+=`direction: ltr; `:e.td===2&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===1?n+=`text-align: left; `:e.ht===3?n+=`text-align: right; `:e.ht===2?n+=`text-align: center; `:e.ht===4&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===3?n+=`vertical-align: bottom; `:e.vt===1?n+=`vertical-align: top; `:e.vt===2&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===2?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===3&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function bu(e){let t=``;return e===0?t=`none`:e===1?t=`0.5pt solid`:e===2?t=`0.5pt double`:e===3?t=`0.5pt dotted`:e===4||e===5?t=`0.5pt dashed`:e===6?t=`0.5pt dotted`:e===7?t=`0.5pt double`:e===8?t=`1pt solid`:e===9||e===10?t=`1pt dashed`:e===11?t=`1pt dotted`:e===12?t=`0.5pt dashed`:e===13&&(t=`1.5pt solid`),t}function xu(e){let t=0;if(e=e.trim(),e===`none`)t=0;else if(e===`0.5pt solid`)t=1;else if(e===`0.5pt double`)t=2;else if(e===`0.5pt dotted`)t=3;else if(e===`0.5pt dashed`)t=4;else if(e===`1pt solid`)t=8;else if(e===`1pt dashed`)t=9;else if(e===`1pt dotted`)t=11;else if(e===`1.5pt solid`)t=13;else if(!e.includes(`none`))t=1;else return 0;return t}function Su(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function Cu(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===2||!(Number.isNaN(i)&&Number.isNaN(a))&&o===1||o!==1&&o!==2&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function wu(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function Tu(e){return e.si===void 0?e.f===void 0?e.v===void 0&&e.p===void 0?e:{...e,f:null,si:null}:{...e,si:null}:e}function Eu(e){if(_u(e))return{f:e,v:null,p:null,si:null};if(so(e)){if(typeof e==`string`){let t=eu(e);if(t&&t.z)return{v:t.v,p:null,f:null,si:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null,si:null}}return io(e)?Tu(e):e}function Du(e,t){let n=new du,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(z.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,Eu(e[t][a]));else new du(e).forValue((e,t,r)=>{n.setValue(e,t,Eu(r))});return n.getMatrix()}function Ou(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Ou(e[n],t[n])):e===t:!1}function ku(e,t){let n=e.ts||{},r=t.ts||{};if(e.sId!==t.sId||!Ou(n,r))return!1;let i=/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)]);for(let n of i)if(n!==`st`&&n!==`ed`&&n!==`ts`&&n!==`sId`&&!Ou(e[n],t[n]))return!1;return!0}function Au(e,t){return t.some(t=>e.indexOf(t)>-1)}let ju=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Mu=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Nu=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Pu=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Fu=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],Iu={L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`,l:`M/D/YYYY`,ll:`MMM D, YYYY`,lll:`MMM D, YYYY h:mm A`,llll:`ddd, MMM D, YYYY h:mm A`},Lu={millisecond:`millisecond`,milliseconds:`millisecond`,ms:`millisecond`,second:`second`,seconds:`second`,s:`second`,minute:`minute`,minutes:`minute`,m:`minute`,hour:`hour`,hours:`hour`,h:`hour`,day:`day`,days:`day`,d:`day`,week:`week`,weeks:`week`,w:`week`,month:`month`,months:`month`,M:`month`,year:`year`,years:`year`,y:`year`};var Ru=class e{constructor(e,t){this._date=e,this._isUTC=t}isValid(){return!Number.isNaN(this._date.getTime())}format(e=`YYYY-MM-DDTHH:mm:ssZ`){return this.isValid()?$u(this._date,e,this._isUTC):`Invalid Date`}formatIntl(e,t={}){if(!this.isValid())return`Invalid Date`;if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)return this.format();let n=this._isUTC&&!t.timeZone?{...t,timeZone:`UTC`}:t;return new Intl.DateTimeFormat(e,n).format(this._date)}valueOf(){return this._date.getTime()}toDate(){return new Date(this.valueOf())}_clone(){return new e(this.toDate(),this._isUTC)}add(t,n=`millisecond`){let r=Wu(n);return!this.isValid()||!r||!Number.isFinite(t)?this._clone():new e(qu(this._date,t,r,this._isUTC),this._isUTC)}subtract(e,t=`millisecond`){return this.add(-e,t)}startOf(t){let n=Wu(t);return!n||!this.isValid()?this._clone():new e(Ju(this._date,n,this._isUTC),this._isUTC)}endOf(e){let t=Wu(e);return!t||!this.isValid()||t===`millisecond`?this._clone():this.startOf(t).add(1,t).subtract(1,`millisecond`)}utc(){return new e(this.toDate(),!0)}local(){return new e(this.toDate(),!1)}weekday(e){let t=(Bu(this._date,this._isUTC).dayOfWeek-0+7)%7;return e===void 0?t:this.add(e-t,`day`)}week(e){let t=Yu(this._date,this._isUTC);return e===void 0?t:this.add((e-t)*7,`day`)}};function zu(e,t=2){return String(Math.abs(e)).padStart(t,`0`)}function Bu(e,t){return t?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),millisecond:e.getUTCMilliseconds(),dayOfWeek:e.getUTCDay()}:{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),dayOfWeek:e.getDay()}}function Vu(e,t){return e instanceof Ru?e.toDate():e===void 0?/* @__PURE__ */ new Date:e===null?/* @__PURE__ */ new Date(NaN):e instanceof Date?new Date(e.getTime()):typeof e==`number`?new Date(e):typeof e==`string`?Uu(e,t):/* @__PURE__ */ new Date(NaN)}function Hu(e,t,n,r,i,a,o,s){let c=s?new Date(Date.UTC(e,t-1,n,r,i,a,o)):new Date(e,t-1,n,r,i,a,o),l=Bu(c,s);return l.year!==e||l.month!==t||l.day!==n||l.hour!==r||l.minute!==i||l.second!==a?/* @__PURE__ */ new Date(NaN):c}function Uu(e,t){let n=e.trim();if(!n)return/* @__PURE__ */ new Date(NaN);let r=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})日(?:\s+(\d{1,2})(?::(\d{1,2})(?::(\d{1,2}))?)?)?$/);if(r){let[,e,n,i,a=`0`,o=`0`,s=`0`]=r;return Hu(Number(e),Number(n),Number(i),Number(a),Number(o),Number(s),0,t)}let i=n.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[ T](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?)?$/);if(i){let[,e,n,r,a=`0`,o=`0`,s=`0`,c=`0`]=i;return Hu(Number(e),Number(n),Number(r),Number(a),Number(o),Number(s),Number(c),t)}return/^-?\d+(\.\d+)?$/.test(n)?new Date(Number(n)):new Date(n)}function Wu(e){return Lu[e]??Lu[String(e).toLowerCase()]}function Gu(e,t,n){return n?new Date(Date.UTC(e,t,0)).getUTCDate():new Date(e,t,0).getDate()}function Ku(e,t,n,r){let i=new Date(e.getTime());if(t){switch(n){case`year`:i.setUTCFullYear(r);break;case`month`:i.setUTCMonth(r);break;case`day`:i.setUTCDate(r);break;case`hour`:i.setUTCHours(r);break;case`minute`:i.setUTCMinutes(r);break;case`second`:i.setUTCSeconds(r);break;case`millisecond`:i.setUTCMilliseconds(r)}return i}switch(n){case`year`:i.setFullYear(r);break;case`month`:i.setMonth(r);break;case`day`:i.setDate(r);break;case`hour`:i.setHours(r);break;case`minute`:i.setMinutes(r);break;case`second`:i.setSeconds(r);break;case`millisecond`:i.setMilliseconds(r)}return i}function qu(e,t,n,r){switch(n){case`millisecond`:return new Date(e.getTime()+t);case`second`:return new Date(e.getTime()+t*1e3);case`minute`:return new Date(e.getTime()+t*6e4);case`hour`:return new Date(e.getTime()+t*36e5);case`day`:return Ku(e,r,`day`,(r?e.getUTCDate():e.getDate())+t);case`week`:return Ku(e,r,`day`,(r?e.getUTCDate():e.getDate())+t*7);case`month`:{let n=Bu(e,r),i=Hu(n.year,n.month,1,n.hour,n.minute,n.second,n.millisecond,r),a=Ku(i,r,`month`,(r?i.getUTCMonth():i.getMonth())+t),o=Bu(a,r),s=Gu(o.year,o.month,r);return Ku(a,r,`day`,Math.min(n.day,s))}case`year`:return qu(e,t*12,`month`,r)}}function Ju(e,t,n){let r=Bu(e,n);switch(t){case`year`:return Hu(r.year,1,1,0,0,0,0,n);case`month`:return Hu(r.year,r.month,1,0,0,0,0,n);case`week`:{let e=(r.dayOfWeek-0+7)%7,t=Hu(r.year,r.month,r.day,0,0,0,0,n);return Ku(t,n,`day`,(n?t.getUTCDate():t.getDate())-e)}case`day`:return Hu(r.year,r.month,r.day,0,0,0,0,n);case`hour`:return Hu(r.year,r.month,r.day,r.hour,0,0,0,n);case`minute`:return Hu(r.year,r.month,r.day,r.hour,r.minute,0,0,n);case`second`:return Hu(r.year,r.month,r.day,r.hour,r.minute,r.second,0,n);default:return new Date(e.getTime())}}function Yu(e,t){let n=Bu(Ju(e,`week`,t),t),r=Bu(Ju(Ju(e,`year`,t),`week`,t),t),i=Hu(n.year,n.month,n.day,0,0,0,0,!0),a=Hu(r.year,r.month,r.day,0,0,0,0,!0);return Math.floor((i.getTime()-a.getTime())/864e5/7)+1}function Xu(e,t,n=!1){if(t)return n?`+0000`:`+00:00`;let r=-e.getTimezoneOffset(),i=r>=0?`+`:`-`,a=Math.abs(r),o=zu(Math.floor(a/60),2),s=zu(a%60,2);return n?`${i}${o}${s}`:`${i}${o}:${s}`}function Zu(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Qu(e){return e.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g,e=>Iu[e]??e)}function $u(e,t,n){let r=Bu(e,n),i=r.hour%12,a=i===0?12:i,o=Math.ceil(r.month/3),s={YYYY:String(r.year),YY:zu(r.year%100,2),MMMM:ju[r.month-1],MMM:Mu[r.month-1],MM:zu(r.month,2),M:String(r.month),DD:zu(r.day,2),D:String(r.day),Do:Zu(r.day),dddd:Nu[r.dayOfWeek],ddd:Pu[r.dayOfWeek],dd:Fu[r.dayOfWeek],d:String(r.dayOfWeek),HH:zu(r.hour,2),H:String(r.hour),hh:zu(a,2),h:String(a),mm:zu(r.minute,2),m:String(r.minute),ss:zu(r.second,2),s:String(r.second),SSS:zu(r.millisecond,3),A:r.hour>=12?`PM`:`AM`,a:r.hour>=12?`pm`:`am`,Q:String(o),Qo:Zu(o),X:String(Math.floor(e.getTime()/1e3)),x:String(e.getTime()),Z:Xu(e,n,!1),ZZ:Xu(e,n,!0)},c=[];return Qu(t.replace(/\[([^\]]+)]/g,(e,t)=>`\u0000${c.push(t)-1}\u0000`)).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g,e=>s[e]??e).replace(/\u0000(\d+)\u0000/g,(e,t)=>c[Number(t)]??``)}function ed(e){return new Ru(Vu(e,!1),!1)}let td=Object.assign(ed,{utc:e=>new Ru(Vu(e,!0),!0),isDateKit:e=>e instanceof Ru,unix:e=>ed(e*1e3)});function nd(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function rd(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function id(e){if(e==null)return!1;let t=e.paragraphStyle;return ad(t)}function ad(e){var t;return e!=null&&(e.indentStart!=null&&e.indentStart.v!==0||e.hanging!=null)&&((t=e.hanging)==null?void 0:t.v)!==0}function od(e,t,n){return e.slice(0,t)+n+e.slice(t)}function sd(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function cd(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t!==``&&!isNaN(Number(t))}return!1}function ld(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function ud(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function dd(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function fd(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,Object.assign({},...t)}let pd,md,hd,gd,K=Symbol(`newer`),q=Symbol(`older`);pd=Symbol.iterator;var _d=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[pd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.key}):{done:!0,value:void 0}}};md=Symbol.iterator;var vd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[md](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.value}):{done:!0,value:void 0}}};hd=Symbol.iterator;var yd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[hd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},bd=class{constructor(e,t){T(this,`key`,void 0),T(this,`value`,void 0),T(this,K,void 0),T(this,q,void 0),this.key=e,this.value=t,this[K]=void 0,this[q]=void 0}toJSON(){return{key:this.key,value:this.value}}};gd=Symbol.iterator;var xd=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),D(()=>Be(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(T(this,`_keymap`,void 0),T(this,`size`,0),T(this,`limit`,void 0),T(this,`oldest`,void 0),T(this,`newest`,void 0),T(this,`_onShiftListeners`,[]),Sd.hasLength(e,1)){if(Sd.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(Sd.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}}else if(Sd.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=/* @__PURE__ */ new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[K]&&(e===this.oldest&&(this.oldest=e[K]),e[K][q]=e[q]),e[q]&&(e[q][K]=e[K]),e[K]=void 0,e[q]=this.newest,this.newest&&(this.newest[K]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new bd(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[K]=r,r[q]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new bd(e,t)),this.newest?(this.newest[K]=n,n[q]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[K]?(this.oldest=this.oldest[K],this.oldest[q]=void 0):(this.oldest=void 0,this.newest=void 0),e[K]=e[q]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[K]&&t[q]?(t[q][K]=t[K],t[K][q]=t[q]):t[K]?(t[K][q]=void 0,this.oldest=t[K]):t[q]?(t[q][K]=void 0,this.newest=t[q]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new _d(this.oldest)}values(){return new vd(this.oldest)}entries(){return this[Symbol.iterator]()}[gd](){return new yd(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[K]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[K];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[K],t&&(e+=` < `);return e}},Sd=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function Cd(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}function wd(){let e=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`?crypto:typeof self<`u`&&self.crypto&&typeof self.crypto.getRandomValues==`function`?self.crypto:typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`?window.crypto:void 0;return e==null?void 0:e.getRandomValues.bind(e)}function Td(e,t){let n=``;for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Ed(e,t,n){let r=256-256%t.length,i=Math.ceil(409.6*e/r),a=``;for(;a.length<e;){let o=n(new Uint8Array(i));for(let n=0;n<i&&a.length<e;n++){let e=o[n];e<r&&(a+=t[e%t.length])}}return a}function Dd(e=21,t=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`){if(!e)return``;let n=wd();return n?Ed(e,t,n):Td(e,t)}function J(e=21,t){return Dd(e,t)}function Od(e,t,n=0,r=e.length-1,i=Ad){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);Od(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(kd(e,n,t),i(e[r],a)>0&&kd(e,n,r);o<s;){for(kd(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?kd(e,n,s):(s++,kd(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function kd(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Ad(e,t){return e<t?-1:+(e>t)}var jd=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!Ud(e,t))return n;let r=this.toBBox,i=[];for(;t;){for(let a=0;a<t.children.length;a++){let o=t.children[a],s=t.leaf?r(o):o;Ud(e,s)&&(t.leaf?n.push(o):Hd(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n}collides(e){let t=this.data;if(!Ud(e,t))return!1;let n=[];for(;t;){for(let r=0;r<t.children.length;r++){let i=t.children[r],a=t.leaf?this.toBBox(i):i;if(Ud(e,a)){if(t.leaf||Hd(e,a))return!0;n.push(i)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Wd([]),this}remove(e,t){if(!e)return this;let n=this.data,r=this.toBBox(e),i=[],a=[],o,s,c;for(;n||i.length;){if(n||(n=i.pop(),s=i[i.length-1],o=a.pop(),c=!0),n.leaf){let r=Md(e,n.children,t);if(r!==-1)return n.children.splice(r,1),i.push(n),this._condense(i),this}!c&&!n.leaf&&Hd(n,r)?(i.push(n),a.push(o),o=0,s=n,n=n.children[0]):s?(o++,n=s.children[o],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){let i=n-t+1,a=this._maxEntries,o;if(i<=a)return o=Wd(e.slice(t,n+1)),Nd(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(a)),a=Math.ceil(i/a**(r-1))),o=Wd([]),o.leaf=!1,o.height=r;let s=Math.ceil(i/a),c=s*Math.ceil(Math.sqrt(a));Gd(e,t,n,c,this.compareMinX);for(let i=t;i<=n;i+=c){let t=Math.min(i+c-1,n);Gd(e,i,t,s,this.compareMinY);for(let n=i;n<=t;n+=s){let i=Math.min(n+s-1,t);o.children.push(this._build(e,n,i,r-1))}}return Nd(o,this.toBBox),o}_chooseSubtree(e,t,n,r){for(;r.push(t),!(t.leaf||r.length-1===n);){let n=1/0,r=1/0,i;for(let a=0;a<t.children.length;a++){let o=t.children[a],s=Rd(o),c=Bd(e,o)-s;c<r?(r=c,n=s<n?s:n,i=o):c===r&&s<n&&(n=s,i=o)}t=i||t.children[0]}return t}_insert(e,t,n){let r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),Fd(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)}_split(e,t){let n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);let a=this._chooseSplitIndex(n,i,r),o=Wd(n.children.splice(a,n.children.length-a));o.height=n.height,o.leaf=n.leaf,Nd(n,this.toBBox),Nd(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)}_splitRoot(e,t){this.data=Wd([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Nd(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,i=1/0,a=1/0;for(let o=t;o<=n-t;o++){let t=Pd(e,0,o,this.toBBox),s=Pd(e,o,n,this.toBBox),c=Vd(t,s),l=Rd(t)+Rd(s);c<i?(i=c,r=o,a=l<a?l:a):c===i&&l<a&&(a=l,r=o)}return r||n-t}_chooseSplitAxis(e,t,n){let r=e.leaf?this.compareMinX:Id,i=e.leaf?this.compareMinY:Ld;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);let i=this.toBBox,a=Pd(e,0,t,i),o=Pd(e,n-t,n,i),s=zd(a)+zd(o);for(let r=t;r<n-t;r++){let t=e.children[r];Fd(a,e.leaf?i(t):t),s+=zd(a)}for(let r=n-t-1;r>=t;r--){let t=e.children[r];Fd(o,e.leaf?i(t):t),s+=zd(o)}return s}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Fd(t[r],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():Nd(e[t],this.toBBox)}};function Md(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Nd(e,t){Pd(e,0,e.children.length,t,e)}function Pd(e,t,n,r,i){i||=Wd(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let a=t;a<n;a++){let t=e.children[a];Fd(i,e.leaf?r(t):t)}return i}function Fd(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Id(e,t){return e.minX-t.minX}function Ld(e,t){return e.minY-t.minY}function Rd(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function zd(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Bd(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Vd(e,t){let n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,a-r)}function Hd(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Ud(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Wd(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Gd(e,t,n,r,i){let a=[t,n];for(;a.length;){if(n=a.pop(),t=a.pop(),n-t<=r)continue;let o=t+Math.ceil((n-t)/r/2)*r;Od(e,o,t,n,i),a.push(t,o,o,n)}}var Kd=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===0||t.rangeType===void 0&&e.rangeType===0)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===1&&t.rangeType===2||e.rangeType===2&&t.rangeType===1)return!0;if(e.rangeType===1&&t.rangeType===1)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===2&&t.rangeType===2)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?1048575:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?16383:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?1048575:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?16383:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new jd;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:0}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===2),r=t.some(e=>e.rangeType===1),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?1:n?2:0}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return Zd(e)}static splitIntoGrid(e){return Yd(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=Qd(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};T(Kd,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),T(Kd,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[1,3].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[1,3].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[2,3].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[2,3].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),T(Kd,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),T(Kd,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),T(Kd,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case 1:r.startColumn+=t;break;case 2:r.startRow+=n;break;case 3:break;default:r.startRow+=n,r.startColumn+=t}switch(e.endAbsoluteRefType){case 1:r.endColumn+=t;break;case 2:r.endRow+=n;break;case 3:break;default:r.endRow+=n,r.endColumn+=t}return r});function qd(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||0,o=i.endAbsoluteRefType||0,s=i.rangeType||0;if(!r&&a===3&&o===3)return i;let c=Jd(i.startRow,n,i.startColumn,t,s),l=Jd(i.endRow,n,i.endColumn,t,s);return r||a===0&&o===0?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===0?i={...i,startRow:c.row,startColumn:c.column}:a===2?i={...i,startRow:c.row}:a===1&&(i={...i,startColumn:c.column}),o===0?i={...i,endRow:l.row,endColumn:l.column}:o===2?i={...i,endRow:l.row}:o===1&&(i={...i,endColumn:l.column}),i)}function Jd(e,t,n,r,i){return i===0?{row:e+t,column:n+r}:i===1?{row:e+t,column:n}:i===2?{row:e,column:n+r}:{row:e,column:n}}function Yd(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function Xd(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function Zd(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r]of[[n.startRow,!0],[n.endRow+1,!1]]){let i=t.get(e)??[];i.push({range:n,add:r}),t.set(e,i)}let n=[...t.keys()].sort((e,t)=>e-t),r=/* @__PURE__ */ new Set,i=[];for(let e=0;e<n.length-1;e++){let a=n[e],o=n[e+1]-1;for(let{range:e,add:n}of t.get(a))n?r.add(e):r.delete(e);let s=[...r].sort((e,t)=>e.startColumn-t.startColumn||e.endColumn-t.endColumn),c;for(let e of s)c&&e.startColumn<=c.endColumn+1?c.endColumn=Math.max(c.endColumn,e.endColumn):(c={startRow:a,endRow:o,startColumn:e.startColumn,endColumn:e.endColumn},i.push(c))}return Xd(i)}function Qd(e,t){let n=[];return e.forEach(e=>{n.push(...Kd.subtract(e,t))}),Kd.mergeRanges(n)}function $d(e,t){let n=ef(e.startRow,e.endRow,t.startRow,t.endRow),r=ef(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:tf(e.rangeType,t.rangeType,i,a,o,s)}}function ef(e,t,n,r){let i=Number.isNaN(e)?-1/0:e,a=Number.isNaN(t)?1/0:t,o=Number.isNaN(n)?-1/0:n,s=Number.isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function tf(e,t,n,r,i,a){let o=e===void 0?nf(n,r,i,a):e,s=t===void 0?nf(n,r,i,a):t;return o===3||s===3?o===s?o:o===3?s:o:o===s?o:0}function nf(e,t,n,r){let i=!Number.isNaN(e)&&!Number.isNaN(t),a=!Number.isNaN(n)&&!Number.isNaN(r);return i&&a?0:i?1:a?2:3}var rf=class{constructor(e,t){T(this,`_values`,[]),T(this,`_keys`,[]),T(this,`_keyMaps`,/* @__PURE__ */ new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||/* @__PURE__ */ new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function af(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function of(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function sf(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function cf(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function lf(e,t=!1){let n=97;return t&&(n=65),cf(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function uf(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function df(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function ff(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}let pf=/* @__PURE__ */ function(e){return e.Text=`text`,e.SingleSelect=`singleSelect`,e.MultiSelect=`multiSelect`,e.Person=`person`,e.Group=`group`,e.Date=`date`,e.Attachment=`attachment`,e.Number=`number`,e.Checkbox=`checkbox`,e.Link=`link`,e.Formula=`formula`,e.Numbering=`numbering`,e.Phone=`phone`,e.Email=`email`,e.Progress=`progress`,e.Currency=`currency`,e.Rating=`rating`,e.RecordLink=`recordLink`,e.RecordId=`recordId`,e.CreatedBy=`createdBy`,e.UpdatedBy=`updatedBy`,e.CreatedAt=`createdAt`,e.UpdatedAt=`updatedAt`,e}({}),mf=/* @__PURE__ */ function(e){return e.Parent=`parent`,e}({}),hf=/* @__PURE__ */ function(e){return e.Grid=`grid`,e.Kanban=`kanban`,e.Calendar=`calendar`,e.Gantt=`gantt`,e.Gallery=`gallery`,e.Pivot=`pivot`,e}({}),gf={CELL:`cell`,ROW:`row`,COLUMN:`column`},_f={IS:`is`,IS_NOT:`isNot`,CONTAINS:`contains`,NOT_CONTAINS:`notContains`,IS_EMPTY:`isEmpty`,IS_NOT_EMPTY:`isNotEmpty`,GREATER_THAN:`greaterThan`,LESS_THAN:`lessThan`,BEFORE:`before`,AFTER:`after`},vf={EXACT:`exact`,TODAY:`today`,TOMORROW:`tomorrow`,YESTERDAY:`yesterday`,THIS_WEEK:`thisWeek`,LAST_WEEK:`lastWeek`,THIS_MONTH:`thisMonth`,LAST_MONTH:`lastMonth`,PAST_7_DAYS:`past7`,NEXT_7_DAYS:`next7`,PAST_30_DAYS:`past30`,NEXT_30_DAYS:`next30`},yf=/* @__PURE__ */ function(e){return e.IS=`is`,e.IS_NOT=`isNot`,e.CONTAINS=`contains`,e.NOT_CONTAINS=`notContains`,e.IS_EMPTY=`isEmpty`,e.IS_NOT_EMPTY=`isNotEmpty`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.BEFORE=`before`,e.AFTER=`after`,e}({}),bf=/* @__PURE__ */ function(e){return e.AND=`and`,e.OR=`or`,e}({}),xf=/* @__PURE__ */ function(e){return e.ASC=`asc`,e.DESC=`desc`,e}({}),Sf=/* @__PURE__ */ function(e){return e.MissingParent=`missingParent`,e.SelfParent=`selfParent`,e.Cycle=`cycle`,e.MaxDepth=`maxDepth`,e}({}),Cf=`__record_id`,wf=`record-id`,Tf=/^[A-Za-z0-9_-]+$/;function Ef(){return{id:Cf,name:wf,type:`recordId`,config:{},system:!0,readonly:!0}}function Df(e){return Tf.test(e)}function Of(e){return e.trim().toLowerCase()===wf}function kf(e){let t=e.fields[Cf],n=Object.values(e.fields).filter(e=>e.type===`recordId`);if(!t||n.length!==1||t.type!==`recordId`||t.name!==`record-id`||t.system!==!0||t.readonly!==!0||e.fieldOrder[0]!==`__record_id`||e.primaryFieldId===`__record_id`||!e.fields[e.primaryFieldId])throw Error(`[BaseDataModel]: table "${e.id}" has an invalid record-id system field.`);let r=Object.values(e.fields).find(e=>e.id!==`__record_id`&&Of(e.name));if(r)throw Error(`[BaseDataModel]: field name "${r.name}" is reserved for the record-id system field.`);for(let[t,n]of Object.entries(e.records))if(n.id!==t||!Df(n.id)||n.values.__record_id!==n.id)throw Error(`[BaseDataModel]: record "${t}" has an invalid record-id projection.`)}function Af(e){let t=e.now??Date.now(),n=e.primaryFieldId??J(6),r=e.gridViewId??J(6),i=e.recordCount??0,a=Ef(),o={id:n,name:e.primaryFieldName??`Name`,type:`text`,config:{placeholder:`bases.fieldConfig.textPlaceholder`}},s={},c=[],l={},u={},d={};for(let n=0;n<i;n++){let r=`${e.id}-record-${n+1}`;s[r]={id:r,values:{[Cf]:r},orderKey:String(n+1).padStart(4,`0`),createdAt:t,updatedAt:t},c.push(r),l[r]=n,u[n]=r,d[n]={0:{v:r,t:1}}}let f={id:r,tableId:e.id,name:`Grid`,type:`grid`,fieldOrder:[Cf,n],fieldSettings:{[Cf]:{hidden:!0}},config:{frozenFieldCount:1}};return{id:e.id,name:e.name,primaryFieldId:n,fieldOrder:[Cf,n],fields:{[Cf]:a,[n]:o},records:s,recordOrder:c,rowIndex:l,rowId:u,colIndex:{[Cf]:0,[n]:1},colId:{0:Cf,1:n},cellData:d,resources:{attachmentSets:{},attachments:{}},views:{[r]:f},viewOrder:[r]}}function jf(e=J(),t=``,n=`zhCN`){let r=Date.now(),i=`table-1`;return{id:e,name:t,locale:n,appVersion:ze,schemaVersion:2,tableOrder:[i],tables:{[i]:Af({id:i,name:`Table 1`,now:r,recordCount:0})},createdAt:r,updatedAt:r}}var Mf=class extends M{constructor(e={}){super(),T(this,`type`,n.UniverType.UNIVER_BASE),T(this,`_name$`,void 0),T(this,`name$`,void 0),T(this,`_snapshot`,void 0);let r=jf();this._snapshot=Nf(z.commonExtend(r,e)),this._snapshot.id||(this._snapshot.id=`base-${Math.random().toString(36).slice(2,10)}`),this._name$=new t.BehaviorSubject(this._snapshot.name),this.name$=this._name$.asObservable()}getUnitId(){return this._snapshot.id}setName(e){this._snapshot.name=e,this._snapshot.updatedAt=Date.now(),this._name$.next(e)}getSnapshot(){return this._snapshot}checkTableName(e){return Object.values(this._snapshot.tables).some(t=>t.name.toLowerCase()===e.toLowerCase())}uniqueTableName(e){let t=e,n=1;for(;this.checkTableName(t);)t=`${e}${n}`,n++;return t}setSnapshot(e){this._snapshot=Pf(e)?e:Nf(e),this._name$.next(e.name)}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}dispose(){super.dispose(),this._name$.complete()}};function Nf(e){return delete e.compress,delete e.kind,Object.values(e.tables??{}).forEach(e=>{kf(e),If(e),Gf(e)}),e}function Pf(e){return Object.values(e.tables??{}).every(e=>Ff(e))}function Ff(e){let t=e.records??{},n=e.fields??{};if(kf(e),!Array.isArray(e.recordOrder)||!e.rowIndex||!e.rowId||!e.colIndex||!e.colId||!e.cellData||!e.resources||!e.resources.attachmentSets||!e.resources.attachments||Object.keys(t).length!==e.recordOrder.length)return!1;for(let n=0;n<e.recordOrder.length;n++){var r;let i=e.recordOrder[n];if(!t[i]||e.rowIndex[i]!==n||e.rowId[n]!==i||((r=e.cellData[n])==null||(r=r[0])==null?void 0:r.v)!==i)return!1}for(let t=0;t<e.fieldOrder.length;t++){let r=e.fieldOrder[t];if(n[r]&&(e.colIndex[r]!==t||e.colId[t]!==r))return!1}return!0}function If(e){Lf(e);let t=e.records??{},n=e.fields??{},r=Rf(e,t),i=zf(e,n);e.recordOrder=r,Bf(e),Vf(e,n),Hf(e,t,r),Uf(e,n,i),Wf(e,t,n)}function Lf(e){let t=e.cd;t&&!e.cellData&&(e.cellData=Object.create(null),t.forEach(([t,n,r])=>{e.cellData[t]=e.cellData[t]??{};let{c:i,...a}=r;e.cellData[t][n]=a}),delete e.cd)}function Rf(e,t){var n;let r=((n=e.recordOrder)==null?void 0:n.filter(e=>t[e]))??[],i=new Set(r),a=Object.values(t).filter(e=>!i.has(e.id));return a.length?[...r,...a.sort((e,t)=>e.orderKey.localeCompare(t.orderKey)).map(e=>e.id)]:r}function zf(e,t){return e.fieldOrder.filter(e=>t[e])}function Bf(e){e.rowIndex={...e.rowIndex},e.rowId={...e.rowId},e.colIndex={...e.colIndex},e.colId={...e.colId},e.cellData={...e.cellData},e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments}}function Vf(e,t){Object.entries(e.cellData??{}).forEach(([n,r])=>{let i=Number(n);e.cellData[i]={...r},Object.entries(e.cellData[i]??{}).forEach(([n,r])=>{var a;let o=Number(n),s=(a=e.colId)==null?void 0:a[o];e.cellData[i][o]=qf(r,s?t[s]:void 0)})})}function Hf(e,t,n){n.forEach((t,n)=>{e.rowIndex[t]??(e.rowIndex[t]=n)}),Object.entries(e.rowIndex??{}).forEach(([n,r])=>{t[n]&&(e.rowId[r]=n)})}function Uf(e,t,n){n.forEach((t,n)=>{e.colIndex[t]??(e.colIndex[t]=n)}),Object.entries(e.colIndex??{}).forEach(([n,r])=>{t[n]&&(e.colId[r]=n)})}function Wf(e,t,n){let r=e.rowIndex??{},i=e.colIndex??{},a=e.cellData??{};e.rowIndex=r,e.colIndex=i,e.cellData=a,Object.values(t).forEach(t=>{let o=r[t.id];o!=null&&(a[o]={...a[o]},a[o][0]={v:t.id,t:1},Object.entries(t.values??{}).forEach(([r,s])=>{let c=n[r];(c==null?void 0:c.type)===`attachment`&&Yf(e,t.id,r,s);let l=i[r];if(l==null)return;let u=a[o][l];u==null?a[o][l]=Kf(s,c):(a[o][l]=qf(u,c),Zf(u,c,s)&&(a[o][l]=Kf(s,c)))}))})}function Gf(e){for(let a of Object.values(e.records)){var t,n,r,i;let o=(t=e.rowIndex)==null?void 0:t[a.id];if(o==null||((n=e.colIndex)==null?void 0:n.__record_id)!==0||((r=e.colId)==null?void 0:r[0])!==`__record_id`||((i=e.cellData)==null||(i=i[o])==null||(i=i[0])==null?void 0:i.v)!==a.id)throw Error(`[BaseDataModel]: record "${a.id}" is missing its record-id cell projection.`)}}function Kf(e,t){if(Jf(e))return(t==null?void 0:t.type)===`attachment`?{...e,v:``,t:1}:qf(e,t);if((t==null?void 0:t.type)===`attachment`)return{v:``,t:1};if(Qf(t))return{v:$f(e).join(`, `),t:1};if((t==null?void 0:t.type)===`link`&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return{v:String(t.text??t.url??``),t:1}}return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?{v:e,t:tp(e)}:{v:null,t:null}}function qf(e,t){let n=np(e.t,e.v);if(n===void 0){let{t,...n}=e;return n}return{...e,t:n}}function Jf(e){return!!e&&typeof e==`object`&&(Object.prototype.hasOwnProperty.call(e,`v`)||Object.prototype.hasOwnProperty.call(e,`t`)||Object.prototype.hasOwnProperty.call(e,`p`)||Object.prototype.hasOwnProperty.call(e,`f`)||Object.prototype.hasOwnProperty.call(e,`si`))}function Yf(e,t,n,r){let i=Xf(r);e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments};let a=`${n}${t}`;e.resources.attachmentSets[a]=i.map((t,n)=>{let r=String(t.id??`${a}${n}`),i={...t,id:r};return e.resources.attachments[r]=i,r})}function Xf(e){if(e==null||e===``||Jf(e)&&!(`id`in e)&&!(`name`in e))return[];let t=Array.isArray(e)?e:[e],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`){let e={...r};Object.keys(e).length>0&&n.push(e)}else n.push({id:`attachment-${e}`,name:String(r)})}return n}function Zf(e,t,n){return(t==null?void 0:t.type)===`recordId`?e.v!==n:(t==null?void 0:t.type)===`attachment`?e.v!==``:Qf(t)?Array.isArray(n)&&(e.v==null||e.v===``):!1}function Qf(e){return(e==null?void 0:e.type)===`multiSelect`||(e==null?void 0:e.type)===`person`||(e==null?void 0:e.type)===`group`}function $f(e){if(e==null||e===``)return[];let t=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++){let r=ep(e[n]);r&&t.push(r)}return t}let n=String(e).split(`,`);for(let e=0;e<n.length;e++){let r=n[e].trim();r&&t.push(r)}return t}function ep(e){if(e==null)return``;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`){let t=e;return String(t.id??t.name??t.text??``)}return String(e)}function tp(e){return e==null?null:typeof e==`number`?2:typeof e==`boolean`?3:1}function np(e,t){return e===1||e===2||e===3||e===4||e==null?e:tp(t??null)}function rp(e){let t=e.trim().replace(/[^A-Za-z0-9_.]+/g,`_`),n=/[A-Za-z0-9]/.test(t)?t:`Table`,r=/^[A-Za-z_]/.test(n)?n:`_${n}`;return(/^[RC]$/i.test(r)||/^[A-Za-z]{1,3}[1-9]\d*$/.test(r)||/^R(?:\d+)?C(?:\d+)?$/i.test(r)?`_${r}`:r).slice(0,255)}function ip(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let r=pp(e.formulaName);r&&!n.has(r.toLowerCase())&&(n.add(r.toLowerCase()),t.set(e.id,r))}for(let e of i){if(t.has(e.id))continue;let i=op(e.name,n,e.formulaName,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function ap(e,t,n){return op(e,new Set(Array.from(t,e=>e.toLowerCase())),n)}function op(e,t,n,r=/* @__PURE__ */ new Map){let i=pp(n);if(i&&!t.has(i.toLowerCase()))return i;let a=rp(e),o=a.toLowerCase();if(!t.has(o))return a;let s=r.get(o)??2;for(;;){let e=`_${s++}`,n=`${a.slice(0,255-e.length)}${e}`;if(!t.has(n.toLowerCase()))return r.set(o,s),n}}function sp(e,t){return ip(t).get(e.id)??rp(e.name)}function cp(e,t){return lp(t)(e)}function lp(e,t=ip(e)){let n=gp(dp(e,t));return e=>vp(e,n)}function up(e){let t=ip(e),n=lp(e,t);for(let n of Object.values(e.tables))n.formulaName=t.get(n.id)??rp(n.name);for(let t of Object.values(e.tables)){for(let e of Object.values(t.fields)){var r;e.type===`formula`&&typeof((r=e.config)==null?void 0:r.formula)==`string`&&(e.config.formula=n(e.config.formula))}for(let e of Object.values(t.cellData??{}))for(let t of Object.values(e??{}))t&&typeof t.f==`string`&&(t.f=n(t.f))}}function dp(e,t=ip(e)){let n=fp(e),r=new Map(Array.from(t,([e,t])=>[t.toLowerCase(),e])),i=/* @__PURE__ */ new Map;for(let t of Object.values(e.tables)){let e=t.name.toLowerCase();i.set(e,(i.get(e)??0)+1)}return Object.values(e.tables).flatMap(e=>{let a=t.get(e.id)??rp(e.name),o=[e.id,_p(e.id),n.get(e.id),e.formulaName];return i.get(e.name.toLowerCase())===1&&o.push(e.name),o.filter(e=>!!e).flatMap(e=>[e,mp(e)]).filter(e=>!!e).filter(e=>e.toLowerCase()!==a.toLowerCase()).filter(t=>{let n=r.get(hp(t).toLowerCase());return n==null||n===e.id}).map(e=>({alias:e,formulaName:a}))}).sort((e,t)=>t.alias.length-e.alias.length)}function fp(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let i=op(e.name,n,void 0,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function pp(e){let t=e==null?void 0:e.trim();return t&&rp(t)===t?t:void 0}function mp(e){return/[^A-Za-z0-9_.]/.test(e)?`'${e.replaceAll(`'`,`''`)}'`:void 0}function hp(e){return e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1).replaceAll(`''`,`'`):e}function gp(e){let t=/* @__PURE__ */ new Map;for(let{alias:n,formulaName:r}of e){let e=n.toLowerCase();t.has(e)||t.set(e,r)}let n=Array.from(t.keys()).sort((e,t)=>t.length-e.length);return{formulaNameByAlias:t,pattern:n.length?RegExp(`(${n.map(yp).join(`|`)})(\\s*)\\[`,`gi`):void 0}}function _p(e){return`_T_${Array.from(e,e=>{var t;return/[A-Za-z0-9]/.test(e)?e:`_x${((t=e.codePointAt(0))==null?void 0:t.toString(16))??`0`}_`}).join(``)}`}function vp(e,t){if(!t.pattern)return e;let n=0,r=!1;return t.pattern.lastIndex=0,e.replace(t.pattern,(i,a,o,s)=>{r=bp(e,n,s,r),n=s;let c=e[s-1];if(c!=null&&/[A-Za-z0-9_.]/.test(c)||c===`!`||r)return i;let l=t.formulaNameByAlias.get(a.toLowerCase());return l?`${l}${o}[`:i})}function yp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function bp(e,t,n,r){let i=r;for(let r=t;r<n;r++)e[r]===`"`&&(i&&e[r+1]===`"`?r++:i=!i);return i}var xp=/* @__PURE__ */ f(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,this.maxPending=e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,/* @__PURE__ */ Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)f(!1,/* @__PURE__ */ Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,/* @__PURE__ */ Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,/* @__PURE__ */ Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),Sp=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t)=>{t.exports=xp()})))());let Cp=/* @__PURE__ */ new Set([`true`,`false`]);function wp(e){return Cp.has(e.toLowerCase())}let Tp=`__INTERNAL_EDITOR__`,Ep=`${Tp}DOCS_NORMAL`,Dp=`${Tp}DOCS_FORMULA_BAR`,Op=`${Tp}COMMENT_EDITOR`,kp=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`),Ap=Symbol(`SHEET_TEXT_LINE_GAP`);function jp(e){return`${Tp}${e}`}function Mp(e){return e.startsWith(Tp)}function Np(e){return e.startsWith(Op)}let Pp=/* @__PURE__ */ function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Fp=/* @__PURE__ */ function(e){return e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e[e.DRAWING_IMAGE=0]=`DRAWING_IMAGE`,e[e.DRAWING_SHAPE=1]=`DRAWING_SHAPE`,e[e.DRAWING_CHART=2]=`DRAWING_CHART`,e[e.DRAWING_TABLE=3]=`DRAWING_TABLE`,e[e.DRAWING_SMART_ART=4]=`DRAWING_SMART_ART`,e[e.DRAWING_VIDEO=5]=`DRAWING_VIDEO`,e[e.DRAWING_GROUP=6]=`DRAWING_GROUP`,e[e.DRAWING_UNIT=7]=`DRAWING_UNIT`,e[e.DRAWING_DOM=8]=`DRAWING_DOM`,e[e.DRAWING_BLOCK=9]=`DRAWING_BLOCK`,e[e.DRAWING_SLICER=10]=`DRAWING_SLICER`,e[e.DRAWING_TIMELINE=11]=`DRAWING_TIMELINE`,e[e.DRAWING_OLE=12]=`DRAWING_OLE`,e}({});function Ip(e,t){let n=Math.max(0,t-1);return Math.max(0,Math.min(Math.floor(e),n))||0}function Lp(e,t,n){let r=Ip(e,t);return n===2?Ip(t-1,t):n===0?Ip(r+1,t):n===1?Ip(r-1,t):0}function Rp(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}function zp(){}function Bp(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(r&&=(clearTimeout(r),null),n=a,e.apply(this,i))}}let Vp=/* @__PURE__ */ function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function Hp(e){return`sheet_interceptor_${e}`}let Up=e=>function(t,n){let r=-1,i=t,a=!1,o=e=>(a=!0,e);for(let t=0;t<e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);r=t;let s=e[t];if(a=!1,i=s.handler(i,n,o),!a)break}return i};var Wp=class extends k{constructor(e){super(),T(this,`_interceptorsByName`,/* @__PURE__ */ new Map),T(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){this.ensureNotDisposed();let n=e,r=this._interceptorsByName.get(n);t&&(r=r.filter(t));let i=Up(r||[]);return(e,t)=>(this.ensureNotDisposed(),i(e,t))}intercept(e,t){this.ensureNotDisposed();let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0)));let i=t;return()=>{let e=i;if(i=void 0,!e||this._disposed)return!1;let t=this._interceptorsByName.get(n);return t?Be(t,e):!1}}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear(),super.dispose()}};function Gp(e){return`sheet_async_interceptor_${e}`}let Kp=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var qp=class extends k{constructor(e){super(),T(this,`_asyncInterceptorsByName`,/* @__PURE__ */ new Map),T(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){this.ensureNotDisposed();let n=e,r=this._asyncInterceptorsByName.get(n);t&&(r=r.filter(t));let i=Kp(r||[]);return async(e,t)=>(this.ensureNotDisposed(),i(e,t))}async interceptAsync(e,t){this.ensureNotDisposed();let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0)));let i=t;return()=>{let e=i;if(i=void 0,!e||this._disposed)return!1;let t=this._asyncInterceptorsByName.get(n);return t?Be(t,e):!1}}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear(),super.dispose()}};function Jp(e){return e.map(e=>e/255)}function Yp(e){return e.map(e=>Math.round(e*255))}function Xp([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4}o/=6}return[o,s,a]}function Zp(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function Qp(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function $p(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}let em={r:1,g:1,b:1},tm={r:0,g:0,b:0},nm=Zp(em.r,em.g,em.b),rm=Zp(tm.r,tm.g,tm.b);function im(e){let t=Zp(e[0],e[1],e[2]),n=Qp(nm,t),r=Xp(e),i=1-r[2],a,o,s;do a=$p(r[0],r[1],i),o=Zp(a[0],a[1],a[2]),s=Qp(o,rm),i+=.01;while(i<=1&&i>=0&&Math.abs(s-n)<.01);return a}function am(e){return Yp(im(Jp(e)))}let om=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function sm(e){let t=e[0],n=e[1],r=e[2],i=[om[0][0]*t+om[0][1]*n+om[0][2]*r+om[0][4],om[1][0]*t+om[1][1]*n+om[1][2]*r+om[1][4],om[2][0]*t+om[2][1]*n+om[2][2]*r+om[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function cm(e){return Yp(sm(Jp(e)))}var lm=class{constructor(){T(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function um(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function dm(e){return/^-?\d+(\.\d+)?$/.test(e)}function fm(e){return dm(e)?Number(e)<=2**53-1:!1}function pm(e){return Number(e)>2**53-1||e.length>=18}var mm=class e{constructor(){T(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},hm=class e{constructor(){T(this,`_data`,/* @__PURE__ */ new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function gm(e){let t=new MessageChannel,n=!1,r=()=>{t.port1.onmessage=null,t.port1.close(),t.port2.close()},i=()=>{n||(n=!0,r(),e())};return t.port1.onmessage=i,t.port2.postMessage(null),()=>{n||(n=!0,r())}}function _m(e,t){return t.forEach(t=>e.add(t)),e}let vm=`section_`;function ym(e){let t=`${vm}${J(12)}`;for(;e.has(t);)t=`${vm}${J(12)}`;return e.add(t),t}function bm(e,t,n=!0){let r=z.deepClone(e);return n&&xm(r.sectionId)&&!t.has(r.sectionId)?(t.add(r.sectionId),r):(r.sectionId=ym(t),r)}function xm(e){return typeof e==`string`&&e.startsWith(`section_`)&&e.length>8}let Sm=/* @__PURE__ */ function(e){return e.PARAGRAPH=`PARAGRAPH`,e.SECTION_BREAK=`SECTION_BREAK`,e.TABLE=`TABLE`,e.TABLE_ROW=`TABLE_ROW`,e.TABLE_CELL=`TABLE_CELL`,e.COLUMN_GROUP=`COLUMN_GROUP`,e.COLUMN=`COLUMN`,e.BLOCK=`BLOCK`,e.CUSTOM_BLOCK=`CUSTOM_BLOCK`,e}({}),Cm=/* @__PURE__ */ function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
|
|
2
|
-
`,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.COLUMN_GROUP_START=``,e.COLUMN_START=``,e.COLUMN_END=``,e.COLUMN_GROUP_END=``,e.BLOCK_START=``,e.BLOCK_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({}),
|
|
3
|
-
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\v`,`\f`,`\0`,`\b`]),Tm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Bopomofo}\u3000-\u303F\uFF00-\uFFEF]/u,Em=/\p{Script=Hangul}/u,Dm=2e4;function Om(){return{words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0}}function km(e){if(e!=null&&e.aborted)throw Error(`Document statistics calculation aborted`)}function Am(e){return km(e),new Promise(e=>{setTimeout(e,0)})}function jm(e,t){if(!(t!=null&&t.length))return[e];let n=t.filter(e=>!e.collapsed).map(t=>({startOffset:Math.max(0,Math.min(t.startOffset,t.endOffset)),endOffset:Math.min(e.length,Math.max(t.startOffset,t.endOffset))})).filter(e=>e.startOffset<e.endOffset).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),r=[];for(let e of n){let t=r.at(-1);t&&e.startOffset<=t.endOffset?t.endOffset=Math.max(t.endOffset,e.endOffset):r.push({...e})}return r.map(t=>e.slice(t.startOffset,t.endOffset))}function Mm(e){return Array.from(e).every(e=>wm.has(e))}async function Nm(e,t){let{locale:n,ranges:r,signal:i}=t,a=n==null?void 0:xe[n].tag,o=new Intl.Segmenter(a,{granularity:`grapheme`}),s=new Intl.Segmenter(a,{granularity:`word`}),c=Om();await Am(i),km(i);for(let t of jm(e,r)){let e=0,n=!1;for(let{segment:r}of o.segment(t))km(i),r.includes(`\r`)&&(n&&(c.paragraphs+=1),n=!1),Mm(r)||(c.charactersWithSpaces+=1,/^\s+$/u.test(r)||(c.charactersWithoutSpaces+=1,n=!0),Tm.test(r)&&(c.asianCharactersAndKoreanWords+=1)),e+=r.length,e>=Dm&&(e=0,await Am(i));let r=0;for(let e of s.segment(t))km(i),e.isWordLike&&!Tm.test(e.segment)&&(Em.test(e.segment)?c.asianCharactersAndKoreanWords+=1:c.nonAsianWords+=1),r+=e.segment.length,r>=Dm&&(r=0,await Am(i))}return km(i),c.words=c.nonAsianWords+c.asianCharactersAndKoreanWords,c}let Pm=/* @__PURE__ */ function(e){return e.PARAGRAPH=`paragraph`,e.BLOCK_RANGE=`blockRange`,e.TABLE=`table`,e.CUSTOM_BLOCK=`customBlock`,e.COLUMN_GROUP=`columnGroup`,e}({}),Fm=/* @__PURE__ */ function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),Im=/* @__PURE__ */ function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),Lm=/* @__PURE__ */ function(e){return e[e.BULLET=0]=`BULLET`,e[e.NONE=1]=`NONE`,e[e.DECIMAL=2]=`DECIMAL`,e[e.DECIMAL_ZERO=3]=`DECIMAL_ZERO`,e[e.UPPER_LETTER=4]=`UPPER_LETTER`,e[e.LOWER_LETTER=5]=`LOWER_LETTER`,e[e.UPPER_ROMAN=6]=`UPPER_ROMAN`,e[e.LOWER_ROMAN=7]=`LOWER_ROMAN`,e[e.ORDINAL=8]=`ORDINAL`,e[e.CARDINAL_TEXT=9]=`CARDINAL_TEXT`,e[e.ORDINAL_TEXT=10]=`ORDINAL_TEXT`,e[e.HEX=11]=`HEX`,e[e.CHICAGO=12]=`CHICAGO`,e[e.IDEOGRAPH_DIGITAL=13]=`IDEOGRAPH_DIGITAL`,e[e.JAPANESE_COUNTING=14]=`JAPANESE_COUNTING`,e[e.AIUEO=15]=`AIUEO`,e[e.IROHA=16]=`IROHA`,e[e.DECIMAL_FULL_WIDTH=17]=`DECIMAL_FULL_WIDTH`,e[e.DECIMAL_HALF_WIDTH=18]=`DECIMAL_HALF_WIDTH`,e[e.JAPANESE_LEGAL=19]=`JAPANESE_LEGAL`,e[e.JAPANESE_DIGITAL_TEN_THOUSAND=20]=`JAPANESE_DIGITAL_TEN_THOUSAND`,e[e.DECIMAL_ENCLOSED_CIRCLE=21]=`DECIMAL_ENCLOSED_CIRCLE`,e[e.DECIMAL_FULL_WIDTH2=22]=`DECIMAL_FULL_WIDTH2`,e[e.AIUEO_FULL_WIDTH=23]=`AIUEO_FULL_WIDTH`,e[e.IROHA_FULL_WIDTH=24]=`IROHA_FULL_WIDTH`,e[e.GANADA=25]=`GANADA`,e[e.CHOSUNG=26]=`CHOSUNG`,e[e.DECIMAL_ENCLOSED_FULLSTOP=27]=`DECIMAL_ENCLOSED_FULLSTOP`,e[e.DECIMAL_ENCLOSED_PAREN=28]=`DECIMAL_ENCLOSED_PAREN`,e[e.DECIMAL_ENCLOSED_CIRCLE_CHINESE=29]=`DECIMAL_ENCLOSED_CIRCLE_CHINESE`,e[e.IDEOGRAPH_ENCLOSED_CIRCLE=30]=`IDEOGRAPH_ENCLOSED_CIRCLE`,e[e.IDEOGRAPH_TRADITIONAL=31]=`IDEOGRAPH_TRADITIONAL`,e[e.IDEOGRAPH_ZODIAC=32]=`IDEOGRAPH_ZODIAC`,e[e.IDEOGRAPH_ZODIAC_TRADITIONAL=33]=`IDEOGRAPH_ZODIAC_TRADITIONAL`,e[e.TAIWANESE_COUNTING=34]=`TAIWANESE_COUNTING`,e[e.IDEOGRAPH_LEGAL_TRADITIONAL=35]=`IDEOGRAPH_LEGAL_TRADITIONAL`,e[e.TAIWANESE_COUNTING_THOUSAND=36]=`TAIWANESE_COUNTING_THOUSAND`,e[e.TAIWANESE_DIGITAL=37]=`TAIWANESE_DIGITAL`,e[e.CHINESE_COUNTING=38]=`CHINESE_COUNTING`,e[e.CHINESE_LEGAL_SIMPLIFIED=39]=`CHINESE_LEGAL_SIMPLIFIED`,e[e.CHINESE_COUNTING_THOUSAND=40]=`CHINESE_COUNTING_THOUSAND`,e[e.KOREAN_DIGITAL=41]=`KOREAN_DIGITAL`,e[e.KOREAN_COUNTING=42]=`KOREAN_COUNTING`,e[e.KOREAN_LEGAL=43]=`KOREAN_LEGAL`,e[e.KOREAN_DIGITAL2=44]=`KOREAN_DIGITAL2`,e[e.VIETNAMESE_COUNTING=45]=`VIETNAMESE_COUNTING`,e[e.RUSSIAN_LOWER=46]=`RUSSIAN_LOWER`,e[e.RUSSIAN_UPPER=47]=`RUSSIAN_UPPER`,e[e.NUMBER_IN_DASH=48]=`NUMBER_IN_DASH`,e[e.HEBREW1=49]=`HEBREW1`,e[e.HEBREW2=50]=`HEBREW2`,e[e.ARABIC_ALPHA=51]=`ARABIC_ALPHA`,e[e.ARABIC_ABJAD=52]=`ARABIC_ABJAD`,e[e.HINDI_VOWELS=53]=`HINDI_VOWELS`,e[e.HINDI_CONSONANTS=54]=`HINDI_CONSONANTS`,e[e.HINDI_NUMBERS=55]=`HINDI_NUMBERS`,e[e.HINDI_COUNTING=56]=`HINDI_COUNTING`,e[e.THAI_LETTERS=57]=`THAI_LETTERS`,e[e.THAI_NUMBERS=58]=`THAI_NUMBERS`,e[e.THAI_COUNTING=59]=`THAI_COUNTING`,e[e.CUSTOM=60]=`CUSTOM`,e}({}),Rm=/* @__PURE__ */ function(e){return e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]=`BULLET_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e[e.BOTH=4]=`BOTH`,e}({}),zm=/* @__PURE__ */ function(e){return e.CALLOUT=`callout`,e.QUOTE=`quote`,e.CODE=`code`,e}({}),Bm=/* @__PURE__ */ function(e){return e[e.HYPERLINK=0]=`HYPERLINK`,e[e.FIELD=1]=`FIELD`,e[e.SDT=2]=`SDT`,e[e.BOOKMARK=3]=`BOOKMARK`,e[e.COMMENT=4]=`COMMENT`,e[e.CUSTOM=5]=`CUSTOM`,e[e.MENTION=6]=`MENTION`,e[e.UNI_FORMULA=7]=`UNI_FORMULA`,e[e.FOOTNOTE=8]=`FOOTNOTE`,e[e.ENDNOTE=9]=`ENDNOTE`,e[e.DELTED=9999]=`DELTED`,e}({}),Vm=/* @__PURE__ */ function(e){return e.COLUMN=`column`,e.TEXT_WRAPPING=`textWrapping`,e}({}),Hm=/* @__PURE__ */ function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),Um=/* @__PURE__ */ function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),Wm=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e[e.DRAWINGML=3]=`DRAWINGML`,e}({}),Gm=/* @__PURE__ */ function(e){return e[e.DEFAULT=0]=`DEFAULT`,e[e.LINES=1]=`LINES`,e[e.LINES_AND_CHARS=2]=`LINES_AND_CHARS`,e[e.SNAP_TO_CHARS=3]=`SNAP_TO_CHARS`,e}({}),Km=/* @__PURE__ */ function(e){return e[e.SECTION_TYPE_UNSPECIFIED=0]=`SECTION_TYPE_UNSPECIFIED`,e[e.CONTINUOUS=1]=`CONTINUOUS`,e[e.NEXT_COLUMN=2]=`NEXT_COLUMN`,e[e.NEXT_PAGE=3]=`NEXT_PAGE`,e[e.EVEN_PAGE=4]=`EVEN_PAGE`,e[e.ODD_PAGE=5]=`ODD_PAGE`,e}({}),qm=/* @__PURE__ */ function(e){return e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]=`COLUMN_SEPARATOR_STYLE_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.BETWEEN_EACH_COLUMN=2]=`BETWEEN_EACH_COLUMN`,e}({}),Jm=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),Ym=/* @__PURE__ */ function(e){return e[e.TEXT_RUN=0]=`TEXT_RUN`,e[e.AUTO_TEXT=1]=`AUTO_TEXT`,e[e.PAGE_BREAK=2]=`PAGE_BREAK`,e[e.COLUMN_BREAK=3]=`COLUMN_BREAK`,e[e.FOOT_NOTE_REFERENCE=4]=`FOOT_NOTE_REFERENCE`,e[e.HORIZONTAL_RULE=5]=`HORIZONTAL_RULE`,e[e.EQUATION=6]=`EQUATION`,e[e.DRAWING=7]=`DRAWING`,e[e.PERSON=8]=`PERSON`,e[e.RICH_LINK=9]=`RICH_LINK`,e}({}),Xm=/* @__PURE__ */ function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),Zm=/* @__PURE__ */ function(e){return e[e.INLINE=0]=`INLINE`,e[e.WRAP_NONE=1]=`WRAP_NONE`,e[e.WRAP_POLYGON=2]=`WRAP_POLYGON`,e[e.WRAP_SQUARE=3]=`WRAP_SQUARE`,e[e.WRAP_THROUGH=4]=`WRAP_THROUGH`,e[e.WRAP_TIGHT=5]=`WRAP_TIGHT`,e[e.WRAP_TOP_AND_BOTTOM=6]=`WRAP_TOP_AND_BOTTOM`,e}({}),Qm=/* @__PURE__ */ function(e){return e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]=`NAMED_STYLE_TYPE_UNSPECIFIED`,e[e.NORMAL_TEXT=1]=`NORMAL_TEXT`,e[e.TITLE=2]=`TITLE`,e[e.SUBTITLE=3]=`SUBTITLE`,e[e.HEADING_1=4]=`HEADING_1`,e[e.HEADING_2=5]=`HEADING_2`,e[e.HEADING_3=6]=`HEADING_3`,e[e.HEADING_4=7]=`HEADING_4`,e[e.HEADING_5=8]=`HEADING_5`,e}({}),$m=/* @__PURE__ */ function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),eh=/* @__PURE__ */ function(e){return e[e.DASH_STYLE_UNSPECIFIED=0]=`DASH_STYLE_UNSPECIFIED`,e[e.SOLID=1]=`SOLID`,e[e.DOT=2]=`DOT`,e[e.DASH=3]=`DASH`,e}({}),th=/* @__PURE__ */ function(e){return e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]=`TAB_STOP_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e}({}),nh=/* @__PURE__ */ function(e){return e[e.TAB_STOP_LEADER_UNSPECIFIED=0]=`TAB_STOP_LEADER_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.DOT=2]=`DOT`,e[e.HYPHEN=3]=`HYPHEN`,e[e.UNDERSCORE=4]=`UNDERSCORE`,e[e.HEAVY=5]=`HEAVY`,e[e.MIDDLE_DOT=6]=`MIDDLE_DOT`,e}({}),rh=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),ih=/* @__PURE__ */ function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),ah=/* @__PURE__ */ function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),oh=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),sh=/* @__PURE__ */ function(e){return e.FIXED=`fixed`,e.AUTO=`auto`,e}({}),ch=/* @__PURE__ */ function(e){return e.STACK=`stack`,e.SHRINK=`shrink`,e}({}),lh=/* @__PURE__ */ function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),uh=/* @__PURE__ */ function(e){return e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]=`CONTENT_ALIGNMENT_UNSPECIFIED`,e[e.BOTH=1]=`BOTH`,e[e.TOP=2]=`TOP`,e[e.CENTER=3]=`CENTER`,e[e.BOTTOM=4]=`BOTTOM`,e}({}),dh=/* @__PURE__ */ function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),fh=/* @__PURE__ */ function(e){return e[e.PAGE=0]=`PAGE`,e[e.COLUMN=1]=`COLUMN`,e[e.CHARACTER=2]=`CHARACTER`,e[e.MARGIN=3]=`MARGIN`,e[e.INSIDE_MARGIN=4]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=5]=`OUTSIDE_MARGIN`,e[e.LEFT_MARGIN=6]=`LEFT_MARGIN`,e[e.RIGHT_MARGIN=7]=`RIGHT_MARGIN`,e}({}),ph=/* @__PURE__ */ function(e){return e[e.PAGE=0]=`PAGE`,e[e.PARAGRAPH=1]=`PARAGRAPH`,e[e.LINE=2]=`LINE`,e[e.MARGIN=3]=`MARGIN`,e[e.TOP_MARGIN=4]=`TOP_MARGIN`,e[e.BOTTOM_MARGIN=5]=`BOTTOM_MARGIN`,e[e.INSIDE_MARGIN=6]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=7]=`OUTSIDE_MARGIN`,e}({}),mh=/* @__PURE__ */ function(e){return e[e.POINT=0]=`POINT`,e[e.LINE=1]=`LINE`,e[e.CHARACTER=2]=`CHARACTER`,e[e.PIXEL=3]=`PIXEL`,e[e.PERCENT=4]=`PERCENT`,e}({}),hh=/* @__PURE__ */ function(e){return e[e.CENTER=0]=`CENTER`,e[e.INSIDE=1]=`INSIDE`,e[e.LEFT=2]=`LEFT`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.RIGHT=4]=`RIGHT`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTE=6]=`DISTRIBUTE`,e}({}),gh=/* @__PURE__ */ function(e){return e[e.BOTTOM=0]=`BOTTOM`,e[e.CENTER=1]=`CENTER`,e[e.INSIDE=2]=`INSIDE`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.TOP=4]=`TOP`,e}({}),_h=/* @__PURE__ */ function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),vh=/* @__PURE__ */ function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),yh=/* @__PURE__ */ function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({}),bh=[`A3`,`A4`,`A5`,`B4`,`B5`,`Letter`,`Tabloid`,`Legal`,`Statement`,`Executive`,`Folio`];function xh(){return e=>e}let Sh=xh()([`s`,`c`,`cl`,`t`]),Ch=xh()([`rgb`,`th`]),wh=xh()([`s`,`cl`]),Th=xh()([`t`,`r`,`b`,`l`,`tl_br`,`tl_bc`,`tl_mr`,`bl_tr`,`ml_tr`,`bc_tr`]),Eh=xh()([`a`,`v`]),Dh=xh()([`t`,`r`,`b`,`l`]),Oh=xh()([`ff`,`eastAsiaFontFamily`,`fs`,`it`,`bl`,`ul`,`bbl`,`st`,`ol`,`bg`,`bd`,`cl`,`va`,`n`,`stf`,`tr`,`td`,`ht`,`vt`,`tb`,`pd`]),kh={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Ah={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},jh={startRow:0,startColumn:0,endRow:0,endColumn:0},Mh={row:0,column:0},Y={ff:`Arial`,fs:11,it:0,bl:0,ul:{s:0},st:{s:0},ol:{s:0},tr:{a:0,v:0},td:0,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:0,vt:0,tb:0,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},Nh=[Ep,Dp],Ph={4:{fs:20,bl:1},5:{fs:18,bl:1},6:{fs:16,bl:1},7:{fs:14,bl:1},8:{fs:12,bl:1},1:null,2:{fs:26,bl:1},3:{fs:15,cl:{rgb:`#999999`}},0:null},Fh=1.5,Ih={4:{spaceAbove:{v:20},spaceBelow:{v:10}},5:{spaceAbove:{v:18},spaceBelow:{v:10}},6:{spaceAbove:{v:16},spaceBelow:{v:10}},7:{spaceAbove:{v:14},spaceBelow:{v:8}},8:{spaceAbove:{v:12},spaceBelow:{v:8}},1:{spaceAbove:{v:0},spaceBelow:{v:12}},2:{spaceAbove:{v:0},spaceBelow:{v:7}},3:{spaceAbove:{v:0},spaceBelow:{v:16}},0:null},Lh=/* @__PURE__ */ function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({}),Rh={A3:{width:1123,height:1587},A4:{width:794,height:1124},A5:{width:559,height:794},B4:{width:944,height:1344},B5:{width:665,height:944},Executive:{width:696,height:1008},Folio:{width:816,height:1248},Legal:{width:816,height:1344},Letter:{width:816,height:1056},Statement:{width:528,height:816},Tabloid:{width:1056,height:1632}},zh=/* @__PURE__ */ function(e){return e.NARROW=`narrow`,e.MEDIUM=`medium`,e.WIDE=`wide`,e}({}),Bh={narrow:Rh.A4.width,medium:960,wide:Rh.A3.width},Vh=`para_`;function Hh(e){let t=`${Vh}${J(12)}`;for(;e.has(t);)t=`${Vh}${J(12)}`;return e.add(t),t}function Uh(e,t){let n=Kh(e),r=/* @__PURE__ */ new Set;for(let e of n.paragraphs??[])e.paragraphId=Hh(r);return n}function Wh(e,t,n){let r=qh(e);return n!==!1&&Gh(r.paragraphId)&&!t.has(r.paragraphId)?(t.add(r.paragraphId),r):(r.paragraphId=Hh(t),r)}function Gh(e){return typeof e==`string`&&e.startsWith(`para_`)&&e.length>5}function Kh(e){return JSON.parse(JSON.stringify(e))}function qh(e){return JSON.parse(JSON.stringify(e))}function Jh(e=J(6),t=`enUS`,n=``,r=2){let i={id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},notes:{},noteSettings:{},body:{dataStream:`\r
|
|
4
|
-
`,textRuns:[],customBlocks:[],tables:[],columnGroups:[],blockRanges:[],customRanges:[],customDecorations:[],paragraphs:[{startIndex:0,paragraphId:Hh(/* @__PURE__ */ new Set),paragraphStyle:{lineSpacing:1}}],sectionBreaks:[{sectionId:ym(/* @__PURE__ */ new Set),startIndex:1}]},documentStyle:{pageSize:Rh.A4,documentFlavor:r,marginTop:72,marginBottom:72,marginRight:72,marginLeft:72,autoHyphenation:r===3?0:1,doNotHyphenateCaps:0,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:0,useFirstPageHeaderFooter:0,marginHeader:30,marginFooter:30},settings:{}};return r===2&&(i.body.paragraphs[0].paragraphStyle={},i.documentStyle.defaultParagraphStyle={spaceAbove:{v:0},lineSpacing:Fh,spaceBelow:{v:12}},i.documentStyle.pageSize={width:Bh.medium,height:842/.75},i.documentStyle.marginTop=50,i.documentStyle.marginBottom=50,i.documentStyle.marginRight=50,i.documentStyle.marginLeft=50,i.documentStyle.renderConfig={zeroWidthParagraphBreak:0,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}}),i}var Yh=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),Xh=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}return e}e.default=t})),Zh=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a??s,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),Qh=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||={})})),$h=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),eg=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=$h(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`)}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(n&&n.d!==0&&n.d!==``){if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1]){if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n}else t.push(n)}},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i)}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d))}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),tg=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=eg(),n=$h();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),ng=/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;let s=$h(),c=a(eg()),l=o(tg()),u={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=s.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(s.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:c.uniSlice},d=c.default(u);e.type=Object.assign(Object.assign({},d),{api:l.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>c.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var f=eg();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return f.default}})})),rg=/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let i=r(Yh()),a=r(Xh()),o=Zh(),s=Qh(),c=()=>{};function l(e,t){if(!e)throw Error(t)}let u=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:o.readCursor,writeCursor:o.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){u=e,c.quiet=!e},registerSubtype:x,checkValidOp:k,normalize:A,apply:j,transformPosition:M,compose:N,tryTransform:R,transform:ne,makeInvertible:I,invert:P,invertWithDoc:L,RM_UNEXPECTED_CONTENT:s.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:s.ConflictType.DROP_COLLISION,BLACKHOLE:s.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>z(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>z(t,e,n,r)})};let d=e=>e?e.getComponent():null;function f(e){return e&&typeof e==`object`&&!Array.isArray(e)}let p=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,m=e=>e&&(e.p!=null||e.r!==void 0),h=e=>e&&(e.d!=null||e.i!==void 0);function g(e,t){return l(e!=null),typeof t==`number`?(l(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(l(f(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function _(e,t,n){return typeof t==`number`?(l(e!=null,`Container is missing for key`),l(Array.isArray(e),`Cannot use numerical key for object container`),l(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(l(f(e),`Cannot insert into missing item`),l(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>o.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>o.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>o.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>o.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>o.writeCursor().at(e,e=>E(e,t,n,r)).get();let v=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),y=(e,t)=>v(e,t)?e[t]:void 0,b={};function x(e){let t=e.type?e.type:e;t.name&&(b[t.name]=t),t.uri&&(b[t.uri]=t)}let S=e=>{let t=b[e];if(t)return t;throw Error(`Missing type: `+e)};x(ng());let C=(e,t)=>e+t;x({name:`number`,apply:C,compose:C,invert:e=>-e,transform:e=>e});let w=e=>e==null?null:e.et?S(e.et):e.es?b[`text-unicode`]:e.ena==null?null:b.number,T=e=>e.es?e.es:e.ena==null?e.e:e.ena,E=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[S(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function D(e){l(typeof e==`number`),l(e>=0),l(e===(0|e))}function O(e){typeof e==`number`?D(e):l(typeof e==`string`)}function k(e){if(e===null)return;let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,l(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)D(o),l(!t.has(o)),t.add(o),l(e.r===void 0);else if(a===`d`)D(o),l(!n.has(o)),n.add(o),l(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){l(!i),i=!0;let t=w(e);l(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(T(e))}}l(!r)},i=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||O(e[0]);let a=1,s=0,c=0;for(let t=0;t<e.length;t++){let u=e[t];if(l(u!=null),Array.isArray(u)){let e=i(u,!1,n);if(s){let t=typeof c,n=typeof e;t===n?l(c<e,`descent keys are not in order`):l(t===`number`&&n===`string`)}c=e,s++,a=3}else typeof u==`object`?(l(a===1,`Prev not scalar - instead ${a}`),r(u),a=2):(l(a!==3),O(u),l(o.isValidPathItem(u),`Invalid path key`),a=1)}return l(s!==1,`Operation makes multiple descents. Remove some []`),l(a===2||a===3),e[0]};i(e,!0,!1),l(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)l(t.has(e)),l(n.has(e))}function A(e){let t=0,n=[],r=o.writeCursor();return r.mergeTree(e,(e,r)=>{let i=w(e);if(i){let t=T(e);E(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]??(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function j(e,t){if(c.quiet=!u,k(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},s=0,c=o,u=`root`;function d(){for(;s<a;s++){let e=r[s];typeof e!=`object`&&(l(v(c,u)),c=c[u]=p(c[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(d(),i=c[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(d(),i=_(c,u,t.i)):(d(),i=_(c,u,n[t.d]));let e=w(t);if(e)d(),i=c[u]=e.apply(i,T(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=y(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=y(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===y(n,e)?n:t===void 0?g(n,e):(s=e,c=t,(o=p(o=n))[s]=c,o)}else m(e)&&(l(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,s,c;return t}(e,t),t)}function M(e,t){e=e.slice(),k(t);let n=o.readCursor(t),r,i,a=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(a=!1,r=l.p,i=t):a=!0),t>=e.length)break;let u=0,d=o.advancer(n,void 0,(e,t)=>{m(t)&&u++});s.unshift(d);let f=d(c);if(typeof c==`number`&&(e[t]-=u),!f)break}if(s.forEach(e=>e.end()),a)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(i))}for(;t<e.length;t++){let r=e[t],i=d(n),a=w(i);if(a){let n=T(i);a.transformPosition&&(e[t]=a.transformPosition(e[t],n));break}let s=0,c=o.advancer(n,(e,t)=>h(t)?~(e-s):e-s,(e,t)=>{h(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function N(e,t){if(k(e),k(t),e==null)return t;if(t==null)return e;let n=0,r=o.readCursor(e),i=o.readCursor(t),a=o.writeCursor(),s=[],c=[],u=[],f=[],p=[],g=[],_=/* @__PURE__ */ new Set;r.traverse(null,e=>{e.p!=null&&(u[e.p]=r.clone())}),i.traverse(null,e=>{e.d!=null&&(f[e.d]=i.clone())});let v=o.writeCursor();return function e(t,r,i,a,v,y,b,x){l(r||i);let S=d(r),C=d(i),D=!!C&&C.r!==void 0,O=!!S&&S.i!==void 0,k=S?S.d:null,A=C?C.p:null,j=(y||D)&&A==null;if(A!=null)a=f[A],b=c[A]=new o.WriteCursor;else if(C&&C.r!==void 0)a=null;else{let e=d(a);e&&e.d!=null&&(a=null)}let M=d(a);if(k!=null){if(t=u[k],x=s[k]=new o.WriteCursor,j)y&&!D&&x.write(`r`,!0);else{let e=p[k]=n++;b.write(`d`,e)}}else if(S&&S.i!==void 0)t=null;else{let e=d(t);e&&e.p!=null&&(t=null)}let N;O?(l(v===void 0),N=S.i):N=v;let P=(A==null?!O||y||D:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||O)){let e=k==null?n++:p[k];g[A]=e,x.write(`p`,e)}}else D&&(O||v!==void 0||(C.r,x.write(`r`,C.r)));let F=j?null:w(S),I=w(M);if((F||I)&&(F&&F.name,I&&I.name),F&&I){l(F===I);let e=T(S),t=T(M),n=F.compose(e,t);E(b,F,n),_.add(M)}else F?E(b,F,T(S)):I&&(E(b,I,T(M)),_.add(M));let L=typeof N==`object`&&!!N,ee=!1,R=0,te=0,ne=0,re=0,ie=0,z=o.advancer(a,(e,t)=>h(t)?re-e-1:e-re,(e,t)=>{h(t)&&re++}),ae=o.advancer(t,(e,t)=>m(t)?R-e-1:e-R,(e,t)=>{m(t)&&R++});if(o.eachChildOf(r,i,(t,n,r)=>{let i,a,o=t,s=t,c=t;if(typeof t==`number`){let e=t+ne;a=z(e),s=e+re;let u=t+te;i=ae(u),h(d(a))&&(i=null),o=u+R,c=t+ie,l(o>=0,`p1PickKey is negative`),l(s>=0,`p2DropKey is negative`);let f=h(d(n)),p=m(d(r));(f||p&&!j)&&ie--,f&&te--,p&&ne--}else i=ae(t),a=z(t);x.descend(o),b.descend(s);let u=L&&!h(d(n))?N[c]:void 0,f=e(i,n,r,a,u,j,b,x);var p,g,_;L&&!j?u!==f&&(ee||=(N=Array.isArray(N)?N.slice():Object.assign({},N),!0),p=N,_=f,typeof(g=c)==`number`?(l(Array.isArray(p)),l(g<p.length)):(l(!Array.isArray(p)),l(p[g]!==void 0)),_===void 0?typeof g==`number`?p.splice(g,1):delete p[g]:p[g]=_):l(f===void 0),b.ascend(),x.ascend()}),ae.end(),z.end(),P!=null)P.i=N;else if(!y&&!D&&A==null)return N}(r,r.clone(),i,i.clone(),void 0,!1,a,v),a.reset(),a.mergeTree(v.get()),a.reset(),a.get(),s.map(e=>e.get()),c.map(e=>e.get()),r.traverse(a,(e,t)=>{let n=e.p;if(n!=null){let e=p[n];e!=null&&t.write(`p`,e);let r=s[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),a.reset(),a.get(),i.traverse(a,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=c[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=w(e);r&&!_.has(e)&&E(t,r,T(e))}),a.get()}function P(e){if(e==null)return null;let t=new o.ReadCursor(e),n=new o.WriteCursor,r,i=[],a=[];return function e(t,n,a){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),i[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),a=void 0),o.i!==void 0&&(a=s=o.i);let e=w(o);e&&(a===void 0?(r||=/* @__PURE__ */ new Set,r.add(o)):(T(o),a=e.apply(a,T(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let i=typeof r==`number`?r-l:r,o=y(a,i);h(t.getComponent())&&l++;let s=e(t,n,o);if(a!==void 0&&s!==void 0){if(c||(c=!0,a=p(a)),!v(a,i))throw Error(`Cannot modify child - invalid operation`);a[i]=s}n.ascend()}if(s===void 0)return c?a:void 0;n.write(`r`,a)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=i[e],s=a[e]=o.writeCursor()),r.has(c)){let e=w(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);E(s,e,e.invert(T(c)))}}let l=0,u=0,d=o.advancer(t,(e,t)=>m(t)?l-e-1:e-l,(e,t)=>{m(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),h(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),a.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=a[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let F=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?F(e,t):t(e)));function I(e,t){if(e==null||!F(e,e=>{var t;return e.r!==void 0||((t=w(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new o.ReadCursor(e),r=new o.WriteCursor,i=!1,s=[],c=[],u=(e,t,n)=>{let r=e.getComponent(),o=!1;if(r){r.d!=null&&t.write(`d`,r.d),r.i!==void 0&&t.write(`i`,r.i);let a=r.p;if(a!=null&&(s[a]=e.clone(),l(n!==void 0,`Operation picks up at an invalid key`),c[a]=n,t.write(`p`,r.p)),r.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let o=w(r);o&&(o.makeInvertible?i=!0:E(t,o,T(r),!0))}let d=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-d:r,a=y(n,i),s=u(e,t,a);a!==s&&(o||(o=!0,n=p(n)),s===void 0?(n=g(n,i),typeof r==`number`&&d++):n[i]=s),t.ascend()}return r&&(r.r===void 0?r.p!=null&&(n=void 0):(t.write(`r`,a.default(n)),n=void 0)),n};return u(n,r,t),r.get(),i&&(r.reset(),function e(t,n,r,i,a){let l=n.getComponent();if(l){l.i===void 0?l.d!=null&&(i=c[l.d],t=s[l.d],a=!1,l.d):(i=l.i,a=!0);let e=w(l);if(e&&e.makeInvertible){let t=T(l);E(r,e,e.makeInvertible(t,i),!0)}}let u=0,d=0,f=o.advancer(t,(e,t)=>m(t)?u-e-1:e-u,(e,t)=>{m(t)&&u++});for(let t of n)if(typeof t==`number`){let o=t-d,s=f(o),c=o+u,l=y(i,a?o:c);r.descend(t),e(s,n,r,l,a),h(n.getComponent())&&d++,r.ascend()}else{let o=y(i,t);r.descend(t),e(f(t),n,r,o,a),r.ascend()}f.end()}(n.clone(),n,r,t,!1)),r.get()}function L(e,t){return P(I(e,t))}let ee=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=ee(e))}return t};function R(t,n,r){l(r===`left`||r===`right`,`Direction must be left or right`);let f=r===`left`?0:1;if(c.quiet=!u,c.prefix=0,n==null)return{ok:!0,result:t};k(t),k(n);let p=null,g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],D=[],O=[],A=[],j=[],M=[],N=[],P=[],F=0,I=o.readCursor(t),L=o.readCursor(n),R=o.writeCursor();if(function e(t,n=null,r){let i=d(n);i&&(i.r===void 0?i.p!=null&&(r=null,x[i.p]=t.clone()):r=n.clone());let a=t.getComponent(),s;a&&(s=a.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(O[s]=!0,D[s]=r),i&&i.p!=null&&(N[s]=i.p));let c=o.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(L,I,null),function t(n,r,i,a,c){let l=i.getComponent(),u,h=!1;l&&((u=l.d)==null?l.i!==void 0&&(n=r=null,h=!0,c&&p==null&&(p={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(i.getPath(),l.i)})):(y[u]=i.clone(),a!=null&&(P[a]??(P[a]=[]),P[a].push(u)),O[u],n=b[u]||null,r=v[u]||null,O[u]?(c&&(A[u]=!0),c=D[u]||null):!c||f!==1&&N[u]!=null||(p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),i.getPath())}),h=!0));let g=d(n);g&&(g.r===void 0?g.p!=null&&(g.p,a=g.p,c=null):c=n.clone());let _=w(l);_&&c&&p==null&&(p={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(i.getPath(),_,T(l),!0)});let x=0,S=0,C=o.advancer(r,(e,t)=>m(t)?x-e-1:e-x,(e,t)=>{m(t)&&x++}),E=o.advancer(n);for(let e of i)if(typeof e==`number`){let n=e-S,r=C(n);S+=+t(E(n+x),r,i,a,c)}else{let n=C(e);t(E(e),n,i,a,c)}return C.end(),E.end(),h}(I,L,L.clone(),null,null),y.map(e=>e&&e.get()),p)return{ok:!1,conflict:p};A.map(e=>!!e);let te=[],ne=null;(function e(t,n,r,i,a){let s=!1,c=d(n);if(m(c)){let e=c.p;e==null?(r=null,a=n.clone()):(r=y[e],i=j[e]=o.writeCursor(),s=!0,a=null)}else h(d(r))&&(r=null);let u=t.getComponent();if(u){let e=u.p;e==null?u.r!==void 0&&(a||i.write(`r`,!0),(a||s)&&(ne??=/* @__PURE__ */ new Set,ne.add(u))):(a&&(C[e]=a),te[e]=a||f===1&&s?null:i.getComponent(),g[e]=t.clone(),r&&(S[e]=r.clone()))}let p=0,_=0,v=o.advancer(n,void 0,(e,t)=>{m(t)&&p++}),b=o.advancer(r,(e,t)=>h(t)?~(e-_):e-_,(e,t)=>{h(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),o=b(n);i.descend(n),e(t,r,o,i,a),i.ascend()}else{let r=v(n),o=n-p,s=m(d(r))?null:b(o),c=o+_;l(c>=0),i.descend(c),e(t,r,s,i,a),i.ascend()}v.end(),b.end()})(I,L,L.clone(),R,null),R.reset();let re=[];if(function t(n,c,u,b,D,k){l(c);let A=c.getComponent(),j=d(b),P=!1,I=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(h(A)){let t=A.d;t!=null&&(_[t]=c.clone());let r=t==null?null:te[t],o=!1;if(A.i!==void 0||t!=null&&r){let n;j&&(j.i!==void 0||(n=j.d)!=null&&!O[n])&&(o=n==null?i.default(j.i,A.i):t!=null&&t===N[n],o||n!=null&&f!==1&&N[n]!=null||(p??={type:s.ConflictType.DROP_COLLISION,op1:I(t==null?null:g[t],c,A),op2:I(n==null?null:v[n],b,j)})),o||(k?p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(k.getPath())}:(t==null?D.write(`i`,a.default(A.i)):(re[F]=t,D.write(`d`,r.p=F++)),P=!0))}else if(t!=null&&!r){let e=C[t];e&&(k=e.clone())}t==null?A.i!==void 0&&(n=u=null,o||(b=null)):(n=g[t],u=x[t],b=S[t])}else m(d(n))&&(n=u=b=null);let L=d(n),ee=d(u);if(m(ee)){let e=ee.p;ee.r!==void 0&&(!L||L.r===void 0)||O[e]?(b=null,k=u.clone()):e!=null&&(b=y[e],f!==1&&N[e]!=null||((D=M[e])||(D=M[e]=o.writeCursor()),D.reset(),k=null))}else!h(A)&&h(j)&&(b=null);j=b==null?null:b.getComponent();let R=w(A);if(R){let t=T(A);if(k)p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),R,t,!0),op2:e.removeOp(k.getPath())};else{let e=w(j),n;if(e){if(R!==e)throw Error(`Transforming incompatible types`);let i=T(j);n=R.transform(t,i,r)}else n=a.default(t);E(D,R,n)}}let ie=0,z=0,ae=0,oe=0,se=0,ce=0,le=n!=null&&n.descendFirst(),ue=le,de=o.advancer(u,void 0,(e,t)=>{m(t)&&ae++}),fe=b!=null&&b.descendFirst(),pe=fe;for(let e of c)if(typeof e==`number`){let r,i=h(c.getComponent()),a=e-z;{let e;for(;le&&typeof(e=n.getKey())==`number`;){e+=ie;let t=n.getComponent(),r=m(t);if(e>a||e===a&&(!r||f===0&&i))break;if(r){ie--;let e=t.p;te[e],N.includes(e),t.d,d(M[t.d]),m(d(M[t.d])),(t.r===void 0||ne&&ne.has(t))&&(e==null||!te[e]||f!==1&&N.includes(e))||se--}le=n.nextSibling()}r=le&&e===a?n:null}let o=a-ie,s=de(o),u=o-ae,p=null;{let e,t;for(;fe&&typeof(e=b.getKey())==`number`;){t=e-oe;let n=b.getComponent(),r=h(n);if(t>u)break;if(t===u){if(!r){p=b;break}{if(f===0&&i){p=b;break}let e=s&&m(s.getComponent());if(f===0&&e)break}}if(r){let e=n.d;O[e],N[e],n.i===void 0&&(O[e]||N[e]!=null&&f!==1)?(O[e]||N[e]!=null&&f===0)&&(oe++,ce--):oe++}fe=b.nextSibling()}}let g=u+oe+se+ce;l(g>=0,`trying to descend to a negative index`),D.descend(g),i&&(r=s=p=null,z++),t(r,c,s,p,D,k)&&ce++,D.ascend()}else{let r;for(;le&&(r=n.getKey(),typeof r!=`string`||!(r>e||r===e));)le=n.nextSibling();let i=le&&r===e?n:null,a=de(e),o;for(;fe&&(o=b.getKey(),typeof o!=`string`||!(o>e||o===e));)fe=b.nextSibling();let s=fe&&o===e?b:null;D.descend(e),t(i,c,a,s,D,k),D.ascend()}return de.end(),ue&&n.ascend(),pe&&b.ascend(),P}(I,I.clone(),L,L.clone(),R,null),p)return{ok:!1,conflict:p};R.reset();let ie=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(O.length||j.length)&&(ie(L,R,(e,t,n)=>{O[e]&&!A[e]&&n.write(`r`,!0),j[e]&&n.mergeTree(j[e].get())}),R.reset());let z=[],ae=[];if((M.length||O.length)&&!p){let e=o.readCursor(ee(R.get()));if(ie(e,null,(e,t)=>{z[e]=t.clone()}),M.forEach(e=>{e&&ie(o.readCursor(e.get()),null,(e,t)=>{z[e]=t.clone()})}),function e(t,n,r,i,a,s){c.prefix++;let l=d(n);if(l&&m(l)){if(l.p!=null){a=l;let e=l.p;z[e].getPath(),r=z[e],i=ae[e]=o.writeCursor()}else l.r!==void 0&&(r=null,s=!0)}else h(d(r))&&(r=null);let u=t.getComponent();if(u){let e;if((e=u.d)!=null){let t=M[e];t&&(t.get(),i.mergeTree(t.get()),r=o.readCursor(t.get()))}}let f=0,p=0,g=o.advancer(n,void 0,(e,t)=>{m(t)&&f--}),_=o.advancer(r,(e,t)=>h(t)?-(e-p)-1:e-p,(e,t)=>{h(t)&&p++});for(let n of t)if(typeof n==`number`){let r=g(n),o=n+f,c=_(o),l=o+p;i.descend(l),e(t,r,c,i,a,s),i.ascend()}else i.descend(n),e(t,g(n),_(n),i,a,s),i.ascend();g.end(),_.end()}(L,e,e.clone(),R,null,!1),R.reset(),p)return{ok:!1,conflict:p};if(R.get(),ae.length){let e=ae.map(e=>e?e.get():null);if(ie(o.readCursor(ee(R.get())),R,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=o.writeCursor(),n=o.writeCursor(),r=0,i=0;e.forEach(e=>{e!=null&&ie(o.readCursor(e),null,e=>{let a=re[e];t.writeMove(g[a].getPath(),_[a].getPath(),r++);let o=P[a];o&&o.forEach(e=>{O[e]||f!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),i++)})})}),p={type:s.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return p?{ok:!1,conflict:p}:{ok:!0,result:R.get()}}let te=e=>{let t=/* @__PURE__ */ Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function ne(e,t,n){let r=R(e,t,n);if(r.ok)return r.result;te(r.conflict)}let re=e=>{let t=o.writeCursor();return o.readCursor(e).traverse(t,(e,t)=>{(h(e)||w(e))&&t.write(`r`,!0)}),t.get()},ie=(e,t)=>{let{type:n,op1:r,op2:i}=e;switch(n){case s.ConflictType.DROP_COLLISION:return t===`left`?[null,re(i)]:[re(r),null];case s.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return o.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,re(i)]:[re(r),null];case s.ConflictType.BLACKHOLE:return[re(r),re(i)];default:throw Error(`Unrecognised conflict: `+n)}};function z(e,t,n,r){let i=null;for(;;){let a=R(t,n,r);if(a.ok)return N(i,a.result);{let{conflict:o}=a;e(o)||te(o);let[s,c]=ie(o,r);t=N(A(t),s),n=N(A(n),c),i=N(i,c)}}}})),ig=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(rg(),e);var a=Zh();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return a.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return a.WriteCursor}});var o=Qh();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return o.ConflictType}})})))());let ag=`__textXPreserveParagraphIds`,og=/* @__PURE__ */ function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});function sg(e){return{startOffset:e.startIndex,endOffset:e.endIndex+1}}function cg(e){return{startOffset:e.startIndex,endOffset:e.endIndex}}function lg(e){return cg(e)}function ug(e){return sg(e)}function dg(e){return sg(e)}function fg(e){return sg(e)}function pg(e){return{startOffset:e.startIndex,endOffset:e.startIndex+1}}function mg(e,t){return Cg(e,t,`\x1B`,``)}function hg(e,t){return Cg(e,t,``,``)}function gg(e,t){return e.startOffset<=t&&t<e.endOffset}function _g(e,t){return e.startOffset<t&&t<e.endOffset}function vg(e,t){return Math.max(e.startOffset,t.startOffset)<Math.min(e.endOffset,t.endOffset)}function yg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>=t?{...e,endIndex:e.endIndex+n}:e}function bg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>t?{...e,endIndex:e.endIndex+n}:e}function xg(e,t,n){if(n<=0||e.endIndex<t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>=r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t-1;return s>=o?{...e,startIndex:o,endIndex:s}:null}function Sg(e,t,n){if(n<=0||e.endIndex<=t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t;return s>o?{...e,startIndex:o,endIndex:s}:null}function Cg(e,t,n,r){if(!Number.isInteger(t)||t<0||e[t]!==n)return null;let i=0;for(let a=t;a<e.length;a++){let o=e[a];if(o===n)i++;else if(o===r&&(i--,i===0))return{startOffset:t,endOffset:a+1}}return null}let wg=`__textXRestoreParagraphIds`;function Tg(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&z.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();ku(r,o)&&z.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function Eg(e,t,n,r){let{textRuns:i}=e;if(i==null)return;let a=[],o=i.length,s=!1,c=t.textRuns??[];if(c.length)for(let e of c)e.st+=r,e.ed+=r;for(let e=0;e<o;e++){let t=i[e],{st:o,ed:l}=t;if(l<=r)a.push(t);else if(r>o&&r<l){s=!0;let e={...t,ed:r};a.push(e),c.length&&a.push(...c);let i={...t,st:r+n,ed:l+n};a.push(i)}else t.st+=n,t.ed+=n,s||(s=!0,a.push(...c)),a.push(t)}s||(s=!0,a.push(...c)),e.textRuns=Tg(a)}function Dg(e,t,n,r,i=!1,a=e.dataStream){var o;if(!e.paragraphs&&!((o=t.paragraphs)!=null&&o.length))return;e.paragraphs??=[];let{paragraphs:s}=e,{paragraphs:c}=t;i||Og(s,c,r,{freshenSplitParagraph:!0,preserveExplicitSplitParagraphIds:!!t[wg],preserveExplicitParagraphIds:!!t[ag],dataStream:a});let l=[],u=-1;for(let e=0,t=s.length;e<t;e++){let t=s[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n),u===-1&&i>=r&&(u=e),l.push(t.startIndex)}let d=-1;if(c){for(let e=0,t=c.length;e<t;e++){let t=c[e];t.startIndex+=r;let n=t.startIndex;d=l.indexOf(n)}d!==-1&&s.splice(d,1),s.push(...c),s.sort(ff(`startIndex`))}}function Og(e,t,n,r){if(!e||!(t!=null&&t.length))return;let i=Mg(e,n,r.dataStream),a=i?Ng(t):-1,o=i==null?void 0:i.paragraphId,s=a===-1?void 0:t[a].paragraphId,c=(r.preserveExplicitSplitParagraphIds||r.preserveExplicitParagraphIds)&&s!=null&&s!==o,l=kg(e),u=/* @__PURE__ */ new Set;o&&l.delete(o);for(let e of r.reservedParagraphIds??[])l.add(e);let d;if(o&&a!==-1&&!c){let e=t[a];d=s!=null&&s!==o?Ag(e,l,r.preserveMissingParagraphIds??!1):Wh(e,l,!1),r.freshenSplitParagraph&&d.paragraphId&&(i.paragraphId=d.paragraphId)}for(let e=0,n=t.length;e<n;e++){let n=t[e].paragraphId;r.preserveExplicitParagraphIds&&n&&!u.has(n)?(t[e]={...t[e]},u.add(n)):e!==a||o==null||c?t[e]=Ag(t[e],l,r.preserveMissingParagraphIds??!1):t[e]=r.freshenSplitParagraph?Wh({...t[e],paragraphId:o},l):d}for(let e of t)if(e.paragraphId){var f;(f=r.reservedParagraphIds)==null||f.add(e.paragraphId)}}function kg(e){let t=/* @__PURE__ */ new Set;for(let n of e??[])n.paragraphId&&t.add(n.paragraphId);return t}function Ag(e,t,n){return n&&e.paragraphId==null?z.deepClone(e):Wh(e,t)}let jg=/* @__PURE__ */ new Set([`
|
|
5
|
-
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function Mg(e,t,n){let r=[...e].sort((e,t)=>e.startIndex-t.startIndex);for(let e=0;e<r.length;e++){let i=r[e],a=e>0?r[e-1].startIndex+1:0;for(;a<i.startIndex;){let e=n==null?void 0:n[a];if(!e||!jg.has(e))break;a++}if(t>a&&t<i.startIndex)return i}}function Ng(e){let t=0;for(let n=1;n<e.length;n++)e[n].startIndex<e[t].startIndex&&(t=n);return t}function Pg(e,t,n,r){var i;if(!e.sectionBreaks&&!((i=t.sectionBreaks)!=null&&i.length))return;e.sectionBreaks??=[];let{sectionBreaks:a}=e,o=t.sectionBreaks;Fg(a,o);for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Fg(e,t,n=/* @__PURE__ */ new Set){if(!(t!=null&&t.length))return;let r=new Set((e==null?void 0:e.map(e=>e.sectionId))??[]);for(let e of n)r.add(e);for(let e=0;e<t.length;e++)t[e]=bm(t[e],r),n.add(t[e].sectionId)}function Ig(e,t,n,r,i){if(e[i]==null&&t[i]==null)return;let a=e[i]??[];for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}let o=t[i];if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}a.length&&!e[i]&&(e[i]=a)}function Lg(e,t,n,r){Ig(e,t,n,r,`customBlocks`)}function Rg(e,t,n,r){Ig(e,t,n,r,`docxRawCustomBlocks`)}function zg(e,t,n,r){if(e.docxRawBlocks==null&&t.docxRawBlocks==null)return;let i=e.docxRawBlocks??[];i.forEach(e=>{e.startIndex>=r&&(e.startIndex+=n)}),i.push(...(t.docxRawBlocks??[]).map(e=>({...e,startIndex:e.startIndex+r}))),i.sort(ff(`startIndex`)),e.docxRawBlocks=i}function Bg(e){let t=[...e].sort((e,t)=>e.start-t.start||e.end-t.end),n=[];for(let e of t){let t=n[n.length-1];t&&e.start<=t.end?t.end=Math.max(t.end,e.end):e.end>e.start&&n.push({...e})}return n}function Vg(e,t,n,r){if(e.docxExportExcludedRanges==null&&t.docxExportExcludedRanges==null)return;let i=(e.docxExportExcludedRanges??[]).map(e=>{let t=bg({startIndex:e.start,endIndex:e.end},r,n);return{start:t.startIndex,end:t.endIndex}}),a=(t.docxExportExcludedRanges??[]).map(e=>({start:e.start+r,end:e.end+r}));e.docxExportExcludedRanges=Bg([...i,...a])}function Hg(e,t,n,r){var i;if(!e.tables&&!((i=t.tables)!=null&&i.length))return;e.tables||=[];let{tables:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,bg(t,r,n))}let o=t.tables;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Ug(e,t,n,r){var i;if(!e.columnGroups&&!((i=t.columnGroups)!=null&&i.length))return;e.columnGroups||=[];let{columnGroups:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,yg(t,r,n))}let o=t.columnGroups;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}function Wg(e,t,n,r){var i;if(!e.blockRanges&&!((i=t.blockRanges)!=null&&i.length))return;e.blockRanges||=[];let{blockRanges:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,yg(t,r,n))}let o=t.blockRanges;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(ff(`startIndex`))}}let Gg=e=>e.split(`$`)[0];function Kg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n=/* @__PURE__ */ new Map;for(let r of e){let e={...r,rangeId:Gg(r.rangeId)},i=n.get(e.rangeId);i&&e.rangeType===i.rangeType&&Rp(i.properties,e.properties)&&i.endIndex+1>=e.startIndex?i.endIndex=Math.max(i.endIndex,e.endIndex):(t.push(e),n.set(e.rangeId,e))}let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function qg(e,t){let n=e.filter(e=>e.rangeType!==1&&e.rangeType!==2&&e.rangeType!==3&&e.startIndex<t&&e.endIndex>=t);for(let r of n){let n=e.indexOf(r);e.splice(n,1,{...r,endIndex:t-1,properties:{...r.properties}},{...r,startIndex:t,properties:{...r.properties}})}}function Jg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function Yg(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function Xg(e,t,n,r){e.customRanges||=[];let{customRanges:i}=e;qg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;(t.rangeType===1||t.rangeType===2||t.rangeType===3)&&a<r&&t.endIndex>=r?t.endIndex+=n:a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e],o=n.rangeType===2?i.find(e=>e.rangeType===2&&e.rangeId===n.rangeId):void 0;o?(o.startIndex=Math.min(o.startIndex,r+n.startIndex),o.endIndex=Math.max(o.endIndex,r+n.endIndex),o.properties=z.deepClone(n.properties),o.wholeEntity=n.wholeEntity,i.splice(i.indexOf(o),0,...a.splice(0))):(n.startIndex+=r,n.endIndex+=r,a.push(n))}i.push(...a)}e.customRanges=Kg(i)}function Zg(e,t,n,r){e.customDecorations||=[];let{customDecorations:i}=e;Yg(i,r);for(let e=0,t=i.length;e<t;e++){let t=i[e],{startIndex:a}=t;a>=r&&(t.startIndex+=n,t.endIndex+=n)}let a=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,a.push(n)}i.push(...a)}e.customDecorations=Jg(i)}function Qg(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;i<=c&&a>=l?o.push({...s,st:c-i,ed:l-i}):(c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t),n.push(s))}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function $g(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;d>=i&&d<a?(o.push({...u,startIndex:d-n}),c=!0):(d>=a&&(u.startIndex-=t),l.push(u),s==null&&c&&(s=u))}e.paragraphs=l}return o}function e_(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;l>=i&&l<=a?o.push({...c,startIndex:l-n}):(l>a&&(c.startIndex-=t),s.push(c))}e.sectionBreaks=s}return o}function t_(e,t,n,r){let i=e[r];if(i==null)return;let a=n,o=n+t-1,s=[],c=[];for(let e=0,r=i.length;e<r;e++){let r=i[e],{startIndex:l}=r;l>=a&&l<=o?s.push({...r,startIndex:l-n}):(l>o&&(r.startIndex-=t),c.push(r))}return e[r]=c,i.length&&!e[r]&&(e[r]=i),s}function n_(e,t,n){return e.customBlocks??=[],t_(e,t,n,`customBlocks`)}function r_(e,t,n){return t_(e,t,n,`docxRawCustomBlocks`)}function i_(e,t,n){if(e.docxRawBlocks==null)return;let r=n+t,i=[],a=[];for(let o of e.docxRawBlocks)o.startIndex>=n&&o.startIndex<r?i.push({...o,startIndex:o.startIndex-n}):a.push(o.startIndex>=r?{...o,startIndex:o.startIndex-t}:o);return e.docxRawBlocks=a,i}function a_(e,t,n){if(e.docxExportExcludedRanges==null)return;let r=n+t,i=[],a=[];for(let o of e.docxExportExcludedRanges){let e=Math.max(o.start,n),s=Math.min(o.end,r);s>e&&i.push({start:e-n,end:s-n});let c=Sg({startIndex:o.start,endIndex:o.end},n,t);c&&a.push({start:c.startIndex,end:c.endIndex})}return e.docxExportExcludedRanges=Bg(a),i}function o_(e,t,n){let{tables:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=Sg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n})}e.tables=a}return i}function s_(e,t,n){let{columnGroups:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=xg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n})}e.columnGroups=a}return i}function c_(e,t,n){let{customRanges:r}=e,i=[];if(r){let a=new Map(r.filter(e=>e.rangeType===2).map(e=>[e,e.endIndex-e.startIndex])),o=/* @__PURE__ */ new Map,s=[];for(let e=0,a=r.length;e<a;e++){let a=r[e],c=xg(a,n,t);if(!c)i.push(a);else{if(Object.assign(a,c),a.rangeType===2){let e=`${a.startIndex}:${a.endIndex}`,t=o.get(e)??[];t.push(s.length),o.set(e,t)}s.push(a)}}for(let e of o.values()){if(e.length<2)continue;let t=e.map(e=>s[e]).sort((e,t)=>a.get(e)-a.get(t));e.forEach((e,n)=>{s[e]=t[n]})}e.customRanges=Kg(s)}return i}function l_(e,t,n){let{blockRanges:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=xg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push(o)}e.blockRanges=a}return i}function u_(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o)s.push(c);else{if(Math.max(a,l)<=Math.min(o,u)){let e=nd(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}}e.customDecorations=n}return s}let d_=/* @__PURE__ */ function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),f_=/* @__PURE__ */ function(e){return e.BULLET_LIST=`BULLET_LIST`,e.BULLET_LIST_1=`BULLET_LIST_1`,e.BULLET_LIST_2=`BULLET_LIST_2`,e.BULLET_LIST_3=`BULLET_LIST_3`,e.BULLET_LIST_4=`BULLET_LIST_4`,e.BULLET_LIST_5=`BULLET_LIST_5`,e.ORDER_LIST=`ORDER_LIST`,e.ORDER_LIST_1=`ORDER_LIST_1`,e.ORDER_LIST_2=`ORDER_LIST_2`,e.ORDER_LIST_3=`ORDER_LIST_3`,e.ORDER_LIST_4=`ORDER_LIST_4`,e.ORDER_LIST_5=`ORDER_LIST_5`,e.ORDER_LIST_QUICK_2=`ORDER_LIST_QUICK_2`,e.ORDER_LIST_QUICK_3=`ORDER_LIST_QUICK_3`,e.ORDER_LIST_QUICK_4=`ORDER_LIST_QUICK_4`,e.ORDER_LIST_QUICK_5=`ORDER_LIST_QUICK_5`,e.ORDER_LIST_QUICK_6=`ORDER_LIST_QUICK_6`,e.CHECK_LIST=`CHECK_LIST`,e.CHECK_LIST_CHECKED=`CHECK_LIST_CHECKED`,e}({}),p_={"a)":{glyphFormat:`%1)`,glyphType:2},"1.":{glyphFormat:`%1.`,glyphType:2},"a.":{glyphFormat:`%1.`,glyphType:5},"A.":{glyphFormat:`%1.`,glyphType:4},"i.":{glyphFormat:`%1.`,glyphType:7},"I.":{glyphFormat:`%1.`,glyphType:4}},m_=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),h_=e=>e.map((e,t)=>({...e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),g_=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(r+1)},textStyle:t}})),__={BULLET_LIST:{listType:`BULLET_LIST`,nestingLevel:m_([`●`,`○`,`■`])},BULLET_LIST_1:{listType:`BULLET_LIST`,nestingLevel:m_([`❖`,`➢`,`■`])},BULLET_LIST_2:{listType:`BULLET_LIST`,nestingLevel:m_([`✔`,`●`,`◆`])},BULLET_LIST_3:{listType:`BULLET_LIST`,nestingLevel:m_([`■`,`◆`,`○`])},BULLET_LIST_4:{listType:`BULLET_LIST`,nestingLevel:m_([`✦`,`○`,`■`])},BULLET_LIST_5:{listType:`BULLET_LIST`,nestingLevel:m_([`➢`,`○`,`◆`])},ORDER_LIST:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:2},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:2},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:2},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_1:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1)`,glyphType:2},{glyphFormat:`%2)`,glyphType:5},{glyphFormat:`%3)`,glyphType:7},{glyphFormat:`%4)`,glyphType:2},{glyphFormat:`%5)`,glyphType:5},{glyphFormat:`%6)`,glyphType:7},{glyphFormat:`%7)`,glyphType:2},{glyphFormat:`%8)`,glyphType:5},{glyphFormat:`%9)`,glyphType:7}])},ORDER_LIST_2:{listType:`ORDER_LIST`,nestingLevel:h_([`%1.`,`%1.%2.`,`%1.%2.%3.`,`%1.%2.%3.%4.`,`%1.%2.%3.%4.%5.`,`%1.%2.%3.%4.%5.%6.`,`%1.%2.%3.%4.%5.%6.%7.`].map(e=>({glyphFormat:e,glyphType:2})))},ORDER_LIST_3:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_4:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:2},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:2},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:2},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_5:{listType:`ORDER_LIST`,nestingLevel:h_([{glyphFormat:`%1.`,glyphType:3},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:3},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:3},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},CHECK_LIST:{listType:`CHECK_LIST`,nestingLevel:g_(`☐`)},CHECK_LIST_CHECKED:{listType:`CHECK_LIST_CHECKED`,nestingLevel:g_(`☑`,{st:{s:1}})}},v_=e=>{let{glyphFormat:t,glyphType:n}=e,r=z.deepClone(__.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},y_={ORDER_LIST_QUICK_2:v_(p_[`a)`]),ORDER_LIST_QUICK_3:v_(p_[`a.`]),ORDER_LIST_QUICK_4:v_(p_[`i.`]),ORDER_LIST_QUICK_6:v_(p_[`I.`])};Object.assign(__,y_);let b_={"1.":`ORDER_LIST`,"a)":`ORDER_LIST_QUICK_2`,"a.":`ORDER_LIST_QUICK_3`,"i.":`ORDER_LIST_QUICK_4`,"A.":`ORDER_LIST_3`,"I.":`ORDER_LIST_QUICK_6`,"01.":`ORDER_LIST_5`,"*":`BULLET_LIST`};function x_(e,t,n,r,i){return{dataStream:``,textRuns:S_(e,t,n,r,i),paragraphs:w_(e,t,n,r,i),sectionBreaks:T_(e,t,n,r,i),customBlocks:E_(e,t,n,r,i),docxRawCustomBlocks:D_(e,t,n,r,i),tables:O_(e,t,n,r,i),columnGroups:k_(e,t,n,r,i),blockRanges:A_(e,t,n,r,i),customRanges:j_(e,t,n,r,i),customDecorations:M_(e,t,n,r,i)}}function S_(e,t,n,r,i){let{textRuns:a}=e,{textRuns:o}=t;if(a==null||o==null)return;let s=Qg(e,n,r);return i!==1&&(t.textRuns=C_(o,s,i)),Eg(e,t,n,r),s}function C_(e,t,n){if(t.length===0)return e;e=z.deepClone(e),t=z.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===0?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Tg(r)}function w_(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=$g(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,paragraphId:r,paragraphStyle:a,bullet:o}=t,c=[];for(let e of s){let{startIndex:s,paragraphId:l,paragraphStyle:u,bullet:d}=e,f,p,m=i===0?{...e,...t}:{...t,...e};if(i===0?(f={...u,...a},p={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...d,...o}):(f={...a,...u},p={listId:``,listType:`BULLET_LIST`,nestingLevel:0,textStyle:{},...o,...d}),n===s){c.push({...m,startIndex:n,paragraphId:r??l,paragraphStyle:f,bullet:d==null&&o==null?void 0:p});break}}e.push(...c),c=[]}t.paragraphs=e}else for(let e of o){let t=s.find(t=>t.startIndex===e.startIndex);t&&e.paragraphId==null&&(e.paragraphId=t.paragraphId)}return Dg(e,t,n,r,!0),s}function T_(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=e_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e})}else t.sectionBreaks=o.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e});return Pg(e,t,n,r),s}function E_(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=n_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return Lg(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function D_(e,t,n,r,i){let a=e.docxRawCustomBlocks,o=t.docxRawCustomBlocks;if(a==null||o==null)return;let s=r_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let n=s.find(e=>e.startIndex===t.startIndex);n&&e.push(i===0?{...n,...t}:{...t,...n})}t.docxRawCustomBlocks=e}return Rg(e,t,n,r),a.length&&!e.docxRawCustomBlocks&&(e.docxRawCustomBlocks=a),s}function O_(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=o_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return Hg(e,t,n,r),s}function k_(e,t,n,r,i){let{columnGroups:a}=e,{columnGroups:o}=t;if(a==null||o==null)return;let s=s_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.columnGroups=e}return Ug(e,t,n,r),s}function A_(e,t,n,r,i){let{blockRanges:a}=e,{blockRanges:o}=t;if(a==null||o==null)return;let s=l_(e,n,r);return i!==1&&(t.blockRanges=o.map(e=>{let t=s.find(t=>t.blockId===e.blockId);return t?{...t,...e}:e})),Wg(e,t,n,r),s}function j_(e,t,n,r,i){e.customRanges||=[],qg(e.customRanges,r),qg(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=/* @__PURE__ */ new Map;e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)});let u=[];if(!s)return[];s.forEach(e=>{let{startIndex:t,endIndex:i}=e,a=e.rangeType===2?c.find(t=>t.rangeType===2&&t.rangeId===e.rangeId):void 0;a?(t>0&&(a.startIndex=t+r),i<n-1&&(a.endIndex=i+r),a.properties=z.deepClone(e.properties),a.wholeEntity=e.wholeEntity):c.push({...e,startIndex:t+r,endIndex:i+r})});let d=new Map(s.map((e,t)=>[e.rangeId,t])),f=/* @__PURE__ */ new Map;c.forEach((e,t)=>{if(e.rangeType!==2||!d.has(e.rangeId))return;let n=`${e.startIndex}:${e.endIndex}`,r=f.get(n)??[];r.push(t),f.set(n,r)});for(let e of f.values()){let t=e.map(e=>c[e]).sort((e,t)=>d.get(e.rangeId)-d.get(t.rangeId));e.forEach((e,n)=>{c[e]=t[n]})}return e.customRanges=Kg(c),u}function M_(e,t,n,r,i){e.customDecorations||=[],Yg(e.customDecorations,r),Yg(e.customDecorations,r+n);let a=[],{customDecorations:o}=e,{customDecorations:s=[]}=t;if(i===1){for(let e=0;e<o.length;e++){let t=o[e],{startIndex:i,endIndex:s}=t;i>=r&&s<=r+n-1&&a.push(t)}s.forEach(e=>{let{startIndex:t,endIndex:n}=e;o.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of s){let{id:t}=e;if(e.type===9999){let e=o.filter(e=>e.id===t);e.length&&a.push(...e)}else o.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of a){let{id:t}=e,n=o.findIndex(e=>e.id===t);n!==-1&&o.splice(n,1)}return e.customDecorations=Jg(o),a}function N_(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function P_(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function F_(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function I_(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r??z_(t,n),s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function L_(e,t,n){let r=[],i=z_(t,n);for(let a of e){let e=I_(a,t,n,i);r.push(...e)}return r}let R_=[`\r`,``,``,`\x1B`,``,``];function z_(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!R_.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}let B_=e=>{var t;let{paragraphs:n,segmentId:r,document:i}=e,a=e.listType,o=((t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs)??[],s=n.every(e=>{var t;return((t=e.bullet)==null?void 0:t.listType.indexOf(a))===0}),c=J(6);if(n.length===1){let e=o.indexOf(n[0]),t=o[e-1],r=o[e+1];t&&t.bullet&&t.bullet.listType.indexOf(a)===0?(c=t.bullet.listId,a!==`CHECK_LIST`&&(a=t.bullet.listType)):r&&r.bullet&&r.bullet.listType.indexOf(a)===0&&(c=r.bullet.listId,a!==`CHECK_LIST`&&(a=r.bullet.listType))}let l=new lm;l.reset();let u=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:i}=e;u.push({t:`r`,len:t-l.cursor}),u.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[s?{paragraphId:n,paragraphStyle:r,startIndex:0}:{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{nestingLevel:(i==null?void 0:i.nestingLevel)??0,listType:a,listId:c}}]},coverType:1}),l.moveCursorTo(t+1)}return u},V_=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n);if(!(o!=null&&o.bullet)||o.bullet.listType.indexOf(`CHECK_LIST`)===-1)return!1;let s=new lm;s.reset();let c=new X,{startIndex:l,paragraphStyle:u={}}=o,d=o.bullet.listType===`CHECK_LIST`?`CHECK_LIST_CHECKED`:`CHECK_LIST`;return c.push({t:`r`,len:l-s.cursor}),c.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:u,startIndex:0,bullet:{...o.bullet,listType:d}}]},coverType:1}),s.moveCursorTo(l+1),c},H_=e=>{var t;let{paragraphs:n,listType:r,listId:i,segmentId:a,document:o}=e;if(((t=o.getSelfOrHeaderFooterModel(a))==null||(t=t.getBody())==null?void 0:t.paragraphs)==null)return!1;let s=i??J(6),c=new lm;c.reset();let l=new X;for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:i={},bullet:a}=e;l.push({t:`r`,len:t-c.cursor}),l.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:i,bullet:{nestingLevel:(a==null?void 0:a.nestingLevel)??0,...(a==null?void 0:a.listType)===r&&a.textStyle?{textStyle:a.textStyle}:{},listType:r,listId:s}}]},coverType:1}),c.moveCursorTo(t+1)}return l};function U_(e,t){return t.some(t=>{let n=lg(t);return e.startIndex>n.startOffset&&gg(n,e.startIndex)})}let W_=/* @__PURE__ */ new Set([`
|
|
6
|
-
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function G_(e,t){let n;for(let r of e.paragraphs??[])r.startIndex<t.startIndex&&(!n||r.startIndex>n.startIndex)&&(n=r);let r=n?n.startIndex+1:0;for(;r<t.startIndex&&W_.has(e.dataStream[r]);)r++;return r}function K_(e){let t=/* @__PURE__ */ new Map,n=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex);for(let r=0;r<n.length;r++){let i=n[r],a=r>0?n[r-1].startIndex+1:0;for(;a<i.startIndex&&W_.has(e.dataStream[a]);)a++;t.set(i.startIndex,a)}return t}function q_(e,t){let n=(e.blockRanges??[]).find(e=>{let n=ug(e);return t.startIndex>n.startOffset&&t.startIndex<n.endOffset-1});return n?ug(n).endOffset:t.startIndex+1}let J_=e=>{var t;let{paragraphs:n,document:r,type:i}=e,a=new lm;a.reset();let o=new X,s=r.getSnapshot().lists??{},c=((t=r.getBody())==null?void 0:t.tables)??[],l={...__,...s};for(let e of n){let{startIndex:t,paragraphId:n,paragraphStyle:r={},bullet:s}=e,u=U_(e,c);if(o.push({t:`r`,len:t-a.cursor}),s){let e=l[s.listType].nestingLevel.length-1;u&&(e=Math.min(e,2)),o.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r},bullet:{...s,nestingLevel:Math.max(Math.min(s.nestingLevel+i,e),0)}}]},coverType:1})}else o.push({t:`r`,len:1});a.moveCursorTo(t+1)}return o},Y_=e=>{var t,n;let{textRanges:r,segmentId:i,document:a,style:o,paragraphTextRun:s,cursor:c,deleteLen:l,textX:u}=e,d=a.getSelfOrHeaderFooterModel(i),f=L_(r,(d==null||(t=d.getBody())==null?void 0:t.paragraphs)??[],(d==null||(n=d.getBody())==null?void 0:n.dataStream)??``),p=new lm;c&&p.moveCursorTo(c);let m=u??new X;f.sort((e,t)=>e.startIndex-t.startIndex);let h=Math.max(0,f[0].paragraphStart-1);h>p.cursor&&(m.push({t:`r`,len:h-p.cursor}),p.moveCursorTo(h)),l&&m.push({t:`d`,len:l});for(let e of f){let{startIndex:t,paragraphId:n,paragraphStyle:r={}}=e,i=t-p.cursor;m.push({t:`r`,len:i,...s?{body:{dataStream:``,textRuns:[{ts:s,st:0,ed:i}]},coverType:1}:null}),m.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r,...o}}]},coverType:1}),p.moveCursorTo(t+1)}return m},X_=/* @__PURE__ */ function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function Z_(e,t,n,r,i){return i===1?e>=n&&t<=r:i===2?e<r&&t>n&&t<=r:Math.max(e,n)<Math.min(t,r)}function Q_(e,t,n,r,i){return i===0?{startIndex:Math.max(e,n)-n,endIndex:Math.min(t,r)-n}:{startIndex:e-n,endIndex:t-n}}function $_(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let{st:i,ed:a}=r;if(z.hasIntersectionBetweenTwoRanges(i,a,t,n)){let o=z.deepClone(r);t>=i&&t<=a?e.push({...o,st:t,ed:Math.min(n,a)}):n>=i&&n<=a?e.push({...o,st:Math.max(t,i),ed:n}):e.push(o)}}return Tg(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}if(r)return[{st:0,ed:n-t,ts:{}}]}function ev(e,t,n,r=0){let{tables:i=[]}=e,a=[];for(let e of i){let i=z.deepClone(e),{startIndex:o,endIndex:s}=i;Z_(o,s,t,n,r)&&a.push({...i,...Q_(o,s,t,n,r)})}return a}function tv(e,t,n,r=0){let{blockRanges:i=[]}=e,a=[];for(let e of i){let{startIndex:i,endIndex:o}=e;(r===1?i>=t&&o<n:Z_(i,o,t,n,r))&&a.push({...e,...Q_(i,o,t,n,r)})}return a}function nv(e,t,n,r=0){let{columnGroups:i=[]}=e,a=[];for(let o of i){let i=z.deepClone(o),{startIndex:s,endIndex:c}=i;e.dataStream[s]===``&&Z_(s,c,t,n,r)&&a.push({...i,...Q_(s,c,t,n,r)})}return a}function rv(e,t,n,r=1){let{paragraphs:i=[]}=e,a=[];if(r===1){for(let e of i){let{startIndex:r}=e;r>=t&&r<n&&a.push(z.deepClone(e))}return a.length?a.map(e=>({...e,startIndex:e.startIndex-t})):void 0}let o=[...i].sort((e,t)=>e.startIndex-t.startIndex),s=K_(e);for(let e of o){let r=s.get(e.startIndex)??0,i=e.startIndex;if(i>=t&&i<n||Math.max(r,t)<Math.min(i,n)){let r=z.deepClone(e);r.startIndex=Math.min(Math.max(i,t),n),a.push(r)}}if(a.length)return a.map(e=>({...e,startIndex:e.startIndex-t}))}function iv(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(z.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function av(e,t,n){return sv(e.customBlocks??[],t,n)}function ov(e,t,n){return sv(e.docxRawCustomBlocks??[],t,n)}function sv(e,t,n){let r=[];for(let i of e){let{startIndex:e}=i;e>=t&&e<n&&r.push(z.deepClone(i))}if(r.length)return r.map(e=>({...e,startIndex:e.startIndex-t}))}function cv(e,t,n){return(e.docxRawBlocks??[]).filter(e=>e.startIndex>=t&&e.startIndex<n).map(e=>({...z.deepClone(e),startIndex:e.startIndex-t}))}function lv(e,t,n){return(e.docxExportExcludedRanges??[]).flatMap(e=>{let r=Math.max(e.start,t),i=Math.min(e.end,n);return i>r?[{start:r-t,end:i-t}]:[]})}function uv(e,t,n,r=!0,i=1,a=0){let{dataStream:o}=e,s={dataStream:o.slice(t,n)};e.renderedPageBreaks!=null&&(s.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e>=t&&e<n).map(e=>e-t)),e.__textXPreserveParagraphIds&&(s[ag]=!0),s.textRuns=$_(e,t,n,r);let c=ev(e,t,n,a);c.length&&(s.tables=c);let l=tv(e,t,n,a);l.length&&(s.blockRanges=l);let u=nv(e,t,n,a);u.length&&(s.columnGroups=u),s.paragraphs=rv(e,t,n,i);let d=iv(e,t,n-1);if(d?s.sectionBreaks=d:r&&(s.sectionBreaks=[]),i===1){let i=gv(e,t,n);i?s.customDecorations=i:r&&(s.customDecorations=[])}let{customRanges:f}=hv(e,t,n);return f?s.customRanges=i===0?f.filter(e=>e.rangeType!==1||s.dataStream[e.startIndex]===``&&s.dataStream[e.endIndex]===``):f:r&&(s.customRanges=[]),s.customBlocks=av(e,t,n),e.docxRawCustomBlocks!=null&&(s.docxRawCustomBlocks=ov(e,t,n)??[]),e.docxRawBlocks!=null&&(s.docxRawBlocks=cv(e,t,n)),e.docxExportExcludedRanges!=null&&(s.docxExportExcludedRanges=lv(e,t,n)),s}function dv(e,t,n,r=!0,i=1){return uv(e,t,n,r,i,1)}function fv(e,t,n,r=!0,i=1){return uv(e,t,n,r,i,2)}function pv(e,t,n){var r,i,a,o,s,c,l,u,d,f;e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.map(e=>e+t)),(r=e.textRuns)==null||r.forEach(e=>{e.st+=t,e.ed+=t}),(i=e.paragraphs)==null||i.forEach(e=>{e.startIndex+=t}),(a=e.customBlocks)==null||a.forEach(e=>{e.startIndex+=t}),(o=e.docxRawCustomBlocks)==null||o.forEach(e=>{e.startIndex+=t}),(s=e.docxRawBlocks)==null||s.forEach(e=>{e.startIndex+=t}),(c=e.docxExportExcludedRanges)==null||c.forEach(e=>{e.start+=t,e.end+=t}),(l=e.customRanges)==null||l.forEach(e=>{e.startIndex+=t,e.endIndex+=t}),(u=e.customDecorations)==null||u.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(d=e.tables)==null||d.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(f=e.columnGroups)==null||f.forEach(e=>{e.startIndex+=t,e.endIndex+=n})}function mv(e){let{dataStream:t,textRuns:n,customRanges:r}=e,i=0,a=0;r==null||r.forEach(e=>{e.startIndex<0&&(i=Math.max(i,-e.startIndex)),e.endIndex>t.length-1&&(a=Math.max(a,e.endIndex-t.length+1))});let o=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-i),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+a)),pv(e,i,a),{...e,dataStream:o}}function hv(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function gv(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=z.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function _v(e,t,n){return e==null||t==null?e??t:C_(e,t,n)}function vv(e,t,n){if(e==null||t==null)return e??t;if(t.length===0||e.length===0)return e;if(n===1)return e.map(e=>({...e}));let r=new Map(e.map(e=>[e.rangeId,e]));return[...t.filter(t=>!e.some(e=>t.rangeType===0&&e.rangeType===0&&e.rangeId!==t.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)).map(e=>{let t=r.get(e.rangeId);return t==null?e:(r.delete(e.rangeId),{...e,...t})}),...r.values()]}function yv(e,t,n){return t.length===0||e.length===0||n===1?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function bv(e,t,n=0){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream};e.renderedPageBreaks!=null&&(r.renderedPageBreaks=[...e.renderedPageBreaks]),(e.__textXPreserveParagraphIds||t.__textXPreserveParagraphIds)&&(r[ag]=!0);let{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[],columnGroups:c=[],blockRanges:l=[]}=e,{textRuns:u,paragraphs:d=[],customRanges:f,customDecorations:p=[],columnGroups:m=[],blockRanges:h=[]}=t;r.textRuns=_v(u,i,n),r.customRanges=vv(f,o,n);let g=yv(p,s,n);g.length&&(r.customDecorations=g);let _=[],v=0,y=0;for(;v<a.length&&y<d.length;){let e=a[v],t=d[y],{startIndex:n}=e,{startIndex:r}=t;n===r?(_.push(na(e,t)),v++,y++):n<r?(_.push(z.deepClone(e)),v++):(_.push(z.deepClone(t)),y++)}v<a.length&&_.push(...a.slice(v)),y<d.length&&_.push(...d.slice(y)),_.length&&(r.paragraphs=_);let b=xv(l,h);b.length&&(r.blockRanges=b);let x=Sv(c,m);return x.length&&(r.columnGroups=x),r}function xv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.blockId,z.deepClone(e)]));return t.forEach(e=>n.set(e.blockId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Sv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.columnGroupId,z.deepClone(e)]));return t.forEach(e=>n.set(e.columnGroupId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Cv(e){var t;if((t=e.rangeUpdates)!=null&&t.length)return!1;let{body:n}=e;if(n==null)return!0;let{textRuns:r,paragraphs:i,customRanges:a,customBlocks:o,docxRawCustomBlocks:s,docxRawBlocks:c,docxExportExcludedRanges:l,customDecorations:u,tables:d,columnGroups:f,blockRanges:p}=n;return r==null&&i==null&&a==null&&o==null&&s==null&&c==null&&l==null&&u==null&&d==null&&f==null&&p==null}function wv(e,t=``){var n;if(!t)return[`body`];let{headers:r,footers:i}=e.getSnapshot();if(((n=e.getSnapshot().notes)==null?void 0:n[t])!=null)return[`notes`,t,`body`];if(r==null&&i==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((r==null?void 0:r[t])!=null)return[`headers`,t,`body`];if((i==null?void 0:i[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}var Tv=class{constructor(e){this._actions=e,T(this,`_index`,0),T(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e===void 0&&(e=1/0);let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===`d`||t.t===`r`&&t.body==null?z.deepClone({...t,len:e}):z.deepClone({...t,len:e,body:fv(t.body,n,n+e,!1)})}return{t:`r`,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:`r`}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function Ev(e,t,n){var r;let{dataStream:i}=e,a=n,o=n+t,s=(r=e.renderedPageBreaks)==null?void 0:r.filter(e=>e>=a&&e<o).map(e=>e-a);e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e<a||e>=o).map(e=>e>=o?e-t:e));let c=Qg(e,t,n),l=$g(e,t,n),u=e_(e,t,n),d=n_(e,t,n),f=r_(e,t,n),p=i_(e,t,n),m=a_(e,t,n),h=o_(e,t,n),g=s_(e,t,n),_=l_(e,t,n),v=c_(e,t,n),y=u_(e,t,n),b=``;return i&&(e.dataStream=sd(i,a,o),b=i.slice(a,o)),{dataStream:b,renderedPageBreaks:s,textRuns:c,paragraphs:l,sectionBreaks:u,customBlocks:d,docxRawCustomBlocks:f,docxRawBlocks:p,docxExportExcludedRanges:m,tables:h,columnGroups:g,blockRanges:_,customRanges:v,customDecorations:y}}function Dv(e,t,n,r){let i=e.dataStream;e.dataStream=od(e.dataStream,r,t.dataStream),(e.renderedPageBreaks!=null||t.renderedPageBreaks!=null)&&(e.renderedPageBreaks=[...(e.renderedPageBreaks??[]).map(e=>e>=r?e+n:e),...(t.renderedPageBreaks??[]).map(e=>e+r)].sort((e,t)=>e-t)),Eg(e,t,n,r),Dg(e,t,n,r,!1,i),Pg(e,t,n,r),Lg(e,t,n,r),Rg(e,t,n,r),zg(e,t,n,r),Vg(e,t,n,r),Hg(e,t,n,r),Ug(e,t,n,r),Wg(e,t,n,r),Xg(e,t,n,r),Zg(e,t,n,r)}function Ov(e,t,n=[]){if(z.diffValue(e,t))return[];if(t&&typeof t==`object`&&!Array.isArray(t)&&(e==null||typeof e==`object`&&!Array.isArray(e))){let r=e??{},i=t,a=Array.from(/* @__PURE__ */ new Set([...Object.keys(r),...Object.keys(i)]));return!a.length&&n.length?[n]:a.flatMap(e=>Ov(r[e],i[e],[...n,e]))}return[n]}function kv(e){if(!Array.isArray(e)||e.some(e=>!Array.isArray(e)||!e.length||e.some(e=>typeof e!=`string`||[`__proto__`,`prototype`,`constructor`].includes(e))))throw Error(`Invalid custom range property paths.`)}function Av(e,t,n){kv(n);let r=z.deepClone(e);for(let e of n){let n=r.properties??={},i=t.properties,a=[];for(let t=0;t<e.length;t++){let r=e[t];i=i&&typeof i==`object`?i[r]:void 0,t===e.length-1?i===void 0?delete n[r]:n[r]=z.deepClone(i):((!n[r]||typeof n[r]!=`object`||Array.isArray(n[r]))&&(n[r]={}),a.push({object:n,key:r,value:i}),n=n[r])}for(let e of a.reverse())e.value===void 0&&Object.keys(e.object[e.key]).length===0&&delete e.object[e.key]}return t.properties===void 0&&!Object.keys(r.properties??{}).length&&delete r.properties,r}function jv(e,t){if(!e||!t.propertyPaths||!t.range)return t;if(!e.range)return e;let n=e.propertyPaths&&[...e.propertyPaths,...t.propertyPaths.filter(t=>!e.propertyPaths.some(e=>e.length<=t.length&&e.every((e,n)=>t[n]===e)))];return{...e,range:Av(e.range,t.range,t.propertyPaths),propertyPaths:n}}function Mv(e,t,n){if(!t||!e.range)return[e];if(!t.range)return[];if(!e.propertyPaths||!t.propertyPaths)return n===`left`?[{...e,propertyPaths:void 0}]:[];let r=e.propertyPaths.filter(e=>n===`left`||!t.propertyPaths.some(t=>e.slice(0,Math.min(e.length,t.length)).every((e,n)=>t[n]===e))).map(e=>t.propertyPaths.find(t=>t.length<e.length&&t.every((t,n)=>e[n]===t))??e);return r.length?[{...e,propertyPaths:r}]:[]}function Nv(e){let t=/* @__PURE__ */ new Map;for(let n of e)if(n.t===`r`)for(let e of n.rangeUpdates??[])t.set(e.rangeId,jv(t.get(e.rangeId),e));return t.size?z.deepClone(Array.from(t.values())):[]}function Pv(e){return e.flatMap(e=>{if(e.t===`i`&&e.len>1&&Array.from(e.body.dataStream).every(e=>e===``||e===``))return Array.from(e.body.dataStream,(t,n)=>({...e,len:1,body:fv(e.body,n,n+1,!1)}));if(e.t!==`r`||!e.rangeUpdates)return[e];let{rangeUpdates:t,oldRangeUpdates:n,...r}=e;return r.len===0&&!r.body?[]:[r]})}function Fv(e,t){return t!=null&&t.length?[...e,{t:`r`,len:0,rangeUpdates:t}]:e}function Iv(e,t){for(let{rangeId:n,range:r,nextRangeId:i,propertyPaths:a}of e??[]){if(a!==void 0&&(kv(a),!r))throw Error(`Invalid custom range property paths.`);if(typeof n!=`string`||!n||i!=null&&typeof i!=`string`||r!==null&&(typeof r!=`object`||!r||Array.isArray(r)||r.rangeId!==n||!Number.isInteger(r.startIndex)||!Number.isInteger(r.endIndex)||r.startIndex<0||r.endIndex<r.startIndex||r.endIndex>=t))throw Error(`Invalid custom range identity or bounds.`)}}function Lv(e,t){if(!(t!=null&&t.length))return;let n=e.customRanges??[];for(let{rangeId:e,range:r,nextRangeId:i,propertyPaths:a}of[...t].reverse()){let t=n.findIndex(t=>t.rangeId===e);if(r&&a)t>=0&&(n[t]=Av(n[t],r,a));else if(r){if(i!==void 0){t>=0&&n.splice(t,1);let e=n.findIndex(e=>e.rangeId===i);n.splice(e<0?n.length:e,0,z.deepClone(r))}else t>=0?n[t]=z.deepClone(r):n.push(z.deepClone(r))}else t>=0&&n.splice(t,1)}e.customRanges=n}function Rv(e,t,n=!1){return e.map(e=>{var r;let{rangeId:i,range:a}=e;if(!a&&n)return e;let o={dataStream:``,customRanges:a?[z.deepClone(a)]:[]},s=0;for(let e of t){var c;if(e.t===`i`){var l;Xg(o,{dataStream:``,customRanges:z.deepClone((l=e.body.customRanges)==null?void 0:l.filter(e=>e.rangeId===i))},e.len,s)}else if(e.t===`d`){c_(o,e.len,s);continue}else(c=e.body)!=null&&c.customRanges&&x_(o,{dataStream:``,customRanges:z.deepClone(e.body.customRanges.filter(e=>e.rangeId===i))},e.len,s,e.coverType??0);s+=e.len}let u=(r=o.customRanges)==null?void 0:r.find(e=>e.rangeId===i);return{...e,propertyPaths:u?e.propertyPaths:void 0,range:u&&a&&n?{...z.deepClone(a),startIndex:u.startIndex,endIndex:u.endIndex}:u??null}})}function zv(e,t){let n=new Map(t==null?void 0:t.map(e=>[e.rangeId,e]));return n.size?e.map(e=>{var t;return(t=e.body)!=null&&t.customRanges?{...e,body:{...e.body,customRanges:e.body.customRanges.flatMap(e=>{if(!n.has(e.rangeId))return[e];let t=n.get(e.rangeId);return t.range?[{...t.propertyPaths?Av(e,t.range,t.propertyPaths):z.deepClone(t.range),startIndex:e.startIndex,endIndex:e.endIndex}]:[]})}}:e}):e}function Bv(e,t,n){if(!t.length)return Fv(e,n);let r=[],i=[],a=0,o=0;for(let n of e){var s;let e=(s=n.body)==null?void 0:s.dataStream;n.t===`i`&&n.len===1&&t.some(t=>e===``&&a===t.startIndex||e===``&&a===t.endIndex)?(a>o&&i.push({t:`r`,len:a-o}),i.push({t:`d`,len:1}),o=a+1):r.push(n),n.t!==`d`&&(a+=n.len)}return Fv(r,Rv(n,i))}function Vv(e,t,n,r,i=0){return x_(e,t,n,r,i)}function Hv(e,t,n){return t<=0?{dataStream:``}:Ev(e,t,n)}function Uv(e,t,n,r){n!==0&&Dv(e,t,n,r)}function Wv(e,t){if(t.some(e=>e.t!==`r`&&e.valueRangeId!==void 0&&(typeof e.valueRangeId!=`string`||!e.valueRangeId)))throw Error(`Invalid scalar value range identity.`);let n=Nv(t);n.length&&Iv(n,t.reduce((e,t)=>t.t===`i`?e+t.len:t.t===`d`?e-t.len:e,e.dataStream.length));let r=new lm;return r.reset(),t.forEach(t=>{switch(t.t){case`r`:{let{coverType:n,body:i,len:a}=t;i!=null&&Vv(e,z.deepClone(i),a,r.cursor,n),r.moveCursor(a);break}case`i`:{let{body:n,len:i}=t;Uv(e,Gv(n)?n:z.deepClone(n),i,r.cursor),r.moveCursor(i);break}case`d`:{let{len:n}=t;Hv(e,n,r.cursor);break}default:throw Error(`Unknown action type for action: ${t}.`)}}),Lv(e,n),e}function Gv(e){return Object.keys(e).length===1&&typeof e.dataStream==`string`}function Kv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=z.deepClone(t),e=z.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===0)_={...f},n===0&&r===1&&h&&(_=Object.assign({},h,_));else if(_={...f},n===1){if(r===1)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===1){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Tg(a,!0)}function qv(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===1)return i===1?[z.deepClone(a)]:[z.deepClone(o)];if(r===1){let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}{let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}}function Jv(e,t,n,r,i){let a={startIndex:t.startIndex,paragraphId:t.paragraphId};if(t.paragraphStyle&&(a.paragraphStyle=z.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===1){if(r===1)i===1&&(a.paragraphStyle={...e.paragraphStyle});else if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(r===1){if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(i===1){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}n===1&&r===1?a.bullet=i===1?z.deepClone(e.bullet):z.deepClone(t.bullet):e.bullet===void 0?a.bullet=z.deepClone(t.bullet):n===1||r===1?a.bullet=i===0&&t.bullet?z.deepClone(t.bullet):z.deepClone(e.bullet):i===0&&t.bullet!==void 0&&(a.bullet=z.deepClone(t.bullet));for(let o of[`headingCollapsed`,`styleId`,`sourceBullet`,`directBullet`]){let s=e[o],c=t[o],l;n===1&&r===1?l=i===1?s:c:s===void 0?l=c:n===1||r===1?l=i===0&&c!==void 0?c:s:i===0&&(l=c),l!==void 0&&Object.assign(a,{[o]:z.deepClone(l)})}return a.bullet===void 0&&delete a.bullet,a}function Yv(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return z.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===9999||i===9999)&&(a=!0,n.push({...r,type:9999}));break}a||n.push(r)}return n}function Xv(e,t,n=!1){let{body:r,coverType:i=0}=e,{body:a,coverType:o=0}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],blockRanges:d=[],customRanges:f,customDecorations:p}=r,{textRuns:m,paragraphs:h=[],blockRanges:g=[],customRanges:_,customDecorations:v}=a,y=Kv(l,m,i,o,+!!n);y&&(s.textRuns=y);let b=qv(f,_,i,o,+!!n);b&&(s.customRanges=b);let x=Yv(p,v);x&&(s.customDecorations=x);let S=[],C=0,w=0;for(;C<u.length&&w<h.length;){let e=u[C],t=h[w],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r,paragraphId:t.paragraphId};a=n?Jv(e,t,i,o,1):Jv(e,t,i,o,0),S.push(a),C++,w++}else r<a?C++:(S.push(z.deepClone(t)),w++)}w<h.length&&S.push(...h.slice(w)),S.length&&(s.paragraphs=S);let T=Zv(d,g,n);return T.length&&(s.blockRanges=T),{coverType:c,body:s}}function Zv(e,t,n){return e.length?t.length?t.map(t=>{let r=e.find(e=>e.blockId===t.blockId);return r&&n?na(t,r):t}):[]:t}function Qv(e){return Object.keys(e).length===1}function $v(e){return new Set(e.flatMap(e=>e.t!==`r`&&e.valueRangeId?[e.valueRangeId]:[]))}function ey(e,t){return e.map(e=>{var n,r;if(!((n=e.body)!=null&&(n=n.customRanges)!=null&&n.some(e=>t.has(e.rangeId))))return e;let i={...e.body,customRanges:e.body.customRanges.filter(e=>!t.has(e.rangeId))};return(r=i.customRanges)!=null&&r.length||delete i.customRanges,{...e,body:i}})}function ty(e,t,n){if((e==null?void 0:e.t)!==`i`||(t==null?void 0:t.t)!==`i`)return n===`left`;let r=e.body.dataStream,i=t.body.dataStream;return r===i?n===`left`:r===``||i===``?!0:r===``||i===``?!1:n===`left`}function ny(e,t,n,r){Og(t.paragraphs,e.paragraphs,n,{freshenSplitParagraph:!1,preserveExplicitParagraphIds:!!e[ag],reservedParagraphIds:r,dataStream:t.dataStream})}var X=class e{constructor(){T(this,`_actions`,[])}static apply(e,t){return Wv(e,t)}static compose(t,n){let r=Nv(t),i=Nv(n);if(r.length||i.length){let a=Pv(t),o=Pv(n),s=new Map(Rv(r,o).map(e=>[e.rangeId,e]));for(let e of i)s.set(e.rangeId,jv(s.get(e.rangeId),e));return Fv(e.compose(a,o),Array.from(s.values()))}let a=new Tv(t),o=new Tv(n),s=new e;for(;a.hasNext()||o.hasNext();)if(o.peekType()===`i`)s.push(o.next());else if(a.peekType()===`d`)s.push(a.next());else{let e=Math.min(a.peekLength(),o.peekLength()),t=a.next(e),n=o.next(e);if(t.t===`i`&&n.t===`r`)n.body==null?s.push(t):s.push({...t,body:bv(t.body,n.body,n.coverType)});else if(t.t===`r`&&n.t===`r`){if(t.body==null&&n.body==null)s.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=+(t.coverType===1||n.coverType===1);s.push({...t,t:`r`,coverType:e,body:bv(t.body,n.body,n.coverType)})}else s.push(t.body?t:n)}else t.t===`r`&&n.t===`d`?s.push(n):t.t===`i`&&n.t}return s.trimEndUselessRetainAction(),s.serialize()}static transform(t,n,r=`right`){let i=Nv(t),a=Nv(n);if(i.length||a.length){let o=Pv(t),s=Pv(n),c=Rv(i,e._transform(o,s,r,!0),!0),l=c.flatMap(e=>Mv(e,a.find(t=>t.rangeId===e.rangeId),r)),u=c.flatMap(e=>e.range&&a.some(t=>t.rangeId===e.rangeId&&!t.range)?[e.range]:[]);return Bv(zv(e._transform(s,o,r===`left`?`right`:`left`,!0),a),u,l)}return this._transform(n,t,r===`left`?`right`:`left`)}static _transform(t,n,r=`right`,i=!1){let a=$v(t),o=new Set(Array.from($v(n)).filter(e=>a.has(e))),s=new Tv(o.size&&r===`right`?ey(t,o):t),c=new Tv(o.size&&r===`left`?ey(n,o):n),l=new e;for(;s.hasNext()||c.hasNext();)if(s.peekType()===`i`&&((i?ty(s.peek(),c.peek(),r):r===`left`)||c.peekType()!==`i`)){let e=s.next();e.t===`i`&&e.valueRangeId&&o.has(e.valueRangeId)&&r===`right`?l.push({t:`d`,len:e.len,valueRangeId:e.valueRangeId}):l.retain(e.len)}else if(c.peekType()===`i`){let e=c.next();e.t===`i`&&e.valueRangeId&&o.has(e.valueRangeId)&&r===`left`||l.push(e)}else{let e=Math.min(s.peekLength(),c.peekLength()),t=s.next(e),n=c.next(e);if(t.t===`d`)continue;if(n.t===`d`){l.push(n);continue}if(t.body==null||n.body==null)l.push(n);else{let{coverType:e,body:i}=Xv(t,n,r===`left`);l.push({...n,t:`r`,coverType:e,body:i})}}return l.trimEndUselessRetainAction(),l.serialize()}static transformPosition(e,t,n=!1){let r=new Tv(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();r.next(),a===`d`?t-=Math.min(e,t-i):(a===`i`&&(i<t||!n)&&(t+=e),i+=e)}return t}static isNoop(e){return e.length===0}static invert(t){if(Nv(t).length){let n=t.flatMap(e=>{if(e.t!==`r`||!e.rangeUpdates)return[];if(!e.oldRangeUpdates)throw Error(`makeInvertible must capture custom ranges before inversion.`);return e.oldRangeUpdates});return Fv(e.invert(Pv(t)),z.deepClone(n))}let n=[];for(let e of t)if(e.t===`i`)n.push({t:`d`,len:e.len,body:e.body,valueRangeId:e.valueRangeId});else if(e.t===`d`){var r;if(e.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);(r=e.body.paragraphs)!=null&&r.length&&(e.body[wg]=!0,Reflect.set(e.body,ag,!0)),n.push({t:`i`,body:e.body,len:e.len,valueRangeId:e.valueRangeId})}else if(e.body!=null){if(e.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);n.push({t:`r`,body:e.oldBody,oldBody:e.body,len:e.len,coverType:1})}else n.push(e);return n}static makeInvertible(e,t){let n=[],r=0,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let s of e){if(s.t===`r`&&s.rangeUpdates&&(s.oldRangeUpdates=s.rangeUpdates.map(({rangeId:e,propertyPaths:n})=>{var r,i;let a=((r=t.customRanges)==null?void 0:r.findIndex(t=>t.rangeId===e))??-1;return{rangeId:e,range:a<0?null:z.deepClone(t.customRanges[a]),nextRangeId:a<0?void 0:((i=t.customRanges[a+1])==null?void 0:i.rangeId)??null,propertyPaths:a<0?void 0:n}})),s.t===`i`&&(ny(s.body,t,r,i),Fg(t.sectionBreaks,s.body.sectionBreaks,a)),s.t===`d`&&(s.body==null||s.body&&s.body.dataStream.length!==s.len)){let e=dv(t,r,r+s.len,!1);s.len=e.dataStream.length,s.body=e}if(s.t===`r`&&s.body!=null){let e=uv(t,r,r+s.len,!0);for(let t of Object.keys(e))t!==`dataStream`&&t!==`paragraphs`&&s.body[t]==null&&Reflect.deleteProperty(e,t);if(s.body.paragraphs==null)delete e.paragraphs;else{var o;let t=new Map((o=e.paragraphs)==null?void 0:o.map(e=>[e.startIndex,e]));s.body.paragraphs=s.body.paragraphs.map(e=>{let n=t.get(e.startIndex);if(!n||e.paragraphId!=null&&e.paragraphId!==n.paragraphId)return e;let r={...e};return Reflect.deleteProperty(r,`paragraphId`),Reflect.deleteProperty(n,`paragraphId`),r})}s.oldBody={...e,dataStream:``},s.len=e.dataStream.length}n.push(s),s.t!==`i`&&(r+=s.len)}return n}updateCustomRangeProperties(e,t){let n=Ov(e.properties??{},t);return n.length&&this.updateCustomRanges([{rangeId:e.rangeId,range:{...e,properties:t},propertyPaths:n}]),this}updateCustomRanges(e){return this.push({t:`r`,len:0,rangeUpdates:e}),this}insert(e,t){let n={t:`i`,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:`r`,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:`d`,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=z.deepClone(e[0]);if(r.t===`r`&&r.len===0&&r.body==null&&!r.rangeUpdates)return this;if(typeof n==`object`){if(n.t===`d`&&r.t===`d`&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,this;if(n.t===`d`&&r.t===`i`&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===`r`&&r.t===`r`&&n.body==null&&r.body==null&&!n.rangeUpdates&&!r.rangeUpdates)return n.len+=r.len,this;if(n.t===`i`&&Qv(n.body)&&r.t===`i`&&Qv(r.body)&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===`r`&&Cv(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};T(X,`id`,`text-x`),T(X,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(X,"name",{value:`text-x`});var ry=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==X.id||(this._subTypes.set(e.name,e),ig.type.registerSubtype(e))}static apply(e,t){if(!ig.type.isNoop(t))return ig.type.apply(e,t)}static compose(e,t){return ig.type.compose(e,t)}static transform(e,t,n){return ig.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===X.name?X.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return ig.type.invertWithDoc(e,t)}static isNoop(e){return ig.type.isNoop(e)}static getInstance(){return this._instance??=new e,this._instance}removeOp(e,t){return ig.removeOp(e,t)}moveOp(e,t){return ig.moveOp(e,t)}insertOp(e,t){return ig.insertOp(e,t)}replaceOp(e,t,n){return ig.replaceOp(e,t,n)}editOp(e,t=[`body`]){return ig.editOp(t,X.name,e)}};T(ry,`uri`,`https://github.com/dream-num/univer#json-x`),T(ry,`_subTypes`,/* @__PURE__ */ new Map),T(ry,`_instance`,null),ry.registerSubtype(X);let iy=[``,`\x1B`,``,``,``,``,``,``],ay=e=>{let t=iy.reduce((e,t)=>e.replaceAll(t,``),e);return t.endsWith(`\r
|
|
7
|
-
`)?t.slice(0,-2):t},
|
|
8
|
-
`||t<=0||e.dataStream[t-1]!==`\f`),n=/* @__PURE__ */ new Set,r=t.length!==e.sectionBreaks.length,i=t.map(e=>e.sectionId&&!n.has(e.sectionId)?(n.add(e.sectionId),e):(r=!0,{...e,sectionId:ym(n)}));return r?{...e,sectionBreaks:i}:e}function uy(e){var t,n;if(e.id!=null&&Mp(e.id))return{...cy,...e};let r=Jh(e.id,e.locale,e.title,(t=e.documentStyle)==null?void 0:t.documentFlavor);if(z.isEmptyObject(e))return r;let i=ta({},r,e,(e,t,n)=>{if(Array.isArray(t)||n===`body`&&typeof t==`object`&&t)return t});return e.body!=null&&((n=e.documentStyle)==null?void 0:n.defaultParagraphStyle)===void 0&&delete i.documentStyle.defaultParagraphStyle,i.body=ly(i.body),i}var dy=class extends M{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){super(),T(this,`type`,n.UniverType.UNIVER_DOC),T(this,`_name$`,new t.BehaviorSubject(``)),T(this,`name$`,this._name$.asObservable()),T(this,`snapshot`,void 0),T(this,`_mutationRevision`,0),this.snapshot=uy(e),this._name$.next(this.snapshot.title??`No Title`)}getRev(){return this.snapshot.rev??1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._markMutation(),this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t,this._markMutation()}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){let e=this.snapshot.lists??{};return{...__,...e}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig=t.renderConfig==null?e:{...t.renderConfig,...e},this._markMutation()}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e},this._markMutation()}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i),this._markMutation()}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;n.pageSize?(e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t),this._markMutation()):(n.pageSize={width:e??1/0,height:t??1/0},this._markMutation())}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o,this._markMutation()}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e},this._markMutation()}setDisabled(e){this.snapshot.disabled=e,this._markMutation()}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}getMutationRevision(){return this._mutationRevision}_markMutation(){this._mutationRevision++}},fy=class e extends dy{constructor(e){super(z.isEmptyObject(e)?Jh():e),T(this,`_unitId`,void 0),T(this,`headerModelMap`,/* @__PURE__ */ new Map),T(this,`footerModelMap`,/* @__PURE__ */ new Map),T(this,`noteModelMap`,/* @__PURE__ */ new Map),T(this,`change$`,new t.BehaviorSubject(0)),this._unitId=this.snapshot.id??J(6),this._initializeHeaderFooterModel(),this._name$.next(this.snapshot.title??``)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this.noteModelMap.forEach(e=>e.dispose()),this.noteModelMap.clear(),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot=uy(e),this._initializeHeaderFooterModel(),this._markMutation(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){return e==null||e===``?this:this.headerModelMap.has(e)?this.headerModelMap.get(e):this.footerModelMap.has(e)?this.footerModelMap.get(e):this.noteModelMap.has(e)?this.noteModelMap.get(e):null}getUnitId(){return this._unitId}apply(e){if(ry.isNoop(e))return;let t=this.snapshot.notes,n=/* @__PURE__ */ new Set,r=!1,i=ig.type.readCursor(e);return i.traverse(null,()=>{let e=i.getPath();e[0]===`notes`&&typeof e[1]==`string`&&n.add(e[1]),(e[0]===`styles`||e[0]===`documentStyle`)&&(r=!0)}),this.snapshot=ry.apply(this.snapshot,e),this._markMutation(),(r||t!==this.snapshot.notes||n.size>0)&&this._initializeNoteModels(r?void 0:t,n),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=0){let r=this.getBody();if(r!=null)return uv(r,e,t,!1,n)}_initializeHeaderFooterModel(){this._initializeNoteModels();let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e(r)),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e(r)),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}_initializeNoteModels(t,n){for(let[e,i]of this.noteModelMap){var r;(n!=null&&n.has(e)||(t==null?void 0:t[e])!==((r=this.snapshot.notes)==null?void 0:r[e])||!(t!=null&&t[e]))&&(i.dispose(),this.noteModelMap.delete(e))}for(let[t,n]of Object.entries(this.snapshot.notes??{})){if(this.noteModelMap.has(t))continue;let r=new e({...n,id:this.getUnitId(),documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles});this.noteModelMap.set(t,r)}}updateDocumentStyle(e){super.updateDocumentStyle(e),this._initializeNoteModels()}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e;return ay(((e=this.getBody())==null?void 0:e.dataStream)??``)}getStatistics(e={}){var t;return Nm(((t=this.getBody())==null?void 0:t.dataStream)??``,e)}};function py(e){if(e==null)return{};let t=z.deepClone(e);return z.removeNull(t),t}function my(e,t){if(!e||!t)return{};let n=/* @__PURE__ */ new Set,r=t=>{if(n.has(t))return{};let i=e[t];if(!i||i.type!==1)return{};n.add(t);let a=i.basedOn?r(i.basedOn):{};return n.delete(t),{...a,...py(i.paragraphStyle)}};return r(t)}function hy(e,t,n={}){let r=n.useLegacyModernDefaults??(e==null?void 0:e.documentFlavor)===2?{lineSpacing:Fh,spaceAbove:{v:0},spaceBelow:{v:12}}:{},i={...(e==null?void 0:e.documentFlavor)===1?{widowControl:1}:{},...r,...py(e==null?void 0:e.defaultParagraphStyle)};n.excludeDocumentOuterSpacing&&(delete i.spaceAbove,delete i.spaceBelow);let a=py(t),o=my(n.styles,n.paragraphStyleId),s=a.namedStyleType??o.namedStyleType,c=s==null?null:Ih[s];return z.deepClone({...i,...c,...o,...a})}function gy(e,t){let{documentStyle:n}=e,{wordWrap:r}=hy(n,t==null?void 0:t.paragraphStyle,{styles:e.styles,paragraphStyleId:t==null?void 0:t.styleId});return r??0}function _y(e,t,n,r){if(t===``)return e;let i=new fy({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o=Hl(t,r?`g`:`gi`),s;for(;(s=o.exec(i.getBody().dataStream))!==null;){let e=s.index,t=new X,r=ry.getInstance();if(e>0&&t.retain(e),n.length>0){var c;let r=i.sliceBody(e,e+a),o={dataStream:n};Array.isArray(r==null?void 0:r.textRuns)&&r.textRuns.length&&(o.textRuns=[{...r.textRuns[0],st:0,ed:n.length}]),r!=null&&(c=r.customRanges)!=null&&c.length&&(o.customRanges=[{...r.customRanges[0],startIndex:0,endIndex:n.length-1}]),t.insert(n.length,o)}t.delete(a),i.apply(r.editOp(t.serialize())),o.lastIndex=e+n.length}let l=i.getBody();return i.dispose(),l}function vy(e){let{ranges:t,id:n,type:r}=e,i=new X,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:`r`,len:o-a}),i.push({t:`r`,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function yy(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new X,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:`r`,len:c}),s.push({t:`r`,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:9999}]}}),s}function by(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function xy(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?_g(fg(i),e.startOffset)&&n.push(i):vg({startOffset:e.startOffset,endOffset:e.endOffset},fg(i))&&n.push(i)}return n}function Sy(e){return{...z.deepClone(e),rangeId:J()}}function Cy(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function wy(e,t,n,r){let i=[],a=sg({startIndex:e,endIndex:t});for(let e=0,o=n.length;e<o;e++){let o=n[e];if((r===void 0||o.rangeType===r)&&vg(a,fg(o))&&i.push({...o}),o.startIndex>t)break}return i}function Ty(e,t){var n,r;let i=wy(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,t.customRanges??[]),a=Math.min(e.startOffset,((n=i[0])==null?void 0:n.startIndex)??1/0),o=Math.max(e.endOffset,(((r=i[i.length-1])==null?void 0:r.endIndex)??-1/0)+1);return{startOffset:a,endOffset:o,collapsed:a===o}}var Ey=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;)if(a<e.length-1&&!e[a][1])e.splice(a,1);else switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O})))());function Dy(e){var t;let{rangeId:n,segmentId:r,documentDataModel:i,insert:a}=e,o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===n);if(!o)return!1;let{startIndex:s,endIndex:c}=o,l=new X,u=c-s+1;l.push({t:`r`,len:s}),l.push({t:`r`,len:u,body:{dataStream:``,customRanges:[]}}),a&&l.push({t:`i`,body:a,len:a.dataStream.length});let d=c+1+((a==null?void 0:a.dataStream.length)??0);return l.selections=[{startOffset:d,endOffset:d,collapsed:!0}],l}function Oy(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new X,l=!1;return t.forEach(e=>{let t=Ty(e,o);if(!t||!o)return!1;let{startOffset:u,endOffset:d}=t,f=o.customRanges??[],p=(e,t,o)=>{var l,u;let d=wy(e,t,f,r),p=Math.min(((l=d[0])==null?void 0:l.startIndex)??1/0,e),m=Math.max(((u=d[d.length-1])==null?void 0:u.endIndex)??-1/0,t),h={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:m-p,wholeEntity:i,properties:{...a}};c.push({t:`r`,len:p-s}),c.push({t:`r`,len:m-p+1,body:{dataStream:``,customRanges:[h]},coverType:0}),s=m+1},m=(o.paragraphs??[]).filter(e=>e.startIndex<d&&e.startIndex>u),h=(o.customBlocks??[]).filter(e=>e.startIndex<d&&e.startIndex>u);Cy([u,d-1],[...m.map(e=>e.startIndex),...h.map(e=>e.startIndex)]).forEach(([e,t],n)=>p(e,t,n)),l=!0,c.selections=[{startOffset:t.endOffset,endOffset:t.endOffset,collapsed:!0}]}),l?c:!1}function ky(e,t){return!!(e.atomicRange&&t.some(t=>t.startOffset<=e.atomicRange.startOffset&&t.endOffset>=e.atomicRange.endOffset))}let Ay=/* @__PURE__ */ new Set([`\r`,`
|
|
9
|
-
`]),
|
|
10
|
-
`&&i().sectionBreaks.push(a)}return t.push(...
|
|
11
|
-
`);if(e.require===`paragraph-or-section`){let n=[...e.paragraphs,...e.sectionBreaks].sort((e,t)=>e-t);a&&(s||c)||
|
|
12
|
-
`&&n[t-1]===`\r`&&
|
|
13
|
-
`||e.dataStream[n]===void 0;return{dataStream:a?`${i}\r`:i,customBlocks:t.map((e,t)=>({startIndex:t,blockId:e.drawingId})),...a?{paragraphs:[{startIndex:i.length,paragraphId:
|
|
14
|
-
`&&e.sectionBreaks.push({startIndex:n,sectionId:
|
|
15
|
-
`)}getParagraphStyle(){var e;return
|
|
16
|
-
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0,paragraphId:
|
|
17
|
-
`))throw RangeError(`Rich text run replacement cannot contain paragraph or section breaks.`);let s=this._doc.getBody();if(!s)throw Error(`Rich text body is not available.`);let{startOffset:c,endOffset:l}=e;if(s.dataStream.slice(c,l)===t)return;let u=
|
|
18
|
-
`},n=t.sectionBreaks??=[];if(!n.length){var r;n.push({sectionId:
|
|
19
|
-
\x1B\b]`;function Q(e,t,n,r){return{...e,code:t,index:r,message:n}}function
|
|
20
|
-
`?r.set(a.startIndex,(r.get(a.startIndex)??0)+1):t.push(Q(n,`section-break-token-mismatch`,`Section break metadata must point to a section break sentinel.`,a.startIndex));
|
|
21
|
-
`?t.hasRootSectionBreak=!0:n===``?t.tableRanges.unmatchedStarts.push(e):n===``?
|
|
22
|
-
`)c&&(c.hasChild=!0),u&&(u.hasSectionBreak=!0);else if(o===``)r.push(e);else if(o===``)i.push({startIndex:e,hasChild:!1});else if(o===``){let r=i.pop();r?r.hasChild||t.push(Q(n,`empty-column`,`Column must contain at least one paragraph or section child.`,r.startIndex)):t.push(Q(n,`unbalanced-column-group`,`Column end token has no matching column start.`,e))}else o===``?i.length>0||r.length===0?(t.push(Q(n,`unbalanced-column-group`,`Column group closes while a column is still open.`,e)),i.length=0):r.pop():o===``?(l&&!u&&t.push(Q(n,`unbalanced-table`,`Nested table must be inside a parent cell.`,e)),a.push({inRow:!1})):o===`\x1B`?((!l||l.inRow)&&t.push(Q(n,`unbalanced-table`,`Table row must start inside a table without an open row.`,e)),l&&(l.inRow=!0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table cell must start inside a row without an open cell.`,e)),l&&(l.cell={startIndex:e,hasParagraph:!1,hasSectionBreak:!1})):o===``?(u?u.hasParagraph&&u.hasSectionBreak||t.push(Q(n,`empty-table-cell`,`Table cell must contain a paragraph and section break child.`,u.startIndex)):t.push(Q(n,`unbalanced-table`,`Table cell end token has no matching start.`,e)),l&&(l.cell=void 0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table row closes while a cell is still open.`,e)),l&&(l.inRow=!1)):o===``&&((!l||l.inRow||u)&&t.push(Q(n,`unbalanced-table`,`Table closes while a row or cell is still open.`,e)),a.pop())}(r.length>0||i.length>0)&&t.push(Q(n,`unbalanced-column-group`,`Column group or column token is not closed.`,e.dataStream.length)),a.length>0&&t.push(Q(n,`unbalanced-table`,`Table, row, or cell token is not closed.`,e.dataStream.length))}function zb(e,t,n){let r=/* @__PURE__ */ new Map,i=[];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)i.push(a);else if(o===``){let e=i.pop();e==null?t.push(Q(n,`unbalanced-custom-range`,`Custom range end token has no matching start.`,a)):r.set(e,a)}}for(let e of i)t.push(Q(n,`unbalanced-custom-range`,`Custom range start token has no matching end.`,e));let a=e.customRanges??[],o=/* @__PURE__ */ new Set;for(let i of a)o.has(i.rangeId)&&t.push(Q(n,`duplicate-custom-range-id`,`Custom range ids must be unique.`,i.startIndex)),o.add(i.rangeId),i.rangeType===1&&(e.dataStream[i.startIndex]!==``||e.dataStream[i.endIndex]!==``||r.get(i.startIndex)!==i.endIndex)&&t.push(Q(n,`custom-range-token-mismatch`,`Field metadata must point to a matching custom range token pair.`,i.startIndex));for(let[e,i]of r)a.some(t=>t.startIndex===e&&t.endIndex===i)||t.push(Q(n,`missing-custom-range-metadata`,`Custom range token pair has no metadata.`,e));let s=a.filter(e=>e.rangeType===1).slice().sort((e,t)=>e.startIndex-t.startIndex||t.endIndex-e.endIndex),c=[];for(let e of s){for(;c.length>0&&c[c.length-1].endIndex<e.startIndex;)c.pop();let r=c[c.length-1];r&&e.endIndex>r.endIndex&&t.push(Q(n,`crossing-custom-range`,`Field ranges may nest but must not cross.`,e.startIndex)),c.push(e)}}function Bb(e,t={segmentType:`body`}){let n=[],r=Nb(e.dataStream);if(Eb(r,n,t),Db(e,n,t),Ob(e,n,t),Pb(e,r,n,t),Fb(e,r,n,t),Ib(e,r,n,t),Lb(e,r,n,t),Rb(e,n,t),zb(e,n,t),t.segmentType===`header`||t.segmentType===`footer`)for(let r of e.customRanges??[])(r.rangeType===8||r.rangeType===9)&&n.push(Q(t,`invalid-note-reference`,`Note references are only supported in the document body.`,r.startIndex));return n}function Vb(e,t){var n,r,i;let a={segmentType:`note`,segmentId:e},o=Bb(t.body,a);t.noteId===e&&e.length!==0&&[`footnote`,`endnote`].includes(t.type)||o.push({...a,code:`invalid-note-id`,message:`Note identity must match its segment key.`}),(n=t.body.customRanges)!=null&&n.some(e=>e.rangeType===8||e.rangeType===9)&&o.push({...a,code:`nested-note`,message:`A note cannot contain another note reference.`});let s=((r=t.body.sectionBreaks)==null?void 0:r.filter(e=>{var n;return!((n=t.body.tables)!=null&&n.some(t=>e.startIndex>=t.startIndex&&e.startIndex<t.endIndex))}))??[],c=s.some(e=>Object.keys(e).some(e=>e!==`sectionId`&&e!==`startIndex`)),l=Object.values(t.drawings??{}).some(e=>e.layoutType!==0),u=Object.values(t.tableSource??{}).some(e=>e.textWrap===1);return(s.length>1||c||(i=t.body.columnGroups)!=null&&i.length||l||u)&&o.push({...a,code:`invalid-note-body`,message:`Notes support paragraphs, inline drawings and flow tables without independent sections or columns.`}),o}function Hb(e){let t=[];if(e.body){t.push(...Bb(e.body,{segmentType:`body`}));let i=/* @__PURE__ */ new Set;for(let a of e.body.customRanges??[]){var n,r;if(a.rangeType!==8&&a.rangeType!==9)continue;let o=(n=a.properties)==null?void 0:n.noteId;typeof o!=`string`||((r=e.notes)==null?void 0:r[o])==null?t.push({code:`missing-note`,segmentType:`body`,index:a.startIndex,message:`Note reference must resolve to a note segment.`}):e.notes[o].type===(a.rangeType===9?`endnote`:`footnote`)?i.has(o)?t.push({code:`duplicate-note-reference`,segmentType:`body`,index:a.startIndex,message:`Each note must have its own reference identity.`}):i.add(o):t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference kind must match its target.`}),a.startIndex===a.endIndex&&e.body.dataStream[a.startIndex]===``&&a.wholeEntity||t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference must cover one whole-entity reference character.`})}}for(let[n,r]of Object.entries(e.headers??{}))t.push(...Bb(r.body,{segmentType:`header`,segmentId:n}));for(let[n,r]of Object.entries(e.footers??{}))t.push(...Bb(r.body,{segmentType:`footer`,segmentId:n}));for(let[n,r]of Object.entries(e.notes??{})){var i,a;t.push(...Vb(n,r)),((i=e.headers)!=null&&i[n]||(a=e.footers)!=null&&a[n])&&t.push({code:`invalid-note-id`,segmentType:`note`,segmentId:n,message:`Notes must not share a segment identity with a header or footer.`})}return t}function Ub(e,t){return`${t==="default"?`default`:t===`first`?`firstPage`:`evenPage`}${e===`header`?`Header`:`Footer`}Id`}function Wb(e,t,n,r){if(n<0||n>=t.length)return{linkedToPrevious:!1};let i=t[n],a=i[r];if(typeof a==`string`&&a)return{segmentId:a,linkedToPrevious:!1,sourceSectionId:i.sectionId};if(n===0){let t=e[r];return{...typeof t==`string`&&t?{segmentId:t}:{},linkedToPrevious:!1}}let o=Wb(e,t,n-1,r);return{...o.segmentId?{segmentId:o.segmentId}:{},linkedToPrevious:!0,sourceSectionId:o.sourceSectionId}}function Gb(e,t,n){let r={};for(let i of[`defaultHeaderId`,`defaultFooterId`,`firstPageHeaderId`,`firstPageFooterId`,`evenPageHeaderId`,`evenPageFooterId`]){let{segmentId:a}=Wb(e,t,n,i);a&&(r[i]=a)}return r}function Kb(e){var t;let n=(t=e.properties)==null?void 0:t.dataBinding;if(n!=null&&n.storeItemID&&n.xpath)return JSON.stringify([n.storeItemID.toLowerCase(),n.xpath,n.prefixMappings??``])}function qb(e,t){if(t.properties.showingPlaceholder)return``;if(t.properties.kind===`checkbox`){var n;return(n=t.properties.checkbox)!=null&&n.checked?`true`:`false`}let r=e.dataStream.slice(t.startIndex,t.endIndex+1).replace(/^[\x00-\x08\x0A-\x1F]+|[\x00-\x08\x0A-\x1F]+$/g,``);if(t.properties.kind===`date`){var i;return((i=t.properties.date)==null?void 0:i.fullDate)??r}if(t.properties.kind===`dropDownList`||t.properties.kind===`comboBox`){var a;return((a=t.properties.listItems)==null||(a=a.find(e=>e.displayText===r))==null?void 0:a.value)??r}return[`text`,`richText`].includes(t.properties.kind)?r:void 0}var Jb=class{constructor(){T(this,`skipNextObservers`,!1),T(this,`lastReturnValue`,void 0),T(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},Yb=class extends t.Subject{constructor(...e){super(...e),T(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>(e.priority??0)-(t.priority??0)),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new Jb;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function Xb(e){return new t.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let Zb=(0,i.createIdentifier)(`core.resource-manager.service`),Qb={[n.UnitRole.Editor]:`Editor`,[n.UnitRole.Owner]:`Owner`,[n.UnitRole.Reader]:`Reader`,[n.UnitRole.UNRECOGNIZED]:`UNRECOGNIZED`},$b=e=>e?{userID:`${Qb[e]}_${J(8)}`,name:Qb[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},ex=(e,t)=>e.startsWith(Qb[t]);var tx=class extends k{constructor(...e){super(...e),T(this,`_model`,/* @__PURE__ */ new Map),T(this,`_userChange$`,new t.Subject),T(this,`userChange$`,this._userChange$.asObservable()),T(this,`_currentUser$`,new t.BehaviorSubject($b())),T(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let nx=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,T(this,`_permissionMap`,/* @__PURE__ */ new Map([])),T(this,`_permissionOverrides`,/* @__PURE__ */ new Map),T(this,`_cfgEnableObjInherit`,!1),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser($b(n.UnitRole.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?ex(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[n.UniverType.UNIVER_SHEET,n.UniverType.UNIVER_DOC,n.UniverType.UNIVER_SLIDE,n.UniverType.UNIVER_BOARD],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=J(8),{objectType:r,selectRangeObject:i,worksheetObject:a}=e,o=i||a,s={objectType:r,unitID:(o==null?void 0:o.unitID)||``,name:(o==null?void 0:o.name)||``,strategies:[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}],selectRangeObject:i};return this._permissionMap.set(t,s),t}async allowed(e){let{objectID:t,actions:r}=e,i=this._permissionMap.get(t);return i?r.map(e=>{let r=`${t}:${e}`;if(this._permissionOverrides.has(r))return{action:e,allowed:this._permissionOverrides.get(r)};let a=i.strategies.find(t=>t.action===e);return a?{action:e,allowed:this._getRole(a.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}}):r.map(e=>({action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],r=[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}];return e.objectIDs.forEach(i=>{let a=this._permissionMap.get(i),o=(a==null?void 0:a.strategies)||r,s={objectID:i,unitID:e.unitID,objectType:(a==null?void 0:a.objectType)||3,name:(a==null?void 0:a.name)||``,shareOn:!1,shareRole:n.UnitRole.Owner,shareScope:-1,scope:{read:n.ObjectScope.AllCollaborator,edit:n.ObjectScope.AllCollaborator},creator:$b(n.UnitRole.Owner),strategies:o.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${i}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let r=o.find(t=>t.action===e);return r?{action:e,allowed:this._getRole(r.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}})};t.push(s)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:r}=e,i=this._permissionMap.get(t);i&&r&&(i.strategies=r.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,i),r.forEach(e=>{e.role===n.UnitRole.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===n.UnitRole.Owner||e.role===n.UnitRole.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}setCfgEnableObjInherit(e){this._cfgEnableObjInherit=e}getCfgEnableObjInherit(){return this._cfgEnableObjInherit}};nx=ma([V(0,Zb),V(1,(0,i.Inject)(tx))],nx);let rx=(0,i.createIdentifier)(`IAuthzIoIoService`),ix=(0,i.createIdentifier)(`univer.confirm-service`);var ax=class{constructor(){T(this,`confirmOptions$`,new t.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let ox=`FOCUSING_UNIT`,sx=`FOCUSING_SHEET`,cx=`FOCUSING_DOC`,lx=`FOCUSING_SLIDE`,ux=`FOCUSING_BOARD`,dx=`EDITOR_ACTIVATED`,fx=`FOCUSING_FX_BAR_EDITOR`,px=`FOCUSING_SHAPE_TEXT_EDITOR`;var mx=class extends k{constructor(...e){super(...e),T(this,`_error$`,new t.Subject),T(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emitPermissionDenied(e,t=[]){this._error$.next({errorKey:`Permission denied.`,code:`PERMISSION_DENIED`,permissionTarget:JSON.stringify([e,[...new Set(t)].sort()])})}emit(e){this._error$.next({errorKey:e})}};let hx=/* @__PURE__ */ function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),gx=/* @__PURE__ */ function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),_x=(0,i.createIdentifier)(`core.image-io.service`),vx=(0,i.createIdentifier)(`core.url-image.service`),yx=Object.freeze({iterativeCalculation:!1,maxIterations:100,maxChange:.001});function bx(e){let t=yx;return{iterativeCalculation:typeof(e==null?void 0:e.iterativeCalculation)==`boolean`?e.iterativeCalculation:t.iterativeCalculation,maxIterations:Number.isInteger(e==null?void 0:e.maxIterations)&&e.maxIterations>=1&&e.maxIterations<=32767?e.maxIterations:t.maxIterations,maxChange:typeof(e==null?void 0:e.maxChange)==`number`&&Number.isFinite(e.maxChange)&&e.maxChange>0?e.maxChange:t.maxChange}}function xx(e=``,t=`zhCN`,n=``){return{id:e,sheetOrder:[],name:n,appVersion:ze,locale:t,dateSystem:`date1900`,styles:{},sheets:{},resources:[]}}var Sx=class{constructor(e={}){T(this,`_styles`,void 0),T(this,`_cacheMap`,new xd(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=J(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&z.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(z.diffValue(t[n],e))return n;return null}};let Cx=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Kd.equals(t,e))),wx=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Kd.equals(e.range,r.range)}),Tx={t:0,b:2,l:2,r:2},Ex=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function Dx(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=0,verticalAlign:s=0,wrapStrategy:c=0,cellValueType:l}=n,u=(a==null?void 0:a.t)??Tx.t,d=(a==null?void 0:a.r)??Tx.r,f=(a==null?void 0:a.b)??Tx.b,p=(a==null?void 0:a.l)??Tx.l,{vertexAngle:m,centerAngle:h}=Ix(i);return new fy({id:`d`,body:{dataStream:`${e}\r
|
|
23
|
-
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphId:
|
|
24
|
-
`)===r)}var Gx=class e{constructor(e,t,n){this._deps=n,T(this,`_range`,void 0),T(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=z.numToWord(n+1)+(e+1),a=z.numToWord(r+1)+(t+1)):(i=z.numToWord(r+1)+(t+1),a=z.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||Y.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).clone();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||Y.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?Wx(`ul`,t.body)===1?{s:1}:{s:0}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?Wx(`st`,t.body)===1?{s:1}:{s:0}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(Wx(`it`,t.body)===1):this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(Wx(`bl`,t.body)===1):this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.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(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return+(this.getWrapStrategy()===3)}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||Y[e]}))}};T(Gx,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===3?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===2?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===1?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});var Kx=class{constructor(e,t,n){this._config=e,this._viewModel=t,T(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e??{h:this._config.defaultRowHeight,hd:0},r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=Rx(r.defaultRowHeight,24,!1),a=0;for(let r=0;r<t;r++){let{ia:t,ah:o,h:s=i}=n[r+e]||{hd:0,h:i};a+=(t==null||t===1)&&Lx(o,!1)?o:Rx(s,0)}return a}setRowHeight(e,t){if(!Lx(t))return;let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];if(t!=null&&Object.keys(t).length>0){this._rowData[r]={...t};let e=this._rowData[r];e.h!==void 0&&!Lx(e.h)&&(e.h=0),e.ah!==void 0&&!Lx(e.ah)&&delete e.ah}}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getRowRawVisible(e){let t=this.getRow(e);return!t||t.hd!==1}getSize(){return nu(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}},qx=class extends k{constructor(e){super(),T(this,`_cellCache`,/* @__PURE__ */ new Map),T(this,`_rowCache`,/* @__PURE__ */ new Map),T(this,`_columnCache`,/* @__PURE__ */ new Map),T(this,`_hasRow`,!1),T(this,`_hasColumn`,!1),T(this,`_hasAll`,!1),T(this,`_allIndex`,-1),T(this,`_mergeData`,void 0),T(this,`_rangeMap`,new xd(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===1?this._createRowCache(n,t):e===2?this._createColumnCache(n,t):e===3?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r??(r=/* @__PURE__ */ new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Kd.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},Jx=class extends k{constructor(e){super(),this.getRawCell=e,T(this,`_cellContentInterceptor`,null),T(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,3,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,2):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,1):this.getRawCell(e,t)}getRowFiltered(e){var t;return((t=this._rowFilteredInterceptor)==null?void 0:t.getRowFiltered(e))??!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,D(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,D(()=>this._rowFilteredInterceptor=null)}};let Yx={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var Xx=class{constructor(e,t,n){this.unitId=e,this._styles=n,T(this,`_sheetId`,void 0),T(this,`_snapshot`,void 0),T(this,`_cellData`,void 0),T(this,`_rowManager`,void 0),T(this,`_columnManager`,void 0),T(this,`_viewModel`,void 0),T(this,`_spanModel`,void 0),T(this,`_isRowStylePrecedeColumnStyle`,!0),T(this,`_getCellHeight`,void 0),this._snapshot=Hx(t);let{columnData:r,rowData:i,cellData:a}=this._snapshot;this._sheetId=this._snapshot.id??J(6),this._cellData=new du(a),this._viewModel=new Jx((e,t)=>this.getCellRaw(e,t)),this._rowManager=new Kx(this._snapshot,this._viewModel,i),this._columnManager=new Ux(this._snapshot,r),this._spanModel=new qx(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,D(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this.getRowHeight(e)}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return n??this._isRowStylePrecedeColumnStyle?ae(r,a,i,o==null?void 0:o.themeStyle,s):ae(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return r??this._isRowStylePrecedeColumnStyle?ae(i,o,a,n==null?void 0:n.themeStyle,s):ae(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=`raw`){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new du;return af(e,n,t,r).forEach((e,t)=>{let n;if(i===`raw`)n=this.getCellRaw(e,t);else if(i===`intercepted`)n=this.getCell(e,t);else if(i===`both`){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;jx(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;af(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new Gx(this,e,{getStyles:()=>this._styles}):new Gx(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}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===0?0:1}getHiddenState(){return this._snapshot.hidden}setHiddenState(e){this._snapshot.hidden=e}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn||c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=Yx){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...Yx,...n},s,c=`document`,l=Ox(t),u=o?Y.tr:l.textRotation||Y.tr,d=l.horizontalAlign||Y.ht,f=l.verticalAlign||Y.vt,p=l.wrapStrategy||Y.tb,m=l.paddingData||Tx;if(e.f&&a)s=Dx(e.f.toString(),{},{verticalAlign:f}),d=Y.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=Ix(u);s=this._updateConfigAndGetDocumentModel(i?z.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=kx(t);c=Nx(n).fontCache;let r=Zx(e);e.t===4&&a&&(r=`'${r}`),s=Dx(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Ax(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new fy(e)}getBlankCellDocumentModel(e,t,n){var r;let i=this.getComposedCellStyleByCellData(t,n,e),a=kx(i),o=this.getCellDocumentModel(e,i,{ignoreTextRotation:!0});if(o!=null)return o.documentModel??=Dx(``,a),o;let s=Ox(i),c=Y.tr,l=s.horizontalAlign??Y.ht,u=s.verticalAlign??Y.vt,d=s.wrapStrategy??Y.tb,f=s.paddingData??Tx,p=Nx(a).fontCache;return{documentModel:Dx(``,a),fontString:p,textRotation:c,wrapStrategy:d,verticalAlign:u,horizontalAlign:l,paddingData:f,fill:i==null||(r=i.bg)==null?void 0:r.rgb}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function Zx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===3?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===3?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function Qx(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;if(r==null)return``;if(e.t===3){if(typeof r==`string`)return r.toUpperCase();if(typeof r==`number`)return r?`TRUE`:`FALSE`}return typeof r==`boolean`?r?`TRUE`:`FALSE`:String(r)}function $x(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function eS(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let tS=class extends M{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},r){super(),this._logService=r,T(this,`type`,n.UniverType.UNIVER_SHEET),T(this,`_sheetCreated$`,new t.Subject),T(this,`sheetCreated$`,this._sheetCreated$.asObservable()),T(this,`_sheetDisposed$`,new t.Subject),T(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),T(this,`_activeSheet$`,new t.BehaviorSubject(null)),T(this,`activeSheet$`,this._activeSheet$.asObservable()),T(this,`_worksheets`,void 0),T(this,`_styles`,void 0),T(this,`_snapshot`,void 0),T(this,`_unitId`,void 0),T(this,`_count`,void 0),T(this,`_name$`,void 0),T(this,`name$`,void 0);let i=xx();z.isEmptyObject(e)?this._snapshot=i:(this._snapshot=z.commonExtend(i,e),e.dateSystem==null?delete this._snapshot.dateSystem:e.dateSystem!==`date1900`&&e.dateSystem!==`date1904`&&(this._logService.warn(`[Workbook]`,`Unknown date system "${String(e.dateSystem)}"; falling back to Excel 1900.`),this._snapshot.dateSystem=`date1900`)),this._snapshot.calculationSettings=bx(e.calculationSettings);let{styles:a}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=J(6)),this._unitId=this._snapshot.id,this._styles=new Sx(a),this._count=1,this._worksheets=/* @__PURE__ */ new Map,this._name$=new t.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getCalculationSettings(){return bx(this._snapshot.calculationSettings)}setCalculationSettings(e){this._snapshot.calculationSettings={...e}}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getDateSystem(){return this._snapshot.dateSystem===`date1904`?`date1904`:`date1900`}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new Xx(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=/* @__PURE__ */ new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==1)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(e=!0){return this.getSheets().filter(e=>e.isSheetHidden()===1).filter(t=>e||t.getHiddenState()!==2).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.isSheetHidden()!==1).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(z.isEmptyObject(n)){let e=J();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new Xx(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};tS=ma([V(1,da)],tS);let nS=(0,i.createIdentifier)(`univer.current`),rS=class extends k{constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._logService=r,T(this,`_unitsByType`,/* @__PURE__ */ new Map),T(this,`_unitCreateOptions`,/* @__PURE__ */ new Map),T(this,`_createHandler`,void 0),T(this,`_ctorByType`,/* @__PURE__ */ new Map),T(this,`_currentUnits`,/* @__PURE__ */ new Map),T(this,`_currentUnits$`,new t.BehaviorSubject(this._currentUnits)),T(this,`currentUnits$`,this._currentUnits$.asObservable()),T(this,`_unitAdded$`,new t.Subject),T(this,`unitAdded$`,this._unitAdded$.asObservable()),T(this,`_unitDisposed$`,new t.Subject),T(this,`unitDisposed$`,this._unitDisposed$.asObservable()),T(this,`_focused$`,new t.BehaviorSubject(null)),T(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear(),this._unitCreateOptions.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}__getCtorByType(e){return this._ctorByType.get(e)}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,t.map)(t=>t.get(e)??null),(0,t.distinctUntilChanged)())}getCurrentUnitOfType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.get(t[1])!==t[0]&&(this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits))}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,t.filter)(t=>t.unit.type===e))}__addUnit(e,t){this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let n=e.type;this._unitsByType.has(n)||this._unitsByType.set(n,[]);let r=this._unitsByType.get(n),i=e.getUnitId();if(r.findIndex(e=>e.getUnitId()===i)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${i}.`);r.push(e),t&&this._unitCreateOptions.set(i,{...t}),this._unitAdded$.next({unit:e,options:t}),((t==null?void 0:t.makeCurrent)??!0)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,t.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getUnitCreateOptions(e){return this._unitCreateOptions.get(e)??null}getAllUnitsForType(e){return this._unitsByType.get(e)??[]}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){var t,r;this._focused$.getValue()!==e&&(this._focused$.next(e),this.focused instanceof tS?(this._contextService.setContextValue(ox,!0),this._contextService.setContextValue(cx,!1),this._contextService.setContextValue(sx,!0),this._contextService.setContextValue(lx,!1),this._contextService.setContextValue(ux,!1),this.setCurrentUnitForType(e)):this.focused instanceof fy?(this._contextService.setContextValue(ox,!0),this._contextService.setContextValue(cx,!0),this._contextService.setContextValue(sx,!1),this._contextService.setContextValue(lx,!1),this._contextService.setContextValue(ux,!1),this.setCurrentUnitForType(e)):((t=this.focused)==null?void 0:t.type)===n.UniverType.UNIVER_SLIDE?(this._contextService.setContextValue(ox,!0),this._contextService.setContextValue(cx,!1),this._contextService.setContextValue(sx,!1),this._contextService.setContextValue(lx,!0),this._contextService.setContextValue(ux,!1),this.setCurrentUnitForType(e)):((r=this.focused)==null?void 0:r.type)===n.UniverType.UNIVER_BOARD?(this._contextService.setContextValue(ox,!0),this._contextService.setContextValue(cx,!1),this._contextService.setContextValue(sx,!1),this._contextService.setContextValue(lx,!1),this._contextService.setContextValue(ux,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(ox,!1),this._contextService.setContextValue(cx,!1),this._contextService.setContextValue(sx,!1),this._contextService.setContextValue(lx,!1),this._contextService.setContextValue(ux,!1)))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:n.UniverType.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),this._unitCreateOptions.delete(e),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitOfType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){this._focused$.getValue()===e&&this.focusUnit(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};rS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,ca),V(2,(0,i.Inject)(da))],rS);let iS=/* @__PURE__ */ function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),aS={0:`Starting`,1:`Ready`,2:`Rendered`,3:`Steady`};var oS=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${aS[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let sS=class extends k{constructor(e){super(),this._logService=e,T(this,`_lifecycle$`,new t.BehaviorSubject(0)),T(this,`lifecycle$`,this._lifecycle$.asObservable()),T(this,`_lock`,!1),this._reportProgress(0)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,t.firstValueFrom)(this.lifecycle$.pipe((0,t.filter)(t=>t>=e),Ta(t=>t===e),(0,t.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new oS(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,t.merge)(cS(this.stage),this._lifecycle$.pipe((0,t.skip)(1))).pipe(Ta(e=>e===3))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${aS[e]}".`)}};sS=ma([V(0,da)],sS);function cS(e){switch(e){case 0:return(0,t.of)(0);case 1:return(0,t.of)(0,1);case 2:return(0,t.of)(0,1,2);default:return(0,t.of)(0,1,2,3)}}let lS=(0,i.createIdentifier)(`ILocalStorageService`);var uS=class extends k{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),T(this,`_currentLocale$`,new t.BehaviorSubject(`zhCN`)),T(this,`currentLocale$`,this._currentLocale$.asObservable()),T(this,`_direction$`,new t.BehaviorSubject(`ltr`)),T(this,`direction$`,this._direction$.asObservable()),T(this,`_locales`,null),T(this,`localeChanged$`,new t.Subject),T(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}return e}),this.disposeWithMe(D(()=>{this._locales=null,this._currentLocale$.complete(),this._direction$.complete(),this.localeChanged$.complete()}))}load(e){this._locales=na(this._locales??{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}setDirection(e){this._direction$.next(e)}getDirection(){return this._direction$.value}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let dS=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:0,mentions:[{objectType:0,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};dS=ma([V(0,(0,i.Inject)(tx))],dS);let fS=(0,i.createIdentifier)(`univer.service.mention-io`);var pS=class extends k{constructor(e,n,r,i){super(),this._objectTypes=i,T(this,`_rules`,/* @__PURE__ */ new Map),T(this,`_changes`,new t.Subject),T(this,`changed$`,this._changes.asObservable()),this.disposeWithMe(e.registerPluginResource({pluginName:n,businesses:[r],toJson:e=>JSON.stringify(this.getRules(e)),parseJson:e=>{let t=JSON.parse(e);if(!Array.isArray(t)||t.some(e=>!e||typeof e.objectId!=`string`||typeof e.permissionId!=`string`||!e.permissionId||!this._objectTypes.includes(e.objectType)))throw Error(`Invalid object permission resource.`);return t},onLoad:(e,t)=>{this._rules.set(e,new Map(t.map(e=>[this._key(e.objectType,e.objectId),z.deepClone(e)]))),this._changes.next(e)},onUnLoad:e=>{this._rules.delete(e),this._changes.next(e)}})),this.disposeWithMe(()=>{this._rules.clear(),this._changes.complete()})}getRules(e){var t;return[...((t=this._rules.get(e))==null?void 0:t.values())??[]].map(e=>z.deepClone(e))}getRule(e,t,n){var r;let i=(r=this._rules.get(e))==null?void 0:r.get(this._key(t,n));return i&&z.deepClone(i)}setRule(e,t,n,r){return this.setRules(e,[{objectId:n,objectType:t,rule:r}])}setRules(e,t){if(typeof e!=`string`||!e||!Array.isArray(t)||t.length===0)return!1;let n=/* @__PURE__ */ new Set;for(let e of t){if(!e)return!1;let{objectId:t,objectType:r,rule:i}=e,a=this._key(r,t);if(typeof t!=`string`||!t||!this._objectTypes.includes(r)||n.has(a)||i!==null&&(!i||i.objectId!==t||i.objectType!==r||typeof i.permissionId!=`string`||!i.permissionId))return!1;n.add(a)}let r=z.deepClone(t),i=this._rules.get(e)??/* @__PURE__ */ new Map;for(let{objectId:e,objectType:t,rule:n}of r)n?i.set(this._key(t,e),n):i.delete(this._key(t,e));return this._rules.set(e,i),this._changes.next(e),!0}_key(e,t){return`${e}/${t}`}};let mS=(0,i.createIdentifier)(`univer.undo-redo.service`);var hS=class{dispose(){}async dispatchToHandlers(){return!1}};let gS=`univer.command.redo`,_S=`univer.command.undo`,vS=new class extends hS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,_S)}handler(e){let t=e.get(mS),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.undoMutations,r).result?(t.popUndoToRedo(),!0):!1}},yS=new class extends hS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,gS)}handler(e){let t=e.get(mS),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.redoMutations,r).result?(t.popRedoToUndo(),!0):!1}},bS=class extends k{constructor(e,n,r,i){super(),this._univerInstanceService=e,this._commandService=n,this._contextService=r,T(this,`undoRedoStatus$`,void 0),T(this,`_undoRedoStatus$`,new t.BehaviorSubject({undos:0,redos:0})),T(this,`_undoStacks`,/* @__PURE__ */ new Map),T(this,`_redoStacks`,/* @__PURE__ */ new Map),T(this,`_batchingStatus`,/* @__PURE__ */ new Map),T(this,`_activeGroups`,/* @__PURE__ */ new Map),T(this,`_itemGroups`,/* @__PURE__ */ new WeakMap),T(this,`_historyLimit`,void 0),this._historyLimit=i.getConfig(`undoRedo.historyLimit`)??50,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(vS)),this.disposeWithMe(this._commandService.registerCommand(yS)),this.disposeWithMe(D(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(D(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus())))}getUndoRedoStatus(e){var t,n;return{undos:((t=this._undoStacks.get(e))==null?void 0:t.length)??0,redos:((n=this._redoStacks.get(e))==null?void 0:n.length)??0}}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0),i=this._historyLimit;n.length=0;let a=this._activeGroups.get(t),o=this._pitchUndoElement(t);a?o&&this._itemGroups.get(o)===a.id?a.mode===`replace`?o.redoMutations=e.redoMutations:(o.redoMutations.push(...e.redoMutations),o.undoMutations.unshift(...e.undoMutations)):(s(e),this._itemGroups.set(e,a.id)):this._batchingStatus.has(e.unitID)?this._batchingStatus.get(e.unitID)===0||!o?(s(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(o,e):s(e);function s(e){r.push(e),r.length>i&&r.splice(0,1)}this._updateStatus()}beginUndoRedoGroup(e,t,n=`replace`){if(this._activeGroups.has(e)||this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot group undo redo twice at the same time!`);let r={id:t,mode:n};return this._activeGroups.set(e,r),D(()=>{this._activeGroups.get(e)===r&&this._activeGroups.delete(e)})}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(this._itemGroups.delete(e),e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._itemGroups.delete(e),this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),this._itemGroups.delete(i),Sa(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e)||this._activeGroups.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,0),D(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(sx),r=this._contextService.getContextValue(fx),i=this._contextService.getContextValue(px),a=this._contextService.getContextValue(dx);if(a&&i){var o;return((o=this._univerInstanceService.getCurrentUnitOfType(n.UniverType.UNIVER_DOC))==null?void 0:o.getUnitId())??``}if(t){if(r&&a)e=Dp;else if(a)e=Ep;else{var s;e=((s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())??``}}else{var c;e=((c=this._univerInstanceService.getFocusedUnit())==null?void 0:c.getUnitId())??``}return e}};bS=ma([V(0,nS),V(1,_a),V(2,ca),V(3,oa)],bS);let xS=/* @__PURE__ */ function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),SS=(0,i.createIdentifier)(`univer.permission-service`),CS={[n.UnitObject.Document]:n.UnitObject.Document,[n.UnitObject.DocumentSection]:n.UnitObject.Document,[n.UnitObject.DocumentParagraph]:n.UnitObject.Document,[n.UnitObject.DocumentEntity]:n.UnitObject.Document,[n.UnitObject.Slide]:n.UnitObject.Slide,[n.UnitObject.SlidePage]:n.UnitObject.Slide,[n.UnitObject.SlideElement]:n.UnitObject.Slide,[n.UnitObject.SlideMaster]:n.UnitObject.Slide,[n.UnitObject.Base]:n.UnitObject.Base,[n.UnitObject.BaseTable]:n.UnitObject.Base,[n.UnitObject.BaseField]:n.UnitObject.Base,[n.UnitObject.BaseRecord]:n.UnitObject.Base,[n.UnitObject.BaseView]:n.UnitObject.Base,[n.UnitObject.BaseDashboard]:n.UnitObject.Base,[n.UnitObject.Board]:n.UnitObject.Board,[n.UnitObject.BoardElement]:n.UnitObject.Board},wS=class extends k{constructor(e,r,i,a,o,s){super(),this._injector=e,this._permissions=r,this._logService=i,this._users=a,this._config=o,this._commands=s,T(this,`_models`,/* @__PURE__ */ new Map),T(this,`_initialized`,/* @__PURE__ */ new Set),T(this,`_policies`,/* @__PURE__ */ new Map),T(this,`_generations`,/* @__PURE__ */ new Map),T(this,`_nextGeneration`,0),T(this,`_revision`,new t.BehaviorSubject(0)),T(this,`changed$`,this._revision.asObservable()),T(this,`_unitChanges`,new t.Subject),T(this,`unitChanges$`,this._unitChanges.asObservable()),this.disposeWithMe(this._permissions.permissionPointUpdate$.subscribe(e=>{e.subType===n.UnitAction.Edit&&CS[e.type]===e.type&&this._revision.next(this._revision.value+1)})),this.disposeWithMe(()=>{this._initialized.clear(),this._policies.clear(),this._generations.clear(),this._revision.complete(),this._unitChanges.complete()})}get _authz(){return this._injector.get(rx)}registerRuleModel(e,t,r,i){if(this._models.has(e))throw Error(`Object permission rule model already registered.`);this._models.set(e,{model:t,mutationId:r,batchMutationId:i});let a=t.changed$.subscribe(e=>{this._generations.delete(e),this._policies.delete(e),t.getRules(e).forEach(t=>{if(!this.supports({unitId:e,objectId:t.objectId,objectType:t.objectType}))return;let r=`${t.objectType}.${n.UnitAction.Edit}_${e}_${t.objectId}`;this._permissions.getPermissionPoint(r)?this._permissions.updatePermissionPoint(r,!1):this._permissions.addPermissionPoint({id:r,type:t.objectType,subType:n.UnitAction.Edit,value:!1,status:`init`,unitId:e,objectId:t.objectId})}),this._revision.next(this._revision.value+1),this._initialized.has(e)&&this.refreshUnit(e).catch(e=>this._logService.error(e))});return this.disposeWithMe(D(()=>{a.unsubscribe(),this._models.delete(e)}))}_getRule(e){var t;return(t=this._models.get(CS[e.objectType]))==null?void 0:t.model.getRule(e.unitId,e.objectType,e.objectId)}_getAuthzId(e){var t;return e.objectId===e.unitId?e.unitId:(t=this._getRule(e))==null?void 0:t.permissionId}initializeUnit(e){if(!this.supports(e)||this._initialized.has(e.unitId))return;this._initialized.add(e.unitId);let t=[];this._permissions.getAllPermissionPoint().forEach(n=>{n.subscribe(n=>{`unitId`in n&&n.unitId===e.unitId&&t.push(n.id)}).unsubscribe()}),t.forEach(e=>this._permissions.updatePermissionPoint(e,!1)),this.refreshUnit(e.unitId).catch(e=>{this._logService.error(e)})}supports(e){var t;return((t=this._config.getConfig(`objectPermissionTypes`))==null?void 0:t.includes(e.objectType))===!0&&this._models.has(CS[e.objectType])}getPolicies(e){return this._policies.get(e)??[]}hasPolicy(e){var t,r;let i=this.getPolicies(e.unitId).find(t=>t.objectID===e.objectId&&t.objectType===e.objectType);return!!i&&(((t=i.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf||((r=i.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator||i.strategies.some(e=>e.role===n.UnitRole.Owner))}canView(e){var t;let r=CS[e.objectType];return this.supports(e)&&r!==void 0&&((t=this._permissions.getPermissionPoint(`${r}.${n.UnitAction.Edit}_${e.unitId}`))==null?void 0:t.value)===!0}async canManage(e){if(!this.supports(e))return!1;let t=await this._getPolicy(e);if(!this._getRule(e)&&e.objectId!==e.unitId){let t=CS[e.objectType];return t!==void 0&&this._allowed({...e,objectId:e.unitId,objectType:t},n.UnitAction.CreatePermissionObject)}return(e.objectId===e.unitId||!!t)&&this._canChangeRule(e,t,n.UnitAction.ManageCollaborator)}async canDelete(e){if(!this.supports(e)||e.objectId===e.unitId)return!1;let t=await this._getPolicy(e);return!!t&&this._canChangeRule(e,t,n.UnitAction.Delete)}async remove(e){var t;let n=(t=this._getRule(e))==null?void 0:t.permissionId;if(!await this.canDelete(e))throw Error(`Object permission deletion denied.`);await this._commitRule(e,null,n),await this.refreshUnit(e.unitId)}async _commitRule(e,t,n){let r=this._models.get(CS[e.objectType]);if(!r)throw Error(`Object permission rule model is not registered.`);let i=this._getRule(e)??null;if((i==null?void 0:i.permissionId)!==n)throw Error(`Object permission binding changed during the request.`);let a={id:r.mutationId,params:{...e,rule:t}},o={id:r.mutationId,params:{...e,rule:i}};if(!await this._commands.executeCommand(a.id,a.params))throw Error(`Could not update the object permission binding.`);this._injector.get(mS).pushUndoRedo({unitID:e.unitId,redoMutations:[a],undoMutations:[o]})}async _getPolicy(e){let t=this._getAuthzId(e);if(t)return(await this._authz.list({unitID:e.unitId,objectIDs:[t],actions:[]})).find(n=>n.unitID===e.unitId&&n.objectID===t&&n.objectType===e.objectType)}async _allowed(e,t){let n=this._getAuthzId(e);return n?(await this._authz.allowed({unitID:e.unitId,objectID:n,objectType:e.objectType,actions:[t]})).some(e=>e.action===t&&e.allowed===!0):!1}async _canChangeRule(e,t,n){var r;if(await this._allowed(e,n))return!0;let i=t==null||(r=t.creator)==null?void 0:r.userID;return!!i&&i===this._users.getCurrentUser().userID}async read(e){var t,r;let i=this._getAuthzId(e);if(!i)return{edit:`all`,collaborators:[],strategies:[]};let[a,o]=await Promise.all([this._getPolicy(e),e.objectId===e.unitId?[]:this._authz.listCollaborators({unitID:e.unitId,objectID:i})]),s=`all`;return(a==null||(t=a.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf?s=`owner`:(a==null||(r=a.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator?s=`members`:a!=null&&a.strategies.some(e=>e.action===n.UnitAction.Edit&&e.role===n.UnitRole.Owner)&&(s=`owner`),{edit:s,collaborators:o,strategies:(a==null?void 0:a.strategies)??[]}}async setPoint(e,t,r){if(!this.supports(e)){this._permissions.getPermissionPoint(t.id)||this._permissions.addPermissionPoint(t),this._permissions.updatePermissionPoint(t.id,r);return}this._assertSupported(e);let i=await this.read(e);i.strategies=i.strategies.filter(e=>e.action!==t.subType),i.strategies.push({action:t.subType,role:r?n.UnitRole.Editor:n.UnitRole.Owner}),t.subType===n.UnitAction.Edit&&(i.edit=r?`all`:`owner`),await this.save(e,i)}async save(e,t){var n;let r=(n=this._getRule(e))==null?void 0:n.permissionId,i=await this._writePolicy(e,t,r);i&&await this._commitRule(e,i,r),await this.refreshUnit(e.unitId)}async _writePolicy(e,t,r){var i,a;if(this._assertSupported(e),!await this.canManage(e))throw Error(`Object permission management denied.`);if(e.objectId===e.unitId&&t.edit===`members`)throw Error(`File membership must be managed through the sharing service.`);if(t.edit===`members`&&!t.collaborators.length)throw Error(`Select at least one collaborator.`);let o=await this._getPolicy(e),s=t.strategies.filter(e=>e.action!==n.UnitAction.Edit);s.push({action:n.UnitAction.Edit,role:t.edit===`owner`?n.UnitRole.Owner:n.UnitRole.Editor});let c=n.ObjectScope.AllCollaborator;t.edit===`members`?c=n.ObjectScope.SomeCollaborator:t.edit===`owner`&&(c=n.ObjectScope.OneSelf);let l={read:(o==null||(i=o.scope)==null?void 0:i.read)??n.ObjectScope.AllCollaborator,edit:c};if(((a=this._getRule(e))==null?void 0:a.permissionId)!==r)throw Error(`Object permission binding changed during the request.`);let u=this._getAuthzId(e);if(u)await this._authz.update({unitID:e.unitId,objectID:u,objectType:e.objectType,name:(o==null?void 0:o.name)??e.objectId,share:void 0,strategies:s,scope:l,collaborators:e.objectId===e.unitId?void 0:{collaborators:t.edit===`members`?t.collaborators:[]}});else{let r={unitID:e.unitId,name:e.objectId,strategies:s,scope:l,collaborators:t.edit===`members`?t.collaborators:[]},i={objectType:e.objectType};switch(CS[e.objectType]){case n.UnitObject.Document:i.documentObject=r;break;case n.UnitObject.Slide:i.slideObject=r;break;case n.UnitObject.Base:i.baseObject=r;break;case n.UnitObject.Board:i.boardObject=r;break;default:throw Error(`Unsupported object permission type.`)}if(u=await this._authz.create(i),!u)throw Error(`Authz did not return a permission ID.`);return{objectId:e.objectId,objectType:e.objectType,permissionId:u}}}async saveMany(e){let t=e[0],n=t&&this._models.get(CS[t.objectType]);if(!t||!(n!=null&&n.batchMutationId)||e.some(e=>e.unitId!==t.unitId||e.objectId===t.unitId||CS[e.objectType]!==CS[t.objectType]||!this.supports(e))||new Set(e.map(e=>`${e.objectType}/${e.objectId}`)).size!==e.length)throw Error(`Invalid object permission batch.`);let r={succeeded:[],failed:[]},i=[];for(let t of e){let e=this._getRule(t)??null;try{let n;if(t.policy===null){if(!await this.canDelete(t))throw Error(`Object permission deletion denied.`);n=null}else n=await this._writePolicy(t,t.policy,e==null?void 0:e.permissionId);if(n===void 0){var a;if(((a=this._getRule(t))==null?void 0:a.permissionId)!==(e==null?void 0:e.permissionId))throw Error(`Object permission binding changed during the request.`);r.succeeded.push(t.objectId)}else i.push({target:t,rule:n,previous:e})}catch(e){r.failed.push({objectId:t.objectId,error:e})}}let o=i.filter(({target:e,previous:t})=>{var n;return((n=this._getRule(e))==null?void 0:n.permissionId)===(t==null?void 0:t.permissionId)||(r.failed.push({objectId:e.objectId,error:/* @__PURE__ */ Error(`Object permission binding changed during the request.`)}),!1)});if(o.length){let e={unitId:t.unitId,rules:o.map(({target:e,rule:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))},i={unitId:t.unitId,rules:o.map(({target:e,previous:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))};try{if(!await this._commands.executeCommand(n.batchMutationId,e))throw Error(`Could not update the object permission bindings.`);this._injector.get(mS).pushUndoRedo({unitID:t.unitId,redoMutations:[{id:n.batchMutationId,params:e}],undoMutations:[{id:n.batchMutationId,params:i}]}),r.succeeded.push(...o.map(({target:e})=>e.objectId))}catch(e){r.failed.push(...o.map(({target:t})=>({objectId:t.objectId,error:e})))}}try{await this.refreshUnit(t.unitId)}catch(e){r.refreshError=e}return r}async refreshUnit(e){if(this._disposed)return;let t=[...this._models.values()].flatMap(({model:t})=>t.getRules(e)),r=new Map(t.map(e=>[`${e.objectType}/${e.objectId}`,e])),i=/* @__PURE__ */ new Map,a=(t,n,r,a)=>{if(!this.supports({unitId:e,objectId:r,objectType:n}))return;let o=`${n}/${t}`,s=i.get(o);i.set(o,{unitID:e,objectID:t,objectType:n,targetId:r,actions:[.../* @__PURE__ */ new Set([...(s==null?void 0:s.actions)??[],...a])]})},o=[];t.forEach(e=>a(e.permissionId,e.objectType,e.objectId,[n.UnitAction.Edit])),this._permissions.getAllPermissionPoint().forEach(t=>{t.subscribe(t=>{if(!(`unitId`in t)||t.unitId!==e)return;let n=`objectId`in t&&typeof t.objectId==`string`?t.objectId:e,i=r.get(`${t.type}/${n}`);n===e?a(e,t.type,e,[t.subType]):i?a(i.permissionId,t.type,n,[t.subType]):this.supports({unitId:e,objectId:n,objectType:t.type})&&o.push(t.id)}).unsubscribe()}),o.forEach(e=>this._permissions.updatePermissionPoint(e,!0));let s=++this._nextGeneration;this._generations.set(e,s);let c=[...i.values()];c.length&&this._initialized.add(e);let l=[],u=[];for(let t=0;t<c.length;t+=100){let n=c.slice(t,t+100),r=await this._authz.list({unitID:e,objectIDs:n.map(e=>e.objectID),actions:[]});l.push(...r),n.forEach(e=>{let t=r.find(t=>t.objectID===e.objectID&&t.objectType===e.objectType);e.actions=[.../* @__PURE__ */ new Set([...e.actions,...(t==null?void 0:t.strategies.map(e=>e.action))??[]])]}),u.push(...await this._authz.batchAllowed(n.map(({targetId:e,...t})=>t)))}if(this._disposed||this._generations.get(e)!==s)return;let d=new Map(u.filter(t=>t.unitID===e).map(e=>[e.objectID,e])),f=new Map(l.filter(t=>t.unitID===e).map(e=>[`${e.objectType}/${e.objectID}`,e]));c.forEach(t=>{let n=d.get(t.objectID),r=f.get(`${t.objectType}/${t.objectID}`);[.../* @__PURE__ */ new Set([...t.actions,...(r==null?void 0:r.strategies.map(e=>e.action))??[]])].forEach(r=>{let i=`${t.objectType}.${r}_${e}${t.targetId===e?``:`_${t.targetId}`}`;this._permissions.getPermissionPoint(i)||this._permissions.addPermissionPoint({id:i,type:t.objectType,subType:r,status:`done`,value:!1,unitId:e,objectId:t.targetId}),this._permissions.updatePermissionPoint(i,(n==null?void 0:n.actions.some(e=>e.action===r&&e.allowed===!0))??!1)})}),this._policies.set(e,l.filter(t=>t.unitID===e).map(e=>{var t;return{...e,objectID:((t=i.get(`${e.objectType}/${e.objectID}`))==null?void 0:t.targetId)??e.objectID}})),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}clearUnit(e){this._initialized.delete(e),this._generations.delete(e),this._policies.delete(e),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}_assertSupported(e){if(!this.supports(e))throw Error(`Object permission management is not supported by this Authz provider.`)}};wS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,SS),V(2,da),V(3,(0,i.Inject)(tx)),V(4,oa),V(5,_a)],wS);var TS=class extends k{constructor(...e){super(...e),T(this,`_permissionPointMap`,/* @__PURE__ */ new Map),T(this,`_permissionPointUpdate$`,new t.Subject),T(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),T(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let n=e instanceof t.BehaviorSubject,r=n?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,n?e:new t.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=`done`,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){let n=e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()});return(0,t.combineLatest)(n).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=/* @__PURE__ */ new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function ES(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let DS=Symbol(`DependentOn`);var OS=class extends k{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};T(OS,`pluginName`,void 0),T(OS,`packageName`,Re),T(OS,`version`,ze),T(OS,`type`,n.UniverType.UNIVER_UNKNOWN);var kS=class{constructor(){T(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function AS(...e){return function(t){t[DS]=e}}let jS=class{constructor(e,t,r){this._injector=e,this._lifecycleService=t,this._logService=r,T(this,`_pluginRegistry`,/* @__PURE__ */ new Map),T(this,`_pluginStore`,new kS),T(this,`_seenPlugins`,/* @__PURE__ */ new Set),T(this,`_loadedPlugins`,/* @__PURE__ */ new Set),T(this,`_loadedPluginTypes`,/* @__PURE__ */ new Set([n.UniverType.UNIVER_UNKNOWN])),T(this,`_flushTimerByType`,/* @__PURE__ */ new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let r={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,r),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:i}=e;this._loadedPluginTypes.has(i)&&(i===n.UniverType.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(i))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:r,packageName:i,version:a}=e;if(t===n.UniverType.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!r)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(a&&a!==OS.version&&this._logService.error(`[PluginService]`,[`Plugin version mismatch.`,` plugin: "${r||e.name}"`,` package: "${i}"`,` plugin version: "${a}"`,` core version: "${OS.version}"`,` registration will continue, but please make sure all @univerjs packages use the same version.`].join(`
|
|
25
|
-
`)),this._seenPlugins.has(r))throw Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],r=/* @__PURE__ */ new Set,i=e=>{let{plugin:a}=e,{pluginName:o}=a;if(this._loadedPlugins.has(o)||r.has(o))return;r.add(o),this._pluginRegistry.delete(o);let s=a[DS];s&&s.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)i(t);else if(!this._seenPlugins.has(e.pluginName)&&!r.has(e.pluginName)){if(a.type===n.UniverType.UNIVER_UNKNOWN&&e.type!==n.UniverType.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${e.pluginName}.`);a.type!==e.type&&e.type!==n.UniverType.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),i({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>i(e));let a=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(a)}_pluginsRunLifecycle(e){let n=this._lifecycleService.stage;if(cS(n).subscribe(t=>this._runStage(e,t)),n!==3){let n=this._lifecycleService.lifecycle$.pipe((0,t.skip)(1)).subscribe(t=>{this._runStage(e,t),t===3&&n.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case 0:e.onStarting();break;case 1:e.onReady();break;case 2:e.onRendered();break;case 3:e.onSteady()}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};jS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,(0,i.Inject)(sS)),V(2,da)],jS);let MS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_currentRegion$`,void 0),T(this,`currentRegion$`,void 0),T(this,`_hasExplicitRegion`,!1),this._currentRegion$=new t.BehaviorSubject(this._localeService.getCurrentLocale()),this.currentRegion$=this._currentRegion$.asObservable(),this.disposeWithMe(this._localeService.currentLocale$.subscribe(e=>{!this._hasExplicitRegion&&e!==this._currentRegion$.value&&this._currentRegion$.next(e)})),this.disposeWithMe(D(()=>this._currentRegion$.complete()))}setRegion(e){this._hasExplicitRegion=!0,this._currentRegion$.next(e)}getCurrentRegion(){return this._currentRegion$.value}};MS=ma([V(0,(0,i.Inject)(uS))],MS);let NS=(0,i.createIdentifier)(`resource-loader-service`),PS=class extends k{constructor(e){super(),this._logService=e,T(this,`_resourceMap`,/* @__PURE__ */ new Map),T(this,`_register$`,new t.Subject),T(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){let n=this.getAllResourceHooks(),r=[];for(let i=0;i<n.length;i++){let a=n[i];if(!a.businesses.includes(t))continue;let o=a.toJson(e);r.push({name:a.pluginName,data:o})}return r}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),D(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){let n=this.getAllResourceHooks();for(let i=0;i<n.length;i++){var r;let a=n[i],o=t==null||(r=t.find(e=>e.name===a.pluginName))==null?void 0:r.data;if(o)try{let t=a.parseJson(o);a.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}}}unloadResources(e,t){let n=this.getAllResourceHooks();for(let r=0;r<n.length;r++){let i=n[r];i.businesses.includes(t)&&i.onUnLoad(e)}}dispose(){this._register$.complete(),this._resourceMap.clear()}};PS=ma([V(0,da)],PS);var FS=class extends k{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),T(this,`_darkMode$`,new t.BehaviorSubject(!1)),T(this,`darkMode$`,this._darkMode$.asObservable()),T(this,`_validColorCache`,/* @__PURE__ */ new Map),T(this,`_currentTheme`,a.defaultTheme),T(this,`_currentTheme$`,new t.BehaviorSubject(this._currentTheme)),T(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(D(()=>{this._currentTheme=a.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in a.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in a.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return _i(this._currentTheme,e)}},IS=class{constructor(e,t=1e3){this._injector=e,T(this,`_imageCacheMap`,void 0),this._imageCacheMap=new xd(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(_x)?this._injector.get(_x):null,s=this._injector.has(vx)?this._injector.get(vx):null;if(e===`UUID`)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===`URL`)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function LS(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function RS(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}let zS=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],$=/* @__PURE__ */ new Uint32Array(96);var BS=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=zS[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=zS.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return VS(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=[];for(;s>0;){let l=$[--s],u=$[--s],d=$[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&($[s++]=d,$[s++]=f-1,$[s++]=1-l),(l===0?n>=p:r>=m)&&($[s++]=f+1,$[s++]=u,$[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=$[--s],d=$[--s],f=$[--s];if(d-f<=o){for(let n=f;n<=d;n++)GS(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];GS(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&($[s++]=f,$[s++]=p-1,$[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&($[s++]=p+1,$[s++]=d,$[s++]=1-u)}return c}};function VS(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;HS(e,t,o,r,i,a),VS(e,t,n,r,o-1,1-a),VS(e,t,n,o+1,i,1-a)}function HS(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);HS(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(US(e,t,r,n),t[2*i+a]>o&&US(e,t,r,i);s<c;){for(US(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?US(e,t,r,c):(c++,US(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function US(e,t,n,r){WS(e,n,r),WS(t,2*n,2*r),WS(t,2*n+1,2*r+1)}function WS(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function GS(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var KS=class{constructor(e=!1){this._enableOneCellCache=e,T(this,`_tree`,/* @__PURE__ */ new Map),T(this,`_oneCellCache`,/* @__PURE__ */ new Map),T(this,`_kdTree`,/* @__PURE__ */ new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,/* @__PURE__ */ new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new jd),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,/* @__PURE__ */ new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,/* @__PURE__ */ new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,/* @__PURE__ */ new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,/* @__PURE__ */ new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,/* @__PURE__ */ new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new BS(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=/* @__PURE__ */ new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){var t;let{unitId:n,sheetId:r,range:i,id:a}=e,o=(t=this._tree.get(n))==null?void 0:t.get(r);if(!o)return;let s=o.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e=0;e<s.length;e++)s[e].id===a&&o.remove(s[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){if(e.length<2){for(let t of e)this.remove(t);return}let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.unitId);e||(e=/* @__PURE__ */ new Map,t.set(n.unitId,e));let r=e.get(n.sheetId);r||(r=/* @__PURE__ */ new Map,e.set(n.sheetId,r));let i=r.get(n.id);i?i.push(n):r.set(n.id,[n])}for(let[e,n]of t)for(let[t,r]of n)this._removeSparseRanges(e,t,r)||this._bulkRemoveFromSheet(e,t,r)}_bulkRemoveFromSheet(e,t,n){var r,i;if(n.size===1){let[e]=n.values();if(e.length===1){this.remove(e[0]);return}}let a=(e,t,r=!1)=>{var i;return((i=n.get(e))==null?void 0:i.some(({range:e})=>(!r||!this._enableOneCellCache||e.startRow!==e.endRow||e.startColumn!==e.endColumn)&&e.startColumn<=t.maxX&&e.endColumn>=t.minX&&e.startRow<=t.maxY&&e.endRow>=t.minY))??!1},o=(r=this._tree.get(e))==null?void 0:r.get(t);if(o){let e=o.all(),t=0;for(let n of e)a(n.id,n,!0)||(e[t++]=n);t!==e.length&&(e.length=t,o.clear(),o.load(e))}let s=(i=this._oneCellCache.get(e))==null?void 0:i.get(t);if(s)for(let[e,t]of s)for(let[n,r]of t){let t={minX:n,maxX:n,minY:e,maxY:e};for(let e of r)a(e,t)&&r.delete(e)}}_removeSparseRanges(e,t,n){var r,i;let a=128;if(n.size>a)return!1;let o=(e,t)=>{if(--a<0||!e.leaf&&t.startColumn<=e.minX&&t.endColumn>=e.maxX&&t.startRow<=e.minY&&t.endRow>=e.maxY)return!1;for(let n of e.children)if(t.startColumn<=n.maxX&&t.endColumn>=n.minX&&t.startRow<=n.maxY&&t.endRow>=n.minY){if(e.leaf){if(--a<0)return!1}else if(!o(n,t))return!1}return!0},s=(r=this._tree.get(e))==null?void 0:r.get(t),c=s==null?void 0:s.toJSON(),l=(i=this._oneCellCache.get(e))==null?void 0:i.get(t);for(let[e,t]of n){if(Number.isNaN(e))return!1;for(let{range:e}of t){if(--a<0)return!1;if(this._enableOneCellCache){if(e.startRow===e.endRow&&e.startColumn===e.endColumn)continue;if(l)return!1}if(c&&!o(c,e))return!1}}for(let e of n.values())for(let t of e)this.remove(t);return!0}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,/* @__PURE__ */ new Map);for(let n in e[t]){let r=new jd;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};let qS=/* @__PURE__ */ function(e){return e.Blank=`blank`,e.String=`string`,e.Number=`number`,e.Date=`date`,e.Boolean=`boolean`,e.Error=`error`,e}({}),JS=/* @__PURE__ */ function(e){return e.All=`all`,e.Include=`include`,e.Exclude=`exclude`,e}({});function YS(e){let t=e;if(!XS(t)||typeof t.type!=`string`)throw TypeError(`Invalid record value.`);switch(t.type){case`blank`:if(`value`in t)throw TypeError(`Blank record values cannot have a value.`);return`["blank"]`;case`string`:case`error`:if(typeof t.value!=`string`)throw TypeError(`Invalid record value.`);return JSON.stringify([t.type,t.value]);case`boolean`:if(typeof t.value!=`boolean`)throw TypeError(`Invalid record value.`);return JSON.stringify([t.type,t.value]);case`number`:case`date`:if(typeof t.value!=`number`)throw TypeError(`Invalid record value.`);if(!Number.isFinite(t.value))throw RangeError(`Record numeric values must be finite.`);return JSON.stringify([t.type,t.value===0?0:t.value]);default:throw TypeError(`Unknown record value type.`)}}function XS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZS(e){return new Promise(t=>setTimeout(t,e))}function QS(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let $S=9525;function eC(e){return Math.round(e*$S)}function tC(e){return e/$S}function nC(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=nC(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=nC(e[i])}return t}function rC(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:nC(e.p)),e.s!==void 0&&(t.s=e.s===null||typeof e.s==`string`?e.s:nC(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ft!==void 0&&(t.ft=e.ft),e.fd!==void 0&&(t.fd=e.fd),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:nC(e.custom)),t}function iC(e){if(e==null)return e;let t=rC(e);return e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function aC(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=rC(r))}t[a]=s}return t}function oC(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(s.s=o.s===null||typeof o.s==`string`?o.s:nC(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:nC(o.custom)),t[a]=s}return t}function sC(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function cC(e){let t={id:e.id,...e.type===void 0?{}:{type:e.type},name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,...e.zoomToFit===void 0?{}:{zoomToFit:e.zoomToFit},scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,backgroundImage:e.backgroundImage?{source:e.backgroundImage.source,imageSourceType:e.backgroundImage.imageSourceType,scaleX:e.backgroundImage.scaleX,scaleY:e.backgroundImage.scaleY}:void 0,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:sC(e.mergeData),cellData:aC(e.cellData),rowData:oC(e.rowData),columnData:oC(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(t.defaultStyle=e.defaultStyle===null||typeof e.defaultStyle==`string`?e.defaultStyle:nC(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:nC(e.custom)),t}let lC=class extends k{constructor(e){super(),this._localeService=e,T(this,`_fontLocale`,void 0),T(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};lC=ma([V(0,(0,i.Inject)(uS))],lC);function uC(e={}){let t={defaultBackgroundColor:`rgba(24, 119, 242, 0.08)`,defaultStripeColor:`rgba(24, 119, 242, 0.25)`,rowGaps:{1:{size:6},3:{size:10,color:`rgba(245, 158, 11, 0.14)`},6:{size:14,color:`rgba(16, 185, 129, 0.12)`,stripeColor:`rgba(5, 150, 105, 0.35)`}},colGaps:{1:{size:5},2:{size:8,stripeColor:`rgba(59, 130, 246, 0.35)`},4:{size:12,color:`rgba(244, 63, 94, 0.12)`,stripeColor:`rgba(225, 29, 72, 0.30)`}}};return{...t,...e,rowGaps:{...t.rowGaps,...e.rowGaps},colGaps:{...t.colGaps,...e.colGaps}}}let dC=class extends lC{constructor(e,n,r,i,a,o){super(r),this.worksheet=e,this._styles=n,this._contextService=i,this._configService=a,this._injector=o,T(this,`_worksheetData`,void 0),T(this,`_renderRawFormula`,!1),T(this,`_cellData`,void 0),T(this,`_imageCacheMap`,void 0),T(this,`_skipAutoHeightForMergedCells`,!0),T(this,`_rowTotalHeight`,0),T(this,`_columnTotalWidth`,0),T(this,`_rowHeaderWidth`,0),T(this,`_columnHeaderHeight`,0),T(this,`_rowHeightAccumulation`,[]),T(this,`_columnWidthAccumulation`,[]),T(this,`_marginTop`,0),T(this,`_marginLeft`,0),T(this,`_gapConfig`,{}),T(this,`_scaleX`,1),T(this,`_scaleY`,1),T(this,`_scrollX`,0),T(this,`_scrollY`,0),T(this,`_gapConfigChanged$`,new t.Subject),T(this,`gapConfigChanged$`,this._gapConfigChanged$.asObservable()),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new IS(this._injector),this.initConfig()}initConfig(){this._skipAutoHeightForMergedCells=!(this._configService.getConfig(kp)??!1),this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig(`isRowStylePrecedeColumnStyle`)??!1)}resetCache(){}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){z.isDefine(e)&&(this._scrollX=e),z.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}get gapConfig(){return this._gapConfig}setGapConfig(e){this._gapConfig=this._fillDefaultGapThemeColors(e),this.makeDirty(!0),this._updateLayout(),this._gapConfigChanged$.next()}_fillDefaultGapThemeColors(e){if(e.defaultBackgroundColor&&e.defaultStripeColor)return e;let{r:t,g:n,b:r}=new La(this._injector.get(FS).getColorFromTheme(`primary.500`)).toRgb();return{...e,defaultBackgroundColor:e.defaultBackgroundColor??`rgba(${t}, ${n}, ${r}, 0.025)`,defaultStripeColor:e.defaultStripeColor??`rgba(${t}, ${n}, ${r}, 0.08)`}}getRowGapSize(e){var t;return((t=this._gapConfig.rowGaps)==null||(t=t[e])==null?void 0:t.size)??0}getColGapSize(e){var t;return((t=this._gapConfig.colGaps)==null||(t=t[e])==null?void 0:t.size)??0}getGapSizeGetter(){if(this._gapConfig.rowGaps||this._gapConfig.colGaps)return{row:e=>this.getRowGapSize(e),col:e=>this.getColGapSize(e)}}getRowGapAtPosition(e){let{rowGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._rowHeightAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}getColGapAtPosition(e){let{colGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._columnWidthAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=Rx(n,24,!1),o=t;for(let t=0;t<e;t++){var s;let e=a;if(this.worksheet.getRowFiltered(t))e=0;else if(o[t]!=null){let n=o[t];if(!n)continue;let{h:r=a,ah:i,ia:s}=n;e=(s==null||s===1)&&Lx(i,!1)?i:Rx(r,0),n.hd===1&&(e=0)}let n=((s=this._gapConfig.rowGaps)==null||(s=s[t])==null?void 0:s.size)??0;r+=n,r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=Rx(n,88,!1),o=t;for(let t=0;t<e;t++){var s;let e=a;if(o[t]!=null){let n=o[t];if(!n)continue;n.w!==void 0&&(e=Rx(n.w,0)),n.hd===1&&(e=0)}let n=((s=this._gapConfig.colGaps)==null||(s=s[t])==null?void 0:s.size)??0;r+=n,r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=1){let a=0,o=t>n?-1:1;for(let s=t;o===1?s<=n:s>=n;s+=o){if(!hu(this.worksheet.getCell(e,s))&&s!==t||this.intersectMergeRange(e,s))return s===t?s:z.clamp(s-o,0,this._columnWidthAccumulation.length-1);let{startX:n,endX:c}=pC(e,s,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(a+=i===2&&s===t?(c-n)/2:c-n,r<a)return s}return o===1?n:t}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===1?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===1?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new du,l=0,u=null;for(;s;){s=!1;for(let e of o)c.getValue(e.startRow,e.startColumn)||$d({startColumn:r,startRow:n,endColumn:a,endRow:i},e)&&(n=Math.min(n,e.startRow),r=Math.min(r,e.startColumn),i=Math.max(i,e.endRow),a=Math.max(a,e.endColumn),c.setValue(e.startRow,e.startColumn,!0),s=!0,l++,u=e)}return t&&l===1&&Kd.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=pC(e,t,r,i,void 0,this.getGapSizeGetter());return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this,a=hC(e,t,n,this.columnHeaderHeightAndMarginTop),o=Na(i,a,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(i[o]-a)<Math.abs(a-(i[o-1]??0))&&(o+=1),o}getColumnIndexByOffsetX(e,t,n,r){let i=mC(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=Na(a,i,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(a[o]-i)<Math.abs(i-(a[o-1]??0))&&(o+=1),o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=pC(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t),this.getGapSizeGetter()),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=Na(this.columnWidthAccumulation,e),r=e-((this._columnWidthAccumulation[n-1]||0)+this.getColGapSize(n)),i=Na(this.rowHeightAccumulation,t);return{row:i,column:n,columnOffset:r,rowOffset:t-((this._rowHeightAccumulation[i-1]||0)+this.getRowGapSize(i))}}getCellIndexAndOffsetByPosition(e,t,n=this._scaleX,r=this._scaleY,i={x:this._scrollX,y:this._scrollY}){let{actualRow:a,actualColumn:o,startX:s,startY:c}=this.getCellWithCoordByOffset(e,t,n,r,i);return{row:a,rowOffset:t-c,column:o,columnOffset:e-s}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new fy(e)}dispose(){super.dispose(),this._gapConfigChanged$.complete(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};dC=ma([V(2,(0,i.Inject)(uS)),V(3,ca),V(4,oa),V(5,(0,i.Inject)(i.Injector))],dC);function fC(e,t,n,r,i=0,a=0){let o=e-1,s=t-1,c=(n[o]||0)+i,l=n[e];l??=n[n.length-1];let u=(r[s]||0)+a,d=r[t];return d??=r[r.length-1],{startY:c,endY:l,startX:u,endX:d}}function pC(e,t,n,r,i,a){let o=z.clamp(e,0,n.length-1),s=z.clamp(t,0,r.length-1),c=fC(o,s,n,r,(a==null?void 0:a.row(o))??0,(a==null?void 0:a.col(s))??0),{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i??{isMerged:!1,isMergedMainCell:!1,startRow:o,startColumn:s,endRow:o,endColumn:s},h={...c,startRow:d,startColumn:f,endRow:p,endColumn:m};if(l?d!==-1&&f!==-1:p!==-1&&m!==-1){if(l){let e=(a==null?void 0:a.row(d))??0,t=(a==null?void 0:a.col(f))??0;h.startY=(n[d-1]??0)+e,h.startX=(r[f-1]??0)+t}h.endY=n[p]??n[n.length-1],h.endX=r[m]??r[r.length-1]}return{...c,isMerged:l,isMergedMainCell:u,actualRow:o,actualColumn:s,mergeInfo:h}}function mC(e,t,n,r){let{x:i}=n;return e/t+i-r}function hC(e,t,n,r){let{y:i}=n;return e/t+i-r}let gC=[`script`,`style`,`meta`,`comment`,`link`],_C=/* @__PURE__ */ function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),vC=/* @__PURE__ */ function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),yC=/* @__PURE__ */ function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),bC=/* @__PURE__ */ function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),xC=/* @__PURE__ */ function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),SC=/* @__PURE__ */ function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),CC=class extends k{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=(e,t,n=[],r)=>{let i=n.find(t=>t.name===e.pluginName);if(i)try{let n=e.parseJson(i.data);e.onLoad(t,n)}catch{console.error(`Load ${r}{${t}} Resources{${e.pluginName}} Data Error.`)}},t=t=>{t.businesses.forEach(r=>{switch(r){case n.UniverType.UNRECOGNIZED:case n.UniverType.UNIVER_UNKNOWN:case n.UniverType.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_DOC).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Document`)});break;case n.UniverType.UNIVER_SLIDE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SLIDE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Slide`)});break;case n.UniverType.UNIVER_BOARD:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BOARD).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Board`)});break;case n.UniverType.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SHEET).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Workbook`)});break;case n.UniverType.UNIVER_BASE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BASE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Base`)})}})};this._resourceManagerService.getAllResourceHooks().forEach(e=>t(e)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(e=>t(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SHEET).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_DOC).subscribe(e=>{let{unit:t}=e;Mp(t.getUnitId())||this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BOARD).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BASE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_DOC)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BASE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BASE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SLIDE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BOARD).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BOARD)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=z.deepClone(t.getSnapshot());return r.resources=n,r}};CC=ma([V(0,(0,i.Inject)(Zb)),V(1,(0,i.Inject)(nS))],CC);var wC=class{get _univerInstanceService(){return this._injector.get(nS)}get _pluginService(){return this._injector.get(jS)}constructor(e={},t){T(this,`_startedTypes`,/* @__PURE__ */ new Set),T(this,`_injector`,void 0),T(this,`_disposingCallbacks`,new O);let n=this._injector=TC(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,region:o,locales:s,direction:c,logLevel:l,logCommandExecution:u,undoRedoHistoryLimit:d}=e,f=this._injector.get(oa);r&&this._injector.get(FS).setTheme(r),i&&this._injector.get(FS).setDarkMode(i),s&&this._injector.get(uS).load(s),a&&this._injector.get(uS).setLocale(a),o&&this._injector.get(MS).setRegion(o),c&&this._injector.get(uS).setDirection(c),l&&this._injector.get(da).setLogLevel(l),u!==void 0&&f.setConfig(ha,u),f.setConfig(`undoRedo.historyLimit`,d??50),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(D(e));return D(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(uS).setLocale(e)}setRegion(e){this._injector.get(MS).setRegion(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}_init(e){this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SHEET,tS),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_DOC,fy);let t=e.get(nS);t.__setCreateHandler((n,r,i,a)=>{let o=!this._startedTypes.has(n);o&&(this._pluginService.startPluginsForType(n),this._startedTypes.add(n));let s=t.__getCtorByType(n)??i;if(!s)throw Error(`[Univer]: No constructor registered for unit type ${n}.`);let c=e.createInstance(s,r);return t.__addUnit(c,a),o&&this._tryProgressToReady(),c})}_tryProgressToReady(){this._injector.get(sS).stage<1&&(this._injector.get(sS).stage=1)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function TC(e,t){let n=ES([[mx],[uS],[MS],[FS],[sS],[jS],[tx],[nS,{useClass:rS}],[SS,{useClass:TS}],[wS],[da,{useClass:fa,lazy:!0}],[_a,{useClass:ba}],[mS,{useClass:bS,lazy:!0}],[oa,{useClass:sa}],[ca,{useClass:la}],[Zb,{useClass:PS,lazy:!0}],[NS,{useClass:CC,lazy:!0}],[rx,{useClass:nx}],[fS,{useClass:dS,lazy:!0}]],t),r=e?e.createChild(n):new i.Injector(n);return Je(r,[[tx],[NS]]),r}x(),e.ABCToNumber=of,e.AUTO_HEIGHT_FOR_MERGED_CELLS=kp,e.AbsoluteRefType=lo,e.ActionIterator=Tv,e.AlignTypeH=hh,e.AlignTypeV=gh,e.ArrangeTypeEnum=Pp,e.AsyncInterceptorManager=qp,Object.defineProperty(e,"AsyncLock",{enumerable:!0,get:function(){return Sp.default}}),Object.defineProperty(e,"AuthzIoLocalService",{enumerable:!0,get:function(){return nx}}),e.AutoFillSeries=se,e.BASE_RECORD_ID_FIELD_ID=Cf,e.BASE_RECORD_ID_FIELD_NAME=wf,e.BORDER_KEYS=Th,e.BORDER_STYLE_KEYS=wh,e.BaseConditionalColorOperator=_f,e.BaseConditionalColorTarget=gf,e.BaseConditionalDateMode=vf,e.BaseDataModel=Mf,e.BaseFieldType=pf,e.BaseFilterConjunction=bf,e.BaseFilterOperator=yf,e.BaseHierarchyInvalidReason=Sf,e.BaseRecordLinkRole=mf,e.BaseSortDirection=xf,e.BaseViewType=hf,e.BaselineOffset=Ne,e.BlockType=Um,e.BooleanNumber=Pe,e.BorderStyleTypes=ce,e.BorderType=le,e.BuildTextUtils=Z,e.BulletAlignment=Rm,e.COLORS=Ia,e.COLOR_STYLE_KEYS=Ch,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=ha,e.CanceledError=Xe,e.CellModeEnum=mo,e.CellValueType=Fe,e.ColorKit=La,e.ColorType=ue,e.ColumnLayoutType=sh,e.ColumnResponsiveType=ch,e.ColumnSeparatorType=qm,Object.defineProperty(e,"CommandService",{enumerable:!0,get:function(){return ba}}),e.CommandType=ga,e.CommonHideTypes=de,e.ConfigService=sa,e.ContextService=la,e.CopyPasteType=fe,e.CustomCommandExecutionError=Ye,e.CustomDecorationType=Hm,e.CustomRangeType=Bm,e.DEFAULT_CELL=Mh,e.DEFAULT_DOC=cy,e.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING=Fh,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE=0,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW=12,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
|
|
26
|
-
`,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=Ah,e.DEFAULT_RANGE_ARRAY=kh,e.DEFAULT_SELECTION=jh,e.DEFAULT_STYLES=Y,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=Vx,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Op,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=Dp,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Ep,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=po,e.DashStyleType=eh,e.DataStreamTreeNodeType=Sm,e.DataStreamTreeTokenType=Cm,e.DataValidationErrorStyle=_C,e.DataValidationImeMode=vC,e.DataValidationOperator=yC,e.DataValidationRenderMode=bC,e.DataValidationStatus=xC,e.DataValidationType=SC,e.DateSystem=pe,e.DeleteDirection=me,e.DependentOn=AS,e.DesktopLogService=fa,e.DeveloperMetadataVisibility=he,e.Dimension=ge,e.Direction=_e,e.Disposable=k,e.DisposableCollection=O,e.DocStyleType=Fm,e.DocumentBlockRangeType=zm,e.DocumentBlockType=Pm,e.DocumentDataModel=fy,e.DocumentFlavor=Wm,e.DocxBreakType=Vm,e.DrawingTypeEnum=Fp,e.EDITOR_ACTIVATED=dx,e.EMU_PER_CSS_PX=$S,e.EXCEL_1904_OFFSET=Qs,e.EXTENSION_NAMES=Lh,e.ErrorService=mx,e.EventState=Jb,e.EventSubject=Yb,e.FOCUSING_BOARD=ux,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=cx,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=fx,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=px,e.FOCUSING_SHEET=sx,e.FOCUSING_SLIDE=lx,e.FOCUSING_UNIT=ox,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FilterSelectionMode=JS,e.FollowNumberWithType=Im,e.FontItalic=je,e.FontStyleType=dh,e.FontWeight=Me,e.FormulaType=ro,e.GridType=Gm,e.HorizontalAlign=Oe,e.IAuthzIoService=rx,e.ICommandService=_a,e.IConfigService=oa,e.IConfirmService=ix,e.IContextService=ca,e.IImageIoService=_x,e.ILocalStorageService=lS,e.ILogService=da,e.IMentionIOService=fS,e.IPermissionService=SS,e.IResourceLoaderService=NS,e.IResourceManagerService=Zb,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=vx,e.IUndoRedoService=mS,e.IUniverInstanceService=nS,e.ImageCacheMap=IS,e.ImageSourceType=hx,e.ImageUploadStatusType=gx,Object.defineProperty(e,"Inject",{enumerable:!0,get:function(){return i.Inject}}),Object.defineProperty(e,"InjectSelf",{enumerable:!0,get:function(){return i.InjectSelf}}),Object.defineProperty(e,"Injector",{enumerable:!0,get:function(){return i.Injector}}),e.InterceptorEffectEnum=Vp,e.InterceptorManager=Wp,e.InterpolationPointType=ye,Object.defineProperty(e,"JSON1",{enumerable:!0,get:function(){return ig}}),e.JSONX=ry,e.LOCALE_META=xe,e.LRUHelper=Sd,e.LRUMap=xd,Object.defineProperty(e,"LifecycleService",{enumerable:!0,get:function(){return sS}}),e.LifecycleStages=iS,e.LifecycleUnreachableError=oS,e.ListGlyphType=Lm,Object.defineProperty(e,"LocalUndoRedoService",{enumerable:!0,get:function(){return bS}}),e.LocaleService=uS,e.LocaleType=be,e.LogLevel=ua,Object.defineProperty(e,"LookUp",{enumerable:!0,get:function(){return i.LookUp}}),e.MAX_COLUMN_COUNT=16384,e.MAX_ITERATION_COUNT=32767,e.MAX_ROW_COUNT=1048576,e.MODERN_DOCUMENT_DEFAULT_MARGIN=66.66666666666667,e.MODERN_DOCUMENT_WIDTH=Bh,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,"Many",{enumerable:!0,get:function(){return i.Many}}),e.MemoryCursor=lm,Object.defineProperty(e,"MentionIOLocalService",{enumerable:!0,get:function(){return dS}}),e.MentionType=Se,e.ModernDocumentWidthMode=zh,e.NAMED_STYLE_MAP=Ph,e.NAMED_STYLE_SPACE_MAP=Ih,e.NamedStyleType=Qm,e.NilCommand=ya,e.NumberUnitType=mh,e.OBJECT_PERMISSION_CONFIG_KEY=`objectPermissionTypes`,e.ObjectMatrix=du,e.ObjectPermissionRuleModel=pS,Object.defineProperty(e,"ObjectPermissionService",{enumerable:!0,get:function(){return wS}}),e.ObjectRelativeFromH=fh,e.ObjectRelativeFromV=ph,Object.defineProperty(e,"Optional",{enumerable:!0,get:function(){return i.Optional}}),e.PADDING_KEYS=Dh,e.PAGE_SIZE=Rh,e.PAPER_TYPES=bh,e.PARAGRAPH_ID_PREFIX=Vh,e.PRESERVE_INSERTED_PARAGRAPH_IDS=ag,e.PRESET_LIST_TYPE=__,e.PageOrientType=vh,e.PaperType=yh,e.ParagraphElementType=Ym,e.ParagraphStyleBuilder=yb,e.ParagraphStyleValue=vb,e.PermissionService=TS,e.PermissionStatus=xS,e.Plugin=OS,Object.defineProperty(e,"PluginService",{enumerable:!0,get:function(){return jS}}),e.PositionedObjectLayoutType=Zm,e.PresetListType=f_,e.ProtectionType=Ce,Object.defineProperty(e,"Quantity",{enumerable:!0,get:function(){return i.Quantity}}),e.QuickListType=d_,e.QuickListTypeMap=b_,e.RANGE_DIRECTION=fo,e.RANGE_TYPE=co,e.RBush=jd,e.RCDisposable=j,e.RESTORE_INSERTED_PARAGRAPH_IDS=wg,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=KS,e.Range=Gx,e.RecordValueType=qS,e.Rectangle=Kd,Object.defineProperty(e,"RediError",{enumerable:!0,get:function(){return i.RediError}}),e.RedoCommand=yS,e.RedoCommandId=gS,e.RefAlias=rf,Object.defineProperty(e,"RegionService",{enumerable:!0,get:function(){return MS}}),e.Registry=mm,e.RegistryAsMap=hm,e.RelativeDate=we,Object.defineProperty(e,"ResourceManagerService",{enumerable:!0,get:function(){return PS}}),e.RichTextBuilder=xb,e.RichTextParagraphBuilder=Sb,e.RichTextRunBuilder=Cb,e.RichTextValue=bb,e.RxDisposable=A,e.SECTION_ID_PREFIX=vm,e.SHEET_EDITOR_UNITS=Nh,e.SHEET_TEXT_LINE_GAP=Ap,e.STYLE_KEYS=Oh,e.SectionType=Km,Object.defineProperty(e,"Self",{enumerable:!0,get:function(){return i.Self}}),Object.defineProperty(e,"SheetSkeleton",{enumerable:!0,get:function(){return dC}}),e.SheetTypes=Te,e.SheetViewModel=Jx,Object.defineProperty(e,"Skeleton",{enumerable:!0,get:function(){return lC}}),Object.defineProperty(e,"SkipSelf",{enumerable:!0,get:function(){return i.SkipSelf}}),e.SliceBodyType=X_,e.SpacingRule=$m,e.Styles=Sx,e.TEXT_DECORATION_KEYS=Sh,e.TEXT_ROTATION_KEYS=Eh,e.THEME_COLORS=ho,e.TRADITIONAL_DOCUMENT_DEFAULT_MARGIN=72,e.TabStopAlignment=th,e.TabStopLeader=nh,e.TableAlignmentType=ih,e.TableLayoutType=ah,e.TableRowHeightRule=lh,e.TableSizeType=rh,e.TableTextWrapType=oh,e.TestConfirmService=ax,e.TextDecoration=De,e.TextDecorationBuilder=_b,e.TextDirection=Ee,e.TextDirectionType=Jm,e.TextStyleBuilder=gb,e.TextStyleValue=hb,e.TextX=X,e.TextXActionType=og,e.ThemeColorType=Ie,e.ThemeColors=Le,e.ThemeService=FS,e.Tools=z,e.UndoCommand=vS,e.UndoCommandId=_S,e.UnitModel=M,e.Univer=wC,Object.defineProperty(e,"UniverInstanceService",{enumerable:!0,get:function(){return rS}}),Object.defineProperty(e,"UniverInstanceType",{enumerable:!0,get:function(){return n.UniverType}}),e.UpdateDocsAttributeType=to,e.UserManagerService=tx,e.VerticalAlign=ke,e.VerticalAlignmentType=uh,Object.defineProperty(e,"WithNew",{enumerable:!0,get:function(){return i.WithNew}}),Object.defineProperty(e,"Workbook",{enumerable:!0,get:function(){return tS}}),e.Worksheet=Xx,e.WorksheetHiddenState=no,e.WrapStrategy=Ae,e.WrapTextType=Xm,e.addLinkToDocumentModel=Ax,e.afterInitApply=ka,e.afterTime=Da,e.allocateBaseFormulaTableName=ap,e.assertBaseTableRecordIdentity=kf,e.awaitTime=ZS,e.binSearchFirstGreaterThanTarget=Ma,e.binarySearchArray=ja,e.bufferDebounceTime=Ea,e.cellToRange=wu,e.characterSpacingControlType=_h,e.checkForSubstrings=Au,e.checkIfMove=Fa,e.checkParagraphHasBullet=rd,e.checkParagraphHasIndent=id,e.checkParagraphHasIndentByStyle=ad,e.cloneBodyWithFreshParagraphIds=Uh,e.cloneCellData=rC,e.cloneCellDataMatrix=aC,e.cloneCellDataWithSpanAndDisplay=iC,e.cloneParagraphWithId=Wh,e.cloneSectionBreakWithId=bm,e.cloneValue=nC,e.cloneWorksheetData=cC,e.codeToBlob=Pa,e.columnLabelToNumber=Cd,e.composeBody=bv,e.composeInterceptors=Up,e.composeStyles=ae,e.concatMatrixArray=ou,e.containsInteriorInsertionOffset=_g,e.containsStreamIndex=gg,e.convertCellToRange=fu,e.convertObservableToBehaviorSubject=Oa,e.covertCellValue=Eu,e.covertCellValues=Du,e.createAsyncInterceptorKey=Gp,e.createBaseFormulaTableNameMap=ip,e.createBaseFormulaTableReferenceNormalizer=lp,e.createBaseRecordIdField=Ef,e.createDefaultBaseTableSnapshot=Af,e.createDefaultUser=$b,e.createDocumentModelWithStyle=Dx,Object.defineProperty(e,"createIdentifier",{enumerable:!0,get:function(){return i.createIdentifier}}),e.createInterceptorKey=Hp,e.createInternalEditorID=jp,e.createParagraphId=Hh,e.createRandomId=Dd,e.createRowColIter=af,e.createSectionId=ym,e.createSheetGapTestConfig=uC,e.cssPxToEmu=eC,e.currencySymbols=Ql,e.customNameCharacterCheck=RS,e.dateKit=td,e.debounce=Ji,e.dedupe=Ve,e.dedupeBy=He,e.deepCompare=Ou,e.delayAnimationFrame=QS,e.deleteContent=sd,e.emuToCssPx=tC,e.excelDateSerial=dc,e.excelDateTimePartsToSerial=lc,e.excelDateTimeSerial=fc,e.excelSerialToDate=sc,e.excelSerialToDateTime=cc,e.excelSerialToDateTimeParts=ac,e.extractPureTextFromCell=Zx,Object.defineProperty(e,"forwardRef",{enumerable:!0,get:function(){return i.forwardRef}}),e.fromCallback=wa,e.fromEventSubject=Xb,e.generateIntervalsByPoints=ud,e.generateRandomId=J,e.get=_i,e.getArrayLength=nu,e.getBaseFormulaTableName=sp,e.getBasesEmptySnapshot=jf,e.getBlockRangeInterval=ug,e.getBodySlice=uv,e.getBodySliceForSplitTextXAction=fv,e.getBodySliceForTextXAction=dv,e.getBorderStyleType=xu,e.getCellCoordByIndexSimple=fC,e.getCellValueType=ao,e.getCellWithCoordByIndexCore=pC,e.getColorStyle=gu,e.getColumnGroupRangeInterval=dg,e.getCustomBlockIdsInSelections=Xy,e.getCustomBlockInterval=pg,e.getCustomBlockSlice=av,e.getCustomDecorationSlice=gv,e.getCustomRangeInterval=fg,e.getCustomRangeSlice=hv,e.getDateSystemMaxSerial=ec,e.getDisplayValueFromCell=Qx,e.getDocsEmptySnapshot=Jh,e.getDocsUpdateBody=Su,e.getDrawingOrderIndex=Lp,e.getEmptyCell=Mx,e.getExclusiveRangeInterval=cg,e.getInclusiveRangeInterval=sg,e.getIntersectRange=$d,e.getNumfmtLocaleTag=Jl,e.getNumfmtParseValueFilter=eu,e.getOriginCellValue=$x,e.getParagraphContentStartOffset=G_,e.getParagraphContentStartOffsets=K_,e.getParagraphFollowingBlockOffset=q_,e.getParagraphsSlice=rv,e.getPlainText=ay,e.getRecordValueKey=YS,e.getReverseDirection=ve,e.getRichTextEditPath=wv,e.getSdtBindingKey=Kb,e.getSdtBindingValue=qb,e.getSectionBreakSlice=iv,e.getSectionHeaderFooterReferenceKey=Ub,e.getSheetsEmptySnapshot=xx,e.getSingleDataStreamChange=nb,e.getTableCellTokenInterval=hg,e.getTableRangeInterval=lg,e.getTableRowTokenInterval=mg,e.getTableSlice=ev,e.getTextRunSlice=$_,e.getTransformOffsetX=mC,e.getTransformOffsetY=hC,e.getWorksheetUID=eS,e.groupBy=Ge,e.handleStyleToString=yu,e.hashAlgorithm=ld,e.horizontalLineSegmentsSubtraction=nd,e.insertMatrixArray=iu,e.insertTextToContent=od,e.intersectsOperationalIntervals=vg,e.invertColorByHSL=am,e.invertColorByMatrix=cm,Object.defineProperty(e,"isAsyncDependencyItem",{enumerable:!0,get:function(){return i.isAsyncDependencyItem}}),Object.defineProperty(e,"isAsyncHook",{enumerable:!0,get:function(){return i.isAsyncHook}}),e.isBaseRecordIdFieldName=Of,e.isBlackColor=$a,e.isBooleanString=wp,e.isCellCoverable=hu,e.isCellV=so,Object.defineProperty(e,"isClassDependencyItem",{enumerable:!0,get:function(){return i.isClassDependencyItem}}),e.isCommentEditorID=Np,Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i.isCtor}}),e.isDefaultFormat=ql,Object.defineProperty(e,"isDisposable",{enumerable:!0,get:function(){return i.isDisposable}}),e.isEmptyCell=mu,Object.defineProperty(e,"isFactoryDependencyItem",{enumerable:!0,get:function(){return i.isFactoryDependencyItem}}),e.isFormulaId=vu,e.isFormulaString=_u,e.isICellData=io,e.isInternalEditorID=Mp,e.isNodeEnv=oe,e.isNotNullOrUndefined=jx,e.isNullCell=oo,e.isNumeric=dm,e.isPatternEqualWithoutDecimal=Yl,e.isRangesEqual=Cx,e.isRealNum=cd,e.isSafeNumeric=fm,e.isSafeUrl=R,e.isSameStyleTextRun=ku,e.isTextFormat=Kl,e.isUnitRangesEqual=wx,e.isValidBaseRecordId=Df,e.isValidColumnDimensions=zx,e.isValidRange=Cu,e.isValidRowDimensions=Bx,e.isValidSheetDimension=Lx,Object.defineProperty(e,"isValueDependencyItem",{enumerable:!0,get:function(){return i.isValueDependencyItem}}),e.isWhiteColor=eo,e.makeArray=Ke,e.makeCellRangeToRangeData=pu,e.mapObjectMatrix=tu,e.merge=na,e.mergeIntervals=dd,e.mergeLocales=fd,e.mergeOverrideWithDependencies=ES,e.mergeSets=_m,e.mergeWith=ta,e.mergeWorksheetSnapshotWithDefault=Hx,e.migrateBaseFormulaTableNames=up,e.mixinClass=um,e.moveMatrixArray=cu,e.moveRangeByOffset=qd,e.nameCharacterCheck=LS,e.noop=zp,e.normalizeBaseFormulaTableName=rp,e.normalizeBaseFormulaTableReferences=cp,e.normalizeBody=mv,e.normalizeDrawingOrderIndex=Ip,e.normalizeInsertedSectionIdsForDocument=Fg,e.normalizeTextRuns=Tg,e.normalizeUrl=ee,e.normalizeWorkbookCalculationSettings=bx,e.numberToABC=sf,e.numberToListABC=lf,Object.defineProperty(e,"numfmt",{enumerable:!0,get:function(){return vl}}),e.regexp=Gl,e.registerDependencies=qe,e.remove=Be,e.repeatStringNumTimes=cf,e.replaceInDocumentBody=_y,e.requestImmediateMacroTask=gm,e.resolveDocumentParagraphStyle=hy,e.resolveDocumentParagraphWordWrap=gy,e.resolveSectionHeaderFooterReference=Wb,e.resolveSectionHeaderFooterReferences=Gb,e.resolveWithBasePath=te,e.rotate=We,e.searchArray=Na,e.searchInOrderedArray=Aa,e.selectionToArray=uo,e.sequence=Qe,e.sequenceAsync=Ze,e.sequenceExecute=Sa,e.sequenceExecuteAsync=Ca,e.set=ia,Object.defineProperty(e,"setDependencies",{enumerable:!0,get:function(){return i.setDependencies}}),e.setWith=aa,e.shallowEqual=Rp,e.shiftExclusiveRangeOnDelete=Sg,e.shiftExclusiveRangeOnInsert=bg,e.shiftInclusiveRangeOnDelete=xg,e.shiftInclusiveRangeOnInsert=yg,e.skipParseTagNames=gC,e.sliceMatrixArray=su,e.sortRules=uf,e.sortRulesByDesc=df,e.sortRulesFactory=ff,e.spliceArray=au,e.splitIntoGrid=Yd,e.takeAfter=Ta,e.throttle=Bp,e.toDisposable=D,e.touchDependencies=Je,e.updateAttributeByDelete=Ev,e.updateAttributeByInsert=Dv,e.validateDocBodyStructure=Bb,e.validateDocumentStructure=Hb,e.willLoseNumericPrecision=pm});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("rxjs"),require("@univerjs/protocol"),require("rxjs/operators"),require("@wendellhu/redi"),require("@univerjs/themes")):typeof define==`function`&&define.amd?define([`exports`,`rxjs`,`@univerjs/protocol`,`rxjs/operators`,`@wendellhu/redi`,`@univerjs/themes`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCore={},e.rxjs,e.UniverProtocol,e.rxjs.operators,e[`@wendellhu/redi`],e.UniverThemes))})(this,function(e,t,n,r,i,a){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),p=(e,t)=>{let n=Object.setPrototypeOf({},null);for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t&1||s(n,Symbol.toStringTag,{value:`Module`}),t&2?n:Object.preventExtensions(n)},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:o(u(e)),m(t||!e||!e.__esModule||!d.call(e,`default`)?s(n,`default`,{value:e,enumerable:!0}):n,e));let g=typeof global<`u`?global:typeof self<`u`?self:window;function _(){let e=/* @__PURE__ */ new Map,t=0;typeof g.requestIdleCallback!=`function`&&(g.requestIdleCallback=function(n){let r=Date.now(),i=++t,a=setTimeout(function(){e.delete(i);let t=Math.max(0,50-(Date.now()-r));n({didTimeout:t===0,timeRemaining(){return t}})},1);return e.set(i,a),i}),typeof g.cancelIdleCallback!=`function`&&(g.cancelIdleCallback=function(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))})}function v(){typeof g.queueMicrotask!=`function`&&(g.queueMicrotask=function(e){Promise.resolve().then(e).catch(e=>{setTimeout(()=>{throw e},0)})})}function y(){typeof g.Array.prototype.findLastIndex!=`function`&&(g.Array.prototype.findLastIndex=function(e,t){if(this==null)throw TypeError(`Array.prototype.findLastIndex called on null or undefined`);if(typeof e!=`function`)throw TypeError(`callback must be a function`);let n=this.length>>>0;for(let r=n-1;r>=0;r--)if(r in this&&e.call(t,this[r],r,this))return r;return-1}),typeof g.Array.prototype.findLast!=`function`&&(g.Array.prototype.findLast=function(e,t){let n=this.findLastIndex(e,t);return n===-1?void 0:this[n]})}function b(){typeof g.String.prototype.at!=`function`&&(g.String.prototype.at=function(e){if(this==null)throw TypeError(`String.prototype.at called on null or undefined`);let t=this.length;if(e<0&&(e=t+e),!(e<0||e>=t))return this.charAt(e)})}function x(){_(),v(),y(),b()}function S(e){"@babel/helpers - typeof";return S=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},S(e)}function C(e,t){if(S(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(S(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function w(e){var t=C(e,`string`);return S(t)==`symbol`?t:t+``}function T(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){return e instanceof t.Subscription||e instanceof t.Subject||e&&`closed`in e&&e.unsubscribe!==void 0}function D(e){let t=!1;return e?E(e)?{dispose:()=>e.unsubscribe()}:typeof e==`function`?{dispose:()=>{t||(t=!0,e())}}:e:D(()=>{})}var O=class{constructor(){T(this,`_disposables`,/* @__PURE__ */ new Set)}add(e){let t=D(e);return this._disposables.add(t),{dispose:(e=!1)=>{e||t.dispose(),this._disposables.delete(t)}}}dispose(){this._disposables.forEach(e=>{e.dispose()}),this._disposables.clear()}},k=class{constructor(){T(this,`_disposed`,!1),T(this,`_collection`,new O)}disposeWithMe(e){return this._collection.add(e)}ensureNotDisposed(){if(this._disposed)throw Error(`[Disposable]: object is disposed!`)}dispose(){this._disposed||(this._disposed=!0,this._collection.dispose())}},A=class extends k{constructor(...e){super(...e),T(this,`dispose$`,new t.Subject)}dispose(){super.dispose(),this.dispose$.next(),this.dispose$.complete()}},j=class extends k{constructor(e){super(),this._rootDisposable=e,T(this,`_ref`,0)}inc(){if(this._disposed)throw Error(`[RCDisposable]: should not ref to a disposed.`);this._ref+=1}dec(){--this._ref,this._ref===0&&(this._rootDisposable.dispose(),this.dispose())}},M=class extends k{};let N=/* @__PURE__ */ new Set(/* @__PURE__ */ `ac.ad.ae.aero.af.ag.ai.al.am.ao.aq.ar.arpa.as.asia.at.au.aw.ax.az.ba.bb.bd.be.bf.bg.bh.bi.biz.bj.bm.bn.bo.br.bs.bt.bv.bw.by.bz.ca.cat.cc.cd.cf.cg.ch.ci.ck.cl.cm.cn.co.com.coop.cr.cu.cv.cw.cx.cy.cz.de.dj.dk.dm.do.dz.ec.edu.ee.eg.er.es.et.eu.fi.fj.fk.fm.fo.fr.ga.gb.gd.ge.gf.gg.gh.gi.gl.gm.gn.gov.gp.gq.gr.gs.gt.gu.gw.gy.hk.hm.hn.hr.ht.hu.id.ie.il.im.in.info.int.io.iq.ir.is.it.je.jm.jo.jobs.jp.ke.kg.kh.ki.km.kn.kp.kr.kw.ky.kz.la.lb.lc.li.lk.lr.ls.lt.lu.lv.ly.ma.mc.md.me.mg.mh.mil.mk.ml.mm.mn.mo.mobi.mp.mq.mr.ms.mt.mu.museum.mv.mw.mx.my.mz.na.name.nc.ne.net.nf.ng.ni.nl.no.np.nr.nu.nz.om.onion.org.pa.pe.pf.pg.ph.pk.pl.pm.pn.post.pr.pro.ps.pt.pw.py.qa.re.ro.rs.ru.rw.sa.sb.sc.sd.se.sg.sh.si.sj.sk.sl.sm.sn.so.sr.ss.st.su.sv.sx.sy.sz.tc.td.tel.tf.tg.th.tj.tk.tl.tm.tn.to.tr.tt.tv.tw.tz.ua.ug.uk.us.uy.uz.va.vc.ve.vg.vi.vn.vu.wf.ws.yt.za.zm.zw`.split(`.`)),P=/* @__PURE__ */ RegExp(`^(?:(?:(?:https?|ftp):)?\\/\\/)?(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff_-]{0,62})?[a-z0-9\\u00a1-\\uffff]\\.)+(?:[a-z\\u00a1-\\uffff]{2,}\\.?))(?::\\d{2,5})?(?:[/?#]\\S*)?$`,`i`);function F(e){if(!Number.isNaN(+e))return!1;if(e.startsWith(`http://localhost:5173`)||e.startsWith(`localhost:5173`))return!0;if(P.test(e)){if(I(e))return!0;try{let t=new URL(ee(e)).hostname.split(`.`).pop();if(t&&N.has(t))return!0}catch{return!1}}return!1}function I(e){return/^[a-zA-Z]+:\/\//.test(e)}function L(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function ee(e){return I(e)?e:L(e)?`mailto://${e}`:`https://${e}`}function R(e){if(!e||typeof e!=`string`)return!1;try{let t=typeof window<`u`&&window.location?window.location.origin:`http://localhost`,n=new URL(e,t);return[`http:`,`https:`,`mailto:`].includes(n.protocol)}catch{return!1}}function te(e,t){try{let n=new URL(t),r=n.pathname.endsWith(`/`)?n.pathname:`${n.pathname}/`,i=e.startsWith(`/`)?e.substring(1):e;return new URL(i,n.origin+r).toString()}catch(t){return console.error(`Error resolving URL with base URL:`,t),e}}function ne(e,t){return z.getValueType(e)===z.getValueType(t)?z.isArray(e)?re(e,t):z.isObject(e)?ie(e,t):z.isDate(e)?e.getTime()===t.getTime():z.isRegExp(e)?e.toString()===t.toString():e===t:!1}function re(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++){let r=e[n],i=t[n];if(!ne(r,i))return!1}return!0}function ie(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.prototype.propertyIsEnumerable.call(t,r))return!1;let n=e[r],i=t[r];if(!ne(n,i))return!1}return!0}var z=class e{static deleteNull(e){for(let t in e)(e[t]===null||e[t]===void 0)&&delete e[t];return e}static getSystemType(){let e=navigator.userAgent,t=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`&&!t&&!n)return`Unix`;if(String(navigator.platform).indexOf(`Linux`)>-1)return`Linux`;if(t){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(){let e=navigator.userAgent,t=e.indexOf(`Opera`)>-1,n=e.indexOf(`compatible`)>-1&&e.indexOf(`MSIE`)>-1&&!t,r=e.indexOf(`Trident`)>-1&&e.indexOf(`rv:11.0`)>-1,i=e.indexOf(`Edge`)>-1,a=e.indexOf(`Firefox`)>-1,o=e.indexOf(`Safari`)>-1&&e.indexOf(`Chrome`)===-1,s=e.indexOf(`Chrome`)>-1&&e.indexOf(`Safari`)>-1;if(n){(/* @__PURE__ */ RegExp(`MSIE (\\d+\\.\\d+);`)).test(e);let t=Number.parseFloat(RegExp.$1);return t===7?`IE7`:t===8?`IE8`:t===9?`IE9`:t===10?`IE10`:`0`}return a?`FF`:t?`Opera`:o?`Safari`:s?`Chrome`:i?`Edge`:r?`IE11`:`Unknown browser`}static diffValue(e,t){return ne(e,t)}static deepClone(t){if(!this.isDefine(t))return t;if(this.isRegExp(t))return new RegExp(t);if(this.isDate(t))return new Date(t);if(this.isArray(t)){let n=[];return t.forEach((t,r)=>{n[r]=e.deepClone(t)}),n}if(this.isObject(t)){let n=t,r={};for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&(r[t]=e.deepClone(n[t]));return Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r}return t}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 isPlainObject(e){return this.isDefine(e)?Object.getPrototypeOf(e)===Object.getPrototypeOf({}):!1}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(let t in e)return!1;return!0}static isTablet(){return/ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle/i.test(navigator.userAgent.toLowerCase())}static isIPhone(){return/iPhone/i.test(navigator.userAgent)}static isLegalUrl(e){return F(e)}static normalizeUrl(e){return ee(e)}static topLevelDomainCombiningString(){return[...N].join(`|`)}static removeNull(t){return this.isObject(t)&&Object.keys(t).forEach(n=>{let r=t[n];r==null?delete t[n]:e.removeNull(r)}),t}static numToWord(e){let t=``;for(;e>0;){let n=e%26;n=n===0?n=26:n,t=String.fromCharCode(96+n)+t,e=(e-n)/26}return t.toLocaleUpperCase()}static ABCatNum(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=0,i=0;for(let e=0;e<n;e++)i=t[e].charCodeAt(0)-96,r+=i*26**(n-e-1);return r===0?NaN:r-1}static chatAtABC(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+97)+t,e=Math.floor(e/26)-1;return t.toUpperCase()}static commonExtend(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)t[e]!=null&&(n[e]=t[e]);return n}static hasIntersectionBetweenTwoRanges(e,t,n,r){return t>=n&&r>=e}static isStartValidPosition(e){return/^[A-Za-zА-Яа-яЁё_]/.test(e)}static isValidParameter(e){let t=/[~!@#$%^&*()+=\-{}\[\]\|:;"'<>,?\/ ]+/.test(e),n=e.length<=255;return!t&&n}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static now(){return performance&&performance.now?performance.now():Date.now()}};function ae(...e){let t={},n=e.length;for(let r=n-1;r>=0;r--){let n=e[r];if(n){let e=Object.keys(n);for(let r of e)t[r]===void 0&&(t[r]=n[r])}}return t}let oe=()=>typeof process<`u`&&process.versions!=null&&process.versions.node!=null,se=/* @__PURE__ */ function(e){return e[e.DEFAULT_SERIES=0]=`DEFAULT_SERIES`,e[e.ALTERNATE_SERIES=1]=`ALTERNATE_SERIES`,e}({}),ce=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.THIN=1]=`THIN`,e[e.HAIR=2]=`HAIR`,e[e.DOTTED=3]=`DOTTED`,e[e.DASHED=4]=`DASHED`,e[e.DASH_DOT=5]=`DASH_DOT`,e[e.DASH_DOT_DOT=6]=`DASH_DOT_DOT`,e[e.DOUBLE=7]=`DOUBLE`,e[e.MEDIUM=8]=`MEDIUM`,e[e.MEDIUM_DASHED=9]=`MEDIUM_DASHED`,e[e.MEDIUM_DASH_DOT=10]=`MEDIUM_DASH_DOT`,e[e.MEDIUM_DASH_DOT_DOT=11]=`MEDIUM_DASH_DOT_DOT`,e[e.SLANT_DASH_DOT=12]=`SLANT_DASH_DOT`,e[e.THICK=13]=`THICK`,e}({}),le=/* @__PURE__ */ function(e){return e.TOP=`top`,e.BOTTOM=`bottom`,e.LEFT=`left`,e.RIGHT=`right`,e.NONE=`none`,e.ALL=`all`,e.OUTSIDE=`outside`,e.INSIDE=`inside`,e.HORIZONTAL=`horizontal`,e.VERTICAL=`vertical`,e.TLBR=`tlbr`,e.TLBC_TLMR=`tlbc_tlmr`,e.TLBR_TLBC_TLMR=`tlbr_tlbc_tlmr`,e.BLTR=`bl_tr`,e.MLTR_BCTR=`mltr_bctr`,e}({}),ue=/* @__PURE__ */ function(e){return e[e.UNSUPPORTED=0]=`UNSUPPORTED`,e[e.RGB=1]=`RGB`,e[e.HEX=2]=`HEX`,e[e.THEME=3]=`THEME`,e}({}),de=/* @__PURE__ */ function(e){return e[e.ON=0]=`ON`,e[e.OFF=1]=`OFF`,e}({}),fe=/* @__PURE__ */ function(e){return e[e.PASTE_NORMAL=0]=`PASTE_NORMAL`,e[e.PASTE_NO_BORDERS=1]=`PASTE_NO_BORDERS`,e[e.PASTE_FORMAT=2]=`PASTE_FORMAT`,e[e.PASTE_FORMULA=3]=`PASTE_FORMULA`,e[e.PASTE_DATA_VALIDATION=4]=`PASTE_DATA_VALIDATION`,e[e.PASTE_VALUES=5]=`PASTE_VALUES`,e[e.PASTE_CONDITIONAL_FORMATTING=6]=`PASTE_CONDITIONAL_FORMATTING`,e[e.PASTE_COLUMN_WIDTHS=7]=`PASTE_COLUMN_WIDTHS`,e}({}),pe=/* @__PURE__ */ function(e){return e.Date1900=`date1900`,e.Date1904=`date1904`,e}({}),me=/* @__PURE__ */ function(e){return e[e.LEFT=0]=`LEFT`,e[e.RIGHT=1]=`RIGHT`,e}({}),he=/* @__PURE__ */ function(e){return e[e.DOCUMENT=0]=`DOCUMENT`,e[e.PROJECT=1]=`PROJECT`,e}({}),ge=/* @__PURE__ */ function(e){return e[e.COLUMNS=0]=`COLUMNS`,e[e.ROWS=1]=`ROWS`,e}({}),_e=/* @__PURE__ */ function(e){return e[e.UP=0]=`UP`,e[e.RIGHT=1]=`RIGHT`,e[e.DOWN=2]=`DOWN`,e[e.LEFT=3]=`LEFT`,e}({});function ve(e){switch(e){case 3:return 1;case 1:return 3;case 0:return 2;case 2:return 0}}let ye=/* @__PURE__ */ function(e){return e[e.INTERPOLATION_POINT_TYPE_UNSPECIFIED=0]=`INTERPOLATION_POINT_TYPE_UNSPECIFIED`,e[e.MIN=1]=`MIN`,e[e.MAX=2]=`MAX`,e[e.NUMBER=3]=`NUMBER`,e[e.PERCENT=4]=`PERCENT`,e[e.PERCENTILE=5]=`PERCENTILE`,e}({}),be=/* @__PURE__ */ function(e){return e.EN_US=`enUS`,e.FR_FR=`frFR`,e.ZH_CN=`zhCN`,e.RU_RU=`ruRU`,e.ZH_TW=`zhTW`,e.ZH_HK=`zhHK`,e.VI_VN=`viVN`,e.FA_IR=`faIR`,e.JA_JP=`jaJP`,e.KO_KR=`koKR`,e.ES_ES=`esES`,e.CA_ES=`caES`,e.SK_SK=`skSK`,e.PT_BR=`ptBR`,e.DE_DE=`deDE`,e.IT_IT=`itIT`,e.ID_ID=`idID`,e.PL_PL=`plPL`,e.AR_SA=`arSA`,e}({}),xe={enUS:{name:`English`,tag:`en-US`,direction:`ltr`},frFR:{name:`Français`,tag:`fr-FR`,direction:`ltr`},zhCN:{name:`简体中文`,tag:`zh-CN`,direction:`ltr`},ruRU:{name:`Русский`,tag:`ru-RU`,direction:`ltr`},zhTW:{name:`繁體中文`,tag:`zh-TW`,direction:`ltr`},zhHK:{name:`繁體中文(香港)`,tag:`zh-HK`,direction:`ltr`},viVN:{name:`Tiếng Việt`,tag:`vi-VN`,direction:`ltr`},faIR:{name:`فارسی`,tag:`fa-IR`,direction:`rtl`,numberingSystem:`arabext`},jaJP:{name:`日本語`,tag:`ja-JP`,direction:`ltr`},koKR:{name:`한국어`,tag:`ko-KR`,direction:`ltr`},esES:{name:`Español`,tag:`es-ES`,direction:`ltr`},caES:{name:`Català`,tag:`ca-ES`,direction:`ltr`},skSK:{name:`Slovenčina`,tag:`sk-SK`,direction:`ltr`},ptBR:{name:`Português (Brasil)`,tag:`pt-BR`,direction:`ltr`},deDE:{name:`Deutsch`,tag:`de-DE`,direction:`ltr`},itIT:{name:`Italiano`,tag:`it-IT`,direction:`ltr`},idID:{name:`Bahasa Indonesia`,tag:`id-ID`,direction:`ltr`},plPL:{name:`Polski`,tag:`pl-PL`,direction:`ltr`},arSA:{name:`العربية`,tag:`ar-SA`,direction:`rtl`,numberingSystem:`arab`}},Se=/* @__PURE__ */ function(e){return e[e.PERSON=0]=`PERSON`,e[e.FILE=1]=`FILE`,e[e.DATE=2]=`DATE`,e[e.LOCATION=3]=`LOCATION`,e[e.EVENT=4]=`EVENT`,e}({}),Ce=/* @__PURE__ */ function(e){return e[e.RANGE=0]=`RANGE`,e[e.SHEET=1]=`SHEET`,e}({}),we=/* @__PURE__ */ function(e){return e[e.RELATIVE_DATE_UNSPECIFIED=0]=`RELATIVE_DATE_UNSPECIFIED`,e[e.PAST_YEAR=1]=`PAST_YEAR`,e[e.PAST_MONTH=2]=`PAST_MONTH`,e[e.PAST_WEEK=3]=`PAST_WEEK`,e[e.YESTERDAY=4]=`YESTERDAY`,e[e.TODAY=5]=`TODAY`,e[e.TOMORROW=6]=`TOMORROW`,e}({}),Te=/* @__PURE__ */ function(e){return e[e.GRID=0]=`GRID`,e[e.KANBAN=1]=`KANBAN`,e[e.GANTT=2]=`GANTT`,e[e.CHART=3]=`CHART`,e}({}),Ee=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT_TO_RIGHT=1]=`LEFT_TO_RIGHT`,e[e.RIGHT_TO_LEFT=2]=`RIGHT_TO_LEFT`,e}({}),De=/* @__PURE__ */ function(e){return e[e.DASH=0]=`DASH`,e[e.DASH_DOT_DOT_HEAVY=1]=`DASH_DOT_DOT_HEAVY`,e[e.DASH_DOT_HEAVY=2]=`DASH_DOT_HEAVY`,e[e.DASHED_HEAVY=3]=`DASHED_HEAVY`,e[e.DASH_LONG=4]=`DASH_LONG`,e[e.DASH_LONG_HEAVY=5]=`DASH_LONG_HEAVY`,e[e.DOT_DASH=6]=`DOT_DASH`,e[e.DOT_DOT_DASH=7]=`DOT_DOT_DASH`,e[e.DOTTED=8]=`DOTTED`,e[e.DOTTED_HEAVY=9]=`DOTTED_HEAVY`,e[e.DOUBLE=10]=`DOUBLE`,e[e.NONE=11]=`NONE`,e[e.SINGLE=12]=`SINGLE`,e[e.THICK=13]=`THICK`,e[e.WAVE=14]=`WAVE`,e[e.WAVY_DOUBLE=15]=`WAVY_DOUBLE`,e[e.WAVY_HEAVY=16]=`WAVY_HEAVY`,e[e.WORDS=17]=`WORDS`,e[e.SINGLE_ACCOUNTING=18]=`SINGLE_ACCOUNTING`,e[e.DOUBLE_ACCOUNTING=19]=`DOUBLE_ACCOUNTING`,e}({}),Oe=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.LEFT=1]=`LEFT`,e[e.CENTER=2]=`CENTER`,e[e.RIGHT=3]=`RIGHT`,e[e.JUSTIFIED=4]=`JUSTIFIED`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTED=6]=`DISTRIBUTED`,e}({}),ke=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TOP=1]=`TOP`,e[e.MIDDLE=2]=`MIDDLE`,e[e.BOTTOM=3]=`BOTTOM`,e}({}),Ae=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.OVERFLOW=1]=`OVERFLOW`,e[e.CLIP=2]=`CLIP`,e[e.WRAP=3]=`WRAP`,e}({}),je=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ITALIC=1]=`ITALIC`,e}({}),Me=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.BOLD=1]=`BOLD`,e}({}),Ne=/* @__PURE__ */ function(e){return e[e.NORMAL=1]=`NORMAL`,e[e.SUBSCRIPT=2]=`SUBSCRIPT`,e[e.SUPERSCRIPT=3]=`SUPERSCRIPT`,e}({}),Pe=/* @__PURE__ */ function(e){return e[e.FALSE=0]=`FALSE`,e[e.TRUE=1]=`TRUE`,e}({}),Fe=/* @__PURE__ */ function(e){return e[e.STRING=1]=`STRING`,e[e.NUMBER=2]=`NUMBER`,e[e.BOOLEAN=3]=`BOOLEAN`,e[e.FORCE_STRING=4]=`FORCE_STRING`,e}({}),Ie=/* @__PURE__ */ function(e){return e[e.DARK1=0]=`DARK1`,e[e.LIGHT1=1]=`LIGHT1`,e[e.DARK2=2]=`DARK2`,e[e.LIGHT2=3]=`LIGHT2`,e[e.ACCENT1=4]=`ACCENT1`,e[e.ACCENT2=5]=`ACCENT2`,e[e.ACCENT3=6]=`ACCENT3`,e[e.ACCENT4=7]=`ACCENT4`,e[e.ACCENT5=8]=`ACCENT5`,e[e.ACCENT6=9]=`ACCENT6`,e[e.HYPERLINK=10]=`HYPERLINK`,e[e.FOLLOWED_HYPERLINK=11]=`FOLLOWED_HYPERLINK`,e}({}),Le=/* @__PURE__ */ function(e){return e.OFFICE=`Office`,e.OFFICE_2007_2010=`Office 2007-2010`,e.GRAYSCALE=`Grayscale`,e.BLUE_WARM=`Blue Warm`,e.BLUE=`Blue`,e.BLUE_II=`Blue II`,e.BLUE_GREEN=`Blue Green`,e.GREEN=`Green`,e.GREEN_YELLOW=`Green Yellow`,e.YELLOW=`Yellow`,e.YELLOW_ORANGE=`Yellow Orange`,e.ORANGE=`Orange`,e.ORANGE_RED=`Orange Red`,e.RED_ORANGE=`Red Orange`,e.RED=`Red`,e.RED_VIOLET=`Red Violet`,e.VIOLET=`Violet`,e.VIOLET_II=`Violet II`,e.MEDIAN=`Median`,e.PAPER=`Paper`,e.MARQUEE=`Marquee`,e.SLIPSTREAM=`Slipstream`,e.Aspect=`Aspect`,e}({});var Re=`@univerjs/core`,ze=`1.6.0`;function Be(e,t){let n=e.indexOf(t);return n>-1&&(e.splice(n,1),!0)}function Ve(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function He(e,t){let n=/* @__PURE__ */ new Set,r=[];for(let i of e){let e=t(i);n.has(e)||(n.add(e),r.push(i))}return r}function Ue(e,t){for(let n=e.length-1;n>-1;n--){let r=e[n];if(t(r,n))return r}return null}function We(e,t){if(e.length===0)return e;let n=t%e.length;return e.slice(n).concat(e.slice(0,n))}function Ge(e,t){let n=/* @__PURE__ */ new Map;return e.forEach(e=>{let r=t(e),i=n.get(r);n.has(r)||(i=[],n.set(r,i)),i.push(e)}),n}function Ke(e){return Array.isArray(e)?e:[e]}function qe(e,t){t.forEach(t=>e.add(t))}function Je(e,t){t.forEach(([t])=>{e.has(t)&&e.get(t)})}var Ye=class extends Error{constructor(e){super(e),this.name=`CustomCommandExecutionError`}},Xe=class extends Ye{constructor(){super(`Canceled by facade`),this.name=`CanceledError`}};async function Ze(e){for(let[t,n]of e.entries())try{if(!await n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}function Qe(e){for(let[t,n]of e.entries())try{if(!n())return{index:t,result:!1}}catch(e){return{index:t,result:!1,error:e}}return{result:!0,index:-1}}var $e=typeof global==`object`&&global&&global.Object===Object&&global,et=typeof self==`object`&&self&&self.Object===Object&&self,tt=$e||et||Function(`return this`)(),nt=tt.Symbol,rt=Object.prototype,it=rt.hasOwnProperty,at=rt.toString,ot=nt?nt.toStringTag:void 0;function st(e){var t=it.call(e,ot),n=e[ot];try{e[ot]=void 0;var r=!0}catch{}var i=at.call(e);return r&&(t?e[ot]=n:delete e[ot]),i}var ct=Object.prototype.toString;function lt(e){return ct.call(e)}var ut=`[object Null]`,dt=`[object Undefined]`,ft=nt?nt.toStringTag:void 0;function pt(e){return e==null?e===void 0?dt:ut:ft&&ft in Object(e)?st(e):lt(e)}function mt(e){return typeof e==`object`&&!!e}var ht=`[object Symbol]`;function gt(e){return typeof e==`symbol`||mt(e)&&pt(e)==ht}function _t(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var vt=Array.isArray,yt=1/0,bt=nt?nt.prototype:void 0,xt=bt?bt.toString:void 0;function St(e){if(typeof e==`string`)return e;if(vt(e))return _t(e,St)+``;if(gt(e))return xt?xt.call(e):``;var t=e+``;return t==`0`&&1/e==-yt?`-0`:t}var Ct=/\s/;function wt(e){for(var t=e.length;t--&&Ct.test(e.charAt(t)););return t}var Tt=/^\s+/;function Et(e){return e&&e.slice(0,wt(e)+1).replace(Tt,``)}function Dt(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var Ot=NaN,kt=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,jt=/^0o[0-7]+$/i,Mt=parseInt;function Nt(e){if(typeof e==`number`)return e;if(gt(e))return Ot;if(Dt(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=Dt(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=Et(e);var n=At.test(e);return n||jt.test(e)?Mt(e.slice(2),n?2:8):kt.test(e)?Ot:+e}function Pt(e){return e}var Ft=`[object AsyncFunction]`,It=`[object Function]`,Lt=`[object GeneratorFunction]`,Rt=`[object Proxy]`;function zt(e){if(!Dt(e))return!1;var t=pt(e);return t==It||t==Lt||t==Ft||t==Rt}var Bt=tt[`__core-js_shared__`],Vt=function(){var e=/[^.]+$/.exec(Bt&&Bt.keys&&Bt.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function Ht(e){return!!Vt&&Vt in e}var Ut=Function.prototype.toString;function Wt(e){if(e!=null){try{return Ut.call(e)}catch{}try{return e+``}catch{}}return``}var Gt=/[\\^$.*+?()[\]{}|]/g,Kt=/^\[object .+?Constructor\]$/,qt=Function.prototype,Jt=Object.prototype,Yt=qt.toString,Xt=Jt.hasOwnProperty,Zt=RegExp(`^`+Yt.call(Xt).replace(Gt,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Qt(e){return!Dt(e)||Ht(e)?!1:(zt(e)?Zt:Kt).test(Wt(e))}function $t(e,t){return e==null?void 0:e[t]}function en(e,t){var n=$t(e,t);return Qt(n)?n:void 0}var tn=Object.create,nn=function(){function e(){}return function(t){if(!Dt(t))return{};if(tn)return tn(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function rn(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function an(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var on=800,sn=16,cn=Date.now;function ln(e){var t=0,n=0;return function(){var r=cn(),i=sn-(r-n);if(n=r,i>0){if(++t>=on)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function un(e){return function(){return e}}var dn=function(){try{var e=en(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),fn=ln(dn?function(e,t){return dn(e,`toString`,{configurable:!0,enumerable:!1,value:un(t),writable:!0})}:Pt),pn=9007199254740991,mn=/^(?:0|[1-9]\d*)$/;function hn(e,t){var n=typeof e;return t??=pn,!!t&&(n==`number`||n!=`symbol`&&mn.test(e))&&e>-1&&e%1==0&&e<t}function gn(e,t,n){t==`__proto__`&&dn?dn(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function _n(e,t){return e===t||e!==e&&t!==t}var vn=Object.prototype.hasOwnProperty;function yn(e,t,n){var r=e[t];(!(vn.call(e,t)&&_n(r,n))||n===void 0&&!(t in e))&&gn(e,t,n)}function bn(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?gn(n,s,c):yn(n,s,c)}return n}var xn=Math.max;function Sn(e,t,n){return t=xn(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=xn(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),rn(e,this,s)}}function Cn(e,t){return fn(Sn(e,t,Pt),e+``)}var wn=9007199254740991;function Tn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=wn}function En(e){return e!=null&&Tn(e.length)&&!zt(e)}function Dn(e,t,n){if(!Dt(n))return!1;var r=typeof t;return(r==`number`?En(n)&&hn(t,n.length):r==`string`&&t in n)?_n(n[t],e):!1}function On(e){return Cn(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Dn(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var kn=Object.prototype;function An(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||kn)}function jn(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Mn=`[object Arguments]`;function Nn(e){return mt(e)&&pt(e)==Mn}var Pn=Object.prototype,Fn=Pn.hasOwnProperty,In=Pn.propertyIsEnumerable,Ln=Nn(function(){return arguments}())?Nn:function(e){return mt(e)&&Fn.call(e,`callee`)&&!In.call(e,`callee`)};function Rn(){return!1}var zn=typeof e==`object`&&e&&!e.nodeType&&e,Bn=zn&&typeof module==`object`&&module&&!module.nodeType&&module,Vn=Bn&&Bn.exports===zn?tt.Buffer:void 0,Hn=(Vn?Vn.isBuffer:void 0)||Rn,Un=`[object Arguments]`,Wn=`[object Array]`,Gn=`[object Boolean]`,Kn=`[object Date]`,qn=`[object Error]`,Jn=`[object Function]`,Yn=`[object Map]`,Xn=`[object Number]`,Zn=`[object Object]`,Qn=`[object RegExp]`,$n=`[object Set]`,er=`[object String]`,tr=`[object WeakMap]`,nr=`[object ArrayBuffer]`,rr=`[object DataView]`,ir=`[object Float32Array]`,ar=`[object Float64Array]`,or=`[object Int8Array]`,sr=`[object Int16Array]`,cr=`[object Int32Array]`,lr=`[object Uint8Array]`,ur=`[object Uint8ClampedArray]`,dr=`[object Uint16Array]`,fr=`[object Uint32Array]`,B={};B[ir]=B[ar]=B[or]=B[sr]=B[cr]=B[lr]=B[ur]=B[dr]=B[fr]=!0,B[Un]=B[Wn]=B[nr]=B[Gn]=B[rr]=B[Kn]=B[qn]=B[Jn]=B[Yn]=B[Xn]=B[Zn]=B[Qn]=B[$n]=B[er]=B[tr]=!1;function pr(e){return mt(e)&&Tn(e.length)&&!!B[pt(e)]}function mr(e){return function(t){return e(t)}}var hr=typeof e==`object`&&e&&!e.nodeType&&e,gr=hr&&typeof module==`object`&&module&&!module.nodeType&&module,_r=gr&&gr.exports===hr&&$e.process,vr=function(){try{return gr&&gr.require&&gr.require(`util`).types||_r&&_r.binding&&_r.binding(`util`)}catch{}}(),yr=vr&&vr.isTypedArray,br=yr?mr(yr):pr,xr=Object.prototype.hasOwnProperty;function Sr(e,t){var n=vt(e),r=!n&&Ln(e),i=!n&&!r&&Hn(e),a=!n&&!r&&!i&&br(e),o=n||r||i||a,s=o?jn(e.length,String):[],c=s.length;for(var l in e)(t||xr.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||hn(l,c)))&&s.push(l);return s}function Cr(e,t){return function(n){return e(t(n))}}function wr(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var Tr=Object.prototype.hasOwnProperty;function Er(e){if(!Dt(e))return wr(e);var t=An(e),n=[];for(var r in e)(r!=`constructor`||!t&&Tr.call(e,r))&&n.push(r);return n}function Dr(e){return En(e)?Sr(e,!0):Er(e)}var Or=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kr=/^\w*$/;function Ar(e,t){if(vt(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||gt(e)?!0:kr.test(e)||!Or.test(e)||t!=null&&e in Object(t)}var jr=en(Object,`create`);function Mr(){this.__data__=jr?jr(null):{},this.size=0}function Nr(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var Pr=`__lodash_hash_undefined__`,Fr=Object.prototype.hasOwnProperty;function Ir(e){var t=this.__data__;if(jr){var n=t[e];return n===Pr?void 0:n}return Fr.call(t,e)?t[e]:void 0}var Lr=Object.prototype.hasOwnProperty;function Rr(e){var t=this.__data__;return jr?t[e]!==void 0:Lr.call(t,e)}var zr=`__lodash_hash_undefined__`;function Br(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=jr&&t===void 0?zr:t,this}function Vr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Vr.prototype.clear=Mr,Vr.prototype.delete=Nr,Vr.prototype.get=Ir,Vr.prototype.has=Rr,Vr.prototype.set=Br;function Hr(){this.__data__=[],this.size=0}function Ur(e,t){for(var n=e.length;n--;)if(_n(e[n][0],t))return n;return-1}var Wr=Array.prototype.splice;function Gr(e){var t=this.__data__,n=Ur(t,e);return n<0?!1:(n==t.length-1?t.pop():Wr.call(t,n,1),--this.size,!0)}function Kr(e){var t=this.__data__,n=Ur(t,e);return n<0?void 0:t[n][1]}function qr(e){return Ur(this.__data__,e)>-1}function Jr(e,t){var n=this.__data__,r=Ur(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function Yr(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Yr.prototype.clear=Hr,Yr.prototype.delete=Gr,Yr.prototype.get=Kr,Yr.prototype.has=qr,Yr.prototype.set=Jr;var Xr=en(tt,`Map`);function Zr(){this.size=0,this.__data__={hash:new Vr,map:new(Xr||Yr),string:new Vr}}function Qr(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function $r(e,t){var n=e.__data__;return Qr(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function ei(e){var t=$r(this,e).delete(e);return this.size-=+!!t,t}function ti(e){return $r(this,e).get(e)}function ni(e){return $r(this,e).has(e)}function ri(e,t){var n=$r(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function ii(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ii.prototype.clear=Zr,ii.prototype.delete=ei,ii.prototype.get=ti,ii.prototype.has=ni,ii.prototype.set=ri;var ai=`Expected a function`;function oi(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(ai);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(oi.Cache||ii),n}oi.Cache=ii;var si=500;function ci(e){var t=oi(e,function(e){return n.size===si&&n.clear(),e}),n=t.cache;return t}var li=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ui=/\\(\\)?/g,di=ci(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(li,function(e,n,r,i){t.push(r?i.replace(ui,`$1`):n||e)}),t});function fi(e){return e==null?``:St(e)}function pi(e,t){return vt(e)?e:Ar(e,t)?[e]:di(fi(e))}var mi=1/0;function hi(e){if(typeof e==`string`||gt(e))return e;var t=e+``;return t==`0`&&1/e==-mi?`-0`:t}function gi(e,t){t=pi(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[hi(t[n++])];return n&&n==r?e:void 0}function _i(e,t,n){var r=e==null?void 0:gi(e,t);return r===void 0?n:r}var vi=Cr(Object.getPrototypeOf,Object),yi=`[object Object]`,bi=Function.prototype,xi=Object.prototype,Si=bi.toString,Ci=xi.hasOwnProperty,wi=Si.call(Object);function Ti(e){if(!mt(e)||pt(e)!=yi)return!1;var t=vi(e);if(t===null)return!0;var n=Ci.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Si.call(n)==wi}function Ei(){this.__data__=new Yr,this.size=0}function Di(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Oi(e){return this.__data__.get(e)}function ki(e){return this.__data__.has(e)}var Ai=200;function ji(e,t){var n=this.__data__;if(n instanceof Yr){var r=n.__data__;if(!Xr||r.length<Ai-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ii(r)}return n.set(e,t),this.size=n.size,this}function Mi(e){var t=this.__data__=new Yr(e);this.size=t.size}Mi.prototype.clear=Ei,Mi.prototype.delete=Di,Mi.prototype.get=Oi,Mi.prototype.has=ki,Mi.prototype.set=ji;var Ni=typeof e==`object`&&e&&!e.nodeType&&e,Pi=Ni&&typeof module==`object`&&module&&!module.nodeType&&module,Fi=Pi&&Pi.exports===Ni?tt.Buffer:void 0,Ii=Fi?Fi.allocUnsafe:void 0;function Li(e,t){if(t)return e.slice();var n=e.length,r=Ii?Ii(n):new e.constructor(n);return e.copy(r),r}var Ri=tt.Uint8Array;function zi(e){var t=new e.constructor(e.byteLength);return new Ri(t).set(new Ri(e)),t}function Bi(e,t){var n=t?zi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Vi(e){return typeof e.constructor==`function`&&!An(e)?nn(vi(e)):{}}function Hi(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var Ui=Hi(),Wi=function(){return tt.Date.now()},Gi=`Expected a function`,Ki=Math.max,qi=Math.min;function Ji(e,t,n){var r,i,a,o,s,c,l=0,u=!1,d=!1,f=!0;if(typeof e!=`function`)throw TypeError(Gi);t=Nt(t)||0,Dt(n)&&(u=!!n.leading,d=`maxWait`in n,a=d?Ki(Nt(n.maxWait)||0,t):a,f=`trailing`in n?!!n.trailing:f);function p(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n),o}function m(e){return l=e,s=setTimeout(_,t),u?p(e):o}function h(e){var n=e-c,r=e-l,i=t-n;return d?qi(i,a-r):i}function g(e){var n=e-c,r=e-l;return c===void 0||n>=t||n<0||d&&r>=a}function _(){var e=Wi();if(g(e))return v(e);s=setTimeout(_,h(e))}function v(e){return s=void 0,f&&r?p(e):(r=i=void 0,o)}function y(){s!==void 0&&clearTimeout(s),l=0,r=c=i=s=void 0}function b(){return s===void 0?o:v(Wi())}function x(){var e=Wi(),n=g(e);if(r=arguments,i=this,c=e,n){if(s===void 0)return m(c);if(d)return clearTimeout(s),s=setTimeout(_,t),p(c)}return s===void 0&&(s=setTimeout(_,t)),o}return x.cancel=y,x.flush=b,x}function Yi(e,t,n){(n!==void 0&&!_n(e[t],n)||n===void 0&&!(t in e))&&gn(e,t,n)}function Xi(e){return mt(e)&&En(e)}function Zi(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}function Qi(e){return bn(e,Dr(e))}function $i(e,t,n,r,i,a,o){var s=Zi(e,n),c=Zi(t,n),l=o.get(c);if(l)Yi(e,n,l);else{var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=vt(c),p=!f&&Hn(c),m=!f&&!p&&br(c);u=c,f||p||m?vt(s)?u=s:Xi(s)?u=an(s):p?(d=!1,u=Li(c,!0)):m?(d=!1,u=Bi(c,!0)):u=[]:Ti(c)||Ln(c)?(u=s,Ln(s)?u=Qi(s):(!Dt(s)||zt(s))&&(u=Vi(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Yi(e,n,u)}}function ea(e,t,n,r,i){e!==t&&Ui(t,function(a,o){if(i||=new Mi,Dt(a))$i(e,t,o,n,ea,r,i);else{var s=r?r(Zi(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Yi(e,o,s)}},Dr)}var ta=On(function(e,t,n,r){ea(e,t,n,r)}),na=On(function(e,t,n){ea(e,t,n)});function ra(e,t,n,r){if(!Dt(e))return e;t=pi(t,e);for(var i=-1,a=t.length,o=a-1,s=e;s!=null&&++i<a;){var c=hi(t[i]),l=n;if(c===`__proto__`||c===`constructor`||c===`prototype`)return e;if(i!=o){var u=s[c];l=r?r(u,c,s):void 0,l===void 0&&(l=Dt(u)?u:hn(t[i+1])?[]:{})}yn(s,c,l),s=s[c]}return e}function ia(e,t,n){return e==null?e:ra(e,t,n)}function aa(e,t,n,r){return r=typeof r==`function`?r:void 0,e==null?e:ra(e,t,n,r)}let oa=(0,i.createIdentifier)(`univer.config-service`);var sa=class{constructor(){T(this,`_configChanged$`,new t.Subject),T(this,`configChanged$`,this._configChanged$.asObservable()),T(this,`_config`,/* @__PURE__ */ new Map)}dispose(){this._config.clear(),this._configChanged$.complete()}getConfig(e){return this._config.get(e)}setConfig(e,t,n){let{merge:r=!1}=n||{},i=this._config.get(e)??{};i=r?na(i,t):t,this._config.set(e,i),this._configChanged$.next({[e]:i})}deleteConfig(e){return this._config.delete(e)}subscribeConfigValue$(e){return new t.Observable(n=>{Object.prototype.hasOwnProperty.call(this._config,e)&&n.next(this._config.get(e));let r=this.configChanged$.pipe((0,t.filter)(t=>Object.prototype.hasOwnProperty.call(t,e))).subscribe(t=>n.next(t[e]));return()=>r.unsubscribe()})}};let ca=(0,i.createIdentifier)(`univer.context-service`);var la=class extends k{constructor(...e){super(...e),T(this,`_contextChanged$`,new t.Subject),T(this,`contextChanged$`,this._contextChanged$.asObservable()),T(this,`_contextMap`,/* @__PURE__ */ new Map)}dispose(){super.dispose(),this._contextChanged$.complete(),this._contextMap.clear()}getContextValue(e){return this._contextMap.get(e)??!1}setContextValue(e,t){this._contextMap.set(e,t),this._contextChanged$.next({[e]:t})}subscribeContextValue$(e){return new t.Observable(n=>{let r=this._contextChanged$.pipe((0,t.filter)(t=>t[e]!==void 0)).subscribe(t=>n.next(t[e]));return this._contextMap.has(e)&&n.next(this._contextMap.get(e)),()=>r.unsubscribe()})}};let ua=/* @__PURE__ */ function(e){return e[e.SILENT=0]=`SILENT`,e[e.ERROR=1]=`ERROR`,e[e.WARN=2]=`WARN`,e[e.INFO=3]=`INFO`,e[e.VERBOSE=4]=`VERBOSE`,e}({}),da=(0,i.createIdentifier)(`univer.log`);var fa=class extends k{constructor(...e){super(...e),T(this,`_logLevel`,3),T(this,`_deduction`,/* @__PURE__ */ new Set)}dispose(){super.dispose(),this._logLevel=3,this._deduction.clear()}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)}deprecate(...e){this._logLevel>=2&&this._logWithDeduplication(console.error,...e)}setLogLevel(e){this._logLevel=e}_log(e,...t){let n=t[0];/^\[(.*?)\]/g.test(n)?e(`\x1B[97;104m${n}\x1B[0m`,...t.slice(1)):e(...t)}_logWithDeduplication(e,...t){let n=pa(...t);this._deduction.has(n)||(this._deduction.add(n),this._log(e,...t))}};function pa(...e){return e.map(e=>JSON.stringify(e)).join(``)}function V(e,t){return function(n,r){t(n,r,e)}}function ma(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let ha=`command.logExecution`,ga=/* @__PURE__ */ function(e){return e[e.COMMAND=0]=`COMMAND`,e[e.OPERATION=1]=`OPERATION`,e[e.MUTATION=2]=`MUTATION`,e}({}),_a=(0,i.createIdentifier)(`univer.core.command-service`);var va=class{constructor(){T(this,`_commands`,/* @__PURE__ */ new Map),T(this,`_commandTypes`,/* @__PURE__ */ new Map)}registerCommand(e){if(this._commands.has(e.id))throw Error(`[CommandRegistry]: command "${e.id}" has been registered before.`);return this._commands.set(e.id,e),this._commandTypes.set(e.id,e.type),D(()=>{this.unregisterCommand(e.id)})}unregisterCommand(e){this._commands.delete(e),this._commandTypes.delete(e)}hasCommand(e){return this._commands.has(e)}getCommand(e){return this._commands.has(e)?[this._commands.get(e)]:null}getCommandType(e){return this._commandTypes.get(e)}};let ya={id:`nil`,type:0,handler:()=>!0},ba=class extends k{constructor(e,t,n){super(),this._injector=e,this._logService=t,this._configService=n,T(this,`_commandRegistry`,void 0),T(this,`_beforeCommandExecutionListeners`,[]),T(this,`_commandExecutedListeners`,[]),T(this,`_collabMutationListeners`,[]),T(this,`_multiCommandDisposables`,/* @__PURE__ */ new Map),T(this,`_commandExecutingLevel`,0),T(this,`_commandExecutionStack`,[]),this._commandRegistry=new va,this.registerCommand(ya)}dispose(){super.dispose(),this._commandExecutedListeners.length=0,this._beforeCommandExecutionListeners.length=0,this._collabMutationListeners.length=0}disposed(){return this._disposed}_warnCommandSkippedAfterDisposed(e){this._logService.warn(`[CommandService]`,`command "${e}" skipped because CommandService is disposed.`)}hasCommand(e){return this._commandRegistry.hasCommand(e)}registerCommand(e){return this._commandRegistry.registerCommand(e)}unregisterCommand(e){var t;this._commandRegistry.unregisterCommand(e),(t=this._multiCommandDisposables.get(e))==null||t.dispose()}registerMultipleCommand(e){return this._registerMultiCommand(e)}beforeCommandExecuted(e){if(this._beforeCommandExecutionListeners.indexOf(e)===-1)return this._beforeCommandExecutionListeners.push(e),D(()=>{let t=this._beforeCommandExecutionListeners.indexOf(e);this._beforeCommandExecutionListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onCommandExecuted(e){if(this._commandExecutedListeners.indexOf(e)===-1)return this._commandExecutedListeners.push(e),D(()=>{let t=this._commandExecutedListeners.indexOf(e);this._commandExecutedListeners.splice(t,1)});throw Error(`[CommandService]: could not add a listener twice.`)}onMutationExecutedForCollab(e){if(this._collabMutationListeners.indexOf(e)===-1)return this._collabMutationListeners.push(e),D(()=>{let t=this._collabMutationListeners.indexOf(e);this._collabMutationListeners.splice(t,1)});throw Error(`[CommandService]: could not add a collab mutation listener twice.`)}async executeCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=await this._execute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}syncExecuteCommand(e,t,n){if(this._disposed)return this._warnCommandSkippedAfterDisposed(e),!1;try{let r=this._commandRegistry.getCommand(e);if(r){let[i]=r,a={id:i.id,type:i.type,params:t};this._attachMutationTrigger(i,t);let o=this._pushCommandExecutionStack(a),s=n??{};if(this._beforeCommandExecutionListeners.forEach(e=>e(a,s)),this._disposed)return o.dispose(),this._warnCommandSkippedAfterDisposed(e),!1;let c=this._syncExecute(i,t,s);return s.syncOnly||this._commandExecutedListeners.forEach(e=>e(a,s)),i.type===2&&this._collabMutationListeners.forEach(e=>e(a,s)),o.dispose(),c}throw Error(`[CommandService]: command "${e}" is not registered.`)}catch(e){if(e instanceof Ye)return!1;throw e}}_pushCommandExecutionStack(e){return this._commandExecutionStack.push(e),D(()=>Be(this._commandExecutionStack,e))}_registerMultiCommand(e){let t=this._commandRegistry.getCommand(e.id),n;if(t){let e=t[0];if(!(e instanceof xa))throw TypeError(`Command has registered as a single command.`);n=e}else{n=new xa(e.id);let t=new O;t.add(this._commandRegistry.registerCommand(n)),t.add(D(()=>{this._multiCommandDisposables.delete(e.id)})),this._multiCommandDisposables.set(e.id,t)}let r=n.registerImplementation(e);return D(()=>{if(r.dispose(),!n.hasImplementations()){var t;(t=this._multiCommandDisposables.get(e.id))==null||t.dispose()}})}_attachMutationTrigger(e,t){if(e.type!==2||!t)return;let n=Ue(this._commandExecutionStack,e=>e.type===0);if(n){this._setMutationTrigger(t,n.id);return}if(`trigger`in t&&t.trigger!==void 0)return;let r=Ue(this._commandExecutionStack,e=>e.type===1);r&&this._setMutationTrigger(t,r.id)}_setMutationTrigger(e,t){Object.assign(e,{trigger:t})}async _execute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(this._commandExecutingLevel,0))}executing command "${e.id}"`),this._commandExecutingLevel++;let r;try{r=await this._injector.invoke(e.handler,t,n),this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}_syncExecute(e,t,n){if(n!=null&&n.syncOnly)return!0;this._configService.getConfig(`command.logExecution`)!==!1&&this._logService.debug(`[CommandService]`,`${`|-`.repeat(Math.max(0,this._commandExecutingLevel))}executing command "${e.id}".`),this._commandExecutingLevel++;let r;try{if(r=this._injector.invoke(e.handler,t,n),r instanceof Promise)throw TypeError(`[CommandService]: Command handler should not return a promise.`);this._commandExecutingLevel--}catch(e){throw r=!1,this._commandExecutingLevel=0,e}return r}};ba=ma([V(0,(0,i.Inject)(i.Injector)),V(1,da),V(2,oa)],ba);var xa=class{constructor(e){this.id=e,T(this,`name`,void 0),T(this,`multi`,!0),T(this,`type`,0),T(this,`priority`,0),T(this,`_implementations`,[]),T(this,`handler`,async(e,t)=>{if(!this._implementations.length)return!1;let n=e.get(da),r=e.get(ca),a=e.get(i.Injector);for(let e of this._implementations){let i=e.command.preconditions;if((!i||i&&i(r))&&(n.debug(`[MultiCommand]`,`executing implementation "${e.command.name}".`),await a.invoke(e.command.handler,t)))return!0}return!1}),this.name=e}registerImplementation(e){let t={command:e};return this._implementations.push(t),this._implementations.sort((e,t)=>t.command.priority-e.command.priority),D(()=>{let e=this._implementations.indexOf(t);this._implementations.splice(e,1)})}hasImplementations(){return this._implementations.length>0}};function Sa(e,t,n){return Qe(e.map(e=>()=>t.syncExecuteCommand(e.id,e.params,n)))}function Ca(e,t,n){return Ze(e.map(e=>()=>t.executeCommand(e.id,e.params,n)))}function wa(e){return new t.Observable(t=>{let n=e((...e)=>t.next(e));return()=>n==null?void 0:n.dispose()})}function Ta(e){return function(n){return n.pipe((0,t.takeWhile)(t=>!e(t),!0))}}function Ea(e=0){return n=>{let r=[];return n.pipe((0,t.tap)(e=>r.push(e)),(0,t.debounceTime)(e),(0,t.map)(()=>r),(0,t.tap)(()=>r=[]))}}function Da(e){let n=new t.ReplaySubject(1);return setTimeout(()=>n.next(),e),n.pipe((0,t.take)(1))}function Oa(e,n){let r=new t.BehaviorSubject(n),i=e.subscribe(r),a=r.complete.bind(r);return r.complete=()=>{i.unsubscribe(),a()},r}let ka=e=>new Promise(n=>{(0,t.merge)(wa(e.onCommandExecuted.bind(e)).pipe((0,r.filter)(([e])=>e.type===2)),(0,t.timer)(300)).pipe((0,r.debounceTime)(16),(0,r.first)()).subscribe(()=>{n()})});function Aa(e,t){let n=0,r=e.length-1;if(t<e[0])return 0;if(t>=e[e.length-1])return e.length-1;for(;n<=r;){if(e[n]===t){for(;n<e.length&&e[n]===t;)n++;return n}if(t>e[n]&&t<e[n+1])return n+1;if(e[r]===t){for(;r<e.length&&e[r]===t;)r++;return r}if(t>e[r-1]&&t<e[r])return r;n++,r--}return-1}function ja(e,t){let n=0,r=e.length-1;for(;n<=r;){let i=Math.floor((r+n)/2);if(t<e[i]&&(i===0||t>=e[i-1]))return i;if(t>=e[i])n=i+1;else if(t<e[i])r=i-1;else return-1}return-1}function Ma(e,t){let n=0,r=e.length;for(;n<r;){let i=Math.floor((n+r)/2);e[i]<=t?n=i+1:r=i}return n<e.length?n:e.length-1}function Na(e,t,n=!1){let r=e.length-1;if(t<0||t<e[0])return 0;if(r=e.length<40||t<=e[20]||t>=e[r-20]?Aa(e,t):Ma(e,t),n){let t=e[r];return e.indexOf(t)}return r}function Pa(e){let t=new Blob([e],{type:`text/javascript`});return window.URL.createObjectURL(t)}function Fa(e,t){if(t==null||e==null)return!0;let{left:n=0,top:r=0,height:i=0,width:a=0,angle:o=0}=t,{left:s=0,top:c=0,height:l=0,width:u=0,angle:d=0}=e,f=u,p=l,m=a,h=i;return Math.abs(s-n)>2||Math.abs(c-r)>2||Math.abs(f-m)>2||Math.abs(p-h)>2||Math.abs(d-o)>1}let Ia={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],blanchedalmond:[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,134,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],darkyellow:[139,128,0],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,250,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],midnightblue:[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,221],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:[112,128,144],slategrey:[112,128,144],snow:[255,250,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,50]};var La=class e{static mix(t,n,r){r=Math.min(1,Math.max(0,r));let i=new e(t).toRgb(),a=new e(n).toRgb(),o=i.a??1,s=a.a??1,c={r:(a.r-i.r)*r+i.r,g:(a.g-i.g)*r+i.g,b:(a.b-i.b)*r+i.b,a:(s-o)*r+o};return new e(c)}static getContrastRatio(t,n){let r=new e(t).getLuminance(),i=new e(n).getLuminance();return(Math.max(r,i)+.05)/(Math.min(r,i)+.05)}constructor(t){if(T(this,`_color`,void 0),T(this,`_rgbColor`,void 0),T(this,`_isValid`,!1),t==null){this._setNullColor();return}if(t instanceof e){this._color={...t._color},this._rgbColor={...t._rgbColor};return}let n=Ba(t);if(n==null){this._setNullColor();return}this._color=n;let r=Ga(this._color);r==null?this._setNullColor():(this._rgbColor=r,this._isValid=!0)}get isValid(){return this._isValid}toRgb(){return this._rgbColor}toRgbString(){let{r:e,g:t,b:n,a:r=1}=this.toRgb(),i=r<1;return`rgb${i?`a`:``}(${e},${t},${n}${i?`,${r}`:``})`}toString(){return this.toRgbString()}toHexString(e){let{r:t,g:n,b:r,a:i=1}=this.toRgb(),a=i<1,o=[Ra(Math.round(t).toString(16)),Ra(Math.round(n).toString(16)),Ra(Math.round(r).toString(16)),Ra(Math.round(i*255).toString(16))];return e&&o[0][0]===o[0][1]&&o[1][0]===o[1][1]&&o[2][0]===o[2][1]&&o[3][0]===o[3][1]?a?`#${o[0][0]}${o[1][0]}${o[2][0]}${o[3][0]}`:`#${o[0][0]}${o[1][0]}${o[2][0]}`:a?`#${o[0]}${o[1]}${o[2]}${o[3]}`:`#${o[0]}${o[1]}${o[2]}`}toHsv(){return Xa(this.toRgb())}toHsl(){return Ya(this.toRgb())}lighten(t=10){let n=this.toHsl();return n.l+=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}darken(t=10){let n=this.toHsl();return n.l-=t,n.l=Math.min(Math.max(n.l,0),100),new e(n)}setAlpha(t){return new e({...this._rgbColor,a:t})}getLuminance(){let{r:e,g:t,b:n}=this.toRgb();return e=za(e),t=za(t),n=za(n),Number((.2126*e+.7152*t+.0722*n).toFixed(3))}getBrightness(){let{r:e,g:t,b:n}=this.toRgb();return(e*299+t*587+n*114)/1e3}getAlpha(){return this._color.a??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}}};let Ra=e=>e.length===1?`0${e}`:e,za=e=>(e/=255,e<=.03928?e/12.92:((e+.055)/1.055)**2.4),Ba=e=>{if(Qa(e)){if(`r`in e){let t={r:Math.round(e.r),g:Math.round(e.g),b:Math.round(e.b)};return e.a!==void 0&&(t.a=e.a),t}if(`l`in e){let t={h:Math.round(e.h),s:e.s,l:e.l};return e.a!==void 0&&(t.a=e.a),t}let t={h:Math.round(e.h),s:e.s,v:e.v};return e.a!==void 0&&(t.a=e.a),t}let t=e.trim().toLowerCase();if(Ia[t]){let e=Ia[t],n={r:Math.round(e[0]),g:Math.round(e[1]),b:Math.round(e[2])};return n.a=e[3]??1,n}if(t.startsWith(`#`))return Va(t);if(t.startsWith(`rgb`))return Ha(t);if(t.startsWith(`hsl`))return Ua(t);if(t.startsWith(`hsv`))return Wa(t)},Va=e=>{let t=e.substring(1),n=RegExp(`.{1,${t.length>=6?2:1}}`,`g`),r=t.match(n);if(!r||r.length<3)throw Error(`The color '${e}' is illegal hex color`);r[0].length===1&&(r=r.map(e=>e+e));let i={r:Number.parseInt(r[0],16),g:Number.parseInt(r[1],16),b:Number.parseInt(r[2],16)};return r.length>3&&(i.a=Number.parseInt(r[3],16)/255),i},Ha=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal rgb color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal rgb color`);let r={r:Number.parseInt(n[0],10),g:Number.parseInt(n[1],10),b:Number.parseInt(n[2],10)};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ua=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsl color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsl color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),l:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Wa=e=>{let t=e.indexOf(`(`);if(t===-1)throw Error(`The color '${e}' is illegal hsv color`);let n=e.substring(t+1,e.length-1).split(`,`);if(n.length<3)throw Error(`The color '${e}' is illegal hsv color`);let r={h:Number.parseInt(n[0],10),s:Number.parseFloat(n[1]),v:Number.parseFloat(n[2])};return n.length>3&&(r.a=Number.parseFloat(n[3])),r},Ga=e=>{let t=Ba(e);if(t!=null)return`r`in t?t:`l`in t?qa(t):Ja(t)},Ka=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),qa=e=>{let{h:t,s:n,l:r}=e;t/=360,n/=100,r/=100;let i=0,a=0,o=0;if(n===0)i=a=o=r;else{let e=r<.5?r*(1+n):r+n-r*n,s=2*r-e;i=Ka(s,e,t+1/3),a=Ka(s,e,t),o=Ka(s,e,t-1/3)}let s={r:Math.round(i*255),g:Math.round(a*255),b:Math.round(o*255)};return e.a!==void 0&&(s.a=e.a),s},Ja=e=>{let{h:t,s:n,v:r}=e;t=t/360*6,n/=100,r/=100;let i=Math.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),c=r*(1-(1-a)*n),l=i%6,u=[r,s,o,o,c,r][l],d=[c,r,r,s,o,o][l],f=[o,o,c,r,r,s][l],p={r:u*255,g:d*255,b:f*255};return e.a!==void 0&&(p.a=e.a),p},Ya=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o=(i+a)/2,s,c;if(i===a)s=c=0;else{let e=i-a;switch(c=o>.5?e/(2-i-a):e/(i+a),i){case t:s=(n-r)/e+(n<r?6:0);break;case n:s=(r-t)/e+2;break;default:s=(t-n)/e+4}s/=6}let l={h:Math.round(s*360),s:Math.round(c*100),l:Math.round(o*100)};return e.a!==void 0&&(l.a=e.a),l},Xa=e=>{let{r:t,g:n,b:r}=e;t/=255,n/=255,r/=255;let i=Math.max(t,n,r),a=Math.min(t,n,r),o,s=i,c=i-a,l=i===0?0:c/i;if(i===a)o=0;else{switch(i){case t:o=(n-r)/c+(n<r?6:0);break;case n:o=(r-t)/c+2;break;default:o=(t-n)/c+4}o/=6}let u={h:Math.round(o*360),s:Math.round(l*100),v:Math.round(s*100)};return e.a!==void 0&&(u.a=e.a),u},Za=e=>e==null,Qa=e=>!Za(e)&&typeof e==`object`;function $a(e){return!!(/^#(?:[0]{3}|[0]{6})\b/.test(e)||/^rgb\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*\)$/.test(e)||/^rgba\s*\(\s*0+\s*,\s*0+\s*,\s*0+\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*0%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}function eo(e){return!!(/^#(?:[Ff]{3}|[Ff]{6})\b/.test(e)||/^rgb\s*\(\s*255\s*,\s*255\s*,\s*255\s*\)$/.test(e)||/^rgba\s*\(\s*255\s*,\s*255\s*,\s*255\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e)||/^hsl\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*\)$/.test(e)||/^hsla\s*\(\s*0*\s*,\s*0%*\s*,\s*100%*\s*,\s*(1|1\.0*|0?\.\d+)\)$/.test(e))}let to=/* @__PURE__ */ function(e){return e[e.COVER=0]=`COVER`,e[e.REPLACE=1]=`REPLACE`,e}({}),no=/* @__PURE__ */ function(e){return e[e.VISIBLE=0]=`VISIBLE`,e[e.HIDDEN=1]=`HIDDEN`,e[e.VERY_HIDDEN=2]=`VERY_HIDDEN`,e}({}),ro=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.SHARED=1]=`SHARED`,e[e.ARRAY=2]=`ARRAY`,e[e.DATA_TABLE=3]=`DATA_TABLE`,e}({});function io(e){return e&&(e.s!==void 0||e.p!==void 0||e.v!==void 0||e.t!==void 0||e.f!==void 0||e.ft!==void 0||e.fd!==void 0||e.si!==void 0||e.custom!==void 0)}function ao(e){if(e.t!==void 0)return e.t;if(typeof e.v==`string`)return 1;if(typeof e.v==`number`)return 2;if(typeof e.v==`boolean`)return 3}function oo(e){if(e==null)return!0;let{v:t,f:n,si:r,p:i}=e;return!(!(t==null||typeof t==`string`&&t.length===0)||n!=null&&n.length>0||r!=null&&r.length>0||i!=null)}function so(e){return e!=null&&(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)}let co=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({}),lo=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.ROW=1]=`ROW`,e[e.COLUMN=2]=`COLUMN`,e[e.ALL=3]=`ALL`,e}({});function uo(e){return[e.startRow,e.startColumn,e.endRow,e.endColumn]}let fo=/* @__PURE__ */ function(e){return e.NONE=`none`,e.BACKWARD=`backward`,e.FORWARD=`forward`,e}({}),po=/* @__PURE__ */ function(e){return e.RECT=`RECT`,e.TEXT=`TEXT`,e}({}),mo=/* @__PURE__ */ function(e){return e.Raw=`raw`,e.Intercepted=`intercepted`,e.Both=`both`,e}({}),ho={Office:{4:`#4472C4`,5:`#ED7D31`,6:`#A5A5A5`,7:`#70AD47`,8:`#5B9BD5`,9:`#70AD47`,0:`#000000`,2:`#44546A`,1:`#FFFFFF`,3:`#E7E6E6`,10:`#0563C1`,11:`#954F72`}},go=`general`,_o=`hash`,vo=`zero`,yo=`qmark`,bo=`slash`,xo=`group`,So=`scale`,Co=`comma`,wo=`break`,To=`text`,Eo=`plus`,Do=`minus`,Oo=`point`,ko=`space`,Ao=`percent`,jo=`digit`,Mo=`calendar`,No=`error`,Po=`datetime`,Fo=`duration`,Io=`condition`,Lo=`dbnum`,Ro=`natnum`,zo=`locale`,Bo=`color`,Vo=`modifier`,Ho=`ampm`,Uo=`escaped`,Wo=`string`,Go=`skip`,Ko=`fill`,qo=`paren`,Jo=`char`,Yo=/* @__PURE__ */ `#000000.#FFFFFF.#FF0000.#00FF00.#0000FF.#FFFF00.#FF00FF.#00FFFF.#800000.#008000.#000080.#808000.#800080.#008080.#C0C0C0.#808080.#9999FF.#993366.#FFFFCC.#CCFFFF.#660066.#FF8080.#0066CC.#CCCCFF.#000080.#FF00FF.#FFFF00.#00FFFF.#800080.#800000.#008080.#0000FF.#00CCFF.#CCFFFF.#CCFFCC.#FFFF99.#99CCFF.#FF99CC.#CC99FF.#FFCC99.#3366FF.#33CCCC.#99CC00.#FFCC00.#FF9900.#FF6600.#666699.#969696.#003366.#339966.#003300.#333300.#993300.#993366.#333399.#333333`.split(`.`),Xo=/* @__PURE__ */ `¤.$.£.¥.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿`.split(`.`),Zo=RegExp(`[${Xo.join(``)}]`);function Qo(e){if(!Number.isFinite(e))throw RangeError(`decimalFromNumber requires a finite number`);let t=e<0||Object.is(e,-0);if(e===0)return{negative:t,digits:`0`,exponent:0};let[n,r]=Math.abs(e).toExponential(14).split(`e`);return{negative:t,digits:n.replace(`.`,``).replace(/0+$/,``)||`0`,exponent:Number(r)}}function $o(e,t){return{...e,exponent:e.digits===`0`?0:e.exponent+Math.trunc(t)}}function es(e){let t=[...e];for(let e=t.length-1;e>=0;e--){if(t[e]!==`9`)return t[e]=String(Number(t[e])+1),t.join(``);t[e]=`0`}return`1${t.join(``)}`}function ts(e,t=0){let n=Math.trunc(t),r=e.exponent+1+n,i;if(r<0?i=`0`:r===0?i=e.digits[0]>=`5`?`1`:`0`:(i=e.digits.slice(0,r).padEnd(r,`0`)||`0`,r<e.digits.length&&e.digits[r]>=`5`&&(i=es(i))),/^0+$/.test(i))return{negative:e.negative,integer:`0`,fraction:``,zero:!0};if(n<=0)return{negative:e.negative,integer:i+`0`.repeat(-n),fraction:``,zero:!1};let a=i.padStart(n+1,`0`);return{negative:e.negative,integer:a.slice(0,-n),fraction:a.slice(-n).replace(/0+$/,``),zero:!1}}function ns(e){let t=Number(e.fraction?`${e.integer}.${e.fraction}`:e.integer);return e.negative&&!e.zero?-t:t}function rs(e){return`${e.negative&&!e.zero?`-`:``}${e.integer}${e.fraction?`.${e.fraction}`:``}`}function is(e,t,n,r){if(e.digits===`0`)return{exponent:0,rounded:ts(e,r)};let i=t>1?Math.floor(e.exponent/t)*t:e.exponent;n||i++;let a=ts($o(e,-i),r);return t===1&&a.integer.length>1&&(i++,a=ts($o(e,-i),r)),{exponent:i,rounded:a}}let as=Object.freeze({1078:`af`,1052:`sq`,1118:`am`,5121:`ar_DZ`,15361:`ar_BH`,3073:`ar_EG`,2049:`ar_IQ`,11265:`ar_JO`,13313:`ar_KW`,12289:`ar_LB`,4097:`ar_LY`,6145:`ar_MA`,8193:`ar_OM`,16385:`ar_QA`,1025:`ar_SA`,10241:`ar_SY`,7169:`ar_TN`,14337:`ar_AE`,9217:`ar_YE`,1067:`hy`,1101:`as`,2092:`az_AZ`,1068:`az_AZ`,1069:`eu`,1059:`be`,2117:`bn`,1093:`bn_IN`,5146:`bs`,1026:`bg`,1109:`my`,1027:`ca`,2052:`zh_CN`,3076:`zh_HK`,5124:`zh_MO`,4100:`zh_SG`,1028:`zh_TW`,1050:`hr`,1029:`cs`,1030:`da`,1125:`dv`,2067:`nl_BE`,1043:`nl_NL`,1126:`bin`,3081:`en_AU`,10249:`en_BZ`,4105:`en_CA`,9225:`en_CB`,2057:`en_GB`,16393:`en_IN`,6153:`en_IE`,8201:`en_JM`,5129:`en_NZ`,13321:`en_PH`,7177:`en_ZA`,11273:`en_TT`,1033:`en_US`,12297:`en_ZW`,1061:`et`,1071:`mk`,1080:`fo`,1065:`fa`,1124:`fil`,1035:`fi`,2060:`fr_BE`,11276:`fr_CM`,3084:`fr_CA`,9228:`fr_CG`,12300:`fr_CI`,1036:`fr_FR`,5132:`fr_LU`,13324:`fr_ML`,6156:`fr_MC`,14348:`fr_MA`,10252:`fr_SN`,4108:`fr_CH`,7180:`fr`,1122:`fy_NL`,2108:`gd_IE`,1084:`gd`,1110:`gl`,1079:`ka`,3079:`de_AT`,1031:`de_DE`,5127:`de_LI`,4103:`de_LU`,2055:`de_CH`,1032:`el`,1140:`gn`,1095:`gu`,1279:`en`,1037:`he`,1081:`hi`,1038:`hu`,1039:`is`,1136:`ig_NG`,1057:`id`,1040:`it_IT`,2064:`it_CH`,1041:`ja`,1099:`kn`,1120:`ks`,1087:`kk`,1107:`km`,1111:`kok`,1042:`ko`,1088:`ky`,1108:`lo`,1142:`la`,1062:`lv`,1063:`lt`,2110:`ms_BN`,1086:`ms_MY`,1100:`ml`,1082:`mt`,1112:`mni`,1153:`mi`,1102:`mr`,1104:`mn`,2128:`mn`,1121:`ne`,1044:`no_NO`,2068:`no_NO`,1096:`or`,1045:`pl`,1046:`pt_BR`,2070:`pt_PT`,1094:`pa`,1047:`rm`,2072:`ro_MO`,1048:`ro_RO`,1049:`ru`,2073:`ru_MO`,1083:`se`,1103:`sa`,3098:`sr_SP`,2074:`sr_SP`,1072:`st`,1074:`tn`,1113:`sd`,1115:`si`,1051:`sk`,1060:`sl`,1143:`so`,1070:`sb`,11274:`es_AR`,16394:`es_BO`,13322:`es_CL`,9226:`es_CO`,5130:`es_CR`,7178:`es_DO`,12298:`es_EC`,17418:`es_SV`,4106:`es_GT`,18442:`es_HN`,2058:`es_MX`,19466:`es_NI`,6154:`es_PA`,15370:`es_PY`,10250:`es_PE`,20490:`es_PR`,1034:`es_ES`,14346:`es_UY`,8202:`es_VE`,1089:`sw`,2077:`sv_FI`,1053:`sv_SE`,1114:`syc`,1064:`tg`,1097:`ta`,1092:`tt`,1098:`te`,1054:`th`,1105:`bo`,1073:`ts`,1055:`tr`,1090:`tk`,1058:`uk`,1056:`ur`,2115:`uz_UZ`,1091:`uz_UZ`,1075:`ve`,1066:`vi`,1106:`cy`,1076:`xh`,1085:`yi`,1077:`zu`}),os=/^([a-z\d]+)(?:[_-]([a-z\d]+))?(?:\.([a-z\d]+))?(?:@([a-z\d]+))?$/i,ss={},H=(e,t=``)=>e.replace(/~/g,t).split(`;`),U=(e,t=0,n=0)=>(e.mmm||=t<1?e.mmmm.concat():e.mmmm.map(e=>{let n=e.slice(0,t%10);return n+(t<10||e===n?``:`.`)}),e.ddd||=n<1?e.dddd.concat():e.dddd.map(e=>{let t=e.slice(0,n%10);return t+(n<10||e===t?``:`.`)}),!e.mmm6&&e.mmmm6&&(e.mmm6=e.mmmm6),e),cs={group:`\xA0`,decimal:`.`,positive:`+`,negative:`-`,percent:`%`,exponent:`E`,nan:`NaN`,infinity:`∞`,ampm:H(`AM;PM`),mmmm6:H(`Muharram;Safar;Rabiʻ I;Rabiʻ II;Jumada I;Jumada II;Rajab;Shaʻban;Ramadan;Shawwal;Dhuʻl-Qiʻdah;Dhuʻl-Hijjah`),mmm6:H(`Muh.;Saf.;Rab. I;Rab. II;Jum. I;Jum. II;Raj.;Sha.;Ram.;Shaw.;Dhuʻl-Q.;Dhuʻl-H.`),mmmm:H(`January;February;March;April;May;June;July;August;September;October;November;December`),mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec`),dddd:H(`Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday`),ddd:H(`Sun;Mon;Tue;Wed;Thu;Fri;Sat`),bool:H(`TRUE;FALSE`),preferMDY:!1};function ls(e){let t=os.exec(e);if(!t)throw SyntaxError(`Malformed locale: ${e}`);return{lang:t[1]+(t[2]?`_${t[2]}`:``),language:t[1],territory:t[2]||``}}function us(e){if(typeof e==`number`)return as[e&65535]||null;let t=Number.parseInt(e,16);return Number.isFinite(t)&&as[t&65535]?as[t&65535]||null:os.test(e)?e:null}function ds(e){let t=us(e),n=null;if(t){let e=ls(t);n=ss[e.lang]||ss[e.language]||null}return n}function fs(e){return Object.assign({},cs,e)}function W(e,t){let n=typeof t==`object`?t:ls(t);return ss[n.lang]=fs(e),n.language!==n.lang&&!ss[n.language]&&(ss[n.language]=fs(e)),ss[n.lang]}let ps=fs({group:`,`,preferMDY:!0});ps.isDefault=!0,W({group:`,`,ampm:H(`上午;下午`),mmmm:H(`一月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)},`zh_CN`);let ms={group:`,`,ampm:H(`上午;下午`),mmmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),mmm:H(`1月;2月;3月;4月;5月;6月;7月;8月;9月;10月;11月;12月`),dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`),ddd:H(`周日;周一;周二;周三;周四;周五;周六`)};W({...ms,nan:`非數值`,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_TW`),W({...ms,dddd:H(`~日;~一;~二;~三;~四;~五;~六`,`星期`)},`zh_HK`),W({...ms,ampm:H(`午前;午後`),dddd:H(`日~;月~;火~;水~;木~;金~;土~`,`曜日`),ddd:H(`日;月;火;水;木;金;土`)},`ja`),W({group:`,`,ampm:H(`오전;오후`),mmmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),mmm:H(`1월;2월;3월;4월;5월;6월;7월;8월;9월;10월;11월;12월`),dddd:H(`일요일;월요일;화요일;수요일;목요일;금요일;토요일`),ddd:H(`일;월;화;수;목;금;토`)},`ko`),W({group:`,`,ampm:H(`ก่อนเที่ยง;หลังเที่ยง`),mmmm:H(`มกร~;กุมภาพันธ์;มีน~;เมษายน;พฤษภ~;มิถุนายน;กรกฎ~;สิงห~;กันยายน;ตุล~;พฤศจิกายน;ธันว~`,`าคม`),mmm:H(`ม.ค.;ก.พ.;มี.ค.;เม.ย.;พ.ค.;มิ.ย.;ก.ค.;ส.ค.;ก.ย.;ต.ค.;พ.ย.;ธ.ค.`),dddd:H(`วันอาทิตย์;วันจันทร์;วันอังคาร;วันพุธ;วันพฤหัสบดี;วันศุกร์;วันเสาร์`),ddd:H(`อา.;จ.;อ.;พ.;พฤ.;ศ.;ส.`)},`th`),W(U({decimal:`,`,ampm:H(`dop.;odp.`),mmmm:H(`ledna;února;března;dubna;května;června;července;srpna;září;října;listopadu;prosince`),mmm:H(`I;II;III;IV;V;VI;VII;VIII;IX;X;XI;XII`),dddd:H(`neděle;pondělí;úterý;středa;čtvrtek;pátek;sobota`),bool:H(`PRAVDA;NEPRAVDA`)},-1,2),`cs`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marts;april;maj;juni;juli;august;september;oktober;november;december`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SAND;FALSK`)},13,13),`da`),W(U({group:`.`,decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januari;februari;maart;april;mei;juni;juli;augustus;september;oktober;november;december`),mmm:H(`jan.;feb.;mrt.;apr.;mei;jun.;jul.;aug.;sep.;okt.;nov.;dec.`),dddd:H(`zondag;maandag;dinsdag;woensdag;donderdag;vrijdag;zaterdag`),bool:H(`WAAR;ONWAAR`)},-1,2),`nl`),W({group:`,`,preferMDY:!0},`en`),W({group:`,`,preferMDY:!0},`en_US`),W({group:`,`},`en_AU`),W({group:`,`},`en_CA`),W({group:`,`},`en_GB`),W({group:`,`,mmm:H(`Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sept;Oct;Nov;Dec`)},`en_IE`),W(U({decimal:`,`,nan:`epäluku`,ampm:H(`ap.;ip.`),mmmm:H(`tammi~;helmi~;maalis~;huhti~;touko~;kesä~;heinä~;elo~;syys~;loka~;marras~;joulu~`,`kuuta`),mmm:H(`tammik.;helmik.;maalisk.;huhtik.;toukok.;kesäk.;heinäk.;elok.;syysk.;lokak.;marrask.;jouluk.`),dddd:H(`sunnun~;maanan~;tiis~;keskiviikkona;tors~;perjan~;lauan~`,`taina`),bool:H(`TOSI;EPÄTOSI`)},-1,2),`fi`);let hs=U({group:` `,decimal:`,`,mmmm:H(`janvier;février;mars;avril;mai;juin;juillet;août;septembre;octobre;novembre;décembre`),mmm:H(`janv.;févr.;mars;avr.;mai;juin;juil.;août;sept.;oct.;nov.;déc.`),dddd:H(`~manche;lun~;mar~;mercre~;jeu~;vendre~;same~`,`di`),bool:H(`VRAI;FAUX`)},-1,13);W({...hs},`fr`),W({...hs,mmm:H(`janv.;févr.;mars;avr.;mai;juin;juill.;août;sept.;oct.;nov.;déc.`)},`fr_CA`),W({group:`'`,decimal:`.`,...hs},`fr_CH`);let gs=U({mmmm:H(`Januar;Februar;März;April;Mai;Juni;Juli;August;September;Oktober;November;Dezember`),mmm:H(`Jan.;Feb.;März;Apr.;Mai;Juni;Juli;Aug.;Sept.;Okt.;Nov.;Dez.`),dddd:H(`Sonn~;Mon~;Diens~;Mittwoch;Donners~;Frei~;Sams~`,`tag`),bool:H(`WAHR;FALSCH`)},-1,12);W({group:`.`,decimal:`,`,...gs},`de`),W({group:`'`,decimal:`.`,...gs},`de_CH`),W(U({group:`.`,decimal:`,`,ampm:H(`π.μ.;μ.μ.`),mmmm:H(`Ιανουαρ~;Φεβρουαρ~;Μαρτ~;Απριλ~;Μαΐου;Ιουν~;Ιουλ~;Αυγούστου;Σεπτεμβρ~;Οκτωβρ~;Νοεμβρ~;Δεκεμβρ~`,`ίου`),mmm:H(`Ιαν;Φεβ;Μαρ;Απρ;Μαΐ;Ιουν;Ιουλ;Αυγ;Σεπ;Οκτ;Νοε;Δεκ`),dddd:H(`Κυριακή;Δευτέρα;Τρίτη;Τετάρτη;Πέμπτη;Παρασκευή;Σάββατο`)},-1,3),`el`),W({decimal:`,`,ampm:H(`de.;du.`),mmmm:H(`január;február;március;április;május;június;július;augusztus;szeptember;október;november;december`),mmm:H(`jan.;febr.;márc.;ápr.;máj.;jún.;júl.;aug.;szept.;okt.;nov.;dec.`),dddd:H(`vasárnap;hétfő;kedd;szerda;csütörtök;péntek;szombat`),ddd:H(`V;H;K;Sze;Cs;P;Szo`),bool:H(`IGAZ;HAMIS`)},`hu`),W(U({group:`.`,decimal:`,`,ampm:H(`f.h.;e.h.`),mmmm:H(`janúar;febrúar;mars;apríl;maí;júní;júlí;ágúst;september;október;nóvember;desember`),dddd:H(`sunnu~;mánu~;þriðju~;miðviku~;fimmtu~;föstu~;laugar~`,`dagur`)},13,13),`is`),W(U({group:`.`,decimal:`,`,mmmm:H(`Januari;Februari;Maret;April;Mei;Juni;Juli;Agustus;September;Oktober;November;Desember`),dddd:H(`Minggu;Senin;Selasa;Rabu;Kamis;Jumat;Sabtu`)},3,3),`id`);let _s=U({mmmm:H(`gennaio;febbraio;marzo;aprile;maggio;giugno;luglio;agosto;settembre;ottobre;novembre;dicembre`),dddd:H(`domenica;lunedì;martedì;mercoledì;giovedì;venerdì;sabato`),bool:H(`VERO;FALSO`)},3,3);W({group:`.`,decimal:`,`,..._s},`it`),W({group:`'`,decimal:`.`,..._s},`it_CH`);let vs={decimal:`,`,ampm:H(`a.m.;p.m.`),mmmm:H(`januar;februar;mars;april;mai;juni;juli;august;september;oktober;november;desember`),mmm:H(`jan.;feb.;mar.;apr.;mai;jun.;jul.;aug.;sep.;okt.;nov.;des.`),dddd:H(`søn~;man~;tirs~;ons~;tors~;fre~;lør~`,`dag`),bool:H(`SANN;USANN`)};W(U({...vs},-1,13),`nb`),W(U({...vs},-1,13),`no`),W(U({decimal:`,`,mmmm:H(`stycznia;lutego;marca;kwietnia;maja;czerwca;lipca;sierpnia;września;października;listopada;grudnia`),dddd:H(`niedziela;poniedziałek;wtorek;środa;czwartek;piątek;sobota`),ddd:H(`niedz.;pon.;wt.;śr.;czw.;pt.;sob.`),bool:H(`PRAWDA;FAŁSZ`)},3,-1),`pl`);let ys={group:`.`,decimal:`,`,mmmm:H(`janeiro;fevereiro;março;abril;maio;junho;julho;agosto;setembro;outubro;novembro;dezembro`),dddd:H(`domingo;segunda-feira;terça-feira;quarta-feira;quinta-feira;sexta-feira;sábado`),bool:H(`VERDADEIRO;FALSO`)};W(U(ys,13,13),`pt`),W(U(ys,13,13),`pt_BR`),W({decimal:`,`,nan:`не\xA0число`,mmmm:H(`января;февраля;марта;апреля;мая;июня;июля;августа;сентября;октября;ноября;декабря`),mmm:H(`янв.;февр.;мар.;апр.;мая;июн.;июл.;авг.;сент.;окт.;нояб.;дек.`),dddd:H(`воскресенье;понедельник;вторник;среда;четверг;пятница;суббота`),ddd:H(`вс;пн;вт;ср;чт;пт;сб`),mmmm6:H(`рамадан;шавваль;зуль-каада;зуль-хиджжа;мухаррам;раби-уль-авваль;раби-уль-ахир;джумад-уль-авваль;джумад-уль-ахир;раджаб;шаабан;рамадан`),mmm6:H(`рам.;шав.;зуль-к.;зуль-х.;мух.;раб. I;раб. II;джум. I;джум. II;радж.;шааб.;рам.`),bool:H(`ИСТИНА;ЛОЖЬ`)},`ru`),W(U({decimal:`,`,mmmm:H(`januára;februára;marca;apríla;mája;júna;júla;augusta;septembra;októbra;novembra;decembra`),dddd:H(`nedeľa;pondelok;utorok;streda;štvrtok;piatok;sobota`)},3,2),`sk`);let bs={group:`.`,decimal:`,`,ampm:H(`a.\xA0m.;p.\xA0m.`),mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;septiem~;octu~;noviem~;diciem~`,`bre`),mmm:H(`ene;feb;mar;abr;may;jun;jul;ago;sept;oct;nov;dic`),dddd:H(`domingo;lunes;martes;miércoles;jueves;viernes;sábado`),ddd:H(`dom;lun;mar;mié;jue;vie;sáb`),bool:H(`VERDADERO;FALSO`)},xs=H(`ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic`),Ss=H(`ene.;feb.;mar.;abr.;may.;jun.;jul.;ago.;sept.;oct.;nov.;dic.`);W({...bs},`es`),W({...bs},`es_AR`),W({...bs},`es_BO`),W({...bs},`es_CL`),W({...bs},`es_CO`),W({...bs},`es_EC`),W({...bs,mmm:xs,ampm:H(`a.m.;p.m.`)},`es_MX`),W({...bs,mmm:Ss},`es_PY`),W({...bs,mmm:Ss},`es_UY`),W({...bs,mmm:Ss,mmmm:H(`enero;febrero;marzo;abril;mayo;junio;julio;agosto;setiembre;octubre;noviembre;diciembre`)},`es_VE`),W({decimal:`,`,ampm:H(`fm;em`),mmmm:H(`januari;februari;mars;april;maj;juni;juli;augusti;september;oktober;november;december`),mmm:H(`jan.;feb.;mars;apr.;maj;juni;juli;aug.;sep.;okt.;nov.;dec.`),dddd:H(`sön~;mån~;tis~;ons~;tors~;fre~;lör~`,`dag`),ddd:H(`sön;mån;tis;ons;tors;fre;lör`)},`sv`),W(U({group:`.`,decimal:`,`,ampm:H(`ÖÖ;ÖS`),mmmm:H(`Ocak;Şubat;Mart;Nisan;Mayıs;Haziran;Temmuz;Ağustos;Eylül;Ekim;Kasım;Aralık`),mmm:H(`Oca;Şub;Mar;Nis;May;Haz;Tem;Ağu;Eyl;Eki;Kas;Ara`),dddd:H(`Pazar;Pazartesi;Salı;Çarşamba;Perşembe;Cuma;Cumartesi`),ddd:H(`Paz;Pzt;Sal;Çar;Per;Cum;Cmt`),bool:H(`DOĞRU;YANLIŞ`)},3,-1),`tr`),W({group:`,`,ampm:H(`yb;yh`),mmmm:H(`Ionawr;Chwefror;Mawrth;Ebrill;Mai;Mehefin;Gorffennaf;Awst;Medi;Hydref;Tachwedd;Rhagfyr`),mmm:H(`Ion;Chwef;Maw;Ebr;Mai;Meh;Gorff;Awst;Medi;Hyd;Tach;Rhag`),dddd:H(`Dydd Sul;Dydd Llun;Dydd Mawrth;Dydd Mercher;Dydd Iau;Dydd Gwener;Dydd Sadwrn`),ddd:H(`Sul;Llun;Maw;Mer;Iau;Gwen;Sad`)},`cy`),W({group:`.`,decimal:`,`,mmmm:H(`yanvar;fevral;mart;aprel;may;iyun;iyul;avqust;sentyabr;oktyabr;noyabr;dekabr`),mmm:H(`yan;fev;mar;apr;may;iyn;iyl;avq;sen;okt;noy;dek`),dddd:H(`bazar;bazar ertəsi;çərşənbə axşamı;çərşənbə;cümə axşamı;cümə;şənbə`),ddd:H(`B.;B.e.;Ç.a.;Ç.;C.a.;C.;Ş.`)},`az`),W(U({decimal:`,`,mmmm:H(`студзеня;лютага;сакавіка;красавіка;мая;чэрвеня;ліпеня;жніўня;верасня;кастрычніка;лістапада;снежня`),dddd:H(`нядзеля;панядзелак;аўторак;серада;чацвер;пятніца;субота`),ddd:H(`нд;пн;аў;ср;чц;пт;сб`)},3,-1),`be`),W({decimal:`,`,ampm:H(`пр.об.;сл.об.`),mmmm:H(`януари;февруари;март;април;май;юни;юли;август;септември;октомври;ноември;декември`),mmm:H(`яну;фев;март;апр;май;юни;юли;авг;сеп;окт;ное;дек`),dddd:H(`неделя;понеделник;вторник;сряда;четвъртък;петък;събота`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),bool:H(`ИСТИНА;ЛОЖЬ`)},`bg`),W({group:`.`,decimal:`,`,mmmm:H(`de gener;de febrer;de març;d’abril;de maig;de juny;de juliol;d’agost;de setembre;d’octubre;de novembre;de desembre`),mmm:H(`de gen.;de febr.;de març;d’abr.;de maig;de juny;de jul.;d’ag.;de set.;d’oct.;de nov.;de des.`),dddd:H(`diumenge;dilluns;dimarts;dimecres;dijous;divendres;dissabte`),ddd:H(`dg.;dl.;dt.;dc.;dj.;dv.;ds.`),ampm:H(`a.\xA0m.;p.\xA0m.`)},`ca`),W(U({group:`,`,decimal:`.`,mmmm:H(`Enero;Pebrero;Marso;Abril;Mayo;Hunyo;Hulyo;Agosto;Setyembre;Oktubre;Nobyembre;Disyembre`),dddd:H(`Linggo;Lunes;Martes;Miyerkules;Huwebes;Biyernes;Sabado`)},3,3),`fil`),W({group:`,`,decimal:`.`,mmmm:H(`જાન્યુઆરી;ફેબ્રુઆરી;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટેમ્બર;ઑક્ટોબર;નવેમ્બર;ડિસેમ્બર`),mmm:H(`જાન્યુ;ફેબ્રુ;માર્ચ;એપ્રિલ;મે;જૂન;જુલાઈ;ઑગસ્ટ;સપ્ટે;ઑક્ટો;નવે;ડિસે`),dddd:H(`રવિ~;સોમ~;મંગળ~;બુધ~;ગુરુ~;શુક્ર~;શનિ~`,`વાર`),ddd:H(`રવિ;સોમ;મંગળ;બુધ;ગુરુ;શુક્ર;શનિ`)},`gu`),W({group:`,`,decimal:`.`,ampm:H(`לפנה״צ;אחה״צ`),dddd:H(`~ראשון;~שני;~שלישי;~רביעי;~חמישי;~שישי;~שבת`,`יום `),ddd:H(`~א׳;~ב׳;~ג׳;~ד׳;~ה׳;~ו׳;שבת`,`יום `),mmmm:H(`ינואר;פברואר;מרץ;אפריל;מאי;יוני;יולי;אוגוסט;ספטמבר;אוקטובר;נובמבר;דצמבר`),mmm:H(`ינו׳;פבר׳;מרץ;אפר׳;מאי;יוני;יולי;אוג׳;ספט׳;אוק׳;נוב׳;דצמ׳`),mmmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע אל־אוול;רביע א־ת׳אני;ג׳ומאדא אל־אולא;ג׳ומאדא א־ת׳אניה;רג׳ב;שעבאן;רמדאן`),mmm6:H(`רמדאן;שוואל;ד׳ו אל־קעדה;ד׳ו אל־חיג׳ה;מוחרם;רביע א׳;רביע ב׳;ג׳ומאדא א׳;ג׳ומאדא ב׳;רג׳ב;שעבאן;רמדאן`)},`he`),W(U({group:`.`,decimal:`,`,mmmm:H(`siječnja;veljače;ožujka;travnja;svibnja;lipnja;srpnja;kolovoza;rujna;listopada;studenoga;prosinca`),mmm:H(`sij;velj;ožu;tra;svi;lip;srp;kol;ruj;lis;stu;pro`),dddd:H(`nedjelja;ponedjeljak;utorak;srijeda;četvrtak;petak;subota`)},-1,3),`hr`),W({decimal:`,`,mmmm:H(`հունվարի;փետրվարի;մարտի;ապրիլի;մայիսի;հունիսի;հուլիսի;օգոստոսի;սեպտեմբերի;հոկտեմբերի;նոյեմբերի;դեկտեմբերի`),mmm:H(`հնվ;փտվ;մրտ;ապր;մյս;հնս;հլս;օգս;սեպ;հոկ;նոյ;դեկ`),dddd:H(`կիրակի;երկուշաբթի;երեքշաբթի;չորեքշաբթի;հինգշաբթի;ուրբաթ;շաբաթ`),ddd:H(`կիր;երկ;երք;չրք;հնգ;ուր;շբթ`)},`hy`),W(U({decimal:`,`,mmmm:H(`იანვარი;თებერვალი;მარტი;აპრილი;მაისი;ივნისი;ივლისი;აგვისტო;სექტემბერი;ოქტომბერი;ნოემბერი;დეკემბერი`),dddd:H(`კვირა;ორშაბათი;სამშაბათი;ოთხშაბათი;ხუთშაბათი;პარასკევი;შაბათი`)},3,3),`ka`),W(U({decimal:`,`,mmmm:H(`қаңтар;ақпан;наурыз;сәуір;мамыр;маусым;шілде;тамыз;қыркүйек;қазан;қараша;желтоқсан`),dddd:H(`жексенбі;дүйсенбі;сейсенбі;сәрсенбі;бейсенбі;жұма;сенбі`),ddd:H(`жс;дс;сс;ср;бс;жм;сб`)},13,-1),`kk`),W({group:`,`,mmmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿಲ್;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂಬರ್;ಅಕ್ಟೋಬರ್;ನವೆಂಬರ್;ಡಿಸೆಂಬರ್`),mmm:H(`ಜನವರಿ;ಫೆಬ್ರವರಿ;ಮಾರ್ಚ್;ಏಪ್ರಿ;ಮೇ;ಜೂನ್;ಜುಲೈ;ಆಗಸ್ಟ್;ಸೆಪ್ಟೆಂ;ಅಕ್ಟೋ;ನವೆಂ;ಡಿಸೆಂ`),dddd:H(`ಭಾನು~;ಸೋಮ~;ಮಂಗಳ~;ಬುಧ~;ಗುರು~;ಶುಕ್ರ~;ಶನಿ~`,`ವಾರ`),ddd:H(`ಭಾನು;ಸೋಮ;ಮಂಗಳ;ಬುಧ;ಗುರು;ಶುಕ್ರ;ಶನಿ`),ampm:H(`ಪೂರ್ವಾಹ್ನ;ಅಪರಾಹ್ನ`)},`kn`),W({decimal:`,`,mmmm:H(`sausio;vasario;kovo;balandžio;gegužės;birželio;liepos;rugpjūčio;rugsėjo;spalio;lapkričio;gruodžio`),mmm:H(`saus.;vas.;kov.;bal.;geg.;birž.;liep.;rugp.;rugs.;spal.;lapkr.;gruod.`),dddd:H(`sekmadienis;pirmadienis;antradienis;trečiadienis;ketvirtadienis;penktadienis;šeštadienis`),ddd:H(`sk;pr;an;tr;kt;pn;št`),ampm:H(`priešpiet;popiet`)},`lt`),W({decimal:`,`,mmmm:H(`janvāris;februāris;marts;aprīlis;maijs;jūnijs;jūlijs;augusts;septembris;oktobris;novembris;decembris`),mmm:H(`janv.;febr.;marts;apr.;maijs;jūn.;jūl.;aug.;sept.;okt.;nov.;dec.`),dddd:H(`svētdiena;pirmdiena;otrdiena;trešdiena;ceturtdiena;piektdiena;sestdiena`),ddd:H(`svētd.;pirmd.;otrd.;trešd.;ceturtd.;piektd.;sestd.`),ampm:H(`priekšpusdienā;pēcpusdienā`)},`lv`),W({group:`,`,decimal:`.`,mmmm:H(`ജനുവരി;ഫെബ്രുവരി;മാർച്ച്;ഏപ്രിൽ;മേയ്;ജൂൺ;ജൂലൈ;ഓഗസ്റ്റ്;സെപ്റ്റംബർ;ഒക്ടോബർ;നവംബർ;ഡിസംബർ`),mmm:H(`ജനു;ഫെബ്രു;മാർ;ഏപ്രി;മേയ്;ജൂൺ;ജൂലൈ;ഓഗ;സെപ്റ്റം;ഒക്ടോ;നവം;ഡിസം`),dddd:H(`ഞായറാഴ്ച;തിങ്കളാഴ്ച;ചൊവ്വാഴ്ച;ബുധനാഴ്ച;വ്യാഴാഴ്ച;വെള്ളിയാഴ്ച;ശനിയാഴ്ച`),ddd:H(`ഞായർ;തിങ്കൾ;ചൊവ്വ;ബുധൻ;വ്യാഴം;വെള്ളി;ശനി`)},`ml`),W({group:`,`,decimal:`.`,mmmm:H(`нэгдүгээ~;хоёрдугаа~;гуравдугаа~;дөрөвдүгээ~;тавдугаа~;зургаадугаа~;долоодугаа~;наймдугаа~;есдүгээ~;аравдугаа~;арван нэгдүгээ~;арван хоёрдугаа~`,`р сар`),mmm:H(`1~;2~;3~;4~;5~;6~;7~;8~;9~;10~;11~;12~`,`-р сар`),dddd:H(`ням;даваа;мягмар;лхагва;пүрэв;баасан;бямба`),ddd:H(`Ня;Да;Мя;Лх;Пү;Ба;Бя`),ampm:H(`ү.ө.;ү.х.`)},`mn`),W({group:`,`,decimal:`.`,mmmm:H(`जानेवारी;फेब्रुवारी;मार्च;एप्रिल;मे;जून;जुलै;ऑगस्ट;सप्टेंबर;ऑक्टोबर;नोव्हेंबर;डिसेंबर`),mmm:H(`जाने;फेब्रु;मार्च;एप्रि;मे;जून;जुलै;ऑग;सप्टें;ऑक्टो;नोव्हें;डिसें`),dddd:H(`रविवार;सोमवार;मंगळवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगळ;बुध;गुरु;शुक्र;शनि`)},`mr`),W(U({group:`,`,decimal:`.`,mmmm:H(`ဇန်နဝါရီ;ဖေဖော်ဝါရီ;မတ်;ဧပြီ;မေ;ဇွန်;ဇူလိုင်;ဩဂုတ်;စက်တင်ဘာ;အောက်တိုဘာ;နိုဝင်ဘာ;ဒီဇင်ဘာ`),mmm:H(`ဇန်;ဖေ;မတ်;ဧ;မေ;ဇွန်;ဇူ;ဩ;စက်;အောက်;နို;ဒီ`),dddd:H(`တနင်္ဂနွေ;တနင်္လာ;အင်္ဂါ;ဗုဒ္ဓဟူး;ကြာသပတေး;သောကြာ;စနေ`),ampm:H(`နံနက်;ညနေ`)},-1,0),`my`),W({group:`,`,decimal:`.`,mmmm:H(`ਜਨਵਰੀ;ਫ਼ਰਵਰੀ;ਮਾਰਚ;ਅਪ੍ਰੈਲ;ਮਈ;ਜੂਨ;ਜੁਲਾਈ;ਅਗਸਤ;ਸਤੰਬਰ;ਅਕਤੂਬਰ;ਨਵੰਬਰ;ਦਸੰਬਰ`),mmm:H(`ਜਨ;ਫ਼ਰ;ਮਾਰਚ;ਅਪ੍ਰੈ;ਮਈ;ਜੂਨ;ਜੁਲਾ;ਅਗ;ਸਤੰ;ਅਕਤੂ;ਨਵੰ;ਦਸੰ`),dddd:H(`ਐਤਵਾਰ;ਸੋਮਵਾਰ;ਮੰਗਲਵਾਰ;ਬੁੱਧਵਾਰ;ਵੀਰਵਾਰ;ਸ਼ੁੱਕਰਵਾਰ;ਸ਼ਨਿੱਚਰਵਾਰ`),ddd:H(`ਐਤ;ਸੋਮ;ਮੰਗਲ;ਬੁੱਧ;ਵੀਰ;ਸ਼ੁੱਕਰ;ਸ਼ਨਿੱਚਰ`),ampm:H(`ਪੂ.ਦੁ.;ਬਾ.ਦੁ.`)},`pa`),W({group:`.`,decimal:`,`,mmmm:H(`ianuarie;februarie;martie;aprilie;mai;iunie;iulie;august;septem~;octom~;noiem~;decem~`,`brie`),mmm:H(`ian.;feb.;mar.;apr.;mai;iun.;iul.;aug.;sept.;oct.;nov.;dec.`),dddd:H(`duminică;luni;marți;miercuri;joi;vineri;sâmbătă`),ddd:H(`dum.;lun.;mar.;mie.;joi;vin.;sâm.`),ampm:H(`a.m.;p.m.`)},`ro`),W(U({group:`.`,decimal:`,`,mmmm:H(`januar;februar;marec;april;maj;junij;julij;avgust;september;oktober;november;december`),mmm:H(`jan.;feb.;mar.;apr.;maj;jun.;jul.;avg.;sep.;okt.;nov.;dec.`),dddd:H(`nedelja;ponedeljek;torek;sreda;četrtek;petek;sobota`),ampm:H(`dop.;pop.`)},-1,13),`sl`),W(U({group:`.`,decimal:`,`,mmmm:H(`јануар;фебруар;март;април;мај;јун;јул;август;септембар;октобар;новембар;децембар`),dddd:H(`недеља;понедељак;уторак;среда;четвртак;петак;субота`)},3,3),`sr`),W({group:`,`,decimal:`.`,mmmm:H(`ஜனவரி;பிப்ரவரி;மார்ச்;ஏப்ரல்;மே;ஜூன்;ஜூலை;ஆகஸ்ட்;செப்டம்பர்;அக்டோபர்;நவம்பர்;டிசம்பர்`),mmm:H(`ஜன.;பிப்.;மார்.;ஏப்.;மே;ஜூன்;ஜூலை;ஆக.;செப்.;அக்.;நவ.;டிச.`),dddd:H(`ஞாயிறு;திங்கள்;செவ்வாய்;புதன்;வியாழன்;வெள்ளி;சனி`),ddd:H(`ஞாயி.;திங்.;செவ்.;புத.;வியா.;வெள்.;சனி`)},`ta`),W({group:`,`,decimal:`.`,mmmm:H(`జనవరి;ఫిబ్రవరి;మార్చి;ఏప్రిల్;మే;జూన్;జులై;ఆగస్టు;సెప్టెంబర్;అక్టోబర్;నవంబర్;డిసెంబర్`),mmm:H(`జన;ఫిబ్ర;మార్చి;ఏప్రి;మే;జూన్;జులై;ఆగ;సెప్టెం;అక్టో;నవం;డిసెం`),dddd:H(`ఆదివారం;సోమవారం;మంగళవారం;బుధవారం;గురువారం;శుక్రవారం;శనివారం`),ddd:H(`ఆది;సోమ;మంగళ;బుధ;గురు;శుక్ర;శని`)},`te`),W({decimal:`,`,mmmm:H(`січня;лютого;березня;квітня;травня;червня;липня;серпня;вересня;жовтня;листопада;грудня`),mmm:H(`січ.;лют.;бер.;квіт.;трав.;черв.;лип.;серп.;вер.;жовт.;лист.;груд.`),dddd:H(`неділю;понеділок;вівторок;середу;четвер;пʼятницю;суботу`),ddd:H(`нд;пн;вт;ср;чт;пт;сб`),ampm:H(`дп;пп`)},`uk`),W({group:`.`,decimal:`,`,mmmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`tháng `),mmm:H(`~1;~2;~3;~4;~5;~6;~7;~8;~9;~10;~11;~12`,`thg `),dddd:H(`Chủ Nhật;Thứ Hai;Thứ Ba;Thứ Tư;Thứ Năm;Thứ Sáu;Thứ Bảy`),ddd:H(`CN;Th 2;Th 3;Th 4;Th 5;Th 6;Th 7`),ampm:H(`SA;CH`)},`vi`),W(U({group:`٬`,decimal:`٫`,ampm:H(`ص;م`),mmmm:H(`يناير;فبراير;مارس;أبريل;مايو;يونيو;يوليو;أغسطس;سبتمبر;أكتوبر;نوفمبر;ديسمبر`),dddd:H(`الأحد;الاثنين;الثلاثاء;الأربعاء;الخميس;الجمعة;السبت`),mmmm6:H(`رمضان;شوال;ذو القعدة;ذو الحجة;محرم;ربيع الأول;ربيع الآخرة;جمادى الأولى;جمادى الآخرة;رجب;شعبان;رمضان`)},0,0),`ar`),W({group:`,`,decimal:`.`,mmmm:H(`জানুয়ারী;ফেব্রুয়ারী;মার্চ;এপ্রিল;মে;জুন;জুলাই;আগস্ট;সেপ্টেম্বর;অক্টোবর;নভেম্বর;ডিসেম্বর`),mmm:H(`জানু;ফেব;মার্চ;এপ্রি;মে;জুন;জুল;আগ;সেপ্টেঃ;অক্টোঃ;নভেঃ;ডিসেঃ`),dddd:H(`রবিবার;সোমবার;মঙ্গলবার;বুধবার;বৃহস্পতিবার;শুক্রবার;শনিবার`),ddd:H(`রবি;সোম;মঙ্গল;বুধ;বৃহস্পতি;শুক্র;শনি`)},`bn`),W({group:`,`,decimal:`.`,mmmm:H(`जनवरी;फ़रवरी;मार्च;अप्रैल;मई;जून;जुलाई;अगस्त;सितंबर;अक्तूबर;नवंबर;दिसंबर`),mmm:H(`जन॰;फ़र॰;मार्च;अप्रैल;मई;जून;जुल॰;अग॰;सित॰;अक्तू॰;नव॰;दिस॰`),dddd:H(`रविवार;सोमवार;मंगलवार;बुधवार;गुरुवार;शुक्रवार;शनिवार`),ddd:H(`रवि;सोम;मंगल;बुध;गुरु;शुक्र;शनि`),ampm:H(`am;pm`)},`hi`);function Cs(e,t){switch(t){case`int`:return e.int_pattern;case`frac`:return e.frac_pattern;case`man`:return e.man_pattern;case`den`:return e.den_pattern;case`num`:return e.num_pattern}}function ws(e,t,n){let r=e.length,i=e.replace(/#/g,``).length;switch(n){case`int`:t.int_max=r,t.int_min=i;break;case`frac`:t.frac_max=r,t.frac_min=i;break;case`man`:t.man_max=r,t.man_min=i;break;case`den`:t.den_max=r,t.den_min=i;break;case`num`:t.num_max=r,t.num_min=i}return t}function G(e,t){typeof e==`string`?t.push({type:`string`,value:e}):t.push(e)}function Ts(e,t){let n=e==null?void 0:e.type;return n===`hash`||n===`zero`||n===`qmark`||n===`digit`&&t===`den`}function Es(e){if(e===null)throw TypeError(`Cannot read properties of null (reading 'num')`)}function Ds(e){let t=[],n={scale:1,scaleExponent:0,percent:!1,text:!1,date:0,date_eval:!1,date_system:1,sec_decimals:0,general:!1,clock:24,int_pattern:[],frac_pattern:[],man_pattern:[],den_pattern:[],num_pattern:[],tokens:t,tokensUsed:0,pattern:``,int_max:0,int_min:0,frac_max:0,frac_min:0,man_max:0,man_min:0,num_max:0,num_min:0,den_max:0,den_min:0,int_p:``,man_p:``,num_p:``,den_p:``,integer:!1},r=`int`,i=null,a=[],o,s=!1,c=-1,l=!1,u=``,d=!1;for(;++c<e.length&&!l;){var f;let h=e[c],g=h.type||`error`;if(u+=h.raw,g===`general`)n.general=!0,G(h,t);else if(Ts(h,r)){let e=Cs(n,r);Ts(o,r)||(o==null?void 0:o.type)===`group`?(e.push((e.pop()||``)+h.value),Es(i),i.num+=h.value):(e.push(h.value),i={type:r,num:h.value},G(i,t))}else if(g===`paren`)h.value===`(`&&(n.parens=!0),G(h.value,t);else if(g===`digit`)G(h.value,t);else if(g===`slash`){d=!0;let e=Cs(n,r);if(e.length){if(!i)throw SyntaxError(`Format pattern is missing a numerator`);n.fractions=!0;let a=e.pop();if(a===void 0)throw SyntaxError(`Format pattern is missing a numerator`);n.num_pattern.push(a),i.type=`num`,r=`den`,G({type:`div`},t)}else G(h.value,t)}else if(g===`comma`)G(`,`,t);else if(g===`scale`)n.scale=.001**h.raw.length,n.scaleExponent=-3*h.raw.length;else if(g===`group`){if(r===`int`&&(n.grouping=!0),r===`den`)throw SyntaxError(`Cannot group denominator digits`)}else if(g===`space`)G(h,t);else if(g===`break`){l=!0;break}else if(g===`text`)n.text=!0,G(h,t);else if(g===`plus`||g===`minus`)G(h,t);else if(g===`duration`){let e=h.value.toLowerCase(),r=e[0],i={type:``,size:0,date:1,pad:e.length};r===`h`?(i.size=16,i.type=`hour-elap`):r===`m`?(i.size=32,i.type=`min-elap`):(i.size=64,i.type=`sec-elap`),n.date|=i.size,a.push(i),G(i,t)}else if(n.date&&g===`point`&&((f=e[c+1])==null?void 0:f.type)===`zero`){var p,m;let r=1;c++;let i=`0`;((p=e[c+1])==null?void 0:p.type)===`zero`&&(i+=`0`,r=2,c++),((m=e[c+1])==null?void 0:m.type)===`zero`&&(i+=`0`,r=3,c++),u+=i;let a=[64,128,256,512][r];n.date|=a,n.date_eval=!0,n.sec_decimals=Math.max(n.sec_decimals,r),G({type:`subsec`,size:a,decimals:r,date:1},t)}else if(g===`calendar`)s||(n.date_system=h.value===`B2`||h.value===`b2`?6:1);else if(g===`datetime`){let e={type:``,size:0,date:1},r=h.value.toLowerCase(),i=r[0];if(r===`y`||r===`yy`)e.size=2,e.type=`year-short`;else if(i===`y`||i===`e`)e.size=2,e.type=`year`;else if(r===`b`||r===`bb`)e.size=2,e.type=`b-year-short`;else if(i===`b`)e.size=2,e.type=`b-year`;else if(r===`d`||r===`dd`)e.size=8,e.type=`day`,e.pad=/dd/.test(r);else if(r===`ddd`||r===`aaa`)e.size=8,e.type=`weekday-short`;else if(i===`d`||i===`a`)e.size=8,e.type=`weekday`;else if(i===`h`)e.size=16,e.type=`hour`,e.pad=/hh/i.test(r);else if(i===`m`){r.length===3?(e.size=4,e.type=`monthname-short`):r.length===5?(e.size=4,e.type=`monthname-single`):r.length>=4&&(e.size=4,e.type=`monthname`);let t=a[a.length-1];!e.type&&t&&!t.used&&t.size&80&&(t.used=!0,e.size=32,e.type=`min`,e.pad=/mm/.test(r)),e.type||(e.size=4,e.type=`month`,e.pad=/mm/.test(r),e.indeterminate=!0)}else if(i===`s`){e.size=64,e.type=`sec`,e.pad=/ss/.test(r);let t=a[a.length-1];t&&t.size&32?e.used=!0:t!=null&&t.indeterminate&&(delete t.indeterminate,t.size=32,t.type=`min`,e.used=!0)}n.date|=e.size,n.date_eval=!0,a.push(e),G(e,t)}else if(g===`ampm`)n.clock=12,n.date|=16,n.date_eval=!0,h.short=h.value===`A/P`,G(h,t);else if(g===`string`||g===`escaped`||g===`char`)G(h.value,t);else if(g===`condition`)n.condition=[h.value[0],Number.parseFloat(h.value[1])];else if(g===`locale`){let e=h.value.split(`-`),r=e.length<2?``:e.slice(1).join(`-`),i=e[0];i&&G(i,t);let a=us(r);a&&(n.locale=a);let o=Number.parseInt(r,16);Number.isFinite(o)&&o&16711680&&(o>>16&255)==6&&(n.date_system=6),s=!0}else if(g===`color`){let e=h.value.toLowerCase(),t=e,r=/^color\s*(\d+)$/i.exec(e);r&&(t=Number.parseInt(r[1],10)),n.color=t}else if(g===`percent`)n.scale=100,n.scaleExponent=2,n.percent=!0,G(`%`,t);else if(g===`point`)G(h,t),n.date||(n.dec_fractions=!0,r=`frac`);else if(g===`exp`)n.exponential=!0,n.exp_plus=h.value.includes(`+`),r=`man`,G({type:`exp`,plus:n.exp_plus},t);else if(g===`skip`||g===`fill`)G(h,t);else if(g!==`dbnum`&&g!==`natnum`)throw SyntaxError(g===`error`?`Illegal character: ${u}`:`Unknown token ${g} in ${u}`);o=h}if(n.tokensUsed=c,n.pattern=u,/^((?:\[[^\]]+\])+)(;|$)/.test(n.pattern)&&!/^\[(?:h+|m+|s+)\]/.test(n.pattern)&&G({type:`text`},t),n.fractions&&n.dec_fractions||n.grouping&&!n.int_pattern.length||n.fractions&&n.exponential||n.fractions&&n.den_pattern.length*n.num_pattern.length===0||d&&!n.fractions&&!n.date||n.exponential&&(n.int_pattern.length||n.frac_pattern.length)*n.man_pattern.length===0)throw SyntaxError(`Invalid pattern: ${u}`);let h=n.int_pattern.join(``),g=n.man_pattern.join(``),_=n.frac_pattern.join(``);ws(h,n,`int`);let v=0;for(let e=0;e<h.length;e++){let t=h[h.length-1-e];/^[0-9?]/.test(t)&&(v=e+1)}n.int_min=v,ws(_,n,`frac`),ws(g,n,`man`);let y=n.num_pattern.join(``),b=n.den_pattern[0]||``;if(b.includes(`?`)||y.includes(`?`)?(b=b.replace(/\d/g,`?`),b=b.replace(/#$/g,`?`),ws(y,n,`num`),ws(b,n,`den`),y=y.replace(/#$/g,`?`)):(ws(y,n,`num`),ws(b,n,`den`)),n.int_p=h,n.man_p=g,n.num_p=y,n.den_p=b,n.den_pattern.length&&(n.denominator=Number.parseInt(n.den_pattern.join(``).replace(/\D/g,``),10)),n.integer=!!h.length,!n.integer&&!n.exponential&&_.length){let e=n.tokens.findIndex(e=>e.type===`point`);n.tokens.splice(e,0,{type:`int`,value:`#`}),n.integer=!0,n.int_pattern=[`#`],n.int_p=`#`}if(n.fractions)for(let e=0;e<t.length-1;e++){let n=t[e];if(n.type!==`string`&&n.type!==`space`)continue;let r=t[e+1].type;r===`num`?n.rule=`num+int`:r===`div`?n.rule=`num`:r===`den`&&(n.rule=`den`)}return n.grouping&&n.int_pattern.length>1&&(n.grouping=!1),n}function Os(e){if(e===0)return e;let t=Math.ceil(Math.log10(e<0?-e:e)),n=10**(16-Math.floor(t));return isFinite(n)?Math.round(e*n)/n:0}function ks(e,t=2,n=2){let r=e<0?-1:1,i=10**(t||2),a=10**(n||2),o=Math.abs(e),s=0,c=0,l=0,u=1,d,f;if(e=o,e%1==0)f=[e*r,1];else if(e<1e-19)f=[r,0x8ac7230489e80000];else if(e>0x8ac7230489e80000)f=[0x8ac7230489e80000*r,1];else{do if(o=1/(o-Math.floor(o)),d=u,u=u*Math.floor(o)+s,s=d,c=l,l=Math.floor(e*u+.5),l>=i||u>=a)return[r*c,s];while(Math.abs(e-l/u)>=1e-13&&o!==Math.floor(o));f=[r*l,u]}return f}let As={total:1,sign:0,period:0,int:1,frac:0};function js(e,t=!0){let n=Qo(e);if(n.digits===`0`)return As;let r=n.exponent+1,i=Math.max(r,1),a=Math.max(0,n.digits.length-r),o=t&&n.negative?1:0,s=+(a>0);return{total:o+i+s+a,digits:Math.max(r,0)+a,sign:o,period:s,int:i,frac:a}}function Ms(e,t=0){let n=Math.floor(Math.log10(e));return t>1?Math.floor(n/t)*t:n}function Ns(e,t=1){return t<-300?Number.parseFloat(e.toExponential().split(`e`)[0]):e*10**-t}function Ps(e,t=0){if(e<0)return-Ps(-e,t);if(t){let n=10**t||1;return Ps(e*n,0)/n}return Math.round(e)}function Fs(e,t=0){if(typeof e!=`number`)return e;if(!Number.isFinite(e)||e===0)return e===0?0:e;if(!Number.isFinite(t))return Ps(e,t);let n=Math.trunc(t);if(Number.isInteger(e)&&n>=0||n>324)return e;let r=ns(ts(Qo(e),n));return Number.isFinite(r)?r:e}function Is(e,t){return e.replace(/\./,t.decimal)}function Ls(e){return e?e.negative?{...e,negative:!1}:e:null}function Rs(e){return(e==null?void 0:e.exponent)??0}function zs(e){return!e||e.exponent<-308}function Bs(e,t){let n=is(e,1,!0,5),r=n.exponent,i=Math.abs(r);return[Is(rs(n.rounded),t),t.exponent,r<0?t.negative:t.positive,i<10?`0`:``,i]}function Vs(e,t,n){let r=Math.abs(t),i=e===1?e:Math.round(e*1e5)/1e5;return[Is(String(i),n),n.exponent,t<0?n.negative:n.positive,r<10?`0`:``,r]}function Hs(e,t,n,r,i=null){let a=typeof n==`number`?n|0:0;if(typeof n==`string`)e.push(n);else if(n===a)e.push(Math.abs(a));else{let t=Math.abs(n),a=Ls(i),o=Rs(a),s=null;zs(a)&&(o=Ms(t),s=Ns(t,o),s===10&&(s=1,o++));let c=js(t);if(o>=-4&&o<=-1){let n=t.toPrecision(10+o).replace(/\.?0+$/,``);e.push(Is(n,r))}else if(o===10){let n=t.toFixed(10).slice(0,12).replace(/\.$/,``);e.push(Is(n,r))}else if(Math.abs(o)<=9){if(c.total<=11){let n=Fs(t,9).toFixed(c.frac);e.push(Is(n,r))}else o===9?e.push(Math.floor(t)):o>=0&&o<9?e.push(Is(String(Fs(t,9-o)),r)):e.push(...s===null?Bs(a,r):Vs(s,o,r))}else c.total>=12?e.push(...s===null?Bs(a,r):Vs(s,o,r)):e.push(Is(Fs(t,9).toFixed(c.frac),r))}return e}function Us(e,t=!1){return e===`0`?`0`:e===`?`?t?`\xA0`:` `:``}let Ws=Math.floor;function Gs(e,t=!0){if(t&&e>=0){if(e===0)return[1900,1,0];if(e===60)return[1900,2,29];if(e<60)return[1900,e<32?1:2,(e-1)%31+1]}let n=e+68569+2415019,r=Ws(4*n/146097);n-=Ws((146097*r+3)/4);let i=Ws(4e3*(n+1)/1461001);n=n-Ws(1461*i/4)+31;let a=Ws(80*n/2447),o=n-Ws(2447*a/80);n=Ws(a/11);let s=a+2-12*n;return[100*(r-49)+i+n|0,s|0,o|0]}function Ks(e){return Gs(e+1462)}function qs(e){if(e===60)throw Error(`#VALUE!`);if(e<=1)return[1317,8,29];if(e<60)return[1317,e<32?9:10,1+(e-2)%30];let t=10631/30,n=8.01/60,r=e+466935,i=Ws(r/10631);r-=10631*i;let a=Ws((r-n)/t);r-=Ws(a*t+n);let o=Ws((r+28.5001)/29.5);return o===13?[30*i+a,12,30]:[30*i+a,o,r-Ws(29.5001*o-29)]}function Js(e,t=0,n=!0){let r=Ws(e);return t===6?qs(r):t===-1?Ks(r):Gs(r,n)}let Ys=Math.floor,Xs=86400,Zs=Date.UTC,Qs=1462,$s=9999;function ec(e=`date1900`){return e===`date1904`?2957003:2958465}function tc(e){return e%4==0&&(e%100!=0||e%400==0)}function nc(e,t,n){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(n)||e<1||e>$s||t<1||t>12)return!1;let r=[31,tc(e)?29:28,31,30,31,30,31,31,30,31,30,31];return n>=1&&n<=r[t-1]}function rc(e,t,n){let r=e-+(t<=2),i=Math.floor(r/400),a=r-i*400,o=t+(t>2?-3:9),s=Math.floor((153*o+2)/5)+n-1,c=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return i*146097+c-719468}function ic(e,t,n){if(e===1900&&t===1&&n===0)return 0;if(e===1900&&t===2&&n===29)return 60;if(!nc(e,t,n))return null;let r=rc(e,t,n);return r+(r<=-25509?25568:25569)}function ac(e,t){if(!Number.isFinite(e)||e<0||e>=ec(t.dateSystem)+1)return null;let n=Math.floor(e),[r,i,a]=Js(t.dateSystem===`date1904`?n+Qs:n,0,!0);if(r>$s)return null;let o=(e-n)*Xs,s=Math.floor(o);return{year:r,month:i,day:a,hours:Math.floor(s/3600),minutes:Math.floor(s/60)%60,seconds:s%60,fractionalSecond:o-s}}function oc(e,t){let n=e.year===1900&&e.month===2&&e.day===29?28:e.day;return new Date(Date.UTC(e.year,e.month-1,n,t?e.hours:0,t?e.minutes:0,t?e.seconds:0,t?Math.round(e.fractionalSecond*1e3):0))}function sc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!1):/* @__PURE__ */ new Date(NaN)}function cc(e,t=`date1900`){let n=ac(e,{dateSystem:t});return n?oc(n,!0):/* @__PURE__ */ new Date(NaN)}function lc(e,t){let{year:n,month:r,day:i,hours:a,minutes:o,seconds:s,fractionalSecond:c}=e;if(!Number.isInteger(a)||a<0||a>23||!Number.isInteger(o)||o<0||o>59||!Number.isInteger(s)||s<0||s>59||!Number.isFinite(c)||c<0||c>=1||t.dateSystem===`date1900`&&n<1900)return null;let l=ic(n,r,i);if(l==null)return null;if(t.dateSystem===`date1904`){if(n===1900&&r===1&&i===0||n===1900&&r===2&&i===29)return null;l-=Qs}return l<0?null:l+(a*3600+o*60+s+c)/Xs}function uc(e,t,n){return Number.isFinite(e.getTime())?lc({year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hours:t?e.getUTCHours():0,minutes:t?e.getUTCMinutes():0,seconds:t?e.getUTCSeconds():0,fractionalSecond:t?e.getUTCMilliseconds()/1e3:0},{dateSystem:n})??((t?e.getTime():Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()))-(n===`date1904`?Date.UTC(1904,0,1):Date.UTC(1899,11,31)))/864e5:NaN}function dc(e,t=`date1900`){return uc(e,!1,t)}function fc(e,t=`date1900`){return uc(e,!0,t)}function pc(e,t){let n=null;if(Array.isArray(e)){let[t,r,i,a,o,s]=e;n=Zs(t,r==null?0:r-1,i??1,a||0,o||0,s||0)}else if(e instanceof Date&&(n=e.getTime(),!(t!=null&&t.ignoreTimezone))){let t=/* @__PURE__ */ new Date;t.setUTCFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t.setUTCHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n=t.getTime()}if(n!=null&&Number.isFinite(n)){let e=n/864e5;return e-(e<=-25509?-25568:-25569)}return null}function mc(e,t){let n=e|0,r=Xs*(e-n),i=Ys(r);r-i>.9999&&(i+=1,i===Xs&&(i=0,n+=1));let a=i<0?Xs+i:i,[o,s,c]=Js(e,0,t==null?void 0:t.leap1900);return[o,s,c,Ys(a/60/60)%60,Ys(a/60)%60,Ys(a)%60]}let hc=86400;function gc(e,t,n,r){if(n)return e<-694324||t>=35830291;let i=ec(r)+1;return e<0||t>=i}function _c(e,t=0){if(e<0)return-_c(-e,t);if(t){let n=10**t||1;return _c(e*n,0)/n}return Math.round(e)}function vc(e,t,n,r,i=null){let a=t,o=e,s=e,c=``,l=``,u=``,d=``,f=``,p=``,m=0,h=null,g=0;if(typeof o==`bigint`){if(o<=2**53-1&&o>=-(2**53-1))s=Number(o),o=s;else return n.bigintErrorNumber?String(o):n.overflow;g=s}else g=Math.trunc(s);let _=0,v=0,y=1,b=0,x=0,S=0,C=0,w=0,T=0,E=r||ps,D=i;if(!D&&typeof e==`number`&&Number.isFinite(e)&&(D=Qo(e)),D&&!a.text&&a.scaleExponent&&(D=$o(D,a.scaleExponent)),!a.text&&Number.isFinite(a.scale)&&a.scale!==1&&(s=Os(s*a.scale),o=s),a.exponential&&D&&D.exponent>=-308){let e=is(D,a.int_max,!!a.integer,a.frac_max);m=e.exponent,h=e.rounded,c+=Math.abs(m)}else if(a.exponential){let e=Math.abs(s);e&&(m=Ms(e,a.int_max)),s&&!a.integer&&m++,e=Ns(e,m),a.int_max===1&&_c(e,a.frac_max)===10&&(e=1,m++),s=s<0?-e:e,o=s,c+=Math.abs(m)}let O=!Number.isSafeInteger(s)||!!a.scaleExponent;if(h||=D&&O&&!a.date&&!a.fractions&&!a.exponential&&(a.integer||a.dec_fractions)?ts(D,a.frac_max):null,a.integer){if(h)p=h.integer===`0`?``:h.integer;else{let e=a.fractions?1:a.frac_max,t=Math.abs(Number.isSafeInteger(s)&&e===0?s:_c(s,e));p+=t<1?``:Math.floor(t)}}let k=n.grouping[0]??3,A=n.grouping[1]??k;a.dec_fractions&&(f=h?h.fraction:String(_c(s,a.frac_max)).split(`.`)[1]||``);let j=!a.error&&(a.num_p.includes(`0`)||a.den_p.includes(`0`)),M=j;if(a.fractions){M=j||!!(s%1);let e=Math.abs(a.integer?s%1:s);if(e){if(M=!0,a.denominator&&Number.isFinite(a.denominator))d+=a.denominator,u+=_c(e*a.denominator),u===`0`&&(u=``,d=``,M=j);else{let t=ks(e,1/0,a.den_max);u+=t[0],d+=t[1],a.integer&&u===`0`&&(u=``,d=``,M=j)}}else!s&&!a.integer&&(M=!0,u=`0`,d=`1`);a.integer&&!M&&!Math.trunc(s)&&(p=`0`)}if(a.date){g=Math.trunc(s);let e=hc*(s-g);if(_=Math.floor(e),T=e-_,Math.abs(T)<1e-6?T=0:T>.9999&&(T=0,_+=1,_===hc&&(_=0,g+=1)),T){let e=a.date&512||a.date&256||a.date&128;(e===512&&T>.9995||e===256&&T>.995||e===128&&T>.95||!e&&T>=.5)&&(_++,T=0)}let t=a.date_system===6?6:n.dateSystem===`date1904`?-1:a.date_system;if(g||a.date_system){let e=Js(s,t,n.leap1900);v=e[0],y=e[1],b=e[2]}if(_){let e=_<0?hc+_:_;w=Math.floor(e)%60,C=Math.floor(e/60)%60,S=Math.floor(e/60/60)%60}if(x=((t===-1?5:6)+g)%7,a.date_eval&&gc(s,g+_/hc,n.dateSpanLarge,n.dateSystem)){if(n.dateErrorThrows)throw Error(`Date out of bounds`);return n.dateErrorNumber?Hs(s<0?[E.negative]:[],{},s,E,D).join(``):n.overflow}}let N=Us(`?`,n.nbsp);m<0?l=`-`:a.exp_plus&&(l=`+`);let P=[],F=(e,t,r,i)=>{let a=i,o=!a&&e.length>t.length?r.length+e.length-t.length:r.length;e.length<t.length&&(a+=e.length-t.length);for(let t=0;t<o;t++)P.push(e[t+a]||Us(r[t],n.nbsp));return o},I=!1,L={int:0,frac:0,man:0,num:0,den:0};for(let e=0,t=a.tokens.length;e<t;e++){let t=a.tokens[e],i=t.type,m=t.num?t.num.length:0;if(i===`string`){let e=t.value;t.rule?t.rule===`num`?M?P.push(e.replace(/ /g,N)):(a.num_min>0||a.den_min>0)&&P.push(e.replace(/./g,N)):t.rule===`num+int`?M&&p?P.push(e.replace(/ /g,N)):a.den_min>0&&(p||a.num_min)&&P.push(e.replace(/./g,N)):t.rule===`den`&&(M?P.push(e.replace(/ /g,N)):a.den_min>0&&P.push(e.replace(/./g,N))):P.push(e.replace(/ /g,N))}else if(i===`space`)t.rule===`num+int`?(M||a.num_min||a.den_min)&&(p||a.num_min)&&P.push(N):P.push(N);else if(i===`error`)P.push(n.invalid);else if(i===`point`)P.push(a.date?t.value:E.decimal);else if(i===`general`)Hs(P,a,o,E,D);else if(i===`exp`)P.push(E.exponent);else if(i===`minus`)t.volatile&&a.date||(t.volatile&&h?h.negative&&!h.zero&&P.push(E.negative):t.volatile&&(s>=0||typeof o!=`number`)||(t.volatile&&!a.fractions&&(a.integer||a.dec_fractions)?(s<0&&p&&p!==`0`||f)&&P.push(E.negative):P.push(E.negative)));else if(i===`plus`)P.push(E.positive);else if(i===`text`)P.push(o);else if(i===`fill`)n.fillChar&&P.push(n.fillChar,t.value);else if(i===`skip`)n.skipChar?P.push(n.skipChar,t.value):P.push(n.nbsp?`\xA0`:` `);else if(i===`div`)M?P.push(`/`):a.num_min>0||a.den_min>0?P.push(N):P.push(Us(`#`,n.nbsp));else if(i===`int`){if(a.int_pattern.length===1){let e=a.int_p,t=Math.max(a.int_min,p.length),r=``;for(let i=t;i>0;i--){let t=p.charAt(p.length-i),o=t?``:e.charAt(e.length-i)||e[0],s=``;if(a.grouping){let e=i-1-k;e>=0&&!(e%A)&&(s=t||o===`0`?E.group:Us(`?`,n.nbsp))}r+=(t||Us(o,n.nbsp))+s}P.push(r)}else L.int+=F(p,a.int_p,t.num,L.int)}else if(i===`frac`){let e=L.frac;for(let r=0;r<m;r++)P.push(f[r+e]||Us(t.num[r],n.nbsp));L.frac+=m}else if(i===`man`)!L[i]&&!L.man&&P.push(l),L.man+=F(c,a.man_p,t.num,L.man);else if(i===`num`)L.num+=F(u,a.num_p,t.num,L.num);else if(i===`den`){let e=L.den;for(let r=0;r<m;r++){let i=d[r+e];if(!i){let e=t.num[r];`123456789`.includes(e)||I&&e===`0`?(I=!0,i=n.nbsp?`\xA0`:` `):i=!I&&r===m-1&&e===`0`&&!d?`1`:Us(e,n.nbsp)}P.push(i)}L.den+=m}else if(i===`year`)v<0&&P.push(E.negative),P.push(String(Math.abs(v)).padStart(4,`0`));else if(i===`year-short`){let e=v%100;P.push(e<10?`0`:``,e)}else if(i===`month`)P.push(t.pad&&y<10?`0`:``,y);else if(i===`monthname-single`)a.date_system===6?P.push(E.mmmm6[y-1].charAt(0)):P.push(E.mmmm[y-1].charAt(0));else if(i===`monthname-short`)a.date_system===6?P.push(E.mmm6[y-1]):P.push(E.mmm[y-1]);else if(i===`monthname`)a.date_system===6?P.push(E.mmmm6[y-1]):P.push(E.mmmm[y-1]);else if(t.type===`weekday-short`)P.push(E.ddd[x]);else if(i===`weekday`)P.push(E.dddd[x]);else if(i===`day`)P.push(t.pad&&b<10?`0`:``,b);else if(i===`hour`){let e=S%a.clock||(a.clock<24?a.clock:0);P.push(t.pad&&e<10?`0`:``,e)}else if(i===`min`)P.push(t.pad&&C<10?`0`:``,C);else if(i===`sec`)P.push(t.pad&&w<10?`0`:``,w);else if(i===`subsec`){P.push(E.decimal);let e=T.toFixed(a.sec_decimals);P.push(e.slice(2,2+t.decimals))}else if(i===`ampm`){let e=S<12?0:1;t.short&&!r?P.push(`AP`[e]):P.push(E.ampm[e])}else if(i===`hour-elap`){s<0&&P.push(E.negative);let e=g*24+Math.floor(Math.abs(_)/3600);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`min-elap`){s<0&&P.push(E.negative);let e=g*1440+Math.floor(Math.abs(_)/60);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`sec-elap`){s<0&&P.push(E.negative);let e=g*hc+Math.abs(_);P.push(String(Math.abs(e)).padStart(t.pad,`0`))}else if(i===`b-year`)P.push(v+543);else if(i===`b-year-short`){let e=(v+543)%100;P.push(e<10?`0`:``,e)}}return P.join(``)}let yc=Ds([{type:To,value:`@`,raw:`@`}]);function bc(e){return!!e&&`scale`in e}function xc(e,t){for(let n=0;n<3;n++){let r=t[n];if(bc(r)){let t;if(r.condition){let n=r.condition[0],i=r.condition[1];n===`=`?t=e===i:n===`>`?t=e>i:n===`<`?t=e<i:n===`>=`?t=e>=i:n===`<=`?t=e<=i:n===`<>`&&(t=e!==i)}else t=!0;if(t)return r}else if(r)return r}}function Sc(e,t,n){let r=t.partitions,i=r[3],a=null;return(typeof e==`number`||typeof e==`bigint`)&&isFinite(e)&&(i=xc(e,r)),bc(i)&&i.color&&(a=i.color),a&&typeof a==`number`&&n.indexColors&&(a=Yo[a-1]||`#000`),a}function Cc(e,t,n){let r=t.partitions,i=ds(t.locale||n.locale),a=e,o=r[3]?r[3]:yc;if(typeof a==`boolean`&&(a=(i||ps).bool[+!a]),a==null)return``;let s=typeof a==`bigint`;if(typeof a!=`number`&&!s)return vc(a,o,n,i);if(!s&&!Number.isFinite(a)){let e=i||ps;return Number.isNaN(a)?e.nan:(a<0?e.negative:``)+e.infinity}let c=xc(e,r),l=c&&typeof e==`number`&&Number.isFinite(e)?Qo(e):null;return c?vc(e,c,n,i,l):n.overflow}function wc(e){return!!e&&`scale`in e}function Tc(e,t){return e.type===`year`||e.type===`year-short`?{type:`year`,pattern:`yyyy`,tokenIndex:t}:e.type===`month`?{type:`month`,pattern:e.pad?`mm`:`m`,tokenIndex:t}:e.type===`day`?{type:`day`,pattern:e.pad?`dd`:`d`,tokenIndex:t}:null}function Ec(e){return e.type.startsWith(`b-year`)||e.type.startsWith(`monthname`)||e.type.startsWith(`weekday`)}function Dc(e,t,n){if(n!==t+2)return null;let r=e[t+1];return r.value===`-`||r.value===`/`?r.value:null}function Oc(e,t){let n=e.find(e=>e.type===(t===`day`?`month`:`day`)),r=(n==null?void 0:n.pattern.length)===2;return t===`day`?r?`dd`:`d`:r?`mm`:`m`}function kc(e,t){let n=e.map(e=>e.type).join(``);if(new Set(e.map(e=>e.type)).size!==e.length)return null;let r=new Map(e.map(e=>[e.type,e.pattern]));r.set(`year`,`yyyy`),r.has(`month`)||r.set(`month`,Oc(e,`month`)),r.has(`day`)||r.set(`day`,Oc(e,`day`));let i={daymonth:[`day`,`month`,`year`],daymonthyear:[`day`,`month`,`year`],dayyear:[`day`,`month`,`year`],monthday:[`year`,`month`,`day`],monthdayyear:[`month`,`day`,`year`],monthyear:[`month`,`day`,`year`],yearmonth:[`year`,`month`,`day`],yearmonthday:[`year`,`month`,`day`],yearday:[`year`,`month`,`day`]}[n];return i?i.map(e=>r.get(e)).join(t):null}function Ac(e){let t=e.tokens.map((e,t)=>Tc(e,t)).filter(e=>e!==null);if(!t.length)return null;if(t.length<2||t.length>3||e.locale||e.date_system!==1||e.tokens.some(Ec))return`yyyy/mm/dd`;let n=t.slice(1).map((n,r)=>Dc(e.tokens,t[r].tokenIndex,n.tokenIndex)),r=n[0];return!r||n.some(e=>e!==r)?`yyyy/mm/dd`:kc(t,r)??`yyyy/mm/dd`}function jc(e){let t=e.tokens.findIndex(e=>e.type===`hour`),n=e.tokens.find(e=>e.type===`min`),r=e.tokens.findIndex(e=>e.type===`ampm`),i=r<0?void 0:e.tokens[r];if(!(t>=0||n||e.tokens.some(e=>e.type===`sec`)||i))return null;let a=t<0?void 0:e.tokens[t],o=`${a!=null&&a.pad?`hh`:`h`}:${(n==null?void 0:n.pad)===!1?`m`:`mm`}:ss`;return!i||typeof i.value!=`string`?o:r<t?`${i.value} ${o}`:`${o} ${i.value}`}function Mc(e,t){let n=xc(t,e);if(!wc(n)||n.tokens.some(e=>e.type.endsWith(`-elap`)))return null;let r=Ac(n),i=jc(n);return r&&i?`${r} ${i}`:r??i}function Nc(e){return!!e&&`scale`in e}function Pc(e){return!!e&&`generated`in e&&!!e.generated}function Fc(e){return!!(Nc(e[0])&&e[0].percent||Nc(e[1])&&e[1].percent||Nc(e[2])&&e[2].percent||Nc(e[3])&&e[3].percent)}function Ic(e){return!!(Nc(e[0])&&e[0].date||Nc(e[1])&&e[1].date||Nc(e[2])&&e[2].date||Nc(e[3])&&e[3].date)}function Lc(e){let[t,n,r,i]=e;return!(t&&!Pc(t)||n&&!Pc(n)||r&&!Pc(r)||!Nc(i)||!i.text||Pc(i))}let Rc={text:15,datetime:10.8,date:10.8,time:10.8,percent:10.6,currency:10.4,grouped:10.2,scientific:6,number:4,fraction:2,general:0,error:0},zc=[[`DMY`,1],[`DM`,2],[`MY`,3],[`MDY`,4],[`MD`,5],[`hmsa`,6],[`hma`,7],[`hms`,8],[`hm`,9]];function Bc(e,t=null){let[n,r]=e;if(!n)throw TypeError(`Cannot read properties of undefined (reading 'frac_max')`);let i=Nc(n)?n:void 0,a=Nc(r)?r:void 0,o=`error`in n,s=i==null?void 0:i.frac_max,c={type:`general`,isDate:Ic(e),isText:Lc(e),isPercent:Fc(e),maxDecimals:i!=null&&i.general?9:s??0,scale:(i==null?void 0:i.scale)??1,color:0,parentheses:0,grouped:i!=null&&i.grouping?1:0,code:``,level:0},l=!c.isDate&&!c.isText&&!o&&n.tokens.some(e=>e.type===`string`&&typeof e.value==`string`&&(t?e.value===t:Zo.test(e.value))),u=`G`,d=s!==void 0&&s>=0?Math.min(15,s):``,f=``,p=``;if(a!=null&&a.color&&(p=`-`,c.color=1),i!=null&&i.parens&&(f=`()`,c.parentheses=1),l)u=`C`,c.type=`currency`;else if(o)c.type=`error`,c.maxDecimals=0;else if(c.isDate){let e=0,t=0,r=``;n.tokens.forEach(n=>{let i=n.type;/^(b-)?year/.test(i)?(r+=`Y`,t++):i.startsWith(`month`)?(r+=`M`,t++):/^(week)?day/.test(i)?(r+=`D`,t++):(i===`hour`||i===`min`||i===`sec`||i===`ampm`)&&(r+=i[0],e++)}),c.type=`date`,t&&e?c.type=`datetime`:!t&&e&&(c.type=`time`);let i=zc.find(([e])=>r.startsWith(e));u=i?`D`:`G`,d=i?i[1]:``}else c.isText?(u=`G`,c.type=`text`,d=``,c.maxDecimals=0):i!=null&&i.general?(u=`G`,c.type=`general`,d=``):i!=null&&i.fractions?(u=`G`,c.type=`fraction`,d=``):i!=null&&i.exponential?(u=`S`,c.type=`scientific`):c.isPercent?(u=`P`,c.type=`percent`):i!=null&&i.grouping?(u=`,`,c.type=`grouped`):i&&(i.int_max||s)&&(u=`F`,c.type=`number`);return c.code=u+d+p+f,c.level=Rc[c.type],Object.freeze(c)}function Vc(e){let[t]=e;if(!t)throw TypeError(`Cannot read properties of undefined (reading 'date')`);let n=Nc(t)?t:void 0,r=(n==null?void 0:n.date)??0;return{year:!!(r&2),month:!!(r&4),day:!!(r&8),hours:!!(r&16),minutes:!!(r&32),seconds:!!(r&64),isDuration:(n==null?void 0:n.tokens.some(e=>e.type.endsWith(`-elap`)))??!1,clockType:(n==null?void 0:n.clock)===12?12:24}}let Hc={overflow:`######`,dateErrorThrows:!1,dateErrorNumber:!1,bigintErrorNumber:!1,dateSpanLarge:!1,leap1900:!0,dateSystem:`date1900`,nbsp:!1,throws:!0,invalid:`######`,locale:``,ignoreTimezone:!1,grouping:[3,3],indexColors:!0,skipChar:``,fillChar:``},Uc=[[go,/^General/i,0],[_o,/^#/,0],[vo,/^0/,0],[yo,/^\?/,0],[bo,/^\//,0],[wo,/^;/,0],[To,/^@/,0],[Eo,/^\+/,0],[Do,/^-/,0],[Oo,/^\./,0],[ko,/^ /,0],[Ao,/^%/,0],[jo,/^[1-9]/,0],[Mo,/^(?:B[12])/i,0],[No,/^B$/,0],[Po,/^(?:[hH]+|[mM]+|[sS]+|[yY]+|[bB]+|[dD]+|[gG]+|[aA]{3,}|e+)/,0],[Fo,/^(?:\[(h+|m+|s+)\])/i,1],[Io,/^\[(<[=>]?|>=?|=)\s*(-?[.\d]+)\]/,[1,2]],[Lo,/^\[(DBNum[0-4]?\d)\]/i,1],[Ro,/^\[(NatNum[0-4]?\d)\]/i,1],[zo,/^\[\$([^\]]+)\]/,1],[Bo,/^\[(black|blue|cyan|green|magenta|red|white|yellow|color\s*\d+)\]/i,1],[Vo,/^\[([^\]]+)\]/,1],[Ho,/^(?:AM\/PM|am\/pm|A\/P)/,0],[Uo,/^\\([\s\S])/,1],[Wo,/^"([^"]*?)"/,1],[Go,/^_(\\.|.)/,1],[`exp`,/^[Ee]([+-])/,1],[Ko,/^\*(\\.|.)/,1],[qo,/^[()]/,0],[No,/^[EÈÉÊËèéêëĒēĔĕĖėĘęĚěȄȅȆȇȨȩNnÑñŃńŅņŇňǸǹ["*/\\_]/,0],[Jo,/^./,0]],Wc=e=>{let t=(e||`\0`).charCodeAt(0);return t===63||t===35||t>=48&&t<=57};function Gc(e){let t=0,n=[],r=[];for(;t<e.length;){let i=e.slice(t),a=0,o=/^(,+)(.)?/.exec(i);if(o){let i=o[1];a=i.length;let s=e[t-1]||``,c=!1,l=!1;Wc(s)?(c=!0,l=!0):s===`.`&&(l=!0);let u=o[2]||``;if(c&&(!u||u===`;`)&&(c=!1),l&&Wc(u)&&(l=!1),c&&!l)n.push({type:xo,value:`,`,raw:i});else if(!c&&l)n.push({type:So,value:`,`,raw:i});else if(c&&l){let e={type:So,value:`,`,raw:i};n.push(e),r.push(e)}else n.push({type:Co,value:`,`,raw:i})}else{let e;for(let[t,r,o]of Uc){let s=r.exec(i);if(s){e={type:t,value:typeof o==`number`?s[o||0]:o.map(e=>s[e]),raw:s[0]},n.push(e),a=s[0].length;break}}r.length&&(e==null?void 0:e.raw)===`;`&&(r.length=0),r.length&&Wc(e==null?void 0:e.raw)&&(r.forEach(e=>e.type=xo),r.length=0)}if(!a){let e=i[0];a=1,n.push({type:Jo,value:e,raw:e})}t+=a}return n}function Kc(e){var t,n;let r=(t=e.condition)==null?void 0:t[0],i=(n=e.condition)==null?void 0:n[1];typeof i==`number`&&i<0&&(r===`<`||r===`<=`||r===`=`)||i===0&&r===`<`||e.tokens.unshift({type:`minus`,volatile:!0})}function qc(e,t=null){let n={...e,int_pattern:[...e.int_pattern],frac_pattern:[...e.frac_pattern],man_pattern:[...e.man_pattern],den_pattern:[...e.den_pattern],num_pattern:[...e.num_pattern],tokens:[...e.tokens]};return e.condition&&(n.condition=[...e.condition]),t&&n.tokens.unshift(t),n.generated=!0,n}function Jc(e){let t=[],n=!1,r,i=null,a=0,o=0,s=0,c=Gc(e);do{var l;let e=Ds(c);if((e.date||e.general)&&(e.int_pattern.length||e.frac_pattern.length||e.scale!==1||e.text))throw Error(`Illegal format`);if(e.condition&&(s++,n=!0),e.text){if(i)throw Error(`Unexpected partition`);i=e}e.locale&&(r=us(e.locale)),t.push(e),a=+(((l=c[e.tokensUsed])==null?void 0:l.type)===`break`),c=c.slice(e.tokensUsed+a),o++}while(a&&o<4&&s<3);if(a)throw Error(`Unexpected partition`);if(s>2)throw Error(`Unexpected condition`);let u=t[3];if(u&&(u.int_pattern.length||u.frac_pattern.length||u.date))throw Error(`Unexpected partition`);if(n){t[0].condition||(t[0].condition=[`>`,0]);let e=t.length;if(e===1){let e=Ds(Gc(`General`));e.generated=!0,t[1]=e}if(e<3){let e=t[0],n=t[1];if(Kc(e),n.condition)Kc(n);else{let t=e.condition;((t==null?void 0:t[0])===`=`||typeof(t==null?void 0:t[1])==`number`&&t[1]>=0&&(t[0]===`>`||t[0]===`>=`))&&n.tokens.unshift({type:`minus`,volatile:!0})}}else t.forEach(Kc)}else{if(t.length<4&&i)for(let e=0,n=t.length;e<n;e++)t[e]===i&&t.splice(e,1);if(t.length<1&&i){let e=Ds(Gc(`General`));e.generated=!0,t[0]=e}if(t.length<2&&t.push(qc(t[0],{type:`minus`,volatile:!0})),t.length<3&&t.push(qc(t[0])),t.length<4){if(i)t.push(i);else{let e=Ds(Gc(`@`));e.generated=!0,t.push(e)}}t[0].condition=[`>`,0],t[1].condition=[`<`,0],t[2].condition=null}return{pattern:e,partitions:t,locale:r}}let Yc=/* @__PURE__ */ `!d-m-y.!d-m-Y.!j-m-y.!j-m-Y.!d-n-y.!d-n-Y.!j-n-y.!j-n-Y.?m-d-y.?m-d-Y.?m-j-y.?m-j-Y.?n-d-y.?n-d-Y.?n-j-y.?n-j-Y.d-M-y.d-M-Y.j-M-y.j-M-Y.M-d-y.M-d-Y.M-j-y.M-j-Y.d-F-y.d-F-Y.F-d-y.F-d-Y.F-j-y.F-j-Y.j-F-y.j-F-Y.y-F-d.y-F-j.y-M-d.y-M-j.Y-F-d.Y-F-j.Y-M-d.Y-m-d.Y-M-j.Y-m-j.Y-n-d.Y-n-j.j-F.j-M.d-F.d-M.n-d.n-j.n-Y.m-d.m-j.m-Y.M-Y.M-y.F-y.F-Y.Y-M.Y-n.Y-m.Y-F.Y-M`.split(`.`),Xc={j:`d`,d:`d`,D:`ddd`,l:`dddd`,n:`m`,m:`m`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Zc={j:`dd`,d:`dd`,D:`ddd`,l:`dddd`,n:`mm`,m:`mm`,M:`mmm`,F:`mmmm`,y:`yy`,Y:`yyyy`},Qc={},$c={};function el(e,t,n=1){if(e){let r=e[0],i=e.slice(1);if(r===`!`)el(i,t,4);else if(r===`?`)el(i,t,2);else{let e=t[r];typeof e!=`object`&&(e={},t[r]=e),el(i,e,n)}}else t.$=n}function tl(e,t){el(e,t),el(`${e} x`,t),el(`${e} l`,t),el(`${e} l x`,t),el(`l ${e}`,t),el(`l ${e} x`,t),el(`${e} D`,t),el(`${e} D x`,t),el(`D ${e}`,t),el(`D ${e} x`,t)}Yc.forEach(e=>{e.startsWith(`?`)||tl(e,Qc),e.startsWith(`!`)||tl(e,$c)});let nl={".":[`,`,`\xA0`,` `,`'`,`٬`],",":[`.`,`\xA0`,` `,`'`,`٬`],"٫":[`.`,`\xA0`,` `,`'`,`٬`]},rl=e=>(e==null?void 0:e.length)===1&&e>=`0`&&e<=`9`;function il(e,t={}){let n=ds(t.locale||``)||ps,r=n.decimal,i=[...nl[r]||[`'`,`٬`]];!i.includes(n.group)&&n.group!==` `&&n.group!==r&&i.push(n.group);let a=``,o=``,s=1,c=``,l=!1,u=!1,d=!1,f=!1,p=!1,m=!1,h=``,g=!1,_=0,v=[` `,`\xA0`,` `,`+`,`%`,`(`,`-`].concat(Xo);for(;v.includes(e.charAt(_));){let t=e.charAt(_);if(t===`-`){if(l||d)return null;l=!0,s=-1}else if(Zo.test(t)){if(m)return null;m=!0,h=t}else if(t===`+`){if(d)return null;u=!0}else if(t===`(`){if(d||l||u)return null;d=!0,s=-1}else if(t===`%`){if(p)return null;p=!0}_++}let y=!1,b;if(e.charAt(_)===r||rl(e.charAt(_)))for(;_<e.length;){let t=e.charAt(_);if(!b&&i.includes(t))b=t;else if(!(b&&b===t)){if(t===r){if(y)break;a+=`.`,y=!0}else if(rl(t))a+=t;else break}_++}if(e.charAt(_)===`e`||e.charAt(_)===`E`){o+=e.charAt(_),_++,(e.charAt(_)===`+`||e.charAt(_)===`-`)&&(o+=e.charAt(_),_++);let t=_;for(;rl(e.charAt(_));)o+=e.charAt(_),_++;if(t===_)return null}let x=[` `,`\xA0`,` `,`%`,`$`,`)`].concat(Xo);for(;x.includes(e.charAt(_));){let t=e.charAt(_);if(Zo.test(t)){if(m)return null;m=!0,h=t,g=!0}else if(t===`)`){if(f||!d)return null;f=!0}else if(t===`%`){if(p)return null;p=!0}_++}if(_!==e.length||d&&!f)return null;let S=Number.parseFloat(a+o);if(!Number.isFinite(S))return null;if(o){if(p||m)return null;c=`0.00E+00`}else if(p){if(m)return null;c=a.includes(`.`)?`0.00%`:`0%`,S*=.01}else if(m){let e=a.includes(`.`)?`#,##0.00`:`#,##0`;c=g?e+h:h+e}else b&&(c=a.includes(`.`)?`#,##0.00`:`#,##0`);let C={v:S*s};return c&&(C.z=c),C}function al(e,t,n){if(n<1||t<1||t>12)return!1;if(t===2){if(n>(e%4==0&&e%100!=0||e%400==0||e===1900?29:28))return!1}else if((t===4||t===6||t===9||t===11)&&n>30||(t===1||t===3||t===5||t===7||t===8||t===10||t===12)&&n>31)return!1;return!0}let ol=/* @__PURE__ */ new WeakMap,sl=(e,t,n=!1)=>{for(let r of t)if(e.startsWith(r[0])){let t=r[0].length;return n&&(r[2]===`D`||r[2]===`M`)&&e[t]===`.`&&t++,[e.slice(0,t),r]}return[``,null]},cl=(e,t,n,r)=>{let i=n.path||``,a=Object.keys(t);for(let o of a){let a=t[o],s;if(!a)continue;if(o===`$`||o===`€`)e||(s=n);else{if(typeof a!=`object`)continue;if(o===`-`){let t=/^(\s*([./-]|,\s)\s*|\s+)/.exec(e);if(t){let o=t[1]===`-`||t[1]===`/`||t[1]===`.`?t[1]:` `;if(!n.sep||n.sep===o){let c=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,sep:o,path:i+c},r)}}}else if(o===` `){let t=/^[,.]?\s+/.exec(e);if(t){let o=t[0].replace(/\s+/g,` `);s=cl(e.slice(t[0].length),a,{...n,path:i+o},r)}}else if(o===`j`||o===`d`){let t=/^(0{1,2}|0?[1-9]|1\d|2\d|3[01])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,day:t[0],path:i+o},r))}else if(o===`n`||o===`m`){let t=/^(0?[1-9]|1[012])\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,month:+t[0],_mon:t[0],path:i+o},r))}else if(o===`F`||o===`M`){let[t,c]=sl(e,r.mon,r.mp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,month:c[1],_mon:t,path:i+o},r))}else if(o===`l`||o===`D`){let[t,c]=sl(e,r.day,r.dp);(c==null?void 0:c[2])===o&&(s=cl(e.slice(t.length),a,{...n,path:i+o},r))}else if(o===`y`){let t=/^\d\d\b/.exec(e);if(t){let c=+t[0]>=30?+t[0]+1900:+t[0]+2e3;s=cl(e.slice(t[0].length),a,{...n,year:c,path:i+o},r)}}else if(o===`Y`){let t=/^\d\d\d\d\b/.exec(e);t&&(s=cl(e.slice(t[0].length),a,{...n,year:+t[0],path:i+o},r))}else if(o===`x`){let t=hl(e,{locale:r.locale});t&&(s=cl(``,a,{...n,time:t.v,tf:t.z,path:i+o},r))}else throw Error(`Unknown date token "${o}"`)}let c=(s==null?void 0:s.year)||1916,l=(s==null?void 0:s.month)||1,u=s!=null&&s.day?+s.day:1,d=r.dateSystem===`date1900`&&c===1900&&l===1&&u===0;if(s&&(d||al(c,l,u)))return s}},ll=e=>e.replace(/\s+/g,` `).trim().replace(/’/,`'`).replace(/\.$/,``).toLowerCase(),ul=(e,t)=>{let n=e.map((e,n)=>[ll(e),n+1,t]);return n.sort((e,t)=>t[0].length-e[0].length),n},dl=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),fl=e=>{let t=ol.get(e);return t&&dl(e.mmmm,t.mmmm)&&dl(e.mmm,t.mmm)&&dl(e.dddd,t.dddd)&&dl(e.ddd,t.ddd)||(t={lookups:{mon:ul(e.mmmm,`F`).concat(ul(e.mmm,`M`)),mp:e.mmm[0].endsWith(`.`),day:ul(e.dddd,`l`).concat(ul(e.ddd,`D`)),dp:e.ddd[0].endsWith(`.`)},mmmm:[...e.mmmm],mmm:[...e.mmm],dddd:[...e.dddd],ddd:[...e.ddd]},ol.set(e,t)),t.lookups};function pl(e,t={}){let n=ds(t.locale||``)||ps,r={...fl(n),locale:t.locale,dateSystem:t.dateSystem??`date1900`},i=cl(ll(e),n.preferMDY?$c:Qc,{path:``},r);if(!i||i.sep===`.`&&i.path.length===3||i.month==null||i._mon==null)return null;let a=+(i.year??(/* @__PURE__ */ new Date()).getUTCFullYear()),o=i.day??`1`,s=t.dateSystem??`date1900`,c=lc({year:a,month:i.month,day:+o,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s});if(c==null)return null;let l=c+(i.time||0);if(l>=lc({year:9999,month:12,day:31,hours:0,minutes:0,seconds:0,fractionalSecond:0},{dateSystem:s})+1)return null;let u=i._mon[0]===`0`||o[0]===`0`||i._mon.length===2&&o.length===2;return{v:l,z:i.path.replace(/[jdlDnmMFyYx]/g,e=>e===`x`?i.tf||``:(u?Zc[e]:Xc[e])||e)}}let ml=e=>e.replace(/\s+/g,``).trim().replace(/\./g,``).toLowerCase();function hl(e,t={}){let n=ds(t.locale||``)||ps,r=/^\s*([10]?\d|2[0-4])(?::([0-5]\d|\d))?(?::([0-5]\d|\d))?(\.\d{1,10})?(?=\s*[^\s\d]|$)/.exec(e),i=``;if(r){let t=ml(e.slice(r[0].length));if(t===ml(n.ampm[0])||t===`a`||t===`am`)i=`a`;else if(t===ml(n.ampm[1])||t===`p`||t===`pm`)i=`p`;else if(t===`:`)r[3]||=`0`,r[2]||=`0`;else if(t)return null}if(!r)return null;let[,a,o,s,c]=r;if(c&&!s||!i&&!o&&!s)return null;let l=+(a||0);if(i){if(l>=13)return null;i===`a`?l===12&&(l=0):i===`p`&&l!==12&&(l+=12)}let u=+(o||0),d=+(s||0),f=+(c||0),p=a.length===2?`hh`:`h`,m=s?`:ss`:``,h=i?` AM/PM`:``;return{v:(l*60*60+u*60+d+f)/86400,z:`${p}:mm${m}${h}`}}function gl(e,t={}){let n=ds(t.locale||``)||ps,r=e.trim().toLowerCase(),i=n.bool[0].toLowerCase();if(r===`true`||r===i)return{v:!0};let a=n.bool[1].toLowerCase();return r===`false`||r===a?{v:!1}:null}function _l(e,t){return il(e,t)??pl(e,t)??hl(e,t)??gl(e,t)}var vl=/* @__PURE__ */ p({addLocale:()=>W,dateFromSerial:()=>mc,dateToSerial:()=>pc,dec2frac:()=>ks,format:()=>xl,formatColor:()=>Sl,getDateTimeEditPattern:()=>kl,getFormatDateInfo:()=>Ol,getFormatInfo:()=>Dl,getLocale:()=>ds,isDateFormat:()=>Cl,isPercentFormat:()=>wl,isTextFormat:()=>Tl,isValidFormat:()=>El,parseBool:()=>gl,parseDate:()=>pl,parseLocale:()=>ls,parseNumber:()=>il,parseTime:()=>hl,parseValue:()=>_l,round:()=>Fs,tokenTypes:()=>Al,tokenize:()=>Gc});let yl=Object.create({});function bl(e,t=!1){let n=e||`General`,r=yl[n];if(!r)try{r=Jc(n),yl[n]=r}catch(e){if(t)throw e;let i=e instanceof Error?e.message:String(e),a={tokens:[{type:`error`}],error:i};r={pattern:n,partitions:[a,a,a,a],error:i,locale:null}}return r}function xl(e,t,n={}){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Cc(pc(t,r)??t,i,r)}function Sl(e,t,n){let r=Object.assign({},Hc,n),i=bl(e,r.throws);return Sc(pc(t,r)??t,i,r)}function Cl(e){return Ic(bl(e,!1).partitions)}function wl(e){return Fc(bl(e,!1).partitions)}function Tl(e){return Lc(bl(e,!1).partitions)}function El(e){try{return bl(e,!0),!0}catch{return!1}}function Dl(e,t={}){let n=bl(e,!1);return n.info||=Bc(n.partitions,t==null?void 0:t.currency),n.info}function Ol(e){let t=bl(e,!1);return t.dateInfo||=Vc(t.partitions),t.dateInfo}function kl(e,t){return Mc(bl(e,!1).partitions,t)}let Al=Object.freeze({AMPM:Ho,BREAK:wo,CALENDAR:Mo,CHAR:Jo,COLOR:Bo,COMMA:Co,CONDITION:Io,DATETIME:Po,DBNUM:Lo,DIGIT:jo,DURATION:Fo,ERROR:No,ESCAPED:Uo,EXP:`exp`,FILL:Ko,GENERAL:go,GROUP:xo,HASH:_o,LOCALE:zo,MINUS:Do,MODIFIER:Vo,NATNUM:Ro,PAREN:qo,PERCENT:Ao,PLUS:Eo,POINT:Oo,QMARK:yo,SCALE:So,SKIP:Go,SLASH:bo,SPACE:ko,STRING:Wo,TEXT:To,ZERO:vo}),jl=/* @__PURE__ */ new Set([`d`,`g`,`i`,`m`,`s`,`u`,`v`,`y`]);function Ml(e,t){let n=Nl(t);return new RegExp(e,n)}function Nl(e){if(e===void 0)return;let t=/* @__PURE__ */ new Set;for(let n of e){if(!jl.has(n)||t.has(n))throw SyntaxError(`Invalid regular expression flags: ${e}`);t.add(n)}return e}var Pl=class e{constructor(...e){T(this,`data`,void 0),this.data=Rl(e.flatMap(e=>Il(e)))}union(...t){return new e(this,...t)}subtract(...t){let n=Rl(t.flatMap(e=>Il(e))),r=this.data.slice();for(let[e,t]of n){let n=[];for(let[i,a]of r)t<i||e>a?n.push([i,a]):(e>i&&n.push([i,e-1]),t<a&&n.push([t+1,a]));r=n}return new e(...r)}intersect(...t){let n=Rl(t.flatMap(e=>Il(e))),r=[];for(let[e,t]of this.data)for(let[i,a]of n){let n=Math.max(e,i),o=Math.min(t,a);n<=o&&r.push([n,o])}return new e(...r)}isEmpty(){return this.data.length===0}toString(){return this.isEmpty()?`(?!)`:`[${this.data.map(zl).join(``)}]`}toRegExp(e){return Ml(this.toString(),e)}};let Fl=(...e)=>new Pl(...e);function Il(e){if(e instanceof Pl)return e.data;if(Array.isArray(e)){let t=Ll(e[0]),n=Ll(e[1]);return[[Math.min(t,n),Math.max(t,n)]]}let t=Ll(e);return[[t,t]]}function Ll(e){if(typeof e==`number`){if(!Number.isInteger(e)||e<0||e>1114111)throw RangeError(`Invalid code point: ${e}`);return e}let t=e.codePointAt(0);if(t==null||String.fromCodePoint(t)!==e)throw RangeError(`Charset string inputs must contain exactly one code point: ${e}`);return t}function Rl(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]),n=[];for(let[e,r]of t){let t=n[n.length-1];!t||e>t[1]+1?n.push([e,r]):t[1]=Math.max(t[1],r)}return n}function zl([e,t]){return e===t?Bl(e):`${Bl(e)}-${Bl(t)}`}function Bl(e){let t=String.fromCodePoint(e);return t===`\\`||t===`]`||t===`-`||t===`^`?`\\${t}`:e<=31||e===127?`\\u${e.toString(16).padStart(4,`0`)}`:t}function Vl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Hl(e,t){return Ml(Vl(e),t)}function Ul(e){return Ml(`^${Vl(e).replace(/\\\*/g,`.*`).replace(/\\\?/g,`.`)}$`,`i`)}var Wl=class e{constructor(...t){T(this,`charset`,void 0),T(this,`strings`,void 0);let n=[],r=[];for(let i of t)i instanceof e?(n.push(i.charset),r.push(...i.strings)):i instanceof Pl||typeof i==`number`||Array.isArray(i)?n.push(i):r.push(i);this.charset=Fl(...n),this.strings=Array.from(new Set(r))}union(...t){return new e(this,...t)}subtract(...t){let n=new e(...t),r=this.strings.filter(e=>!n.strings.includes(e));return new e(this.charset.subtract(n.charset),...r)}isEmpty(){return this.charset.isEmpty()&&this.strings.length===0}toString(){if(this.isEmpty())return`(?!)`;let e=[...this.charset.isEmpty()?[]:[this.charset.toString()],...this.strings.map(Vl)];return e.length===1?e[0]:`(?:${e.join(`|`)})`}toRegExp(e){return Ml(this.toString(),e)}};let Gl={Charset:Pl,Or:Wl,charset:Fl,or:(...e)=>new Wl(...e),createRegExpFromSafeFragment:Ml,escapeRegExp:Vl,createLiteralRegExp:Hl,createFromWildcard:Ul};function Kl(e){return e===`@@@`||e===`@`}function ql(e){return e==null||e===`General`}function Jl(e){switch(e){case`frFR`:return`fr`;case`ruRU`:return`ru`;case`viVN`:return`vi`;case`zhCN`:return`zh-CN`;case`koKR`:return`ko`;case`zhTW`:return`zh-TW`;case`zhHK`:return`zh-HK`;case`esES`:case`caES`:return`es`;case`skSK`:return`sk`;case`jaJP`:return`ja`;case`ptBR`:return`pt`;case`deDE`:return`de`;case`itIT`:return`it`;case`idID`:return`id`;case`plPL`:return`pl`;case`arSA`:return`ar`;default:return`en`}}let Yl=(e,t)=>{if(e&&!t||!e&&t)return!1;let n=e=>{let t=Gc(e),n=``,r=!1,i=!1;for(let e of t)e.type===Al.POINT?r=!0:i&&e.type===Al.MINUS||e.type!==Al.SKIP&&(e.type===Al.COLOR?i=!0:(i=!1,r&&e.type===Al.ZERO||(r=!1,r||(n+=e.value||``))));return n};return n(e)===n(t)},Xl=/* @__PURE__ */ new Set([`m d`]),Zl=/* @__PURE__ */ new Set([`h:mm AM/PM`,`hh:mm AM/PM`]),Ql=/* @__PURE__ */ `Rp.zł.NT$.R$.HK$.$.£.¥.¤.֏.؋.৳.฿.៛.₡.₦.₩.₪.₫.€.₭.₮.₱.₲.₴.₸.₹.₺.₼.₽.₾.₿.﷼`.split(`.`),$l=RegExp(`^${Gl.charset(...Array.from(new Set(Ql.join(``))))}+`),eu=(e,t={})=>{let n=pl(e,t)??hl(e,t)??il(e,t);if(!n)return null;let{z:r}=n;if(r){if(Xl.has(r)||Zl.has(r)&&!/\s(A|AM|P|PM)$/i.test(e))return null;if(r.includes(`#,##0`)){if(/[.,]$/.test(e))return null;let t=e=>{let t=e.trim();return t.startsWith(`(`)&&t.endsWith(`)`)?t.slice(1,-1).trim():t},n=t(t(e).replace($l,``).trim());if(n.includes(`,`)&&!/^-?\d{1,3}(,\d{3})*(\.\d+)?$/.test(n))return null}}return n};function tu(e,t){let n={};for(let r in e){let i=Number(r),a=e[i];for(let e in a){let r=Number(e),o=a[r],s=t(i,r,o);s!==void 0&&(n[i]?n[i][r]=s:n[i]={[r]:s})}}return n}function nu(e){let t=0,n=Object.keys(e);for(let e of n){let n=Number(e);t=Math.max(t,n)}return t+1}let ru=e=>e==null||typeof e==`object`&&Object.keys(e).length===0;function iu(e,t,n){let r=nu(n),i=n;for(let t=r-1;t>=e;t--)ru(i[t])?delete i[t+1]:i[t+1]=i[t];ru(t)||(i[e]=t)}function au(e,t,n){let r=Object.keys(n).reduce((e,t)=>Math.max(e,Number.parseInt(t)),0)+1;for(let i=e;i<r;i++)i<e+t?delete n[i]:n[i]!==void 0&&(n[i-t]=n[i],delete n[i])}function ou(e,t){let n=e,r=Object.keys(n),i=r.length,a=t,o=Object.keys(a),s=o.length,c={},l=0;for(let e=0;e<i;e++,l++){let t=r[e];c[l]=n[t]}for(let e=0;e<s;e++,l++){let t=o[e];c[l]=a[t]}return c}function su(e,t,n){let r=n;if(nu(n)>0){let n={},i=0;for(let a=e;a<=t;a++)r[a]&&(n[i]=r[a],i++);return n}return{}}function cu(e,t,n,r){let i=e>n;if(!i&&e+t>n)throw Error(`Invalid move operation`);i?lu(e,t,n,r):uu(e,t,n,r)}function lu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e-1;r>=n;r--){let e=i[r];i[r+t]=e,e===void 0&&delete i[r+t]}a.forEach((e,t)=>{i[n+t]=e,e===void 0&&delete i[n+t]})}function uu(e,t,n,r){let i=r,a=[];for(let n=e;n<e+t;n++)a.push(i[n]);for(let r=e+t;r<n;r++){let e=i[r];i[r-t]=e,e===void 0&&delete i[r-t]}a.forEach((e,r)=>{i[n+r-t]=e,e===void 0&&delete i[n+r-t]})}var du=class e{constructor(e={}){T(this,`_matrix`,void 0),this._setOriginValue(e)}static MakeObjectMatrixSize(t){return new e({[t-1]:{}})}getMatrix(){return this._matrix}forEach(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,i)===!1)return this}return this}forRow(e){let t=this._matrix,n=Object.keys(t);for(let r of n){let n=Number(r),i=t[n];if(e(n,Object.keys(i).map(e=>Number(e)))===!1)return this}return this}forValue(e){let t=this._matrix;for(let n in t){let r=Number(n),i=t[r];if(i)for(let t in i){let n=Number(t),a=i[n];if(e(r,n,a)===!1)return this}}return this}swapRow(e,t){let n=this._matrix[e],r=this._matrix[t];this._matrix[e]=r,this._matrix[t]=n}getRow(e){return this._matrix[e]}getRowOrCreate(e){let t=this.getRow(e);return t??(t={},this._matrix[e]=t),t}reset(){this._setOriginValue({})}hasValue(){let e=this._matrix,t=Object.keys(e);if(t.length===0)return!1;for(let n of t){let t=e[Number(n)];if(Object.keys(t).length>0)return!0}return!1}getValue(e,t){var n;return(n=this._matrix)==null||(n=n[e])==null?void 0:n[t]}setValue(e,t,n){let r=this.getRowOrCreate(e);r[t]=n}realDeleteValue(e,t){var n;if((n=this._matrix)==null||(n=n[e])==null||delete n[t],this.getRow(e)){let t=this.getRow(e);if(t==null)return;if(Object.keys(t).length===0){var r;(r=this._matrix)==null||delete r[e]}}}setRow(e,t){this._matrix[e]=t}moveRows(e,t,n){cu(e,t,n,this._matrix)}moveColumns(e,t,n){this.forEach((r,i)=>{cu(e,t,n,i)})}insertRows(e,t){let n=Object.keys(this._matrix);for(let r=n.length-1;r>=0;r--){let i=Number(n[r]);if(i>=e){let e=this._matrix[i];delete this._matrix[i],this._matrix[i+t]=e}}}insertColumns(e,t){let n=Object.keys(this._matrix);for(let r=0;r<n.length;r++){let i=Number(n[r]),a=this._matrix[i],o=Object.keys(a);for(let n=o.length-1;n>=0;n--){let r=Number(o[n]);if(r>=e){let e=a[r];delete a[r],a[r+t]=e}}}}removeRows(e,t){au(e,t,this._matrix)}removeColumns(e,t){this.forEach((n,r)=>{r&&au(e,t,r)})}getFragment(t,n,r,i){let a=new e,o=0;for(let e=t;e<=n;e++){let t={},n=0;for(let a=r;a<=i;a++){let r=this.getValue(e,a);t[n]=r,n++}a.setRow(o,t),o++}return a}getSlice(t,n,r,i){let a=new e;for(let e=t;e<=n;e++)for(let t=r;t<=i;t++){let n=this.getValue(e,t);n&&a.setValue(e,t,z.deepClone(n))}return a}getSliceDataAndCellCountByRows(t,n){let r=new e,i=0;for(let e=t;e<=n;e++){let t=this.getRow(e);t&&(r.setRow(e,t),i+=Object.keys(t).length)}return{sliceData:r,cellCount:i}}getSizeOf(){return Object.keys(this._matrix).length}getLength(){return nu(this._matrix)}getRange(){let e=this.getLength()-1,t=0,n=this.getLength();for(let e=0;e<n;e++){let n=this.getRow(e);if(n){let e=nu(n)-1;t=e>t?e:t}}return{startRow:0,startColumn:0,endRow:e,endColumn:t}}getRealRange(){let e=Object.keys(this._matrix),t=e.length,n=t>0?Number(e[0]):0,r=t>0?Number(e[t-1]):0,i=-1/0,a=0;for(let t of e){let e=this.getRow(Number(t));if(e){let t=Object.keys(e);if(t.length>0){let e=Number(t[0]),n=Number(t[t.length-1]);(i===-1/0||e<i)&&(i=e),n>a&&(a=n)}}}return i===-1/0&&(i=0),{startRow:n,endRow:r,startColumn:i,endColumn:a}}getRealRowRange(){let e=Object.keys(this._matrix),t=e.length;return{startRow:t>0?Number(e[0]):0,endRow:t>0?Number(e[t-1]):0}}toNativeArray(){let e=[];return this.forValue((t,n,r)=>{e.push(r)}),e}toArray(){let e=[];return this.forRow((t,n)=>{e[t]??(e[t]=[]),n.forEach(n=>{e[t][n]=this.getValue(t,n)})}),e}toFullArray(){let{endColumn:e,endRow:t}=this.getRange(),n=[];for(let r=0;r<=t;r++){let t=Array(e+1).fill(void 0);n.push(t)}return this.forValue((e,t,r)=>{n[e][t]=r}),n}clone(){let e=JSON.stringify(this._matrix);return JSON.parse(e)}getArrayData(){let t=0,n=0,r=!1,i=!1,a=new e;return this.forEach((e,o)=>{r||(r=!0,t=e),Object.keys(o).forEach(r=>{let o=Number(r);i?o<n&&(n=o):(i=!0,n=o);let s=this.getValue(e,o);a.setValue(e-t,o-n,s)})}),a.clone()}getStartEndScope(){let e=-1,t=-1,n=-1,r=-1,i=Object.keys(this._matrix);i.length>0&&(e=+i[0],t=+i[i.length-1]);for(let e of i){let t=Object.keys(this._matrix[e]);t.length>0&&(n=n===-1?+t[0]:Math.min(n,+t[0]),r=Math.max(r,+t[t.length-1]))}return{startRow:e,endRow:t,startColumn:n,endColumn:r}}getDataRange(){let e=0,t=0,n=0,r=-1,i=!1,a=!1;return this.forEach((o,s)=>{if(i||(i=!0,e=o),s==null)return;let c=nu(s)-1;c>n&&(n=c),Object.keys(s).forEach(e=>{let n=Number(e);a?n<t&&(t=n):(a=!0,t=n)}),o>r&&(r=o)}),{startRow:e,startColumn:t,endRow:r,endColumn:n}}getDiscreteRanges(){let e=[];return this.forEach((t,n)=>{Object.keys(n).forEach(n=>{let r=Number(n),i=!1;for(let n of e)if(t>=n.startRow&&t<=n.endRow+1&&r>=n.startColumn&&r<=n.endColumn+1){n.endRow=Math.max(t,n.endRow),n.endColumn=Math.max(r,n.endColumn),i=!0;break}i||e.push({startRow:t,endRow:t,startColumn:r,endColumn:r})})}),e}merge(e){this.forValue((t,n)=>{let r=e.getValue(t,n);r!=null&&this.setValue(t,n,r)})}concatRows(e){let t=e.getMatrix();for(let e in t){let n=Number(e);this.setRow(n,t[n])}}_setOriginValue(e={}){this._matrix=e}};function fu(e){let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,mergeInfo:a}=e,{startY:o,endY:s,startX:c,endX:l}=e,u=t,d=n,f=t,p=n;if(r&&a){let{startRow:e,startColumn:t,endRow:n,endColumn:r,startY:i,endY:m,startX:h,endX:g}=a;u=e,d=t,f=n,p=r,o=i,s=m,c=h,l=g}return i&&(o=a.startY,s=a.endY,c=a.startX,l=a.endX,f=a.endRow,p=a.endColumn),{startRow:u,startColumn:d,endRow:f,endColumn:p,startY:o,endY:s,startX:c,endX:l}}function pu(e){if(!e)return;let{actualRow:t,actualColumn:n,isMerged:r,isMergedMainCell:i,startRow:a,startColumn:o,endRow:s,endColumn:c}=e,l=t,u=n,d=t,f=n;return(r||i)&&(l=a,u=o,d=s,f=c),{startRow:l,startColumn:u,endRow:d,endColumn:f}}function mu(e){var t;return!e||((e==null||(t=e.v)==null?void 0:t.toString())||``).length===0&&!e.p}function hu(e){return mu(e)&&(e==null?void 0:e.coverable)!==!1}function gu(e){if(e){if(e.rgb)return new La(e.rgb).toHexString();if(e.th!=null){var t;let n=(t=ho.Office)==null?void 0:t[e.th];if(n)return new La(n).toRgbString()}}return null}function _u(e){return z.isString(e)&&e.substring(0,1)===`=`&&e.length>1}function vu(e){return z.isString(e)&&e.length>0}let yu=/(text-decoration(?:-line)?:\s*[^;]+)(?=;)/;function bu(e,t=!1){let n=``,r=/* @__PURE__ */ new Map([[`ff`,()=>{e.ff&&(n+=`font-family: ${e.ff}; `)}],[`fs`,()=>{if(e.fs){let t=e.fs;e.va&&(t/=2),n+=`font-size: ${t}pt; `}}],[`it`,()=>{e.it&&(n+=`font-style: italic; `)}],[`bl`,()=>{e.bl&&(n+=`font-weight: bold; `)}],[`ul`,()=>{var t;(t=e.ul)!=null&&t.s&&(yu.test(n)?n=n.replace(yu,(e,t)=>`${t} underline`):n+=`text-decoration: underline; `,e.ul.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ul.cl)}; `),e.ul.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ul.t} `))}],[`st`,()=>{var t;(t=e.st)!=null&&t.s&&(yu.test(n)?n=n.replace(yu,(e,t)=>`${t} line-through`):n+=`text-decoration-line: line-through; `,e.st.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.st.cl)}; `),e.st.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.st.t} `))}],[`ol`,()=>{var t;(t=e.ol)!=null&&t.s&&(yu.test(n)?n=n.replace(yu,(e,t)=>`${t} overline`):n+=`text-decoration-line: overline; `,e.ol.cl&&n.indexOf(`text-decoration-color`)===-1&&(n+=`text-decoration-color: ${gu(e.ol.cl)}; `),e.ol.t&&n.indexOf(`text-decoration-style`)===-1&&(n+=`text-decoration-style: ${e.ol.t} `))}],[`bg`,()=>{e.bg&&(n+=`background: ${gu(e.bg)}; `)}],[`bd`,()=>{var t,r,i,a;if((t=e.bd)!=null&&t.b){var o;n+=`border-bottom: ${Su((o=e.bd)==null?void 0:o.b.s)} ${gu(e.bd.b.cl)??``}; `}if((r=e.bd)!=null&&r.t){var s;n+=`border-top: ${Su((s=e.bd)==null?void 0:s.t.s)} ${gu(e.bd.t.cl)??``}; `}if((i=e.bd)!=null&&i.r){var c;n+=`border-right: ${Su((c=e.bd)==null?void 0:c.r.s)} ${gu(e.bd.r.cl)??``}; `}if((a=e.bd)!=null&&a.l){var l;n+=`border-left: ${Su((l=e.bd)==null?void 0:l.l.s)} ${gu(e.bd.l.cl)??``}; `}}],[`cl`,()=>{e.cl&&(n+=`color: ${gu(e.cl)}; `)}],[`va`,()=>{e.va===2?n+=`vertical-align: sub; `:e.va===3&&(n+=`vertical-align: super; `)}],[`td`,()=>{e.td===1?n+=`direction: ltr; `:e.td===2&&(n+=`direction: rtl; `)}],[`tr`,()=>{if(e.tr){var t,r,i;n+=`--data-rotate: (${(t=e.tr)==null?void 0:t.a}deg${(r=e.tr)!=null&&r.v?` ,${(i=e.tr)==null?void 0:i.v}`:``});`}}],[`ht`,()=>{e.ht===1?n+=`text-align: left; `:e.ht===3?n+=`text-align: right; `:e.ht===2?n+=`text-align: center; `:e.ht===4&&(n+=`text-align: justify; `)}],[`vt`,()=>{e.vt===3?n+=`vertical-align: bottom; `:e.vt===1?n+=`vertical-align: top; `:e.vt===2&&(n+=`vertical-align: middle; `)}],[`tb`,()=>{e.tb===2?n+=`white-space: nowrap; overflow-x: hidden; `:e.tb===3&&(n+=`white-space: normal;`)}],[`pd`,()=>{var t,r,i,a,o,s,c,l;let u=`${(t=e.pd)==null?void 0:t.b}pt`,d=`${(r=e.pd)==null?void 0:r.t}pt`,f=`${(i=e.pd)==null?void 0:i.l}pt`,p=`${(a=e.pd)==null?void 0:a.r}pt`;(o=e.pd)!=null&&o.b&&(n+=`padding-bottom: ${u}; `),(s=e.pd)!=null&&s.t&&(n+=`padding-top: ${d}; `),(c=e.pd)!=null&&c.l&&(n+=`padding-left: ${f}; `),(l=e.pd)!=null&&l.r&&(n+=`padding-right: ${p}; `)}]]),i=[`bd`,`tr`,`tb`];for(let n in e){var a;t&&i.includes(n)||(a=r.get(n))==null||a()}return n}function xu(e,t){let n=t.split(/\s+/);n.includes(`underline`)&&(e.ul={...e.ul,s:1}),n.includes(`line-through`)&&(e.st={...e.st,s:1}),n.includes(`overline`)&&(e.ol={...e.ol,s:1})}function Su(e){let t=``;return e===0?t=`none`:e===1?t=`0.5pt solid`:e===2?t=`0.5pt double`:e===3?t=`0.5pt dotted`:e===4||e===5?t=`0.5pt dashed`:e===6?t=`0.5pt dotted`:e===7?t=`0.5pt double`:e===8?t=`1pt solid`:e===9||e===10?t=`1pt dashed`:e===11?t=`1pt dotted`:e===12?t=`0.5pt dashed`:e===13&&(t=`1.5pt solid`),t}function Cu(e){let t=0;if(e=e.trim(),e===`none`)t=0;else if(e===`0.5pt solid`)t=1;else if(e===`0.5pt double`)t=2;else if(e===`0.5pt dotted`)t=3;else if(e===`0.5pt dashed`)t=4;else if(e===`1pt solid`)t=8;else if(e===`1pt dashed`)t=9;else if(e===`1pt dotted`)t=11;else if(e===`1.5pt solid`)t=13;else if(!e.includes(`none`))t=1;else return 0;return t}function wu(e,t){let n=e.body;if(t){let{headers:r,footers:i}=e;r!=null&&r[t]?n=r[t].body:i!=null&&i[t]&&(n=i[t].body)}return n}function Tu(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a,rangeType:o}=e;if(n<0||i<0||r<0||a<0||!(Number.isNaN(n)&&Number.isNaN(r))&&o===2||!(Number.isNaN(i)&&Number.isNaN(a))&&o===1||o!==1&&o!==2&&(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(a)||Number.isNaN(r)))return!1;if(t){let e=t.getRowCount(),n=t.getColumnCount();if(r>=e||a>=n)return!1}return!0}function Eu(e,t){return{startRow:e,endRow:e,startColumn:t,endColumn:t}}function Du(e){return e.si===void 0?e.f===void 0?e.v===void 0&&e.p===void 0?e:{...e,f:null,si:null}:{...e,si:null}:e}function Ou(e){if(_u(e))return{f:e,v:null,p:null,si:null};if(so(e)){if(typeof e==`string`){let t=eu(e);if(t&&t.z)return{v:t.v,p:null,f:null,si:null,s:{n:{pattern:t.z||`General`}}}}return{v:e,p:null,f:null,si:null}}return io(e)?Du(e):e}function ku(e,t){let n=new du,{startRow:r,startColumn:i,endRow:a,endColumn:o}=t;if(z.isArray(e))for(let t=0;t<=a-r;t++)for(let a=0;a<=o-i;a++)n.setValue(t+r,a+i,Ou(e[t][a]));else new du(e).forValue((e,t,r)=>{n.setValue(e,t,Ou(r))});return n.getMatrix()}function Au(e,t){return Object.prototype.toString.call(e)===Object.prototype.toString.call(t)?Object.prototype.toString.call(e)===`[object Object]`||Object.prototype.toString.call(e)===`[object Array]`?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Au(e[n],t[n])):e===t:!1}function ju(e,t){let n=e.ts||{},r=t.ts||{};if(e.sId!==t.sId||!Au(n,r))return!1;let i=/* @__PURE__ */ new Set([...Object.keys(e),...Object.keys(t)]);for(let n of i)if(n!==`st`&&n!==`ed`&&n!==`ts`&&n!==`sId`&&!Au(e[n],t[n]))return!1;return!0}function Mu(e,t){return t.some(t=>e.indexOf(t)>-1)}let Nu=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],Pu=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Fu=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Iu=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Lu=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],Ru={L:`MM/DD/YYYY`,LL:`MMMM D, YYYY`,LLL:`MMMM D, YYYY h:mm A`,LLLL:`dddd, MMMM D, YYYY h:mm A`,l:`M/D/YYYY`,ll:`MMM D, YYYY`,lll:`MMM D, YYYY h:mm A`,llll:`ddd, MMM D, YYYY h:mm A`},zu={millisecond:`millisecond`,milliseconds:`millisecond`,ms:`millisecond`,second:`second`,seconds:`second`,s:`second`,minute:`minute`,minutes:`minute`,m:`minute`,hour:`hour`,hours:`hour`,h:`hour`,day:`day`,days:`day`,d:`day`,week:`week`,weeks:`week`,w:`week`,month:`month`,months:`month`,M:`month`,year:`year`,years:`year`,y:`year`};var Bu=class e{constructor(e,t){this._date=e,this._isUTC=t}isValid(){return!Number.isNaN(this._date.getTime())}format(e=`YYYY-MM-DDTHH:mm:ssZ`){return this.isValid()?td(this._date,e,this._isUTC):`Invalid Date`}formatIntl(e,t={}){if(!this.isValid())return`Invalid Date`;if(typeof Intl>`u`||typeof Intl.DateTimeFormat!=`function`)return this.format();let n=this._isUTC&&!t.timeZone?{...t,timeZone:`UTC`}:t;return new Intl.DateTimeFormat(e,n).format(this._date)}valueOf(){return this._date.getTime()}toDate(){return new Date(this.valueOf())}_clone(){return new e(this.toDate(),this._isUTC)}add(t,n=`millisecond`){let r=Ku(n);return!this.isValid()||!r||!Number.isFinite(t)?this._clone():new e(Yu(this._date,t,r,this._isUTC),this._isUTC)}subtract(e,t=`millisecond`){return this.add(-e,t)}startOf(t){let n=Ku(t);return!n||!this.isValid()?this._clone():new e(Xu(this._date,n,this._isUTC),this._isUTC)}endOf(e){let t=Ku(e);return!t||!this.isValid()||t===`millisecond`?this._clone():this.startOf(t).add(1,t).subtract(1,`millisecond`)}utc(){return new e(this.toDate(),!0)}local(){return new e(this.toDate(),!1)}weekday(e){let t=(Hu(this._date,this._isUTC).dayOfWeek-0+7)%7;return e===void 0?t:this.add(e-t,`day`)}week(e){let t=Zu(this._date,this._isUTC);return e===void 0?t:this.add((e-t)*7,`day`)}};function Vu(e,t=2){return String(Math.abs(e)).padStart(t,`0`)}function Hu(e,t){return t?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),millisecond:e.getUTCMilliseconds(),dayOfWeek:e.getUTCDay()}:{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds(),dayOfWeek:e.getDay()}}function Uu(e,t){return e instanceof Bu?e.toDate():e===void 0?/* @__PURE__ */ new Date:e===null?/* @__PURE__ */ new Date(NaN):e instanceof Date?new Date(e.getTime()):typeof e==`number`?new Date(e):typeof e==`string`?Gu(e,t):/* @__PURE__ */ new Date(NaN)}function Wu(e,t,n,r,i,a,o,s){let c=s?new Date(Date.UTC(e,t-1,n,r,i,a,o)):new Date(e,t-1,n,r,i,a,o),l=Hu(c,s);return l.year!==e||l.month!==t||l.day!==n||l.hour!==r||l.minute!==i||l.second!==a?/* @__PURE__ */ new Date(NaN):c}function Gu(e,t){let n=e.trim();if(!n)return/* @__PURE__ */ new Date(NaN);let r=n.match(/^(\d{4})年(\d{1,2})月(\d{1,2})日(?:\s+(\d{1,2})(?::(\d{1,2})(?::(\d{1,2}))?)?)?$/);if(r){let[,e,n,i,a=`0`,o=`0`,s=`0`]=r;return Wu(Number(e),Number(n),Number(i),Number(a),Number(o),Number(s),0,t)}let i=n.match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})(?:[ T](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?)?$/);if(i){let[,e,n,r,a=`0`,o=`0`,s=`0`,c=`0`]=i;return Wu(Number(e),Number(n),Number(r),Number(a),Number(o),Number(s),Number(c),t)}return/^-?\d+(\.\d+)?$/.test(n)?new Date(Number(n)):new Date(n)}function Ku(e){return zu[e]??zu[String(e).toLowerCase()]}function qu(e,t,n){return n?new Date(Date.UTC(e,t,0)).getUTCDate():new Date(e,t,0).getDate()}function Ju(e,t,n,r){let i=new Date(e.getTime());if(t){switch(n){case`year`:i.setUTCFullYear(r);break;case`month`:i.setUTCMonth(r);break;case`day`:i.setUTCDate(r);break;case`hour`:i.setUTCHours(r);break;case`minute`:i.setUTCMinutes(r);break;case`second`:i.setUTCSeconds(r);break;case`millisecond`:i.setUTCMilliseconds(r)}return i}switch(n){case`year`:i.setFullYear(r);break;case`month`:i.setMonth(r);break;case`day`:i.setDate(r);break;case`hour`:i.setHours(r);break;case`minute`:i.setMinutes(r);break;case`second`:i.setSeconds(r);break;case`millisecond`:i.setMilliseconds(r)}return i}function Yu(e,t,n,r){switch(n){case`millisecond`:return new Date(e.getTime()+t);case`second`:return new Date(e.getTime()+t*1e3);case`minute`:return new Date(e.getTime()+t*6e4);case`hour`:return new Date(e.getTime()+t*36e5);case`day`:return Ju(e,r,`day`,(r?e.getUTCDate():e.getDate())+t);case`week`:return Ju(e,r,`day`,(r?e.getUTCDate():e.getDate())+t*7);case`month`:{let n=Hu(e,r),i=Wu(n.year,n.month,1,n.hour,n.minute,n.second,n.millisecond,r),a=Ju(i,r,`month`,(r?i.getUTCMonth():i.getMonth())+t),o=Hu(a,r),s=qu(o.year,o.month,r);return Ju(a,r,`day`,Math.min(n.day,s))}case`year`:return Yu(e,t*12,`month`,r)}}function Xu(e,t,n){let r=Hu(e,n);switch(t){case`year`:return Wu(r.year,1,1,0,0,0,0,n);case`month`:return Wu(r.year,r.month,1,0,0,0,0,n);case`week`:{let e=(r.dayOfWeek-0+7)%7,t=Wu(r.year,r.month,r.day,0,0,0,0,n);return Ju(t,n,`day`,(n?t.getUTCDate():t.getDate())-e)}case`day`:return Wu(r.year,r.month,r.day,0,0,0,0,n);case`hour`:return Wu(r.year,r.month,r.day,r.hour,0,0,0,n);case`minute`:return Wu(r.year,r.month,r.day,r.hour,r.minute,0,0,n);case`second`:return Wu(r.year,r.month,r.day,r.hour,r.minute,r.second,0,n);default:return new Date(e.getTime())}}function Zu(e,t){let n=Hu(Xu(e,`week`,t),t),r=Hu(Xu(Xu(e,`year`,t),`week`,t),t),i=Wu(n.year,n.month,n.day,0,0,0,0,!0),a=Wu(r.year,r.month,r.day,0,0,0,0,!0);return Math.floor((i.getTime()-a.getTime())/864e5/7)+1}function Qu(e,t,n=!1){if(t)return n?`+0000`:`+00:00`;let r=-e.getTimezoneOffset(),i=r>=0?`+`:`-`,a=Math.abs(r),o=Vu(Math.floor(a/60),2),s=Vu(a%60,2);return n?`${i}${o}${s}`:`${i}${o}:${s}`}function $u(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function ed(e){return e.replace(/LLLL|LLL|LL|L|llll|lll|ll|l/g,e=>Ru[e]??e)}function td(e,t,n){let r=Hu(e,n),i=r.hour%12,a=i===0?12:i,o=Math.ceil(r.month/3),s={YYYY:String(r.year),YY:Vu(r.year%100,2),MMMM:Nu[r.month-1],MMM:Pu[r.month-1],MM:Vu(r.month,2),M:String(r.month),DD:Vu(r.day,2),D:String(r.day),Do:$u(r.day),dddd:Fu[r.dayOfWeek],ddd:Iu[r.dayOfWeek],dd:Lu[r.dayOfWeek],d:String(r.dayOfWeek),HH:Vu(r.hour,2),H:String(r.hour),hh:Vu(a,2),h:String(a),mm:Vu(r.minute,2),m:String(r.minute),ss:Vu(r.second,2),s:String(r.second),SSS:Vu(r.millisecond,3),A:r.hour>=12?`PM`:`AM`,a:r.hour>=12?`pm`:`am`,Q:String(o),Qo:$u(o),X:String(Math.floor(e.getTime()/1e3)),x:String(e.getTime()),Z:Qu(e,n,!1),ZZ:Qu(e,n,!0)},c=[];return ed(t.replace(/\[([^\]]+)]/g,(e,t)=>`\u0000${c.push(t)-1}\u0000`)).replace(/YYYY|YY|MMMM|MMM|MM|M|DD|Do|D|dddd|ddd|dd|d|HH|H|hh|h|mm|m|ss|s|SSS|A|a|Qo|Q|X|x|ZZ|Z/g,e=>s[e]??e).replace(/\u0000(\d+)\u0000/g,(e,t)=>c[Number(t)]??``)}function nd(e){return new Bu(Uu(e,!1),!1)}let rd=Object.assign(nd,{utc:e=>new Bu(Uu(e,!0),!0),isDateKit:e=>e instanceof Bu,unix:e=>nd(e*1e3)});function id(e,t,n,r){if(e>t)throw Error(`a1 should be less than a2`);if(n>r)throw Error(`b1 should be less than b2`);if(t<n||r<e)return[e,t];if(n<=e&&r>=t)return[];let i=r-n+1;return e<n&&t>r?[e,t-i]:n<=e&&r<t?[r+1-i,t-i]:n>e&&r>=t?[e,n-1]:[e,t]}function ad(e){if(e==null)return!1;let t=e.bullet;return(t==null?void 0:t.listId)!=null}function od(e){if(e==null)return!1;let t=e.paragraphStyle;return sd(t)}function sd(e){var t;return e!=null&&(e.indentStart!=null&&e.indentStart.v!==0||e.hanging!=null)&&((t=e.hanging)==null?void 0:t.v)!==0}function cd(e,t,n){return e.slice(0,t)+n+e.slice(t)}function ld(e,t,n){return t>n?e:e.slice(0,t)+e.slice(n)}function ud(e){if(e==null||typeof e==`boolean`)return!1;if(typeof e==`number`)return!isNaN(e);if(typeof e==`string`){let t=e.trim();return t!==``&&!isNaN(Number(t))}return!1}function dd(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+(t<<6)+(t<<16)-t;return t>>>0}function fd(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>(Array.isArray(e)?e[0]:e)-(Array.isArray(t)?t[0]:t)),n=[],r=Array.isArray(t[0])?t[0][0]:t[0],i=r;for(let e=1;e<t.length;e++){let a=t[e],o,s;Array.isArray(a)?(o=a[0],s=a[1]):(o=a,s=a),o<=i+1?i=Math.max(i,s):(n.push([r,i]),r=o,i=s)}return n.push([r,i]),n}function pd(e){if(e.length===0)return[];let t=e.slice().sort((e,t)=>e[0]-t[0]),n=[],[r,i]=t[0];for(let e=1;e<t.length;e++){let[a,o]=t[e];a<=i+1?i=Math.max(i,o):(n.push([r,i]),r=a,i=o)}return n.push([r,i]),n}function md(...e){let t;return t=e.length===1&&Array.isArray(e[0])?e[0]:e,Object.assign({},...t)}let hd,gd,_d,vd,K=Symbol(`newer`),q=Symbol(`older`);hd=Symbol.iterator;var yd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[hd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.key}):{done:!0,value:void 0}}};gd=Symbol.iterator;var bd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[gd](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:e.value}):{done:!0,value:void 0}}};_d=Symbol.iterator;var xd=class{constructor(e){T(this,`entry`,void 0),this.entry=e}[_d](){return this}next(){let e=this.entry;return e?(this.entry=e[K],{done:!1,value:[e.key,e.value]}):{done:!0,value:void 0}}},Sd=class{constructor(e,t){T(this,`key`,void 0),T(this,`value`,void 0),T(this,K,void 0),T(this,q,void 0),this.key=e,this.value=t,this[K]=void 0,this[q]=void 0}toJSON(){return{key:this.key,value:this.value}}};vd=Symbol.iterator;var Cd=class{onShift(e){if(this._onShiftListeners.indexOf(e)===-1)return this._onShiftListeners.push(e),D(()=>Be(this._onShiftListeners,e));throw Error(`[LRUMap]: the listener has been registered!`)}constructor(...e){if(T(this,`_keymap`,void 0),T(this,`size`,0),T(this,`limit`,void 0),T(this,`oldest`,void 0),T(this,`newest`,void 0),T(this,`_onShiftListeners`,[]),wd.hasLength(e,1)){if(wd.isNumber(e[0])){let t=e[0];this._initialize(t,void 0);return}if(wd.isIterable(e[0])){let t=e[0];this._initialize(0,t);return}}else if(wd.hasLength(e,2)){let t=e[0],n=e[1];this._initialize(t,n)}}_initialize(e,t){this.oldest=void 0,this.newest=void 0,this.size=0,this.limit=e,this._keymap=/* @__PURE__ */ new Map,t&&(this.assign(t),e<1&&(this.limit=this.size))}_markEntryAsUsed(e){e!==this.newest&&(e[K]&&(e===this.oldest&&(this.oldest=e[K]),e[K][q]=e[q]),e[q]&&(e[q][K]=e[K]),e[K]=void 0,e[q]=this.newest,this.newest&&(this.newest[K]=e),this.newest=e)}assign(e){let t,n=this.limit||Number.MAX_VALUE;this._keymap.clear();let r=e[Symbol.iterator]();for(let e=r.next();!e.done;e=r.next()){let r=new Sd(e.value[0],e.value[1]);if(this._keymap.set(r.key,r),t?(t[K]=r,r[q]=t):this.oldest=r,t=r,n--===0)throw Error(`overflow`)}this.newest=t,this.size=this._keymap.size}set(e,t){let n=this._keymap.get(e);return n?(n.value=t,this._markEntryAsUsed(n),this):(this._keymap.set(e,n=new Sd(e,t)),this.newest?(this.newest[K]=n,n[q]=this.newest):this.oldest=n,this.newest=n,++this.size,this.size>this.limit&&this.shift(),this)}shift(){let e=this.oldest;if(e)return this.oldest&&this.oldest[K]?(this.oldest=this.oldest[K],this.oldest[q]=void 0):(this.oldest=void 0,this.newest=void 0),e[K]=e[q]=void 0,this._keymap.delete(e.key),--this.size,this._onShiftListeners.forEach(t=>t(e)),[e.key,e.value]}get(e){let t=this._keymap.get(e);if(t)return this._markEntryAsUsed(t),t.value}has(e){return this._keymap.has(e)}find(e){let t=this._keymap.get(e);return t?t.value:void 0}delete(e){let t=this._keymap.get(e);if(t)return this._keymap.delete(t.key),t[K]&&t[q]?(t[q][K]=t[K],t[K][q]=t[q]):t[K]?(t[K][q]=void 0,this.oldest=t[K]):t[q]?(t[q][K]=void 0,this.newest=t[q]):this.oldest=this.newest=void 0,this.size--,t.value}clear(){this.oldest=void 0,this.newest=void 0,this.size=0,this._keymap.clear()}keys(){return new yd(this.oldest)}values(){return new bd(this.oldest)}entries(){return this[Symbol.iterator]()}[vd](){return new xd(this.oldest)}forEach(e,t){typeof t!=`object`&&(t=this);let n=this.oldest;for(;n;)e.call(t,n.value,n.key,this),n=n[K]}toJSON(){let e=Array(this.size),t=0,n=this.oldest;for(;n;)e[t++]={key:n.key,value:n.value},n=n[K];return e}toString(){let e=``,t=this.oldest;for(;t;)e+=`${String(t.key)}:${t.value}`,t=t[K],t&&(e+=` < `);return e}},wd=class{static hasLength(e,t){return e.length===t}static getValueType(e){return Object.prototype.toString.apply(e)}static isObject(e){return this.getValueType(e)===`[object Object]`}static isIterable(e){return e[Symbol.iterator]!=null}static isNumber(e){return this.getValueType(e)===`[object Number]`}};function Td(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<65||r>90)return-1;t=t*26+(r-64)}return t}function Ed(){let e=typeof crypto<`u`&&typeof crypto.getRandomValues==`function`?crypto:typeof self<`u`&&self.crypto&&typeof self.crypto.getRandomValues==`function`?self.crypto:typeof window<`u`&&window.crypto&&typeof window.crypto.getRandomValues==`function`?window.crypto:void 0;return e==null?void 0:e.getRandomValues.bind(e)}function Dd(e,t){let n=``;for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Od(e,t,n){let r=256-256%t.length,i=Math.ceil(409.6*e/r),a=``;for(;a.length<e;){let o=n(new Uint8Array(i));for(let n=0;n<i&&a.length<e;n++){let e=o[n];e<r&&(a+=t[e%t.length])}}return a}function kd(e=21,t=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`){if(!e)return``;let n=Ed();return n?Od(e,t,n):Dd(e,t)}function J(e=21,t){return kd(e,t)}function Ad(e,t,n=0,r=e.length-1,i=Md){for(;r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1);Ad(e,t,Math.max(n,Math.floor(t-o*c/a+l)),Math.min(r,Math.floor(t+(a-o)*c/a+l)),i)}let a=e[t],o=n,s=r;for(jd(e,n,t),i(e[r],a)>0&&jd(e,n,r);o<s;){for(jd(e,o,s),o++,s--;i(e[o],a)<0;)o++;for(;i(e[s],a)>0;)s--}i(e[n],a)===0?jd(e,n,s):(s++,jd(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function jd(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Md(e,t){return e<t?-1:+(e>t)}var Nd=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data,n=[];if(!Gd(e,t))return n;let r=this.toBBox,i=[];for(;t;){for(let a=0;a<t.children.length;a++){let o=t.children[a],s=t.leaf?r(o):o;Gd(e,s)&&(t.leaf?n.push(o):Wd(e,s)?this._all(o,n):i.push(o))}t=i.pop()}return n}collides(e){let t=this.data;if(!Gd(e,t))return!1;let n=[];for(;t;){for(let r=0;r<t.children.length;r++){let i=t.children[r],a=t.leaf?this.toBBox(i):i;if(Gd(e,a)){if(t.leaf||Wd(e,a))return!0;n.push(i)}}t=n.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let t=0;t<e.length;t++)this.insert(e[t]);return this}let t=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=t;else if(this.data.height===t.height)this._splitRoot(this.data,t);else{if(this.data.height<t.height){let e=this.data;this.data=t,t=e}this._insert(t,this.data.height-t.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=Kd([]),this}remove(e,t){if(!e)return this;let n=this.data,r=this.toBBox(e),i=[],a=[],o,s,c;for(;n||i.length;){if(n||(n=i.pop(),s=i[i.length-1],o=a.pop(),c=!0),n.leaf){let r=Pd(e,n.children,t);if(r!==-1)return n.children.splice(r,1),i.push(n),this._condense(i),this}!c&&!n.leaf&&Wd(n,r)?(i.push(n),a.push(o),o=0,s=n,n=n.children[0]):s?(o++,n=s.children[o],c=!1):n=null}return this}toBBox(e){return e}compareMinX(e,t){return e.minX-t.minX}compareMinY(e,t){return e.minY-t.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,t){let n=[];for(;e;)e.leaf?t.push(...e.children):n.push(...e.children),e=n.pop();return t}_build(e,t,n,r){let i=n-t+1,a=this._maxEntries,o;if(i<=a)return o=Kd(e.slice(t,n+1)),Fd(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(a)),a=Math.ceil(i/a**(r-1))),o=Kd([]),o.leaf=!1,o.height=r;let s=Math.ceil(i/a),c=s*Math.ceil(Math.sqrt(a));qd(e,t,n,c,this.compareMinX);for(let i=t;i<=n;i+=c){let t=Math.min(i+c-1,n);qd(e,i,t,s,this.compareMinY);for(let n=i;n<=t;n+=s){let i=Math.min(n+s-1,t);o.children.push(this._build(e,n,i,r-1))}}return Fd(o,this.toBBox),o}_chooseSubtree(e,t,n,r){for(;r.push(t),!(t.leaf||r.length-1===n);){let n=1/0,r=1/0,i;for(let a=0;a<t.children.length;a++){let o=t.children[a],s=Bd(o),c=Hd(e,o)-s;c<r?(r=c,n=s<n?s:n,i=o):c===r&&s<n&&(n=s,i=o)}t=i||t.children[0]}return t}_insert(e,t,n){let r=n?e:this.toBBox(e),i=[],a=this._chooseSubtree(r,this.data,t,i);for(a.children.push(e),Ld(a,r);t>=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)}_split(e,t){let n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);let a=this._chooseSplitIndex(n,i,r),o=Kd(n.children.splice(a,n.children.length-a));o.height=n.height,o.leaf=n.leaf,Fd(n,this.toBBox),Fd(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)}_splitRoot(e,t){this.data=Kd([e,t]),this.data.height=e.height+1,this.data.leaf=!1,Fd(this.data,this.toBBox)}_chooseSplitIndex(e,t,n){let r,i=1/0,a=1/0;for(let o=t;o<=n-t;o++){let t=Id(e,0,o,this.toBBox),s=Id(e,o,n,this.toBBox),c=Ud(t,s),l=Bd(t)+Bd(s);c<i?(i=c,r=o,a=l<a?l:a):c===i&&l<a&&(a=l,r=o)}return r||n-t}_chooseSplitAxis(e,t,n){let r=e.leaf?this.compareMinX:Rd,i=e.leaf?this.compareMinY:zd;this._allDistMargin(e,t,n,r)<this._allDistMargin(e,t,n,i)&&e.children.sort(r)}_allDistMargin(e,t,n,r){e.children.sort(r);let i=this.toBBox,a=Id(e,0,t,i),o=Id(e,n-t,n,i),s=Vd(a)+Vd(o);for(let r=t;r<n-t;r++){let t=e.children[r];Ld(a,e.leaf?i(t):t),s+=Vd(a)}for(let r=n-t-1;r>=t;r--){let t=e.children[r];Ld(o,e.leaf?i(t):t),s+=Vd(o)}return s}_adjustParentBBoxes(e,t,n){for(let r=n;r>=0;r--)Ld(t[r],e)}_condense(e){for(let t=e.length-1,n;t>=0;t--)e[t].children.length===0?t>0?(n=e[t-1].children,n.splice(n.indexOf(e[t]),1)):this.clear():Fd(e[t],this.toBBox)}};function Pd(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Fd(e,t){Id(e,0,e.children.length,t,e)}function Id(e,t,n,r,i){i||=Kd(null),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let a=t;a<n;a++){let t=e.children[a];Ld(i,e.leaf?r(t):t)}return i}function Ld(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function Rd(e,t){return e.minX-t.minX}function zd(e,t){return e.minY-t.minY}function Bd(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Vd(e){return e.maxX-e.minX+(e.maxY-e.minY)}function Hd(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function Ud(e,t){let n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),a=Math.min(e.maxY,t.maxY);return Math.max(0,i-n)*Math.max(0,a-r)}function Wd(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Gd(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Kd(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function qd(e,t,n,r,i){let a=[t,n];for(;a.length;){if(n=a.pop(),t=a.pop(),n-t<=r)continue;let o=t+Math.ceil((n-t)/r/2)*r;Ad(e,o,t,n,i),a.push(t,o,o,n)}}var Jd=class e{static clone(e){return e.rangeType===void 0?{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}:{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn,rangeType:e.rangeType}}static equals(e,t){return e==null||t==null?!1:e.endRow===t.endRow&&e.endColumn===t.endColumn&&e.startRow===t.startRow&&e.startColumn===t.startColumn&&(e.rangeType===t.rangeType||e.rangeType===void 0&&t.rangeType===0||t.rangeType===void 0&&e.rangeType===0)}static simpleRangesIntersect(e,t){let{startRow:n,endRow:r,startColumn:i,endColumn:a}=e,{startRow:o,endRow:s,startColumn:c,endColumn:l}=t;return n<=s&&r>=o&&i<=l&&a>=c}static intersects(e,t){if(e.rangeType===1&&t.rangeType===2||e.rangeType===2&&t.rangeType===1)return!0;if(e.rangeType===1&&t.rangeType===1)return e.startRow<=t.endRow&&e.endRow>=t.startRow;if(e.rangeType===2&&t.rangeType===2)return e.startColumn<=t.endColumn&&e.endColumn>=t.startColumn;let n=Number.isNaN(e.startRow)?0:e.startRow,r=Number.isNaN(e.endRow)?1048575:e.endRow,i=Number.isNaN(e.startColumn)?0:e.startColumn,a=Number.isNaN(e.endColumn)?16383:e.endColumn,o=Number.isNaN(t.startRow)?0:t.startRow,s=Number.isNaN(t.endRow)?1048575:t.endRow,c=Number.isNaN(t.startColumn)?0:t.startColumn,l=Number.isNaN(t.endColumn)?16383:t.endColumn,u=Math.abs(i+a-c-l),d=Math.abs(i-a)+Math.abs(c-l),f=Math.abs(n+r-o-s),p=Math.abs(n-r)+Math.abs(o-s);return u<=d&&f<=p}static doAnyRangesIntersect(e,t){let n=new Nd;return n.load(e.map(e=>({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}))),t.some(e=>n.search({minX:e.startColumn,minY:e.startRow,maxX:e.endColumn,maxY:e.endRow}).length>0)}static contains(e,t){return e.startRow<=t.startRow&&e.endRow>=t.endRow&&e.startColumn<=t.startColumn&&e.endColumn>=t.endColumn}static realContain(t,n){return e.contains(t,n)&&(t.startRow<n.startRow||t.endRow>n.endRow||t.startColumn<n.startColumn||t.endColumn>n.endColumn)}static union(...e){return e.reduce((e,t)=>({startRow:Math.min(e.startRow,t.startRow),startColumn:Math.min(e.startColumn,t.startColumn),endRow:Math.max(e.endRow,t.endRow),endColumn:Math.max(e.endColumn,t.endColumn),rangeType:0}),e[0])}static realUnion(...t){let n=t.some(e=>e.rangeType===2),r=t.some(e=>e.rangeType===1),i=e.union(...t);return{startColumn:r?NaN:i.startColumn,endColumn:r?NaN:i.endColumn,startRow:n?NaN:i.startRow,endRow:n?NaN:i.endRow,rangeType:r?1:n?2:0}}static subtract(e,t){if(t.startRow>e.endRow||t.endRow<e.startRow||t.startColumn>e.endColumn||t.endColumn<e.startColumn)return[e];let n=[];t.startRow>=e.startRow&&n.push({startRow:e.startRow,startColumn:e.startColumn,endRow:t.startRow-1,endColumn:e.endColumn}),t.endRow<=e.endRow&&n.push({startRow:t.endRow+1,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn});let r=Math.max(e.startRow,t.startRow),i=Math.min(e.endRow,t.endRow);return t.startColumn>=e.startColumn&&n.push({startRow:r,startColumn:e.startColumn,endRow:i,endColumn:t.startColumn-1}),t.endColumn<=e.endColumn&&n.push({startRow:r,startColumn:t.endColumn+1,endRow:i,endColumn:e.endColumn}),n.filter(e=>e.startRow<=e.endRow&&e.startColumn<=e.endColumn)}static mergeRanges(e){return $d(e)}static splitIntoGrid(e){return Zd(e)}static subtractMulti(e,t){if(!t.length)return e;let n=e;return t.forEach(e=>{n=ef(n,e)}),n}static hasIntersectionBetweenTwoRect(e,t){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}static getIntersectionBetweenTwoRect(e,t){let n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),i=Math.max(e.top,t.top),a=Math.min(e.bottom,t.bottom);return r<=n||a<=i?null:{left:n,right:r,top:i,bottom:a,width:r-n,height:a-i}}static sort(e){return e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn)}};T(Jd,`getRelativeRange`,(e,t)=>({startRow:e.startRow-t.startRow,endRow:e.endRow-e.startRow,startColumn:e.startColumn-t.startColumn,endColumn:e.endColumn-e.startColumn})),T(Jd,`getPositionRange`,(e,t,n)=>({...n||{},startRow:n&&[1,3].includes(n.startAbsoluteRefType||0)?n.startRow:e.startRow+t.startRow,endRow:n&&[1,3].includes(n.endAbsoluteRefType||0)?n.endRow:e.endRow+e.startRow+t.startRow,startColumn:n&&[2,3].includes(n.startAbsoluteRefType||0)?n.startColumn:e.startColumn+t.startColumn,endColumn:n&&[2,3].includes(n.endAbsoluteRefType||0)?n.endColumn:e.endColumn+e.startColumn+t.startColumn})),T(Jd,`moveHorizontal`,(e,t=0,n=0)=>({...e,startColumn:e.startColumn+t,endColumn:e.endColumn+t+n})),T(Jd,`moveVertical`,(e,t=0,n=0)=>({...e,startRow:e.startRow+t,endRow:e.endRow+t+n})),T(Jd,`moveOffset`,(e,t,n)=>{let r={...e};switch(e.startAbsoluteRefType){case 1:r.startColumn+=t;break;case 2:r.startRow+=n;break;case 3:break;default:r.startRow+=n,r.startColumn+=t}switch(e.endAbsoluteRefType){case 1:r.endColumn+=t;break;case 2:r.endRow+=n;break;case 3:break;default:r.endRow+=n,r.endColumn+=t}return r});function Yd(e,t,n,r=!1){if(t===0&&n===0)return e;let i={...e},a=i.startAbsoluteRefType||0,o=i.endAbsoluteRefType||0,s=i.rangeType||0;if(!r&&a===3&&o===3)return i;let c=Xd(i.startRow,n,i.startColumn,t,s),l=Xd(i.endRow,n,i.endColumn,t,s);return r||a===0&&o===0?i={...i,startRow:c.row,startColumn:c.column,endRow:l.row,endColumn:l.column}:(a===0?i={...i,startRow:c.row,startColumn:c.column}:a===2?i={...i,startRow:c.row}:a===1&&(i={...i,startColumn:c.column}),o===0?i={...i,endRow:l.row,endColumn:l.column}:o===2?i={...i,endRow:l.row}:o===1&&(i={...i,endColumn:l.column}),i)}function Xd(e,t,n,r,i){return i===0?{row:e+t,column:n+r}:i===1?{row:e+t,column:n}:i===2?{row:e,column:n+r}:{row:e,column:n}}function Zd(e){let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set;for(let r of e)t.add(r.startColumn),t.add(r.endColumn+1),n.add(r.startRow),n.add(r.endRow+1);let r=Array.from(t).sort((e,t)=>e-t),i=Array.from(n).sort((e,t)=>e-t);e.sort((e,t)=>e.startRow-t.startRow||e.startColumn-t.startColumn);let a=[];for(let t=0;t<i.length-1;t++)for(let n=0;n<r.length-1;n++){let o=r[n],s=r[n+1]-1,c=i[t],l=i[t+1]-1;for(let t of e){if(t.startRow>l)break;if(t.startRow<=c&&t.endRow>=l&&t.startColumn<=o&&t.endColumn>=s){a.push({startColumn:o,endColumn:s,startRow:c,endRow:l});break}}}return a}function Qd(e){e.sort((e,t)=>e.startColumn-t.startColumn||e.startRow-t.startRow);let t={};for(let n of e)t[n.startColumn]||(t[n.startColumn]=[]),t[n.startColumn].push(n);let n=[];for(let e in t){let r=t[+e];r.sort((e,t)=>e.startRow-t.startRow);let i=r[0];for(let e=1;e<r.length;e++){let t=r[e];t.startRow<=i.endRow+1&&t.startColumn===i.startColumn&&t.endColumn===i.endColumn?i.endRow=Math.max(i.endRow,t.endRow):(n.push(i),i=t)}n.push(i)}return n}function $d(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let[e,r]of[[n.startRow,!0],[n.endRow+1,!1]]){let i=t.get(e)??[];i.push({range:n,add:r}),t.set(e,i)}let n=[...t.keys()].sort((e,t)=>e-t),r=/* @__PURE__ */ new Set,i=[];for(let e=0;e<n.length-1;e++){let a=n[e],o=n[e+1]-1;for(let{range:e,add:n}of t.get(a))n?r.add(e):r.delete(e);let s=[...r].sort((e,t)=>e.startColumn-t.startColumn||e.endColumn-t.endColumn),c;for(let e of s)c&&e.startColumn<=c.endColumn+1?c.endColumn=Math.max(c.endColumn,e.endColumn):(c={startRow:a,endRow:o,startColumn:e.startColumn,endColumn:e.endColumn},i.push(c))}return Qd(i)}function ef(e,t){let n=[];return e.forEach(e=>{n.push(...Jd.subtract(e,t))}),Jd.mergeRanges(n)}function tf(e,t){let n=nf(e.startRow,e.endRow,t.startRow,t.endRow),r=nf(e.startColumn,e.endColumn,t.startColumn,t.endColumn);if(!n||!r)return null;let[i,a]=n,[o,s]=r;return{startRow:i,endRow:a,startColumn:o,endColumn:s,rangeType:rf(e.rangeType,t.rangeType,i,a,o,s)}}function nf(e,t,n,r){let i=Number.isNaN(e)?-1/0:e,a=Number.isNaN(t)?1/0:t,o=Number.isNaN(n)?-1/0:n,s=Number.isNaN(r)?1/0:r,c=Math.max(i,o),l=Math.min(a,s);return c<=l?[c===-1/0?NaN:c,l===1/0?NaN:l]:null}function rf(e,t,n,r,i,a){let o=e===void 0?af(n,r,i,a):e,s=t===void 0?af(n,r,i,a):t;return o===3||s===3?o===s?o:o===3?s:o:o===s?o:0}function af(e,t,n,r){let i=!Number.isNaN(e)&&!Number.isNaN(t),a=!Number.isNaN(n)&&!Number.isNaN(r);return i&&a?0:i?1:a?2:3}var of=class{constructor(e,t){T(this,`_values`,[]),T(this,`_keys`,[]),T(this,`_keyMaps`,/* @__PURE__ */ new Map),this._values=e,this._keys=t,e.forEach(e=>{this._initKeyMap(e)})}_initKeyMap(e){this._keys.forEach(t=>{let n=e[t],r=this._keyMaps.get(t)||/* @__PURE__ */ new Map;r.set(n,e),this._keyMaps.set(t,r)})}getValue(e,t){let n=t||this._keys;for(let t=0;t<n.length;t++){let r=this._keyMaps.get(n[t]);if(r!=null&&r.has(e))return r.get(e)}return null}hasValue(e){for(let t=0;t<this._keys.length;t++){let n=this._keyMaps.get(this._keys[t]);if(n!=null&&n.has(e))return!0}return!1}addValue(e){this._values.push(e),this._initKeyMap(e)}setValue(e,t,n){let r=this.getValue(e);r&&Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=n)}deleteValue(e,t){let n=this.getValue(e,t);if(n){this._keys.forEach(e=>{let t=this._keyMaps.get(e),r=n[e];t==null||t.delete(r)});let e=this._values.findIndex(e=>e===n);this._values.splice(e,1)}}getValues(){return this._values}getKeyMap(e){var t;return[...((t=this._keyMaps.get(e))==null?void 0:t.keys())||[]]}clear(){this._values=[],this._keys=[],this._keyMaps.clear()}};function sf(e,t,n,r){return{forEach(i){for(let a=e;a<=t;a++)for(let e=n;e<=r;e++)i(a,e)}}}function cf(e){if(e==null||e.length===0)return NaN;let t=e.toLowerCase().split(``),n=t.length,r=e=>e.charCodeAt(0)-96,i=0,a=0;for(let e=0;e<n;e++)a=r(t[e]),i+=a*26**(n-e-1);return i===0?NaN:i-1}function lf(e){let t=``;for(;e>=0;)t=String.fromCharCode(e%26+65)+t,e=Math.floor(e/26)-1;return t}function uf(e,t){let n=``;for(;t>0;)n+=e,t--;return n}function df(e,t=!1){let n=97;return t&&(n=65),uf(String.fromCharCode(e%26+n),Math.floor(e/26)+1)}function ff(e,t){return e.zIndex>t.zIndex?1:e.zIndex===t.zIndex?0:-1}function pf(e,t){return e.zIndex>t.zIndex?-1:e.zIndex===t.zIndex?0:1}function mf(e=`index`,t=1){return(n,r)=>n[e]>r[e]?t:n[e]===r[e]?0:-t}let hf=/* @__PURE__ */ function(e){return e.Text=`text`,e.SingleSelect=`singleSelect`,e.MultiSelect=`multiSelect`,e.Person=`person`,e.Group=`group`,e.Date=`date`,e.Attachment=`attachment`,e.Number=`number`,e.Checkbox=`checkbox`,e.Link=`link`,e.Formula=`formula`,e.Numbering=`numbering`,e.Phone=`phone`,e.Email=`email`,e.Progress=`progress`,e.Currency=`currency`,e.Rating=`rating`,e.RecordLink=`recordLink`,e.RecordId=`recordId`,e.CreatedBy=`createdBy`,e.UpdatedBy=`updatedBy`,e.CreatedAt=`createdAt`,e.UpdatedAt=`updatedAt`,e}({}),gf=/* @__PURE__ */ function(e){return e.Parent=`parent`,e}({}),_f=/* @__PURE__ */ function(e){return e.Grid=`grid`,e.Kanban=`kanban`,e.Calendar=`calendar`,e.Gantt=`gantt`,e.Gallery=`gallery`,e.Pivot=`pivot`,e}({}),vf={CELL:`cell`,ROW:`row`,COLUMN:`column`},yf={IS:`is`,IS_NOT:`isNot`,CONTAINS:`contains`,NOT_CONTAINS:`notContains`,IS_EMPTY:`isEmpty`,IS_NOT_EMPTY:`isNotEmpty`,GREATER_THAN:`greaterThan`,LESS_THAN:`lessThan`,BEFORE:`before`,AFTER:`after`},bf={EXACT:`exact`,TODAY:`today`,TOMORROW:`tomorrow`,YESTERDAY:`yesterday`,THIS_WEEK:`thisWeek`,LAST_WEEK:`lastWeek`,THIS_MONTH:`thisMonth`,LAST_MONTH:`lastMonth`,PAST_7_DAYS:`past7`,NEXT_7_DAYS:`next7`,PAST_30_DAYS:`past30`,NEXT_30_DAYS:`next30`},xf=/* @__PURE__ */ function(e){return e.IS=`is`,e.IS_NOT=`isNot`,e.CONTAINS=`contains`,e.NOT_CONTAINS=`notContains`,e.IS_EMPTY=`isEmpty`,e.IS_NOT_EMPTY=`isNotEmpty`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.BEFORE=`before`,e.AFTER=`after`,e}({}),Sf=/* @__PURE__ */ function(e){return e.AND=`and`,e.OR=`or`,e}({}),Cf=/* @__PURE__ */ function(e){return e.ASC=`asc`,e.DESC=`desc`,e}({}),wf=/* @__PURE__ */ function(e){return e.MissingParent=`missingParent`,e.SelfParent=`selfParent`,e.Cycle=`cycle`,e.MaxDepth=`maxDepth`,e}({}),Tf=`__record_id`,Ef=`record-id`,Df=/^[A-Za-z0-9_-]+$/;function Of(){return{id:Tf,name:Ef,type:`recordId`,config:{},system:!0,readonly:!0}}function kf(e){return Df.test(e)}function Af(e){return e.trim().toLowerCase()===Ef}function jf(e){let t=e.fields[Tf],n=Object.values(e.fields).filter(e=>e.type===`recordId`);if(!t||n.length!==1||t.type!==`recordId`||t.name!==`record-id`||t.system!==!0||t.readonly!==!0||e.fieldOrder[0]!==`__record_id`||e.primaryFieldId===`__record_id`||!e.fields[e.primaryFieldId])throw Error(`[BaseDataModel]: table "${e.id}" has an invalid record-id system field.`);let r=Object.values(e.fields).find(e=>e.id!==`__record_id`&&Af(e.name));if(r)throw Error(`[BaseDataModel]: field name "${r.name}" is reserved for the record-id system field.`);for(let[t,n]of Object.entries(e.records))if(n.id!==t||!kf(n.id)||n.values.__record_id!==n.id)throw Error(`[BaseDataModel]: record "${t}" has an invalid record-id projection.`)}function Mf(e){let t=e.now??Date.now(),n=e.primaryFieldId??J(6),r=e.gridViewId??J(6),i=e.recordCount??0,a=Of(),o={id:n,name:e.primaryFieldName??`Name`,type:`text`,config:{placeholder:`bases.fieldConfig.textPlaceholder`}},s={},c=[],l={},u={},d={};for(let n=0;n<i;n++){let r=`${e.id}-record-${n+1}`;s[r]={id:r,values:{[Tf]:r},orderKey:String(n+1).padStart(4,`0`),createdAt:t,updatedAt:t},c.push(r),l[r]=n,u[n]=r,d[n]={0:{v:r,t:1}}}let f={id:r,tableId:e.id,name:`Grid`,type:`grid`,fieldOrder:[Tf,n],fieldSettings:{[Tf]:{hidden:!0}},config:{frozenFieldCount:1}};return{id:e.id,name:e.name,primaryFieldId:n,fieldOrder:[Tf,n],fields:{[Tf]:a,[n]:o},records:s,recordOrder:c,rowIndex:l,rowId:u,colIndex:{[Tf]:0,[n]:1},colId:{0:Tf,1:n},cellData:d,resources:{attachmentSets:{},attachments:{}},views:{[r]:f},viewOrder:[r]}}function Nf(e=J(),t=``,n=`zhCN`){let r=Date.now(),i=`table-1`;return{id:e,name:t,locale:n,appVersion:ze,schemaVersion:2,tableOrder:[i],tables:{[i]:Mf({id:i,name:`Table 1`,now:r,recordCount:0})},createdAt:r,updatedAt:r}}var Pf=class extends M{constructor(e={}){super(),T(this,`type`,n.UniverType.UNIVER_BASE),T(this,`_name$`,void 0),T(this,`name$`,void 0),T(this,`_snapshot`,void 0);let r=Nf();this._snapshot=Ff(z.commonExtend(r,e)),this._snapshot.id||(this._snapshot.id=`base-${Math.random().toString(36).slice(2,10)}`),this._name$=new t.BehaviorSubject(this._snapshot.name),this.name$=this._name$.asObservable()}getUnitId(){return this._snapshot.id}setName(e){this._snapshot.name=e,this._snapshot.updatedAt=Date.now(),this._name$.next(e)}getSnapshot(){return this._snapshot}checkTableName(e){return Object.values(this._snapshot.tables).some(t=>t.name.toLowerCase()===e.toLowerCase())}uniqueTableName(e){let t=e,n=1;for(;this.checkTableName(t);)t=`${e}${n}`,n++;return t}setSnapshot(e){this._snapshot=If(e)?e:Ff(e),this._name$.next(e.name)}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}dispose(){super.dispose(),this._name$.complete()}};function Ff(e){return delete e.compress,delete e.kind,Object.values(e.tables??{}).forEach(e=>{jf(e),Rf(e),qf(e)}),e}function If(e){return Object.values(e.tables??{}).every(e=>Lf(e))}function Lf(e){let t=e.records??{},n=e.fields??{};if(jf(e),!Array.isArray(e.recordOrder)||!e.rowIndex||!e.rowId||!e.colIndex||!e.colId||!e.cellData||!e.resources||!e.resources.attachmentSets||!e.resources.attachments||Object.keys(t).length!==e.recordOrder.length)return!1;for(let n=0;n<e.recordOrder.length;n++){var r;let i=e.recordOrder[n];if(!t[i]||e.rowIndex[i]!==n||e.rowId[n]!==i||((r=e.cellData[n])==null||(r=r[0])==null?void 0:r.v)!==i)return!1}for(let t=0;t<e.fieldOrder.length;t++){let r=e.fieldOrder[t];if(n[r]&&(e.colIndex[r]!==t||e.colId[t]!==r))return!1}return!0}function Rf(e){zf(e);let t=e.records??{},n=e.fields??{},r=Bf(e,t),i=Vf(e,n);e.recordOrder=r,Hf(e),Uf(e,n),Wf(e,t,r),Gf(e,n,i),Kf(e,t,n)}function zf(e){let t=e.cd;t&&!e.cellData&&(e.cellData=Object.create(null),t.forEach(([t,n,r])=>{e.cellData[t]=e.cellData[t]??{};let{c:i,...a}=r;e.cellData[t][n]=a}),delete e.cd)}function Bf(e,t){var n;let r=((n=e.recordOrder)==null?void 0:n.filter(e=>t[e]))??[],i=new Set(r),a=Object.values(t).filter(e=>!i.has(e.id));return a.length?[...r,...a.sort((e,t)=>e.orderKey.localeCompare(t.orderKey)).map(e=>e.id)]:r}function Vf(e,t){return e.fieldOrder.filter(e=>t[e])}function Hf(e){e.rowIndex={...e.rowIndex},e.rowId={...e.rowId},e.colIndex={...e.colIndex},e.colId={...e.colId},e.cellData={...e.cellData},e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments}}function Uf(e,t){Object.entries(e.cellData??{}).forEach(([n,r])=>{let i=Number(n);e.cellData[i]={...r},Object.entries(e.cellData[i]??{}).forEach(([n,r])=>{var a;let o=Number(n),s=(a=e.colId)==null?void 0:a[o];e.cellData[i][o]=Yf(r,s?t[s]:void 0)})})}function Wf(e,t,n){n.forEach((t,n)=>{e.rowIndex[t]??(e.rowIndex[t]=n)}),Object.entries(e.rowIndex??{}).forEach(([n,r])=>{t[n]&&(e.rowId[r]=n)})}function Gf(e,t,n){n.forEach((t,n)=>{e.colIndex[t]??(e.colIndex[t]=n)}),Object.entries(e.colIndex??{}).forEach(([n,r])=>{t[n]&&(e.colId[r]=n)})}function Kf(e,t,n){let r=e.rowIndex??{},i=e.colIndex??{},a=e.cellData??{};e.rowIndex=r,e.colIndex=i,e.cellData=a,Object.values(t).forEach(t=>{let o=r[t.id];o!=null&&(a[o]={...a[o]},a[o][0]={v:t.id,t:1},Object.entries(t.values??{}).forEach(([r,s])=>{let c=n[r];(c==null?void 0:c.type)===`attachment`&&Zf(e,t.id,r,s);let l=i[r];if(l==null)return;let u=a[o][l];u==null?a[o][l]=Jf(s,c):(a[o][l]=Yf(u,c),$f(u,c,s)&&(a[o][l]=Jf(s,c)))}))})}function qf(e){for(let a of Object.values(e.records)){var t,n,r,i;let o=(t=e.rowIndex)==null?void 0:t[a.id];if(o==null||((n=e.colIndex)==null?void 0:n.__record_id)!==0||((r=e.colId)==null?void 0:r[0])!==`__record_id`||((i=e.cellData)==null||(i=i[o])==null||(i=i[0])==null?void 0:i.v)!==a.id)throw Error(`[BaseDataModel]: record "${a.id}" is missing its record-id cell projection.`)}}function Jf(e,t){if(Xf(e))return(t==null?void 0:t.type)===`attachment`?{...e,v:``,t:1}:Yf(e,t);if((t==null?void 0:t.type)===`attachment`)return{v:``,t:1};if(ep(t))return{v:tp(e).join(`, `),t:1};if((t==null?void 0:t.type)===`link`&&e&&typeof e==`object`&&!Array.isArray(e)){let t=e;return{v:String(t.text??t.url??``),t:1}}return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`?{v:e,t:rp(e)}:{v:null,t:null}}function Yf(e,t){let n=ip(e.t,e.v);if(n===void 0){let{t,...n}=e;return n}return{...e,t:n}}function Xf(e){return!!e&&typeof e==`object`&&(Object.prototype.hasOwnProperty.call(e,`v`)||Object.prototype.hasOwnProperty.call(e,`t`)||Object.prototype.hasOwnProperty.call(e,`p`)||Object.prototype.hasOwnProperty.call(e,`f`)||Object.prototype.hasOwnProperty.call(e,`si`))}function Zf(e,t,n,r){let i=Qf(r);e.resources={...e.resources},e.resources.attachmentSets={...e.resources.attachmentSets},e.resources.attachments={...e.resources.attachments};let a=`${n}${t}`;e.resources.attachmentSets[a]=i.map((t,n)=>{let r=String(t.id??`${a}${n}`),i={...t,id:r};return e.resources.attachments[r]=i,r})}function Qf(e){if(e==null||e===``||Xf(e)&&!(`id`in e)&&!(`name`in e))return[];let t=Array.isArray(e)?e:[e],n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r&&typeof r==`object`){let e={...r};Object.keys(e).length>0&&n.push(e)}else n.push({id:`attachment-${e}`,name:String(r)})}return n}function $f(e,t,n){return(t==null?void 0:t.type)===`recordId`?e.v!==n:(t==null?void 0:t.type)===`attachment`?e.v!==``:ep(t)?Array.isArray(n)&&(e.v==null||e.v===``):!1}function ep(e){return(e==null?void 0:e.type)===`multiSelect`||(e==null?void 0:e.type)===`person`||(e==null?void 0:e.type)===`group`}function tp(e){if(e==null||e===``)return[];let t=[];if(Array.isArray(e)){for(let n=0;n<e.length;n++){let r=np(e[n]);r&&t.push(r)}return t}let n=String(e).split(`,`);for(let e=0;e<n.length;e++){let r=n[e].trim();r&&t.push(r)}return t}function np(e){if(e==null)return``;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`){let t=e;return String(t.id??t.name??t.text??``)}return String(e)}function rp(e){return e==null?null:typeof e==`number`?2:typeof e==`boolean`?3:1}function ip(e,t){return e===1||e===2||e===3||e===4||e==null?e:rp(t??null)}function ap(e){let t=e.trim().replace(/[^A-Za-z0-9_.]+/g,`_`),n=/[A-Za-z0-9]/.test(t)?t:`Table`,r=/^[A-Za-z_]/.test(n)?n:`_${n}`;return(/^[RC]$/i.test(r)||/^[A-Za-z]{1,3}[1-9]\d*$/.test(r)||/^R(?:\d+)?C(?:\d+)?$/i.test(r)?`_${r}`:r).slice(0,255)}function op(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let r=hp(e.formulaName);r&&!n.has(r.toLowerCase())&&(n.add(r.toLowerCase()),t.set(e.id,r))}for(let e of i){if(t.has(e.id))continue;let i=cp(e.name,n,e.formulaName,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function sp(e,t,n){return cp(e,new Set(Array.from(t,e=>e.toLowerCase())),n)}function cp(e,t,n,r=/* @__PURE__ */ new Map){let i=hp(n);if(i&&!t.has(i.toLowerCase()))return i;let a=ap(e),o=a.toLowerCase();if(!t.has(o))return a;let s=r.get(o)??2;for(;;){let e=`_${s++}`,n=`${a.slice(0,255-e.length)}${e}`;if(!t.has(n.toLowerCase()))return r.set(o,s),n}}function lp(e,t){return op(t).get(e.id)??ap(e.name)}function up(e,t){return dp(t)(e)}function dp(e,t=op(e)){let n=vp(pp(e,t));return e=>bp(e,n)}function fp(e){let t=op(e),n=dp(e,t);for(let n of Object.values(e.tables))n.formulaName=t.get(n.id)??ap(n.name);for(let t of Object.values(e.tables)){for(let e of Object.values(t.fields)){var r;e.type===`formula`&&typeof((r=e.config)==null?void 0:r.formula)==`string`&&(e.config.formula=n(e.config.formula))}for(let e of Object.values(t.cellData??{}))for(let t of Object.values(e??{}))t&&typeof t.f==`string`&&(t.f=n(t.f))}}function pp(e,t=op(e)){let n=mp(e),r=new Map(Array.from(t,([e,t])=>[t.toLowerCase(),e])),i=/* @__PURE__ */ new Map;for(let t of Object.values(e.tables)){let e=t.name.toLowerCase();i.set(e,(i.get(e)??0)+1)}return Object.values(e.tables).flatMap(e=>{let a=t.get(e.id)??ap(e.name),o=[e.id,yp(e.id),n.get(e.id),e.formulaName];return i.get(e.name.toLowerCase())===1&&o.push(e.name),o.filter(e=>!!e).flatMap(e=>[e,gp(e)]).filter(e=>!!e).filter(e=>e.toLowerCase()!==a.toLowerCase()).filter(t=>{let n=r.get(_p(t).toLowerCase());return n==null||n===e.id}).map(e=>({alias:e,formulaName:a}))}).sort((e,t)=>t.alias.length-e.alias.length)}function mp(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Map,i=Object.values(e.tables).sort((e,t)=>e.id.localeCompare(t.id));for(let e of i){let i=cp(e.name,n,void 0,r);n.add(i.toLowerCase()),t.set(e.id,i)}return t}function hp(e){let t=e==null?void 0:e.trim();return t&&ap(t)===t?t:void 0}function gp(e){return/[^A-Za-z0-9_.]/.test(e)?`'${e.replaceAll(`'`,`''`)}'`:void 0}function _p(e){return e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,-1).replaceAll(`''`,`'`):e}function vp(e){let t=/* @__PURE__ */ new Map;for(let{alias:n,formulaName:r}of e){let e=n.toLowerCase();t.has(e)||t.set(e,r)}let n=Array.from(t.keys()).sort((e,t)=>t.length-e.length);return{formulaNameByAlias:t,pattern:n.length?RegExp(`(${n.map(xp).join(`|`)})(\\s*)\\[`,`gi`):void 0}}function yp(e){return`_T_${Array.from(e,e=>{var t;return/[A-Za-z0-9]/.test(e)?e:`_x${((t=e.codePointAt(0))==null?void 0:t.toString(16))??`0`}_`}).join(``)}`}function bp(e,t){if(!t.pattern)return e;let n=0,r=!1;return t.pattern.lastIndex=0,e.replace(t.pattern,(i,a,o,s)=>{r=Sp(e,n,s,r),n=s;let c=e[s-1];if(c!=null&&/[A-Za-z0-9_.]/.test(c)||c===`!`||r)return i;let l=t.formulaNameByAlias.get(a.toLowerCase());return l?`${l}${o}[`:i})}function xp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Sp(e,t,n,r){let i=r;for(let r=t;r<n;r++)e[r]===`"`&&(i&&e[r+1]===`"`?r++:i=!i);return i}var Cp=/* @__PURE__ */ f(((e,t)=>{var n=function(e){if(e||={},this.Promise=e.Promise||Promise,this.queues=Object.create(null),this.domainReentrant=e.domainReentrant||!1,this.domainReentrant){if(typeof process>`u`||process.domain===void 0)throw Error("Domain-reentrant locks require `process.domain` to exist. Please flip `opts.domainReentrant = false`, use a NodeJS version that still implements Domain, or install a browser polyfill.");this.domains=Object.create(null)}this.timeout=e.timeout||n.DEFAULT_TIMEOUT,this.maxOccupationTime=e.maxOccupationTime||n.DEFAULT_MAX_OCCUPATION_TIME,this.maxExecutionTime=e.maxExecutionTime||n.DEFAULT_MAX_EXECUTION_TIME,this.maxPending=e.maxPending===1/0||Number.isInteger(e.maxPending)&&e.maxPending>=0?e.maxPending:n.DEFAULT_MAX_PENDING};n.DEFAULT_TIMEOUT=0,n.DEFAULT_MAX_OCCUPATION_TIME=0,n.DEFAULT_MAX_EXECUTION_TIME=0,n.DEFAULT_MAX_PENDING=1e3,n.prototype.acquire=function(e,t,n,r){if(Array.isArray(e))return this._acquireBatch(e,t,n,r);if(typeof t!=`function`)throw Error(`You must pass a function to execute`);var i=null,a=null,o=null;typeof n!=`function`&&(r=n,n=null,o=new this.Promise(function(e,t){i=e,a=t})),r||={};var s=!1,c=null,l=null,u=null,d=this,f=function(t,r,c){l&&=(clearTimeout(l),null),u&&=(clearTimeout(u),null),t&&(d.queues[e]&&d.queues[e].length===0&&delete d.queues[e],d.domainReentrant&&delete d.domains[e]),s||=(o?r?a(r):i(c):typeof n==`function`&&n(r,c),!0),t&&d.queues[e]&&d.queues[e].length>0&&d.queues[e].shift()()},p=function(n){if(s)return f(n);c&&=(clearTimeout(c),null),d.domainReentrant&&n&&(d.domains[e]=process.domain);var i=r.maxExecutionTime||d.maxExecutionTime;if(i&&(u=setTimeout(function(){d.queues[e]&&f(n,/* @__PURE__ */ Error(`Maximum execution time is exceeded `+e))},i)),t.length===1){var a=!1;try{t(function(e,t){a||(a=!0,f(n,e,t))})}catch(e){a||(a=!0,f(n,e))}}else d._promiseTry(function(){return t()}).then(function(e){f(n,void 0,e)},function(e){f(n,e)})};d.domainReentrant&&process.domain&&(p=process.domain.bind(p));var m=r.maxPending||d.maxPending;if(!d.queues[e])d.queues[e]=[],p(!0);else if(d.domainReentrant&&process.domain&&process.domain===d.domains[e])p(!1);else if(d.queues[e].length>=m)f(!1,/* @__PURE__ */ Error(`Too many pending tasks in queue `+e));else{var h=function(){p(!0)};r.skipQueue?d.queues[e].unshift(h):d.queues[e].push(h);var g=r.timeout||d.timeout;g&&(c=setTimeout(function(){c=null,f(!1,/* @__PURE__ */ Error(`async-lock timed out in queue `+e))},g))}var _=r.maxOccupationTime||d.maxOccupationTime;if(_&&(l=setTimeout(function(){d.queues[e]&&f(!1,/* @__PURE__ */ Error(`Maximum occupation time is exceeded in queue `+e))},_)),o)return o},n.prototype._acquireBatch=function(e,t,n,r){typeof n!=`function`&&(r=n,n=null);var i=this,a=function(e,t){return function(n){i.acquire(e,t,n,r)}},o=e.reduceRight(function(e,t){return a(t,e)},t);if(typeof n==`function`)o(n);else return new this.Promise(function(e,t){o.length===1?o(function(n,r){n?t(n):e(r)}):e(o())})},n.prototype.isBusy=function(e){return e?!!this.queues[e]:Object.keys(this.queues).length>0},n.prototype._promiseTry=function(e){try{return this.Promise.resolve(e())}catch(e){return this.Promise.reject(e)}},t.exports=n})),wp=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t)=>{t.exports=Cp()})))());let Tp=/* @__PURE__ */ new Set([`true`,`false`]);function Ep(e){return Tp.has(e.toLowerCase())}let Dp=`__INTERNAL_EDITOR__`,Op=`${Dp}DOCS_NORMAL`,kp=`${Dp}DOCS_FORMULA_BAR`,Ap=`${Dp}COMMENT_EDITOR`,jp=Symbol(`AUTO_HEIGHT_FOR_MERGED_CELLS`),Mp=Symbol(`SHEET_TEXT_LINE_GAP`);function Np(e){return`${Dp}${e}`}function Pp(e){return e.startsWith(Dp)}function Fp(e){return e.startsWith(Ap)}let Ip=/* @__PURE__ */ function(e){return e[e.forward=0]=`forward`,e[e.backward=1]=`backward`,e[e.front=2]=`front`,e[e.back=3]=`back`,e}({}),Lp=/* @__PURE__ */ function(e){return e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e[e.DRAWING_IMAGE=0]=`DRAWING_IMAGE`,e[e.DRAWING_SHAPE=1]=`DRAWING_SHAPE`,e[e.DRAWING_CHART=2]=`DRAWING_CHART`,e[e.DRAWING_TABLE=3]=`DRAWING_TABLE`,e[e.DRAWING_SMART_ART=4]=`DRAWING_SMART_ART`,e[e.DRAWING_VIDEO=5]=`DRAWING_VIDEO`,e[e.DRAWING_GROUP=6]=`DRAWING_GROUP`,e[e.DRAWING_UNIT=7]=`DRAWING_UNIT`,e[e.DRAWING_DOM=8]=`DRAWING_DOM`,e[e.DRAWING_BLOCK=9]=`DRAWING_BLOCK`,e[e.DRAWING_SLICER=10]=`DRAWING_SLICER`,e[e.DRAWING_TIMELINE=11]=`DRAWING_TIMELINE`,e[e.DRAWING_OLE=12]=`DRAWING_OLE`,e}({});function Rp(e,t){let n=Math.max(0,t-1);return Math.max(0,Math.min(Math.floor(e),n))||0}function zp(e,t,n){let r=Rp(e,t);return n===2?Rp(t-1,t):n===0?Rp(r+1,t):n===1?Rp(r-1,t):0}function Bp(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;let i=Object.prototype.hasOwnProperty.bind(t);for(let r=0;r<n.length;r++){let a=n[r];if(!i(a)||e[a]!==t[a])return!1}return!0}function Vp(){}function Hp(e,t=16){let n=0,r=null;return function(...i){let a=Date.now();a-n<t?(r&&clearTimeout(r),r=setTimeout(()=>{n=a,e.apply(this,i)},t)):(r&&=(clearTimeout(r),null),n=a,e.apply(this,i))}}let Up=/* @__PURE__ */ function(e){return e[e.Style=1]=`Style`,e[e.Value=2]=`Value`,e}({});function Wp(e){return`sheet_interceptor_${e}`}let Gp=e=>function(t,n){let r=-1,i=t,a=!1,o=e=>(a=!0,e);for(let t=0;t<e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);r=t;let s=e[t];if(a=!1,i=s.handler(i,n,o),!a)break}return i};var Kp=class extends k{constructor(e){super(),T(this,`_interceptorsByName`,/* @__PURE__ */ new Map),T(this,`_interceptorPoints`,void 0),this._interceptorPoints=e}fetchThroughInterceptors(e,t){this.ensureNotDisposed();let n=e,r=this._interceptorsByName.get(n);t&&(r=r.filter(t));let i=Gp(r||[]);return(e,t)=>(this.ensureNotDisposed(),i(e,t))}intercept(e,t){this.ensureNotDisposed();let n=e;this._interceptorsByName.has(n)||this._interceptorsByName.set(n,[]);let r=this._interceptorsByName.get(n);r.push(t),this._interceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0)));let i=t;return()=>{let e=i;if(i=void 0,!e||this._disposed)return!1;let t=this._interceptorsByName.get(n);return t?Be(t,e):!1}}getInterceptPoints(){return this._interceptorPoints}dispose(){this._interceptorsByName.clear(),super.dispose()}};function qp(e){return`sheet_async_interceptor_${e}`}let Jp=e=>async function(t,n){let r=-1,i=t;for(let t=0;t<=e.length;t++){if(t<=r)throw Error(`[SheetInterceptorService]: next() called multiple times!`);if(r=t,t===e.length)return i;let a=e[t],o=!1;if(i=await a.handler(i,n,async e=>(o=!0,e)),!o)break}return i};var Yp=class extends k{constructor(e){super(),T(this,`_asyncInterceptorsByName`,/* @__PURE__ */ new Map),T(this,`_asyncInterceptorPoints`,void 0),this._asyncInterceptorPoints=e}fetchThroughAsyncInterceptors(e,t){this.ensureNotDisposed();let n=e,r=this._asyncInterceptorsByName.get(n);t&&(r=r.filter(t));let i=Jp(r||[]);return async(e,t)=>(this.ensureNotDisposed(),i(e,t))}async interceptAsync(e,t){this.ensureNotDisposed();let n=e;this._asyncInterceptorsByName.has(n)||this._asyncInterceptorsByName.set(n,[]);let r=this._asyncInterceptorsByName.get(n);r.push(t),this._asyncInterceptorsByName.set(n,r.sort((e,t)=>(t.priority??0)-(e.priority??0)));let i=t;return()=>{let e=i;if(i=void 0,!e||this._disposed)return!1;let t=this._asyncInterceptorsByName.get(n);return t?Be(t,e):!1}}getInterceptPoints(){return this._asyncInterceptorPoints}dispose(){this._asyncInterceptorsByName.clear(),super.dispose()}};function Xp(e){return e.map(e=>e/255)}function Zp(e){return e.map(e=>Math.round(e*255))}function Qp([e,t,n]){let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2,o=0,s=0;if(r!==i){let c=r-i;switch(s=a>.5?c/(2-r-i):c/(r+i),r){case e:o=(t-n)/c+(t<n?6:0);break;case t:o=(n-e)/c+2;break;case n:o=(e-t)/c+4}o/=6}return[o,s,a]}function $p(e,t,n){let r=[e,t,n].map(e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4);return .2126*r[0]+.7152*r[1]+.0722*r[2]}function em(e,t){return(Math.max(e,t)+.05)/(Math.min(e,t)+.05)}function tm(e,t,n){let r,i,a;if(t===0)r=i=a=n;else{let o=(e,t,n)=>{let r=n;return r<0&&(r+=1),r>1&&--r,r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e},s=n<.5?n*(1+t):n+t-n*t,c=2*n-s;r=o(c,s,e+1/3),i=o(c,s,e),a=o(c,s,e-1/3)}return[r,i,a]}let nm={r:1,g:1,b:1},rm={r:0,g:0,b:0},im=$p(nm.r,nm.g,nm.b),am=$p(rm.r,rm.g,rm.b);function om(e){let t=$p(e[0],e[1],e[2]),n=em(im,t),r=Qp(e),i=1-r[2],a,o,s;do a=tm(r[0],r[1],i),o=$p(a[0],a[1],a[2]),s=em(o,am),i+=.01;while(i<=1&&i>=0&&Math.abs(s-n)<.01);return a}function sm(e){return Zp(om(Xp(e)))}let cm=[[.333,-.667,-.667,0,1],[-.667,.333,-.667,0,1],[-.667,-.667,.333,0,1],[0,0,0,1,0]];function lm(e){let t=e[0],n=e[1],r=e[2],i=[cm[0][0]*t+cm[0][1]*n+cm[0][2]*r+cm[0][4],cm[1][0]*t+cm[1][1]*n+cm[1][2]*r+cm[1][4],cm[2][0]*t+cm[2][1]*n+cm[2][2]*r+cm[2][4]];return i=i.map(e=>e>1?1:e<0?0:e),i}function um(e){return Zp(lm(Xp(e)))}var dm=class{constructor(){T(this,`cursor`,0)}reset(){return this.cursor=0,this}moveCursor(e){this.cursor+=e}moveCursorTo(e){this.cursor=e}};function fm(e,t){for(let n in t)t.hasOwnProperty(n)&&(e[n]=t[n])}function pm(e){return/^-?\d+(\.\d+)?$/.test(e)}function mm(e){return pm(e)?Number(e)<=2**53-1:!1}function hm(e){return Number(e)>2**53-1||e.length>=18}var gm=class e{constructor(){T(this,`_data`,[])}static create(){return new e}add(e){this._data.indexOf(e)>-1||this._data.push(e)}delete(e){let t=this._data.indexOf(e);this._data.splice(t,1)}getData(){return this._data}},_m=class e{constructor(){T(this,`_data`,/* @__PURE__ */ new Map)}static create(){return new e}add(e,t){this._data.has(e)||this._data.set(e,t)}delete(e){this._data.delete(e)}getData(){return this._data}};function vm(e){let t=new MessageChannel,n=!1,r=()=>{t.port1.onmessage=null,t.port1.close(),t.port2.close()},i=()=>{n||(n=!0,r(),e())};return t.port1.onmessage=i,t.port2.postMessage(null),()=>{n||(n=!0,r())}}function ym(e,t){return t.forEach(t=>e.add(t)),e}let bm=`section_`;function xm(e){let t=`${bm}${J(12)}`;for(;e.has(t);)t=`${bm}${J(12)}`;return e.add(t),t}function Sm(e,t,n=!0){let r=z.deepClone(e);return n&&Cm(r.sectionId)&&!t.has(r.sectionId)?(t.add(r.sectionId),r):(r.sectionId=xm(t),r)}function Cm(e){return typeof e==`string`&&e.length>0}let wm=/* @__PURE__ */ function(e){return e.PARAGRAPH=`PARAGRAPH`,e.SECTION_BREAK=`SECTION_BREAK`,e.TABLE=`TABLE`,e.TABLE_ROW=`TABLE_ROW`,e.TABLE_CELL=`TABLE_CELL`,e.COLUMN_GROUP=`COLUMN_GROUP`,e.COLUMN=`COLUMN`,e.BLOCK=`BLOCK`,e.CUSTOM_BLOCK=`CUSTOM_BLOCK`,e}({}),Tm=/* @__PURE__ */ function(e){return e.PARAGRAPH=`\r`,e.SECTION_BREAK=`
|
|
2
|
+
`,e.TABLE_START=``,e.TABLE_ROW_START=`\x1B`,e.TABLE_CELL_START=``,e.TABLE_CELL_END=``,e.TABLE_ROW_END=``,e.TABLE_END=``,e.COLUMN_GROUP_START=``,e.COLUMN_START=``,e.COLUMN_END=``,e.COLUMN_GROUP_END=``,e.BLOCK_START=``,e.BLOCK_END=``,e.CUSTOM_RANGE_START=``,e.CUSTOM_RANGE_END=``,e.COLUMN_BREAK=`\v`,e.PAGE_BREAK=`\f`,e.DOCS_END=`\0`,e.TAB=` `,e.CUSTOM_BLOCK=`\b`,e.LETTER=``,e.SPACE=` `,e}({}),Em=/* @__PURE__ */ new Set([`\r`,`
|
|
3
|
+
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``,`\v`,`\f`,`\0`,`\b`]),Dm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Bopomofo}\u3000-\u303F\uFF00-\uFFEF]/u,Om=/\p{Script=Hangul}/u,km=2e4;function Am(){return{words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0}}function jm(e){if(e!=null&&e.aborted)throw Error(`Document statistics calculation aborted`)}function Mm(e){return jm(e),new Promise(e=>{setTimeout(e,0)})}function Nm(e,t){if(!(t!=null&&t.length))return[e];let n=t.filter(e=>!e.collapsed).map(t=>({startOffset:Math.max(0,Math.min(t.startOffset,t.endOffset)),endOffset:Math.min(e.length,Math.max(t.startOffset,t.endOffset))})).filter(e=>e.startOffset<e.endOffset).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),r=[];for(let e of n){let t=r.at(-1);t&&e.startOffset<=t.endOffset?t.endOffset=Math.max(t.endOffset,e.endOffset):r.push({...e})}return r.map(t=>e.slice(t.startOffset,t.endOffset))}function Pm(e){return Array.from(e).every(e=>Em.has(e))}async function Fm(e,t){let{locale:n,ranges:r,signal:i}=t,a=n==null?void 0:xe[n].tag,o=new Intl.Segmenter(a,{granularity:`grapheme`}),s=new Intl.Segmenter(a,{granularity:`word`}),c=Am();await Mm(i),jm(i);for(let t of Nm(e,r)){let e=0,n=!1;for(let{segment:r}of o.segment(t))jm(i),r.includes(`\r`)&&(n&&(c.paragraphs+=1),n=!1),Pm(r)||(c.charactersWithSpaces+=1,/^\s+$/u.test(r)||(c.charactersWithoutSpaces+=1,n=!0),Dm.test(r)&&(c.asianCharactersAndKoreanWords+=1)),e+=r.length,e>=km&&(e=0,await Mm(i));let r=0;for(let e of s.segment(t))jm(i),e.isWordLike&&!Dm.test(e.segment)&&(Om.test(e.segment)?c.asianCharactersAndKoreanWords+=1:c.nonAsianWords+=1),r+=e.segment.length,r>=km&&(r=0,await Mm(i))}return jm(i),c.words=c.nonAsianWords+c.asianCharactersAndKoreanWords,c}let Im=/* @__PURE__ */ function(e){return e.PARAGRAPH=`paragraph`,e.BLOCK_RANGE=`blockRange`,e.TABLE=`table`,e.CUSTOM_BLOCK=`customBlock`,e.COLUMN_GROUP=`columnGroup`,e}({}),Lm=/* @__PURE__ */ function(e){return e[e.character=0]=`character`,e[e.paragraph=1]=`paragraph`,e[e.table=2]=`table`,e[e.numbering=3]=`numbering`,e}({}),Rm=/* @__PURE__ */ function(e){return e[e.TAB=0]=`TAB`,e[e.SPACE=1]=`SPACE`,e[e.NOTHING=2]=`NOTHING`,e}({}),zm=/* @__PURE__ */ function(e){return e[e.BULLET=0]=`BULLET`,e[e.NONE=1]=`NONE`,e[e.DECIMAL=2]=`DECIMAL`,e[e.DECIMAL_ZERO=3]=`DECIMAL_ZERO`,e[e.UPPER_LETTER=4]=`UPPER_LETTER`,e[e.LOWER_LETTER=5]=`LOWER_LETTER`,e[e.UPPER_ROMAN=6]=`UPPER_ROMAN`,e[e.LOWER_ROMAN=7]=`LOWER_ROMAN`,e[e.ORDINAL=8]=`ORDINAL`,e[e.CARDINAL_TEXT=9]=`CARDINAL_TEXT`,e[e.ORDINAL_TEXT=10]=`ORDINAL_TEXT`,e[e.HEX=11]=`HEX`,e[e.CHICAGO=12]=`CHICAGO`,e[e.IDEOGRAPH_DIGITAL=13]=`IDEOGRAPH_DIGITAL`,e[e.JAPANESE_COUNTING=14]=`JAPANESE_COUNTING`,e[e.AIUEO=15]=`AIUEO`,e[e.IROHA=16]=`IROHA`,e[e.DECIMAL_FULL_WIDTH=17]=`DECIMAL_FULL_WIDTH`,e[e.DECIMAL_HALF_WIDTH=18]=`DECIMAL_HALF_WIDTH`,e[e.JAPANESE_LEGAL=19]=`JAPANESE_LEGAL`,e[e.JAPANESE_DIGITAL_TEN_THOUSAND=20]=`JAPANESE_DIGITAL_TEN_THOUSAND`,e[e.DECIMAL_ENCLOSED_CIRCLE=21]=`DECIMAL_ENCLOSED_CIRCLE`,e[e.DECIMAL_FULL_WIDTH2=22]=`DECIMAL_FULL_WIDTH2`,e[e.AIUEO_FULL_WIDTH=23]=`AIUEO_FULL_WIDTH`,e[e.IROHA_FULL_WIDTH=24]=`IROHA_FULL_WIDTH`,e[e.GANADA=25]=`GANADA`,e[e.CHOSUNG=26]=`CHOSUNG`,e[e.DECIMAL_ENCLOSED_FULLSTOP=27]=`DECIMAL_ENCLOSED_FULLSTOP`,e[e.DECIMAL_ENCLOSED_PAREN=28]=`DECIMAL_ENCLOSED_PAREN`,e[e.DECIMAL_ENCLOSED_CIRCLE_CHINESE=29]=`DECIMAL_ENCLOSED_CIRCLE_CHINESE`,e[e.IDEOGRAPH_ENCLOSED_CIRCLE=30]=`IDEOGRAPH_ENCLOSED_CIRCLE`,e[e.IDEOGRAPH_TRADITIONAL=31]=`IDEOGRAPH_TRADITIONAL`,e[e.IDEOGRAPH_ZODIAC=32]=`IDEOGRAPH_ZODIAC`,e[e.IDEOGRAPH_ZODIAC_TRADITIONAL=33]=`IDEOGRAPH_ZODIAC_TRADITIONAL`,e[e.TAIWANESE_COUNTING=34]=`TAIWANESE_COUNTING`,e[e.IDEOGRAPH_LEGAL_TRADITIONAL=35]=`IDEOGRAPH_LEGAL_TRADITIONAL`,e[e.TAIWANESE_COUNTING_THOUSAND=36]=`TAIWANESE_COUNTING_THOUSAND`,e[e.TAIWANESE_DIGITAL=37]=`TAIWANESE_DIGITAL`,e[e.CHINESE_COUNTING=38]=`CHINESE_COUNTING`,e[e.CHINESE_LEGAL_SIMPLIFIED=39]=`CHINESE_LEGAL_SIMPLIFIED`,e[e.CHINESE_COUNTING_THOUSAND=40]=`CHINESE_COUNTING_THOUSAND`,e[e.KOREAN_DIGITAL=41]=`KOREAN_DIGITAL`,e[e.KOREAN_COUNTING=42]=`KOREAN_COUNTING`,e[e.KOREAN_LEGAL=43]=`KOREAN_LEGAL`,e[e.KOREAN_DIGITAL2=44]=`KOREAN_DIGITAL2`,e[e.VIETNAMESE_COUNTING=45]=`VIETNAMESE_COUNTING`,e[e.RUSSIAN_LOWER=46]=`RUSSIAN_LOWER`,e[e.RUSSIAN_UPPER=47]=`RUSSIAN_UPPER`,e[e.NUMBER_IN_DASH=48]=`NUMBER_IN_DASH`,e[e.HEBREW1=49]=`HEBREW1`,e[e.HEBREW2=50]=`HEBREW2`,e[e.ARABIC_ALPHA=51]=`ARABIC_ALPHA`,e[e.ARABIC_ABJAD=52]=`ARABIC_ABJAD`,e[e.HINDI_VOWELS=53]=`HINDI_VOWELS`,e[e.HINDI_CONSONANTS=54]=`HINDI_CONSONANTS`,e[e.HINDI_NUMBERS=55]=`HINDI_NUMBERS`,e[e.HINDI_COUNTING=56]=`HINDI_COUNTING`,e[e.THAI_LETTERS=57]=`THAI_LETTERS`,e[e.THAI_NUMBERS=58]=`THAI_NUMBERS`,e[e.THAI_COUNTING=59]=`THAI_COUNTING`,e[e.CUSTOM=60]=`CUSTOM`,e}({}),Bm=/* @__PURE__ */ function(e){return e[e.BULLET_ALIGNMENT_UNSPECIFIED=0]=`BULLET_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e[e.BOTH=4]=`BOTH`,e}({}),Vm=/* @__PURE__ */ function(e){return e.NON_BREAKING_HYPHEN=`nonBreakingHyphen`,e.OPTIONAL_HYPHEN=`optionalHyphen`,e.EM_SPACE=`emSpace`,e.EN_SPACE=`enSpace`,e}({}),Hm=/* @__PURE__ */ function(e){return e.CALLOUT=`callout`,e.QUOTE=`quote`,e.CODE=`code`,e}({}),Um=/* @__PURE__ */ function(e){return e[e.HYPERLINK=0]=`HYPERLINK`,e[e.FIELD=1]=`FIELD`,e[e.SDT=2]=`SDT`,e[e.BOOKMARK=3]=`BOOKMARK`,e[e.COMMENT=4]=`COMMENT`,e[e.CUSTOM=5]=`CUSTOM`,e[e.MENTION=6]=`MENTION`,e[e.UNI_FORMULA=7]=`UNI_FORMULA`,e[e.FOOTNOTE=8]=`FOOTNOTE`,e[e.ENDNOTE=9]=`ENDNOTE`,e[e.DELTED=9999]=`DELTED`,e}({}),Wm=/* @__PURE__ */ function(e){return e.COLUMN=`column`,e.TEXT_WRAPPING=`textWrapping`,e}({}),Gm=/* @__PURE__ */ function(e){return e[e.COMMENT=0]=`COMMENT`,e[e.DELETED=9999]=`DELETED`,e}({}),Km=/* @__PURE__ */ function(e){return e[e.DRAWING=0]=`DRAWING`,e[e.CUSTOM=1]=`CUSTOM`,e}({}),qm=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.TRADITIONAL=1]=`TRADITIONAL`,e[e.MODERN=2]=`MODERN`,e[e.DRAWINGML=3]=`DRAWINGML`,e}({}),Jm=/* @__PURE__ */ function(e){return e[e.DEFAULT=0]=`DEFAULT`,e[e.LINES=1]=`LINES`,e[e.LINES_AND_CHARS=2]=`LINES_AND_CHARS`,e[e.SNAP_TO_CHARS=3]=`SNAP_TO_CHARS`,e}({}),Ym=/* @__PURE__ */ function(e){return e[e.SECTION_TYPE_UNSPECIFIED=0]=`SECTION_TYPE_UNSPECIFIED`,e[e.CONTINUOUS=1]=`CONTINUOUS`,e[e.NEXT_COLUMN=2]=`NEXT_COLUMN`,e[e.NEXT_PAGE=3]=`NEXT_PAGE`,e[e.EVEN_PAGE=4]=`EVEN_PAGE`,e[e.ODD_PAGE=5]=`ODD_PAGE`,e}({}),Xm=/* @__PURE__ */ function(e){return e[e.COLUMN_SEPARATOR_STYLE_UNSPECIFIED=0]=`COLUMN_SEPARATOR_STYLE_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.BETWEEN_EACH_COLUMN=2]=`BETWEEN_EACH_COLUMN`,e}({}),Zm=/* @__PURE__ */ function(e){return e[e.NORMAL=0]=`NORMAL`,e[e.TBRL=1]=`TBRL`,e[e.LRTBV=2]=`LRTBV`,e}({}),Qm=/* @__PURE__ */ function(e){return e[e.TEXT_RUN=0]=`TEXT_RUN`,e[e.AUTO_TEXT=1]=`AUTO_TEXT`,e[e.PAGE_BREAK=2]=`PAGE_BREAK`,e[e.COLUMN_BREAK=3]=`COLUMN_BREAK`,e[e.FOOT_NOTE_REFERENCE=4]=`FOOT_NOTE_REFERENCE`,e[e.HORIZONTAL_RULE=5]=`HORIZONTAL_RULE`,e[e.EQUATION=6]=`EQUATION`,e[e.DRAWING=7]=`DRAWING`,e[e.PERSON=8]=`PERSON`,e[e.RICH_LINK=9]=`RICH_LINK`,e}({}),$m=/* @__PURE__ */ function(e){return e[e.BOTH_SIDES=0]=`BOTH_SIDES`,e[e.LEFT=1]=`LEFT`,e[e.RIGHT=2]=`RIGHT`,e[e.LARGEST=3]=`LARGEST`,e}({}),eh=/* @__PURE__ */ function(e){return e[e.INLINE=0]=`INLINE`,e[e.WRAP_NONE=1]=`WRAP_NONE`,e[e.WRAP_POLYGON=2]=`WRAP_POLYGON`,e[e.WRAP_SQUARE=3]=`WRAP_SQUARE`,e[e.WRAP_THROUGH=4]=`WRAP_THROUGH`,e[e.WRAP_TIGHT=5]=`WRAP_TIGHT`,e[e.WRAP_TOP_AND_BOTTOM=6]=`WRAP_TOP_AND_BOTTOM`,e}({}),th=/* @__PURE__ */ function(e){return e[e.NAMED_STYLE_TYPE_UNSPECIFIED=0]=`NAMED_STYLE_TYPE_UNSPECIFIED`,e[e.NORMAL_TEXT=1]=`NORMAL_TEXT`,e[e.TITLE=2]=`TITLE`,e[e.SUBTITLE=3]=`SUBTITLE`,e[e.HEADING_1=4]=`HEADING_1`,e[e.HEADING_2=5]=`HEADING_2`,e[e.HEADING_3=6]=`HEADING_3`,e[e.HEADING_4=7]=`HEADING_4`,e[e.HEADING_5=8]=`HEADING_5`,e}({}),nh=/* @__PURE__ */ function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),rh=/* @__PURE__ */ function(e){return e[e.DASH_STYLE_UNSPECIFIED=0]=`DASH_STYLE_UNSPECIFIED`,e[e.SOLID=1]=`SOLID`,e[e.DOT=2]=`DOT`,e[e.DASH=3]=`DASH`,e}({}),ih=/* @__PURE__ */ function(e){return e[e.TAB_STOP_ALIGNMENT_UNSPECIFIED=0]=`TAB_STOP_ALIGNMENT_UNSPECIFIED`,e[e.START=1]=`START`,e[e.CENTER=2]=`CENTER`,e[e.END=3]=`END`,e}({}),ah=/* @__PURE__ */ function(e){return e[e.TAB_STOP_LEADER_UNSPECIFIED=0]=`TAB_STOP_LEADER_UNSPECIFIED`,e[e.NONE=1]=`NONE`,e[e.DOT=2]=`DOT`,e[e.HYPHEN=3]=`HYPHEN`,e[e.UNDERSCORE=4]=`UNDERSCORE`,e[e.HEAVY=5]=`HEAVY`,e[e.MIDDLE_DOT=6]=`MIDDLE_DOT`,e}({}),oh=/* @__PURE__ */ function(e){return e[e.UNSPECIFIED=0]=`UNSPECIFIED`,e[e.SPECIFIED=1]=`SPECIFIED`,e}({}),sh=/* @__PURE__ */ function(e){return e[e.START=0]=`START`,e[e.CENTER=1]=`CENTER`,e[e.END=2]=`END`,e}({}),ch=/* @__PURE__ */ function(e){return e[e.AUTO_FIT=0]=`AUTO_FIT`,e[e.FIXED=1]=`FIXED`,e}({}),lh=/* @__PURE__ */ function(e){return e[e.NONE=0]=`NONE`,e[e.WRAP=1]=`WRAP`,e}({}),uh=/* @__PURE__ */ function(e){return e.FIXED=`fixed`,e.AUTO=`auto`,e}({}),dh=/* @__PURE__ */ function(e){return e.STACK=`stack`,e.SHRINK=`shrink`,e}({}),fh=/* @__PURE__ */ function(e){return e[e.AUTO=0]=`AUTO`,e[e.AT_LEAST=1]=`AT_LEAST`,e[e.EXACT=2]=`EXACT`,e}({}),ph=/* @__PURE__ */ function(e){return e[e.CONTENT_ALIGNMENT_UNSPECIFIED=0]=`CONTENT_ALIGNMENT_UNSPECIFIED`,e[e.BOTH=1]=`BOTH`,e[e.TOP=2]=`TOP`,e[e.CENTER=3]=`CENTER`,e[e.BOTTOM=4]=`BOTTOM`,e}({}),mh=/* @__PURE__ */ function(e){return e.NORMAL=`normal`,e.BOLD=`bold`,e.ITALIC=`italic`,e}({}),hh=/* @__PURE__ */ function(e){return e[e.PAGE=0]=`PAGE`,e[e.COLUMN=1]=`COLUMN`,e[e.CHARACTER=2]=`CHARACTER`,e[e.MARGIN=3]=`MARGIN`,e[e.INSIDE_MARGIN=4]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=5]=`OUTSIDE_MARGIN`,e[e.LEFT_MARGIN=6]=`LEFT_MARGIN`,e[e.RIGHT_MARGIN=7]=`RIGHT_MARGIN`,e}({}),gh=/* @__PURE__ */ function(e){return e[e.PAGE=0]=`PAGE`,e[e.PARAGRAPH=1]=`PARAGRAPH`,e[e.LINE=2]=`LINE`,e[e.MARGIN=3]=`MARGIN`,e[e.TOP_MARGIN=4]=`TOP_MARGIN`,e[e.BOTTOM_MARGIN=5]=`BOTTOM_MARGIN`,e[e.INSIDE_MARGIN=6]=`INSIDE_MARGIN`,e[e.OUTSIDE_MARGIN=7]=`OUTSIDE_MARGIN`,e}({}),_h=/* @__PURE__ */ function(e){return e[e.POINT=0]=`POINT`,e[e.LINE=1]=`LINE`,e[e.CHARACTER=2]=`CHARACTER`,e[e.PIXEL=3]=`PIXEL`,e[e.PERCENT=4]=`PERCENT`,e}({}),vh=/* @__PURE__ */ function(e){return e[e.CENTER=0]=`CENTER`,e[e.INSIDE=1]=`INSIDE`,e[e.LEFT=2]=`LEFT`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.RIGHT=4]=`RIGHT`,e[e.BOTH=5]=`BOTH`,e[e.DISTRIBUTE=6]=`DISTRIBUTE`,e}({}),yh=/* @__PURE__ */ function(e){return e[e.BOTTOM=0]=`BOTTOM`,e[e.CENTER=1]=`CENTER`,e[e.INSIDE=2]=`INSIDE`,e[e.OUTSIDE=3]=`OUTSIDE`,e[e.TOP=4]=`TOP`,e}({}),bh=/* @__PURE__ */ function(e){return e[e.compressPunctuation=0]=`compressPunctuation`,e[e.compressPunctuationAndJapaneseKana=1]=`compressPunctuationAndJapaneseKana`,e[e.doNotCompress=2]=`doNotCompress`,e}({}),xh=/* @__PURE__ */ function(e){return e[e.PORTRAIT=0]=`PORTRAIT`,e[e.LANDSCAPE=1]=`LANDSCAPE`,e}({}),Sh=/* @__PURE__ */ function(e){return e.Letter=`Letter`,e.Tabloid=`Tabloid`,e.Legal=`Legal`,e.Statement=`Statement`,e.Executive=`Executive`,e.Folio=`Folio`,e.A3=`A3`,e.A4=`A4`,e.A5=`A5`,e.B4=`B4`,e.B5=`B5`,e}({}),Ch=[`A3`,`A4`,`A5`,`B4`,`B5`,`Letter`,`Tabloid`,`Legal`,`Statement`,`Executive`,`Folio`];function wh(){return e=>e}let Th=wh()([`s`,`c`,`cl`,`t`]),Eh=wh()([`rgb`,`th`]),Dh=wh()([`s`,`cl`]),Oh=wh()([`t`,`r`,`b`,`l`,`tl_br`,`tl_bc`,`tl_mr`,`bl_tr`,`ml_tr`,`bc_tr`]),kh=wh()([`a`,`v`]),Ah=wh()([`t`,`r`,`b`,`l`]),jh=wh()([`ff`,`eastAsiaFontFamily`,`fs`,`it`,`bl`,`ul`,`bbl`,`st`,`ol`,`bg`,`bd`,`cl`,`va`,`n`,`stf`,`tr`,`td`,`ht`,`vt`,`tb`,`pd`]),Mh={sheetId:``,range:{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1}},Nh={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1},Ph={startRow:0,startColumn:0,endRow:0,endColumn:0},Fh={row:0,column:0},Y={ff:`Arial`,fs:11,it:0,bl:0,ul:{s:0},st:{s:0},ol:{s:0},tr:{a:0,v:0},td:0,cl:{rgb:`#000000`},bg:{rgb:`#fff`},ht:0,vt:0,tb:0,pd:{t:0,r:0,b:0,l:0},n:null,bd:{b:null,l:null,r:null,t:null}},Ih=[Op,kp],Lh={4:{fs:20,bl:1},5:{fs:18,bl:1},6:{fs:16,bl:1},7:{fs:14,bl:1},8:{fs:12,bl:1},1:null,2:{fs:26,bl:1},3:{fs:15,cl:{rgb:`#999999`}},0:null},Rh=1.5,zh={4:{spaceAbove:{v:20},spaceBelow:{v:10}},5:{spaceAbove:{v:18},spaceBelow:{v:10}},6:{spaceAbove:{v:16},spaceBelow:{v:10}},7:{spaceAbove:{v:14},spaceBelow:{v:8}},8:{spaceAbove:{v:12},spaceBelow:{v:8}},1:{spaceAbove:{v:0},spaceBelow:{v:12}},2:{spaceAbove:{v:0},spaceBelow:{v:7}},3:{spaceAbove:{v:0},spaceBelow:{v:16}},0:null},Bh=/* @__PURE__ */ function(e){return e.ARRAY_CONVERTOR=`ARRAY_CONVERTOR`,e.MATRIX_CONVERTOR=`MATRIX_CONVERTOR`,e}({}),Vh={A3:{width:1123,height:1587},A4:{width:794,height:1124},A5:{width:559,height:794},B4:{width:944,height:1344},B5:{width:665,height:944},Executive:{width:696,height:1008},Folio:{width:816,height:1248},Legal:{width:816,height:1344},Letter:{width:816,height:1056},Statement:{width:528,height:816},Tabloid:{width:1056,height:1632}},Hh=/* @__PURE__ */ function(e){return e.NARROW=`narrow`,e.MEDIUM=`medium`,e.WIDE=`wide`,e}({}),Uh={narrow:Vh.A4.width,medium:960,wide:Vh.A3.width},Wh=`para_`;function Gh(e){let t=`${Wh}${J(12)}`;for(;e.has(t);)t=`${Wh}${J(12)}`;return e.add(t),t}function Kh(e,t){let n=Yh(e),r=/* @__PURE__ */ new Set;for(let e of n.paragraphs??[])e.paragraphId=Gh(r);return n}function qh(e,t,n){let r=Xh(e);return n!==!1&&Jh(r.paragraphId)&&!t.has(r.paragraphId)?(t.add(r.paragraphId),r):(r.paragraphId=Gh(t),r)}function Jh(e){return typeof e==`string`&&e.startsWith(`para_`)&&e.length>5}function Yh(e){return JSON.parse(JSON.stringify(e))}function Xh(e){return JSON.parse(JSON.stringify(e))}function Zh(e=J(6),t=`enUS`,n=``,r=2){let i={id:e,locale:t,title:n,tableSource:{},drawings:{},drawingsOrder:[],headers:{},footers:{},notes:{},noteSettings:{},body:{dataStream:`\r
|
|
4
|
+
`,textRuns:[],customBlocks:[],tables:[],columnGroups:[],blockRanges:[],customRanges:[],customDecorations:[],paragraphs:[{startIndex:0,paragraphId:Gh(/* @__PURE__ */ new Set),paragraphStyle:{lineSpacing:1}}],sectionBreaks:[{sectionId:xm(/* @__PURE__ */ new Set),startIndex:1}]},documentStyle:{pageSize:Vh.A4,documentFlavor:r,marginTop:72,marginBottom:72,marginRight:72,marginLeft:72,autoHyphenation:r===3?0:1,doNotHyphenateCaps:0,consecutiveHyphenLimit:2,defaultHeaderId:``,defaultFooterId:``,evenPageHeaderId:``,evenPageFooterId:``,firstPageHeaderId:``,firstPageFooterId:``,evenAndOddHeaders:0,useFirstPageHeaderFooter:0,marginHeader:30,marginFooter:30},settings:{}};return r===2&&(i.body.paragraphs[0].paragraphStyle={},i.documentStyle.defaultParagraphStyle={spaceAbove:{v:0},lineSpacing:Rh,spaceBelow:{v:12}},i.documentStyle.pageSize={width:Uh.medium,height:842/.75},i.documentStyle.marginTop=50,i.documentStyle.marginBottom=50,i.documentStyle.marginRight=50,i.documentStyle.marginLeft=50,i.documentStyle.renderConfig={zeroWidthParagraphBreak:0,vertexAngle:0,centerAngle:0,background:{rgb:`#ccc`}}),i}var Qh=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t){if(Array.isArray(t))return!1;for(let n in e)if(!r(e[n],t[n]))return!1;for(let n in t)if(e[n]===void 0)return!1;return!0}function n(e,t){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}function r(e,r){return e===r?!0:e===null||r===null||typeof e!=`object`||typeof r!=`object`?!1:Array.isArray(e)?n(e,r):t(e,r)}e.default=r})),$h=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){if(e===null)return null;if(Array.isArray(e))return e.map(t);if(typeof e==`object`){let n={};for(let r in e)n[r]=t(e[r]);return n}return e}e.default=t})),eg=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.eachChildOf=e.advancer=e.readCursor=e.writeCursor=e.WriteCursor=e.ReadCursor=e.isValidPathItem=void 0;function t(e,t){if(!e)throw Error(t)}let n=e=>typeof e==`object`&&!!e&&!Array.isArray(e),r=(e,t)=>typeof e==typeof t?e>t:typeof e==`string`&&typeof t==`number`;function i(e,t){for(let n in e){let r=n;t.write(r,e[r])}}e.isValidPathItem=e=>typeof e==`number`||typeof e==`string`&&e!==`__proto__`;var a=class{constructor(e=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=e}ascend(){t(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(t(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){let e=[],t=this.container,r=this.parents.length-1,i=this.idx;for(;i>=0;)e.unshift(t[i]),i===0?(i=this.indexes[r*2],t=this.parents[r--]):i-=n(t[i-1])?2:1;return e}},o=class e extends a{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return t(this.container!=null,`Invalid call to getKey before cursor descended`),this.container[this.idx]}getComponent(){let e;return this.container&&this.container.length>this.idx+1&&n(e=this.container[this.idx+1])?e:null}descendFirst(){let e=this.idx+1;if(!this.container||e>=this.container.length||n(this.container[e])&&e+1>=this.container.length)return!1;n(this.container[e])&&e++;let t=this.container[e];return Array.isArray(t)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(e),this.idx=0,this.container=t):this.idx=e,!0}nextSibling(){if(t(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;let e=this.indexes[this.indexes.length-1]+1,n=this.parents[this.parents.length-1];return e>=n.length?!1:(t(!isNaN(e)),this.indexes[this.indexes.length-1]=e,this.container=n[e],!0)}_init(e,t,n,r){this.container=e,this.idx=t,this.parents=n.slice(),this.indexes=r.slice()}clone(){let t=new e;return t._init(this.container,this.idx,this.parents,this.indexes),t}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(e,t){let n=this.getComponent();n&&t(n,e);for(let n of this)e&&e.descend(n),this.traverse(e,t),e&&e.ascend()}eachPick(e,t){this.traverse(e,(e,n)=>{e.p!=null&&t(e.p,n)})}eachDrop(e,t){this.traverse(e,(e,n)=>{e.d!=null&&t(e.d,n)})}};e.ReadCursor=o;var s=class extends a{constructor(e=null){super(e),this.pendingDescent=[],this._op=e}flushDescent(){t(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let e=0;e<this.pendingDescent.length;e++){let i=this.pendingDescent[e],a=this.idx+1;if(a<this.container.length&&n(this.container[a])&&a++,t(a===this.container.length||!n(this.container[a])),a===this.container.length)this.container.push(i),this.idx=a;else if(this.container[a]===i)this.idx=a;else{if(!Array.isArray(this.container[a])){let e=this.container.splice(a,this.container.length-a);this.container.push(e),this.lcIdx>-1&&(this.lcIdx=a)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(t(r(i,this.container[this.lcIdx][0])),a=this.lcIdx+1,this.lcIdx=-1);a<this.container.length&&r(i,this.container[a][0]);)a++;if(this.indexes.push(a),this.idx=0,a<this.container.length&&this.container[a][0]===i)this.container=this.container[a];else{let e=[i];this.container.splice(a,0,e),this.container=e}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();let e=this.idx+1;if(e<this.container.length&&n(this.container[e]))return this.container[e];{let t={};return this.container.splice(e,0,t),t}}write(e,n){let r=this.getComponent();t(r[e]==null||r[e]===n,`Internal consistency error: Overwritten component. File a bug`),r[e]=n}get(){return this._op}descend(t){if(!e.isValidPathItem(t))throw Error(`Invalid JSON key`);this.pendingDescent.push(t)}descendPath(e){return this.pendingDescent.push(...e),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(e,n=i){if(e===null)return;if(t(Array.isArray(e)),e===this._op)throw Error(`Cannot merge into my own tree`);let r=this.lcIdx,a=this.parents.length,o=0;for(let t=0;t<e.length;t++){let r=e[t];typeof r==`string`||typeof r==`number`?(o++,this.descend(r)):Array.isArray(r)?this.mergeTree(r,n):typeof r==`object`&&n(r,this)}for(;o--;)this.ascend();this.lcIdx=this.parents.length===a?r:-1}at(e,t){this.descendPath(e),t(this);for(let t=0;t<e.length;t++)this.ascend();return this}writeAtPath(e,t,n){return this.at(e,()=>this.write(t,n)),this.reset(),this}writeMove(e,t,n=0){return this.writeAtPath(e,`p`,n).writeAtPath(t,`d`,n)}getPath(){let e=super.getPath();return e.push(...this.pendingDescent),e}};e.WriteCursor=s,e.writeCursor=()=>new s,e.readCursor=e=>new o(e);function c(e,t,n){let i,a;a=i=e?e.descendFirst():!1;function o(i){let o;for(;a;){let s=o=e.getKey();if(i!=null){let n=!1;if(t&&typeof s==`number`&&(o=t(s,e.getComponent()),o<0&&(o=~o,n=!0)),r(o,i))return null;if(o===i&&!n)return e}n&&typeof o==`number`&&n(o,e.getComponent()),a=e.nextSibling()}return null}return o.end=()=>{i&&e.ascend()},o}e.advancer=c;function l(e,t,n){let i,a,o,s;for(i=a=e&&e.descendFirst(),o=s=t&&t.descendFirst();i||o;){let a=i?e.getKey():null,s=o?t.getKey():null;a!==null&&s!==null&&(r(s,a)?s=null:a!==s&&(a=null)),n(a??s,a==null?null:e,s==null?null:t),a!=null&&i&&(i=e.nextSibling()),s!=null&&o&&(o=t.nextSibling())}a&&e.ascend(),s&&t.ascend()}e.eachChildOf=l})),tg=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]=`RM_UNEXPECTED_CONTENT`,e[e.DROP_COLLISION=2]=`DROP_COLLISION`,e[e.BLACKHOLE=3]=`BLACKHOLE`})(e.ConflictType||={})})),ng=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniToStrPos=e.strPosToUni=void 0,e.strPosToUni=(e,t=e.length)=>{let n=0,r=0;for(;r<t;r++){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(n++,r++)}if(r!==t)throw Error(`Invalid offset - splits unicode bytes`);return r-n},e.uniToStrPos=(e,t)=>{let n=0;for(;t>0;t--){let t=e.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}})),rg=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.uniSlice=e.dlen=e.eachOp=void 0;let t=ng(),n=t=>{if(!Array.isArray(t))throw Error(`Op must be an array of components`);let n=null;for(let r=0;r<t.length;r++){let i=t[r];switch(typeof i){case`object`:if(typeof i.d!=`number`&&typeof i.d!=`string`)throw Error(`Delete must be number or string`);if(e.dlen(i.d)<=0)throw Error(`Deletes must not be empty`);break;case`string`:if(!(i.length>0))throw Error(`Inserts cannot be empty`);break;case`number`:if(!(i>0))throw Error(`Skip components must be >0`);if(typeof n==`number`)throw Error(`Adjacent skip components should be combined`)}n=i}if(typeof n==`number`)throw Error(`Op has a trailing skip`)};function r(n,r){let i=0,a=0;for(let o=0;o<n.length;o++){let s=n[o];switch(r(s,i,a),typeof s){case`object`:i+=e.dlen(s.d);break;case`string`:a+=t.strPosToUni(s);break;case`number`:i+=s,a+=s}}}e.eachOp=r;function i(e,t){let n=[],i=s(n);return r(e,(e,n,r)=>{i(t(e,n,r))}),d(n)}let a=e=>e,o=e=>i(e,a);e.dlen=e=>typeof e==`number`?e:t.strPosToUni(e);let s=t=>n=>{if(n&&n.d!==0&&n.d!==``){if(t.length===0)t.push(n);else if(typeof n==typeof t[t.length-1]){if(typeof n==`object`){let r=t[t.length-1];r.d=typeof r.d==`string`&&typeof n.d==`string`?r.d+n.d:e.dlen(r.d)+e.dlen(n.d)}else t[t.length-1]+=n}else t.push(n)}},c=e=>typeof e==`number`?e:typeof e==`string`?t.strPosToUni(e):typeof e.d==`number`?e.d:t.strPosToUni(e.d);e.uniSlice=(e,n,r)=>{let i=t.uniToStrPos(e,n),a=r==null?1/0:t.uniToStrPos(e,r);return e.slice(i,a)};let l=(t,n,r)=>typeof t==`number`?r==null?t-n:Math.min(t,r)-n:e.uniSlice(t,n,r),u=n=>{let r=0,i=0;return{take:(a,o)=>{if(r===n.length)return a===-1?null:a;let s=n[r],c;if(typeof s==`number`)return a===-1||s-i<=a?(c=s-i,++r,i=0,c):(i+=a,a);if(typeof s==`string`){if(a===-1||o===`i`||t.strPosToUni(s.slice(i))<=a)return c=s.slice(i),++r,i=0,c;{let e=i+t.uniToStrPos(s.slice(i),a);return c=s.slice(i,e),i=e,c}}if(a===-1||o===`d`||e.dlen(s.d)-i<=a)return c={d:l(s.d,i)},++r,i=0,c;{let e=l(s.d,i,i+a);return i+=a,{d:e}}},peek:()=>n[r]}},d=e=>(e.length>0&&typeof e[e.length-1]==`number`&&e.pop(),e);function f(r,i,a){if(a!==`left`&&a!==`right`)throw Error(`side (`+a+`) must be 'left' or 'right'`);n(r),n(i);let o=[],l=s(o),{take:f,peek:p}=u(r);for(let n=0;n<i.length;n++){let r=i[n],o,s;switch(typeof r){case`number`:for(o=r;o>0;)s=f(o,`i`),l(s),typeof s!=`string`&&(o-=c(s));break;case`string`:a===`left`&&typeof p()==`string`&&l(f(-1)),l(t.strPosToUni(r));break;case`object`:for(o=e.dlen(r.d);o>0;)switch(s=f(o,`i`),typeof s){case`number`:o-=s;break;case`string`:l(s);break;case`object`:o-=e.dlen(s.d)}}}let m;for(;m=f(-1);)l(m);return d(o)}function p(r,i){n(r),n(i);let a=[],o=s(a),{take:f}=u(r);for(let n=0;n<i.length;n++){let r=i[n],a,s;switch(typeof r){case`number`:for(a=r;a>0;)s=f(a,`d`),o(s),typeof s!=`object`&&(a-=c(s));break;case`string`:o(r);break;case`object`:a=e.dlen(r.d);let n=0;for(;n<a;)switch(s=f(a-n,`d`),typeof s){case`number`:o({d:l(r.d,n,n+s)}),n+=s;break;case`string`:n+=t.strPosToUni(s);break;case`object`:o(s)}}}let p;for(;p=f(-1);)o(p);return d(a)}let m=(n,r)=>{let i=0;for(let a=0;a<r.length&&n>i;a++){let o=r[a];switch(typeof o){case`number`:i+=o;break;case`string`:let r=t.strPosToUni(o);i+=r,n+=r;break;case`object`:n-=Math.min(e.dlen(o.d),n-i)}}return n},h=(e,t)=>typeof e==`number`?m(e,t):e.map(e=>m(e,t));function g(e,t,n){return i(e,(e,r)=>typeof e==`object`&&typeof e.d==`number`?{d:n.slice(t,r,r+e.d)}:e)}function _(e){return i(e,e=>{switch(typeof e){case`object`:if(typeof e.d==`number`)throw Error(`Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.`);return e.d;case`string`:return{d:e};case`number`:return e}})}function v(e){return i(e,e=>typeof e==`object`&&typeof e.d==`string`?{d:t.strPosToUni(e.d)}:e)}function y(e){let t=!0;return r(e,e=>{typeof e==`object`&&typeof e.d==`number`&&(t=!1)}),t}function b(t){return{name:`text-unicode`,uri:`http://sharejs.org/types/text-unicode`,trim:d,normalize:o,checkOp:n,create(e=``){if(typeof e!=`string`)throw Error(`Initial data must be a string`);return t.create(e)},apply(r,i){n(i);let a=t.builder(r);for(let t=0;t<i.length;t++){let n=i[t];switch(typeof n){case`number`:a.skip(n);break;case`string`:a.append(n);break;case`object`:a.del(e.dlen(n.d))}}return a.build()},transform:f,compose:p,transformPosition:m,transformSelection:h,isInvertible:y,makeInvertible(e,n){return g(e,n,t)},stripInvertible:v,invert:_,invertWithDoc(e,n){return _(g(e,n,t))},isNoop:e=>e.length===0}}e.default=b})),ig=/* @__PURE__ */ f((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=rg(),n=ng();function r(e,r){return{get:e,getLength(){return e().length},insert(t,i,a){return r([n.strPosToUni(e(),t),i],a)},remove(t,i,a){return r([n.strPosToUni(e(),t),{d:i}],a)},_onOp(e){t.eachOp(e,(e,n,r)=>{switch(typeof e){case`string`:this.onInsert&&this.onInsert(r,e);break;case`object`:let n=t.dlen(e.d);this.onRemove&&this.onRemove(r,n)}})},onInsert:null,onRemove:null}}e.default=r,r.provides={text:!0}})),ag=/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.type=e.remove=e.insert=void 0;let s=ng(),c=a(rg()),l=o(ig()),u={create(e){return e},toString(e){return e},builder(e){if(typeof e!=`string`)throw Error(`Invalid document snapshot: `+e);let t=[];return{skip(n){let r=s.uniToStrPos(e,n);if(r>e.length)throw Error(`The op is too long for this document`);t.push(e.slice(0,r)),e=e.slice(r)},append(e){t.push(e)},del(t){e=e.slice(s.uniToStrPos(e,t))},build(){return t.join(``)+e}}},slice:c.uniSlice},d=c.default(u);e.type=Object.assign(Object.assign({},d),{api:l.default}),e.insert=(e,t)=>t.length===0?[]:e===0?[t]:[e,t],e.remove=(e,t)=>c.dlen(t)===0?[]:e===0?[{d:t}]:[e,{d:t}];var f=rg();Object.defineProperty(e,"makeType",{enumerable:!0,get:function(){return f.default}})})),og=/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.editOp=e.replaceOp=e.insertOp=e.moveOp=e.removeOp=e.type=void 0;let i=r(Qh()),a=r($h()),o=eg(),s=tg(),c=()=>{};function l(e,t){if(!e)throw Error(t)}let u=!1;e.type={name:`json1`,uri:`http://sharejs.org/types/JSONv1`,readCursor:o.readCursor,writeCursor:o.writeCursor,create:e=>e,isNoop:e=>e==null,setDebug(e){u=e,c.quiet=!e},registerSubtype:x,checkValidOp:k,normalize:A,apply:j,transformPosition:M,compose:N,tryTransform:R,transform:ne,makeInvertible:I,invert:P,invertWithDoc:L,RM_UNEXPECTED_CONTENT:s.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:s.ConflictType.DROP_COLLISION,BLACKHOLE:s.ConflictType.BLACKHOLE,transformNoConflict:(e,t,n)=>z(()=>!0,e,t,n),typeAllowingConflictsPred:t=>Object.assign(Object.assign({},e.type),{transform:(e,n,r)=>z(t,e,n,r)})};let d=e=>e?e.getComponent():null;function f(e){return e&&typeof e==`object`&&!Array.isArray(e)}let p=e=>Array.isArray(e)?e.slice():typeof e==`object`&&e?Object.assign({},e):e,m=e=>e&&(e.p!=null||e.r!==void 0),h=e=>e&&(e.d!=null||e.i!==void 0);function g(e,t){return l(e!=null),typeof t==`number`?(l(Array.isArray(e),`Invalid key - child is not an array`),(e=e.slice()).splice(t,1)):(l(f(e),`Invalid key - child is not an object`),delete(e=Object.assign({},e))[t]),e}function _(e,t,n){return typeof t==`number`?(l(e!=null,`Container is missing for key`),l(Array.isArray(e),`Cannot use numerical key for object container`),l(e.length>=t,`Cannot insert into out of bounds index`),e.splice(t,0,n)):(l(f(e),`Cannot insert into missing item`),l(e[t]===void 0,`Trying to overwrite value at key. Your op needs to remove it first`),e[t]=n),n}e.removeOp=(e,t=!0)=>o.writeCursor().writeAtPath(e,`r`,t).get(),e.moveOp=(e,t)=>o.writeCursor().writeMove(e,t).get(),e.insertOp=(e,t)=>o.writeCursor().writeAtPath(e,`i`,t).get(),e.replaceOp=(e,t,n)=>o.writeCursor().at(e,e=>{e.write(`r`,t),e.write(`i`,n)}).get(),e.editOp=(e,t,n,r=!1)=>o.writeCursor().at(e,e=>E(e,t,n,r)).get();let v=(e,t)=>e!=null&&(typeof t==`number`?Array.isArray(e):typeof e==`object`),y=(e,t)=>v(e,t)?e[t]:void 0,b={};function x(e){let t=e.type?e.type:e;t.name&&(b[t.name]=t),t.uri&&(b[t.uri]=t)}let S=e=>{let t=b[e];if(t)return t;throw Error(`Missing type: `+e)};x(ag());let C=(e,t)=>e+t;x({name:`number`,apply:C,compose:C,invert:e=>-e,transform:e=>e});let w=e=>e==null?null:e.et?S(e.et):e.es?b[`text-unicode`]:e.ena==null?null:b.number,T=e=>e.es?e.es:e.ena==null?e.e:e.ena,E=(e,t,n,r=!1)=>{let[i,a]=typeof t==`string`?[S(t),t]:[t,t.name];!r&&i.isNoop&&i.isNoop(n)||(a===`number`?e.write(`ena`,n):a===`text-unicode`?e.write(`es`,n):(e.write(`et`,a),e.write(`e`,n)))};function D(e){l(typeof e==`number`),l(e>=0),l(e===(0|e))}function O(e){typeof e==`number`?D(e):l(typeof e==`string`)}function k(e){if(e===null)return;let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Set,r=e=>{let r=!0,i=!1;for(let a in e){let o=e[a];if(r=!1,l(a===`p`||a===`r`||a===`d`||a===`i`||a===`e`||a===`es`||a===`ena`||a===`et`,`Invalid component item '`+a+`'`),a===`p`)D(o),l(!t.has(o)),t.add(o),l(e.r===void 0);else if(a===`d`)D(o),l(!n.has(o)),n.add(o),l(e.i===void 0);else if(a===`e`||a===`es`||a===`ena`){l(!i),i=!0;let t=w(e);l(t,`Missing type in edit`),t.checkValidOp&&t.checkValidOp(T(e))}}l(!r)},i=(e,t,n)=>{if(!Array.isArray(e))throw Error(`Op must be null or a list`);if(e.length===0)throw Error(`Empty descent`);t||O(e[0]);let a=1,s=0,c=0;for(let t=0;t<e.length;t++){let u=e[t];if(l(u!=null),Array.isArray(u)){let e=i(u,!1,n);if(s){let t=typeof c,n=typeof e;t===n?l(c<e,`descent keys are not in order`):l(t===`number`&&n===`string`)}c=e,s++,a=3}else typeof u==`object`?(l(a===1,`Prev not scalar - instead ${a}`),r(u),a=2):(l(a!==3),O(u),l(o.isValidPathItem(u),`Invalid path key`),a=1)}return l(s!==1,`Operation makes multiple descents. Remove some []`),l(a===2||a===3),e[0]};i(e,!0,!1),l(t.size===n.size,`Mismatched picks and drops in op`);for(let e=0;e<t.size;e++)l(t.has(e)),l(n.has(e))}function A(e){let t=0,n=[],r=o.writeCursor();return r.mergeTree(e,(e,r)=>{let i=w(e);if(i){let t=T(e);E(r,i,i.normalize?i.normalize(t):t)}for(let i of[`r`,`p`,`i`,`d`])if(e[i]!==void 0){let o=i===`p`||i===`d`?(a=e[i],n[a]??(n[a]=t++),n[a]):e[i];r.write(i,o)}var a}),r.get()}function j(e,t){if(c.quiet=!u,k(t),t===null)return e;let n=[];return function e(t,r){let i=t,a=0,o={root:t},s=0,c=o,u=`root`;function d(){for(;s<a;s++){let e=r[s];typeof e!=`object`&&(l(v(c,u)),c=c[u]=p(c[u]),u=e)}}for(;a<r.length;a++){let t=r[a];if(Array.isArray(t)){let n=e(i,t);n!==i&&n!==void 0&&(d(),i=c[u]=n)}else if(typeof t==`object`){t.d==null?t.i!==void 0&&(d(),i=_(c,u,t.i)):(d(),i=_(c,u,n[t.d]));let e=w(t);if(e)d(),i=c[u]=e.apply(i,T(t));else if(t.e!==void 0)throw Error(`Subtype `+t.et+` undefined`)}else i=y(i,t)}return o.root}(e=function e(t,r){let i=[],a=0;for(;a<r.length;a++){let e=r[a];if(Array.isArray(e))break;typeof e!=`object`&&(i.push(t),t=y(t,e))}for(let n=r.length-1;n>=a;n--)t=e(t,r[n]);for(--a;a>=0;a--){let e=r[a];if(typeof e!=`object`){let n=i.pop();t=t===y(n,e)?n:t===void 0?g(n,e):(s=e,c=t,(o=p(o=n))[s]=c,o)}else m(e)&&(l(t!==void 0,`Cannot pick up or remove undefined`),e.p!=null&&(n[e.p]=t),t=void 0)}var o,s,c;return t}(e,t),t)}function M(e,t){e=e.slice(),k(t);let n=o.readCursor(t),r,i,a=!1,s=[];for(let t=0;;t++){let c=e[t],l=n.getComponent();if(l&&(l.r===void 0?l.p!=null&&(a=!1,r=l.p,i=t):a=!0),t>=e.length)break;let u=0,d=o.advancer(n,void 0,(e,t)=>{m(t)&&u++});s.unshift(d);let f=d(c);if(typeof c==`number`&&(e[t]-=u),!f)break}if(s.forEach(e=>e.end()),a)return null;let c=()=>{let t=0;if(r!=null){let r=n.getPath();t=r.length,e=r.concat(e.slice(i))}for(;t<e.length;t++){let r=e[t],i=d(n),a=w(i);if(a){let n=T(i);a.transformPosition&&(e[t]=a.transformPosition(e[t],n));break}let s=0,c=o.advancer(n,(e,t)=>h(t)?~(e-s):e-s,(e,t)=>{h(t)&&s++})(r);if(typeof r==`number`&&(e[t]+=s),!c)break}};return r==null?c():n.eachDrop(null,e=>{e===r&&c()}),e}function N(e,t){if(k(e),k(t),e==null)return t;if(t==null)return e;let n=0,r=o.readCursor(e),i=o.readCursor(t),a=o.writeCursor(),s=[],c=[],u=[],f=[],p=[],g=[],_=/* @__PURE__ */ new Set;r.traverse(null,e=>{e.p!=null&&(u[e.p]=r.clone())}),i.traverse(null,e=>{e.d!=null&&(f[e.d]=i.clone())});let v=o.writeCursor();return function e(t,r,i,a,v,y,b,x){l(r||i);let S=d(r),C=d(i),D=!!C&&C.r!==void 0,O=!!S&&S.i!==void 0,k=S?S.d:null,A=C?C.p:null,j=(y||D)&&A==null;if(A!=null)a=f[A],b=c[A]=new o.WriteCursor;else if(C&&C.r!==void 0)a=null;else{let e=d(a);e&&e.d!=null&&(a=null)}let M=d(a);if(k!=null){if(t=u[k],x=s[k]=new o.WriteCursor,j)y&&!D&&x.write(`r`,!0);else{let e=p[k]=n++;b.write(`d`,e)}}else if(S&&S.i!==void 0)t=null;else{let e=d(t);e&&e.p!=null&&(t=null)}let N;O?(l(v===void 0),N=S.i):N=v;let P=(A==null?!O||y||D:N===void 0)?null:b.getComponent();if(A!=null){if(!(v!==void 0||O)){let e=k==null?n++:p[k];g[A]=e,x.write(`p`,e)}}else D&&(O||v!==void 0||(C.r,x.write(`r`,C.r)));let F=j?null:w(S),I=w(M);if((F||I)&&(F&&F.name,I&&I.name),F&&I){l(F===I);let e=T(S),t=T(M),n=F.compose(e,t);E(b,F,n),_.add(M)}else F?E(b,F,T(S)):I&&(E(b,I,T(M)),_.add(M));let L=typeof N==`object`&&!!N,ee=!1,R=0,te=0,ne=0,re=0,ie=0,z=o.advancer(a,(e,t)=>h(t)?re-e-1:e-re,(e,t)=>{h(t)&&re++}),ae=o.advancer(t,(e,t)=>m(t)?R-e-1:e-R,(e,t)=>{m(t)&&R++});if(o.eachChildOf(r,i,(t,n,r)=>{let i,a,o=t,s=t,c=t;if(typeof t==`number`){let e=t+ne;a=z(e),s=e+re;let u=t+te;i=ae(u),h(d(a))&&(i=null),o=u+R,c=t+ie,l(o>=0,`p1PickKey is negative`),l(s>=0,`p2DropKey is negative`);let f=h(d(n)),p=m(d(r));(f||p&&!j)&&ie--,f&&te--,p&&ne--}else i=ae(t),a=z(t);x.descend(o),b.descend(s);let u=L&&!h(d(n))?N[c]:void 0,f=e(i,n,r,a,u,j,b,x);var p,g,_;L&&!j?u!==f&&(ee||=(N=Array.isArray(N)?N.slice():Object.assign({},N),!0),p=N,_=f,typeof(g=c)==`number`?(l(Array.isArray(p)),l(g<p.length)):(l(!Array.isArray(p)),l(p[g]!==void 0)),_===void 0?typeof g==`number`?p.splice(g,1):delete p[g]:p[g]=_):l(f===void 0),b.ascend(),x.ascend()}),ae.end(),z.end(),P!=null)P.i=N;else if(!y&&!D&&A==null)return N}(r,r.clone(),i,i.clone(),void 0,!1,a,v),a.reset(),a.mergeTree(v.get()),a.reset(),a.get(),s.map(e=>e.get()),c.map(e=>e.get()),r.traverse(a,(e,t)=>{let n=e.p;if(n!=null){let e=p[n];e!=null&&t.write(`p`,e);let r=s[n];r&&r.get(),r&&t.mergeTree(r.get())}else e.r!==void 0&&t.write(`r`,e.r)}),a.reset(),a.get(),i.traverse(a,(e,t)=>{let n=e.d;if(n!=null){let e=g[n];e!=null&&t.write(`d`,e);let r=c[n];r&&t.mergeTree(r.get())}else e.i!==void 0&&t.write(`i`,e.i);let r=w(e);r&&!_.has(e)&&E(t,r,T(e))}),a.get()}function P(e){if(e==null)return null;let t=new o.ReadCursor(e),n=new o.WriteCursor,r,i=[],a=[];return function e(t,n,a){let o=t.getComponent(),s,c=!1;if(o){o.p!=null&&(n.write(`d`,o.p),i[o.p]=t.clone()),o.r!==void 0&&n.write(`i`,o.r),o.d!=null&&(n.write(`p`,o.d),a=void 0),o.i!==void 0&&(a=s=o.i);let e=w(o);e&&(a===void 0?(r||=/* @__PURE__ */ new Set,r.add(o)):(T(o),a=e.apply(a,T(o)),c=!0))}let l=0;for(let r of t){n.descend(r);let i=typeof r==`number`?r-l:r,o=y(a,i);h(t.getComponent())&&l++;let s=e(t,n,o);if(a!==void 0&&s!==void 0){if(c||(c=!0,a=p(a)),!v(a,i))throw Error(`Cannot modify child - invalid operation`);a[i]=s}n.ascend()}if(s===void 0)return c?a:void 0;n.write(`r`,a)}(t,n,void 0),r&&(n.reset(),function e(t,n,s){let c=n.getComponent();if(c){let e=c.d;if(e!=null&&(t=i[e],s=a[e]=o.writeCursor()),r.has(c)){let e=w(c);if(!e.invert)throw Error(`Cannot invert subtype ${e.name}`);E(s,e,e.invert(T(c)))}}let l=0,u=0,d=o.advancer(t,(e,t)=>m(t)?l-e-1:e-l,(e,t)=>{m(t)&&l++});for(let t of n)if(typeof t==`number`){let r=t-u,i=d(r),a=r+l;s.descend(a),e(i,n,s),h(n.getComponent())&&u++,s.ascend()}else s.descend(t),e(d(t),n,s),s.ascend();d.end()}(t.clone(),t,n),a.length&&(n.reset(),t.traverse(n,(e,t)=>{let n=e.p;if(n!=null){let e=a[n];e&&e.get(),e&&t.mergeTree(e.get())}}))),n.get()}let F=(e,t)=>e.some(e=>typeof e==`object`&&(Array.isArray(e)?F(e,t):t(e)));function I(e,t){if(e==null||!F(e,e=>{var t;return e.r!==void 0||((t=w(e))==null?void 0:t.makeInvertible)!=null}))return e;let n=new o.ReadCursor(e),r=new o.WriteCursor,i=!1,s=[],c=[],u=(e,t,n)=>{let r=e.getComponent(),o=!1;if(r){r.d!=null&&t.write(`d`,r.d),r.i!==void 0&&t.write(`i`,r.i);let a=r.p;if(a!=null&&(s[a]=e.clone(),l(n!==void 0,`Operation picks up at an invalid key`),c[a]=n,t.write(`p`,r.p)),r.r!==void 0&&n===void 0)throw Error(`Invalid doc / op in makeInvertible: removed item missing from doc`);let o=w(r);o&&(o.makeInvertible?i=!0:E(t,o,T(r),!0))}let d=0;for(let r of e){t.descend(r);let i=typeof r==`number`?r-d:r,a=y(n,i),s=u(e,t,a);a!==s&&(o||(o=!0,n=p(n)),s===void 0?(n=g(n,i),typeof r==`number`&&d++):n[i]=s),t.ascend()}return r&&(r.r===void 0?r.p!=null&&(n=void 0):(t.write(`r`,a.default(n)),n=void 0)),n};return u(n,r,t),r.get(),i&&(r.reset(),function e(t,n,r,i,a){let l=n.getComponent();if(l){l.i===void 0?l.d!=null&&(i=c[l.d],t=s[l.d],a=!1,l.d):(i=l.i,a=!0);let e=w(l);if(e&&e.makeInvertible){let t=T(l);E(r,e,e.makeInvertible(t,i),!0)}}let u=0,d=0,f=o.advancer(t,(e,t)=>m(t)?u-e-1:e-u,(e,t)=>{m(t)&&u++});for(let t of n)if(typeof t==`number`){let o=t-d,s=f(o),c=o+u,l=y(i,a?o:c);r.descend(t),e(s,n,r,l,a),h(n.getComponent())&&d++,r.ascend()}else{let o=y(i,t);r.descend(t),e(f(t),n,r,o,a),r.ascend()}f.end()}(n.clone(),n,r,t,!1)),r.get()}function L(e,t){return P(I(e,t))}let ee=e=>{if(e==null)return null;let t=e.slice();for(let n=0;n<e.length;n++){let e=t[n];Array.isArray(e)&&(t[n]=ee(e))}return t};function R(t,n,r){l(r===`left`||r===`right`,`Direction must be left or right`);let f=r===`left`?0:1;if(c.quiet=!u,c.prefix=0,n==null)return{ok:!0,result:t};k(t),k(n);let p=null,g=[],_=[],v=[],y=[],b=[],x=[],S=[],C=[],D=[],O=[],A=[],j=[],M=[],N=[],P=[],F=0,I=o.readCursor(t),L=o.readCursor(n),R=o.writeCursor();if(function e(t,n=null,r){let i=d(n);i&&(i.r===void 0?i.p!=null&&(r=null,x[i.p]=t.clone()):r=n.clone());let a=t.getComponent(),s;a&&(s=a.p)!=null&&(b[s]=n?n.clone():null,v[s]=t.clone(),r&&(O[s]=!0,D[s]=r),i&&i.p!=null&&(N[s]=i.p));let c=o.advancer(n);for(let n of t)e(t,c(n),r);c.end()}(L,I,null),function t(n,r,i,a,c){let l=i.getComponent(),u,h=!1;l&&((u=l.d)==null?l.i!==void 0&&(n=r=null,h=!0,c&&p==null&&(p={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.insertOp(i.getPath(),l.i)})):(y[u]=i.clone(),a!=null&&(P[a]??(P[a]=[]),P[a].push(u)),O[u],n=b[u]||null,r=v[u]||null,O[u]?(c&&(A[u]=!0),c=D[u]||null):!c||f!==1&&N[u]!=null||(p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.moveOp(r.getPath(),i.getPath())}),h=!0));let g=d(n);g&&(g.r===void 0?g.p!=null&&(g.p,a=g.p,c=null):c=n.clone());let _=w(l);_&&c&&p==null&&(p={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.removeOp(c.getPath()),op2:e.editOp(i.getPath(),_,T(l),!0)});let x=0,S=0,C=o.advancer(r,(e,t)=>m(t)?x-e-1:e-x,(e,t)=>{m(t)&&x++}),E=o.advancer(n);for(let e of i)if(typeof e==`number`){let n=e-S,r=C(n);S+=+t(E(n+x),r,i,a,c)}else{let n=C(e);t(E(e),n,i,a,c)}return C.end(),E.end(),h}(I,L,L.clone(),null,null),y.map(e=>e&&e.get()),p)return{ok:!1,conflict:p};A.map(e=>!!e);let te=[],ne=null;(function e(t,n,r,i,a){let s=!1,c=d(n);if(m(c)){let e=c.p;e==null?(r=null,a=n.clone()):(r=y[e],i=j[e]=o.writeCursor(),s=!0,a=null)}else h(d(r))&&(r=null);let u=t.getComponent();if(u){let e=u.p;e==null?u.r!==void 0&&(a||i.write(`r`,!0),(a||s)&&(ne??=/* @__PURE__ */ new Set,ne.add(u))):(a&&(C[e]=a),te[e]=a||f===1&&s?null:i.getComponent(),g[e]=t.clone(),r&&(S[e]=r.clone()))}let p=0,_=0,v=o.advancer(n,void 0,(e,t)=>{m(t)&&p++}),b=o.advancer(r,(e,t)=>h(t)?~(e-_):e-_,(e,t)=>{h(t)&&_++});if(t)for(let n of t)if(typeof n==`string`){let r=v(n),o=b(n);i.descend(n),e(t,r,o,i,a),i.ascend()}else{let r=v(n),o=n-p,s=m(d(r))?null:b(o),c=o+_;l(c>=0),i.descend(c),e(t,r,s,i,a),i.ascend()}v.end(),b.end()})(I,L,L.clone(),R,null),R.reset();let re=[];if(function t(n,c,u,b,D,k){l(c);let A=c.getComponent(),j=d(b),P=!1,I=(t,n,r)=>t?e.moveOp(t.getPath(),n.getPath()):e.insertOp(n.getPath(),r.i);if(h(A)){let t=A.d;t!=null&&(_[t]=c.clone());let r=t==null?null:te[t],o=!1;if(A.i!==void 0||t!=null&&r){let n;j&&(j.i!==void 0||(n=j.d)!=null&&!O[n])&&(o=n==null?i.default(j.i,A.i):t!=null&&t===N[n],o||n!=null&&f!==1&&N[n]!=null||(p??={type:s.ConflictType.DROP_COLLISION,op1:I(t==null?null:g[t],c,A),op2:I(n==null?null:v[n],b,j)})),o||(k?p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:I(t==null?null:g[t],c,A),op2:e.removeOp(k.getPath())}:(t==null?D.write(`i`,a.default(A.i)):(re[F]=t,D.write(`d`,r.p=F++)),P=!0))}else if(t!=null&&!r){let e=C[t];e&&(k=e.clone())}t==null?A.i!==void 0&&(n=u=null,o||(b=null)):(n=g[t],u=x[t],b=S[t])}else m(d(n))&&(n=u=b=null);let L=d(n),ee=d(u);if(m(ee)){let e=ee.p;ee.r!==void 0&&(!L||L.r===void 0)||O[e]?(b=null,k=u.clone()):e!=null&&(b=y[e],f!==1&&N[e]!=null||((D=M[e])||(D=M[e]=o.writeCursor()),D.reset(),k=null))}else!h(A)&&h(j)&&(b=null);j=b==null?null:b.getComponent();let R=w(A);if(R){let t=T(A);if(k)p??={type:s.ConflictType.RM_UNEXPECTED_CONTENT,op1:e.editOp(c.getPath(),R,t,!0),op2:e.removeOp(k.getPath())};else{let e=w(j),n;if(e){if(R!==e)throw Error(`Transforming incompatible types`);let i=T(j);n=R.transform(t,i,r)}else n=a.default(t);E(D,R,n)}}let ie=0,z=0,ae=0,oe=0,se=0,ce=0,le=n!=null&&n.descendFirst(),ue=le,de=o.advancer(u,void 0,(e,t)=>{m(t)&&ae++}),fe=b!=null&&b.descendFirst(),pe=fe;for(let e of c)if(typeof e==`number`){let r,i=h(c.getComponent()),a=e-z;{let e;for(;le&&typeof(e=n.getKey())==`number`;){e+=ie;let t=n.getComponent(),r=m(t);if(e>a||e===a&&(!r||f===0&&i))break;if(r){ie--;let e=t.p;te[e],N.includes(e),t.d,d(M[t.d]),m(d(M[t.d])),(t.r===void 0||ne&&ne.has(t))&&(e==null||!te[e]||f!==1&&N.includes(e))||se--}le=n.nextSibling()}r=le&&e===a?n:null}let o=a-ie,s=de(o),u=o-ae,p=null;{let e,t;for(;fe&&typeof(e=b.getKey())==`number`;){t=e-oe;let n=b.getComponent(),r=h(n);if(t>u)break;if(t===u){if(!r){p=b;break}{if(f===0&&i){p=b;break}let e=s&&m(s.getComponent());if(f===0&&e)break}}if(r){let e=n.d;O[e],N[e],n.i===void 0&&(O[e]||N[e]!=null&&f!==1)?(O[e]||N[e]!=null&&f===0)&&(oe++,ce--):oe++}fe=b.nextSibling()}}let g=u+oe+se+ce;l(g>=0,`trying to descend to a negative index`),D.descend(g),i&&(r=s=p=null,z++),t(r,c,s,p,D,k)&&ce++,D.ascend()}else{let r;for(;le&&(r=n.getKey(),typeof r!=`string`||!(r>e||r===e));)le=n.nextSibling();let i=le&&r===e?n:null,a=de(e),o;for(;fe&&(o=b.getKey(),typeof o!=`string`||!(o>e||o===e));)fe=b.nextSibling();let s=fe&&o===e?b:null;D.descend(e),t(i,c,a,s,D,k),D.ascend()}return de.end(),ue&&n.ascend(),pe&&b.ascend(),P}(I,I.clone(),L,L.clone(),R,null),p)return{ok:!1,conflict:p};R.reset();let ie=(e,t,n)=>e.traverse(t,(t,r)=>{t.d!=null&&n(t.d,e,r)});(O.length||j.length)&&(ie(L,R,(e,t,n)=>{O[e]&&!A[e]&&n.write(`r`,!0),j[e]&&n.mergeTree(j[e].get())}),R.reset());let z=[],ae=[];if((M.length||O.length)&&!p){let e=o.readCursor(ee(R.get()));if(ie(e,null,(e,t)=>{z[e]=t.clone()}),M.forEach(e=>{e&&ie(o.readCursor(e.get()),null,(e,t)=>{z[e]=t.clone()})}),function e(t,n,r,i,a,s){c.prefix++;let l=d(n);if(l&&m(l)){if(l.p!=null){a=l;let e=l.p;z[e].getPath(),r=z[e],i=ae[e]=o.writeCursor()}else l.r!==void 0&&(r=null,s=!0)}else h(d(r))&&(r=null);let u=t.getComponent();if(u){let e;if((e=u.d)!=null){let t=M[e];t&&(t.get(),i.mergeTree(t.get()),r=o.readCursor(t.get()))}}let f=0,p=0,g=o.advancer(n,void 0,(e,t)=>{m(t)&&f--}),_=o.advancer(r,(e,t)=>h(t)?-(e-p)-1:e-p,(e,t)=>{h(t)&&p++});for(let n of t)if(typeof n==`number`){let r=g(n),o=n+f,c=_(o),l=o+p;i.descend(l),e(t,r,c,i,a,s),i.ascend()}else i.descend(n),e(t,g(n),_(n),i,a,s),i.ascend();g.end(),_.end()}(L,e,e.clone(),R,null,!1),R.reset(),p)return{ok:!1,conflict:p};if(R.get(),ae.length){let e=ae.map(e=>e?e.get():null);if(ie(o.readCursor(ee(R.get())),R,(t,n,r)=>{let i=e[t];i&&(r.mergeTree(i),e[t]=null)}),e.find(e=>e)){let t=o.writeCursor(),n=o.writeCursor(),r=0,i=0;e.forEach(e=>{e!=null&&ie(o.readCursor(e),null,e=>{let a=re[e];t.writeMove(g[a].getPath(),_[a].getPath(),r++);let o=P[a];o&&o.forEach(e=>{O[e]||f!==1&&N[e]!=null||n.writeMove(v[e].getPath(),y[e].getPath(),i++)})})}),p={type:s.ConflictType.BLACKHOLE,op1:t.get(),op2:n.get()}}}}return p?{ok:!1,conflict:p}:{ok:!0,result:R.get()}}let te=e=>{let t=/* @__PURE__ */ Error(`Transform detected write conflict`);throw t.conflict=e,t.type=t.name=`writeConflict`,t};function ne(e,t,n){let r=R(e,t,n);if(r.ok)return r.result;te(r.conflict)}let re=e=>{let t=o.writeCursor();return o.readCursor(e).traverse(t,(e,t)=>{(h(e)||w(e))&&t.write(`r`,!0)}),t.get()},ie=(e,t)=>{let{type:n,op1:r,op2:i}=e;switch(n){case s.ConflictType.DROP_COLLISION:return t===`left`?[null,re(i)]:[re(r),null];case s.ConflictType.RM_UNEXPECTED_CONTENT:let e=!1;return o.readCursor(r).traverse(null,t=>{t.r!==void 0&&(e=!0)}),e?[null,re(i)]:[re(r),null];case s.ConflictType.BLACKHOLE:return[re(r),re(i)];default:throw Error(`Unrecognised conflict: `+n)}};function z(e,t,n,r){let i=null;for(;;){let a=R(t,n,r);if(a.ok)return N(i,a.result);{let{conflict:o}=a;e(o)||te(o);let[s,c]=ie(o,r);t=N(A(t),s),n=N(A(n),c),i=N(i,c)}}}})),sg=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),i(og(),e);var a=eg();Object.defineProperty(e,"ReadCursor",{enumerable:!0,get:function(){return a.ReadCursor}}),Object.defineProperty(e,"WriteCursor",{enumerable:!0,get:function(){return a.WriteCursor}});var o=tg();Object.defineProperty(e,"ConflictType",{enumerable:!0,get:function(){return o.ConflictType}})})))());let cg=`__textXPreserveParagraphIds`,lg=/* @__PURE__ */ function(e){return e.RETAIN=`r`,e.INSERT=`i`,e.DELETE=`d`,e}({});function ug(e){return{startOffset:e.startIndex,endOffset:e.endIndex+1}}function dg(e){return{startOffset:e.startIndex,endOffset:e.endIndex}}function fg(e){return dg(e)}function pg(e){return ug(e)}function mg(e){return ug(e)}function hg(e){return ug(e)}function gg(e){return{startOffset:e.startIndex,endOffset:e.startIndex+1}}function _g(e,t){return Eg(e,t,`\x1B`,``)}function vg(e,t){return Eg(e,t,``,``)}function yg(e,t){return e.startOffset<=t&&t<e.endOffset}function bg(e,t){return e.startOffset<t&&t<e.endOffset}function xg(e,t){return Math.max(e.startOffset,t.startOffset)<Math.min(e.endOffset,t.endOffset)}function Sg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>=t?{...e,endIndex:e.endIndex+n}:e}function Cg(e,t,n){return e.startIndex>=t?{...e,startIndex:e.startIndex+n,endIndex:e.endIndex+n}:e.endIndex>t?{...e,endIndex:e.endIndex+n}:e}function wg(e,t,n){if(n<=0||e.endIndex<t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>=r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t-1;return s>=o?{...e,startIndex:o,endIndex:s}:null}function Tg(e,t,n){if(n<=0||e.endIndex<=t)return e;let r=t+n;if(e.startIndex>=r)return{...e,startIndex:e.startIndex-n,endIndex:e.endIndex-n};let i=e.startIndex<t,a=e.endIndex>r;if(!i&&!a)return null;let o=i?e.startIndex:t,s=a?e.endIndex-n:t;return s>o?{...e,startIndex:o,endIndex:s}:null}function Eg(e,t,n,r){if(!Number.isInteger(t)||t<0||e[t]!==n)return null;let i=0;for(let a=t;a<e.length;a++){let o=e[a];if(o===n)i++;else if(o===r&&(i--,i===0))return{startOffset:t,endOffset:a+1}}return null}let Dg=`__textXRestoreParagraphIds`;function Og(e,t=!1){let n=[];for(let r of e){let{st:e,ed:i,ts:a}=r;if(r.sId===void 0&&delete r.sId,e===i||!t&&z.isEmptyObject(a)&&r.sId==null)continue;if(n.length===0){n.push(r);continue}let o=n.pop();ju(r,o)&&z.hasIntersectionBetweenTwoRanges(o.st,o.ed,r.st,r.ed)?n.push({...r,st:o.st,ed:i}):n.push(o,r)}return n}function kg(e,t,n,r){var i;let a=e.textRuns??[];if(e.textRuns==null&&!((i=t.textRuns)!=null&&i.some(e=>e.sId||Object.keys(e.ts??{}).length)))return;let o=[],s=a.length,c=!1,l=t.textRuns??[];if(l.length)for(let e of l)e.st+=r,e.ed+=r;for(let e=0;e<s;e++){let t=a[e],{st:i,ed:s}=t;if(s<=r)o.push(t);else if(r>i&&r<s){c=!0;let e={...t,ed:r};o.push(e),l.length&&o.push(...l);let i={...t,st:r+n,ed:s+n};o.push(i)}else t.st+=n,t.ed+=n,c||(c=!0,o.push(...l)),o.push(t)}c||(c=!0,o.push(...l)),e.textRuns=Og(o)}function Ag(e,t,n,r,i=!1,a=e.dataStream){var o;if(!e.paragraphs&&!((o=t.paragraphs)!=null&&o.length))return;e.paragraphs??=[];let{paragraphs:s}=e,{paragraphs:c}=t;i||jg(s,c,r,{freshenSplitParagraph:!0,preserveExplicitSplitParagraphIds:!!t[Dg],preserveExplicitParagraphIds:!!t[cg],dataStream:a});let l=[],u=-1;for(let e=0,t=s.length;e<t;e++){let t=s[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n),u===-1&&i>=r&&(u=e),l.push(t.startIndex)}let d=-1;if(c){for(let e=0,t=c.length;e<t;e++){let t=c[e];t.startIndex+=r;let n=t.startIndex;d=l.indexOf(n)}d!==-1&&s.splice(d,1),s.push(...c),s.sort(mf(`startIndex`))}}function jg(e,t,n,r){if(!e||!(t!=null&&t.length))return!1;let i=Fg(e,n,r.dataStream),a=i?Ig(t):-1,o=i==null?void 0:i.paragraphId,s=a===-1?void 0:t[a].paragraphId,c=(r.preserveExplicitSplitParagraphIds||r.preserveExplicitParagraphIds)&&s!=null&&s!==o,l=Mg(e),u=/* @__PURE__ */ new Set;o&&l.delete(o);for(let e of r.reservedParagraphIds??[])l.add(e);let d;if(o&&a!==-1&&!c){let e=t[a];d=s!=null&&s!==o?Ng(e,l,r.preserveMissingParagraphIds??!1):qh(e,l,!1),r.freshenSplitParagraph&&d.paragraphId&&(i.paragraphId=d.paragraphId)}for(let e=0,n=t.length;e<n;e++){let n=t[e].paragraphId;r.preserveExplicitParagraphIds&&n&&!u.has(n)?(t[e]={...t[e]},u.add(n)):e!==a||o==null||c?t[e]=Ng(t[e],l,r.preserveMissingParagraphIds??!1):t[e]=r.freshenSplitParagraph?qh({...t[e],paragraphId:o},l):d}for(let e of t)if(e.paragraphId){var f;(f=r.reservedParagraphIds)==null||f.add(e.paragraphId)}return i!=null}function Mg(e){let t=/* @__PURE__ */ new Set;for(let n of e??[])n.paragraphId&&t.add(n.paragraphId);return t}function Ng(e,t,n){return n&&e.paragraphId==null?z.deepClone(e):qh(e,t)}let Pg=/* @__PURE__ */ new Set([`
|
|
5
|
+
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function Fg(e,t,n){let r=[...e].sort((e,t)=>e.startIndex-t.startIndex);for(let e=0;e<r.length;e++){let i=r[e],a=e>0?r[e-1].startIndex+1:0;for(;a<i.startIndex;){let e=n==null?void 0:n[a];if(!e||!Pg.has(e))break;a++}if(t>a&&t<i.startIndex)return i}}function Ig(e){let t=0;for(let n=1;n<e.length;n++)e[n].startIndex<e[t].startIndex&&(t=n);return t}function Lg(e,t,n,r){var i;if(!e.sectionBreaks&&!((i=t.sectionBreaks)!=null&&i.length))return;e.sectionBreaks??=[];let{sectionBreaks:a}=e,o=t.sectionBreaks;Rg(a,o);for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(mf(`startIndex`))}}function Rg(e,t,n=/* @__PURE__ */ new Set){if(!(t!=null&&t.length))return;let r=new Set((e==null?void 0:e.map(e=>e.sectionId))??[]);for(let e of n)r.add(e);for(let e=0;e<t.length;e++)t[e]=Sm(t[e],r),n.add(t[e].sectionId)}function zg(e,t,n,r,i){if(e[i]==null&&t[i]==null)return;let a=e[i]??[];for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n)}let o=t[i];if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r}a.push(...o),a.sort(mf(`startIndex`))}a.length&&!e[i]&&(e[i]=a)}function Bg(e,t,n,r){zg(e,t,n,r,`customBlocks`)}function Vg(e,t,n,r){zg(e,t,n,r,`docxRawCustomBlocks`)}function Hg(e,t,n,r){if(e.docxRawBlocks==null&&t.docxRawBlocks==null)return;let i=e.docxRawBlocks??[];i.forEach(e=>{e.startIndex>=r&&(e.startIndex+=n)}),i.push(...(t.docxRawBlocks??[]).map(e=>({...e,startIndex:e.startIndex+r}))),i.sort(mf(`startIndex`)),e.docxRawBlocks=i}function Ug(e){let t=[...e].sort((e,t)=>e.start-t.start||e.end-t.end),n=[];for(let e of t){let t=n[n.length-1];t&&e.start<=t.end?t.end=Math.max(t.end,e.end):e.end>e.start&&n.push({...e})}return n}function Wg(e,t,n,r){if(e.docxExportExcludedRanges==null&&t.docxExportExcludedRanges==null)return;let i=(e.docxExportExcludedRanges??[]).map(e=>{let t=Cg({startIndex:e.start,endIndex:e.end},r,n);return{start:t.startIndex,end:t.endIndex}}),a=(t.docxExportExcludedRanges??[]).map(e=>({start:e.start+r,end:e.end+r}));e.docxExportExcludedRanges=Ug([...i,...a])}function Gg(e,t,n,r){var i;if(!e.tables&&!((i=t.tables)!=null&&i.length))return;e.tables||=[];let{tables:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,Cg(t,r,n))}let o=t.tables;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(mf(`startIndex`))}}function Kg(e,t,n,r){var i;if(!e.columnGroups&&!((i=t.columnGroups)!=null&&i.length))return;e.columnGroups||=[];let{columnGroups:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,Sg(t,r,n))}let o=t.columnGroups;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(mf(`startIndex`))}}function qg(e,t,n,r){var i;if(!e.blockRanges&&!((i=t.blockRanges)!=null&&i.length))return;e.blockRanges||=[];let{blockRanges:a}=e;for(let e=0,t=a.length;e<t;e++){let t=a[e];Object.assign(t,Sg(t,r,n))}let o=t.blockRanges;if(o){for(let e=0,t=o.length;e<t;e++){let t=o[e];t.startIndex+=r,t.endIndex+=r}a.push(...o),a.sort(mf(`startIndex`))}}let Jg=e=>e.split(`$`)[0];function Yg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n=/* @__PURE__ */ new Map;for(let r of e){let e={...r,rangeId:Jg(r.rangeId)},i=n.get(e.rangeId);i&&e.rangeType===i.rangeType&&Bp(i.properties,e.properties)&&i.endIndex+1>=e.startIndex?i.endIndex=Math.max(i.endIndex,e.endIndex):(t.push(e),n.set(e.rangeId,e))}let r=Object.create(null);for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.rangeId;r[i]?(n.rangeId=`${i}$${r[i]}`,r[i]=r[i]+1):r[i]=1}return t}function Xg(e,t){let n=e.filter(e=>{var n;return e.rangeType!==1&&e.rangeType!==2&&e.rangeType!==3&&(e.rangeType!==5||((n=e.properties)==null?void 0:n.kind)!==`docx-permission`)&&e.startIndex<t&&e.endIndex>=t});for(let r of n){let n=e.indexOf(r);e.splice(n,1,{...r,endIndex:t-1,properties:{...r.properties}},{...r,startIndex:t,properties:{...r.properties}})}}function Zg(e){if(e.length<=1)return e;e.sort((e,t)=>e.startIndex-t.startIndex);let t=[],n={...e[0]};for(let r=1;r<e.length;r++){let i=e[r];i.id===n.id&&n.endIndex+1>=i.startIndex?n.endIndex=i.endIndex:(t.push(n),n={...i})}return t.push(n),t}function Qg(e,t){e.filter(e=>e.startIndex<t&&e.endIndex>=t).forEach(n=>{let r=e.indexOf(n);e.splice(r,1,{id:n.id,type:n.type,startIndex:n.startIndex,endIndex:t-1},{id:n.id,type:n.type,startIndex:t,endIndex:n.endIndex})})}function $g(e,t,n,r){e.customRanges||=[];let{customRanges:i}=e;Xg(i,r);for(let e=0,t=i.length;e<t;e++){var a;let t=i[e],{startIndex:o}=t;(t.rangeType===1||t.rangeType===2||t.rangeType===3||t.rangeType===5&&((a=t.properties)==null?void 0:a.kind)===`docx-permission`)&&o<r&&t.endIndex>=r?t.endIndex+=n:o>=r&&(t.startIndex+=n,t.endIndex+=n)}let o=[];if(t.customRanges){for(let e=0,n=t.customRanges.length;e<n;e++){let n=t.customRanges[e],a=n.rangeType===2?i.find(e=>e.rangeType===2&&e.rangeId===n.rangeId):void 0;a?(a.startIndex=Math.min(a.startIndex,r+n.startIndex),a.endIndex=Math.max(a.endIndex,r+n.endIndex),a.properties=z.deepClone(n.properties),a.wholeEntity=n.wholeEntity,i.splice(i.indexOf(a),0,...o.splice(0))):(n.startIndex+=r,n.endIndex+=r,o.push(n))}i.push(...o)}e.customRanges=Yg(i)}function e_(e,t,n,r){var i;if(e.customDecorations==null&&!((i=t.customDecorations)!=null&&i.length))return;e.customDecorations||=[];let{customDecorations:a}=e;Qg(a,r);for(let e=0,t=a.length;e<t;e++){let t=a[e],{startIndex:i}=t;i>=r&&(t.startIndex+=n,t.endIndex+=n)}let o=[];if(t.customDecorations){for(let e=0,n=t.customDecorations.length;e<n;e++){let n=t.customDecorations[e];n.startIndex+=r,n.endIndex+=r,o.push(n)}a.push(...o)}e.customDecorations=Zg(a)}function t_(e,t,n){let{textRuns:r}=e,i=n,a=n+t,o=[];if(r){let n=[];for(let e=0,s=r.length;e<s;e++){let s=r[e],{st:c,ed:l}=s;i<=c&&a>=l?o.push({...s,st:c-i,ed:l-i}):(c<=i&&l>=a?(o.push({...s,st:i-i,ed:a-i}),s.ed-=t):i>=c&&i<l?(o.push({...s,st:i-i,ed:l-i}),s.ed=i):a>c&&a<=l?(o.push({...s,st:c-i,ed:a-i}),s.st=a-t,s.ed-=t):c>=a&&(s.st-=t,s.ed-=t),n.push(s))}e.textRuns=n}return o.length===0&&o.push({st:0,ed:t,ts:{}}),o}function n_(e,t,n){let{paragraphs:r}=e,i=n,a=n+t,o=[],s=null,c=!1;if(r){let l=[];for(let e=0,u=r.length;e<u;e++){let u=r[e],{startIndex:d}=u;d>=i&&d<a?(o.push({...u,startIndex:d-n}),c=!0):(d>=a&&(u.startIndex-=t),l.push(u),s==null&&c&&(s=u))}e.paragraphs=l}return o}function r_(e,t,n){let{sectionBreaks:r}=e,i=n,a=n+t-1,o=[];if(r){let s=[];for(let e=0,c=r.length;e<c;e++){let c=r[e],{startIndex:l}=c;l>=i&&l<=a?o.push({...c,startIndex:l-n}):(l>a&&(c.startIndex-=t),s.push(c))}e.sectionBreaks=s}return o}function i_(e,t,n,r){let i=e[r];if(i==null)return;let a=n,o=n+t-1,s=[],c=[];for(let e=0,r=i.length;e<r;e++){let r=i[e],{startIndex:l}=r;l>=a&&l<=o?s.push({...r,startIndex:l-n}):(l>o&&(r.startIndex-=t),c.push(r))}return e[r]=c,i.length&&!e[r]&&(e[r]=i),s}function a_(e,t,n){return e.customBlocks??=[],i_(e,t,n,`customBlocks`)}function o_(e,t,n){return i_(e,t,n,`docxRawCustomBlocks`)}function s_(e,t,n){if(e.docxRawBlocks==null)return;let r=n+t,i=[],a=[];for(let o of e.docxRawBlocks)o.startIndex>=n&&o.startIndex<r?i.push({...o,startIndex:o.startIndex-n}):a.push(o.startIndex>=r?{...o,startIndex:o.startIndex-t}:o);return e.docxRawBlocks=a,i}function c_(e,t,n){if(e.docxExportExcludedRanges==null)return;let r=n+t,i=[],a=[];for(let o of e.docxExportExcludedRanges){let e=Math.max(o.start,n),s=Math.min(o.end,r);s>e&&i.push({start:e-n,end:s-n});let c=Tg({startIndex:o.start,endIndex:o.end},n,t);c&&a.push({start:c.startIndex,end:c.endIndex})}return e.docxExportExcludedRanges=Ug(a),i}function l_(e,t,n){let{tables:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=Tg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n})}e.tables=a}return i}function u_(e,t,n){let{columnGroups:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=wg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push({...o,startIndex:o.startIndex-n,endIndex:o.endIndex-n})}e.columnGroups=a}return i}function d_(e,t,n){let{customRanges:r}=e,i=[];if(r){let a=new Map(r.filter(e=>e.rangeType===2).map(e=>[e,e.endIndex-e.startIndex])),o=/* @__PURE__ */ new Map,s=[];for(let e=0,a=r.length;e<a;e++){let a=r[e],c=wg(a,n,t);if(!c)i.push(a);else{if(Object.assign(a,c),a.rangeType===2){let e=`${a.startIndex}:${a.endIndex}`,t=o.get(e)??[];t.push(s.length),o.set(e,t)}s.push(a)}}for(let e of o.values()){if(e.length<2)continue;let t=e.map(e=>s[e]).sort((e,t)=>a.get(e)-a.get(t));e.forEach((e,n)=>{s[e]=t[n]})}e.customRanges=Yg(s)}return i}function f_(e,t,n){let{blockRanges:r}=e,i=[];if(r){let a=[];for(let e=0,o=r.length;e<o;e++){let o=r[e],s=wg(o,n,t);s?(Object.assign(o,s),a.push(o)):i.push(o)}e.blockRanges=a}return i}function p_(e,t,n,r=!0){let{customDecorations:i}=e,a=n,o=n+t-1,s=[];if(i){let n=[];for(let e=0,c=i.length;e<c;e++){let c=i[e],{startIndex:l,endIndex:u}=c;if(l>=a&&u<=o)s.push(c);else{if(Math.max(a,l)<=Math.min(o,u)){let e=id(l,u,a,o);if(e.length===0)continue;c.startIndex=e[0],c.endIndex=e[1]}else o<l&&r&&(c.startIndex-=t,c.endIndex-=t);n.push(c)}}e.customDecorations=n}return s}function m_(e,t,n,r,i){return{dataStream:``,textRuns:h_(e,t,n,r,i),paragraphs:__(e,t,n,r,i),sectionBreaks:v_(e,t,n,r,i),customBlocks:y_(e,t,n,r,i),docxRawCustomBlocks:b_(e,t,n,r,i),tables:x_(e,t,n,r,i),columnGroups:S_(e,t,n,r,i),blockRanges:C_(e,t,n,r,i),customRanges:w_(e,t,n,r,i),customDecorations:T_(e,t,n,r,i)}}function h_(e,t,n,r,i){let{textRuns:a}=t;if(a==null||e.textRuns==null&&!a.some(e=>e.sId||Object.keys(e.ts??{}).length))return;e.textRuns??=[];let o=t_(e,n,r);return i!==1&&(t.textRuns=g_(a,o,i)),kg(e,t,n,r),o}function g_(e,t,n){if(t.length===0)return e;e=z.deepClone(e),t=z.deepClone(t);let r=[],i=e.length,a=t.length,o=0,s=0,c=null;function l(){return c?(r.push(c),c=null,!0):!1}for(;o<i&&s<a;){let{st:i,ed:a,ts:u}=e[o],{st:d,ed:f,ts:p,sId:m}=t[s],h;if(h=n===0?{...p,...u}:{...u},a<d)l()||r.push(e[o]),o++;else if(f<i)l()||r.push(t[s]),s++;else{let n={st:Math.min(i,d),ed:Math.max(i,d),ts:i<d?{...u}:{...p},sId:i<d?void 0:m};n.ed>n.st&&r.push(n),r.push({st:Math.max(i,d),ed:Math.min(a,f),ts:h,sId:m}),a<f?(o++,t[s].st=a,t[s].st===t[s].ed&&s++):(s++,e[o].st=f,e[o].st===e[o].ed&&o++);let l={st:Math.min(a,f),ed:Math.max(a,f),ts:a<f?{...p}:{...u},sId:a<f?m:void 0};c=l.ed>l.st?l:null}}l();let u=r[r.length-1],d=e[i-1],f=t[a-1];return u&&u.ed!==Math.max(d.ed,f.ed)&&(d.ed>f.ed?r.push(d):r.push(f)),Og(r)}function __(e,t,n,r,i){let{paragraphs:a}=e,{paragraphs:o}=t;if(a==null||o==null)return;let s=n_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,paragraphId:r}=t;for(let a of s){if(n!==a.startIndex)continue;let[o,s]=i===0?[a,t]:[t,a],c=o.bullet==null?o.bullet:{...o.bullet};s.bullet===null?c=null:s.bullet!==void 0&&(c={...c,...s.bullet});let l={...o,...s,startIndex:n,paragraphId:r??a.paragraphId,paragraphStyle:{...o.paragraphStyle,...s.paragraphStyle}};c===void 0?delete l.bullet:l.bullet=c,e.push(l);break}}t.paragraphs=e}else for(let e of o){let t=s.find(t=>t.startIndex===e.startIndex);t&&e.paragraphId==null&&(e.paragraphId=t.paragraphId)}return Ag(e,t,n,r,!0),s}function v_(e,t,n,r,i){let{sectionBreaks:a}=e,{sectionBreaks:o}=t;if(a==null||o==null)return;let s=r_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.sectionBreaks=e.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e})}else t.sectionBreaks=o.map(e=>{let t=s.find(t=>t.startIndex===e.startIndex);return t?{...e,sectionId:t.sectionId}:e});return Lg(e,t,n,r),s}function y_(e,t,n,r,i){let{customBlocks:a=[]}=e,{customBlocks:o}=t;if(a==null||o==null)return;let s=a_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let{startIndex:n}=t,r=[];for(let e of s){let{startIndex:a}=e;if(n===a){i===0?r.push({...e,...t}):r.push({...t,...e});break}}e.push(...r),r=[]}t.customBlocks=e}return Bg(e,t,n,r),a.length&&!e.customBlocks&&(e.customBlocks=a),s}function b_(e,t,n,r,i){let a=e.docxRawCustomBlocks,o=t.docxRawCustomBlocks;if(a==null||o==null)return;let s=o_(e,n,r)??[];if(i!==1){let e=[];for(let t of o){let n=s.find(e=>e.startIndex===t.startIndex);n&&e.push(i===0?{...n,...t}:{...t,...n})}t.docxRawCustomBlocks=e}return Vg(e,t,n,r),a.length&&!e.docxRawCustomBlocks&&(e.docxRawCustomBlocks=a),s}function x_(e,t,n,r,i){let{tables:a}=e,{tables:o}=t;if(a==null||o==null)return;let s=l_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.tables=e}return Gg(e,t,n,r),s}function S_(e,t,n,r,i){let{columnGroups:a}=e,{columnGroups:o}=t;if(a==null||o==null)return;let s=u_(e,n,r);if(i!==1){let e=[];for(let t of o){let{startIndex:n,endIndex:r}=t,a=[];for(let e of s){let{startIndex:o,endIndex:s}=e;if(o>=n&&s<=r){i===0?a.push({...e,...t}):a.push({...t,...e});break}}e.push(...a),a=[]}t.columnGroups=e}return Kg(e,t,n,r),s}function C_(e,t,n,r,i){let{blockRanges:a}=e,{blockRanges:o}=t;if(a==null||o==null)return;let s=f_(e,n,r);return i!==1&&(t.blockRanges=o.map(e=>{let t=s.find(t=>t.blockId===e.blockId);return t?{...t,...e}:e})),qg(e,t,n,r),s}function w_(e,t,n,r,i){e.customRanges||=[],Xg(e.customRanges,r),Xg(e.customRanges,r+n);let a=r,o=r+n-1,{customRanges:s}=t,c=[],l=/* @__PURE__ */ new Map;e.customRanges.forEach(e=>{let{startIndex:t,endIndex:n}=e;t>=a&&n<=o?l.set(e.rangeId,e):c.push(e)});let u=[];if(!s)return[];s.forEach(e=>{let{startIndex:t,endIndex:i}=e,a=e.rangeType===2?c.find(t=>t.rangeType===2&&t.rangeId===e.rangeId):void 0;a?(t>0&&(a.startIndex=t+r),i<n-1&&(a.endIndex=i+r),a.properties=z.deepClone(e.properties),a.wholeEntity=e.wholeEntity):c.push({...e,startIndex:t+r,endIndex:i+r})});let d=new Map(s.map((e,t)=>[e.rangeId,t])),f=/* @__PURE__ */ new Map;c.forEach((e,t)=>{if(e.rangeType!==2||!d.has(e.rangeId))return;let n=`${e.startIndex}:${e.endIndex}`,r=f.get(n)??[];r.push(t),f.set(n,r)});for(let e of f.values()){let t=e.map(e=>c[e]).sort((e,t)=>d.get(e.rangeId)-d.get(t.rangeId));e.forEach((e,n)=>{c[e]=t[n]})}return e.customRanges=Yg(c),u}function T_(e,t,n,r,i){var a;if(e.customDecorations==null&&!((a=t.customDecorations)!=null&&a.length))return;e.customDecorations||=[],Qg(e.customDecorations,r),Qg(e.customDecorations,r+n);let o=[],{customDecorations:s}=e,{customDecorations:c=[]}=t;if(i===1){for(let e=0;e<s.length;e++){let t=s[e],{startIndex:i,endIndex:a}=t;i>=r&&a<=r+n-1&&o.push(t)}c.forEach(e=>{let{startIndex:t,endIndex:n}=e;s.push({...e,startIndex:t+r,endIndex:n+r})})}else for(let e of c){let{id:t}=e;if(e.type===9999){let e=s.filter(e=>e.id===t);e.length&&o.push(...e)}else s.push({...e,startIndex:e.startIndex+r,endIndex:e.endIndex+r})}for(let e of o){let{id:t}=e,n=s.findIndex(e=>e.id===t);n!==-1&&s.splice(n,1)}return e.customDecorations=Zg(s),o}function E_(e,t){var n;if(t.bullet===null)return;let r=[],i=/* @__PURE__ */ new Set,a=t.styleId??((n=e.documentStyle)==null?void 0:n.defaultParagraphStyleId);for(;a&&!i.has(a);){var o;i.add(a);let t=(o=e.styles)==null?void 0:o[a];if(!t||t.type!==1)break;r.unshift(t),a=t.basedOn}let s={};for(let e of[...r.map(e=>e.bullet),t.bullet])e===null?s={}:((e==null?void 0:e.listId)!=null&&e.listId!==s.listId&&e.listType==null&&delete s.listType,s={...s,...e});let{listId:c,nestingLevel:l=0}=s;if(c==null||c===`0`)return;let u=Object.keys(e.lists??{}).find(t=>{var n;return(n=e.lists)==null||(n=n[t].counterIds)==null?void 0:n.includes(c)}),d=s.listType??u??c;return{...s,listId:c,listType:d,nestingLevel:l}}function D_(e){if(e==null)return{};let t=z.deepClone(e);z.removeNull(t);for(let r of[`textStyle`,`paragraphMarkTextStyle`]){var n;((n=e[r])==null?void 0:n.eastAsiaFontTheme)===null&&((t[r]??={}).eastAsiaFontTheme=null)}return t}function O_(e,t,n){if(t.u===n){let r=t.fallback??((e==null?void 0:e.u)===n?e.fallback:e==null?void 0:e.v);return r==null?{...t}:{...t,fallback:r}}return(e==null?void 0:e.u)===n?{...e,fallback:t.v}:{...t}}function k_(e,t){for(let i of[`indentStart`,`indentEnd`,`indentFirstLine`,`hanging`]){let a=t[i];if(a!=null){if(i===`indentFirstLine`||i===`hanging`){var n;let t=i===`hanging`?`indentFirstLine`:`hanging`;if(a.u===2&&((n=e[t])==null?void 0:n.u)===2&&(e[t]={...e[t],v:0}),a.u!==2||a.fallback!=null){var r;((r=e[t])==null?void 0:r.u)===2?(e[t]={...e[t]},delete e[t].fallback):delete e[t]}}e[i]=O_(e[i],a,2)}}}function A_(e,t,n=!1){var r;let i=(t==null||(r=t.indentFirstLine)==null?void 0:r.u)===2&&t.indentFirstLine.v===0;!n&&(t==null?void 0:t.indentFirstLine)!=null&&t.hanging==null&&!i?delete e.hanging:!n&&(t==null?void 0:t.hanging)!=null&&t.indentFirstLine==null&&delete e.indentFirstLine;let a=e.tabStops,o={indentStart:e.indentStart,indentEnd:e.indentEnd,indentFirstLine:e.indentFirstLine,hanging:e.hanging,spaceAbove:e.spaceAbove,spaceBelow:e.spaceBelow};if(Object.assign(e,t),n&&t){Object.assign(e,o),k_(e,t);for(let n of[`spaceAbove`,`spaceBelow`]){let r=t[n];r!=null&&(e[n]=O_(e[n],r,1))}}if(a&&t!=null&&t.tabStops){let n=new Map(a.map(e=>[e.offset,e]));for(let e of t.tabStops)n.set(e.offset,e);e.tabStops=[...n.values()].sort((e,t)=>e.offset-t.offset)}}function j_(e,t){let n=[],r=/* @__PURE__ */ new Set,i=t;for(;i&&!r.has(i);){r.add(i);let t=e==null?void 0:e[i];if(!t)break;n.unshift(t.textStyle??{}),i=t.basedOn??(t.type===0?t.link:void 0)}return Object.assign({},...n)}function M_(e,t,n){if(!e||!t)return{};let r=/* @__PURE__ */ new Set,i=t=>{if(r.has(t))return{};let a=e[t];if(!a||a.type!==1)return{};r.add(t);let o=a.basedOn?i(a.basedOn):{};r.delete(t);let s=D_(a.paragraphStyle),c={...o};A_(c,s,n);let l={...o.textStyle,...a.textStyle,...s.textStyle};return Object.keys(l).length&&(c.textStyle=l),c};return i(t)}function N_(e,t,n={}){var r,i;let a=n.useLegacyModernDefaults??(e==null?void 0:e.documentFlavor)===2?{lineSpacing:Rh,spaceAbove:{v:0},spaceBelow:{v:12}}:{},o={...(e==null?void 0:e.documentFlavor)===1?{widowControl:1}:{},...a,...D_(e==null?void 0:e.defaultParagraphStyle)};n.excludeDocumentOuterSpacing&&(delete o.spaceAbove,delete o.spaceBelow);let s=D_(t),c=n.paragraphStyleId??(s.namedStyleType==null||s.namedStyleType===0||s.namedStyleType===1?e==null?void 0:e.defaultParagraphStyleId:void 0),l=M_(n.styles,c,(e==null?void 0:e.documentFlavor)===1),u=E_({styles:n.styles,lists:n.lists},{styleId:c,bullet:n.bullet}),d=u&&((r=n.lists)==null||(r=r[u.listType])==null||(r=r.nestingLevel[u.nestingLevel])==null?void 0:r.paragraphProperties),f=(e==null?void 0:e.documentFlavor)===1,p={};for(let e of[`indentStart`,`indentEnd`,`indentFirstLine`,`hanging`]){let t=d==null?void 0:d[e];f&&t!=null&&(p[e]=t)}let m=f&&n.bullet!=null?p:{};f&&n.bullet===null&&Object.assign(m,{indentStart:{v:0},indentFirstLine:{v:0},hanging:{v:0}});let h=s.namedStyleType??l.namedStyleType,g=c!=null&&((i=n.styles)==null||(i=i[c])==null?void 0:i.type)===1,_=h==null||g&&l.namedStyleType==null?null:zh[h],v={};for(let e of[o,_,p,l,m,s])A_(v,e,f);if(f){var y,b;((y=v.indentFirstLine)==null?void 0:y.u)===2&&v.indentFirstLine.v!==0?delete v.hanging:((b=v.hanging)==null?void 0:b.u)===2&&v.hanging.v!==0&&delete v.indentFirstLine}let x={...e==null?void 0:e.textStyle,...o.textStyle,...D_(_).textStyle,...l.textStyle,...s.textStyle};if(Object.keys(x).length&&(v.textStyle=x),v.paragraphMarkStyleId!=null){let e=j_(n.styles,v.paragraphMarkStyleId);Object.keys(e).length&&(v.paragraphMarkTextStyle={...e,...v.paragraphMarkTextStyle})}return z.deepClone(v)}function P_(e,t,n){var r;let i=z.deepClone({...t.paragraphStyle,...n});if(((r=e.documentStyle)==null?void 0:r.documentFlavor)!==1)return i;let a=N_(e.documentStyle,t.paragraphStyle,{styles:e.styles,lists:e.lists,paragraphStyleId:t.styleId,bullet:t.bullet});for(let e of[`indentStart`,`indentEnd`,`indentFirstLine`,`hanging`]){var o;let t=n[e],r=e===`hanging`?a.indentFirstLine:a.hanging,s=((o=a[e])==null?void 0:o.u)===2||(e===`indentFirstLine`||e===`hanging`)&&(r==null?void 0:r.u)===2;t!=null&&t.u!==2&&s&&(i[e]={v:0,u:2,fallback:t.v},e===`indentFirstLine`&&n.hanging==null?delete i.hanging:e===`hanging`&&n.indentFirstLine==null&&delete i.indentFirstLine)}for(let e of[`spaceAbove`,`spaceBelow`]){var s;let t=n[e];t!=null&&t.u!==1&&((s=a[e])==null?void 0:s.u)===1&&(i[e]={v:0,u:1,fallback:t.v})}return i}function F_(e,t){let{documentStyle:n}=e,{wordWrap:r}=N_(n,t==null?void 0:t.paragraphStyle,{styles:e.styles,paragraphStyleId:t==null?void 0:t.styleId});return r??0}let I_=/* @__PURE__ */ function(e){return e.ORDER_LIST_QUICK_1=`1.`,e.ORDER_LIST_QUICK_2=`a)`,e.ORDER_LIST_QUICK_3=`a.`,e.ORDER_LIST_QUICK_4=`i.`,e.ORDER_LIST_QUICK_5=`A.`,e.ORDER_LIST_QUICK_6=`I.`,e.ORDER_LIST_QUICK_7=`01.`,e.BULLET_LIST=`*`,e}({}),L_=/* @__PURE__ */ function(e){return e.BULLET_LIST=`BULLET_LIST`,e.BULLET_LIST_1=`BULLET_LIST_1`,e.BULLET_LIST_2=`BULLET_LIST_2`,e.BULLET_LIST_3=`BULLET_LIST_3`,e.BULLET_LIST_4=`BULLET_LIST_4`,e.BULLET_LIST_5=`BULLET_LIST_5`,e.ORDER_LIST=`ORDER_LIST`,e.ORDER_LIST_1=`ORDER_LIST_1`,e.ORDER_LIST_2=`ORDER_LIST_2`,e.ORDER_LIST_3=`ORDER_LIST_3`,e.ORDER_LIST_4=`ORDER_LIST_4`,e.ORDER_LIST_5=`ORDER_LIST_5`,e.ORDER_LIST_QUICK_2=`ORDER_LIST_QUICK_2`,e.ORDER_LIST_QUICK_3=`ORDER_LIST_QUICK_3`,e.ORDER_LIST_QUICK_4=`ORDER_LIST_QUICK_4`,e.ORDER_LIST_QUICK_5=`ORDER_LIST_QUICK_5`,e.ORDER_LIST_QUICK_6=`ORDER_LIST_QUICK_6`,e.CHECK_LIST=`CHECK_LIST`,e.CHECK_LIST_CHECKED=`CHECK_LIST_CHECKED`,e}({}),R_={"a)":{glyphFormat:`%1)`,glyphType:2},"1.":{glyphFormat:`%1.`,glyphType:2},"a.":{glyphFormat:`%1.`,glyphType:5},"A.":{glyphFormat:`%1.`,glyphType:4},"i.":{glyphFormat:`%1.`,glyphType:7},"I.":{glyphFormat:`%1.`,glyphType:4}},z_=e=>[...e,...e,...e].map((e,t)=>({glyphFormat:` %${t+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),B_=e=>e.map((e,t)=>({...e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(t+1)}}})),V_=(e,t)=>Array(9).fill(0).map((n,r)=>({glyphFormat:` %${r+1}`,glyphSymbol:e,bulletAlignment:1,startNumber:0,paragraphProperties:{hanging:{v:21},indentStart:{v:21*(r+1)},textStyle:t}})),H_={BULLET_LIST:{listType:`BULLET_LIST`,nestingLevel:z_([`●`,`○`,`■`])},BULLET_LIST_1:{listType:`BULLET_LIST`,nestingLevel:z_([`❖`,`➢`,`■`])},BULLET_LIST_2:{listType:`BULLET_LIST`,nestingLevel:z_([`✔`,`●`,`◆`])},BULLET_LIST_3:{listType:`BULLET_LIST`,nestingLevel:z_([`■`,`◆`,`○`])},BULLET_LIST_4:{listType:`BULLET_LIST`,nestingLevel:z_([`✦`,`○`,`■`])},BULLET_LIST_5:{listType:`BULLET_LIST`,nestingLevel:z_([`➢`,`○`,`◆`])},ORDER_LIST:{listType:`ORDER_LIST`,nestingLevel:B_([{glyphFormat:`%1.`,glyphType:2},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:2},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:2},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_1:{listType:`ORDER_LIST`,nestingLevel:B_([{glyphFormat:`%1)`,glyphType:2},{glyphFormat:`%2)`,glyphType:5},{glyphFormat:`%3)`,glyphType:7},{glyphFormat:`%4)`,glyphType:2},{glyphFormat:`%5)`,glyphType:5},{glyphFormat:`%6)`,glyphType:7},{glyphFormat:`%7)`,glyphType:2},{glyphFormat:`%8)`,glyphType:5},{glyphFormat:`%9)`,glyphType:7}])},ORDER_LIST_2:{listType:`ORDER_LIST`,nestingLevel:B_([`%1.`,`%1.%2.`,`%1.%2.%3.`,`%1.%2.%3.%4.`,`%1.%2.%3.%4.%5.`,`%1.%2.%3.%4.%5.%6.`,`%1.%2.%3.%4.%5.%6.%7.`].map(e=>({glyphFormat:e,glyphType:2})))},ORDER_LIST_3:{listType:`ORDER_LIST`,nestingLevel:B_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_4:{listType:`ORDER_LIST`,nestingLevel:B_([{glyphFormat:`%1.`,glyphType:4},{glyphFormat:`%2.`,glyphType:2},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:4},{glyphFormat:`%5.`,glyphType:2},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:4},{glyphFormat:`%8.`,glyphType:2},{glyphFormat:`%9.`,glyphType:7}])},ORDER_LIST_5:{listType:`ORDER_LIST`,nestingLevel:B_([{glyphFormat:`%1.`,glyphType:3},{glyphFormat:`%2.`,glyphType:5},{glyphFormat:`%3.`,glyphType:7},{glyphFormat:`%4.`,glyphType:3},{glyphFormat:`%5.`,glyphType:5},{glyphFormat:`%6.`,glyphType:7},{glyphFormat:`%7.`,glyphType:3},{glyphFormat:`%8.`,glyphType:5},{glyphFormat:`%9.`,glyphType:7}])},CHECK_LIST:{listType:`CHECK_LIST`,nestingLevel:V_(`☐`)},CHECK_LIST_CHECKED:{listType:`CHECK_LIST_CHECKED`,nestingLevel:V_(`☑`,{st:{s:1}})}},U_=e=>{let{glyphFormat:t,glyphType:n}=e,r=z.deepClone(H_.ORDER_LIST);return r.nestingLevel[0].glyphFormat=t,r.nestingLevel[0].glyphType=n,r},W_={ORDER_LIST_QUICK_2:U_(R_[`a)`]),ORDER_LIST_QUICK_3:U_(R_[`a.`]),ORDER_LIST_QUICK_4:U_(R_[`i.`]),ORDER_LIST_QUICK_6:U_(R_[`I.`])};Object.assign(H_,W_);let G_={"1.":`ORDER_LIST`,"a)":`ORDER_LIST_QUICK_2`,"a.":`ORDER_LIST_QUICK_3`,"i.":`ORDER_LIST_QUICK_4`,"A.":`ORDER_LIST_3`,"I.":`ORDER_LIST_QUICK_6`,"01.":`ORDER_LIST_5`,"*":`BULLET_LIST`};function K_(e,t){if(t===void 0)return{startOffset:e,endOffset:e,collapsed:!0};if(t<e)throw Error(`Cannot make a doc selection when endOffset ${t} is less than startOffset ${e}.`);return{startOffset:e,endOffset:t,collapsed:e===t}}function q_(e){let{startOffset:t,endOffset:n,collapsed:r}=e;return{startOffset:Math.min(t,n),endOffset:Math.max(t,n),collapsed:r}}function J_(e,t,n,r){return Math.max(e,n)<=Math.min(t,r)}function Y_(e,t,n,r){let{startOffset:i,endOffset:a}=e,o=r??Q_(t,n),s=[],c=-1;for(let e=0;e<o.length;e++){let t=o[e],{startIndex:n}=t;(i>c&&i<=n||a>c&&a<=n||n>=i&&n<=a)&&s.push(t),c=n}return s}function X_(e,t,n){let r=[],i=Q_(t,n);for(let a of e){let e=Y_(a,t,n,i);r.push(...e)}return r}let Z_=[`\r`,``,``,`\x1B`,``,``];function Q_(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r],{startIndex:a}=i,o=a-1;for(;!Z_.includes(t[o])&&o>=0;)o--;n.push({...i,paragraphStart:o+1,paragraphEnd:i.startIndex})}return n}let $_=e=>{var t;let{paragraphs:n,segmentId:r,document:i}=e,a=e.listType,o=((t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs)??[],s=i.getSnapshot(),c=n.every(e=>{var t;return((t=E_(s,e))==null?void 0:t.listType.indexOf(a))===0}),l=J(6);if(n.length===1){let e=o.indexOf(n[0]),t=o[e-1],r=o[e+1],i=t&&E_(s,t),c=r&&E_(s,r);i&&i.listType.indexOf(a)===0?(l=i.listId,a!==`CHECK_LIST`&&(a=i.listType)):c&&c.listType.indexOf(a)===0&&(l=c.listId,a!==`CHECK_LIST`&&(a=c.listType))}let u=new dm;u.reset();let d=new X;for(let e of n){let{startIndex:t}=e,n=E_(s,e),r={...e,startIndex:0,paragraphStyle:e.paragraphStyle??{}};c?E_(s,{styleId:e.styleId})?r.bullet=null:delete r.bullet:r.bullet={nestingLevel:(n==null?void 0:n.nestingLevel)??0,listType:a,listId:l},d.push({t:`r`,len:t-u.cursor}),d.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[r]},coverType:1}),u.moveCursorTo(t+1)}return d},ev=e=>{var t;let{paragraphIndex:n,segmentId:r,document:i}=e,a=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null?void 0:t.paragraphs;if(a==null)return!1;let o=a.find(e=>e.startIndex===n),s=o&&E_(i.getSnapshot(),o);if(!o||!s||s.listType.indexOf(`CHECK_LIST`)===-1)return!1;let c=new dm;c.reset();let l=new X,{startIndex:u,paragraphStyle:d={}}=o,f=s.listType===`CHECK_LIST`?`CHECK_LIST_CHECKED`:`CHECK_LIST`;return l.push({t:`r`,len:u-c.cursor}),l.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...o,paragraphStyle:d,startIndex:0,bullet:{...o.bullet,listType:f}}]},coverType:1}),c.moveCursorTo(u+1),l},tv=e=>{var t;let{paragraphs:n,listType:r,listId:i,segmentId:a,document:o}=e;if(((t=o.getSelfOrHeaderFooterModel(a))==null||(t=t.getBody())==null?void 0:t.paragraphs)==null)return!1;let s=i??J(6),c=new dm;c.reset();let l=new X;for(let e of n){let{startIndex:t,paragraphStyle:n={}}=e,i=E_(o.getSnapshot(),e);l.push({t:`r`,len:t-c.cursor}),l.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...e,startIndex:0,paragraphStyle:n,bullet:{nestingLevel:(i==null?void 0:i.nestingLevel)??0,...(i==null?void 0:i.listType)===r&&i.textStyle?{textStyle:i.textStyle}:{},listType:r,listId:s}}]},coverType:1}),c.moveCursorTo(t+1)}return l};function nv(e,t){return t.some(t=>{let n=fg(t);return e.startIndex>n.startOffset&&yg(n,e.startIndex)})}let rv=/* @__PURE__ */ new Set([`
|
|
6
|
+
`,``,`\x1B`,``,``,``,``,``,``,``,``,``,``]);function iv(e,t){let n;for(let r of e.paragraphs??[])r.startIndex<t.startIndex&&(!n||r.startIndex>n.startIndex)&&(n=r);let r=n?n.startIndex+1:0;for(;r<t.startIndex&&rv.has(e.dataStream[r]);)r++;return r}function av(e){let t=/* @__PURE__ */ new Map,n=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex);for(let r=0;r<n.length;r++){let i=n[r],a=r>0?n[r-1].startIndex+1:0;for(;a<i.startIndex&&rv.has(e.dataStream[a]);)a++;t.set(i.startIndex,a)}return t}function ov(e,t){let n=(e.blockRanges??[]).find(e=>{let n=pg(e);return t.startIndex>n.startOffset&&t.startIndex<n.endOffset-1});return n?pg(n).endOffset:t.startIndex+1}let sv=e=>{var t;let{paragraphs:n,document:r,type:i}=e,a=new dm;a.reset();let o=new X,s=r.getSnapshot().lists??{},c=((t=r.getBody())==null?void 0:t.tables)??[],l={...H_,...s};for(let e of n){let{startIndex:t,paragraphStyle:n={}}=e,s=E_(r.getSnapshot(),e),u=nv(e,c);if(o.push({t:`r`,len:t-a.cursor}),s){let t=l[s.listType].nestingLevel.length-1;u&&(t=Math.min(t,2)),o.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...e,startIndex:0,paragraphStyle:{...n},bullet:{...e.bullet,nestingLevel:Math.max(Math.min(s.nestingLevel+i,t),0)}}]},coverType:1})}else o.push({t:`r`,len:1});a.moveCursorTo(t+1)}return o},cv=e=>{var t,n;let{textRanges:r,segmentId:i,document:a,style:o,paragraphTextRun:s,cursor:c,deleteLen:l,textX:u}=e,d=a.getSelfOrHeaderFooterModel(i),f=X_(r,(d==null||(t=d.getBody())==null?void 0:t.paragraphs)??[],(d==null||(n=d.getBody())==null?void 0:n.dataStream)??``),p=new dm;c&&p.moveCursorTo(c);let m=u??new X;f.sort((e,t)=>e.startIndex-t.startIndex);let h=Math.max(0,f[0].paragraphStart-1);h>p.cursor&&(m.push({t:`r`,len:h-p.cursor}),p.moveCursorTo(h)),l&&m.push({t:`d`,len:l});for(let e of f){let{startIndex:t,paragraphId:n,paragraphStyle:r={}}=e,i=t-p.cursor;m.push({t:`r`,len:i,...s?{body:{dataStream:``,textRuns:[{ts:s,st:0,ed:i}]},coverType:1}:null}),m.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:n,paragraphStyle:{...r,...o}}]},coverType:1}),p.moveCursorTo(t+1)}return m},lv=/* @__PURE__ */ function(e){return e[e.copy=0]=`copy`,e[e.cut=1]=`cut`,e}({});function uv(e,t,n,r,i){return i===1?e>=n&&t<=r:i===2?e<r&&t>n&&t<=r:Math.max(e,n)<Math.min(t,r)}function dv(e,t,n,r,i){return i===0?{startIndex:Math.max(e,n)-n,endIndex:Math.min(t,r)-n}:{startIndex:e-n,endIndex:t-n}}function fv(e,t,n,r=!0){let{textRuns:i}=e;if(i){let e=[];for(let r of i){let{st:i,ed:a}=r;if(z.hasIntersectionBetweenTwoRanges(i,a,t,n)){let o=z.deepClone(r);t>=i&&t<=a?e.push({...o,st:t,ed:Math.min(n,a)}):n>=i&&n<=a?e.push({...o,st:Math.max(t,i),ed:n}):e.push(o)}}return Og(e.map(e=>{let{st:n,ed:r}=e;return{...e,st:n-t,ed:r-t}}))}if(r)return[{st:0,ed:n-t,ts:{}}]}function pv(e,t,n,r=0){let{tables:i=[]}=e,a=[];for(let e of i){let i=z.deepClone(e),{startIndex:o,endIndex:s}=i;uv(o,s,t,n,r)&&a.push({...i,...dv(o,s,t,n,r)})}return a}function mv(e,t,n,r=0){let{blockRanges:i=[]}=e,a=[];for(let e of i){let{startIndex:i,endIndex:o}=e;(r===1?i>=t&&o<n:uv(i,o,t,n,r))&&a.push({...e,...dv(i,o,t,n,r)})}return a}function hv(e,t,n,r=0){let{columnGroups:i=[]}=e,a=[];for(let o of i){let i=z.deepClone(o),{startIndex:s,endIndex:c}=i;e.dataStream[s]===``&&uv(s,c,t,n,r)&&a.push({...i,...dv(s,c,t,n,r)})}return a}function gv(e,t,n,r=1){let{paragraphs:i=[]}=e,a=[];if(r===1){for(let e of i){let{startIndex:r}=e;r>=t&&r<n&&a.push(z.deepClone(e))}return a.length?a.map(e=>({...e,startIndex:e.startIndex-t})):void 0}let o=[...i].sort((e,t)=>e.startIndex-t.startIndex),s=av(e);for(let e of o){let r=s.get(e.startIndex)??0,i=e.startIndex;if(i>=t&&i<n||Math.max(r,t)<Math.min(i,n)){let r=z.deepClone(e);r.startIndex=Math.min(Math.max(i,t),n),a.push(r)}}if(a.length)return a.map(e=>({...e,startIndex:e.startIndex-t}))}function _v(e,t,n){let{sectionBreaks:r=[]}=e,i=[];for(let e of r){let{startIndex:r}=e;r>=t&&r<=n&&i.push(z.deepClone(e))}if(i.length)return i.map(e=>({...e,startIndex:e.startIndex-t}))}function vv(e,t,n){return bv(e.customBlocks??[],t,n)}function yv(e,t,n){return bv(e.docxRawCustomBlocks??[],t,n)}function bv(e,t,n){let r=[];for(let i of e){let{startIndex:e}=i;e>=t&&e<n&&r.push(z.deepClone(i))}if(r.length)return r.map(e=>({...e,startIndex:e.startIndex-t}))}function xv(e,t,n){return(e.docxRawBlocks??[]).filter(e=>e.startIndex>=t&&e.startIndex<n).map(e=>({...z.deepClone(e),startIndex:e.startIndex-t}))}function Sv(e,t,n){return(e.docxExportExcludedRanges??[]).flatMap(e=>{let r=Math.max(e.start,t),i=Math.min(e.end,n);return i>r?[{start:r-t,end:i-t}]:[]})}function Cv(e,t,n,r=!0,i=1,a=0){let{dataStream:o}=e,s={dataStream:o.slice(t,n)};e.renderedPageBreaks!=null&&(s.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e>=t&&e<n).map(e=>e-t)),e.__textXPreserveParagraphIds&&(s[cg]=!0),s.textRuns=fv(e,t,n,r);let c=pv(e,t,n,a);c.length&&(s.tables=c);let l=mv(e,t,n,a);l.length&&(s.blockRanges=l);let u=hv(e,t,n,a);u.length&&(s.columnGroups=u),s.paragraphs=gv(e,t,n,i);let d=_v(e,t,n-1);if(d?s.sectionBreaks=d:r&&(s.sectionBreaks=[]),i===1){let i=kv(e,t,n);i?s.customDecorations=i:r&&(s.customDecorations=[])}let{customRanges:f}=Ov(e,t,n);return f?s.customRanges=i===0?f.filter(e=>e.rangeType!==1||s.dataStream[e.startIndex]===``&&s.dataStream[e.endIndex]===``):f:r&&(s.customRanges=[]),s.customBlocks=vv(e,t,n),e.docxRawCustomBlocks!=null&&(s.docxRawCustomBlocks=yv(e,t,n)??[]),e.docxRawBlocks!=null&&(s.docxRawBlocks=xv(e,t,n)),e.docxExportExcludedRanges!=null&&(s.docxExportExcludedRanges=Sv(e,t,n)),s}function wv(e,t,n,r=!0,i=1){return Cv(e,t,n,r,i,1)}function Tv(e,t,n,r=!0,i=1){return Cv(e,t,n,r,i,2)}function Ev(e,t,n){var r,i,a,o,s,c,l,u,d,f;e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.map(e=>e+t)),(r=e.textRuns)==null||r.forEach(e=>{e.st+=t,e.ed+=t}),(i=e.paragraphs)==null||i.forEach(e=>{e.startIndex+=t}),(a=e.customBlocks)==null||a.forEach(e=>{e.startIndex+=t}),(o=e.docxRawCustomBlocks)==null||o.forEach(e=>{e.startIndex+=t}),(s=e.docxRawBlocks)==null||s.forEach(e=>{e.startIndex+=t}),(c=e.docxExportExcludedRanges)==null||c.forEach(e=>{e.start+=t,e.end+=t}),(l=e.customRanges)==null||l.forEach(e=>{e.startIndex+=t,e.endIndex+=t}),(u=e.customDecorations)==null||u.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(d=e.tables)==null||d.forEach(e=>{e.startIndex+=t,e.endIndex+=n}),(f=e.columnGroups)==null||f.forEach(e=>{e.startIndex+=t,e.endIndex+=n})}function Dv(e){let{dataStream:t,textRuns:n,customRanges:r}=e,i=0,a=0;r==null||r.forEach(e=>{e.startIndex<0&&(i=Math.max(i,-e.startIndex)),e.endIndex>t.length-1&&(a=Math.max(a,e.endIndex-t.length+1))});let o=`${t}`;return n&&(n[0]&&(n[0].st=n[0].st-i),n[n.length-1]&&(n[n.length-1].ed=n[n.length-1].ed+a)),Ev(e,i,a),{...e,dataStream:o}}function Ov(e,t,n){if(e.customRanges==null)return{};let{customRanges:r}=e;return{customRanges:r.filter(e=>Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)).map(e=>({...e,startIndex:Math.max(e.startIndex,t),endIndex:Math.min(e.endIndex,n-1)})).map(e=>({...e,startIndex:e.startIndex-t,endIndex:e.endIndex-t})),leftOffset:0,rightOffset:0}}function kv(e,t,n){if(e.customDecorations==null)return;let{customDecorations:r=[]}=e,i=[];return r.forEach(e=>{if(Math.max(e.startIndex,t)<=Math.min(e.endIndex,n-1)){let r=z.deepClone(e);i.push({...r,startIndex:Math.max(r.startIndex-t,0),endIndex:Math.min(r.endIndex,n-1)-t})}}),i}function Av(e,t,n){return e==null||t==null?e??t:g_(e,t,n)}function jv(e,t,n){if(e==null||t==null)return e??t;if(t.length===0||e.length===0)return e;if(n===1)return e.map(e=>({...e}));let r=new Map(e.map(e=>[e.rangeId,e]));return[...t.filter(t=>!e.some(e=>t.rangeType===0&&e.rangeType===0&&e.rangeId!==t.rangeId&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)).map(e=>{let t=r.get(e.rangeId);return t==null?e:(r.delete(e.rangeId),{...e,...t})}),...r.values()]}function Mv(e,t,n){return t.length===0||e.length===0||n===1?e:[...e,...t.filter(t=>!e.some(e=>t.id===e.id))]}function Nv(e,t,n=0){if(t.dataStream!==``)throw Error(`Cannot compose other body with non-empty dataStream`);let r={dataStream:e.dataStream};e.renderedPageBreaks!=null&&(r.renderedPageBreaks=[...e.renderedPageBreaks]),(e.__textXPreserveParagraphIds||t.__textXPreserveParagraphIds)&&(r[cg]=!0);let{textRuns:i,paragraphs:a=[],customRanges:o,customDecorations:s=[],columnGroups:c=[],blockRanges:l=[]}=e,{textRuns:u,paragraphs:d=[],customRanges:f,customDecorations:p=[],columnGroups:m=[],blockRanges:h=[]}=t;r.textRuns=Av(u,i,n),r.customRanges=jv(f,o,n);let g=Mv(p,s,n);g.length&&(r.customDecorations=g);let _=[],v=0,y=0;for(;v<a.length&&y<d.length;){let e=a[v],t=d[y],{startIndex:n}=e,{startIndex:r}=t;n===r?(_.push(na(e,t)),v++,y++):n<r?(_.push(z.deepClone(e)),v++):(_.push(z.deepClone(t)),y++)}v<a.length&&_.push(...a.slice(v)),y<d.length&&_.push(...d.slice(y)),_.length&&(r.paragraphs=_);let b=Pv(l,h);b.length&&(r.blockRanges=b);let x=Fv(c,m);return x.length&&(r.columnGroups=x),r}function Pv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.blockId,z.deepClone(e)]));return t.forEach(e=>n.set(e.blockId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Fv(e,t){if(!e.length)return t;if(!t.length)return e;let n=new Map(e.map(e=>[e.columnGroupId,z.deepClone(e)]));return t.forEach(e=>n.set(e.columnGroupId,z.deepClone(e))),Array.from(n.values()).sort((e,t)=>e.startIndex-t.startIndex)}function Iv(e){var t;if((t=e.rangeUpdates)!=null&&t.length)return!1;let{body:n}=e;if(n==null)return!0;let{textRuns:r,paragraphs:i,sectionBreaks:a,customRanges:o,customBlocks:s,docxRawCustomBlocks:c,docxRawBlocks:l,docxExportExcludedRanges:u,customDecorations:d,tables:f,columnGroups:p,blockRanges:m}=n;return r==null&&i==null&&a==null&&o==null&&s==null&&c==null&&l==null&&u==null&&d==null&&f==null&&p==null&&m==null}function Lv(e,t=``){var n;if(!t)return[`body`];let{headers:r,footers:i}=e.getSnapshot();if(((n=e.getSnapshot().notes)==null?void 0:n[t])!=null)return[`notes`,t,`body`];if(r==null&&i==null)throw Error(`Document data model must have headers or footers when update by segment id`);if((r==null?void 0:r[t])!=null)return[`headers`,t,`body`];if((i==null?void 0:i[t])!=null)return[`footers`,t,`body`];throw Error(`Segment id not found in headers or footers`)}var Rv=class{constructor(e){this._actions=e,T(this,`_index`,0),T(this,`_offset`,0)}hasNext(){return this.peekLength()<1/0}next(e){e===void 0&&(e=1/0);let t=this._actions[this._index];if(t){let n=this._offset,r=t.len;return e>=r-n?(e=r-n,this._index+=1,this._offset=0):this._offset+=e,t.t===`d`||t.t===`r`&&t.body==null?z.deepClone({...t,len:e}):z.deepClone({...t,len:e,body:Tv(t.body,n,n+e,!1)})}return{t:`r`,len:1/0}}peek(){return this._actions[this._index]}peekLength(){return this._actions[this._index]?this._actions[this._index].len-this._offset:1/0}peekType(){let e=this._actions[this._index];return e?e.t:`r`}rest(){if(!this.hasNext())return[];if(this._offset===0)return this._actions.slice(this._index);{let e=this._offset,t=this._index,n=this.next(),r=this._actions.slice(this._index);return this._offset=e,this._index=t,[n].concat(r)}}};function zv(e,t,n){var r;let{dataStream:i}=e,a=n,o=n+t,s=(r=e.renderedPageBreaks)==null?void 0:r.filter(e=>e>=a&&e<o).map(e=>e-a);e.renderedPageBreaks!=null&&(e.renderedPageBreaks=e.renderedPageBreaks.filter(e=>e<a||e>=o).map(e=>e>=o?e-t:e));let c=t_(e,t,n),l=n_(e,t,n),u=r_(e,t,n),d=a_(e,t,n),f=o_(e,t,n),p=s_(e,t,n),m=c_(e,t,n),h=l_(e,t,n),g=u_(e,t,n),_=f_(e,t,n),v=d_(e,t,n),y=p_(e,t,n),b=``;return i&&(e.dataStream=ld(i,a,o),b=i.slice(a,o)),{dataStream:b,renderedPageBreaks:s,textRuns:c,paragraphs:l,sectionBreaks:u,customBlocks:d,docxRawCustomBlocks:f,docxRawBlocks:p,docxExportExcludedRanges:m,tables:h,columnGroups:g,blockRanges:_,customRanges:v,customDecorations:y}}function Bv(e,t,n,r){let i=e.dataStream;e.dataStream=cd(e.dataStream,r,t.dataStream),(e.renderedPageBreaks!=null||t.renderedPageBreaks!=null)&&(e.renderedPageBreaks=[...(e.renderedPageBreaks??[]).map(e=>e>=r?e+n:e),...(t.renderedPageBreaks??[]).map(e=>e+r)].sort((e,t)=>e-t)),kg(e,t,n,r),Ag(e,t,n,r,!1,i),Lg(e,t,n,r),Bg(e,t,n,r),Vg(e,t,n,r),Hg(e,t,n,r),Wg(e,t,n,r),Gg(e,t,n,r),Kg(e,t,n,r),qg(e,t,n,r),$g(e,t,n,r),e_(e,t,n,r)}function Vv(e,t,n=[]){if(z.diffValue(e,t))return[];if(t&&typeof t==`object`&&!Array.isArray(t)&&(e==null||typeof e==`object`&&!Array.isArray(e))){let r=e??{},i=t,a=Array.from(/* @__PURE__ */ new Set([...Object.keys(r),...Object.keys(i)]));return!a.length&&n.length?[n]:a.flatMap(e=>Vv(r[e],i[e],[...n,e]))}return[n]}function Hv(e){if(!Array.isArray(e)||e.some(e=>!Array.isArray(e)||!e.length||e.some(e=>typeof e!=`string`||[`__proto__`,`prototype`,`constructor`].includes(e))))throw Error(`Invalid custom range property paths.`)}function Uv(e,t,n){Hv(n);let r=z.deepClone(e);for(let e of n){let n=r.properties??={},i=t.properties,a=[];for(let t=0;t<e.length;t++){let r=e[t];i=i&&typeof i==`object`?i[r]:void 0,t===e.length-1?i===void 0?delete n[r]:n[r]=z.deepClone(i):((!n[r]||typeof n[r]!=`object`||Array.isArray(n[r]))&&(n[r]={}),a.push({object:n,key:r,value:i}),n=n[r])}for(let e of a.reverse())e.value===void 0&&Object.keys(e.object[e.key]).length===0&&delete e.object[e.key]}return t.properties===void 0&&!Object.keys(r.properties??{}).length&&delete r.properties,r}function Wv(e,t){if(!e||!t.propertyPaths||!t.range)return t;if(!e.range)return e;let n=e.propertyPaths&&[...e.propertyPaths,...t.propertyPaths.filter(t=>!e.propertyPaths.some(e=>e.length<=t.length&&e.every((e,n)=>t[n]===e)))];return{...e,range:Uv(e.range,t.range,t.propertyPaths),propertyPaths:n}}function Gv(e,t,n){if(!t||!e.range)return[e];if(!t.range)return[];if(!e.propertyPaths||!t.propertyPaths)return n===`left`?[{...e,propertyPaths:void 0}]:[];let r=e.propertyPaths.filter(e=>n===`left`||!t.propertyPaths.some(t=>e.slice(0,Math.min(e.length,t.length)).every((e,n)=>t[n]===e))).map(e=>t.propertyPaths.find(t=>t.length<e.length&&t.every((t,n)=>e[n]===t))??e);return r.length?[{...e,propertyPaths:r}]:[]}function Kv(e){let t=/* @__PURE__ */ new Map;for(let n of e)if(n.t===`r`)for(let e of n.rangeUpdates??[])t.set(e.rangeId,Wv(t.get(e.rangeId),e));return t.size?z.deepClone(Array.from(t.values())):[]}function qv(e){return e.flatMap(e=>{if(e.t===`i`&&e.len>1&&Array.from(e.body.dataStream).every(e=>e===``||e===``))return Array.from(e.body.dataStream,(t,n)=>({...e,len:1,body:Tv(e.body,n,n+1,!1)}));if(e.t!==`r`||!e.rangeUpdates)return[e];let{rangeUpdates:t,oldRangeUpdates:n,...r}=e;return r.len===0&&!r.body?[]:[r]})}function Jv(e,t){return t!=null&&t.length?[...e,{t:`r`,len:0,rangeUpdates:t}]:e}function Yv(e,t){for(let{rangeId:n,range:r,nextRangeId:i,propertyPaths:a}of e??[]){if(a!==void 0&&(Hv(a),!r))throw Error(`Invalid custom range property paths.`);if(typeof n!=`string`||!n||i!=null&&typeof i!=`string`||r!==null&&(typeof r!=`object`||!r||Array.isArray(r)||r.rangeId!==n||!Number.isInteger(r.startIndex)||!Number.isInteger(r.endIndex)||r.startIndex<0||r.endIndex<r.startIndex||r.endIndex>=t))throw Error(`Invalid custom range identity or bounds.`)}}function Xv(e,t){if(!(t!=null&&t.length))return;let n=e.customRanges??[];for(let{rangeId:e,range:r,nextRangeId:i,propertyPaths:a}of[...t].reverse()){let t=n.findIndex(t=>t.rangeId===e);if(r&&a)t>=0&&(n[t]=Uv(n[t],r,a));else if(r){if(i!==void 0){t>=0&&n.splice(t,1);let e=n.findIndex(e=>e.rangeId===i);n.splice(e<0?n.length:e,0,z.deepClone(r))}else t>=0?n[t]=z.deepClone(r):n.push(z.deepClone(r))}else t>=0&&n.splice(t,1)}e.customRanges=n}function Zv(e,t,n=!1){return e.map(e=>{var r;let{rangeId:i,range:a}=e;if(!a&&n)return e;let o={dataStream:``,customRanges:a?[z.deepClone(a)]:[]},s=0;for(let e of t){var c;if(e.t===`i`){var l;$g(o,{dataStream:``,customRanges:z.deepClone((l=e.body.customRanges)==null?void 0:l.filter(e=>e.rangeId===i))},e.len,s)}else if(e.t===`d`){d_(o,e.len,s);continue}else(c=e.body)!=null&&c.customRanges&&m_(o,{dataStream:``,customRanges:z.deepClone(e.body.customRanges.filter(e=>e.rangeId===i))},e.len,s,e.coverType??0);s+=e.len}let u=(r=o.customRanges)==null?void 0:r.find(e=>e.rangeId===i);return{...e,propertyPaths:u?e.propertyPaths:void 0,range:u&&a&&n?{...z.deepClone(a),startIndex:u.startIndex,endIndex:u.endIndex}:u??null}})}function Qv(e,t){let n=new Map(t==null?void 0:t.map(e=>[e.rangeId,e]));return n.size?e.map(e=>{var t;return(t=e.body)!=null&&t.customRanges?{...e,body:{...e.body,customRanges:e.body.customRanges.flatMap(e=>{if(!n.has(e.rangeId))return[e];let t=n.get(e.rangeId);return t.range?[{...t.propertyPaths?Uv(e,t.range,t.propertyPaths):z.deepClone(t.range),startIndex:e.startIndex,endIndex:e.endIndex}]:[]})}}:e}):e}function $v(e,t,n){if(!t.length)return Jv(e,n);let r=[],i=[],a=0,o=0;for(let n of e){var s;let e=(s=n.body)==null?void 0:s.dataStream;n.t===`i`&&n.len===1&&t.some(t=>e===``&&a===t.startIndex||e===``&&a===t.endIndex)?(a>o&&i.push({t:`r`,len:a-o}),i.push({t:`d`,len:1}),o=a+1):r.push(n),n.t!==`d`&&(a+=n.len)}return Jv(r,Zv(n,i))}function ey(e,t,n,r,i=0){return m_(e,t,n,r,i)}function ty(e,t,n){return t<=0?{dataStream:``}:zv(e,t,n)}function ny(e,t,n,r){n!==0&&Bv(e,t,n,r)}function ry(e,t){if(t.some(e=>e.t!==`r`&&e.valueRangeId!==void 0&&(typeof e.valueRangeId!=`string`||!e.valueRangeId)))throw Error(`Invalid scalar value range identity.`);let n=Kv(t);n.length&&Yv(n,t.reduce((e,t)=>t.t===`i`?e+t.len:t.t===`d`?e-t.len:e,e.dataStream.length));let r=new dm;return r.reset(),t.forEach(t=>{switch(t.t){case`r`:{let{coverType:n,body:i,len:a}=t;i!=null&&ey(e,z.deepClone(i),a,r.cursor,n),r.moveCursor(a);break}case`i`:{let{body:n,len:i}=t;ny(e,iy(n)?n:z.deepClone(n),i,r.cursor),r.moveCursor(i);break}case`d`:{let{len:n}=t;ty(e,n,r.cursor);break}default:throw Error(`Unknown action type for action: ${t}.`)}}),Xv(e,n),e}function iy(e){return Object.keys(e).length===1&&typeof e.dataStream==`string`}function ay(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];t=z.deepClone(t),e=z.deepClone(e);let a=[],o=t.length,s=e.length,c=0,l=0,u=null;function d(){return u?(a.push(u),u=null,!0):!1}for(;c<o&&l<s;){let{st:o,ed:s,ts:f}=t[c],{st:p,ed:m,ts:h,sId:g}=e[l],_={};if(i===0)_={...f},n===0&&r===1&&h&&(_=Object.assign({},h,_));else if(_={...f},n===1){if(r===1)_={...h};else if(f&&h){let e=Object.keys(f);for(let t of e)h[t]&&delete _[t]}}else if(r===1){if(h){let e=Object.keys(h);for(let t of e)h[t]!==void 0&&(_[t]=h[t])}}else if(h){let e=Object.keys(h);for(let t of e)_[t]!==void 0&&delete _[t]}if(s<p)d()||a.push(t[c]),c++;else if(m<o)d()||a.push(e[l]),l++;else{let n={st:Math.min(o,p),ed:Math.max(o,p),ts:o<p?{...f}:{...h},sId:o<p?void 0:g};n.ed>n.st&&a.push(),a.push({st:Math.max(o,p),ed:Math.min(s,m),ts:_,sId:g}),s<m?(c++,e[l].st=s,e[l].st===e[l].ed&&l++):(l++,t[c].st=m,t[c].st===t[c].ed&&c++);let r={st:Math.min(s,m),ed:Math.max(s,m),ts:s<m?{...h}:{...f},sId:s<m?g:void 0};u=r.ed>r.st?r:null}}d();let f=a[a.length-1],p=t[o-1],m=e[s-1];return f.ed!==Math.max(p.ed,m.ed)&&(p.ed>m.ed?a.push(p):a.push(m)),Og(a,!0)}function oy(e,t,n,r,i){if(e==null||t==null)return t;if(e.length===0||t.length===0)return[];if(e.length>1||t.length>1)throw Error(`CustomRanges is only supported transform for length one now.`);let a=e[0],o=t[0];if(n===1)return i===1?[z.deepClone(a)]:[z.deepClone(o)];if(r===1){let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}{let e=z.deepClone(o);return i===1&&Object.assign(e,z.deepClone(a)),[e]}}function sy(e,t,n,r,i){let a={startIndex:t.startIndex,paragraphId:t.paragraphId};if(t.paragraphStyle&&(a.paragraphStyle=z.deepClone(t.paragraphStyle),e.paragraphStyle)){if(n===1){if(r===1)i===1&&(a.paragraphStyle={...e.paragraphStyle});else if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(r===1){if(i===1){let t=Object.keys(e.paragraphStyle);for(let n of t)e.paragraphStyle[n]!==void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}else{let t=Object.keys(e.paragraphStyle);for(let n of t)a.paragraphStyle[n]===void 0&&(a.paragraphStyle[n]=e.paragraphStyle[n])}}else if(i===1){let t=Object.keys(e.paragraphStyle);for(let e of t)a.paragraphStyle[e]&&delete a.paragraphStyle[e]}}n===1&&r===1?a.bullet=i===1?z.deepClone(e.bullet):z.deepClone(t.bullet):e.bullet===void 0?a.bullet=z.deepClone(t.bullet):n===1||r===1?a.bullet=i===0&&t.bullet?z.deepClone(t.bullet):z.deepClone(e.bullet):i===0&&t.bullet!==void 0&&(a.bullet=z.deepClone(t.bullet));for(let o of[`headingCollapsed`,`styleId`,`sourceBullet`,`directBullet`]){let s=e[o],c=t[o],l;n===1&&r===1?l=i===1?s:c:s===void 0?l=c:n===1||r===1?l=i===0&&c!==void 0?c:s:i===0&&(l=c),l!==void 0&&Object.assign(a,{[o]:z.deepClone(l)})}return a.bullet===void 0&&delete a.bullet,a}function cy(e,t){if(e==null||t==null)return t;if(e.length===0||t.length===0)return z.deepClone(t);let n=[];for(let r of t){let{id:t,type:i}=r,a=!1;for(let o of e)if(o.id===t){(o.type===9999||i===9999)&&(a=!0,n.push({...r,type:9999}));break}a||n.push(r)}return n}function ly(e,t,n=!1){let{body:r,coverType:i=0}=e,{body:a,coverType:o=0}=t;if(r==null||r.dataStream!==``||a==null||a.dataStream!==``)throw Error(`Data stream is not supported in retain transform.`);let s={dataStream:``},c=o,{textRuns:l,paragraphs:u=[],blockRanges:d=[],customRanges:f,customDecorations:p}=r,{textRuns:m,paragraphs:h=[],blockRanges:g=[],customRanges:_,customDecorations:v}=a,y=ay(l,m,i,o,+!!n);y&&(s.textRuns=y);let b=oy(f,_,i,o,+!!n);b&&(s.customRanges=b);let x=cy(p,v);x&&(s.customDecorations=x);let S=[],C=0,w=0;for(;C<u.length&&w<h.length;){let e=u[C],t=h[w],{startIndex:r}=e,{startIndex:a}=t;if(r===a){let a={startIndex:r,paragraphId:t.paragraphId};a=n?sy(e,t,i,o,1):sy(e,t,i,o,0),S.push(a),C++,w++}else r<a?C++:(S.push(z.deepClone(t)),w++)}w<h.length&&S.push(...h.slice(w)),S.length&&(s.paragraphs=S);let T=uy(d,g,n);return T.length&&(s.blockRanges=T),{coverType:c,body:s}}function uy(e,t,n){return e.length?t.length?t.map(t=>{let r=e.find(e=>e.blockId===t.blockId);return r&&n?na(t,r):t}):[]:t}function dy(e){return Object.keys(e).length===1}function fy(e){return new Set(e.flatMap(e=>e.t!==`r`&&e.valueRangeId?[e.valueRangeId]:[]))}function py(e,t){return e.map(e=>{var n,r;if(!((n=e.body)!=null&&(n=n.customRanges)!=null&&n.some(e=>t.has(e.rangeId))))return e;let i={...e.body,customRanges:e.body.customRanges.filter(e=>!t.has(e.rangeId))};return(r=i.customRanges)!=null&&r.length||delete i.customRanges,{...e,body:i}})}function my(e,t,n){let r=/* @__PURE__ */ new Map;for(let n of[e,t])for(let e of n)if(e.t===`i`)for(let t of e.body.customRanges??[])t.rangeType===1&&e.body.dataStream[t.startIndex]===``&&e.body.dataStream[t.endIndex]===``&&r.set(t.rangeId,(r.get(t.rangeId)??0)+1);if(!r.size)return n;let i=/* @__PURE__ */ new Map,a=0;for(let e of n){if(e.t===`i`)for(let t of e.body.customRanges??[]){if(r.get(t.rangeId)!==1)continue;let n=a+t.startIndex,o=a+t.endIndex,s=i.get(t.rangeId);s?(s.range.endIndex=o,s.endToken=e.body.dataStream[t.endIndex],s.count++):i.set(t.rangeId,{range:{...z.deepClone(t),startIndex:n,endIndex:o},count:1,startToken:e.body.dataStream[t.startIndex],endToken:e.body.dataStream[t.endIndex]})}e.t!==`d`&&(a+=e.len)}let o=[...i.values()].filter(e=>e.count>1&&e.startToken===``&&e.endToken===``);if(!o.length)return n;let s=new Map(Kv(n).map(e=>[e.rangeId,e])),c=new Set(o.map(({range:e})=>e.rangeId)),l=new Set(c);return Jv(n.map(e=>{var t;if(!((t=e.body)!=null&&(t=t.customRanges)!=null&&t.some(e=>c.has(e.rangeId))))return e;let n={...e.body,customRanges:e.body.customRanges.filter(e=>!c.has(e.rangeId)||l.delete(e.rangeId))};return n.customRanges.length||Reflect.deleteProperty(n,`customRanges`),{...e,body:n}}),o.map(({range:e})=>s.has(e.rangeId)?Wv({rangeId:e.rangeId,range:e},s.get(e.rangeId)):{rangeId:e.rangeId,range:e}))}function hy(e,t,n){if((e==null?void 0:e.t)!==`i`||(t==null?void 0:t.t)!==`i`)return n===`left`;let r=e.body.dataStream,i=t.body.dataStream;return r===i?n===`left`:r===``||i===``?!0:r===``||i===``?!1:n===`left`}function gy(e,t,n,r){var i;let a=jg(t.paragraphs,e.paragraphs,n,{freshenSplitParagraph:!1,preserveExplicitParagraphIds:!!e[cg],reservedParagraphIds:r,dataStream:t.dataStream});(i=e.paragraphs)!=null&&i.length&&!a&&Reflect.set(e,cg,!0)}var X=class e{constructor(){T(this,`_actions`,[])}static apply(e,t){return ry(e,t)}static compose(t,n){let r=Kv(t),i=Kv(n);if(r.length||i.length){let a=qv(t),o=qv(n),s=new Map(Zv(r,o).map(e=>[e.rangeId,e]));for(let e of i)s.set(e.rangeId,Wv(s.get(e.rangeId),e));return my(t,n,Jv(e.compose(a,o),Array.from(s.values())))}let a=new Rv(t),o=new Rv(n),s=new e;for(;a.hasNext()||o.hasNext();)if(o.peekType()===`i`)s.push(o.next());else if(a.peekType()===`d`)s.push(a.next());else{let e=Math.min(a.peekLength(),o.peekLength()),t=a.next(e),n=o.next(e);if(t.t===`i`&&n.t===`r`)n.body==null?s.push(t):s.push({...t,body:Nv(t.body,n.body,n.coverType)});else if(t.t===`r`&&n.t===`r`){if(t.body==null&&n.body==null)s.push(t.len===1/0?n:t);else if(t.body&&n.body){let e=+(t.coverType===1||n.coverType===1);s.push({...t,t:`r`,coverType:e,body:Nv(t.body,n.body,n.coverType)})}else s.push(t.body?t:n)}else t.t===`r`&&n.t===`d`?s.push(n):t.t===`i`&&n.t}return s.trimEndUselessRetainAction(),my(t,n,s.serialize())}static transform(t,n,r=`right`){let i=Kv(t),a=Kv(n);if(i.length||a.length){let o=qv(t),s=qv(n),c=Zv(i,e._transform(o,s,r,!0),!0),l=c.flatMap(e=>Gv(e,a.find(t=>t.rangeId===e.rangeId),r)),u=c.flatMap(e=>e.range&&a.some(t=>t.rangeId===e.rangeId&&!t.range)?[e.range]:[]);return $v(Qv(e._transform(s,o,r===`left`?`right`:`left`,!0),a),u,l)}return this._transform(n,t,r===`left`?`right`:`left`)}static _transform(t,n,r=`right`,i=!1){let a=fy(t),o=new Set(Array.from(fy(n)).filter(e=>a.has(e))),s=new Rv(o.size&&r===`right`?py(t,o):t),c=new Rv(o.size&&r===`left`?py(n,o):n),l=new e;for(;s.hasNext()||c.hasNext();)if(s.peekType()===`i`&&((i?hy(s.peek(),c.peek(),r):r===`left`)||c.peekType()!==`i`)){let e=s.next();e.t===`i`&&e.valueRangeId&&o.has(e.valueRangeId)&&r===`right`?l.push({t:`d`,len:e.len,valueRangeId:e.valueRangeId}):l.retain(e.len)}else if(c.peekType()===`i`){let e=c.next();e.t===`i`&&e.valueRangeId&&o.has(e.valueRangeId)&&r===`left`||l.push(e)}else{let e=Math.min(s.peekLength(),c.peekLength()),t=s.next(e),n=c.next(e);if(t.t===`d`)continue;if(n.t===`d`){l.push(n);continue}if(t.body==null||n.body==null)l.push({...n,len:e});else{let{coverType:e,body:i}=ly(t,n,r===`left`);l.push({...n,t:`r`,coverType:e,body:i})}}return l.trimEndUselessRetainAction(),l.serialize()}static transformPosition(e,t,n=!1){let r=new Rv(e),i=0;for(;r.hasNext()&&i<=t;){let e=r.peekLength(),a=r.peekType();r.next(),a===`d`?t-=Math.min(e,t-i):(a===`i`&&(i<t||!n)&&(t+=e),i+=e)}return t}static isNoop(e){return e.length===0}static invert(t){if(Kv(t).length){let n=t.flatMap(e=>{if(e.t!==`r`||!e.rangeUpdates)return[];if(!e.oldRangeUpdates)throw Error(`makeInvertible must capture custom ranges before inversion.`);return e.oldRangeUpdates});return Jv(e.invert(qv(t)),z.deepClone(n))}let n=[];for(let e of t)if(e.t===`i`)n.push({t:`d`,len:e.len,body:e.body,valueRangeId:e.valueRangeId});else if(e.t===`d`){var r;if(e.body==null)throw Error(`Can not invert DELETE action without body property, makeInvertible must be called first.`);(r=e.body.paragraphs)!=null&&r.length&&(e.body[Dg]=!0,Reflect.set(e.body,cg,!0)),n.push({t:`i`,body:e.body,len:e.len,valueRangeId:e.valueRangeId})}else if(e.body!=null){if(e.oldBody==null)throw Error(`Can not invert RETAIN action without oldBody property, makeInvertible must be called first.`);n.push({t:`r`,body:e.oldBody,oldBody:e.body,len:e.len,coverType:1})}else n.push(e);return n}static makeInvertible(e,t){let n=[],r=0,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set;for(let s of e){if(s.t===`r`&&s.rangeUpdates&&(s.oldRangeUpdates=s.rangeUpdates.map(({rangeId:e,propertyPaths:n})=>{var r,i;let a=((r=t.customRanges)==null?void 0:r.findIndex(t=>t.rangeId===e))??-1;return{rangeId:e,range:a<0?null:z.deepClone(t.customRanges[a]),nextRangeId:a<0?void 0:((i=t.customRanges[a+1])==null?void 0:i.rangeId)??null,propertyPaths:a<0?void 0:n}})),s.t===`i`&&(gy(s.body,t,r,i),Rg(t.sectionBreaks,s.body.sectionBreaks,a)),s.t===`d`&&(s.body==null||s.body&&s.body.dataStream.length!==s.len)){let e=wv(t,r,r+s.len,!1);s.len=e.dataStream.length,s.body=e}if(s.t===`r`&&s.body!=null){let e=Cv(t,r,r+s.len,!0);for(let t of Object.keys(e))t!==`dataStream`&&t!==`paragraphs`&&s.body[t]==null&&Reflect.deleteProperty(e,t);if(s.body.paragraphs==null)delete e.paragraphs;else{var o;let t=new Map((o=e.paragraphs)==null?void 0:o.map(e=>[e.startIndex,e]));s.body.paragraphs=s.body.paragraphs.map(e=>{let n=t.get(e.startIndex);if(!n||e.paragraphId!=null&&e.paragraphId!==n.paragraphId)return e;let r={...e};return Reflect.deleteProperty(r,`paragraphId`),Reflect.deleteProperty(n,`paragraphId`),r})}s.oldBody={...e,dataStream:``},s.len=e.dataStream.length}n.push(s),s.t!==`i`&&(r+=s.len)}return n}updateCustomRangeProperties(e,t){let n=Vv(e.properties??{},t);return n.length&&this.updateCustomRanges([{rangeId:e.rangeId,range:{...e,properties:t},propertyPaths:n}]),this}updateCustomRanges(e){return this.push({t:`r`,len:0,rangeUpdates:e}),this}insert(e,t){let n={t:`i`,body:t,len:e};return this.push(n),this}retain(e,t,n){let r={t:`r`,len:e};return t!=null&&(r.body=t),n!=null&&(r.coverType=n),this.push(r),this}delete(e){let t={t:`d`,len:e};return this.push(t),this}empty(){return this._actions=[],this}serialize(){return this._actions}push(...e){if(e.length>1){for(let t of e)this.push(t);return this}let t=this._actions.length,n=this._actions[t-1],r=z.deepClone(e[0]);if(r.t===`r`&&r.len===0&&r.body==null&&!r.rangeUpdates)return this;if(typeof n==`object`){if(n.t===`d`&&r.t===`d`&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,this;if(n.t===`d`&&r.t===`i`&&(--t,n=this._actions[t-1],n==null))return this._actions.unshift(r),this;if(n.t===`r`&&r.t===`r`&&n.body==null&&r.body==null&&!n.rangeUpdates&&!r.rangeUpdates)return n.len+=r.len,this;if(n.t===`i`&&dy(n.body)&&r.t===`i`&&dy(r.body)&&n.valueRangeId===r.valueRangeId)return n.len+=r.len,n.body.dataStream+=r.body.dataStream,this}return t===this._actions.length?this._actions.push(r):this._actions.splice(t,0,r),this}trimEndUselessRetainAction(){let e=this._actions[this._actions.length-1];for(;e&&e.t===`r`&&Iv(e);)this._actions.pop(),e=this._actions[this._actions.length-1];return this}};T(X,`id`,`text-x`),T(X,`uri`,`https://github.com/dream-num/univer#text-x`),Object.defineProperty(X,"name",{value:`text-x`});var _y=class e{static registerSubtype(e){var t;e==null||this._subTypes.has(e.name)&&((t=this._subTypes.get(e.name))==null?void 0:t.id)!==X.id||(this._subTypes.set(e.name,e),sg.type.registerSubtype(e))}static apply(e,t){if(!sg.type.isNoop(t))return sg.type.apply(e,t)}static compose(e,t){return sg.type.compose(e,t)}static transform(e,t,n){return sg.type.transform(e,t,n)}static transformPosition(e,t,n=`right`){return e&&e.length===2&&e[0]===`body`&&e[1].et===X.name?X.transformPosition(e[1].e,t,n===`left`):t}static invertWithDoc(e,t){return sg.type.invertWithDoc(e,t)}static isNoop(e){return sg.type.isNoop(e)}static getInstance(){return this._instance??=new e,this._instance}removeOp(e,t){return sg.removeOp(e,t)}moveOp(e,t){return sg.moveOp(e,t)}insertOp(e,t){return sg.insertOp(e,t)}replaceOp(e,t,n){return sg.replaceOp(e,t,n)}editOp(e,t=[`body`]){return sg.editOp(t,X.name,e)}};T(_y,`uri`,`https://github.com/dream-num/univer#json-x`),T(_y,`_subTypes`,/* @__PURE__ */ new Map),T(_y,`_instance`,null),_y.registerSubtype(X);let vy=[``,`\x1B`,``,``,``,``,``,``],yy=e=>{let t=vy.reduce((e,t)=>e.replaceAll(t,``),e);return t.endsWith(`\r
|
|
7
|
+
`)?t.slice(0,-2):t},by=e=>!e||yy(e).replaceAll(`\r`,``)===``,xy=e=>{let t=e.replace(/\r\n?|\n/g,`\r`),n=[],r=/* @__PURE__ */ new Set,i=[],a=0,o=``,s=(s,c=!0)=>{let l=t.slice(a,s);if(z.isLegalUrl(l)){let t=J(),u=`${l}`,d={startIndex:a,endIndex:a+u.length-1,rangeId:t,rangeType:0,properties:{url:e}};i.push(d),o+=u,a=s+1,c&&(o+=`\r`,n.push({startIndex:s,paragraphId:Gh(r)}))}else o+=t.slice(a,s+1),a=s+1,c&&n.push({startIndex:s,paragraphId:Gh(r)})},c=0;for(let e=0;e<t.length;e++)t[e]===`\r`&&(s(e),c=e);return(c!==t.length-1||t.length===1)&&s(t.length,!1),{dataStream:o,paragraphs:n,customRanges:i}},Sy={id:`default_doc`,documentStyle:{}};function Cy(e){if((e==null?void 0:e.dataStream)==null||e.sectionBreaks==null)return e;let t=e.sectionBreaks.filter(({startIndex:t})=>e.dataStream[t]===`
|
|
8
|
+
`||t<=0||e.dataStream[t-1]!==`\f`),n=/* @__PURE__ */ new Set,r=t.length!==e.sectionBreaks.length,i=t.map(e=>e.sectionId&&!n.has(e.sectionId)?(n.add(e.sectionId),e):(r=!0,{...e,sectionId:xm(n)}));return r?{...e,sectionBreaks:i}:e}function wy(e){var t,n;if(e.id!=null&&Pp(e.id))return{...Sy,...e};let r=Zh(e.id,e.locale,e.title,(t=e.documentStyle)==null?void 0:t.documentFlavor);if(z.isEmptyObject(e))return r;let i=ta({},r,e,(e,t,n)=>{if(Array.isArray(t)||n===`body`&&typeof t==`object`&&t)return t});return e.body!=null&&((n=e.documentStyle)==null?void 0:n.defaultParagraphStyle)===void 0&&delete i.documentStyle.defaultParagraphStyle,i.body=Cy(i.body),i}var Ty=class extends M{getUnitId(){throw Error(`Method not implemented.`)}constructor(e){super(),T(this,`type`,n.UniverType.UNIVER_DOC),T(this,`_name$`,new t.BehaviorSubject(``)),T(this,`name$`,this._name$.asObservable()),T(this,`snapshot`,void 0),T(this,`_mutationRevision`,0),this.snapshot=wy(e),this._name$.next(this.snapshot.title??`No Title`)}getRev(){return this.snapshot.rev??1}incrementRev(){this.snapshot.rev=this.getRev()+1}setRev(e){this.snapshot.rev=e}setName(e){this.snapshot.title=e,this._markMutation(),this._name$.next(e)}get drawings(){return this.snapshot.drawings}get documentStyle(){return this.snapshot.documentStyle}get lists(){return this.snapshot.lists}get zoomRatio(){var e;return((e=this.snapshot.settings)==null?void 0:e.zoomRatio)||1}resetDrawing(e,t){this.snapshot.drawings=e,this.snapshot.drawingsOrder=t,this._markMutation()}getBody(){return this.snapshot.body}getSnapshot(){return this.snapshot}getBulletPresetList(){let e=this.snapshot.lists??{};return{...H_,...e}}updateDocumentId(e){this.snapshot.id=e}updateDocumentRenderConfig(e){let{documentStyle:t}=this.snapshot;t.renderConfig=t.renderConfig==null?e:{...t.renderConfig,...e},this._markMutation()}getDocumentStyle(){return this.snapshot.documentStyle}updateDocumentStyle(e){this.snapshot.documentStyle==null?this.snapshot.documentStyle=e:this.snapshot.documentStyle={...this.snapshot.documentStyle,...e},this._markMutation()}updateDocumentDataMargin(e){let{t,l:n,b:r,r:i}=e,{documentStyle:a}=this.snapshot;t!=null&&(a.marginTop=t),n!=null&&(a.marginLeft=n),r!=null&&(a.marginBottom=r),i!=null&&(a.marginRight=i),this._markMutation()}updateDocumentDataPageSize(e,t){let{documentStyle:n}=this.snapshot;n.pageSize?(e!==void 0&&e!==n.pageSize.width||t!==void 0&&t!==n.pageSize.height)&&(e!==void 0&&(n.pageSize.width=e),t!==void 0&&(n.pageSize.height=t),this._markMutation()):(n.pageSize={width:e??1/0,height:t??1/0},this._markMutation())}updateDrawing(e,t){let{drawings:n}=this,{width:r,height:i,left:a,top:o}=t,s=n==null?void 0:n[e];if(!s)return;let c=s.docTransform;c.size.width=r,c.size.height=i,c.positionH.posOffset=a,c.positionV.posOffset=o,this._markMutation()}setZoomRatio(e=1){this.snapshot.settings?this.snapshot.settings.zoomRatio=e:this.snapshot.settings={zoomRatio:e},this._markMutation()}setDisabled(e){this.snapshot.disabled=e,this._markMutation()}getDisabled(){return this.snapshot.disabled}getTitle(){return this.snapshot.title}getMutationRevision(){return this._mutationRevision}_markMutation(){this._mutationRevision++}},Ey=class e extends Ty{constructor(e){super(z.isEmptyObject(e)?Zh():e),T(this,`_unitId`,void 0),T(this,`headerModelMap`,/* @__PURE__ */ new Map),T(this,`footerModelMap`,/* @__PURE__ */ new Map),T(this,`noteModelMap`,/* @__PURE__ */ new Map),T(this,`change$`,new t.BehaviorSubject(0)),this._unitId=this.snapshot.id??J(6),this._initializeHeaderFooterModel(),this._name$.next(this.snapshot.title??``)}dispose(){super.dispose(),this.headerModelMap.forEach(e=>{e.dispose()}),this.footerModelMap.forEach(e=>{e.dispose()}),this.noteModelMap.forEach(e=>e.dispose()),this.noteModelMap.clear(),this._name$.complete()}getDrawings(){return this.snapshot.drawings}getDrawingsOrder(){return this.snapshot.drawingsOrder}getCustomRanges(){var e;return(e=this.snapshot.body)==null?void 0:e.customRanges}getCustomDecorations(){var e;return(e=this.snapshot.body)==null?void 0:e.customDecorations}getSettings(){return this.snapshot.settings}reset(e){if(e.id&&e.id!==this._unitId)throw Error(`Cannot reset a document model with a different unit id!`);this.snapshot=wy(e),this._initializeHeaderFooterModel(),this._markMutation(),this.change$.next(this.change$.value+1)}getSelfOrHeaderFooterModel(e){return e==null||e===``?this:this.headerModelMap.has(e)?this.headerModelMap.get(e):this.footerModelMap.has(e)?this.footerModelMap.get(e):this.noteModelMap.has(e)?this.noteModelMap.get(e):null}getUnitId(){return this._unitId}apply(e){if(_y.isNoop(e))return;let t=this.snapshot.notes,n=/* @__PURE__ */ new Set,r=!1,i=sg.type.readCursor(e);return i.traverse(null,()=>{let e=i.getPath();e[0]===`notes`&&typeof e[1]==`string`&&n.add(e[1]),(e[0]===`styles`||e[0]===`documentStyle`)&&(r=!0)}),this.snapshot=_y.apply(this.snapshot,z.deepClone(e)),this._markMutation(),(r||t!==this.snapshot.notes||n.size>0)&&this._initializeNoteModels(r?void 0:t,n),e!=null&&e.some(e=>Array.isArray(e)&&((e==null?void 0:e[0])===`headers`||(e==null?void 0:e[0])===`footers`))&&(this.headerModelMap.clear(),this.footerModelMap.clear(),this._initializeHeaderFooterModel()),this.change$.next(this.change$.value+1),this.snapshot}sliceBody(e,t,n=0){let r=this.getBody();if(r!=null)return Cv(r,e,t,!1,n)}_initializeHeaderFooterModel(){this._initializeNoteModels();let{headers:t,footers:n}=this.getSnapshot();if(t)for(let n in t){let r=t[n];this.headerModelMap.set(n,new e({...r,documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles})),this.headerModelMap.get(n).updateDocumentId(this.getUnitId())}if(n)for(let t in n){let r=n[t];this.footerModelMap.set(t,new e({...r,documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles})),this.footerModelMap.get(t).updateDocumentId(this.getUnitId())}}_initializeNoteModels(t,n){for(let[e,i]of this.noteModelMap){var r;(n!=null&&n.has(e)||(t==null?void 0:t[e])!==((r=this.snapshot.notes)==null?void 0:r[e])||!(t!=null&&t[e]))&&(i.dispose(),this.noteModelMap.delete(e))}for(let[t,n]of Object.entries(this.snapshot.notes??{})){if(this.noteModelMap.has(t))continue;let r=new e({...n,id:this.getUnitId(),documentStyle:this.snapshot.documentStyle,styles:this.snapshot.styles});this.noteModelMap.set(t,r)}}updateDocumentStyle(e){super.updateDocumentStyle(e),this._initializeNoteModels()}updateDocumentId(e){super.updateDocumentId(e),this._unitId=e}getPlainText(){var e;return yy(((e=this.getBody())==null?void 0:e.dataStream)??``)}getStatistics(e={}){var t;return Fm(((t=this.getBody())==null?void 0:t.dataStream)??``,e)}};function Dy(e,t,n,r){if(t===``)return e;let i=new Ey({id:`mock-id`,body:e,documentStyle:{}}),a=t.length,o=Hl(t,r?`g`:`gi`),s;for(;(s=o.exec(i.getBody().dataStream))!==null;){let e=s.index,t=new X,r=_y.getInstance();if(e>0&&t.retain(e),n.length>0){var c;i.getBody().customDecorations??=[];let r=i.sliceBody(e,e+a),o={dataStream:n};Array.isArray(r==null?void 0:r.textRuns)&&r.textRuns.length&&(o.textRuns=[{...r.textRuns[0],st:0,ed:n.length}]),r!=null&&(c=r.customRanges)!=null&&c.length&&(o.customRanges=[{...r.customRanges[0],startIndex:0,endIndex:n.length-1}]),t.insert(n.length,o)}t.delete(a),i.apply(r.editOp(t.serialize())),o.lastIndex=e+n.length}let l=i.getBody();return i.dispose(),l}function Oy(e){let{ranges:t,id:n,type:r}=e,i=new X,a=0;for(let e=0;e<t.length;e++){let{startOffset:o,endOffset:s}=t[e];o>0&&i.push({t:`r`,len:o-a}),i.push({t:`r`,body:{dataStream:``,customDecorations:[{id:n,type:r,startIndex:0,endIndex:s-o-1}]},len:s-o}),a=s}return i}function ky(e){var t;let{id:n,segmentId:r,documentDataModel:i}=e,a=i==null?void 0:i.getBody();if(!i||!a)return!1;let o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customDecorations)==null?void 0:t.find(e=>e.id===n);if(!o)return!1;let s=new X,{startIndex:c,endIndex:l}=o,u=l-c+1;return s.push({t:`r`,len:c}),s.push({t:`r`,len:u,body:{dataStream:``,customDecorations:[{startIndex:0,endIndex:u-1,id:n,type:9999}]}}),s}function Ay(e,t,n,r){return e<=n&&t>=n||e>=n&&e<=r}function jy(e,t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];e.collapsed?bg(hg(i),e.startOffset)&&n.push(i):xg({startOffset:e.startOffset,endOffset:e.endOffset},hg(i))&&n.push(i)}return n}function My(e){return{...z.deepClone(e),rangeId:J()}}function Ny(e,t){let n=[],r=e[0];for(let i of t)i<e[0]||i>e[1]||(r<i&&n.push([r,i-1]),r=i+1);return r<=e[1]&&n.push([r,e[1]]),n}function Py(e,t,n,r){let i=[],a=ug({startIndex:e,endIndex:t});for(let e=0,o=n.length;e<o;e++){let o=n[e];if((r===void 0||o.rangeType===r)&&xg(a,hg(o))&&i.push({...o}),o.startIndex>t)break}return i}function Fy(e,t){var n,r;let i=Py(e.startOffset,e.collapsed?e.startOffset:e.endOffset-1,t.customRanges??[]),a=Math.min(e.startOffset,((n=i[0])==null?void 0:n.startIndex)??1/0),o=Math.max(e.endOffset,(((r=i[i.length-1])==null?void 0:r.endIndex)??-1/0)+1);return{startOffset:a,endOffset:o,collapsed:a===o}}var Iy=/* @__PURE__ */ h((/* @__PURE__ */ f(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;)if(a<e.length-1&&!e[a][1])e.splice(a,1);else switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O})))());function Ly(e){var t;let{rangeId:n,segmentId:r,documentDataModel:i,insert:a}=e,o=(t=i.getSelfOrHeaderFooterModel(r))==null||(t=t.getBody())==null||(t=t.customRanges)==null?void 0:t.find(e=>e.rangeId===n);if(!o)return!1;let{startIndex:s,endIndex:c}=o,l=new X,u=c-s+1;l.push({t:`r`,len:s}),l.push({t:`r`,len:u,body:{dataStream:``,customRanges:[]}}),a&&l.push({t:`i`,body:a,len:a.dataStream.length});let d=c+1+((a==null?void 0:a.dataStream.length)??0);return l.selections=[{startOffset:d,endOffset:d,collapsed:!0}],l}function Ry(e){let{ranges:t,rangeId:n,rangeType:r,wholeEntity:i,properties:a,body:o}=e,s=0,c=new X,l=!1;return t.forEach(e=>{let t=Fy(e,o);if(!t||!o)return!1;let{startOffset:u,endOffset:d}=t,f=o.customRanges??[],p=(e,t,o)=>{var l,u;let d=Py(e,t,f,r),p=Math.min(((l=d[0])==null?void 0:l.startIndex)??1/0,e),m=Math.max(((u=d[d.length-1])==null?void 0:u.endIndex)??-1/0,t),h={rangeId:o?`${n}$${o}`:n,rangeType:r,startIndex:0,endIndex:m-p,wholeEntity:i,properties:{...a}};c.push({t:`r`,len:p-s}),c.push({t:`r`,len:m-p+1,body:{dataStream:``,customRanges:[h]},coverType:0}),s=m+1},m=(o.paragraphs??[]).filter(e=>e.startIndex<d&&e.startIndex>u),h=(o.customBlocks??[]).filter(e=>e.startIndex<d&&e.startIndex>u);Ny([u,d-1],[...m.map(e=>e.startIndex),...h.map(e=>e.startIndex)]).forEach(([e,t],n)=>p(e,t,n)),l=!0,c.selections=[{startOffset:t.endOffset,endOffset:t.endOffset,collapsed:!0}]}),l?c:!1}function zy(e,t){return!!(e.atomicRange&&t.some(t=>t.startOffset<=e.atomicRange.startOffset&&t.endOffset>=e.atomicRange.endOffset))}let By=/* @__PURE__ */ new Set([`\r`,`
|
|
9
|
+
`]),Vy=/* @__PURE__ */ new Set([...By,``,``,``,``]);function Hy(e){let t=e.filter(e=>e.endOffset>e.startOffset).map(e=>({...e,collapsed:!1})).sort((e,t)=>e.startOffset-t.startOffset||e.endOffset-t.endOffset),n=[];for(let e of t){let t=n[n.length-1];t&&e.startOffset<=t.endOffset?t.endOffset=Math.max(t.endOffset,e.endOffset):n.push(e)}return n}function Uy(e,t,n,r){let i=e.startOffset,a=!1;for(let o of t){if(o.endOffset<=i||o.startOffset>=e.endOffset)continue;a=!0;let t=Math.max(o.startOffset,e.startOffset),s=Math.min(o.endOffset,e.endOffset);for(let e=i;e<t;e++)if(!r.has(n.dataStream[e]))return!1;if(i=Math.max(i,s),i>=e.endOffset)return!0}for(let t=i;t<e.endOffset;t++)if(!r.has(n.dataStream[t]))return!1;return a}function Wy(e,t,n,r){let i=[...e],a=e[0];for(let e of t)Uy(e,i,n,r)&&i.push({...a,...e,collapsed:!1});return Hy(i)}function Gy(e,t){let n=Hy(e);n=Wy(n,(t.blockRanges??[]).map(pg),t,By),n=Wy(n,(t.customRanges??[]).map(hg),t,By),n=Wy(n,(t.columnGroups??[]).map(mg),t,Vy);let r=Math.max(0,t.dataStream.length-2);return r>0&&(n=Wy(n,[{startOffset:0,endOffset:r}],t,By)),n}function Ky(e,t){return t.some(t=>e>=t.startOffset&&e<t.endOffset)}function qy(e,t){return e>=t.startOffset&&e<=t.endOffset}function Jy(e,t,n){e.length&&e.every(e=>Ky(e,t))&&n.add(e[e.length-1])}function Yy(e,t,n){let r=(e.columnGroups??[]).map(mg).filter(e=>t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset));for(let i=0;i<e.dataStream.length;i++){let a=e.dataStream[i];(a===``||a===``||a===``||a===``)&&Ky(i,t)&&!r.some(e=>i>=e.startOffset&&i<e.endOffset)&&n.add(i)}}function Xy(e,t,n){for(let r of e.blockRanges??[]){let e=pg(r);t.some(t=>t.startOffset<=e.startOffset&&t.endOffset>=e.endOffset)||(Ky(r.startIndex,t)&&n.add(r.startIndex),Ky(r.endIndex,t)&&n.add(r.endIndex))}}function Zy(e){let t=[...e.blockRanges??[]].sort((e,t)=>e.startIndex-t.startIndex),n=t.map(e=>{let t=pg(e);return{atomicRange:t,startOffset:t.startOffset+1,endOffset:t.endOffset-1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`}}),r=(e,r)=>{let i=0,a=t.length-1,o=-1;for(;i<=a;){let n=Math.floor((i+a)/2),r=t[n];if(e<=r.startIndex)a=n-1;else if(e>=r.endIndex)i=n+1;else{o=n;break}}o>=0&&n[o][r].push(e)};return(e.paragraphs??[]).forEach(e=>r(e.startIndex,`paragraphs`)),(e.sectionBreaks??[]).forEach(e=>r(e.startIndex,`sectionBreaks`)),n}function Qy(e){let t=[{startOffset:0,endOffset:e.dataStream.length,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`}],n=[],r=[],i=()=>r.length?r[r.length-1]:n.length?n[n.length-1]:t[0];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)n.push({atomicRange:{startOffset:a,endOffset:a+1},startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-or-section`});else if(o===``){let e=n.pop();e&&(e.endOffset=a,e.atomicRange&&(e.atomicRange.endOffset=a+1),t.push(e))}else if(o===``)r.push({startOffset:a+1,endOffset:a+1,paragraphs:[],sectionBreaks:[],require:`paragraph-and-section`});else if(o===``){let e=r.pop();e&&(e.endOffset=a,t.push(e))}else o===`\r`?i().paragraphs.push(a):o===`
|
|
10
|
+
`&&i().sectionBreaks.push(a)}return t.push(...Zy(e)),t}function $y(e,t,n,r,i){if(zy(e,t))return;let a=n&&qy(r,e),o=(n==null?void 0:n.dataStream)??``,s=o.includes(`\r`),c=o.includes(`
|
|
11
|
+
`);if(e.require===`paragraph-or-section`){let n=[...e.paragraphs,...e.sectionBreaks].sort((e,t)=>e-t);a&&(s||c)||Jy(n,t,i)}else a&&s||Jy(e.paragraphs,t,i),a&&c||Jy(e.sectionBreaks,t,i)}function eb(e,t,n){if(!e.length)return e;let r=n==null?Gy(e,t):e;if(!r.length)return e;let i=r[0].startOffset,a=/* @__PURE__ */ new Set;if(Qy(t).forEach(e=>{$y(e,r,n,i,a)}),Yy(t,r,a),Xy(t,r,a),!a.size)return r;let o=[];return r.forEach(e=>{let t=e.startOffset;for(let n=e.startOffset;n<e.endOffset;n++)a.has(n)&&(t<n&&o.push({...e,startOffset:t,endOffset:n,collapsed:!1}),t=n+1);t<e.endOffset&&o.push({...e,startOffset:t,endOffset:e.endOffset,collapsed:!1})}),o.length?o:[{...r[0],endOffset:r[0].startOffset,collapsed:!0}]}function tb(e,t,n=0,r=null,i=!0,a){let o=eb([...e].sort((e,t)=>e.startOffset-t.startOffset),t,r),s=[],{paragraphs:c=[]}=t,l=c==null?void 0:c.find(e=>e.startIndex>=o[0].startOffset&&e.startIndex<o[0].endOffset),u=n;if(o.forEach(e=>{var n;let{startOffset:i,endOffset:l}=e;i>u&&(s.push({t:`r`,len:i-u}),u=i),u<l&&(s.push({t:`d`,len:l-u}),u=l);let d=a===2&&o.length===1&&!r&&i<l?c.find(e=>e.startIndex===l&&iv(t,e)===i):void 0;if(d&&((n=d.paragraphStyle)==null?void 0:n.paragraphMarkTextStyle)==null){var f;let e=((f=t.textRuns)==null||(f=f.find(e=>e.st<=i&&e.ed>i))==null?void 0:f.ts)??{};s.push({t:`r`,len:1,body:{dataStream:``,textRuns:[{st:0,ed:1,ts:{...e}}]},coverType:1}),u++}}),r&&s.push({t:`i`,body:r,len:r.dataStream.length}),l!=null&&l.bullet&&i){let e=c.find(e=>e.startIndex-n>=o[o.length-1].endOffset-1);e&&(e.startIndex>u&&(s.push({t:`r`,len:e.startIndex-u}),u=e.startIndex),s.push({t:`r`,len:1,body:{dataStream:``,paragraphs:[{...e,startIndex:0,bullet:l==null?void 0:l.bullet}]},coverType:0}))}return s}function nb(e,t,n=0){let r=[],i=n;return e.forEach(e=>{let{startOffset:n,endOffset:a}=e;n>i&&(r.push({t:`r`,len:n-i}),i=n),a>i&&(r.push({t:`r`,len:a-i,body:{...z.deepClone(t),dataStream:``}}),i=a)}),r}let rb=e=>{var t;let{selection:n,body:r,doc:i}=e,a=n.segmentId,o=(t=i.getSelfOrHeaderFooterModel(a))==null?void 0:t.getBody();if(!o)return!1;let s=eb([n],o,r);if(s.length!==1||s[0].startOffset!==n.startOffset||s[0].endOffset!==n.endOffset){let e=new X;return e.push(...tb([n],o,0,r)),e}let c=n.collapsed?null:Cv(o,n.startOffset,n.endOffset),l=(0,Iy.default)(c?c.dataStream:``,r.dataStream),u=0,d=l.map(([e,t])=>{switch(e){case 0:{let e={t:`r`,body:{...wv(r,u,u+t.length,!1),dataStream:``},len:t.length};return u+=t.length,e}case 1:{let e={t:`i`,body:wv(r,u,u+t.length),len:t.length};return u+=t.length,e}default:return{t:`d`,len:t.length}}}),f=new X;return f.push({t:`r`,len:n.startOffset}),f.push(...d),f};function ib(e,t){return!!((e==null?void 0:e.length)===(t==null?void 0:t.length)&&e!=null&&e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t==null?void 0:t[n])))}let ab=e=>{var t;let{selection:n,body:r,doc:i,themeService:a}=e,o=n.segmentId,s=(t=i.getSelfOrHeaderFooterModel(o))==null?void 0:t.getBody();if(!s)return!1;let c=eb([n],s,r);if(c.length!==1||c[0].startOffset!==n.startOffset||c[0].endOffset!==n.endOffset){let e=new X;return e.push(...tb([n],s,0,r)),e}let l=n.collapsed?null:Cv(s,n.startOffset,n.endOffset),u=(0,Iy.default)(l?l.dataStream:``,r.dataStream),d=0,f=u.map(([e,t])=>{switch(e){case 0:{let e=fv(r,d,d+t.length,!1),n={t:`r`,body:ib(e,fv(l,d,d+t.length,!1))?void 0:{textRuns:e==null?void 0:e.map(e=>{var t,n,r;return{...e,ts:{...e.ts,cl:(t=e.ts)!=null&&(t=t.cl)!=null&&(t=t.rgb)!=null&&t.includes(`.`)?{rgb:a.getColorFromTheme(((n=e.ts)==null||(n=n.cl)==null?void 0:n.rgb)??``)}:(r=e.ts)==null?void 0:r.cl}}}),dataStream:``},len:t.length};return d+=t.length,n}case 1:{let e={t:`i`,body:wv(r,d,d+t.length),len:t.length};return d+=t.length,e}default:return{t:`d`,len:t.length}}});if(f.every(e=>e.t===`r`&&!e.body))return!1;let p=new X;return p.push({t:`r`,len:n.startOffset}),p.push(...f),p};function ob(e,t){let n=[],{customBlocks:r=[]}=e;for(let e of t){let{startOffset:t,endOffset:i}=e;if(t!=null&&i!=null)for(let e of r){let{startIndex:r}=e;r>=t&&r<i&&n.push(e.blockId)}}return n}function sb(e,t,n=e.body,r=``){var i;if(!n)return[];let a=(i=e.notes)==null?void 0:i[r],o=a??e,s=a?[`notes`,r]:[],c=o.drawings??{},l=o.drawingsOrder??[],u=new Set(ob(n,t)),d=-1;for(;d!==u.size;){d=u.size;for(let e of Object.values(c))e.groupId&&u.has(e.groupId)&&u.add(e.drawingId)}let f=[...u].sort((e,t)=>l.indexOf(t)-l.indexOf(e)),p=_y.getInstance(),m=[];for(let e of f){let t=c[e];if(t!=null){let n=p.removeOp([...s,`drawings`,e],t);n&&m.push(n)}let n=l.indexOf(e);if(n>=0){let t=p.removeOp([...s,`drawingsOrder`,n],e);t&&m.push(t)}}return m}let cb=e=>{var t,n;let{selection:r,documentDataModel:i,drawings:a}=e,{collapsed:o,startOffset:s,segmentId:c}=r,l=new X,u=_y.getInstance(),d=[],f=(t=i.getSelfOrHeaderFooterModel(c))==null?void 0:t.getBody();if(!f)return!1;let p=i.getSnapshot(),m=(n=p.notes)==null?void 0:n[c??``],h=m??p,g=m?[`notes`,c]:[],_=h.drawingsOrder??[],v=_.length;h.drawings??d.push(u.insertOp([...g,`drawings`],{})),h.drawingsOrder??d.push(u.insertOp([...g,`drawingsOrder`],[]));let y=o?lb(f,s??0):s??0;if(o)y>0&&l.push({t:`r`,len:y});else{let e=tb([r],f,0,null,!1);l.push(...e);let t=new Set(ob(f,[r]));v-=_.filter(e=>t.has(e)).length;for(let e of sb(p,[r],f,c))e&&d.push(e)}let b=db(f,a,y);l.push({t:`i`,body:b,len:b.dataStream.length});let x=Lv(i,c),S=u.editOp(l.serialize(),x);d.push(S);for(let e of a){let{drawingId:t}=e,n=u.insertOp([...g,`drawings`,t],e),r=u.insertOp([...g,`drawingsOrder`,v++],t);d.push(n),d.push(r)}return d.reduce((e,t)=>_y.compose(e,t),null)};function lb(e,t){let{dataStream:n}=e;return t===0&&n[0]===`\r`?1:n[t]===`
|
|
12
|
+
`&&n[t-1]===`\r`&&ub(n,t)?t-1:t}function ub(e,t){let n=0;for(let r=0;r<t;r++)e[r]===``?n++:e[r]===``&&(n=Math.max(0,n-1));return n>0}function db(e,t,n){var r;let i=`\b`.repeat(t.length),a=e.dataStream[n]===`
|
|
13
|
+
`||e.dataStream[n]===void 0;return{dataStream:a?`${i}\r`:i,customBlocks:t.map((e,t)=>({startIndex:t,blockId:e.drawingId})),...a?{paragraphs:[{startIndex:i.length,paragraphId:Gh(new Set((r=e.paragraphs)==null?void 0:r.map(e=>e.paragraphId)))}]}:{}}}function fb(e,t){if(e==null||t==null)return null;let n=e.dataStream,r=t.dataStream;if(n===r)return null;let i=r.length-n.length;if(i>0){let a=mb(e,t,n,r,i);if(a)return a}else if(i<0){let a=pb(e,t,n,r,-i);if(a)return a}let a=0;for(;a<n.length&&a<r.length&&n[a]===r[a];)a++;let o=n.length,s=r.length;for(;o>a&&s>a&&n[o-1]===r[s-1];)o--,s--;return{start:a,deleteLength:o-a,insertLength:s-a}}function pb(e,t,n,r,i){for(let a of hb(t,e))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a+i)===r.slice(a))return{start:a,deleteLength:i,insertLength:0};return null}function mb(e,t,n,r,i){for(let a of hb(e,t))if(n.slice(0,a)===r.slice(0,a)&&n.slice(a)===r.slice(a+i))return{start:a,deleteLength:0,insertLength:i};return null}function hb(e,t){let n=[...gb(e.blockRanges,t.blockRanges,e=>e.blockId),...gb(e.tables,t.tables,e=>e.tableId),...gb(e.columnGroups,t.columnGroups,e=>e.columnGroupId),...gb(e.customBlocks,t.customBlocks,e=>e.blockId)];return Array.from(new Set(n)).sort((e,t)=>e-t)}function gb(e,t,n){let r=new Set((e??[]).map(n));return(t??[]).filter(e=>!r.has(n(e))).map(e=>e.startIndex)}var Z=class{};T(Z,`customRange`,{add:Ry,delete:Ly,copyCustomRange:My,getCustomRangesInterestsWithSelection:jy,isIntersecting:Ay}),T(Z,`customDecoration`,{add:Oy,delete:ky}),T(Z,`selection`,{replace:rb,makeSelection:K_,normalizeSelection:q_,delete:tb,replaceTextRuns:ab,retain:nb}),T(Z,`range`,{isIntersects:J_,getParagraphsInRange:Y_,getParagraphsInRanges:X_}),T(Z,`transform`,{getPlainText:yy,fromPlainText:xy,isEmptyDocument:by}),T(Z,`paragraph`,{bullet:{set:tv,switch:$_,toggleChecklist:ev,changeNestLevel:sv},style:{set:cv},util:{transform:Q_,getParagraphsInRange:Y_,getParagraphsInRanges:X_}}),T(Z,`drawing`,{add:cb,remove:sb});let _b=new Set(Object.values(Tm).filter(e=>e!==``&&e!==` `));function vb(e){if(e.customRanges||=[],!e.paragraphs){e.paragraphs=[];let t=/* @__PURE__ */ new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`\r`&&e.paragraphs.push({startIndex:n,paragraphId:Gh(t)})}if(e.customBlocks||=[],e.textRuns||=[],e.customDecorations||=[],!e.sectionBreaks){e.sectionBreaks=[];let t=/* @__PURE__ */ new Set;for(let n=0;n<e.dataStream.length;n++)e.dataStream[n]===`
|
|
14
|
+
`&&e.sectionBreaks.push({startIndex:n,sectionId:xm(t)})}return e.tables||=[],e}function yb(e){return e.body=vb(e.body??{dataStream:``}),e.drawingsOrder||=[],e.drawings||={},e.documentStyle||={},e}function bb(e){return typeof e==`string`?{rgb:e}:e}function xb(e){let{bold:t,italic:n,fontFamily:r,fontSize:i,color:a,background:o,...s}=e,c={...s};return t!==void 0&&(c.bl=+!!t),n!==void 0&&(c.it=+!!n),r!==void 0&&(c.ff=r),i!==void 0&&(c.fs=i),a!==void 0&&(c.cl=bb(a)),o!==void 0&&(c.bg=bb(o)),c}function Sb(e){return typeof e==`number`?{v:e}:e}function Cb(e){if(e)return e instanceof kb?e.build():{horizontalAlign:e.align,lineSpacing:e.lineHeight,spacingRule:e.lineHeightRule,indentFirstLine:Sb(e.firstLineIndent),hanging:Sb(e.hangingIndent),indentStart:Sb(e.indentStart),indentEnd:Sb(e.indentEnd),spaceAbove:Sb(e.spaceBefore),spaceBelow:Sb(e.spaceAfter),direction:e.direction,wordWrap:e.wordWrap===void 0?void 0:+!!e.wordWrap,keepLines:e.keepLines===void 0?void 0:+!!e.keepLines,keepNext:e.keepNext===void 0?void 0:+!!e.keepNext}}function wb(e){var t;return(((t=e.body)==null?void 0:t.dataStream)??``).replace(/\r|\n/g,``).length>0}var Tb=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get fontFamily(){return this._style.ff}get fontSize(){return this._style.fs}get italic(){return this._style.it===1}get bold(){return this._style.bl===1}get underline(){return this._style.ul&&Db.create(this._style.ul)}get bottomBorderLine(){return this._style.bbl&&Db.create(this._style.bbl)}get strikethrough(){return this._style.st&&Db.create(this._style.st)}get overline(){return this._style.ol&&Db.create(this._style.ol)}get background(){return this._style.bg}get border(){return this._style.bd}get color(){return this._style.cl}get verticalAlign(){return this._style.va}get numberFormat(){return this._style.n}copy(){return Eb.create(z.deepClone(this._style))}getValue(){return{...this._style}}},Eb=class e extends Tb{static create(t={}){return new e(t)}constructor(e={}){super(e)}setFontFamily(e){return this._style.ff=e,this}setFontSize(e){return this._style.fs=e,this}setItalic(e){return this._style.it=+!!e,this}setBold(e){return this._style.bl=+!!e,this}setUnderline(e){return this._style.ul=e.build(),this}setBottomBorderLine(e){return this._style.bbl=e.build(),this}setStrikethrough(e){return this._style.st=e.build(),this}setOverline(e){return this._style.ol=e.build(),this}setBackground(e){return this._style.bg=e,this}setBorder(e){return this._style.bd=e,this}setColor(e){return this._style.cl=e,this}setVerticalAlign(e){return this._style.va=e,this}copy(){return e.create(z.deepClone(this._style))}build(){return this.getValue()}},Db=class e{static create(t={s:1}){return new e(t)}constructor(e={s:1}){T(this,`_decoration`,void 0),this._decoration=e}get show(){return this._decoration.s===1}get followFontColor(){return this._decoration.c===1}get color(){return this._decoration.cl}get type(){return this._decoration.t}setShow(e){return this._decoration.s=+!!e,this}setFollowFontColor(e){return this._decoration.c=+!!e,this}setColor(e){return this._decoration.cl=e,this}setLineType(e){return this._decoration.t=e,this}copy(){return e.create(z.deepClone(this._decoration))}build(){return{...this._decoration}}},Ob=class e{static create(t={}){return new e(t)}constructor(e={}){T(this,`_style`,void 0),this._style=e}get indentFirstLine(){return this._style.indentFirstLine}get hanging(){return this._style.hanging}get indentStart(){return this._style.indentStart}get tabStops(){return this._style.tabStops}get indentEnd(){return this._style.indentEnd}get textStyle(){return this._style.textStyle}get headingId(){return this._style.headingId}get namedStyleType(){return this._style.namedStyleType}get horizontalAlign(){return this._style.horizontalAlign}get lineSpacing(){return this._style.lineSpacing}get direction(){return this._style.direction}get spacingRule(){return this._style.spacingRule}get snapToGrid(){return this._style.snapToGrid}get spaceAbove(){return this._style.spaceAbove}get spaceBelow(){return this._style.spaceBelow}get borderBetween(){return this._style.borderBetween}get borderTop(){return this._style.borderTop}get borderBottom(){return this._style.borderBottom}get borderLeft(){return this._style.borderLeft}get borderRight(){return this._style.borderRight}get keepLines(){return this._style.keepLines===1}get keepNext(){return this._style.keepNext===1}get wordWrap(){return this._style.wordWrap===1}get widowControl(){return this._style.widowControl===1}get shading(){return this._style.shading}get suppressHyphenation(){return this._style.suppressHyphenation===1}copy(){return kb.create(z.deepClone(this._style))}getValue(){return this._style}},kb=class e extends Ob{static create(t={}){return new e(t)}constructor(e={}){super(e)}setIndentFirstLine(e){return this._style.indentFirstLine=e,this}setHanging(e){return this._style.hanging=e,this}setIndentStart(e){return this._style.indentStart=e,this}setTabStops(e){return this._style.tabStops=e,this}setIndentEnd(e){return this._style.indentEnd=e,this}setTextStyle(e){return this._style.textStyle=e,this}setHeadingId(e){return this._style.headingId=e,this}setNamedStyleType(e){return this._style.namedStyleType=e,this}setHorizontalAlign(e){return this._style.horizontalAlign=e,this}setLineSpacing(e){return this._style.lineSpacing=e,this}setDirection(e){return this._style.direction=e,this}setSpacingRule(e){return this._style.spacingRule=e,this}setSnapToGrid(e){return this._style.snapToGrid=+!!e,this}setSpaceAbove(e){return this._style.spaceAbove=e,this}setSpaceBelow(e){return this._style.spaceBelow=e,this}setBorderBetween(e){return this._style.borderBetween=e,this}setBorderTop(e){return this._style.borderTop=e,this}setBorderBottom(e){return this._style.borderBottom=e,this}setBorderLeft(e){return this._style.borderLeft=e,this}setBorderRight(e){return this._style.borderRight=e,this}setKeepLines(e){return this._style.keepLines=+!!e,this}setKeepNext(e){return this._style.keepNext=+!!e,this}setWordWrap(e){return this._style.wordWrap=+!!e,this}setWidowControl(e){return this._style.widowControl=+!!e,this}setShading(e){return this._style.shading=e,this}setSuppressHyphenation(e){return this._style.suppressHyphenation=+!!e,this}copy(){return e.create(z.deepClone(this._style))}build(){return this.getValue()}},Ab=class e{static create(t){return new e(t)}static createByBody(t){return new e({body:t,id:`d`,documentStyle:{}})}constructor(e){if(T(this,`_data`,void 0),!e.body)throw Error(`Invalid document data, body is required`);this._data=yb(e)}copy(){return jb.create(z.deepClone(this._data))}slice(e,t){let{body:n,...r}=this._data;return jb.create({...z.deepClone(r),body:Cv(n,e,t)})}toPlainText(){var e;return Z.transform.getPlainText(((e=this._data.body)==null?void 0:e.dataStream)??``).replaceAll(`\r`,`
|
|
15
|
+
`)}getParagraphStyle(){var e;return Ob.create((e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].paragraphStyle)}getParagraphBullet(){var e;return(e=this._data.body)==null||(e=e.paragraphs)==null?void 0:e[0].bullet}getParagraphs(){let e=this._data.body;if(!e)return[];let t=av(e);return(e.paragraphs??[]).map(e=>jb.create(Pb(this._data,e.paragraphId,{startOffset:t.get(e.startIndex)??0,endOffset:e.startIndex})))}getTextRuns(){var e;return(((e=this._data.body)==null?void 0:e.textRuns)??[]).map(e=>({...e,ts:e.ts?Tb.create(e.ts):null}))}getLinks(){var e;return((e=this._data.body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getData(){return this._data}},jb=class e extends Ab{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`constructor`)return;let n=Object.getOwnPropertyDescriptor(e.prototype,t);n&&Object.defineProperty(this.prototype,t,n)})}static newEmptyData(){return yb({id:`d`,documentStyle:{},drawings:{},drawingsOrder:[],body:{dataStream:`\r
|
|
16
|
+
`,customBlocks:[],customRanges:[],paragraphs:[{startIndex:0,paragraphId:Gh(/* @__PURE__ */ new Set)}],textRuns:[],tables:[],sectionBreaks:[]}})}static create(t){return new e(t??e.newEmptyData())}constructor(e){super(e),T(this,`_doc`,void 0),T(this,`_trackedRanges`,/* @__PURE__ */ new Set),T(this,`_childHandleRevision`,0),this._doc=new Ey(e),this._data.body=this._doc.getBody()}getParagraphs(){let e=this._data.body;if(!e)return[];let t=av(e);return(e.paragraphs??[]).map(e=>this._createParagraphBuilder(e.paragraphId,t.get(e.startIndex)??0,e.startIndex))}getTextRuns(){return this.getParagraphs().flatMap(e=>e.getTextRuns())}_createTextRunBuilders(e){let t=this._data.body;if(!t||e.startOffset>=e.endOffset)return[];let n=/* @__PURE__ */ new Set([e.startOffset,e.endOffset]),r=(t,r)=>{let i=Math.max(t,e.startOffset),a=Math.min(r,e.endOffset);i<a&&(n.add(i),n.add(a))};for(let e of t.textRuns??[])r(e.st,e.ed);for(let e of t.customRanges??[])r(e.startIndex,e.endIndex+1);for(let e of t.customDecorations??[])r(e.startIndex,e.endIndex+1);for(let r=e.startOffset;r<e.endOffset;r++)_b.has(t.dataStream[r])&&(n.add(r),n.add(r+1));let i=[...n].sort((e,t)=>e-t),a=[];for(let e=0;e<i.length-1;e++){let n=i[e],r=i[e+1];if(n>=r||r-n===1&&_b.has(t.dataStream[n]))continue;let o=(t.textRuns??[]).find(e=>e.st<=n&&e.ed>=r);a.push(new Nb(this,this._trackRange(n,r),o==null?void 0:o.ts,o==null?void 0:o.sId,!!o,this._childHandleRevision))}return a}_replaceTextRun(e,t,n,r,i){var a,o;if(t.includes(`\r`)||t.includes(`
|
|
17
|
+
`))throw RangeError(`Rich text run replacement cannot contain paragraph or section breaks.`);let s=this._doc.getBody();if(!s)throw Error(`Rich text body is not available.`);let{startOffset:c,endOffset:l}=e;if(s.dataStream.slice(c,l)===t)return;let u=Cv(s,c,l),d={dataStream:t};t&&i&&(d.textRuns=[{st:0,ed:t.length,sId:r,ts:z.deepClone(n)}]),t&&(a=u.customRanges)!=null&&a.length&&(d.customRanges=u.customRanges.map(e=>({...z.deepClone(e),startIndex:0,endIndex:t.length-1}))),t&&(o=u.customDecorations)!=null&&o.length&&(d.customDecorations=u.customDecorations.map(e=>({...z.deepClone(e),startIndex:0,endIndex:t.length-1})));let f=Z.selection.replace({doc:this._doc,selection:{startOffset:c,endOffset:l,collapsed:c===l},body:d});if(!f)throw Error(`Replace rich text run failed.`);X.apply(s,f.serialize()),this._rebaseTrackedRanges(c,l,t.length)}_createParagraphBuilder(e,t,n){return new Mb(this,e,this._trackRange(t,n),this._childHandleRevision)}_assertChildHandleRevision(e){if(e!==this._childHandleRevision)throw Error(`Rich text child handle is no longer valid.`)}_trackRange(e,t){let n={startOffset:e,endOffset:t};return this._trackedRanges.add(n),n}_rebaseTrackedRanges(e,t,n){let r=n-(t-e),i=n=>n<=e?n:n>=t?n+r:e,a=i=>i<=e?i:i>=t?i+r:e+n;for(let e of this._trackedRanges)e.startOffset=i(e.startOffset),e.endOffset=a(e.endOffset)}_invalidateChildHandles(){this._childHandleRevision++,this._trackedRanges.clear()}text(e){return this.insertText(e)}align(e){let t=this._data.documentStyle??={},n=t.renderConfig??={};if(e.horizontal!==void 0){var r;n.horizontalAlign=e.horizontal;for(let t of((r=this._data.body)==null?void 0:r.paragraphs)??[])t.paragraphStyle={...t.paragraphStyle,horizontalAlign:e.horizontal}}return e.vertical!==void 0&&(n.verticalAlign=e.vertical),this}columns(e){if(!Number.isInteger(e.count)||e.count<1)throw RangeError(`Rich text column count must be a positive integer.`);let t=this._data.body??={dataStream:`\r
|
|
18
|
+
`},n=t.sectionBreaks??=[];if(!n.length){var r;n.push({sectionId:xm(/* @__PURE__ */ new Set),startIndex:Math.max(0,(((r=t.dataStream)==null?void 0:r.length)??0)-1)})}let i=Math.max(0,e.spacing??0),a=e.count===1?void 0:Array.from({length:e.count},(t,n)=>({width:0,paddingEnd:n===e.count-1?0:i}));for(let e of n)a?e.columnProperties=a.map(e=>({...e})):delete e.columnProperties;return this}span(e,t){return e?t?this.insertText(e,xb(t)):this.insertText(e):this}bold(e){return this.span(e,{bold:!0})}italic(e){return this.span(e,{italic:!0})}code(e){return this.span(e,{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,background:`#f3f4f6`})}link(e,t){return e?this.insertLink(e,t):this}listItem(e,t={}){var n,r,i;let a=t.type??`BULLET_LIST`,o=(n=this._data.body)==null||(n=n.paragraphs)==null?void 0:n.slice(-1)[0],s=o==null?void 0:o.bullet,c=((r=t.listId)==null?void 0:r.trim())||((s==null?void 0:s.listType)===a?s.listId:J());(wb(this._data)||t.paragraphStyle)&&this.paragraph(t.paragraphStyle);let l=(i=this._data.body)==null||(i=i.paragraphs)==null?void 0:i.slice(-1)[0];return l&&(l.bullet={listId:c,listType:a,nestingLevel:Math.max(0,Math.trunc(t.level??0))}),this.text(e)}paragraph(e){var t,n,r;let i=Cb(e);if(!wb(this._data)){if(i){var a;let e=(a=this._data.body)==null||(a=a.paragraphs)==null?void 0:a[0];e&&(e.paragraphStyle=i)}return this}let o=(t=this._data.body)==null||(t=t.paragraphs)==null?void 0:t.slice(-1)[0],s=z.deepClone(o==null?void 0:o.paragraphStyle),c=z.deepClone(o==null?void 0:o.bullet),l=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2);this.insertRichText(l,Ab.create({id:`d`,documentStyle:{},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Gh(/* @__PURE__ */ new Set),paragraphStyle:s,bullet:c}]}}));let u=(r=this._data.body)==null||(r=r.paragraphs)==null?void 0:r.slice(-1)[0];return i?u&&(u.paragraphStyle=i):u&&delete u.paragraphStyle,u&&delete u.bullet,this}insertText(e,t,n){var r;let i=(((r=this._data.body)==null?void 0:r.dataStream.length)??2)-2,a,o;if(typeof e==`string`?a=e:(i=Math.min(e,i),a=typeof t==`string`?t:``),o=typeof t==`object`?t instanceof Eb?t.build():t:n instanceof Eb?n.build():n,!a)return this;let s=Z.transform.fromPlainText(a),c={dataStream:s.dataStream,paragraphs:s.paragraphs,textRuns:o?[{ts:o,st:0,ed:s.dataStream.length}]:[]},l=Z.selection.replace({doc:this._doc,selection:{startOffset:i,endOffset:i,collapsed:!0},body:c});if(!l)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),l.serialize()),this._invalidateChildHandles(),this}insertRichText(e,t){var n;let r=(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2,i;typeof e==`object`?i=e instanceof Ab?e.getData():e:(r=Math.min(e,r),i=t instanceof Ab?t.getData():t);let a=Z.selection.replace({doc:this._doc,selection:{startOffset:r,endOffset:r,collapsed:!0},body:i.body});if(!a)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),a.serialize()),this._invalidateChildHandles(),this}delete(e,t){var n;let r=Math.max(0,(((n=this._data.body)==null?void 0:n.dataStream.length)??2)-2),i,a;if(t===void 0){if(e<0)throw RangeError(`Delete count cannot be negative.`);a=Math.min(e,r),i=r-a}else{if(e<0||t<0)throw RangeError(`Delete range cannot be negative.`);i=Math.min(e,r),a=Math.min(t,r-i)}if(a>0){let e=Z.selection.delete([{startOffset:i,endOffset:i+a,collapsed:!0}],this._data.body);X.apply(this._doc.getBody(),e),this._invalidateChildHandles()}return this}setStyle(e,t,n){let r={dataStream:``,textRuns:[{ts:n instanceof Eb?n.build():n,st:0,ed:t-e}]},i=Z.selection.retain([{startOffset:e,endOffset:t,collapsed:!0}],r);return X.apply(this._doc.getBody(),i),this._invalidateChildHandles(),this}setLink(e,t,n){let r=Z.customRange.add({rangeType:0,rangeId:J(),properties:{url:n},ranges:[{startOffset:e,endOffset:t,collapsed:!1}],body:this._data.body});if(!r)throw Error(`Insert text failed, please check.`);return X.apply(this._doc.getBody(),r.serialize()),this._invalidateChildHandles(),this}cancelLink(e,t){let n=!1;if(typeof e==`string`){let t=Z.customRange.delete({rangeId:e,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0}else this.slice(e,t).getLinks().forEach(e=>{let t=Z.customRange.delete({rangeId:e.rangeId,documentDataModel:this._doc});if(!t)throw Error(`Insert text failed, please check.`);X.apply(this._doc.getBody(),t.serialize()),n=!0});return n&&this._invalidateChildHandles(),this}removeLink(e){return this.cancelLink(e)}updateLink(e,t){var n;let r=(n=this._data.body)==null||(n=n.customRanges)==null?void 0:n.find(t=>t.rangeId===e);if(!r)throw Error(`Link not found`);return r.properties.url=t,this}insertParagraph(e,t){let n,r;if(typeof e==`object`){var i;n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Gh(/* @__PURE__ */ new Set),paragraphStyle:e.build()}]},r=(((i=this._data.body)==null?void 0:i.dataStream.length)??2)-2}else r=e,n={dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:Gh(/* @__PURE__ */ new Set),paragraphStyle:t==null?void 0:t.build()}]};return this.insertRichText(r,Ab.create({body:n,id:`d`,documentStyle:{}})),this}insertLink(t,n,r){let i=``,a=``;typeof t==`string`?(i=t,a=n):(i=n,a=r);let o=e.createByBody({dataStream:i,customRanges:[{rangeType:0,rangeId:J(),properties:{url:a},startIndex:0,endIndex:i.length-1}]});return typeof t==`number`?this.insertRichText(t,o):this.insertRichText(o)}},Mb=class extends Ab{constructor(e,t,n,r){super(Pb(e.getData(),t,n)),this._owner=e,this._paragraphId=t,this._range=n,this._revision=r}getId(){return this._assertActive(),this._paragraphId}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}toPlainText(){return this.getText()}getTextRuns(){return this._assertActive(),this._owner._createTextRunBuilders(this._range)}getParagraphStyle(){return this._assertActive(),Ob.create(this._getParagraph().paragraphStyle)}getParagraphBullet(){return this._assertActive(),this._getParagraph().bullet}getLinks(){var e;return this._assertActive(),((e=this.getData().body)==null||(e=e.customRanges)==null?void 0:e.filter(e=>e.rangeType===0))??[]}getBullet(){return this.getParagraphBullet()}getData(){return this._assertActive(),Pb(this._owner.getData(),this._paragraphId,this._range)}copy(){return jb.create(z.deepClone(this.getData()))}_getParagraph(){var e;let t=(e=this._owner.getData().body)==null||(e=e.paragraphs)==null?void 0:e.find(e=>e.paragraphId===this._paragraphId);if(!t)throw Error(`Rich text paragraph "${this._paragraphId}" was not found.`);return t}_assertActive(){this._owner._assertChildHandleRevision(this._revision)}},Nb=class{constructor(e,t,n,r,i,a){this._owner=e,this._range=t,this._textStyle=n,this._styleId=r,this._hasExplicitTextStyle=i,this._revision=a,T(this,`_active`,!0)}get st(){return this._assertActive(),this._range.startOffset}get ed(){return this._assertActive(),this._range.endOffset}get sId(){return this._assertActive(),this._styleId}get ts(){return this._assertActive(),this._textStyle?Tb.create(this._textStyle):null}getRange(){return this._assertActive(),{...this._range}}getText(){var e;return this._assertActive(),(((e=this._owner.getData().body)==null?void 0:e.dataStream)??``).slice(this._range.startOffset,this._range.endOffset)}getTextStyle(){return this.ts}hasTextStyle(){return this._assertActive(),this._hasExplicitTextStyle}setText(e){return this._assertActive(),this._owner._replaceTextRun(this._range,e,this._textStyle,this._styleId,this._hasExplicitTextStyle),e||(this._active=!1),this}_assertActive(){if(!this._active)throw Error(`Rich text run handle is no longer valid.`);this._owner._assertChildHandleRevision(this._revision)}};function Pb(e,t,n){var r;let{body:i,...a}=e;if(!i)throw Error(`Rich text body is not available.`);let o=(r=i.paragraphs)==null?void 0:r.find(e=>e.paragraphId===t);if(!o)throw Error(`Rich text paragraph "${t}" was not found.`);let s=Cv(i,n.startOffset,n.endOffset);return s.paragraphs=[{...z.deepClone(o),startIndex:n.endOffset-n.startOffset}],{...z.deepClone(a),body:s}}let Fb=`[\r
|
|
19
|
+
\x1B\b]`;function Q(e,t,n,r){return{...e,code:t,index:r,message:n}}function Ib(e,t,n){e.hasRootParagraph||t.push(Q(n,`missing-root-paragraph`,`Document body must contain at least one paragraph sentinel.`)),e.hasRootSectionBreak||t.push(Q(n,`missing-root-section-break`,`Document body must contain at least one section break sentinel.`))}function Lb(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of e.paragraphs??[])e.dataStream[i.startIndex]===`\r`?r.set(i.startIndex,(r.get(i.startIndex)??0)+1):t.push(Q(n,`paragraph-token-mismatch`,`Paragraph metadata must point to a paragraph sentinel.`,i.startIndex));zb(r,{context:n,duplicateCode:`duplicate-paragraph-metadata`,duplicateMessage:`Paragraph sentinel must have exactly one paragraph metadata entry.`},t)}function Rb(e,t,n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let a of e.sectionBreaks??[])a.sectionId?i.set(a.sectionId,(i.get(a.sectionId)??0)+1):t.push(Q(n,`missing-section-id`,`Section break metadata must have a stable section id.`,a.startIndex)),e.dataStream[a.startIndex]===`
|
|
20
|
+
`?r.set(a.startIndex,(r.get(a.startIndex)??0)+1):t.push(Q(n,`section-break-token-mismatch`,`Section break metadata must point to a section break sentinel.`,a.startIndex));zb(r,{context:n,duplicateCode:`duplicate-section-break-metadata`,duplicateMessage:`Section break sentinel must have exactly one section break metadata entry.`},t);for(let[e,r]of i)r>1&&t.push(Q(n,`duplicate-section-id`,`Section id "${e}" must be unique within a document segment.`))}function zb(e,t,n){for(let[r,i]of e)i>1&&n.push(Q(t.context,t.duplicateCode,t.duplicateMessage,r))}function Bb(e){for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(r.startIndex<n.startIndex||r.startIndex===n.startIndex&&r.endIndex<n.endIndex)return[...e].sort((e,t)=>e.startIndex-t.startIndex||e.endIndex-t.endIndex)}return e}function Vb(){return{pairs:/* @__PURE__ */ new Map,unmatchedEnds:[],unmatchedStarts:[]}}function Hb(e,t,n){let r=e.unmatchedStarts.pop();r===void 0?e.unmatchedEnds.push(t):e.pairs.set(r,n?t+1:t)}function Ub(e){let t={hasRootParagraph:!1,hasRootSectionBreak:!1,tableRanges:Vb(),blockRanges:Vb(),columnGroupRanges:Vb(),customBlockIndexes:/* @__PURE__ */ new Set},n=RegExp(Fb,`g`);for(let r of e.matchAll(n)){let e=r.index,n=r[0];n===`\r`?t.hasRootParagraph=!0:n===`
|
|
21
|
+
`?t.hasRootSectionBreak=!0:n===``?t.tableRanges.unmatchedStarts.push(e):n===``?Hb(t.tableRanges,e,!0):n===``?t.blockRanges.unmatchedStarts.push(e):n===``?Hb(t.blockRanges,e,!1):n===``?t.columnGroupRanges.unmatchedStarts.push(e):n===``?Hb(t.columnGroupRanges,e,!1):n===`\b`&&t.customBlockIndexes.add(e)}return t}function Wb(e,t,n,r){let i=t.tableRanges.pairs,a=/* @__PURE__ */ new Set,o=[],s=Bb(e.tables??[]);for(let t of s){for(a.add(t.startIndex),Number.isInteger(t.startIndex)&&e.dataStream[t.startIndex]===``||n.push(Q(r,`table-start-token-mismatch`,`Table startIndex must point to a table start sentinel.`,t.startIndex)),(!Number.isInteger(t.endIndex)||t.endIndex<=t.startIndex||t.endIndex>e.dataStream.length||e.dataStream[t.endIndex-1]!==``||i.get(t.startIndex)!==t.endIndex)&&n.push(Q(r,`table-end-token-mismatch`,`Table endIndex must be the exclusive boundary immediately after a table end sentinel.`,t.endIndex));o.length>0&&o[o.length-1].endIndex<=t.startIndex;)o.pop();let s=o[o.length-1];s&&(t.startIndex===s.startIndex||t.endIndex>=s.endIndex)&&n.push(Q(r,`overlapping-table`,`Table ranges may nest but must not cross or duplicate.`,t.startIndex)),o.push(t)}for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-table-metadata`,`Table token range must have a table metadata entry.`,e))}function Gb(e,t,n,r){let i=t.blockRanges;for(let e of[...i.unmatchedStarts,...i.unmatchedEnds])n.push(Q(r,`unbalanced-block`,`Block sentinel has no matching boundary.`,e));let a=Bb(e.blockRanges??[]),o=/* @__PURE__ */ new Set,s;for(let e=0;e<a.length;e++){let t=a[e];o.add(t.startIndex),i.pairs.get(t.startIndex)!==t.endIndex&&n.push(Q(r,`block-range-token-mismatch`,`Block range must point to its matching block start and end sentinels.`,t.startIndex)),s&&xg(pg(s),pg(t))&&n.push(Q(r,`overlapping-block-range`,`Block ranges must not overlap or share structural sentinels.`,t.startIndex)),s=t}for(let e of i.pairs.keys())o.has(e)||n.push(Q(r,`missing-block-range-metadata`,`Block token range must have a block metadata entry.`,e))}function Kb(e,t,n,r){let i=t.columnGroupRanges.pairs,a=/* @__PURE__ */ new Set,o=Bb(e.columnGroups??[]),s;for(let t of o){a.add(t.startIndex);let o=i.get(t.startIndex);if(o!==t.endIndex&&n.push(Q(r,`column-group-range-token-mismatch`,`Column group range must point to its matching start and end sentinels.`,t.startIndex)),s&&xg(mg(s),mg(t))&&n.push(Q(r,`overlapping-column-group`,`Column group ranges must not overlap.`,t.startIndex)),s=t,Array.isArray(t.columns)){let i=0,a=o??t.endIndex;for(let n=t.startIndex+1;n<a;n++)e.dataStream[n]===``&&i++;i!==t.columns.length&&n.push(Q(r,`column-group-column-count-mismatch`,`Column group metadata column count must match the data stream.`,t.startIndex))}}for(let e of i.keys())a.has(e)||n.push(Q(r,`missing-column-group-metadata`,`Column group token range must have a metadata entry.`,e))}function qb(e,t,n,r){let i=/* @__PURE__ */ new Map,a=[...e.customBlocks??[],...e.docxRawCustomBlocks??[]];for(let t of a){let{startIndex:a}=t;!Number.isInteger(a)||e.dataStream[a]!==`\b`?n.push(Q(r,`custom-block-token-mismatch`,`Custom block startIndex must point to a custom block sentinel.`,a)):i.set(a,(i.get(a)??0)+1)}zb(i,{context:r,duplicateCode:`duplicate-custom-block-metadata`,duplicateMessage:`Custom block sentinel must have exactly one custom block metadata entry.`},n);for(let e of t.customBlockIndexes)i.has(e)||n.push(Q(r,`missing-custom-block-metadata`,`Custom block sentinel must have a custom block metadata entry.`,e))}function Jb(e,t,n){let r=[],i=[],a=[],o=RegExp(Fb,`g`);for(let s of e.dataStream.matchAll(o)){let e=s.index,o=s[0],c=i[i.length-1],l=a[a.length-1],u=l==null?void 0:l.cell;if(o===`\r`)c&&(c.hasChild=!0),u&&(u.hasParagraph=!0);else if(o===`
|
|
22
|
+
`)c&&(c.hasChild=!0),u&&(u.hasSectionBreak=!0);else if(o===``)r.push(e);else if(o===``)i.push({startIndex:e,hasChild:!1});else if(o===``){let r=i.pop();r?r.hasChild||t.push(Q(n,`empty-column`,`Column must contain at least one paragraph or section child.`,r.startIndex)):t.push(Q(n,`unbalanced-column-group`,`Column end token has no matching column start.`,e))}else o===``?i.length>0||r.length===0?(t.push(Q(n,`unbalanced-column-group`,`Column group closes while a column is still open.`,e)),i.length=0):r.pop():o===``?(l&&!u&&t.push(Q(n,`unbalanced-table`,`Nested table must be inside a parent cell.`,e)),a.push({inRow:!1})):o===`\x1B`?((!l||l.inRow)&&t.push(Q(n,`unbalanced-table`,`Table row must start inside a table without an open row.`,e)),l&&(l.inRow=!0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table cell must start inside a row without an open cell.`,e)),l&&(l.cell={startIndex:e,hasParagraph:!1,hasSectionBreak:!1})):o===``?(u?u.hasParagraph&&u.hasSectionBreak||t.push(Q(n,`empty-table-cell`,`Table cell must contain a paragraph and section break child.`,u.startIndex)):t.push(Q(n,`unbalanced-table`,`Table cell end token has no matching start.`,e)),l&&(l.cell=void 0)):o===``?((!(l!=null&&l.inRow)||u)&&t.push(Q(n,`unbalanced-table`,`Table row closes while a cell is still open.`,e)),l&&(l.inRow=!1)):o===``&&((!l||l.inRow||u)&&t.push(Q(n,`unbalanced-table`,`Table closes while a row or cell is still open.`,e)),a.pop())}(r.length>0||i.length>0)&&t.push(Q(n,`unbalanced-column-group`,`Column group or column token is not closed.`,e.dataStream.length)),a.length>0&&t.push(Q(n,`unbalanced-table`,`Table, row, or cell token is not closed.`,e.dataStream.length))}function Yb(e,t,n){let r=/* @__PURE__ */ new Map,i=[];for(let a=0;a<e.dataStream.length;a++){let o=e.dataStream[a];if(o===``)i.push(a);else if(o===``){let e=i.pop();e==null?t.push(Q(n,`unbalanced-custom-range`,`Custom range end token has no matching start.`,a)):r.set(e,a)}}for(let e of i)t.push(Q(n,`unbalanced-custom-range`,`Custom range start token has no matching end.`,e));let a=e.customRanges??[],o=/* @__PURE__ */ new Set;for(let i of a)o.has(i.rangeId)&&t.push(Q(n,`duplicate-custom-range-id`,`Custom range ids must be unique.`,i.startIndex)),o.add(i.rangeId),i.rangeType===1&&(e.dataStream[i.startIndex]!==``||e.dataStream[i.endIndex]!==``||r.get(i.startIndex)!==i.endIndex)&&t.push(Q(n,`custom-range-token-mismatch`,`Field metadata must point to a matching custom range token pair.`,i.startIndex));for(let[e,i]of r)a.some(t=>t.startIndex===e&&t.endIndex===i)||t.push(Q(n,`missing-custom-range-metadata`,`Custom range token pair has no metadata.`,e));let s=a.filter(e=>e.rangeType===1).slice().sort((e,t)=>e.startIndex-t.startIndex||t.endIndex-e.endIndex),c=[];for(let e of s){for(;c.length>0&&c[c.length-1].endIndex<e.startIndex;)c.pop();let r=c[c.length-1];r&&e.endIndex>r.endIndex&&t.push(Q(n,`crossing-custom-range`,`Field ranges may nest but must not cross.`,e.startIndex)),c.push(e)}}function Xb(e,t={segmentType:`body`}){let n=[],r=Ub(e.dataStream);if(Ib(r,n,t),Lb(e,n,t),Rb(e,n,t),Wb(e,r,n,t),Gb(e,r,n,t),Kb(e,r,n,t),qb(e,r,n,t),Jb(e,n,t),Yb(e,n,t),t.segmentType===`header`||t.segmentType===`footer`)for(let r of e.customRanges??[])(r.rangeType===8||r.rangeType===9)&&n.push(Q(t,`invalid-note-reference`,`Note references are only supported in the document body.`,r.startIndex));return n}function Zb(e,t){var n,r,i;let a={segmentType:`note`,segmentId:e},o=Xb(t.body,a);t.noteId===e&&e.length!==0&&[`footnote`,`endnote`].includes(t.type)||o.push({...a,code:`invalid-note-id`,message:`Note identity must match its segment key.`}),(n=t.body.customRanges)!=null&&n.some(e=>e.rangeType===8||e.rangeType===9)&&o.push({...a,code:`nested-note`,message:`A note cannot contain another note reference.`});let s=((r=t.body.sectionBreaks)==null?void 0:r.filter(e=>{var n;return!((n=t.body.tables)!=null&&n.some(t=>e.startIndex>=t.startIndex&&e.startIndex<t.endIndex))}))??[],c=s.some(e=>Object.keys(e).some(e=>e!==`sectionId`&&e!==`startIndex`)),l=Object.values(t.drawings??{}).some(e=>e.layoutType!==0),u=Object.values(t.tableSource??{}).some(e=>e.textWrap===1);return(s.length>1||c||(i=t.body.columnGroups)!=null&&i.length||l||u)&&o.push({...a,code:`invalid-note-body`,message:`Notes support paragraphs, inline drawings and flow tables without independent sections or columns.`}),o}function Qb(e){let t=[];if(e.body){t.push(...Xb(e.body,{segmentType:`body`}));let i=/* @__PURE__ */ new Set;for(let a of e.body.customRanges??[]){var n,r;if(a.rangeType!==8&&a.rangeType!==9)continue;let o=(n=a.properties)==null?void 0:n.noteId;typeof o!=`string`||((r=e.notes)==null?void 0:r[o])==null?t.push({code:`missing-note`,segmentType:`body`,index:a.startIndex,message:`Note reference must resolve to a note segment.`}):e.notes[o].type===(a.rangeType===9?`endnote`:`footnote`)?i.has(o)?t.push({code:`duplicate-note-reference`,segmentType:`body`,index:a.startIndex,message:`Each note must have its own reference identity.`}):i.add(o):t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference kind must match its target.`}),a.startIndex===a.endIndex&&e.body.dataStream[a.startIndex]===``&&a.wholeEntity||t.push({code:`invalid-note-reference`,segmentType:`body`,index:a.startIndex,message:`Note reference must cover one whole-entity reference character.`})}}for(let[n,r]of Object.entries(e.headers??{}))t.push(...Xb(r.body,{segmentType:`header`,segmentId:n}));for(let[n,r]of Object.entries(e.footers??{}))t.push(...Xb(r.body,{segmentType:`footer`,segmentId:n}));for(let[n,r]of Object.entries(e.notes??{})){var i,a;t.push(...Zb(n,r)),((i=e.headers)!=null&&i[n]||(a=e.footers)!=null&&a[n])&&t.push({code:`invalid-note-id`,segmentType:`note`,segmentId:n,message:`Notes must not share a segment identity with a header or footer.`})}return t}function $b(e,t){return`${t==="default"?`default`:t===`first`?`firstPage`:`evenPage`}${e===`header`?`Header`:`Footer`}Id`}function ex(e,t,n,r){if(n<0||n>=t.length)return{linkedToPrevious:!1};let i=t[n],a=i[r];if(typeof a==`string`&&a)return{segmentId:a,linkedToPrevious:!1,sourceSectionId:i.sectionId};if(n===0){let t=e[r];return{...typeof t==`string`&&t?{segmentId:t}:{},linkedToPrevious:!1}}let o=ex(e,t,n-1,r);return{...o.segmentId?{segmentId:o.segmentId}:{},linkedToPrevious:!0,sourceSectionId:o.sourceSectionId}}function tx(e,t,n){let r={};for(let i of[`defaultHeaderId`,`defaultFooterId`,`firstPageHeaderId`,`firstPageFooterId`,`evenPageHeaderId`,`evenPageFooterId`]){let{segmentId:a}=ex(e,t,n,i);a&&(r[i]=a)}return r}function nx(e){var t;let n=(t=e.properties)==null?void 0:t.dataBinding;if(n!=null&&n.storeItemID&&n.xpath)return JSON.stringify([n.storeItemID.toLowerCase(),n.xpath,n.prefixMappings??``])}function rx(e,t){if(t.properties.showingPlaceholder)return``;if(t.properties.kind===`checkbox`){var n;return(n=t.properties.checkbox)!=null&&n.checked?`true`:`false`}let r=e.dataStream.slice(t.startIndex,t.endIndex+1).replace(/^[\x00-\x08\x0A-\x1F]+|[\x00-\x08\x0A-\x1F]+$/g,``);if(t.properties.kind===`date`){var i;return((i=t.properties.date)==null?void 0:i.fullDate)??r}if(t.properties.kind===`dropDownList`||t.properties.kind===`comboBox`){var a;return((a=t.properties.listItems)==null||(a=a.find(e=>e.displayText===r))==null?void 0:a.value)??r}return[`text`,`richText`].includes(t.properties.kind)?r:void 0}var ix=class{constructor(){T(this,`skipNextObservers`,!1),T(this,`lastReturnValue`,void 0),T(this,`isStopPropagation`,!1)}stopPropagation(){this.isStopPropagation=!0}},ax=class extends t.Subject{constructor(...e){super(...e),T(this,`_sortedObservers`,[])}unsubscribe(){super.unsubscribe(),this._sortedObservers.length=0}complete(){super.complete(),this._sortedObservers.length=0}subscribeEvent(e){let t;t=typeof e==`function`?{next:([t,n])=>e(t,n)}:e;let n=super.subscribe(t);return this._sortedObservers.push(t),this._sortedObservers.sort((e,t)=>(e.priority??0)-(t.priority??0)),n.add(()=>this._sortedObservers=this._sortedObservers.filter(e=>e!==t)),n}clearObservers(){this._sortedObservers.forEach(e=>{var t;return(t=e.complete)==null?void 0:t.call(e)}),this._sortedObservers.length=0}emitEvent(e){if(!this.closed){let n=new ix;n.lastReturnValue=e;for(let r of this._sortedObservers){var t;if(n.lastReturnValue=(t=r.next)==null?void 0:t.call(r,[e,n]),n.skipNextObservers)return{handled:!0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}return{handled:this._sortedObservers.length>0,lastReturnValue:n.lastReturnValue,stopPropagation:n.isStopPropagation}}throw Error(`[EventSubject]: cannot emit event on a closed subject.`)}};function ox(e){return new t.Observable(t=>{let n=e.subscribeEvent(e=>{t.next(e)});return()=>n.unsubscribe()})}let sx=(0,i.createIdentifier)(`core.resource-manager.service`),cx={[n.UnitRole.Editor]:`Editor`,[n.UnitRole.Owner]:`Owner`,[n.UnitRole.Reader]:`Reader`,[n.UnitRole.UNRECOGNIZED]:`UNRECOGNIZED`},lx=e=>e?{userID:`${cx[e]}_${J(8)}`,name:cx[e],avatar:``}:{userID:``,name:``,avatar:``,anonymous:!0,canBindAnonymous:!1},ux=(e,t)=>e.startsWith(cx[t]);var dx=class extends k{constructor(...e){super(...e),T(this,`_model`,/* @__PURE__ */ new Map),T(this,`_userChange$`,new t.Subject),T(this,`userChange$`,this._userChange$.asObservable()),T(this,`_currentUser$`,new t.BehaviorSubject(lx())),T(this,`currentUser$`,this._currentUser$.asObservable())}dispose(){super.dispose(),this._model.clear(),this._userChange$.complete(),this._currentUser$.complete()}getCurrentUser(){return this._currentUser$.getValue()}setCurrentUser(e){this.addUser(e),this._currentUser$.next(e)}addUser(e){this._model.set(e.userID,e),this._userChange$.next({type:`add`,user:e})}getUser(e,t){let n=this._model.get(e);if(n)return n;t&&t()}delete(e){let t=this.getUser(e);this._model.delete(e),t&&this._userChange$.next({type:`delete`,user:t})}clear(){this._model.clear(),this._userChange$.next({type:`clear`})}list(){return Array.from(this._model.values())}};let fx=class{constructor(e,t){this._resourceManagerService=e,this._userManagerService=t,T(this,`_permissionMap`,/* @__PURE__ */ new Map([])),T(this,`_permissionOverrides`,/* @__PURE__ */ new Map),T(this,`_cfgEnableObjInherit`,!1),this._initSnapshot(),this._initDefaultUser()}_initDefaultUser(){let e=this._userManagerService.getCurrentUser();e&&e.userID||this._userManagerService.setCurrentUser(lx(n.UnitRole.Owner))}_getRole(e){let t=this._userManagerService.getCurrentUser();return t?ux(t.userID,e):!1}_initSnapshot(){this._resourceManagerService.registerPluginResource({toJson:e=>{let t=[...this._permissionMap.keys()].reduce((e,t)=>(e[t]=this._permissionMap.get(t),e),{});return JSON.stringify(t)},parseJson:e=>JSON.parse(e),pluginName:`SHEET_AuthzIoMockService_PLUGIN`,businesses:[n.UniverType.UNIVER_SHEET,n.UniverType.UNIVER_DOC,n.UniverType.UNIVER_SLIDE,n.UniverType.UNIVER_BOARD],onLoad:(e,t)=>{for(let e in t)this._permissionMap.set(e,t[e])},onUnLoad:()=>{this._permissionMap.clear()}})}async create(e){let t=J(8),{objectType:r,selectRangeObject:i,worksheetObject:a}=e,o=i||a,s={objectType:r,unitID:(o==null?void 0:o.unitID)||``,name:(o==null?void 0:o.name)||``,strategies:[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}],selectRangeObject:i};return this._permissionMap.set(t,s),t}async allowed(e){let{objectID:t,actions:r}=e,i=this._permissionMap.get(t);return i?r.map(e=>{let r=`${t}:${e}`;if(this._permissionOverrides.has(r))return{action:e,allowed:this._permissionOverrides.get(r)};let a=i.strategies.find(t=>t.action===e);return a?{action:e,allowed:this._getRole(a.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}}):r.map(e=>({action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}))}async batchAllowed(e){let t=await Promise.all(e.map(e=>this.allowed(e)));return e.map((e,n)=>({unitID:e.unitID,objectID:e.objectID,actions:t[n]}))}async list(e){let t=[],r=[{action:6,role:n.UnitRole.Owner},{action:16,role:n.UnitRole.Owner},{action:17,role:n.UnitRole.Owner},{action:18,role:n.UnitRole.Owner},{action:19,role:n.UnitRole.Owner},{action:33,role:n.UnitRole.Owner},{action:34,role:n.UnitRole.Owner},{action:35,role:n.UnitRole.Owner},{action:36,role:n.UnitRole.Owner},{action:37,role:n.UnitRole.Owner},{action:38,role:n.UnitRole.Owner},{action:39,role:n.UnitRole.Owner},{action:40,role:n.UnitRole.Owner}];return e.objectIDs.forEach(i=>{let a=this._permissionMap.get(i),o=(a==null?void 0:a.strategies)||r,s={objectID:i,unitID:e.unitID,objectType:(a==null?void 0:a.objectType)||3,name:(a==null?void 0:a.name)||``,shareOn:!1,shareRole:n.UnitRole.Owner,shareScope:-1,scope:{read:n.ObjectScope.AllCollaborator,edit:n.ObjectScope.AllCollaborator},creator:lx(n.UnitRole.Owner),strategies:o.map(e=>({action:e.action,role:e.role})),actions:e.actions.map(e=>{let t=`${i}:${e}`;if(this._permissionOverrides.has(t))return{action:e,allowed:this._permissionOverrides.get(t)};let r=o.find(t=>t.action===e);return r?{action:e,allowed:this._getRole(r.role)}:{action:e,allowed:this._getRole(n.UnitRole.Owner)||this._getRole(n.UnitRole.Editor)}})};t.push(s)}),t}async listCollaborators(){return[]}async listRoles(){return{roles:[],actions:[]}}async deleteCollaborator(){}async update(e){let{objectID:t,strategies:r}=e,i=this._permissionMap.get(t);i&&r&&(i.strategies=r.map(e=>({action:e.action,role:e.role})),this._permissionMap.set(t,i),r.forEach(e=>{e.role===n.UnitRole.Reader?this.setPermissionOverride(t,e.action,!1):(e.role===n.UnitRole.Owner||e.role===n.UnitRole.Editor)&&this.clearPermissionOverride(t,e.action)}))}setPermissionOverride(e,t,n){let r=`${e}:${t}`;this._permissionOverrides.set(r,n)}clearPermissionOverride(e,t){let n=`${e}:${t}`;this._permissionOverrides.delete(n)}clearAllOverrides(e){let t=[];this._permissionOverrides.forEach((n,r)=>{r.startsWith(`${e}:`)&&t.push(r)}),t.forEach(e=>this._permissionOverrides.delete(e))}async updateCollaborator(){}async createCollaborator(){}async putCollaborators(e){}setCfgEnableObjInherit(e){this._cfgEnableObjInherit=e}getCfgEnableObjInherit(){return this._cfgEnableObjInherit}};fx=ma([V(0,sx),V(1,(0,i.Inject)(dx))],fx);let px=(0,i.createIdentifier)(`IAuthzIoIoService`),mx=(0,i.createIdentifier)(`univer.confirm-service`);var hx=class{constructor(){T(this,`confirmOptions$`,new t.Subject)}dispose(){this.confirmOptions$.complete()}open(e){throw Error(`This is not implemented in the test service!`)}confirm(e){return Promise.resolve(!0)}close(e){throw Error(`This is not implemented in the test service!`)}};let gx=`FOCUSING_UNIT`,_x=`FOCUSING_SHEET`,vx=`FOCUSING_DOC`,yx=`FOCUSING_SLIDE`,bx=`FOCUSING_BOARD`,xx=`EDITOR_ACTIVATED`,Sx=`FOCUSING_FX_BAR_EDITOR`,Cx=`FOCUSING_SHAPE_TEXT_EDITOR`;var wx=class extends k{constructor(...e){super(...e),T(this,`_error$`,new t.Subject),T(this,`error$`,this._error$.asObservable())}dispose(){this._error$.complete()}emitPermissionDenied(e,t=[]){this._error$.next({errorKey:`Permission denied.`,code:`PERMISSION_DENIED`,permissionTarget:JSON.stringify([e,[...new Set(t)].sort()])})}emit(e){this._error$.next({errorKey:e})}};let Tx=/* @__PURE__ */ function(e){return e.URL=`URL`,e.UUID=`UUID`,e.BASE64=`BASE64`,e}({}),Ex=/* @__PURE__ */ function(e){return e.SUCCUSS=`0`,e.ERROR_EXCEED_SIZE=`1`,e.ERROR_IMAGE_TYPE=`2`,e.ERROR_UPLOAD_COUNT_LIMIT=`3`,e.ERROR_IMAGE=`4`,e}({}),Dx=(0,i.createIdentifier)(`core.image-io.service`),Ox=(0,i.createIdentifier)(`core.url-image.service`),kx=Object.freeze({iterativeCalculation:!1,maxIterations:100,maxChange:.001});function Ax(e){let t=kx;return{iterativeCalculation:typeof(e==null?void 0:e.iterativeCalculation)==`boolean`?e.iterativeCalculation:t.iterativeCalculation,maxIterations:Number.isInteger(e==null?void 0:e.maxIterations)&&e.maxIterations>=1&&e.maxIterations<=32767?e.maxIterations:t.maxIterations,maxChange:typeof(e==null?void 0:e.maxChange)==`number`&&Number.isFinite(e.maxChange)&&e.maxChange>0?e.maxChange:t.maxChange}}function jx(e=``,t=`zhCN`,n=``){return{id:e,sheetOrder:[],name:n,appVersion:ze,locale:t,dateSystem:`date1900`,styles:{},sheets:{},resources:[]}}var Mx=class{constructor(e={}){T(this,`_styles`,void 0),T(this,`_cacheMap`,new Cd(1e5)),this._styles=e,this._generateCacheMap()}each(e){return Object.entries(this._styles).forEach(e),this}search(e,t){return this._cacheMap.has(t)?this._cacheMap.get(t):this._getExistingStyleId(e)||`-1`}get(e){return typeof e==`string`?(e=String(e),this._styles[e]):e}add(e,t){let n=J(6);return this._styles[n]=e,this._cacheMap.set(t,n),n}setValue(e){if(e==null)return;let t=JSON.stringify(e),n=this.search(e,t);return n===`-1`?this.add(e,t):n}addCustomStyle(e,t){t!=null&&(this._styles[e]=t,this._cacheMap.set(JSON.stringify(t),e))}remove(e){let t=this._styles[e];t&&(delete this._styles[e],this._cacheMap.delete(JSON.stringify(t)))}toJSON(){return this._styles}getStyleByCell(e){let t;t=e&&z.isObject(e.s)?e.s:(e==null?void 0:e.s)&&this.get(e.s);let n=e==null?void 0:e.interceptorStyle;return n?{...t,...n}:t}_generateCacheMap(){let{_styles:e,_cacheMap:t}=this;for(let n in e){let r=JSON.stringify(e[n]);t.set(r,n)}}_getExistingStyleId(e){let{_styles:t}=this;for(let n in t)if(z.diffValue(t[n],e))return n;return null}};let Nx=(e,t)=>t.length===e.length&&!e.some(e=>t.some(t=>!Jd.equals(t,e))),Px=(e,t)=>t.length===e.length&&e.every((e,n)=>{let r=t[n];return r.unitId===e.unitId&&r.sheetId===e.sheetId&&Jd.equals(e.range,r.range)}),Fx={t:0,b:2,l:2,r:2},Ix=e=>({sbr:.6,sbo:e,spr:.6,spo:e});function Lx(e,t,n={}){let r=e.length,{textRotation:i,paddingData:a,horizontalAlign:o=0,verticalAlign:s=0,wrapStrategy:c=0,cellValueType:l}=n,u=(a==null?void 0:a.t)??Fx.t,d=(a==null?void 0:a.r)??Fx.r,f=(a==null?void 0:a.b)??Fx.b,p=(a==null?void 0:a.l)??Fx.l,{vertexAngle:m,centerAngle:h}=Kx(i);return new Ey({id:`d`,body:{dataStream:`${e}\r
|
|
23
|
+
`,textRuns:[{ts:t,st:0,ed:r}],paragraphs:[{startIndex:r,paragraphId:Gh(/* @__PURE__ */ new Set),paragraphStyle:{horizontalAlign:o}}],sectionBreaks:[{sectionId:xm(/* @__PURE__ */ new Set),startIndex:r+1}]},documentStyle:{textStyle:z.deepClone(t),defaultParagraphStyle:{horizontalAlign:o},pageSize:{width:1/0,height:1/0},documentFlavor:0,marginTop:u,marginBottom:f,marginRight:d,marginLeft:p,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:o,verticalAlign:s,centerAngle:h,vertexAngle:m,wrapStrategy:c,cellValueType:l}},drawings:{},drawingsOrder:[]})}function Rx(e){if(!e)return{};let{tr:t,td:n,ht:r,vt:i,tb:a,pd:o}=e;return{textRotation:t,textDirection:n,horizontalAlign:r,verticalAlign:i,wrapStrategy:a,paddingData:o}}function zx(e){if(!e)return{};let{ff:t,fs:n,it:r,bl:i,ul:a,st:o,ol:s,cl:c}=e,l={};return t&&(l.ff=t),n&&(l.fs=n),r&&(l.it=r),i&&(l.bl=i),a&&(l.ul=a),o&&(l.st=o),s&&(l.ol=s),c&&(l.cl=c),l}function Bx(e,t,n){var r;let i=e.getBody();if((r=i.customRanges)!=null&&r.some(e=>e.rangeType===0))return;let a=Z.customRange.add({ranges:[{startOffset:0,endOffset:i.dataStream.length-1,collapsed:!1}],rangeId:n,rangeType:0,body:i,properties:{url:t,refId:n}});a&&X.apply(i,a.serialize())}function Vx(e){return e!=null}function Hx(){return{p:null,s:null,v:null,t:null,f:null,si:null,ref:null,xf:null}}function Ux(e){let t=Y.ff,n=Y.fs;if(!e){let e=`${n}pt ${t}`;return{fontCache:e,fontString:e,fontSize:n,originFontSize:n,fontFamily:t}}let r=`italic`;(e.it===0||e.it===void 0)&&(r=`normal`);let i=`bold`;(e.bl===0||e.bl===void 0)&&(i=`normal`);let a=n;e.fs&&(a=e.fs);let o=Wx(e.ff,t),{va:s}=e,c=a;if(s===2||s===3){let{sbr:e,spr:t}=Gx(o,c);c*=s===2?e:t}let l=`${r} ${i} ${c}pt ${o}`;return{fontCache:l,fontString:`${l}, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif `,fontSize:c,originFontSize:a,fontFamily:o}}function Wx(e,t){return e!=null&&e.trim()?e.split(`,`).map(e=>{let t=e.trim().replace(/^['"]|['"]$/g,``);return t.includes(` `)?`"${t}"`:t}).filter(Boolean).join(`, `):t}function Gx(e,t){return Ix(t)}function Kx(e){let{a:t=0,v:n=0}=e||{a:0,v:0},r=0,i=t;return n===1&&(r=90,i=90),{centerAngle:r,vertexAngle:i}}function qx(e,t=!0){return typeof e==`number`&&Number.isFinite(e)&&(t?e>=0:e>0)}function Jx(e,t,n=!0){return qx(e,n)?e:t}function Yx(e){return(e==null?void 0:e.w)==null||qx(e.w)}function Xx(e){return((e==null?void 0:e.h)==null||qx(e.h))&&((e==null?void 0:e.ah)==null||qx(e.ah))}let Zx=1e3;function Qx(e){let t={name:`Sheet1`,id:`sheet-01`,tabColor:``,hidden:0,rowCount:Zx,columnCount:20,zoomRatio:1,freeze:{xSplit:0,ySplit:0,startRow:-1,startColumn:-1},scrollTop:0,scrollLeft:0,defaultColumnWidth:88,defaultRowHeight:24,mergeData:[],cellData:{},rowData:{},columnData:{},showGridlines:1,rowHeader:{width:46,hidden:0},columnHeader:{height:20,hidden:0},rightToLeft:0};Object.keys(t).forEach(n=>{let r=n;e[r]===void 0&&(e[r]=t[r])});let n=e.freeze;n.xSplit=n.xSplit??t.freeze.xSplit,n.ySplit=n.ySplit??t.freeze.ySplit,n.startRow=n.ySplit===0?t.freeze.startRow:n.startRow??t.freeze.startRow,n.startColumn=n.xSplit===0?t.freeze.startColumn:n.startColumn??t.freeze.startColumn,e.defaultColumnWidth=Jx(e.defaultColumnWidth,88,!1),e.defaultRowHeight=Jx(e.defaultRowHeight,24,!1);for(let t of Object.values(e.columnData))t&&t.w!==void 0&&!qx(t.w)&&(t.w=0);for(let t of Object.values(e.rowData))t&&(t.h!==void 0&&!qx(t.h)&&(t.h=0),t.ah!==void 0&&!qx(t.ah)&&delete t.ah);return e}var $x=class{constructor(e,t){this._config=e,T(this,`_columnData`,{}),this._columnData=t}getColumnData(){return this._columnData}getColVisible(e){let{_columnData:t}=this,n=t[e];return!n||n.hd!==1}getColumnStyle(e){var t;return(t=this._columnData[e])==null?void 0:t.s}setColumnStyle(e,t){let n=this.getColumnOrCreate(e);n.s=t}getHiddenCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getVisibleCols(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getColVisible(a);r&&!e?(r=!1,n.push({rangeType:2,startColumn:i,endColumn:a-1,startRow:0,endRow:0})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:0,endRow:0,startColumn:i,endColumn:t,rangeType:2}),n}getColumnDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getColumn(i);n[r]=e??{w:this._config.defaultColumnWidth,hd:0},r++}return n}getSize(){return nu(this._columnData)}getColumnWidth(e){var t;let n=Jx(this._config.defaultColumnWidth,88,!1),r=(t=this._columnData[e])==null?void 0:t.w;return r===void 0?n:Jx(r,0)}setColumnWidth(e,t){if(!qx(t))return;let n=this._columnData[e];t===this._config.defaultColumnWidth?n&&(delete n.w,Object.keys(n).length===0&&delete this._columnData[e]):this._columnData[e]=n?{...n,w:t}:{w:t}}getColumn(e){return this._columnData[e]}insertColumnsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._columnData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._columnData[n+r]=this._columnData[n],delete this._columnData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];t!=null&&Object.keys(t).length>0&&(this._columnData[r]={...t},t.w!==void 0&&!qx(t.w)&&(this._columnData[r].w=0))}}removeColumn(e){delete this._columnData[e]}getColumnOrCreate(e){let{_columnData:t}=this,n=t[e];if(n)return n;let r={};return this._columnData[e]=r,r}setCustomMetadata(e,t){let n=this.getColumn(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getColumn(e))==null?void 0:t.custom}};function eS(e,t){let{textRuns:n=[]}=t,r=0;for(let t of n){let{ts:n={},st:i,ed:a}=t;if(n[e]==null)return 0;switch(e){case`bl`:case`it`:if(n[e]===0)return 0;break;case`ul`:case`st`:if(n[e].s===0)return 0;break;default:throw Error(`unknown style key: ${e} in IStyleBase`)}r+=a-i}return+(t.dataStream.indexOf(`\r
|
|
24
|
+
`)===r)}var tS=class e{constructor(e,t,n){this._deps=n,T(this,`_range`,void 0),T(this,`_worksheet`,void 0),this._range=t,this._worksheet=e}static foreach(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e;for(let e=n;e<=i;e++)for(let n=r;n<=a;n++)t(e,n)}getRangeData(){return this._range}getValue(){return this.getValues()[0][0]}getValues(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=[];for(let a=e;a<=t;a++){let e=[];for(let t=n;t<=r;t++)e.push(this.getMatrix().getValue(a,t)||null);i.push(e)}return i}getMatrix(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let e=n;e<=r;e++)a.setValue(o,e,i.getValue(o,e)||null);return a}getMatrixObject(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i=this._worksheet.getCellMatrix(),a=new du;for(let o=e;o<=t;o++)for(let t=n;t<=r;t++)a.setValue(o-e,t-n,i.getValue(o,t)||{});return a}getA1Notation(){let{startRow:e,endRow:t,startColumn:n,endColumn:r}=this._range,i,a;return n<r?(i=z.numToWord(n+1)+(e+1),a=z.numToWord(r+1)+(t+1)):(i=z.numToWord(r+1)+(t+1),a=z.numToWord(n+1)+(e+1)),i===a?`${i}`:`${i}:${a}`}getBackground(){return this.getBackgrounds()[0][0]}getBackgrounds(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.bg)==null?void 0:n.rgb)||Y.bg.rgb}))}getCell(t,n){let{startRow:r,startColumn:i}=this._range,a={startRow:r+t,endRow:r+t,startColumn:i+n,endColumn:i+n};return new e(this._worksheet,a,this._deps)}getColumn(){return this._range.startColumn}getObjectValue(e={}){return this.getObjectValues(e)[0][0]}getObjectValues(e={}){let{startRow:t,endRow:n,startColumn:r,endColumn:i}=this._range,a=this._worksheet.getCellMatrix().getFragment(t,n,r,i).clone();if(e.isIncludeStyle){let e=this._deps.getStyles();for(let s=0;s<=n-t;s++)for(let t=0;t<=i-r;t++){var o;if(a==null||(a==null||(o=a[s])==null?void 0:o[t])==null)continue;let n=a[s][t].s;n&&(a[s][t].s=e.get(n))}}return a}getFontColor(){return this.getFontColors()[0][0]}getFontColors(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>{var n;let r=e.getStyleByCell(t);return(r==null||(n=r.cl)==null?void 0:n.rgb)||Y.cl.rgb}))}getFontFamilies(){return this._getStyles(`ff`)}getFontFamily(){return this.getFontFamilies()[0][0]}getUnderlines(){return this._getStyles(`ul`)}getUnderline(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?eS(`ul`,t.body)===1?{s:1}:{s:0}:this.getUnderlines()[0][0]}getOverlines(){return this._getStyles(`ol`)}getOverline(){return this.getOverlines()[0][0]}getStrikeThrough(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?eS(`st`,t.body)===1?{s:1}:{s:0}:this.getStrikeThroughs()[0][0]}getStrikeThroughs(){return this._getStyles(`st`)}getFontSize(){var e,t;let n=((e=this.getValue())==null?void 0:e.p)||{};return n&&Array.isArray((t=n.body)==null?void 0:t.textRuns)&&n.body.textRuns.length>0&&n.body.textRuns.some(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)!=null})?Math.max(...n.body.textRuns.map(e=>{var t;return(e==null||(t=e.ts)==null?void 0:t.fs)||0})):this.getFontSizes()[0][0]}getFontSizes(){return this._getStyles(`fs`)}getBorder(){return this.getBorders()[0][0]}getBorders(){return this._getStyles(`bd`)}getFontStyle(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(eS(`it`,t.body)===1):this._getFontStyles()[0][0]}_getFontStyles(){return this._getStyles(`it`)}getFontWeight(){var e;let{p:t}=this.getValue()??{};return t&&Array.isArray((e=t.body)==null?void 0:e.textRuns)&&t.body.textRuns.length>0?+(eS(`bl`,t.body)===1):this._getFontWeights()[0][0]}_getFontWeights(){return this._getStyles(`bl`)}getGridId(){return this._worksheet.getSheetId()}getHeight(){let{_range:e,_worksheet:t}=this,{startRow:n,endRow:r}=e,i=0;for(let e=0;e<=r-n;e++){let n=t.getRowHeight(e);i+=n}return i}getHorizontalAlignment(){return this.getHorizontalAlignments()[0][0]}getHorizontalAlignments(){return this._getStyles(`ht`)}getLastColumn(){return this._range.endColumn}getLastRow(){return this._range.endRow}getNumColumns(){let{startColumn:e,endColumn:t}=this._range;return t-e+1}getNumRows(){let{startRow:e,endRow:t}=this._range;return t-e+1}getRichTextValue(){return this.getRichTextValues()[0][0]}getRichTextValues(){return this.getValues().map(e=>e.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(){let e=this._deps.getStyles();return this.getValues().map(t=>t.map(t=>e.getStyleByCell(t)))}getVerticalAlignment(){return this.getVerticalAlignments()[0][0]}getVerticalAlignments(){return this._getStyles(`vt`)}getWidth(){let{_range:e,_worksheet:t}=this,{startColumn:n,endColumn:r}=e,i=0;for(let e=0;e<=r-n;e++)i+=t.getColumnWidth(e);return i}getWrap(){return+(this.getWrapStrategy()===3)}getWrapStrategies(){return this._getStyles(`tb`)}getWrapStrategy(){return this.getWrapStrategies()[0][0]}forEach(t){e.foreach(this._range,t)}_getStyles(e){let t=this._deps.getStyles();return this.getValues().map(n=>n.map(n=>{let r=t&&t.getStyleByCell(n);return r&&r[e]||Y[e]}))}};T(tS,`transformRange`,(e,t)=>{let n=t.getMaxColumns()-1,r=t.getMaxRows()-1;return e.rangeType===3?{startColumn:0,startRow:0,endColumn:n,endRow:r}:e.rangeType===2?{startRow:0,endRow:r,startColumn:e.startColumn,endColumn:e.endColumn}:e.rangeType===1?{startColumn:0,endColumn:n,startRow:e.startRow,endRow:e.endRow}:{startColumn:e.startColumn,endColumn:Math.min(e.endColumn,n),startRow:e.startRow,endRow:Math.min(e.endRow,r)}});var nS=class{constructor(e,t,n){this._config=e,this._viewModel=t,T(this,`_rowData`,void 0),this._rowData=n}getRowData(){return this._rowData}getRowStyle(e){var t;return(t=this._rowData[e])==null?void 0:t.s}setRowStyle(e,t){let n=this.getRowOrCreate(e);n.s=t}getRowDatas(e,t){let n={},r=0;for(let i=e;i<e+t;i++){let e=this.getRow(i);n[r]=e??{h:this._config.defaultRowHeight,hd:0},r++}return n}getRowHeight(e,t=1){let{_rowData:n}=this,r=this._config,i=Jx(r.defaultRowHeight,24,!1),a=0;for(let r=0;r<t;r++){let{ia:t,ah:o,h:s=i}=n[r+e]||{hd:0,h:i};a+=(t==null||t===1)&&qx(o,!1)?o:Jx(s,0)}return a}setRowHeight(e,t){if(!qx(t))return;let n=this._rowData[e];if(t===this._config.defaultRowHeight)n&&(delete n.h,Object.keys(n).length===0&&delete this._rowData[e]);else{let r=Math.min(t,2e3);this._rowData[e]=n?{...n,h:r}:{h:r}}}getRow(e){return this._rowData[e]}insertRowsWithData(e,t,n){let r=t-e+1,i=Object.keys(this._rowData);for(let t=i.length-1;t>=0;t--){let n=Number(i[t]);n>=e&&(this._rowData[n+r]=this._rowData[n],delete this._rowData[n])}for(let r=e;r<=t;r++){let t=n==null?void 0:n[r-e];if(t!=null&&Object.keys(t).length>0){this._rowData[r]={...t};let e=this._rowData[r];e.h!==void 0&&!qx(e.h)&&(e.h=0),e.ah!==void 0&&!qx(e.ah)&&delete e.ah}}}removeRow(e){delete this._rowData[e]}getRowOrCreate(e){let{_rowData:t}=this,n=t[e];if(n)return n;let r={};return t[e]=r,r}getHiddenRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&!e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getVisibleRows(e=0,t=this.getSize()-1){let n=[],r=!1,i=-1;for(let a=e;a<=t;a++){let e=this.getRowRawVisible(a);r&&!e?(r=!1,n.push({startRow:i,endRow:a-1,startColumn:0,endColumn:0,rangeType:1})):!r&&e&&(r=!0,i=a)}return r&&n.push({startRow:i,endRow:t,startColumn:0,endColumn:0,rangeType:1}),n}getRowRawVisible(e){let t=this.getRow(e);return!t||t.hd!==1}getSize(){return nu(this._rowData)}setCustomMetadata(e,t){let n=this.getRow(e);n&&(n.custom=t)}getCustomMetadata(e){var t;return(t=this.getRow(e))==null?void 0:t.custom}},rS=class extends k{constructor(e){super(),T(this,`_cellCache`,/* @__PURE__ */ new Map),T(this,`_rowCache`,/* @__PURE__ */ new Map),T(this,`_columnCache`,/* @__PURE__ */ new Map),T(this,`_hasRow`,!1),T(this,`_hasColumn`,!1),T(this,`_hasAll`,!1),T(this,`_allIndex`,-1),T(this,`_mergeData`,void 0),T(this,`_rangeMap`,new Cd(5e4)),this._init(e.concat())}_init(e){this._mergeData=e,this._createCache(e)}_clearCache(){this._cellCache.clear(),this._rowCache.clear(),this._columnCache.clear(),this._hasAll=!1,this._allIndex=-1,this._rangeMap.clear(),this._hasColumn=!1,this._hasRow=!1}_createCache(e){let t=0;for(let n of e){let{rangeType:e}=n;e===1?this._createRowCache(n,t):e===2?this._createColumnCache(n,t):e===3?this._createCellAllCache(t):this._createCellCache(n,t),t++}}rebuild(e){this._clearCache(),this._init(e.concat())}_createRowCache(e,t){let{startRow:n,endRow:r}=e;for(let e=n;e<=r;e++)this._rowCache.set(e,t),this._hasRow=!0}_createColumnCache(e,t){let{startColumn:n,endColumn:r}=e;for(let e=n;e<=r;e++)this._columnCache.set(e,t),this._hasColumn=!0}_createCellAllCache(e){this._hasAll=!0,this._allIndex=e}_createCellCache(e,t){for(let n=e.startRow;n<=e.endRow;n++){let r=this._cellCache.get(n);r??(r=/* @__PURE__ */ new Map,this._cellCache.set(n,r));for(let n=e.startColumn;n<=e.endColumn;n++)r.set(n,t)}}add(e){this._mergeData.push(e),this._clearCache(),this._createCache(this._mergeData)}remove(e,t){let n=this._getMergeDataIndex(e,t);n!==-1&&(this._mergeData.splice(n,1),this._clearCache(),this._createCache(this._mergeData))}getMergedCell(e,t){let n=this._getMergeDataIndex(e,t);return n===-1?null:this._mergeData[n]}getMergeDataIndex(e,t){return this._getMergeDataIndex(e,t)}isRowContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._columnCache)?!0:this._mergeData.some(t=>t.startRow<=e&&e<=t.endRow)}isColumnContainsMergedCell(e){return this._hasAll||!z.isEmptyObject(this._rowCache)?!0:this._mergeData.some(t=>t.startColumn<=e&&e<=t.endColumn)}getMergedCellRange(e,t,n,r){let i=[],a=`${e}-${t}-${n}-${r}`;if(this._rangeMap.has(a))return this._getRangeFromCache(a);let o=0,s=[];for(let a of this._mergeData||[])Jd.intersects(a,{startRow:e,endRow:n,startColumn:t,endColumn:r})&&(i.push({...a}),s.push(o)),o++;return this._rangeMap.set(a,s),i}_getRangeFromCache(e){let t=this._rangeMap.get(e)||[],n=[];for(let e of t)n.push({...this._mergeData[e]});return n}_getMergeDataIndex(e,t){var n;if(this._hasAll)return this._allIndex;if(this._hasRow){let t=this._rowCache.get(e);if(t!==void 0)return t}if(this._hasColumn){let e=this._columnCache.get(t);if(e!==void 0)return e}let r=(n=this._cellCache.get(e))==null?void 0:n.get(t);return r===void 0?-1:r}getMergeDataSnapshot(){return this._mergeData}dispose(){this._clearCache(),this._mergeData=[]}},iS=class extends k{constructor(e){super(),this.getRawCell=e,T(this,`_cellContentInterceptor`,null),T(this,`_rowFilteredInterceptor`,null)}dispose(){super.dispose(),this._cellContentInterceptor=null,this._rowFilteredInterceptor=null}getCell(e,t,n,r){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,3,n,r):this.getRawCell(e,t)}getCellValueOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,2):this.getRawCell(e,t)}getCellStyleOnly(e,t){return this._cellContentInterceptor?this._cellContentInterceptor.getCell(e,t,1):this.getRawCell(e,t)}getRowFiltered(e){var t;return((t=this._rowFilteredInterceptor)==null?void 0:t.getRowFiltered(e))??!1}registerCellContentInterceptor(e){if(this._cellContentInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._cellContentInterceptor=e,D(()=>this._cellContentInterceptor=null)}registerRowFilteredInterceptor(e){if(this._rowFilteredInterceptor)throw Error(`[SheetViewModel]: Interceptor already registered.`);return this._rowFilteredInterceptor=e,D(()=>this._rowFilteredInterceptor=null)}};let aS={isDeepClone:!1,displayRawFormula:!1,ignoreTextRotation:!1};var oS=class{constructor(e,t,n){this.unitId=e,this._styles=n,T(this,`_sheetId`,void 0),T(this,`_snapshot`,void 0),T(this,`_cellData`,void 0),T(this,`_rowManager`,void 0),T(this,`_columnManager`,void 0),T(this,`_viewModel`,void 0),T(this,`_spanModel`,void 0),T(this,`_isRowStylePrecedeColumnStyle`,!0),T(this,`_getCellHeight`,void 0),this._snapshot=Qx(t);let{columnData:r,rowData:i,cellData:a}=this._snapshot;this._sheetId=this._snapshot.id??J(6),this._cellData=new du(a),this._viewModel=new iS((e,t)=>this.getCellRaw(e,t)),this._rowManager=new nS(this._snapshot,this._viewModel,i),this._columnManager=new $x(this._snapshot,r),this._spanModel=new rS(this._snapshot.mergeData)}__interceptViewModel(e){e(this._viewModel)}__registerGetCellHeight(e){return this._getCellHeight=e,D(()=>{this._getCellHeight=null})}getSnapshot(){return this._snapshot}getCellHeight(e,t){return this._getCellHeight?this._getCellHeight(e,t):this.getRowHeight(e)}setMergeData(e){this._snapshot.mergeData=e,this.getSpanModel().rebuild(e)}getSpanModel(){return this._spanModel}setIsRowStylePrecedeColumnStyle(e){this._isRowStylePrecedeColumnStyle=e}getStyleDataByHash(e){return{...this._styles.get(e)}}setStyleData(e){return this._styles.setValue(e)}getColumnStyle(e,t=!1){return t?this._columnManager.getColumnStyle(e):this._styles.get(this._columnManager.getColumnStyle(e))}setColumnStyle(e,t){this._columnManager.setColumnStyle(e,t)}getRowStyle(e,t=!1){return t?this._rowManager.getRowStyle(e):this._styles.get(this._rowManager.getRowStyle(e))}setRowStyle(e,t){this._rowManager.setRowStyle(e,t)}getDefaultCellStyle(){return this._snapshot.defaultStyle}getDefaultCellStyleInternal(){let e=this._snapshot.defaultStyle;return this._styles.get(e)}setDefaultCellStyle(e){this._snapshot.defaultStyle=e}getCellStyle(e,t){let n=this.getCell(e,t);if(n){let e=n.s;return typeof e==`string`?this._styles.get(e):e}return null}getComposedCellStyle(e,t,n){let r=this.getDefaultCellStyleInternal(),i=this.getRowStyle(e),a=this.getColumnStyle(t),o=this.getCell(e,t),s=this._styles.getStyleByCell(o);return n??this._isRowStylePrecedeColumnStyle?ae(r,a,i,o==null?void 0:o.themeStyle,s):ae(r,i,a,o==null?void 0:o.themeStyle,s)}getComposedCellStyleByCellData(e,t,n,r){let i=this.getDefaultCellStyleInternal(),a=this.getRowStyle(e),o=this.getColumnStyle(t),s=this._styles.getStyleByCell(n);return r??this._isRowStylePrecedeColumnStyle?ae(i,o,a,n==null?void 0:n.themeStyle,s):ae(i,a,o,n==null?void 0:n.themeStyle,s)}getComposedCellStyleWithoutSelf(e,t,n,r){let i=n===void 0?this.getComposedCellStyle(e,t,r):this.getComposedCellStyleByCellData(e,t,n,r),a=this.getCellRaw(e,t);if(!a||!a.s)return i;let o=typeof a.s==`string`?this._styles.get(a.s):a.s;if(!o)return i;for(let e in o)e in i&&delete i[e];return i}getCellMatrix(){return this._cellData}getCellMatrixPrintRange(){let e=this.getCellMatrix(),t=this.getMergeData(),n=-1,r=-1,i=-1,a=-1,o=!1,s=!1;return e.forEach((t,c)=>{Object.keys(c).forEach(c=>{let l=+c,u=e.getValue(t,l),d=u!=null&&u.s?this._styles.get(u.s):null,f=(d==null?void 0:d.bd)&&(d.bd.b||d.bd.l||d.bd.r||d.bd.t||d.bd.bc_tr||d.bd.bl_tr||d.bd.ml_tr||d.bd.tl_bc||d.bd.tl_br||d.bd.tl_mr);(u&&(u.v!==null&&u.v!==void 0&&u.v!==``||u.p)||d!=null&&d.bg||f)&&(o?n=Math.min(n,t):(n=t,o=!0),r=Math.max(r,t),s?i=Math.min(i,l):(s=!0,i=l),a=Math.max(a,l))})}),t.forEach(e=>{o?n=Math.min(n,e.startRow):(n=e.startRow,o=!0),r=Math.max(r,e.endRow),s?i=Math.min(i,e.startColumn):(i=e.startColumn,o=!0),a=Math.max(a,e.endColumn)}),!o||!s?null:{startColumn:i,startRow:n,endColumn:a,endRow:r}}getRowManager(){return this._rowManager}getUnitId(){return this.unitId}getSheetId(){return this._sheetId}getColumnManager(){return this._columnManager}getName(){return this._snapshot.name}getMergeData(){return this._spanModel.getMergeDataSnapshot()}getMergedCell(e,t){return this._spanModel.getMergedCell(e,t)}getMergedCellRange(e,t,n,r){return this._spanModel.getMergedCellRange(e,t,n,r)}isRowContainsMergedCell(e){return this._spanModel.isRowContainsMergedCell(e)}isColumnContainsMergedCell(e){return this._spanModel.isColumnContainsMergedCell(e)}getCellInfoInMergeData(e,t){let n=this.getMergedCell(e,t),r=!1,i=!1,a=e,o=t,s=e,c=t;if(n){let{startRow:l,endRow:u,startColumn:d,endColumn:f}=n;e===l&&t===d?(a=u,o=f,s=l,c=d,i=!0):e>=l&&e<=u&&t>=d&&t<=f&&(a=u,o=f,s=l,c=d,r=!0)}return{actualRow:e,actualColumn:t,isMergedMainCell:i,isMerged:r,endRow:a,endColumn:o,startRow:s,startColumn:c}}getCell(e,t){return e<0||t<0?null:this._viewModel.getCell(e,t)}getCellValueOnly(e,t){return e<0||t<0?null:this._viewModel.getCellValueOnly(e,t)}getCellStyleOnly(e,t){return e<0||t<0?null:this._viewModel.getCellStyleOnly(e,t)}getCellRaw(e,t){return this.getCellMatrix().getValue(e,t)}getCellWithFilteredInterceptors(e,t,n,r){return this._viewModel.getCell(e,t,n,r)}getRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRangeFilterRows(e){let t=[];for(let n=e.startRow;n<=e.endRow;n++)this.getRowFiltered(n)&&t.push(n);return t}getMatrixWithMergedCells(e,t,n,r,i=`raw`){let a=this.getCellMatrix(),o=this._spanModel.getMergedCellRange(e,t,n,r),s=new du;return sf(e,n,t,r).forEach((e,t)=>{let n;if(i===`raw`)n=this.getCellRaw(e,t);else if(i===`intercepted`)n=this.getCell(e,t);else if(i===`both`){let i=this.getCellRaw(e,t);if(i){var r;n={...i};let a=(r=this.getCell(e,t))==null?void 0:r.v;Vx(a)&&n&&(n.displayV=String(a))}}n&&s.setValue(e,t,n)}),o.forEach(e=>{let{startColumn:t,startRow:n,endColumn:r,endRow:i}=e;sf(n,i,t,r).forEach((e,o)=>{e===n&&o===t&&s.setValue(e,o,{...a.getValue(e,o),rowSpan:i-n+1,colSpan:r-t+1}),(e!==n||o!==t)&&s.realDeleteValue(e,o)})}),s}getRange(e,t,n,r){return typeof e==`object`?new tS(this,e,{getStyles:()=>this._styles}):new tS(this,{startRow:e,startColumn:t,endColumn:r||t,endRow:n||e},{getStyles:()=>this._styles})}getScrollLeftTopFromSnapshot(){return{scrollLeft:this._snapshot.scrollLeft,scrollTop:this._snapshot.scrollTop}}getZoomRatio(){return this._snapshot.zoomRatio||1}getConfig(){return this._snapshot}getFreeze(){return this._snapshot.freeze}getMaxColumns(){let{_snapshot:e}=this,{columnCount:t}=e;return t}getMaxRows(){let{_snapshot:e}=this,{rowCount:t}=e;return t}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===0?0:1}getHiddenState(){return this._snapshot.hidden}setHiddenState(e){this._snapshot.hidden=e}hasHiddenGridlines(){let{_snapshot:e}=this,{showGridlines:t}=e;return t===0}getGridlinesColor(){return this.getConfig().gridlinesColor}getTabColor(){let{_snapshot:e}=this,{tabColor:t}=e;return t}getColumnWidth(e){return this.getColumnManager().getColumnWidth(e)}getRowHeight(e){return this._viewModel.getRowFiltered(e)?0:this.getRowManager().getRowHeight(e)}isRowFiltered(e){return this._viewModel.getRowFiltered(e)}getRowVisible(e){return!this.isRowFiltered(e)&&this.getRowRawVisible(e)}getRowRawVisible(e){return this.getRowManager().getRowRawVisible(e)}getHiddenRows(e,t){let n=this.getMaxColumns()-1,r=this._rowManager.getHiddenRows(e,t);return r.forEach(e=>e.endColumn=n),r}getColVisible(e){return this._columnManager.getColVisible(e)}getHiddenCols(e,t){let n=this.getMaxRows()-1,r=this._columnManager.getHiddenCols(e,t);return r.forEach(e=>e.endRow=n),r}getVisibleRows(){let e=this.getRowCount();return this._rowManager.getVisibleRows(0,e-1)}getVisibleCols(){let e=this.getColumnCount();return this._columnManager.getVisibleCols(0,e-1)}isRightToLeft(){let{_snapshot:e}=this,{rightToLeft:t}=e;return t}getLastRowWithContent(){return this._cellData.getRealRowRange().endRow}getLastColumnWithContent(){return this.getDataRealRange().endColumn}getDataRealRange(){return this._cellData.getRealRange()}getDataRangeScope(){return this._cellData.getStartEndScope()}cellHasValue(e){return e&&(e.v!==void 0||e.f!==void 0||e.p!==void 0)}iterateByRow(e,t=!0){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this;return{[Symbol.iterator]:()=>{let e=n,s=r;return{next(){for(;;){if(s>a&&(e+=1,s=r),e>i)return{done:!0,value:void 0};let n=o.getCell(e,s),c=!n,l=o.getMergedCell(e,s);if(l){if(e!==l.startRow||s!==l.startColumn||c&&t){s=l.endColumn+1;continue}let r={row:e,col:s,value:n};return r.colSpan=l.endColumn-l.startColumn+1,r.rowSpan=l.endRow-l.startRow+1,s=l.endColumn+1,{done:!1,value:r}}if(c&&t)s+=1;else{let t={row:e,col:s,value:n};return s+=1,{done:!1,value:t}}}}}}}}iterateByColumn(e,t=!0,n=!0){let{startRow:r,startColumn:i,endRow:a,endColumn:o}=e,s=this;return{[Symbol.iterator]:()=>{let e=r,c=i;return{next(){for(;;){if(e>a&&(c+=1,e=r),c>o)return{done:!0,value:void 0};let i=s.getMergedCell(e,c);if(i){let r=e!==i.startRow,a=r||c!==i.startColumn;if(n&&a||!n&&r){e=i.endRow+1;continue}let o=s.getCell(i.startRow,i.startColumn);if(!o&&t){e=i.endRow+1;continue}let l={row:e,col:i.startColumn,value:o};return l.colSpan=i.endColumn-i.startColumn+1,l.rowSpan=i.endRow-i.startRow+1,e=i.endRow+1,{done:!1,value:l}}let l=s.getCell(e,c);if(!l&&t)e+=1;else{let t={row:e,col:c,value:l};return e+=1,{done:!1,value:t}}}}}}}}getCellDocumentModel(e,t,n=aS){var r;if(!e)return;let{isDeepClone:i,displayRawFormula:a,ignoreTextRotation:o}={...aS,...n},s,c=`document`,l=Rx(t),u=o?Y.tr:l.textRotation||Y.tr,d=l.horizontalAlign||Y.ht,f=l.verticalAlign||Y.vt,p=l.wrapStrategy||Y.tb,m=l.paddingData||Fx;if(e.f&&a)s=Lx(e.f.toString(),{},{verticalAlign:f}),d=Y.ht;else if(e.p){let{centerAngle:t,vertexAngle:n}=Kx(u);s=this._updateConfigAndGetDocumentModel(i?z.deepClone(e.p):e.p,d,m,{horizontalAlign:d,verticalAlign:f,centerAngle:t,vertexAngle:n,wrapStrategy:p,zeroWidthParagraphBreak:1})}else if(e.v!=null){let n=zx(t);c=Ux(n).fontCache;let r=sS(e);e.t===4&&a&&(r=`'${r}`),s=Lx(r,n,{...l,textRotation:u,cellValueType:e.t})}return s&&e.linkUrl&&e.linkId&&Bx(s,e.linkUrl,e.linkId),{documentModel:s,fontString:c,textRotation:u,wrapStrategy:p,verticalAlign:f,horizontalAlign:d,paddingData:m,fill:t==null||(r=t.bg)==null?void 0:r.rgb}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new Ey(e)}getBlankCellDocumentModel(e,t,n){var r;let i=this.getComposedCellStyleByCellData(t,n,e),a=zx(i),o=this.getCellDocumentModel(e,i,{ignoreTextRotation:!0});if(o!=null)return o.documentModel??=Lx(``,a),o;let s=Rx(i),c=Y.tr,l=s.horizontalAlign??Y.ht,u=s.verticalAlign??Y.vt,d=s.wrapStrategy??Y.tb,f=s.paddingData??Fx,p=Ux(a).fontCache;return{documentModel:Lx(``,a),fontString:p,textRotation:c,wrapStrategy:d,verticalAlign:u,horizontalAlign:l,paddingData:f,fill:i==null||(r=i.bg)==null?void 0:r.rgb}}getCellDocumentModelWithFormula(e,t,n){let r=this.getComposedCellStyleByCellData(t,n,e);return this.getCellDocumentModel(e,r,{isDeepClone:!0,displayRawFormula:!0,ignoreTextRotation:!0})}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};function sS(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;return typeof r==`string`?e.t===3?r.toUpperCase():r.replace(/[\r\n]/g,``):typeof r==`number`?e.t===3?r?`TRUE`:`FALSE`:r.toString():typeof r==`boolean`?r?`TRUE`:`FALSE`:``}function cS(e){var t;if(!e)return``;let n=(t=e.p)==null||(t=t.body)==null?void 0:t.dataStream;if(n)return Z.transform.getPlainText(n);let r=e.v;if(r==null)return``;if(e.t===3){if(typeof r==`string`)return r.toUpperCase();if(typeof r==`number`)return r?`TRUE`:`FALSE`}return typeof r==`boolean`?r?`TRUE`:`FALSE`:String(r)}function lS(e){if(e===null)return``;if(e!=null&&e.p){let t=e==null?void 0:e.p.body;if(t==null)return``;let n=t.dataStream;return Z.transform.getPlainText(n)}return e==null?void 0:e.v}function uS(e,t){return`${e.getUnitId()}|${t.getSheetId()}`}let dS=class extends M{get _activeSheet(){return this._activeSheet$.getValue()}get name(){return this._name$.getValue()}static isIRangeType(e){return typeof e==`string`||`startRow`in e||`row`in e}constructor(e={},r){super(),this._logService=r,T(this,`type`,n.UniverType.UNIVER_SHEET),T(this,`_sheetCreated$`,new t.Subject),T(this,`sheetCreated$`,this._sheetCreated$.asObservable()),T(this,`_sheetDisposed$`,new t.Subject),T(this,`sheetDisposed$`,this._sheetDisposed$.asObservable()),T(this,`_activeSheet$`,new t.BehaviorSubject(null)),T(this,`activeSheet$`,this._activeSheet$.asObservable()),T(this,`_worksheets`,void 0),T(this,`_styles`,void 0),T(this,`_snapshot`,void 0),T(this,`_unitId`,void 0),T(this,`_count`,void 0),T(this,`_name$`,void 0),T(this,`name$`,void 0);let i=jx();z.isEmptyObject(e)?this._snapshot=i:(this._snapshot=z.commonExtend(i,e),e.dateSystem==null?delete this._snapshot.dateSystem:e.dateSystem!==`date1900`&&e.dateSystem!==`date1904`&&(this._logService.warn(`[Workbook]`,`Unknown date system "${String(e.dateSystem)}"; falling back to Excel 1900.`),this._snapshot.dateSystem=`date1900`)),this._snapshot.calculationSettings=Ax(e.calculationSettings);let{styles:a}=this._snapshot;(this._snapshot.id==null||this._snapshot.id.length===0)&&(this._snapshot.id=J(6)),this._unitId=this._snapshot.id,this._styles=new Mx(a),this._count=1,this._worksheets=/* @__PURE__ */ new Map,this._name$=new t.BehaviorSubject(e.name||``),this.name$=this._name$.asObservable(),this._parseWorksheetSnapshots()}dispose(){super.dispose(),this._sheetCreated$.complete(),this._sheetDisposed$.complete(),this._activeSheet$.complete(),this._name$.complete(),Array.from(this._worksheets.keys()).forEach(e=>{this._removeSheet(e)})}save(){return z.deepClone(this._snapshot)}getSnapshot(){return this._snapshot}getCalculationSettings(){return Ax(this._snapshot.calculationSettings)}setCalculationSettings(e){this._snapshot.calculationSettings={...e}}setName(e){this._name$.next(e),this._snapshot.name=e}getUnitId(){return this._unitId}getDateSystem(){return this._snapshot.dateSystem===`date1904`?`date1904`:`date1900`}getRev(){return this._snapshot.rev??1}incrementRev(){this._snapshot.rev=this.getRev()+1}setRev(e){this._snapshot.rev=e}addWorksheet(e,t,n){let{sheets:r,sheetOrder:i}=this._snapshot;if(r[e])return!1;r[e]=n,i.splice(t,0,e),this.ensureSheetOrderUnique();let a=new oS(this._unitId,n,this._styles);return this._worksheets.set(e,a),this._sheetCreated$.next(a),!0}getSheetOrders(){return this._snapshot.sheetOrder}ensureSheetOrderUnique(){let e=/* @__PURE__ */ new Set,t=[];for(let n of this._snapshot.sheetOrder)e.has(n)||(e.add(n),t.push(n));this._snapshot.sheetOrder=t,e.clear()}getWorksheets(){return this._worksheets}getActiveSpreadsheet(){return this}getStyles(){return this._styles}addStyles(e){Object.entries(e).forEach(([e,t])=>{this._styles.addCustomStyle(e,t)})}removeStyles(e){e.forEach(e=>{this._styles.remove(e)})}getConfig(){return this._snapshot}getIndexBySheetId(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>t===e)}getActiveSheet(e){if(!this._activeSheet&&e===void 0)throw Error(`[Workbook]: no active Worksheet on Workbook ${this._unitId}!`);return this._activeSheet}ensureActiveSheet(){let e=this._activeSheet;if(e)return e;let t=this._snapshot.sheetOrder;for(let e=0,n=t.length;e<n;e++){let n=this._worksheets.get(t[e]);if(n&&n.isSheetHidden()!==1)return this.setActiveSheet(n),n}let n=this._worksheets.get(t[0]);return this.setActiveSheet(n),n}setActiveSheet(e){this._activeSheet$.next(e)}_removeSheet(e){let t=this._worksheets.get(e);return t?(this._worksheets.delete(e),this._snapshot.sheetOrder.splice(this._snapshot.sheetOrder.indexOf(e),1),this.ensureSheetOrderUnique(),this._sheetDisposed$.next(t),!0):!1}removeSheet(e){let t=this._removeSheet(e);return t&&delete this._snapshot.sheets[e],t}getActiveSheetIndex(){let{sheetOrder:e}=this._snapshot;return e.findIndex(e=>this._worksheets.get(e)===this._activeSheet)}getSheetSize(){return this._snapshot.sheetOrder.length}getSheets(){let{sheetOrder:e}=this._snapshot;return e.map(e=>this._worksheets.get(e))}getSheetsName(){let{sheetOrder:e}=this._snapshot,t=[];return e.forEach(e=>{let n=this._worksheets.get(e);n&&t.push(n.getName())}),t}getSheetIndex(e){let{sheetOrder:t}=this._snapshot;return t.findIndex(t=>e.getSheetId()===t)}getSheetBySheetName(e){let{sheetOrder:t}=this._snapshot,n=t.find(t=>this._worksheets.get(t).getName()===e);return this._worksheets.get(n)}getSheetBySheetId(e){return this._worksheets.get(e)}getSheetByIndex(e){let{sheetOrder:t}=this._snapshot;return this._worksheets.get(t[e])}getHiddenWorksheets(e=!0){return this.getSheets().filter(e=>e.isSheetHidden()===1).filter(t=>e||t.getHiddenState()!==2).map(e=>e.getConfig().id)}getUnhiddenWorksheets(){return this.getSheets().filter(e=>e.isSheetHidden()!==1).map(e=>e.getConfig().id)}load(e){this._snapshot=e}checkSheetName(e){return this.getSheetsName().some(t=>t.toLowerCase()===e.toLowerCase())}uniqueSheetName(e=`Sheet1`){let t=e;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}generateNewSheetName(e){let t=e+this._count;for(;this.checkSheetName(t);)t=e+this._count,this._count++;return t}_parseWorksheetSnapshots(){let{_snapshot:e,_worksheets:t}=this,{sheets:n,sheetOrder:r}=e;if(z.isEmptyObject(n)){let e=J();n[e]={id:e}}for(let e in n){let i=n[e],{name:a}=i;i.name=this.uniqueSheetName(a),i.name!==a&&this._logService.debug(`[Workbook]`,`The worksheet name ${a} is duplicated, we changed it to ${i.name}. Please fix the problem in your snapshot.`);let o=new oS(this._unitId,i,this._styles);t.set(e,o),r.includes(e)||r.push(e)}this.ensureSheetOrderUnique(),this.ensureActiveSheet()}getCustomMetadata(){return this._snapshot.custom}setCustomMetadata(e){this._snapshot.custom=e}};dS=ma([V(1,da)],dS);let fS=(0,i.createIdentifier)(`univer.current`),pS=class extends k{constructor(e,n,r){super(),this._injector=e,this._contextService=n,this._logService=r,T(this,`_unitsByType`,/* @__PURE__ */ new Map),T(this,`_unitCreateOptions`,/* @__PURE__ */ new Map),T(this,`_createHandler`,void 0),T(this,`_ctorByType`,/* @__PURE__ */ new Map),T(this,`_currentUnits`,/* @__PURE__ */ new Map),T(this,`_currentUnits$`,new t.BehaviorSubject(this._currentUnits)),T(this,`currentUnits$`,this._currentUnits$.asObservable()),T(this,`_unitAdded$`,new t.Subject),T(this,`unitAdded$`,this._unitAdded$.asObservable()),T(this,`_unitDisposed$`,new t.Subject),T(this,`unitDisposed$`,this._unitDisposed$.asObservable()),T(this,`_focused$`,new t.BehaviorSubject(null)),T(this,`focused$`,this._focused$.asObservable())}dispose(){super.dispose(),this._focused$.complete(),this._currentUnits$.complete(),this._unitAdded$.complete(),this._currentUnits.forEach(e=>e==null?void 0:e.dispose()),this._currentUnits.clear(),this._unitsByType.clear(),this._unitCreateOptions.clear()}__setCreateHandler(e){this._createHandler=e}createUnit(e,t,n){return this._createHandler(e,t,this._ctorByType.get(e),n)}registerCtorForType(e,t){return this._ctorByType.set(e,t),{dispose:()=>{this._ctorByType.delete(e)}}}__getCtorByType(e){return this._ctorByType.get(e)}getCurrentTypeOfUnit$(e){return this.currentUnits$.pipe((0,t.map)(t=>t.get(e)??null),(0,t.distinctUntilChanged)())}getCurrentUnitOfType(e){return this._currentUnits.get(e)}setCurrentUnitForType(e){let t=this._getUnitById(e);if(!t)throw Error(`[UniverInstanceService]: no document with unitId ${e}!`);this._currentUnits.get(t[1])!==t[0]&&(this._currentUnits.set(t[1],t[0]),this._currentUnits$.next(this._currentUnits))}getTypeOfUnitAdded$(e){return this._unitAdded$.pipe((0,t.filter)(t=>t.unit.type===e))}__addUnit(e,t){this._logService.debug(`[UniverInstanceService]: Adding unit with id ${e.getUnitId()}`);let n=e.type;this._unitsByType.has(n)||this._unitsByType.set(n,[]);let r=this._unitsByType.get(n),i=e.getUnitId();if(r.findIndex(e=>e.getUnitId()===i)!==-1)throw Error(`[UniverInstanceService]: cannot create a unit with the same unit id: ${i}.`);r.push(e),t&&this._unitCreateOptions.set(i,{...t}),this._unitAdded$.next({unit:e,options:t}),((t==null?void 0:t.makeCurrent)??!0)&&this.setCurrentUnitForType(e.getUnitId())}getTypeOfUnitDisposed$(e){return this.unitDisposed$.pipe((0,t.filter)(t=>t.type===e))}getUnit(e,t){var n;let r=(n=this._getUnitById(e))==null?void 0:n[0];return t&&(r==null?void 0:r.type)!==t?null:r}getUnitCreateOptions(e){return this._unitCreateOptions.get(e)??null}getAllUnitsForType(e){return this._unitsByType.get(e)??[]}get focused(){var e;let t=this._focused$.getValue();return t?(e=this._getUnitById(t))==null?void 0:e[0]:null}focusUnit(e){var t,r;this._focused$.getValue()!==e&&(this._focused$.next(e),this.focused instanceof dS?(this._contextService.setContextValue(gx,!0),this._contextService.setContextValue(vx,!1),this._contextService.setContextValue(_x,!0),this._contextService.setContextValue(yx,!1),this._contextService.setContextValue(bx,!1),this.setCurrentUnitForType(e)):this.focused instanceof Ey?(this._contextService.setContextValue(gx,!0),this._contextService.setContextValue(vx,!0),this._contextService.setContextValue(_x,!1),this._contextService.setContextValue(yx,!1),this._contextService.setContextValue(bx,!1),this.setCurrentUnitForType(e)):((t=this.focused)==null?void 0:t.type)===n.UniverType.UNIVER_SLIDE?(this._contextService.setContextValue(gx,!0),this._contextService.setContextValue(vx,!1),this._contextService.setContextValue(_x,!1),this._contextService.setContextValue(yx,!0),this._contextService.setContextValue(bx,!1),this.setCurrentUnitForType(e)):((r=this.focused)==null?void 0:r.type)===n.UniverType.UNIVER_BOARD?(this._contextService.setContextValue(gx,!0),this._contextService.setContextValue(vx,!1),this._contextService.setContextValue(_x,!1),this._contextService.setContextValue(yx,!1),this._contextService.setContextValue(bx,!0),this.setCurrentUnitForType(e)):(this._contextService.setContextValue(gx,!1),this._contextService.setContextValue(vx,!1),this._contextService.setContextValue(_x,!1),this._contextService.setContextValue(yx,!1),this._contextService.setContextValue(bx,!1)))}getFocusedUnit(){return this.focused}getUnitType(e){let t=this._getUnitById(e);return t?t[1]:n.UniverType.UNRECOGNIZED}disposeUnit(e){this._logService.debug(`[UniverInstanceService]: Disposing unit with id ${e}`);let t=this._getUnitById(e);if(!t)return this._logService.debug(`[UniverInstanceService]: No unit found with id ${e}`),!1;let[n,r]=t,i=this._unitsByType.get(r),a=i.indexOf(n);return i.splice(a,1),this._tryResetCurrentOnRemoval(e,r),this._tryResetFocusOnRemoval(e),this._unitDisposed$.next(n),this._unitCreateOptions.delete(e),n.dispose(),!0}_tryResetCurrentOnRemoval(e,t){let n=this.getCurrentUnitOfType(t);(n==null?void 0:n.getUnitId())===e&&(this._currentUnits.set(t,null),this._currentUnits$.next(this._currentUnits))}_tryResetFocusOnRemoval(e){this._focused$.getValue()===e&&this.focusUnit(null)}_getUnitById(e){for(let[t,n]of this._unitsByType){let r=n.find(t=>t.getUnitId()===e);if(r)return[r,t]}}};pS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,ca),V(2,(0,i.Inject)(da))],pS);let mS=/* @__PURE__ */ function(e){return e[e.Starting=0]=`Starting`,e[e.Ready=1]=`Ready`,e[e.Rendered=2]=`Rendered`,e[e.Steady=3]=`Steady`,e}({}),hS={0:`Starting`,1:`Ready`,2:`Rendered`,3:`Steady`};var gS=class extends Error{constructor(e){super(`[LifecycleService]: lifecycle stage "${hS[e]}" will never be reached!`),this.name=`LifecycleUnreachableError`}};let _S=class extends k{constructor(e){super(),this._logService=e,T(this,`_lifecycle$`,new t.BehaviorSubject(0)),T(this,`lifecycle$`,this._lifecycle$.asObservable()),T(this,`_lock`,!1),this._reportProgress(0)}get stage(){return this._lifecycle$.getValue()}set stage(e){if(this._lock)throw Error(`[LifecycleService]: cannot set new stage when related logic is all handled!`);if(e<this.stage)throw Error(`[LifecycleService]: lifecycle stage cannot go backward!`);e!==this.stage&&(this._lock=!0,this._reportProgress(e),this._lifecycle$.next(e),this._lock=!1)}dispose(){this._lifecycle$.complete(),super.dispose()}onStage(e){return(0,t.firstValueFrom)(this.lifecycle$.pipe((0,t.filter)(t=>t>=e),Ta(t=>t===e),(0,t.map)(()=>void 0))).catch(t=>t.name===`EmptyError`?Promise.reject(new gS(e)):Promise.reject(t))}subscribeWithPrevious(){return(0,t.merge)(vS(this.stage),this._lifecycle$.pipe((0,t.skip)(1))).pipe(Ta(e=>e===3))}_reportProgress(e){this._logService.debug(`[LifecycleService]`,`lifecycle progressed to "${hS[e]}".`)}};_S=ma([V(0,da)],_S);function vS(e){switch(e){case 0:return(0,t.of)(0);case 1:return(0,t.of)(0,1);case 2:return(0,t.of)(0,1,2);default:return(0,t.of)(0,1,2,3)}}let yS=(0,i.createIdentifier)(`ILocalStorageService`),bS=/* @__PURE__ */ new Map([[`enUS`,`$`],[`ruRU`,`₽`],[`viVN`,`₫`],[`zhCN`,`¥`],[`zhTW`,`NT$`],[`zhHK`,`HK$`],[`frFR`,`€`],[`faIR`,`﷼`],[`koKR`,`₩`],[`esES`,`€`],[`caES`,`€`],[`skSK`,`€`],[`jaJP`,`¥`],[`ptBR`,`R$`],[`deDE`,`€`],[`itIT`,`€`],[`idID`,`Rp`],[`plPL`,`zł`],[`arSA`,`﷼`]]);function xS(e){return bS.get(e)||`$`}var SS=class extends k{get _currentLocale(){return this._currentLocale$.value}constructor(){super(),T(this,`_currentLocale$`,new t.BehaviorSubject(`zhCN`)),T(this,`currentLocale$`,this._currentLocale$.asObservable()),T(this,`_direction$`,new t.BehaviorSubject(`ltr`)),T(this,`direction$`,this._direction$.asObservable()),T(this,`_locales`,null),T(this,`localeChanged$`,new t.Subject),T(this,`t`,(e,...t)=>{if(!this._locales)throw Error(`[LocaleService]: Locale not initialized`);let n=e.split(`.`),r=this.resolveKeyPath(this._locales[this._currentLocale],n);if(typeof r==`string`){let e=r;return t.forEach((t,n)=>{e=e.replace(`{${n}}`,t)}),e}return e}),this.disposeWithMe(D(()=>{this._locales=null,this._currentLocale$.complete(),this._direction$.complete(),this.localeChanged$.complete()}))}load(e){this._locales=na(this._locales??{},e)}setLocale(e){this._currentLocale$.next(e),this.localeChanged$.next()}getLocales(){var e;return(e=this._locales)==null?void 0:e[this._currentLocale]}getCurrentLocale(){return this._currentLocale}setDirection(e){this._direction$.next(e)}getDirection(){return this._direction$.value}resolveKeyPath(e,t){let n=t.shift();if(n&&e&&n in e){let r=e[n];return t.length>0&&(typeof r==`object`||Array.isArray(r))?this.resolveKeyPath(r,t):r}return null}};let CS=class{constructor(e){this._userManagerService=e}async list(e){return{list:[{type:0,mentions:[{objectType:0,objectId:this._userManagerService.getCurrentUser().userID,label:this._userManagerService.getCurrentUser().name,metadata:{icon:this._userManagerService.getCurrentUser().avatar}}],metadata:{},title:`PEOPLE`}],page:e.page,size:e.size,total:1}}};CS=ma([V(0,(0,i.Inject)(dx))],CS);let wS=(0,i.createIdentifier)(`univer.service.mention-io`);var TS=class extends k{constructor(e,n,r,i){super(),this._objectTypes=i,T(this,`_rules`,/* @__PURE__ */ new Map),T(this,`_changes`,new t.Subject),T(this,`changed$`,this._changes.asObservable()),this.disposeWithMe(e.registerPluginResource({pluginName:n,businesses:[r],toJson:e=>JSON.stringify(this.getRules(e)),parseJson:e=>{let t=JSON.parse(e);if(!Array.isArray(t)||t.some(e=>!e||typeof e.objectId!=`string`||typeof e.permissionId!=`string`||!e.permissionId||!this._objectTypes.includes(e.objectType)))throw Error(`Invalid object permission resource.`);return t},onLoad:(e,t)=>{this._rules.set(e,new Map(t.map(e=>[this._key(e.objectType,e.objectId),z.deepClone(e)]))),this._changes.next(e)},onUnLoad:e=>{this._rules.delete(e),this._changes.next(e)}})),this.disposeWithMe(()=>{this._rules.clear(),this._changes.complete()})}getRules(e){var t;return[...((t=this._rules.get(e))==null?void 0:t.values())??[]].map(e=>z.deepClone(e))}getRule(e,t,n){var r;let i=(r=this._rules.get(e))==null?void 0:r.get(this._key(t,n));return i&&z.deepClone(i)}setRule(e,t,n,r){return this.setRules(e,[{objectId:n,objectType:t,rule:r}])}setRules(e,t){if(typeof e!=`string`||!e||!Array.isArray(t)||t.length===0)return!1;let n=/* @__PURE__ */ new Set;for(let e of t){if(!e)return!1;let{objectId:t,objectType:r,rule:i}=e,a=this._key(r,t);if(typeof t!=`string`||!t||!this._objectTypes.includes(r)||n.has(a)||i!==null&&(!i||i.objectId!==t||i.objectType!==r||typeof i.permissionId!=`string`||!i.permissionId))return!1;n.add(a)}let r=z.deepClone(t),i=this._rules.get(e)??/* @__PURE__ */ new Map;for(let{objectId:e,objectType:t,rule:n}of r)n?i.set(this._key(t,e),n):i.delete(this._key(t,e));return this._rules.set(e,i),this._changes.next(e),!0}_key(e,t){return`${e}/${t}`}};let ES=(0,i.createIdentifier)(`univer.undo-redo.service`);var DS=class{dispose(){}async dispatchToHandlers(){return!1}};let OS=`univer.command.redo`,kS=`univer.command.undo`,AS=new class extends DS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,kS)}handler(e){let t=e.get(ES),n=t.pitchTopUndoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.undoMutations,r).result?(t.popUndoToRedo(),!0):!1}},jS=new class extends DS{constructor(...e){super(...e),T(this,`type`,0),T(this,`id`,OS)}handler(e){let t=e.get(ES),n=t.pitchTopRedoElement();if(!n)return!1;let r=e.get(_a);return Sa(n.redoMutations,r).result?(t.popRedoToUndo(),!0):!1}},MS=class extends k{constructor(e,n,r,i){super(),this._univerInstanceService=e,this._commandService=n,this._contextService=r,T(this,`undoRedoStatus$`,void 0),T(this,`_undoRedoStatus$`,new t.BehaviorSubject({undos:0,redos:0})),T(this,`_undoStacks`,/* @__PURE__ */ new Map),T(this,`_redoStacks`,/* @__PURE__ */ new Map),T(this,`_batchingStatus`,/* @__PURE__ */ new Map),T(this,`_activeGroups`,/* @__PURE__ */ new Map),T(this,`_itemGroups`,/* @__PURE__ */ new WeakMap),T(this,`_historyLimit`,void 0),this._historyLimit=i.getConfig(`undoRedo.historyLimit`)??50,this.undoRedoStatus$=this._undoRedoStatus$.asObservable(),this.disposeWithMe(this._commandService.registerCommand(AS)),this.disposeWithMe(this._commandService.registerCommand(jS)),this.disposeWithMe(D(()=>this._undoRedoStatus$.complete())),this.disposeWithMe(D(this._univerInstanceService.focused$.subscribe(()=>this._updateStatus()))),this.disposeWithMe(D(this._univerInstanceService.unitDisposed$.subscribe(e=>{let t=e.getUnitId();this._undoStacks.delete(t),this._redoStacks.delete(t),this._batchingStatus.delete(t),this._activeGroups.delete(t),this._updateStatus()}))),this.disposeWithMe(D(()=>{this._undoStacks.clear(),this._redoStacks.clear(),this._batchingStatus.clear(),this._activeGroups.clear()}))}getUndoRedoStatus(e){var t,n;return{undos:((t=this._undoStacks.get(e))==null?void 0:t.length)??0,redos:((n=this._redoStacks.get(e))==null?void 0:n.length)??0}}pushUndoRedo(e){let{unitID:t}=e,n=this._getRedoStack(t,!0),r=this._getUndoStack(t,!0),i=this._historyLimit;n.length=0;let a=this._activeGroups.get(t),o=this._pitchUndoElement(t);a?o&&this._itemGroups.get(o)===a.id?a.mode===`replace`?o.redoMutations=e.redoMutations:(o.redoMutations.push(...e.redoMutations),o.undoMutations.unshift(...e.undoMutations)):(s(e),this._itemGroups.set(e,a.id)):this._batchingStatus.has(e.unitID)?this._batchingStatus.get(e.unitID)===0||!o?(s(e),this._batchingStatus.set(e.unitID,1)):this._tryBatchingElements(o,e):s(e);function s(e){r.push(e),r.length>i&&r.splice(0,1)}this._updateStatus()}beginUndoRedoGroup(e,t,n=`replace`){if(this._activeGroups.has(e)||this._batchingStatus.has(e))throw Error(`[LocalUndoRedoService]: cannot group undo redo twice at the same time!`);let r={id:t,mode:n};return this._activeGroups.set(e,r),D(()=>{this._activeGroups.get(e)===r&&this._activeGroups.delete(e)})}clearUndoRedo(e){let t=this._getRedoStack(e);t&&(t.length=0);let n=this._getUndoStack(e);n&&(n.length=0),this._updateStatus()}pitchTopUndoElement(){let e=this._getFocusedUnitId();return this._pitchUndoElement(e)}pitchTopRedoElement(){let e=this._getFocusedUnitId();return this._pitchRedoElement(e)}_pitchUndoElement(e){let t=this._getUndoStack(e);return t!=null&&t.length?t[t.length-1]:null}_pitchRedoElement(e){let t=this._getRedoStack(e);return t!=null&&t.length?t[t.length-1]:null}popUndoToRedo(){let e=this._getUndoStackForFocused().pop();e&&(this._itemGroups.delete(e),e.redoMutations.length>0&&this._getRedoStackForFocused().push(e),this._updateStatus())}popRedoToUndo(){let e=this._getRedoStackForFocused().pop();e&&(this._itemGroups.delete(e),this._getUndoStackForFocused().push(e),this._updateStatus())}rollback(e,t){let n=t||this._getFocusedUnitId(),r=this._getUndoStack(n),i=r==null?void 0:r[(r==null?void 0:r.length)-1];i&&i.id===e&&(r.pop(),this._itemGroups.delete(i),Sa(i.undoMutations,this._commandService))}__tempBatchingUndoRedo(e){if(this._batchingStatus.has(e)||this._activeGroups.has(e))throw Error(`[LocalUndoRedoService]: cannot batching undo redo twice at the same time!`);return this._batchingStatus.set(e,0),D(()=>this._batchingStatus.delete(e))}_updateStatus(){var e,t;let n=this._getFocusedUnitId(),r=n&&((e=this._undoStacks.get(n))==null?void 0:e.length)||0,i=n&&((t=this._redoStacks.get(n))==null?void 0:t.length)||0;this._undoRedoStatus$.next({undos:r,redos:i})}_getUndoStack(e,t=!1){let n=this._undoStacks.get(e);return!n&&t&&(n=[],this._undoStacks.set(e,n)),n||null}_getRedoStack(e,t=!1){let n=this._redoStacks.get(e);return!n&&t&&(n=[],this._redoStacks.set(e,n)),n||null}_getUndoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getUndoStack(e,!0)}_getRedoStackForFocused(){let e=this._getFocusedUnitId();if(!e)throw Error(`No focused univer instance!`);return this._getRedoStack(e,!0)}_tryBatchingElements(e,t){e.redoMutations.push(...t.redoMutations),e.undoMutations.push(...t.undoMutations)}_getFocusedUnitId(){let e=``,t=this._contextService.getContextValue(_x),r=this._contextService.getContextValue(Sx),i=this._contextService.getContextValue(Cx),a=this._contextService.getContextValue(xx);if(a&&i){var o;return((o=this._univerInstanceService.getCurrentUnitOfType(n.UniverType.UNIVER_DOC))==null?void 0:o.getUnitId())??``}if(t){if(r&&a)e=kp;else if(a)e=Op;else{var s;e=((s=this._univerInstanceService.getFocusedUnit())==null?void 0:s.getUnitId())??``}}else{var c;e=((c=this._univerInstanceService.getFocusedUnit())==null?void 0:c.getUnitId())??``}return e}};MS=ma([V(0,fS),V(1,_a),V(2,ca),V(3,oa)],MS);let NS=/* @__PURE__ */ function(e){return e.INIT=`init`,e.FETCHING=`fetching`,e.DONE=`done`,e}({}),PS=(0,i.createIdentifier)(`univer.permission-service`),FS={[n.UnitObject.Document]:n.UnitObject.Document,[n.UnitObject.DocumentSection]:n.UnitObject.Document,[n.UnitObject.DocumentParagraph]:n.UnitObject.Document,[n.UnitObject.DocumentEntity]:n.UnitObject.Document,[n.UnitObject.Slide]:n.UnitObject.Slide,[n.UnitObject.SlidePage]:n.UnitObject.Slide,[n.UnitObject.SlideElement]:n.UnitObject.Slide,[n.UnitObject.SlideMaster]:n.UnitObject.Slide,[n.UnitObject.Base]:n.UnitObject.Base,[n.UnitObject.BaseTable]:n.UnitObject.Base,[n.UnitObject.BaseField]:n.UnitObject.Base,[n.UnitObject.BaseRecord]:n.UnitObject.Base,[n.UnitObject.BaseView]:n.UnitObject.Base,[n.UnitObject.BaseDashboard]:n.UnitObject.Base,[n.UnitObject.Board]:n.UnitObject.Board,[n.UnitObject.BoardElement]:n.UnitObject.Board},IS=class extends k{constructor(e,r,i,a,o,s){super(),this._injector=e,this._permissions=r,this._logService=i,this._users=a,this._config=o,this._commands=s,T(this,`_models`,/* @__PURE__ */ new Map),T(this,`_initialized`,/* @__PURE__ */ new Set),T(this,`_policies`,/* @__PURE__ */ new Map),T(this,`_generations`,/* @__PURE__ */ new Map),T(this,`_nextGeneration`,0),T(this,`_revision`,new t.BehaviorSubject(0)),T(this,`changed$`,this._revision.asObservable()),T(this,`_unitChanges`,new t.Subject),T(this,`unitChanges$`,this._unitChanges.asObservable()),this.disposeWithMe(this._permissions.permissionPointUpdate$.subscribe(e=>{e.subType===n.UnitAction.Edit&&FS[e.type]===e.type&&this._revision.next(this._revision.value+1)})),this.disposeWithMe(()=>{this._initialized.clear(),this._policies.clear(),this._generations.clear(),this._revision.complete(),this._unitChanges.complete()})}get _authz(){return this._injector.get(px)}registerRuleModel(e,t,r,i){if(this._models.has(e))throw Error(`Object permission rule model already registered.`);this._models.set(e,{model:t,mutationId:r,batchMutationId:i});let a=t.changed$.subscribe(e=>{this._generations.delete(e),this._policies.delete(e),t.getRules(e).forEach(t=>{if(!this.supports({unitId:e,objectId:t.objectId,objectType:t.objectType}))return;let r=`${t.objectType}.${n.UnitAction.Edit}_${e}_${t.objectId}`;this._permissions.getPermissionPoint(r)?this._permissions.updatePermissionPoint(r,!1):this._permissions.addPermissionPoint({id:r,type:t.objectType,subType:n.UnitAction.Edit,value:!1,status:`init`,unitId:e,objectId:t.objectId})}),this._revision.next(this._revision.value+1),this._initialized.has(e)&&this.refreshUnit(e).catch(e=>this._logService.error(e))});return this.disposeWithMe(D(()=>{a.unsubscribe(),this._models.delete(e)}))}_getRule(e){var t;return(t=this._models.get(FS[e.objectType]))==null?void 0:t.model.getRule(e.unitId,e.objectType,e.objectId)}_getAuthzId(e){var t;return e.objectId===e.unitId?e.unitId:(t=this._getRule(e))==null?void 0:t.permissionId}initializeUnit(e){if(!this.supports(e)||this._initialized.has(e.unitId))return;this._initialized.add(e.unitId);let t=[];this._permissions.getAllPermissionPoint().forEach(n=>{n.subscribe(n=>{`unitId`in n&&n.unitId===e.unitId&&t.push(n.id)}).unsubscribe()}),t.forEach(e=>this._permissions.updatePermissionPoint(e,!1)),this.refreshUnit(e.unitId).catch(e=>{this._logService.error(e)})}supports(e){var t;return((t=this._config.getConfig(`objectPermissionTypes`))==null?void 0:t.includes(e.objectType))===!0&&this._models.has(FS[e.objectType])}getPolicies(e){return this._policies.get(e)??[]}hasPolicy(e){var t,r;let i=this.getPolicies(e.unitId).find(t=>t.objectID===e.objectId&&t.objectType===e.objectType);return!!i&&(((t=i.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf||((r=i.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator||i.strategies.some(e=>e.role===n.UnitRole.Owner))}canView(e){var t;let r=FS[e.objectType];return this.supports(e)&&r!==void 0&&((t=this._permissions.getPermissionPoint(`${r}.${n.UnitAction.Edit}_${e.unitId}`))==null?void 0:t.value)===!0}async canManage(e){if(!this.supports(e))return!1;let t=await this._getPolicy(e);if(!this._getRule(e)&&e.objectId!==e.unitId){let t=FS[e.objectType];return t!==void 0&&this._allowed({...e,objectId:e.unitId,objectType:t},n.UnitAction.CreatePermissionObject)}return(e.objectId===e.unitId||!!t)&&this._canChangeRule(e,t,n.UnitAction.ManageCollaborator)}async canDelete(e){if(!this.supports(e)||e.objectId===e.unitId)return!1;let t=await this._getPolicy(e);return!!t&&this._canChangeRule(e,t,n.UnitAction.Delete)}async remove(e){var t;let n=(t=this._getRule(e))==null?void 0:t.permissionId;if(!await this.canDelete(e))throw Error(`Object permission deletion denied.`);await this._commitRule(e,null,n),await this.refreshUnit(e.unitId)}async _commitRule(e,t,n){let r=this._models.get(FS[e.objectType]);if(!r)throw Error(`Object permission rule model is not registered.`);let i=this._getRule(e)??null;if((i==null?void 0:i.permissionId)!==n)throw Error(`Object permission binding changed during the request.`);let a={id:r.mutationId,params:{...e,rule:t}},o={id:r.mutationId,params:{...e,rule:i}};if(!await this._commands.executeCommand(a.id,a.params))throw Error(`Could not update the object permission binding.`);this._injector.get(ES).pushUndoRedo({unitID:e.unitId,redoMutations:[a],undoMutations:[o]})}async _getPolicy(e){let t=this._getAuthzId(e);if(t)return(await this._authz.list({unitID:e.unitId,objectIDs:[t],actions:[]})).find(n=>n.unitID===e.unitId&&n.objectID===t&&n.objectType===e.objectType)}async _allowed(e,t){let n=this._getAuthzId(e);return n?(await this._authz.allowed({unitID:e.unitId,objectID:n,objectType:e.objectType,actions:[t]})).some(e=>e.action===t&&e.allowed===!0):!1}async _canChangeRule(e,t,n){var r;if(await this._allowed(e,n))return!0;let i=t==null||(r=t.creator)==null?void 0:r.userID;return!!i&&i===this._users.getCurrentUser().userID}async read(e){var t,r;let i=this._getAuthzId(e);if(!i)return{edit:`all`,collaborators:[],strategies:[]};let[a,o]=await Promise.all([this._getPolicy(e),e.objectId===e.unitId?[]:this._authz.listCollaborators({unitID:e.unitId,objectID:i})]),s=`all`;return(a==null||(t=a.scope)==null?void 0:t.edit)===n.ObjectScope.OneSelf?s=`owner`:(a==null||(r=a.scope)==null?void 0:r.edit)===n.ObjectScope.SomeCollaborator?s=`members`:a!=null&&a.strategies.some(e=>e.action===n.UnitAction.Edit&&e.role===n.UnitRole.Owner)&&(s=`owner`),{edit:s,collaborators:o,strategies:(a==null?void 0:a.strategies)??[]}}async setPoint(e,t,r){if(!this.supports(e)){this._permissions.getPermissionPoint(t.id)||this._permissions.addPermissionPoint(t),this._permissions.updatePermissionPoint(t.id,r);return}this._assertSupported(e);let i=await this.read(e);i.strategies=i.strategies.filter(e=>e.action!==t.subType),i.strategies.push({action:t.subType,role:r?n.UnitRole.Editor:n.UnitRole.Owner}),t.subType===n.UnitAction.Edit&&(i.edit=r?`all`:`owner`),await this.save(e,i)}async save(e,t){var n;let r=(n=this._getRule(e))==null?void 0:n.permissionId,i=await this._writePolicy(e,t,r);i&&await this._commitRule(e,i,r),await this.refreshUnit(e.unitId)}async _writePolicy(e,t,r){var i,a;if(this._assertSupported(e),!await this.canManage(e))throw Error(`Object permission management denied.`);if(e.objectId===e.unitId&&t.edit===`members`)throw Error(`File membership must be managed through the sharing service.`);if(t.edit===`members`&&!t.collaborators.length)throw Error(`Select at least one collaborator.`);let o=await this._getPolicy(e),s=t.strategies.filter(e=>e.action!==n.UnitAction.Edit);s.push({action:n.UnitAction.Edit,role:t.edit===`owner`?n.UnitRole.Owner:n.UnitRole.Editor});let c=n.ObjectScope.AllCollaborator;t.edit===`members`?c=n.ObjectScope.SomeCollaborator:t.edit===`owner`&&(c=n.ObjectScope.OneSelf);let l={read:(o==null||(i=o.scope)==null?void 0:i.read)??n.ObjectScope.AllCollaborator,edit:c};if(((a=this._getRule(e))==null?void 0:a.permissionId)!==r)throw Error(`Object permission binding changed during the request.`);let u=this._getAuthzId(e);if(u)await this._authz.update({unitID:e.unitId,objectID:u,objectType:e.objectType,name:(o==null?void 0:o.name)??e.objectId,share:void 0,strategies:s,scope:l,collaborators:e.objectId===e.unitId?void 0:{collaborators:t.edit===`members`?t.collaborators:[]}});else{let r={unitID:e.unitId,name:e.objectId,strategies:s,scope:l,collaborators:t.edit===`members`?t.collaborators:[]},i={objectType:e.objectType};switch(FS[e.objectType]){case n.UnitObject.Document:i.documentObject=r;break;case n.UnitObject.Slide:i.slideObject=r;break;case n.UnitObject.Base:i.baseObject=r;break;case n.UnitObject.Board:i.boardObject=r;break;default:throw Error(`Unsupported object permission type.`)}if(u=await this._authz.create(i),!u)throw Error(`Authz did not return a permission ID.`);return{objectId:e.objectId,objectType:e.objectType,permissionId:u}}}async saveMany(e){let t=e[0],n=t&&this._models.get(FS[t.objectType]);if(!t||!(n!=null&&n.batchMutationId)||e.some(e=>e.unitId!==t.unitId||e.objectId===t.unitId||FS[e.objectType]!==FS[t.objectType]||!this.supports(e))||new Set(e.map(e=>`${e.objectType}/${e.objectId}`)).size!==e.length)throw Error(`Invalid object permission batch.`);let r={succeeded:[],failed:[]},i=[];for(let t of e){let e=this._getRule(t)??null;try{let n;if(t.policy===null){if(!await this.canDelete(t))throw Error(`Object permission deletion denied.`);n=null}else n=await this._writePolicy(t,t.policy,e==null?void 0:e.permissionId);if(n===void 0){var a;if(((a=this._getRule(t))==null?void 0:a.permissionId)!==(e==null?void 0:e.permissionId))throw Error(`Object permission binding changed during the request.`);r.succeeded.push(t.objectId)}else i.push({target:t,rule:n,previous:e})}catch(e){r.failed.push({objectId:t.objectId,error:e})}}let o=i.filter(({target:e,previous:t})=>{var n;return((n=this._getRule(e))==null?void 0:n.permissionId)===(t==null?void 0:t.permissionId)||(r.failed.push({objectId:e.objectId,error:/* @__PURE__ */ Error(`Object permission binding changed during the request.`)}),!1)});if(o.length){let e={unitId:t.unitId,rules:o.map(({target:e,rule:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))},i={unitId:t.unitId,rules:o.map(({target:e,previous:t})=>({objectId:e.objectId,objectType:e.objectType,rule:t}))};try{if(!await this._commands.executeCommand(n.batchMutationId,e))throw Error(`Could not update the object permission bindings.`);this._injector.get(ES).pushUndoRedo({unitID:t.unitId,redoMutations:[{id:n.batchMutationId,params:e}],undoMutations:[{id:n.batchMutationId,params:i}]}),r.succeeded.push(...o.map(({target:e})=>e.objectId))}catch(e){r.failed.push(...o.map(({target:t})=>({objectId:t.objectId,error:e})))}}try{await this.refreshUnit(t.unitId)}catch(e){r.refreshError=e}return r}async refreshUnit(e){if(this._disposed)return;let t=[...this._models.values()].flatMap(({model:t})=>t.getRules(e)),r=new Map(t.map(e=>[`${e.objectType}/${e.objectId}`,e])),i=/* @__PURE__ */ new Map,a=(t,n,r,a)=>{if(!this.supports({unitId:e,objectId:r,objectType:n}))return;let o=`${n}/${t}`,s=i.get(o);i.set(o,{unitID:e,objectID:t,objectType:n,targetId:r,actions:[.../* @__PURE__ */ new Set([...(s==null?void 0:s.actions)??[],...a])]})},o=[];t.forEach(e=>a(e.permissionId,e.objectType,e.objectId,[n.UnitAction.Edit])),this._permissions.getAllPermissionPoint().forEach(t=>{t.subscribe(t=>{if(!(`unitId`in t)||t.unitId!==e)return;let n=`objectId`in t&&typeof t.objectId==`string`?t.objectId:e,i=r.get(`${t.type}/${n}`);n===e?a(e,t.type,e,[t.subType]):i?a(i.permissionId,t.type,n,[t.subType]):this.supports({unitId:e,objectId:n,objectType:t.type})&&o.push(t.id)}).unsubscribe()}),o.forEach(e=>this._permissions.updatePermissionPoint(e,!0));let s=++this._nextGeneration;this._generations.set(e,s);let c=[...i.values()];c.length&&this._initialized.add(e);let l=[],u=[];for(let t=0;t<c.length;t+=100){let n=c.slice(t,t+100),r=await this._authz.list({unitID:e,objectIDs:n.map(e=>e.objectID),actions:[]});l.push(...r),n.forEach(e=>{let t=r.find(t=>t.objectID===e.objectID&&t.objectType===e.objectType);e.actions=[.../* @__PURE__ */ new Set([...e.actions,...(t==null?void 0:t.strategies.map(e=>e.action))??[]])]}),u.push(...await this._authz.batchAllowed(n.map(({targetId:e,...t})=>t)))}if(this._disposed||this._generations.get(e)!==s)return;let d=new Map(u.filter(t=>t.unitID===e).map(e=>[e.objectID,e])),f=new Map(l.filter(t=>t.unitID===e).map(e=>[`${e.objectType}/${e.objectID}`,e]));c.forEach(t=>{let n=d.get(t.objectID),r=f.get(`${t.objectType}/${t.objectID}`);[.../* @__PURE__ */ new Set([...t.actions,...(r==null?void 0:r.strategies.map(e=>e.action))??[]])].forEach(r=>{let i=`${t.objectType}.${r}_${e}${t.targetId===e?``:`_${t.targetId}`}`;this._permissions.getPermissionPoint(i)||this._permissions.addPermissionPoint({id:i,type:t.objectType,subType:r,status:`done`,value:!1,unitId:e,objectId:t.targetId}),this._permissions.updatePermissionPoint(i,(n==null?void 0:n.actions.some(e=>e.action===r&&e.allowed===!0))??!1)})}),this._policies.set(e,l.filter(t=>t.unitID===e).map(e=>{var t;return{...e,objectID:((t=i.get(`${e.objectType}/${e.objectID}`))==null?void 0:t.targetId)??e.objectID}})),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}clearUnit(e){this._initialized.delete(e),this._generations.delete(e),this._policies.delete(e),this._revision.next(this._revision.value+1),this._unitChanges.next(e)}_assertSupported(e){if(!this.supports(e))throw Error(`Object permission management is not supported by this Authz provider.`)}};IS=ma([V(0,(0,i.Inject)(i.Injector)),V(1,PS),V(2,da),V(3,(0,i.Inject)(dx)),V(4,oa),V(5,_a)],IS);var LS=class extends k{constructor(...e){super(...e),T(this,`_permissionPointMap`,/* @__PURE__ */ new Map),T(this,`_permissionPointUpdate$`,new t.Subject),T(this,`permissionPointUpdate$`,this._permissionPointUpdate$.asObservable()),T(this,`_showComponents`,!0)}setShowComponents(e){this._showComponents=e}getShowComponents(){return this._showComponents}deletePermissionPoint(e){let t=this._permissionPointMap.get(e);t&&(t.complete(),this._permissionPointMap.delete(e))}addPermissionPoint(e){let n=e instanceof t.BehaviorSubject,r=n?e.getValue():e;return r.id?this._permissionPointMap.get(r.id)?(console.warn(`${r.id} PermissionPoint already exists`),!1):(this._permissionPointMap.set(r.id,n?e:new t.BehaviorSubject(r)),this._permissionPointUpdate$.next(r),!0):!1}updatePermissionPoint(e,t){let n=this._permissionPointMap.get(e);if(!n)return;let r=n.getValue();r.value=t,r.status=`done`,n.next(r),this._permissionPointUpdate$.next(r)}clearPermissionMap(){this._permissionPointMap.clear()}getPermissionPoint(e){let t=this._permissionPointMap.get(e);if(t)return t.getValue()}getPermissionPoint$(e){let t=this._permissionPointMap.get(e);if(t)return t}composePermission$(e){let n=e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.asObservable()});return(0,t.combineLatest)(n).pipe((0,r.map)(e=>e))}composePermission(e){return e.map(e=>{var t;let n=(t=this._permissionPointMap)==null?void 0:t.get(e);if(!n)throw Error(`[PermissionService]: ${e} permissionPoint does not exist!`);return n.getValue()})}getAllPermissionPoint(){let e=/* @__PURE__ */ new Map;return this._permissionPointMap.forEach((t,n)=>{e.set(n,t)}),e}};function RS(e,t){if(!t)return e;let n=[];for(let r of e){let e=t.find(([e])=>e===r[0]);if(e){if(e[1]===null)continue;n.push([r[0],e[1]])}else n.push(r)}return n}let zS=Symbol(`DependentOn`);var BS=class extends k{onStarting(){}onReady(){}onRendered(){}onSteady(){}getUnitType(){return this.constructor.type}getPluginName(){return this.constructor.pluginName}};T(BS,`pluginName`,void 0),T(BS,`packageName`,Re),T(BS,`version`,ze),T(BS,`type`,n.UniverType.UNIVER_UNKNOWN);var VS=class{constructor(){T(this,`_plugins`,[])}addPlugin(e){this._plugins.push(e)}removePlugins(){let e=this._plugins.slice();return this._plugins.length=0,e}forEachPlugin(e){this._plugins.forEach(e)}};function HS(...e){return function(t){t[zS]=e}}let US=class{constructor(e,t,r){this._injector=e,this._lifecycleService=t,this._logService=r,T(this,`_pluginRegistry`,/* @__PURE__ */ new Map),T(this,`_pluginStore`,new VS),T(this,`_seenPlugins`,/* @__PURE__ */ new Set),T(this,`_loadedPlugins`,/* @__PURE__ */ new Set),T(this,`_loadedPluginTypes`,/* @__PURE__ */ new Set([n.UniverType.UNIVER_UNKNOWN])),T(this,`_flushTimerByType`,/* @__PURE__ */ new Map)}dispose(){this._pluginStore.removePlugins().forEach(e=>e.dispose()),this._flushTimerByType.forEach(e=>clearTimeout(e))}registerPlugin(e,t){this._assertPluginValid(e);let r={plugin:e,options:t};this._pluginRegistry.set(e.pluginName,r),this._logService.debug(`[PluginService]`,`Plugin "${e.pluginName}" registered.`);let{type:i}=e;this._loadedPluginTypes.has(i)&&(i===n.UniverType.UNIVER_UNKNOWN?this._loadFromPlugins([r]):this._flushType(i))}startPluginsForType(e){this._loadedPluginTypes.has(e)||this._loadPluginsForType(e)}_loadPluginsForType(e){let t=Array.from(this._pluginRegistry.keys()),n=[];t.forEach(t=>{let r=this._pluginRegistry.get(t);r.plugin.type===e&&n.push(r)}),this._loadFromPlugins(n),this._loadedPluginTypes.add(e)}_assertPluginValid(e){let{type:t,pluginName:r,packageName:i,version:a}=e;if(t===n.UniverType.UNRECOGNIZED)throw Error(`[PluginService]: invalid plugin type for ${e.name}. Please assign a "type" to your plugin.`);if(!r)throw Error(`[PluginService]: no plugin name for ${e.name}. Please assign a "pluginName" to your plugin.`);if(a&&a!==BS.version&&this._logService.error(`[PluginService]`,[`Plugin version mismatch.`,` plugin: "${r||e.name}"`,` package: "${i}"`,` plugin version: "${a}"`,` core version: "${BS.version}"`,` registration will continue, but please make sure all @univerjs packages use the same version.`].join(`
|
|
25
|
+
`)),this._seenPlugins.has(r))throw Error(`[PluginService]: duplicated plugin name for "${r}". Maybe a plugin that dependents on "${r} has already registered it. In that case please register "${r}" before the that plugin.`);this._seenPlugins.add(e.pluginName)}_flushType(e){this._flushTimerByType.get(e)===void 0&&this._flushTimerByType.set(e,setTimeout(()=>{this._loadPluginsForType(e),this._flushTimerByType.delete(e)},4))}_loadFromPlugins(e){let t=[],r=/* @__PURE__ */ new Set,i=e=>{let{plugin:a}=e,{pluginName:o}=a;if(this._loadedPlugins.has(o)||r.has(o))return;r.add(o),this._pluginRegistry.delete(o);let s=a[zS];s&&s.forEach(e=>{let t=this._pluginRegistry.get(e.pluginName);if(t)i(t);else if(!this._seenPlugins.has(e.pluginName)&&!r.has(e.pluginName)){if(a.type===n.UniverType.UNIVER_UNKNOWN&&e.type!==n.UniverType.UNIVER_UNKNOWN)throw Error(`[PluginService]: cannot register a plugin with Univer type that depends on a plugin with other type. The dependent is ${a.pluginName} and the dependency is ${e.pluginName}.`);a.type!==e.type&&e.type!==n.UniverType.UNIVER_UNKNOWN&&this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which has different type.`),this._logService.debug(`[PluginService]`,`Plugin "${o}" depends on "${e.pluginName}" which is not registered. Univer will automatically register it with default configuration.`),this._assertPluginValid(e),i({plugin:e,options:void 0})}}),t.push(e)};e.forEach(e=>i(e));let a=t.map(e=>this._initPlugin(e.plugin,e.options));this._pluginsRunLifecycle(a)}_pluginsRunLifecycle(e){let n=this._lifecycleService.stage;if(vS(n).subscribe(t=>this._runStage(e,t)),n!==3){let n=this._lifecycleService.lifecycle$.pipe((0,t.skip)(1)).subscribe(t=>{this._runStage(e,t),t===3&&n.unsubscribe()})}}_runStage(e,t){e.forEach(e=>{switch(t){case 0:e.onStarting();break;case 1:e.onReady();break;case 2:e.onRendered();break;case 3:e.onSteady()}})}_initPlugin(e,t){let n=this._injector.createInstance(e,t);return this._pluginStore.addPlugin(n),this._loadedPlugins.add(e.pluginName),this._logService.debug(`[PluginService]`,`Plugin "${n.getPluginName()}" loaded.`),n}};US=ma([V(0,(0,i.Inject)(i.Injector)),V(1,(0,i.Inject)(_S)),V(2,da)],US);let WS=class extends k{constructor(e){super(),this._localeService=e,T(this,`_currentRegion$`,void 0),T(this,`currentRegion$`,void 0),T(this,`_hasExplicitRegion`,!1),this._currentRegion$=new t.BehaviorSubject(this._localeService.getCurrentLocale()),this.currentRegion$=this._currentRegion$.asObservable(),this.disposeWithMe(this._localeService.currentLocale$.subscribe(e=>{!this._hasExplicitRegion&&e!==this._currentRegion$.value&&this._currentRegion$.next(e)})),this.disposeWithMe(D(()=>this._currentRegion$.complete()))}setRegion(e){this._hasExplicitRegion=!0,this._currentRegion$.next(e)}getCurrentRegion(){return this._currentRegion$.value}};WS=ma([V(0,(0,i.Inject)(SS))],WS);let GS=(0,i.createIdentifier)(`resource-loader-service`),KS=class extends k{constructor(e){super(),this._logService=e,T(this,`_resourceMap`,/* @__PURE__ */ new Map),T(this,`_register$`,new t.Subject),T(this,`register$`,this._register$.asObservable())}getAllResourceHooks(){return[...this._resourceMap.values()]}getResources(e,t){return t?this.getResourcesByType(e,t):this.getAllResourceHooks().map(t=>{let n=t.toJson(e);return{name:t.pluginName,data:n}})}getResourcesByType(e,t){let n=this.getAllResourceHooks(),r=[];for(let i=0;i<n.length;i++){let a=n[i];if(!a.businesses.includes(t))continue;let o=a.toJson(e);r.push({name:a.pluginName,data:o})}return r}registerPluginResource(e){let t=e.pluginName;if(this._resourceMap.has(t))throw Error(`the pluginName is registered {${t}}`);return this._resourceMap.set(t,e),this._register$.next(e),D(()=>this._resourceMap.delete(t))}disposePluginResource(e){this._resourceMap.delete(e)}loadResources(e,t){let n=this.getAllResourceHooks();for(let i=0;i<n.length;i++){var r;let a=n[i],o=t==null||(r=t.find(e=>e.name===a.pluginName))==null?void 0:r.data;if(o)try{let t=a.parseJson(o);a.onLoad(e,t)}catch(e){this._logService.error(`[ResourceManagerService]`,`loadResources error`,e)}}}unloadResources(e,t){let n=this.getAllResourceHooks();for(let r=0;r<n.length;r++){let i=n[r];i.businesses.includes(t)&&i.onUnLoad(e)}}dispose(){this._register$.complete(),this._resourceMap.clear()}};KS=ma([V(0,da)],KS);var qS=class extends k{get darkMode(){return this._darkMode$.getValue()}constructor(){super(),T(this,`_darkMode$`,new t.BehaviorSubject(!1)),T(this,`darkMode$`,this._darkMode$.asObservable()),T(this,`_validColorCache`,/* @__PURE__ */ new Map),T(this,`_currentTheme`,a.defaultTheme),T(this,`_currentTheme$`,new t.BehaviorSubject(this._currentTheme)),T(this,`currentTheme$`,this._currentTheme$.asObservable()),this.disposeWithMe(D(()=>{this._currentTheme=a.defaultTheme,this._currentTheme$.complete(),this._darkMode$.complete()}))}isValidThemeColor(e){if(this._validColorCache.has(e))return this._validColorCache.get(e);let t=!1,n=e.split(`.`);if(n.length===1)t=e in a.defaultTheme;else if(n.length===2){let[e,r]=n;t=e in a.defaultTheme&&r in this._currentTheme[e]}return this._validColorCache.set(e,t),t}getCurrentTheme(){return this._currentTheme}setTheme(e){this._currentTheme=e,this._currentTheme$.next(e)}setDarkMode(e){this._darkMode$.next(e)}getColorFromTheme(e){return _i(this._currentTheme,e)}},JS=class{constructor(e,t=1e3){this._injector=e,T(this,`_imageCacheMap`,void 0),this._imageCacheMap=new Cd(t)}_getImageCacheKey(e,t){return`${e}-${t}`}getImage(e,t,n,r){let i=this._getImageCacheKey(e,t);return this._imageCacheMap.get(i)||((async()=>{let a=new Image,o=this._injector.has(Dx)?this._injector.get(Dx):null,s=this._injector.has(Ox)?this._injector.get(Ox):null;if(e===`UUID`)try{a.src=await(o==null?void 0:o.getImage(t))||``}catch(e){console.error(e)}else if(e===`URL`)try{a.src=await(s==null?void 0:s.getImage(t))||t}catch{a.src=t}else a.src=t;a.onload=()=>{a.removeAttribute(`data-error`),n==null||n()},a.onerror=()=>{a.setAttribute(`data-error`,`true`),r==null||r()},this._imageCacheMap.set(i,a)})(),null)}};function YS(e){return!(e.length===0||e.length>31||e.startsWith(`'`)||e.endsWith(`'`)||/[:\\\/\?\*\[\]]/.test(e))}function XS(e,t){return!(!e||e.length===0||e.length>255||t.has(e)||/[ :\\\/\?\*\[\]]/.test(e)||!/^[\p{L}_]/u.test(e)||/^\$?[A-Za-z]{1,3}\$?[0-9]+$/.test(e)||/^[rR]\d+[cC]\d+$/.test(e)||/^\d+$/.test(e))}let ZS=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],$=/* @__PURE__ */ new Uint32Array(96);var QS=class e{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw Error(`Data must be an instance of ArrayBuffer or SharedArrayBuffer.`);let[n,r]=new Uint8Array(t,0,2);if(n!==219)throw Error(`Data does not appear to be in a KDBush format.`);let i=r>>4;if(i!==1)throw Error(`Got v${i} data when expected v1.`);let a=ZS[r&15];if(!a)throw Error(`Unrecognized array type.`);let[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,o,a,void 0,t)}constructor(e,t=64,n=Float64Array,r=ArrayBuffer,i){if(isNaN(e)||e<0)throw Error(`Unexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;let a=ZS.indexOf(this.ArrayType),o=e*2*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(a<0)throw Error(`Unexpected typed array class: ${n}.`);if(i)this.data=i,this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=e*2,this._finished=!0;else{let i=this.data=new r(8+o+s+c);this.ids=new this.IndexArrayType(i,8,e),this.coords=new n(i,8+s+c,e*2),this._pos=0,this._finished=!1,new Uint8Array(i,0,2).set([219,16+a]),new Uint16Array(i,2,1)[0]=t,new Uint32Array(i,4,1)[0]=e}}add(e,t){let n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){let e=this._pos>>1;if(e!==this.numItems)throw Error(`Added ${e} items when expected ${this.numItems}.`);return $S(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=[];for(;s>0;){let l=$[--s],u=$[--s],d=$[--s];if(u-d<=o){for(let o=d;o<=u;o++){let s=a[2*o],l=a[2*o+1];s>=e&&s<=n&&l>=t&&l<=r&&c.push(i[o])}continue}let f=d+u>>1,p=a[2*f],m=a[2*f+1];p>=e&&p<=n&&m>=t&&m<=r&&c.push(i[f]),(l===0?e<=p:t<=m)&&($[s++]=d,$[s++]=f-1,$[s++]=1-l),(l===0?n>=p:r>=m)&&($[s++]=f+1,$[s++]=u,$[s++]=1-l)}return c}within(e,t,n){let r=[];return this.withinInto(e,t,n,r),r}withinInto(e,t,n,r){if(!this._finished)throw Error(`Data not yet indexed - call index.finish().`);let{ids:i,coords:a,nodeSize:o}=this;$[0]=0,$[1]=i.length-1,$[2]=0;let s=3,c=0,l=n*n;for(;s>0;){let u=$[--s],d=$[--s],f=$[--s];if(d-f<=o){for(let n=f;n<=d;n++)rC(a[2*n],a[2*n+1],e,t)<=l&&(r[c++]=i[n]);continue}let p=f+d>>1,m=a[2*p],h=a[2*p+1];rC(m,h,e,t)<=l&&(r[c++]=i[p]),(u===0?e-n<=m:t-n<=h)&&($[s++]=f,$[s++]=p-1,$[s++]=1-u),(u===0?e+n>=m:t+n>=h)&&($[s++]=p+1,$[s++]=d,$[s++]=1-u)}return c}};function $S(e,t,n,r,i,a){if(i-r<=n)return;let o=r+i>>1;eC(e,t,o,r,i,a),$S(e,t,n,r,o-1,1-a),$S(e,t,n,o+1,i,1-a)}function eC(e,t,n,r,i,a){for(;i>r;){if(i-r>600){let o=i-r+1,s=n-r+1,c=Math.log(o),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(o-l)/o)*(s-o/2<0?-1:1);eC(e,t,n,Math.max(r,Math.floor(n-s*l/o+u)),Math.min(i,Math.floor(n+(o-s)*l/o+u)),a)}let o=t[2*n+a],s=r,c=i;for(tC(e,t,r,n),t[2*i+a]>o&&tC(e,t,r,i);s<c;){for(tC(e,t,s,c),s++,c--;t[2*s+a]<o;)s++;for(;t[2*c+a]>o;)c--}t[2*r+a]===o?tC(e,t,r,c):(c++,tC(e,t,c,i)),c<=n&&(r=c+1),n<=c&&(i=c-1)}}function tC(e,t,n,r){nC(e,n,r),nC(t,2*n,2*r),nC(t,2*n+1,2*r+1)}function nC(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function rC(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}var iC=class{constructor(e=!1){this._enableOneCellCache=e,T(this,`_tree`,/* @__PURE__ */ new Map),T(this,`_oneCellCache`,/* @__PURE__ */ new Map),T(this,`_kdTree`,/* @__PURE__ */ new Map)}dispose(){this.clear()}getTree(e,t){return this._tree.has(e)||this._tree.set(e,/* @__PURE__ */ new Map),this._tree.get(e).has(t)||this._tree.get(e).set(t,new Nd),this._tree.get(e).get(t)}_getOneCellCache(e,t,n,r){return this._oneCellCache.has(e)||this._oneCellCache.set(e,/* @__PURE__ */ new Map),this._oneCellCache.get(e).has(t)||this._oneCellCache.get(e).set(t,/* @__PURE__ */ new Map),this._oneCellCache.get(e).get(t).has(n)||this._oneCellCache.get(e).get(t).set(n,/* @__PURE__ */ new Map),this._oneCellCache.get(e).get(t).get(n).has(r)||this._oneCellCache.get(e).get(t).get(n).set(r,/* @__PURE__ */ new Set),this._oneCellCache.get(e).get(t).get(n).get(r)}_removeOneCellCache(e,t,n,r,i){let a=this._oneCellCache.get(e);if(!a)return;let o=a.get(t);if(!o)return;let s=o.get(n);if(!s)return;let c=s.get(r);c&&c.delete(i)}_removeCellCacheByRange(e){let{unitId:t,sheetId:n,range:r,id:i}=e,a=this._oneCellCache.get(t);if(!a)return;let o=a.get(n);if(!o)return;let{startRow:s,startColumn:c,endRow:l,endColumn:u}=r;for(let e=s;e<=l;e++){let t=o.get(e);if(t)for(let e=c;e<=u;e++){let n=t.get(e);n&&n.delete(i)}}}_insertOneCellCache(e,t,n,r,i){this._getOneCellCache(e,t,n,r).add(i)}_getRdTreeItems(e){let t=[];for(let[n,r]of e)for(let[e,i]of r)t.push({x:e,y:n,ids:i});return t}_searchByOneCellCache(e){var t;let{unitId:n,sheetId:r,range:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=i,l=(t=this._kdTree.get(n))==null?void 0:t.get(r);if(!l)return[];let{tree:u,items:d}=l,f=u.range(o,a,c,s),p=[];for(let e of f){let t=d[e];p.push(...Array.from(t.ids))}return p}openKdTree(){for(let[t,n]of this._oneCellCache){this._kdTree.has(t)||this._kdTree.set(t,/* @__PURE__ */ new Map);for(let[r,i]of n){var e;let n=this._getRdTreeItems(i),a=new QS(n.length);(e=this._kdTree.get(t))==null||e.set(r,{tree:a,items:n});for(let e of n)a.add(e.x,e.y);a.finish()}}}closeKdTree(){for(let[t,n]of this._oneCellCache)for(let[r,i]of n){var e;(e=this._kdTree.get(t))==null||e.set(r,void 0)}}insert(e){let{unitId:t,sheetId:n,range:r,id:i}=e;if(!t||t.length===0)return;let{startRow:a,endRow:o,startColumn:s,endColumn:c}=r;if(this._enableOneCellCache&&a===o&&s===c){this._insertOneCellCache(t,n,a,s,i);return}let l=this.getTree(t,n);Number.isNaN(a)&&(a=0),Number.isNaN(s)&&(s=0),Number.isNaN(o)&&(o=1/0),Number.isNaN(c)&&(c=1/0),l.insert({minX:s,minY:a,maxX:c,maxY:o,id:i})}bulkInsert(e){for(let t of e)this.insert(t)}*searchGenerator(e){var t;let{unitId:n,sheetId:r,range:i}=e;if(this._enableOneCellCache){let t=this._searchByOneCellCache(e);for(let e of t)yield e}let a=(t=this._tree.get(n))==null?void 0:t.get(r);if(!a)return;let o=a.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e of o)yield e.id}bulkSearch(e,t){let n=/* @__PURE__ */ new Set;for(let r of e)for(let e of this.searchGenerator(r))(t==null?void 0:t.has(e))!==!0&&n.add(e);return n}removeById(e,t){if(t){var n,r;(n=this._tree.get(e))==null||n.delete(t),(r=this._oneCellCache.get(e))==null||r.delete(t)}else this._tree.delete(e),this._oneCellCache.delete(e)}_removeRTreeItem(e){var t;let{unitId:n,sheetId:r,range:i,id:a}=e,o=(t=this._tree.get(n))==null?void 0:t.get(r);if(!o)return;let s=o.search({minX:i.startColumn,minY:i.startRow,maxX:i.endColumn,maxY:i.endRow});for(let e=0;e<s.length;e++)s[e].id===a&&o.remove(s[e])}remove(e){let{unitId:t,sheetId:n,range:r,id:i}=e,{startRow:a,startColumn:o,endRow:s,endColumn:c}=r;this._enableOneCellCache?a===s&&o===c?this._removeOneCellCache(t,n,r.startRow,r.startColumn,i):(this._removeCellCacheByRange(e),this._removeRTreeItem(e)):this._removeRTreeItem(e)}bulkRemove(e){if(e.length<2){for(let t of e)this.remove(t);return}let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.unitId);e||(e=/* @__PURE__ */ new Map,t.set(n.unitId,e));let r=e.get(n.sheetId);r||(r=/* @__PURE__ */ new Map,e.set(n.sheetId,r));let i=r.get(n.id);i?i.push(n):r.set(n.id,[n])}for(let[e,n]of t)for(let[t,r]of n)this._removeSparseRanges(e,t,r)||this._bulkRemoveFromSheet(e,t,r)}_bulkRemoveFromSheet(e,t,n){var r,i;if(n.size===1){let[e]=n.values();if(e.length===1){this.remove(e[0]);return}}let a=(e,t,r=!1)=>{var i;return((i=n.get(e))==null?void 0:i.some(({range:e})=>(!r||!this._enableOneCellCache||e.startRow!==e.endRow||e.startColumn!==e.endColumn)&&e.startColumn<=t.maxX&&e.endColumn>=t.minX&&e.startRow<=t.maxY&&e.endRow>=t.minY))??!1},o=(r=this._tree.get(e))==null?void 0:r.get(t);if(o){let e=o.all(),t=0;for(let n of e)a(n.id,n,!0)||(e[t++]=n);t!==e.length&&(e.length=t,o.clear(),o.load(e))}let s=(i=this._oneCellCache.get(e))==null?void 0:i.get(t);if(s)for(let[e,t]of s)for(let[n,r]of t){let t={minX:n,maxX:n,minY:e,maxY:e};for(let e of r)a(e,t)&&r.delete(e)}}_removeSparseRanges(e,t,n){var r,i;let a=128;if(n.size>a)return!1;let o=(e,t)=>{if(--a<0||!e.leaf&&t.startColumn<=e.minX&&t.endColumn>=e.maxX&&t.startRow<=e.minY&&t.endRow>=e.maxY)return!1;for(let n of e.children)if(t.startColumn<=n.maxX&&t.endColumn>=n.minX&&t.startRow<=n.maxY&&t.endRow>=n.minY){if(e.leaf){if(--a<0)return!1}else if(!o(n,t))return!1}return!0},s=(r=this._tree.get(e))==null?void 0:r.get(t),c=s==null?void 0:s.toJSON(),l=(i=this._oneCellCache.get(e))==null?void 0:i.get(t);for(let[e,t]of n){if(Number.isNaN(e))return!1;for(let{range:e}of t){if(--a<0)return!1;if(this._enableOneCellCache){if(e.startRow===e.endRow&&e.startColumn===e.endColumn)continue;if(l)return!1}if(c&&!o(c,e))return!1}}for(let e of n.values())for(let t of e)this.remove(t);return!0}clear(){this._tree.clear(),this._oneCellCache.clear()}toJSON(){let e={};return this._tree.forEach((t,n)=>{e[n]={},t.forEach((t,r)=>{e[n][r]=t.toJSON()})}),e}fromJSON(e){this._tree.clear();for(let t in e){this._tree.set(t,/* @__PURE__ */ new Map);for(let n in e[t]){let r=new Nd;r.fromJSON(e[t][n]),this._tree.get(t).set(n,r)}}}};let aC=/* @__PURE__ */ function(e){return e.Blank=`blank`,e.String=`string`,e.Number=`number`,e.Date=`date`,e.Boolean=`boolean`,e.Error=`error`,e}({}),oC=/* @__PURE__ */ function(e){return e.All=`all`,e.Include=`include`,e.Exclude=`exclude`,e}({});function sC(e){let t=e;if(!cC(t)||typeof t.type!=`string`)throw TypeError(`Invalid record value.`);switch(t.type){case`blank`:if(`value`in t)throw TypeError(`Blank record values cannot have a value.`);return`["blank"]`;case`string`:case`error`:if(typeof t.value!=`string`)throw TypeError(`Invalid record value.`);return JSON.stringify([t.type,t.value]);case`boolean`:if(typeof t.value!=`boolean`)throw TypeError(`Invalid record value.`);return JSON.stringify([t.type,t.value]);case`number`:case`date`:if(typeof t.value!=`number`)throw TypeError(`Invalid record value.`);if(!Number.isFinite(t.value))throw RangeError(`Record numeric values must be finite.`);return JSON.stringify([t.type,t.value===0?0:t.value]);default:throw TypeError(`Unknown record value type.`)}}function cC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lC(e){return new Promise(t=>setTimeout(t,e))}function uC(e=1){return new Promise(t=>{let n=0,r=()=>{n++,n>=e?t():requestAnimationFrame(r)};requestAnimationFrame(r)})}let dC=9525;function fC(e){return Math.round(e*dC)}function pC(e){return e/dC}function mC(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e)){let t=e.length,n=Array(t);for(let r=0;r<t;r++)n[r]=mC(e[r]);return n}let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r];t[i]=mC(e[i])}return t}function hC(e){if(e==null)return e;let t={};return e.p!==void 0&&(t.p=e.p===null?null:mC(e.p)),e.s!==void 0&&(t.s=e.s===null||typeof e.s==`string`?e.s:mC(e.s)),e.v!==void 0&&(t.v=e.v),e.t!==void 0&&(t.t=e.t),e.f!==void 0&&(t.f=e.f),e.ft!==void 0&&(t.ft=e.ft),e.fd!==void 0&&(t.fd=e.fd),e.ref!==void 0&&(t.ref=e.ref),e.xf!==void 0&&(t.xf=e.xf),e.si!==void 0&&(t.si=e.si),e.custom!==void 0&&(t.custom=e.custom===null?null:mC(e.custom)),t}function gC(e){if(e==null)return e;let t=hC(e);return e.rowSpan!==void 0&&(t.rowSpan=e.rowSpan),e.colSpan!==void 0&&(t.colSpan=e.colSpan),e.displayV!==void 0&&(t.displayV=e.displayV),t}function _C(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={},c=Object.keys(o);for(let e=0,t=c.length;e<t;e++){let t=c[e],n=Number(t),r=o[n];r!=null&&(s[n]=hC(r))}t[a]=s}return t}function vC(e){let t={},n=Object.keys(e);for(let r=0,i=n.length;r<i;r++){let i=n[r],a=Number(i),o=e[a];if(o===void 0)continue;let s={};`h`in o&&o.h!==void 0&&(s.h=o.h),`ia`in o&&o.ia!==void 0&&(s.ia=o.ia),`ah`in o&&o.ah!==void 0&&(s.ah=o.ah),`hd`in o&&o.hd!==void 0&&(s.hd=o.hd),`w`in o&&o.w!==void 0&&(s.w=o.w),`s`in o&&o.s!==void 0&&(s.s=o.s===null||typeof o.s==`string`?o.s:mC(o.s)),`custom`in o&&o.custom!==void 0&&(s.custom=o.custom===null?null:mC(o.custom)),t[a]=s}return t}function yC(e){let t=e.length,n=Array(t);for(let r=0;r<t;r++){let t=e[r];n[r]={startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn,rangeType:t.rangeType,startAbsoluteRefType:t.startAbsoluteRefType,endAbsoluteRefType:t.endAbsoluteRefType}}return n}function bC(e){let t={id:e.id,...e.type===void 0?{}:{type:e.type},name:e.name,tabColor:e.tabColor,hidden:e.hidden,rowCount:e.rowCount,columnCount:e.columnCount,zoomRatio:e.zoomRatio,...e.zoomToFit===void 0?{}:{zoomToFit:e.zoomToFit},scrollTop:e.scrollTop,scrollLeft:e.scrollLeft,defaultColumnWidth:e.defaultColumnWidth,defaultRowHeight:e.defaultRowHeight,showGridlines:e.showGridlines,rightToLeft:e.rightToLeft,backgroundImage:e.backgroundImage?{source:e.backgroundImage.source,imageSourceType:e.backgroundImage.imageSourceType,scaleX:e.backgroundImage.scaleX,scaleY:e.backgroundImage.scaleY}:void 0,freeze:{xSplit:e.freeze.xSplit,ySplit:e.freeze.ySplit,startRow:e.freeze.startRow,startColumn:e.freeze.startColumn},rowHeader:{width:e.rowHeader.width,hidden:e.rowHeader.hidden},columnHeader:{height:e.columnHeader.height,hidden:e.columnHeader.hidden},mergeData:yC(e.mergeData),cellData:_C(e.cellData),rowData:vC(e.rowData),columnData:vC(e.columnData)};return e.gridlinesColor!==void 0&&(t.gridlinesColor=e.gridlinesColor),e.defaultStyle!==void 0&&(t.defaultStyle=e.defaultStyle===null||typeof e.defaultStyle==`string`?e.defaultStyle:mC(e.defaultStyle)),e.custom!==void 0&&(t.custom=e.custom===null?null:mC(e.custom)),t}let xC=class extends k{constructor(e){super(),this._localeService=e,T(this,`_fontLocale`,void 0),T(this,`_dirty`,!0),this._localeInitial()}get dirty(){return this._dirty}getFontLocale(){return this._fontLocale}makeDirty(e){this._dirty=e}dispose(){super.dispose(),this._fontLocale=null}_localeInitial(){}};xC=ma([V(0,(0,i.Inject)(SS))],xC);function SC(e={}){let t={defaultBackgroundColor:`rgba(24, 119, 242, 0.08)`,defaultStripeColor:`rgba(24, 119, 242, 0.25)`,rowGaps:{1:{size:6},3:{size:10,color:`rgba(245, 158, 11, 0.14)`},6:{size:14,color:`rgba(16, 185, 129, 0.12)`,stripeColor:`rgba(5, 150, 105, 0.35)`}},colGaps:{1:{size:5},2:{size:8,stripeColor:`rgba(59, 130, 246, 0.35)`},4:{size:12,color:`rgba(244, 63, 94, 0.12)`,stripeColor:`rgba(225, 29, 72, 0.30)`}}};return{...t,...e,rowGaps:{...t.rowGaps,...e.rowGaps},colGaps:{...t.colGaps,...e.colGaps}}}let CC=class extends xC{constructor(e,n,r,i,a,o){super(r),this.worksheet=e,this._styles=n,this._contextService=i,this._configService=a,this._injector=o,T(this,`_worksheetData`,void 0),T(this,`_renderRawFormula`,!1),T(this,`_cellData`,void 0),T(this,`_imageCacheMap`,void 0),T(this,`_skipAutoHeightForMergedCells`,!0),T(this,`_rowTotalHeight`,0),T(this,`_columnTotalWidth`,0),T(this,`_rowHeaderWidth`,0),T(this,`_columnHeaderHeight`,0),T(this,`_rowHeightAccumulation`,[]),T(this,`_columnWidthAccumulation`,[]),T(this,`_marginTop`,0),T(this,`_marginLeft`,0),T(this,`_gapConfig`,{}),T(this,`_scaleX`,1),T(this,`_scaleY`,1),T(this,`_scrollX`,0),T(this,`_scrollY`,0),T(this,`_gapConfigChanged$`,new t.Subject),T(this,`gapConfigChanged$`,this._gapConfigChanged$.asObservable()),this._worksheetData=this.worksheet.getConfig(),this._cellData=this.worksheet.getCellMatrix(),this._imageCacheMap=new JS(this._injector),this.initConfig()}initConfig(){this._skipAutoHeightForMergedCells=!(this._configService.getConfig(jp)??!1),this.worksheet.setIsRowStylePrecedeColumnStyle(this._configService.getConfig(`isRowStylePrecedeColumnStyle`)??!1)}resetCache(){}getLocation(){return[this.worksheet.getUnitId(),this.worksheet.getSheetId()]}set columnHeaderHeight(e){this._columnHeaderHeight=e,this._worksheetData.columnHeader.height=e}set rowHeaderWidth(e){this._rowHeaderWidth=e,this._worksheetData.rowHeader.width=e}get rowHeightAccumulation(){return this._rowHeightAccumulation}get rowTotalHeight(){return this._rowTotalHeight}get columnWidthAccumulation(){return this._columnWidthAccumulation}get columnTotalWidth(){return this._columnTotalWidth}get rowHeaderWidth(){return this._rowHeaderWidth}get columnHeaderHeight(){return this._columnHeaderHeight}setMarginLeft(e){this._marginLeft=e}setMarginTop(e){this._marginTop=e}setScale(e,t){this._updateLayout(),this._scaleX=e,this._scaleY=t||e,this._updateLayout()}setScroll(e,t){z.isDefine(e)&&(this._scrollX=e),z.isDefine(t)&&(this._scrollY=t)}get scrollX(){return this._scrollX}get scrollY(){return this._scrollY}get scaleX(){return this._scaleX}get scaleY(){return this._scaleY}get rowHeaderWidthAndMarginLeft(){return this.rowHeaderWidth+this._marginLeft}get columnHeaderHeightAndMarginTop(){return this.columnHeaderHeight+this._marginTop}get imageCacheMap(){return this._imageCacheMap}get gapConfig(){return this._gapConfig}setGapConfig(e){this._gapConfig=this._fillDefaultGapThemeColors(e),this.makeDirty(!0),this._updateLayout(),this._gapConfigChanged$.next()}_fillDefaultGapThemeColors(e){if(e.defaultBackgroundColor&&e.defaultStripeColor)return e;let{r:t,g:n,b:r}=new La(this._injector.get(qS).getColorFromTheme(`primary.500`)).toRgb();return{...e,defaultBackgroundColor:e.defaultBackgroundColor??`rgba(${t}, ${n}, ${r}, 0.025)`,defaultStripeColor:e.defaultStripeColor??`rgba(${t}, ${n}, ${r}, 0.08)`}}getRowGapSize(e){var t;return((t=this._gapConfig.rowGaps)==null||(t=t[e])==null?void 0:t.size)??0}getColGapSize(e){var t;return((t=this._gapConfig.colGaps)==null||(t=t[e])==null?void 0:t.size)??0}getGapSizeGetter(){if(this._gapConfig.rowGaps||this._gapConfig.colGaps)return{row:e=>this.getRowGapSize(e),col:e=>this.getColGapSize(e)}}getRowGapAtPosition(e){let{rowGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._rowHeightAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}getColGapAtPosition(e){let{colGaps:t}=this._gapConfig;if(!t)return-1;for(let r of Object.keys(t)){var n;let i=Number(r),a=((n=t[i])==null?void 0:n.size)??0;if(a<=0)continue;let o=this._columnWidthAccumulation[i-1]??0,s=o+a;if(e>=o&&e<s)return i}return-1}_generateRowMatrixCache(e,t,n){let r=0,i=[],a=Jx(n,24,!1),o=t;for(let t=0;t<e;t++){var s;let e=a;if(this.worksheet.getRowFiltered(t))e=0;else if(o[t]!=null){let n=o[t];if(!n)continue;let{h:r=a,ah:i,ia:s}=n;e=(s==null||s===1)&&qx(i,!1)?i:Jx(r,0),n.hd===1&&(e=0)}let n=((s=this._gapConfig.rowGaps)==null||(s=s[t])==null?void 0:s.size)??0;r+=n,r+=e,i.push(r)}return{rowTotalHeight:r,rowHeightAccumulation:i}}_generateColumnMatrixCache(e,t,n){let r=0,i=[],a=Jx(n,88,!1),o=t;for(let t=0;t<e;t++){var s;let e=a;if(o[t]!=null){let n=o[t];if(!n)continue;n.w!==void 0&&(e=Jx(n.w,0)),n.hd===1&&(e=0)}let n=((s=this._gapConfig.colGaps)==null||(s=s[t])==null?void 0:s.size)??0;r+=n,r+=e,i.push(r)}return{columnTotalWidth:r,columnWidthAccumulation:i}}intersectMergeRange(e,t){return!!this.worksheet.getMergedCell(e,t)}_getOverflowBound(e,t,n,r,i=1){let a=0,o=t>n?-1:1;for(let s=t;o===1?s<=n:s>=n;s+=o){if(!hu(this.worksheet.getCell(e,s))&&s!==t||this.intersectMergeRange(e,s))return s===t?s:z.clamp(s-o,0,this._columnWidthAccumulation.length-1);let{startX:n,endX:c}=TC(e,s,this.rowHeightAccumulation,this.columnWidthAccumulation,void 0,this.getGapSizeGetter());if(a+=i===2&&s===t?(c-n)/2:c-n,r<a)return s}return o===1?n:t}_updateLayout(){if(!this.dirty)return;let{rowData:e,columnData:t,defaultRowHeight:n,defaultColumnWidth:r,rowCount:i,columnCount:a,rowHeader:o,columnHeader:s}=this._worksheetData,{rowTotalHeight:c,rowHeightAccumulation:l}=this._generateRowMatrixCache(i,e,n),{columnTotalWidth:u,columnWidthAccumulation:d}=this._generateColumnMatrixCache(a,t,r);this._rowHeaderWidth=o.hidden===1?0:this._dynamicallyUpdateRowHeaderWidth(o),this._columnHeaderHeight=s.hidden===1?0:s.height,this._rowTotalHeight=c,this._rowHeightAccumulation=l,this._columnTotalWidth=u,this._columnWidthAccumulation=d,this.makeDirty(!1)}calculate(){return this.resetCache(),this._updateLayout(),this}resetRangeCache(e){}_dynamicallyUpdateRowHeaderWidth(e){let t=`${this.worksheet.getRowCount()}`.length*8;return Math.max(e.width,t)}_hasUnMergedCellInRow(e,t,n){if(!this.worksheet.getMergeData())return!1;for(let r=t;r<=n;r++){let{isMerged:t,isMergedMainCell:n}=this.worksheet.getCellInfoInMergeData(e,r);if(!t&&!n)return!0}return!1}expandRangeByMerge(e,t){let{startRow:n,startColumn:r,endRow:i,endColumn:a}=e,o=this._worksheetData.mergeData;if(!o)return{startRow:n,startColumn:r,endRow:i,endColumn:a};let s=!0,c=new du,l=0,u=null;for(;s;){s=!1;for(let e of o)c.getValue(e.startRow,e.startColumn)||tf({startColumn:r,startRow:n,endColumn:a,endRow:i},e)&&(n=Math.min(n,e.startRow),r=Math.min(r,e.startColumn),i=Math.max(i,e.endRow),a=Math.max(a,e.endColumn),c.setValue(e.startRow,e.startColumn,!0),s=!0,l++,u=e)}return t&&l===1&&Jd.contains(u,e)?{startRow:u.startRow,startColumn:u.startColumn,endRow:u.startRow,endColumn:u.startColumn}:{startRow:n,startColumn:r,endRow:i,endColumn:a}}getColumnCount(){return this._columnWidthAccumulation.length}getRowCount(){return this._rowHeightAccumulation.length}_getCellMergeInfo(e,t){return this.worksheet.getCellInfoInMergeData(e,t)}getNoMergeCellWithCoordByIndex(e,t,n=!0){let{rowHeightAccumulation:r,columnWidthAccumulation:i,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:o}=this,{startY:s,endY:c,startX:l,endX:u}=TC(e,t,r,i,void 0,this.getGapSizeGetter());return n&&(s+=o,c+=o,l+=a,u+=a),{startY:s,endY:c,startX:l,endX:u}}getRowIndexByOffsetY(e,t,n,r){let{rowHeightAccumulation:i}=this,a=DC(e,t,n,this.columnHeaderHeightAndMarginTop),o=Na(i,a,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(i[o]-a)<Math.abs(a-(i[o-1]??0))&&(o+=1),o}getColumnIndexByOffsetX(e,t,n,r){let i=EC(e,t,n,this.rowHeaderWidthAndMarginLeft),{columnWidthAccumulation:a}=this,o=Na(a,i,r==null?void 0:r.firstMatch);return r!=null&&r.closeFirst&&Math.abs(a[o]-i)<Math.abs(i-(a[o-1]??0))&&(o+=1),o}getCellIndexByOffset(e,t,n,r,i,a){return{row:this.getRowIndexByOffsetY(t,r,i,a),column:this.getColumnIndexByOffsetX(e,n,i,a)}}getCellByOffset(e,t,n,r,i){var a;let o=(a=this)==null?void 0:a.getCellIndexByOffset(e,t,n,r,i,{firstMatch:!0});return o?this.worksheet.getCellInfoInMergeData(o.row,o.column):null}getCellWithCoordByIndex(e,t,n=!0){var r;let{rowHeightAccumulation:i,columnWidthAccumulation:a,rowHeaderWidthAndMarginLeft:o,columnHeaderHeightAndMarginTop:s}=this,c=TC(e,t,i,a,(r=this.worksheet)==null?void 0:r.getCellInfoInMergeData(e,t),this.getGapSizeGetter()),{isMerged:l,isMergedMainCell:u}=c,{startY:d,endY:f,startX:p,endX:m,mergeInfo:h}=c,g=o,_=s;return n===!1&&(g=0,_=0),d+=_,f+=_,p+=g,m+=g,h.startY+=_,h.endY+=_,h.startX+=g,h.endX+=g,{actualRow:e,actualColumn:t,startX:p,startY:d,endX:m,endY:f,isMerged:l,isMergedMainCell:u,mergeInfo:h}}getCellWithCoordByOffset(e,t,n,r,i,a){let{row:o,column:s}=this.getCellIndexByOffset(e,t,n,r,i,a);return this.getCellWithCoordByIndex(o,s)}getOffsetByColumn(e){let{columnWidthAccumulation:t,rowHeaderWidthAndMarginLeft:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetByRow(e){let{rowHeightAccumulation:t,columnHeaderHeightAndMarginTop:n}=this,r=t.length-1,i=t[e];return i==null?e<0?n:t[r]+n:i+n}getOffsetRelativeToRowCol(e,t){let n=Na(this.columnWidthAccumulation,e),r=e-((this._columnWidthAccumulation[n-1]||0)+this.getColGapSize(n)),i=Na(this.rowHeightAccumulation,t);return{row:i,column:n,columnOffset:r,rowOffset:t-((this._rowHeightAccumulation[i-1]||0)+this.getRowGapSize(i))}}getCellIndexAndOffsetByPosition(e,t,n=this._scaleX,r=this._scaleY,i={x:this._scrollX,y:this._scrollY}){let{actualRow:a,actualColumn:o,startX:s,startY:c}=this.getCellWithCoordByOffset(e,t,n,r,i);return{row:a,rowOffset:t-c,column:o,columnOffset:e-s}}_updateConfigAndGetDocumentModel(e,t,n,r){var i;if(!r||!((i=e.body)!=null&&i.dataStream))return;e.documentStyle||={},e.documentStyle.marginTop=n.t??0,e.documentStyle.marginBottom=n.b??2,e.documentStyle.marginLeft=n.l??2,e.documentStyle.marginRight=n.r??2,e.documentStyle.pageSize={width:1/0,height:1/0},e.documentStyle.documentFlavor=0,e.documentStyle.paragraphLineGapDefault=0,e.documentStyle.renderConfig={...e.documentStyle.renderConfig,...r};let a=e.body.paragraphs||[];for(let e of a)e.paragraphStyle||={},e.paragraphStyle.horizontalAlign=t;return new Ey(e)}dispose(){super.dispose(),this._gapConfigChanged$.complete(),this._rowHeightAccumulation=[],this._columnWidthAccumulation=[],this._rowTotalHeight=0,this._columnTotalWidth=0,this._rowHeaderWidth=0,this._columnHeaderHeight=0,this._worksheetData=null,this._cellData=null,this._styles=null,this.worksheet=null}};CC=ma([V(2,(0,i.Inject)(SS)),V(3,ca),V(4,oa),V(5,(0,i.Inject)(i.Injector))],CC);function wC(e,t,n,r,i=0,a=0){let o=e-1,s=t-1,c=(n[o]||0)+i,l=n[e];l??=n[n.length-1];let u=(r[s]||0)+a,d=r[t];return d??=r[r.length-1],{startY:c,endY:l,startX:u,endX:d}}function TC(e,t,n,r,i,a){let o=z.clamp(e,0,n.length-1),s=z.clamp(t,0,r.length-1),c=wC(o,s,n,r,(a==null?void 0:a.row(o))??0,(a==null?void 0:a.col(s))??0),{isMerged:l,isMergedMainCell:u,startRow:d,startColumn:f,endRow:p,endColumn:m}=i??{isMerged:!1,isMergedMainCell:!1,startRow:o,startColumn:s,endRow:o,endColumn:s},h={...c,startRow:d,startColumn:f,endRow:p,endColumn:m};if(l?d!==-1&&f!==-1:p!==-1&&m!==-1){if(l){let e=(a==null?void 0:a.row(d))??0,t=(a==null?void 0:a.col(f))??0;h.startY=(n[d-1]??0)+e,h.startX=(r[f-1]??0)+t}h.endY=n[p]??n[n.length-1],h.endX=r[m]??r[r.length-1]}return{...c,isMerged:l,isMergedMainCell:u,actualRow:o,actualColumn:s,mergeInfo:h}}function EC(e,t,n,r){let{x:i}=n;return e/t+i-r}function DC(e,t,n,r){let{y:i}=n;return e/t+i-r}let OC=[`script`,`style`,`meta`,`comment`,`link`],kC=/* @__PURE__ */ function(e){return e[e.INFO=0]=`INFO`,e[e.STOP=1]=`STOP`,e[e.WARNING=2]=`WARNING`,e}({}),AC=/* @__PURE__ */ function(e){return e[e.DISABLED=0]=`DISABLED`,e[e.FULL_ALPHA=1]=`FULL_ALPHA`,e[e.FULL_HANGUL=2]=`FULL_HANGUL`,e[e.FULL_KATAKANA=3]=`FULL_KATAKANA`,e[e.HALF_ALPHA=4]=`HALF_ALPHA`,e[e.HALF_HANGUL=5]=`HALF_HANGUL`,e[e.HALF_KATAKANA=6]=`HALF_KATAKANA`,e[e.HIRAGANA=7]=`HIRAGANA`,e[e.NO_CONTROL=8]=`NO_CONTROL`,e[e.OFF=9]=`OFF`,e[e.ON=10]=`ON`,e}({}),jC=/* @__PURE__ */ function(e){return e.BETWEEN=`between`,e.EQUAL=`equal`,e.GREATER_THAN=`greaterThan`,e.GREATER_THAN_OR_EQUAL=`greaterThanOrEqual`,e.LESS_THAN=`lessThan`,e.LESS_THAN_OR_EQUAL=`lessThanOrEqual`,e.NOT_BETWEEN=`notBetween`,e.NOT_EQUAL=`notEqual`,e}({}),MC=/* @__PURE__ */ function(e){return e[e.TEXT=0]=`TEXT`,e[e.ARROW=1]=`ARROW`,e[e.CUSTOM=2]=`CUSTOM`,e}({}),NC=/* @__PURE__ */ function(e){return e.VALID=`valid`,e.INVALID=`invalid`,e.VALIDATING=`validating`,e}({}),PC=/* @__PURE__ */ function(e){return e.CUSTOM=`custom`,e.LIST=`list`,e.LIST_MULTIPLE=`listMultiple`,e.NONE=`none`,e.TEXT_LENGTH=`textLength`,e.DATE=`date`,e.TIME=`time`,e.WHOLE=`whole`,e.DECIMAL=`decimal`,e.CHECKBOX=`checkbox`,e.ANY=`any`,e}({}),FC=class extends k{constructor(e,t){super(),this._resourceManagerService=e,this._univerInstanceService=t,this._init()}_init(){let e=(e,t,n=[],r)=>{let i=n.find(t=>t.name===e.pluginName);if(i)try{let n=e.parseJson(i.data);e.onLoad(t,n)}catch{console.error(`Load ${r}{${t}} Resources{${e.pluginName}} Data Error.`)}},t=t=>{t.businesses.forEach(r=>{switch(r){case n.UniverType.UNRECOGNIZED:case n.UniverType.UNIVER_UNKNOWN:case n.UniverType.UNIVER_DOC:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_DOC).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Document`)});break;case n.UniverType.UNIVER_SLIDE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SLIDE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Slide`)});break;case n.UniverType.UNIVER_BOARD:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BOARD).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Board`)});break;case n.UniverType.UNIVER_SHEET:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_SHEET).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Workbook`)});break;case n.UniverType.UNIVER_BASE:this._univerInstanceService.getAllUnitsForType(n.UniverType.UNIVER_BASE).forEach(n=>{e(t,n.getUnitId(),n.getSnapshot().resources,`Base`)})}})};this._resourceManagerService.getAllResourceHooks().forEach(e=>t(e)),this.disposeWithMe(this._resourceManagerService.register$.subscribe(e=>t(e))),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SHEET).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_DOC).subscribe(e=>{let{unit:t}=e;Pp(t.getUnitId())||this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BOARD).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(n.UniverType.UNIVER_BASE).subscribe(e=>{let{unit:t}=e;this._resourceManagerService.loadResources(t.getUnitId(),t.getSnapshot().resources)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SHEET).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SHEET)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_DOC).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_DOC)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BASE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BASE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_SLIDE).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_SLIDE)})),this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(n.UniverType.UNIVER_BOARD).subscribe(e=>{this._resourceManagerService.unloadResources(e.getUnitId(),n.UniverType.UNIVER_BOARD)}))}saveUnit(e){let t=this._univerInstanceService.getUnit(e);if(!t)return null;let n=this._resourceManagerService.getResources(e,t.type),r=z.deepClone(t.getSnapshot());return r.resources=n,r}};FC=ma([V(0,(0,i.Inject)(sx)),V(1,(0,i.Inject)(fS))],FC);var IC=class{get _univerInstanceService(){return this._injector.get(fS)}get _pluginService(){return this._injector.get(US)}constructor(e={},t){T(this,`_startedTypes`,/* @__PURE__ */ new Set),T(this,`_injector`,void 0),T(this,`_disposingCallbacks`,new O);let n=this._injector=LC(t,e==null?void 0:e.override),{theme:r,darkMode:i,locale:a,region:o,locales:s,direction:c,logLevel:l,logCommandExecution:u,undoRedoHistoryLimit:d}=e,f=this._injector.get(oa);r&&this._injector.get(qS).setTheme(r),i&&this._injector.get(qS).setDarkMode(i),s&&this._injector.get(SS).load(s),a&&this._injector.get(SS).setLocale(a),o&&this._injector.get(WS).setRegion(o),c&&this._injector.get(SS).setDirection(c),l&&this._injector.get(da).setLogLevel(l),u!==void 0&&f.setConfig(ha,u),f.setConfig(`undoRedo.historyLimit`,d??50),this._init(n)}__getInjector(){return this._injector}onDispose(e){let t=this._disposingCallbacks.add(D(e));return D(()=>t.dispose(!0))}dispose(){this._disposingCallbacks.dispose(),this._injector.dispose()}setLocale(e){this._injector.get(SS).setLocale(e)}setRegion(e){this._injector.get(WS).setRegion(e)}createUnit(e,t){return this._univerInstanceService.createUnit(e,t)}_init(e){this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_SHEET,dS),this._univerInstanceService.registerCtorForType(n.UniverType.UNIVER_DOC,Ey);let t=e.get(fS);t.__setCreateHandler((n,r,i,a)=>{let o=!this._startedTypes.has(n);o&&(this._pluginService.startPluginsForType(n),this._startedTypes.add(n));let s=t.__getCtorByType(n)??i;if(!s)throw Error(`[Univer]: No constructor registered for unit type ${n}.`);let c=e.createInstance(s,r);return t.__addUnit(c,a),o&&this._tryProgressToReady(),c})}_tryProgressToReady(){this._injector.get(_S).stage<1&&(this._injector.get(_S).stage=1)}registerPlugin(e,t){this._pluginService.registerPlugin(e,t)}registerPlugins(e){e.forEach(e=>{let[t,n]=e;this._pluginService.registerPlugin(t,n)})}};function LC(e,t){let n=RS([[wx],[SS],[WS],[qS],[_S],[US],[dx],[fS,{useClass:pS}],[PS,{useClass:LS}],[IS],[da,{useClass:fa,lazy:!0}],[_a,{useClass:ba}],[ES,{useClass:MS,lazy:!0}],[oa,{useClass:sa}],[ca,{useClass:la}],[sx,{useClass:KS,lazy:!0}],[GS,{useClass:FC,lazy:!0}],[px,{useClass:fx}],[wS,{useClass:CS,lazy:!0}]],t),r=e?e.createChild(n):new i.Injector(n);return Je(r,[[dx],[GS]]),r}x(),e.ABCToNumber=cf,e.AUTO_HEIGHT_FOR_MERGED_CELLS=jp,e.AbsoluteRefType=lo,e.ActionIterator=Rv,e.AlignTypeH=vh,e.AlignTypeV=yh,e.ArrangeTypeEnum=Ip,e.AsyncInterceptorManager=Yp,Object.defineProperty(e,"AsyncLock",{enumerable:!0,get:function(){return wp.default}}),Object.defineProperty(e,"AuthzIoLocalService",{enumerable:!0,get:function(){return fx}}),e.AutoFillSeries=se,e.BASE_RECORD_ID_FIELD_ID=Tf,e.BASE_RECORD_ID_FIELD_NAME=Ef,e.BORDER_KEYS=Oh,e.BORDER_STYLE_KEYS=Dh,e.BaseConditionalColorOperator=yf,e.BaseConditionalColorTarget=vf,e.BaseConditionalDateMode=bf,e.BaseDataModel=Pf,e.BaseFieldType=hf,e.BaseFilterConjunction=Sf,e.BaseFilterOperator=xf,e.BaseHierarchyInvalidReason=wf,e.BaseRecordLinkRole=gf,e.BaseSortDirection=Cf,e.BaseViewType=_f,e.BaselineOffset=Ne,e.BlockType=Km,e.BooleanNumber=Pe,e.BorderStyleTypes=ce,e.BorderType=le,e.BuildTextUtils=Z,e.BulletAlignment=Bm,e.COLORS=Ia,e.COLOR_STYLE_KEYS=Eh,e.COMMAND_LOG_EXECUTION_CONFIG_KEY=ha,e.CanceledError=Xe,e.CellModeEnum=mo,e.CellValueType=Fe,e.ColorKit=La,e.ColorType=ue,e.ColumnLayoutType=uh,e.ColumnResponsiveType=dh,e.ColumnSeparatorType=Xm,Object.defineProperty(e,"CommandService",{enumerable:!0,get:function(){return ba}}),e.CommandType=ga,e.CommonHideTypes=de,e.ConfigService=sa,e.ContextService=la,e.CopyPasteType=fe,e.CustomCommandExecutionError=Ye,e.CustomDecorationType=Gm,e.CustomRangeType=Um,e.DEFAULT_CELL=Fh,e.DEFAULT_DOC=Sy,e.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING=Rh,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE=0,e.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW=12,e.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=`__default_document_sub_component_id20231101__`,e.DEFAULT_EMPTY_DOCUMENT_VALUE=`\r
|
|
26
|
+
`,e.DEFAULT_NUMBER_FORMAT=`General`,e.DEFAULT_RANGE=Nh,e.DEFAULT_RANGE_ARRAY=Mh,e.DEFAULT_SELECTION=Ph,e.DEFAULT_STYLES=Y,e.DEFAULT_TEXT_FORMAT=`@@@`,e.DEFAULT_TEXT_FORMAT_EXCEL=`@`,e.DEFAULT_WORKSHEET_COLUMN_COUNT=20,e.DEFAULT_WORKSHEET_COLUMN_COUNT_KEY=`DEFAULT_WORKSHEET_COLUMN_COUNT`,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT=20,e.DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT_KEY=`DEFAULT_WORKSHEET_COLUMN_TITLE_HEIGHT`,e.DEFAULT_WORKSHEET_COLUMN_WIDTH=88,e.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY=`DEFAULT_WORKSHEET_COLUMN_WIDTH`,e.DEFAULT_WORKSHEET_ROW_COUNT=Zx,e.DEFAULT_WORKSHEET_ROW_COUNT_KEY=`DEFAULT_WORKSHEET_ROW_COUNT`,e.DEFAULT_WORKSHEET_ROW_HEIGHT=24,e.DEFAULT_WORKSHEET_ROW_HEIGHT_KEY=`DEFAULT_WORKSHEET_ROW_HEIGHT`,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH=46,e.DEFAULT_WORKSHEET_ROW_TITLE_WIDTH_KEY=`DEFAULT_WORKSHEET_ROW_TITLE_WIDTH`,e.DOCS_COMMENT_EDITOR_UNIT_ID_KEY=Ap,e.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY=kp,e.DOCS_NORMAL_EDITOR_UNIT_ID_KEY=Op,e.DOC_DRAWING_PRINTING_COMPONENT_KEY=`univer-docs-drawing-printing`,e.DOC_RANGE_TYPE=po,e.DashStyleType=rh,e.DataStreamTreeNodeType=wm,e.DataStreamTreeTokenType=Tm,e.DataValidationErrorStyle=kC,e.DataValidationImeMode=AC,e.DataValidationOperator=jC,e.DataValidationRenderMode=MC,e.DataValidationStatus=NC,e.DataValidationType=PC,e.DateSystem=pe,e.DeleteDirection=me,e.DependentOn=HS,e.DesktopLogService=fa,e.DeveloperMetadataVisibility=he,e.Dimension=ge,e.Direction=_e,e.Disposable=k,e.DisposableCollection=O,e.DocStyleType=Lm,e.DocumentBlockRangeType=Hm,e.DocumentBlockType=Im,e.DocumentDataModel=Ey,e.DocumentFlavor=qm,e.DocxBreakType=Wm,e.DrawingTypeEnum=Lp,e.EDITOR_ACTIVATED=xx,e.EMU_PER_CSS_PX=dC,e.EXCEL_1904_OFFSET=Qs,e.EXTENSION_NAMES=Bh,e.ErrorService=wx,e.EventState=ix,e.EventSubject=ax,e.FOCUSING_BOARD=bx,e.FOCUSING_COMMENT_EDITOR=`FOCUSING_COMMENT_EDITOR`,e.FOCUSING_COMMON_DRAWINGS=`FOCUSING_COMMON_DRAWINGS`,e.FOCUSING_DOC=vx,e.FOCUSING_EDITOR_INPUT_FORMULA=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_EDITOR_STANDALONE=`FOCUSING_EDITOR_INPUT_FORMULA`,e.FOCUSING_FX_BAR_EDITOR=Sx,e.FOCUSING_PANEL_EDITOR=`FOCUSING_PANEL_EDITOR`,e.FOCUSING_SHAPE_TEXT_EDITOR=Cx,e.FOCUSING_SHEET=_x,e.FOCUSING_SLIDE=yx,e.FOCUSING_UNIT=gx,e.FOCUSING_UNIVER_EDITOR=`FOCUSING_UNIVER_EDITOR`,e.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE=`FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE`,e.FORMULA_EDITOR_ACTIVATED=`FORMULA_EDITOR_ACTIVATED`,e.FilterSelectionMode=oC,e.FollowNumberWithType=Rm,e.FontItalic=je,e.FontStyleType=mh,e.FontWeight=Me,e.FormulaType=ro,e.GridType=Jm,e.HorizontalAlign=Oe,e.IAuthzIoService=px,e.ICommandService=_a,e.IConfigService=oa,e.IConfirmService=mx,e.IContextService=ca,e.IImageIoService=Dx,e.ILocalStorageService=yS,e.ILogService=da,e.IMentionIOService=wS,e.IPermissionService=PS,e.IResourceLoaderService=GS,e.IResourceManagerService=sx,e.IS_ROW_STYLE_PRECEDE_COLUMN_STYLE=`isRowStylePrecedeColumnStyle`,e.IURLImageService=Ox,e.IUndoRedoService=ES,e.IUniverInstanceService=fS,e.ImageCacheMap=JS,e.ImageSourceType=Tx,e.ImageUploadStatusType=Ex,Object.defineProperty(e,"Inject",{enumerable:!0,get:function(){return i.Inject}}),Object.defineProperty(e,"InjectSelf",{enumerable:!0,get:function(){return i.InjectSelf}}),Object.defineProperty(e,"Injector",{enumerable:!0,get:function(){return i.Injector}}),e.InterceptorEffectEnum=Up,e.InterceptorManager=Kp,e.InterpolationPointType=ye,Object.defineProperty(e,"JSON1",{enumerable:!0,get:function(){return sg}}),e.JSONX=_y,e.LOCALE_META=xe,e.LRUHelper=wd,e.LRUMap=Cd,Object.defineProperty(e,"LifecycleService",{enumerable:!0,get:function(){return _S}}),e.LifecycleStages=mS,e.LifecycleUnreachableError=gS,e.ListGlyphType=zm,Object.defineProperty(e,"LocalUndoRedoService",{enumerable:!0,get:function(){return MS}}),e.LocaleService=SS,e.LocaleType=be,e.LogLevel=ua,Object.defineProperty(e,"LookUp",{enumerable:!0,get:function(){return i.LookUp}}),e.MAX_COLUMN_COUNT=16384,e.MAX_ITERATION_COUNT=32767,e.MAX_ROW_COUNT=1048576,e.MODERN_DOCUMENT_DEFAULT_MARGIN=66.66666666666667,e.MODERN_DOCUMENT_WIDTH=Uh,e.MOVE_BUFFER_VALUE=2,Object.defineProperty(e,"Many",{enumerable:!0,get:function(){return i.Many}}),e.MemoryCursor=dm,Object.defineProperty(e,"MentionIOLocalService",{enumerable:!0,get:function(){return CS}}),e.MentionType=Se,e.ModernDocumentWidthMode=Hh,e.NAMED_STYLE_MAP=Lh,e.NAMED_STYLE_SPACE_MAP=zh,e.NamedStyleType=th,e.NilCommand=ya,e.NumberUnitType=_h,e.OBJECT_PERMISSION_CONFIG_KEY=`objectPermissionTypes`,e.ObjectMatrix=du,e.ObjectPermissionRuleModel=TS,Object.defineProperty(e,"ObjectPermissionService",{enumerable:!0,get:function(){return IS}}),e.ObjectRelativeFromH=hh,e.ObjectRelativeFromV=gh,Object.defineProperty(e,"Optional",{enumerable:!0,get:function(){return i.Optional}}),e.PADDING_KEYS=Ah,e.PAGE_SIZE=Vh,e.PAPER_TYPES=Ch,e.PARAGRAPH_ID_PREFIX=Wh,e.PRESERVE_INSERTED_PARAGRAPH_IDS=cg,e.PRESET_LIST_TYPE=H_,e.PageOrientType=xh,e.PaperType=Sh,e.ParagraphElementType=Qm,e.ParagraphStyleBuilder=kb,e.ParagraphStyleValue=Ob,e.PermissionService=LS,e.PermissionStatus=NS,e.Plugin=BS,Object.defineProperty(e,"PluginService",{enumerable:!0,get:function(){return US}}),e.PositionedObjectLayoutType=eh,e.PresetListType=L_,e.ProtectionType=Ce,Object.defineProperty(e,"Quantity",{enumerable:!0,get:function(){return i.Quantity}}),e.QuickListType=I_,e.QuickListTypeMap=G_,e.RANGE_DIRECTION=fo,e.RANGE_TYPE=co,e.RBush=Nd,e.RCDisposable=j,e.RESTORE_INSERTED_PARAGRAPH_IDS=Dg,e.RGBA_PAREN=`rgba(`,e.RGB_PAREN=`rgb(`,e.ROTATE_BUFFER_VALUE=1,e.RTree=iC,e.Range=tS,e.RecordValueType=aC,e.Rectangle=Jd,Object.defineProperty(e,"RediError",{enumerable:!0,get:function(){return i.RediError}}),e.RedoCommand=jS,e.RedoCommandId=OS,e.RefAlias=of,Object.defineProperty(e,"RegionService",{enumerable:!0,get:function(){return WS}}),e.Registry=gm,e.RegistryAsMap=_m,e.RelativeDate=we,Object.defineProperty(e,"ResourceManagerService",{enumerable:!0,get:function(){return KS}}),e.RichTextBuilder=jb,e.RichTextParagraphBuilder=Mb,e.RichTextRunBuilder=Nb,e.RichTextValue=Ab,e.RxDisposable=A,e.SECTION_ID_PREFIX=bm,e.SHEET_EDITOR_UNITS=Ih,e.SHEET_TEXT_LINE_GAP=Mp,e.STYLE_KEYS=jh,e.SectionType=Ym,Object.defineProperty(e,"Self",{enumerable:!0,get:function(){return i.Self}}),Object.defineProperty(e,"SheetSkeleton",{enumerable:!0,get:function(){return CC}}),e.SheetTypes=Te,e.SheetViewModel=iS,Object.defineProperty(e,"Skeleton",{enumerable:!0,get:function(){return xC}}),Object.defineProperty(e,"SkipSelf",{enumerable:!0,get:function(){return i.SkipSelf}}),e.SliceBodyType=lv,e.SpacingRule=nh,e.SpecialCharacterKind=Vm,e.Styles=Mx,e.TEXT_DECORATION_KEYS=Th,e.TEXT_ROTATION_KEYS=kh,e.THEME_COLORS=ho,e.TRADITIONAL_DOCUMENT_DEFAULT_MARGIN=72,e.TabStopAlignment=ih,e.TabStopLeader=ah,e.TableAlignmentType=sh,e.TableLayoutType=ch,e.TableRowHeightRule=fh,e.TableSizeType=oh,e.TableTextWrapType=lh,e.TestConfirmService=hx,e.TextDecoration=De,e.TextDecorationBuilder=Db,e.TextDirection=Ee,e.TextDirectionType=Zm,e.TextStyleBuilder=Eb,e.TextStyleValue=Tb,e.TextX=X,e.TextXActionType=lg,e.ThemeColorType=Ie,e.ThemeColors=Le,e.ThemeService=qS,e.Tools=z,e.UndoCommand=AS,e.UndoCommandId=kS,e.UnitModel=M,e.Univer=IC,Object.defineProperty(e,"UniverInstanceService",{enumerable:!0,get:function(){return pS}}),Object.defineProperty(e,"UniverInstanceType",{enumerable:!0,get:function(){return n.UniverType}}),e.UpdateDocsAttributeType=to,e.UserManagerService=dx,e.VerticalAlign=ke,e.VerticalAlignmentType=ph,Object.defineProperty(e,"WithNew",{enumerable:!0,get:function(){return i.WithNew}}),Object.defineProperty(e,"Workbook",{enumerable:!0,get:function(){return dS}}),e.Worksheet=oS,e.WorksheetHiddenState=no,e.WrapStrategy=Ae,e.WrapTextType=$m,e.addLinkToDocumentModel=Bx,e.afterInitApply=ka,e.afterTime=Da,e.allocateBaseFormulaTableName=sp,e.assertBaseTableRecordIdentity=jf,e.awaitTime=lC,e.binSearchFirstGreaterThanTarget=Ma,e.binarySearchArray=ja,e.bufferDebounceTime=Ea,e.cellToRange=Eu,e.characterSpacingControlType=bh,e.checkForSubstrings=Mu,e.checkIfMove=Fa,e.checkParagraphHasBullet=ad,e.checkParagraphHasIndent=od,e.checkParagraphHasIndentByStyle=sd,e.cloneBodyWithFreshParagraphIds=Kh,e.cloneCellData=hC,e.cloneCellDataMatrix=_C,e.cloneCellDataWithSpanAndDisplay=gC,e.cloneParagraphWithId=qh,e.cloneSectionBreakWithId=Sm,e.cloneValue=mC,e.cloneWorksheetData=bC,e.codeToBlob=Pa,e.columnLabelToNumber=Td,e.composeBody=Nv,e.composeInterceptors=Gp,e.composeStyles=ae,e.concatMatrixArray=ou,e.containsInteriorInsertionOffset=bg,e.containsStreamIndex=yg,e.convertCellToRange=fu,e.convertObservableToBehaviorSubject=Oa,e.covertCellValue=Ou,e.covertCellValues=ku,e.createAsyncInterceptorKey=qp,e.createBaseFormulaTableNameMap=op,e.createBaseFormulaTableReferenceNormalizer=dp,e.createBaseRecordIdField=Of,e.createDefaultBaseTableSnapshot=Mf,e.createDefaultUser=lx,e.createDocumentModelWithStyle=Lx,Object.defineProperty(e,"createIdentifier",{enumerable:!0,get:function(){return i.createIdentifier}}),e.createInterceptorKey=Wp,e.createInternalEditorID=Np,e.createParagraphId=Gh,e.createRandomId=kd,e.createRowColIter=sf,e.createSectionId=xm,e.createSheetGapTestConfig=SC,e.cssPxToEmu=fC,e.currencySymbols=Ql,e.customNameCharacterCheck=XS,e.dateKit=rd,e.debounce=Ji,e.dedupe=Ve,e.dedupeBy=He,e.deepCompare=Au,e.delayAnimationFrame=uC,e.deleteContent=ld,e.emuToCssPx=pC,e.excelDateSerial=dc,e.excelDateTimePartsToSerial=lc,e.excelDateTimeSerial=fc,e.excelSerialToDate=sc,e.excelSerialToDateTime=cc,e.excelSerialToDateTimeParts=ac,e.extractPureTextFromCell=sS,Object.defineProperty(e,"forwardRef",{enumerable:!0,get:function(){return i.forwardRef}}),e.fromCallback=wa,e.fromEventSubject=ox,e.generateIntervalsByPoints=fd,e.generateRandomId=J,e.get=_i,e.getArrayLength=nu,e.getBaseFormulaTableName=lp,e.getBasesEmptySnapshot=Nf,e.getBlockRangeInterval=pg,e.getBodySlice=Cv,e.getBodySliceForSplitTextXAction=Tv,e.getBodySliceForTextXAction=wv,e.getBorderStyleType=Cu,e.getCellCoordByIndexSimple=wC,e.getCellValueType=ao,e.getCellWithCoordByIndexCore=TC,e.getColorStyle=gu,e.getColumnGroupRangeInterval=mg,e.getCurrencySymbolByLocale=xS,e.getCustomBlockIdsInSelections=ob,e.getCustomBlockInterval=gg,e.getCustomBlockSlice=vv,e.getCustomDecorationSlice=kv,e.getCustomRangeInterval=hg,e.getCustomRangeSlice=Ov,e.getDateSystemMaxSerial=ec,e.getDisplayValueFromCell=cS,e.getDocsEmptySnapshot=Zh,e.getDocsUpdateBody=wu,e.getDocumentParagraphStyleForUpdate=P_,e.getDrawingOrderIndex=zp,e.getEmptyCell=Hx,e.getExclusiveRangeInterval=dg,e.getInclusiveRangeInterval=ug,e.getIntersectRange=tf,e.getNumfmtLocaleTag=Jl,e.getNumfmtParseValueFilter=eu,e.getOriginCellValue=lS,e.getParagraphContentStartOffset=iv,e.getParagraphContentStartOffsets=av,e.getParagraphFollowingBlockOffset=ov,e.getParagraphsSlice=gv,e.getPlainText=yy,e.getRecordValueKey=sC,e.getReverseDirection=ve,e.getRichTextEditPath=Lv,e.getSdtBindingKey=nx,e.getSdtBindingValue=rx,e.getSectionBreakSlice=_v,e.getSectionHeaderFooterReferenceKey=$b,e.getSheetsEmptySnapshot=jx,e.getSingleDataStreamChange=fb,e.getTableCellTokenInterval=vg,e.getTableRangeInterval=fg,e.getTableRowTokenInterval=_g,e.getTableSlice=pv,e.getTextRunSlice=fv,e.getTransformOffsetX=EC,e.getTransformOffsetY=DC,e.getWorksheetUID=uS,e.groupBy=Ge,e.handleStyleToString=bu,e.hashAlgorithm=dd,e.horizontalLineSegmentsSubtraction=id,e.insertMatrixArray=iu,e.insertTextToContent=cd,e.intersectsOperationalIntervals=xg,e.invertColorByHSL=sm,e.invertColorByMatrix=um,Object.defineProperty(e,"isAsyncDependencyItem",{enumerable:!0,get:function(){return i.isAsyncDependencyItem}}),Object.defineProperty(e,"isAsyncHook",{enumerable:!0,get:function(){return i.isAsyncHook}}),e.isBaseRecordIdFieldName=Af,e.isBlackColor=$a,e.isBooleanString=Ep,e.isCellCoverable=hu,e.isCellV=so,Object.defineProperty(e,"isClassDependencyItem",{enumerable:!0,get:function(){return i.isClassDependencyItem}}),e.isCommentEditorID=Fp,Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return i.isCtor}}),e.isDefaultFormat=ql,Object.defineProperty(e,"isDisposable",{enumerable:!0,get:function(){return i.isDisposable}}),e.isEmptyCell=mu,Object.defineProperty(e,"isFactoryDependencyItem",{enumerable:!0,get:function(){return i.isFactoryDependencyItem}}),e.isFormulaId=vu,e.isFormulaString=_u,e.isICellData=io,e.isInternalEditorID=Pp,e.isNodeEnv=oe,e.isNotNullOrUndefined=Vx,e.isNullCell=oo,e.isNumeric=pm,e.isPatternEqualWithoutDecimal=Yl,e.isRangesEqual=Nx,e.isRealNum=ud,e.isSafeNumeric=mm,e.isSafeUrl=R,e.isSameStyleTextRun=ju,e.isTextFormat=Kl,e.isUnitRangesEqual=Px,e.isValidBaseRecordId=kf,e.isValidColumnDimensions=Yx,e.isValidRange=Tu,e.isValidRowDimensions=Xx,e.isValidSheetDimension=qx,Object.defineProperty(e,"isValueDependencyItem",{enumerable:!0,get:function(){return i.isValueDependencyItem}}),e.isWhiteColor=eo,e.makeArray=Ke,e.makeCellRangeToRangeData=pu,e.mapObjectMatrix=tu,e.merge=na,e.mergeIntervals=pd,e.mergeLocales=md,e.mergeOverrideWithDependencies=RS,e.mergeSets=ym,e.mergeWith=ta,e.mergeWorksheetSnapshotWithDefault=Qx,e.migrateBaseFormulaTableNames=fp,e.mixinClass=fm,e.moveMatrixArray=cu,e.moveRangeByOffset=Yd,e.nameCharacterCheck=YS,e.noop=Vp,e.normalizeBaseFormulaTableName=ap,e.normalizeBaseFormulaTableReferences=up,e.normalizeBody=Dv,e.normalizeDrawingOrderIndex=Rp,e.normalizeInsertedSectionIdsForDocument=Rg,e.normalizeTextRuns=Og,e.normalizeUrl=ee,e.normalizeWorkbookCalculationSettings=Ax,e.numberToABC=lf,e.numberToListABC=df,Object.defineProperty(e,"numfmt",{enumerable:!0,get:function(){return vl}}),e.regexp=Gl,e.registerDependencies=qe,e.remove=Be,e.repeatStringNumTimes=uf,e.replaceInDocumentBody=Dy,e.requestImmediateMacroTask=vm,e.resolveDocumentParagraphBullet=E_,e.resolveDocumentParagraphStyle=N_,e.resolveDocumentParagraphWordWrap=F_,e.resolveDocumentTextStyle=j_,e.resolveSectionHeaderFooterReference=ex,e.resolveSectionHeaderFooterReferences=tx,e.resolveWithBasePath=te,e.rotate=We,e.searchArray=Na,e.searchInOrderedArray=Aa,e.selectionToArray=uo,e.sequence=Qe,e.sequenceAsync=Ze,e.sequenceExecute=Sa,e.sequenceExecuteAsync=Ca,e.set=ia,Object.defineProperty(e,"setDependencies",{enumerable:!0,get:function(){return i.setDependencies}}),e.setTextDecorationLines=xu,e.setWith=aa,e.shallowEqual=Bp,e.shiftExclusiveRangeOnDelete=Tg,e.shiftExclusiveRangeOnInsert=Cg,e.shiftInclusiveRangeOnDelete=wg,e.shiftInclusiveRangeOnInsert=Sg,e.skipParseTagNames=OC,e.sliceMatrixArray=su,e.sortRules=ff,e.sortRulesByDesc=pf,e.sortRulesFactory=mf,e.spliceArray=au,e.splitIntoGrid=Zd,e.takeAfter=Ta,e.throttle=Hp,e.toDisposable=D,e.touchDependencies=Je,e.updateAttributeByDelete=zv,e.updateAttributeByInsert=Bv,e.validateDocBodyStructure=Xb,e.validateDocumentStructure=Qb,e.willLoseNumericPrecision=hm});
|