@omegagrid/bundle 0.10.46 → 0.10.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/omegagrid.js +7 -7
  2. package/package.json +18 -18
package/omegagrid.js CHANGED
@@ -2597,7 +2597,6 @@
2597
2597
  }
2598
2598
 
2599
2599
  .input > og-dropdown-list {
2600
- flex: 0 0 100px;
2601
2600
  height: 100%;
2602
2601
  border: 1px solid var(--og-accent-color);
2603
2602
  padding-right: 5px;
@@ -2700,7 +2699,7 @@
2700
2699
  ${e.name}
2701
2700
  </div>
2702
2701
  </div>
2703
- `;let fg=class extends En{get activeSection(){return this.sections?.[this.activeSectionIndex]}get inputValue(){return this.input?.value??""}get parsedInput(){const t=this.inputValue,e=t.split(" ",2);if(e.length>1){const i=(this.sections??[]).findIndex((t=>t?.triggerCommand==e[0]));return{section:i,value:i>-1?e[1]??"":t}}return{section:-1,value:t}}get filterValue(){return"search"==this.mode?this.parsedInput?.value??"":""}get commandRenderer(){return this.options?.commandRenderer||gg}get groupRenderer(){return this.options?.groupRenderer||mg}async exec(t=!0){const e=this.parsedInput,i=this.visibleItems[this.list.selectedIndex];i instanceof rg&&(this.clearFilter(!1),i.exec(e.value),this.adapter&&this.adapter.exec(i,e.value),t&&this.dispatchEvent(new pg("exec",{command:i,section:this.sections.find((t=>t.id===e.section)),value:e.value})))}constructor(){super(),this.options=cg(),this.mode="search",this.sectionPosition="right",this.placeholder="",this.showGroups=!1,this.model=new ng,this.sections=[{id:"default"}],this.activeSectionIndex=0,this.noResults=!1,this._onKeyDown=t=>{switch("Escape"!=t.key&&t.stopPropagation(),t.key){case"ArrowDown":t.preventDefault(),this.list.moveDown();break;case"ArrowUp":t.preventDefault(),this.list.moveUp();break;case"Enter":t.preventDefault(),this.visibleItems[this.list.selectedIndex]instanceof sg?this.toggleGroup(this.visibleItems[this.list.selectedIndex].id):this.exec()}},this._debounceInput=q((()=>{if("search"==this.mode){const t=this.parsedInput;t.section>-1?(this.activeSectionIndex=t.section,this.input.value="",this.updateCommands(!0)):this.updateCommands()}else if("none"==this.mode){const t=this.parsedInput,e=this.model.filter(t.value,!1);if(e.length>0){const t=this.visibleItems.findIndex((t=>t instanceof rg&&t.id===e[0].id));t>-1&&(this.list.selectedIndex=t,this.list.renderItems(!0))}}}),this.options.inputDelay),this._onInput=t=>{t.stopPropagation(),this._debounceInput()},this._onSectionSelect=async t=>{this.activeSectionIndex!=t.index&&(this.activeSectionIndex=t.index,this.updateCommands(!0),this.focus())},this._onDropdownChange=async t=>{this.activeSectionIndex=this.sections.findIndex((t=>t.id===this.dropdown.value)),this.updateCommands(!0),this.focus()},this._onSelect=t=>{const e=this.visibleItems[t.index];e instanceof rg?("search"==this.mode&&(this.input.value=e.name),t.trigger!=pp.Click&&t.trigger!=pp.Enter||this.exec()):(this.input.value="",t.trigger!=pp.Click&&t.trigger!=pp.Enter||this.toggleGroup(e.id)),setTimeout((()=>this.input.focus()))},this._itemRenderer=(t,e,i)=>this.visibleItems[e]instanceof sg?this.groupRenderer(t,this.visibleItems[e],i):this.commandRenderer(t,this.visibleItems[e],i),this._updateToken=0,this.renderTabs=()=>this.sections?.length>1?ln`
2702
+ `;let fg=class extends En{get activeSection(){return this.sections?.[this.activeSectionIndex]}get inputValue(){return this.input?.value??""}get parsedInput(){const t=this.inputValue,e=t.split(" ",2);if(e.length>1){const i=(this.sections??[]).findIndex((t=>t?.triggerCommand==e[0]));return{section:i,value:i>-1?e[1]??"":t}}return{section:-1,value:t}}get filterValue(){return"search"==this.mode?this.parsedInput?.value??"":""}get commandRenderer(){return this.options?.commandRenderer||gg}get groupRenderer(){return this.options?.groupRenderer||mg}async exec(t=!0){const e=this.parsedInput,i=this.visibleItems[this.list.selectedIndex];i instanceof rg&&(this.clearFilter(!1),i.exec(e.value),this.adapter&&this.adapter.exec(i,e.value),t&&this.dispatchEvent(new pg("exec",{command:i,section:this.sections.find((t=>t.id===e.section)),value:e.value})))}constructor(){super(),this.options=cg(),this.mode="search",this.sectionPosition="right",this.dropdownWidth=100,this.placeholder="",this.showGroups=!1,this.model=new ng,this.sections=[{id:"default"}],this.activeSectionIndex=0,this.noResults=!1,this._onKeyDown=t=>{switch("Escape"!=t.key&&t.stopPropagation(),t.key){case"ArrowDown":t.preventDefault(),this.list.moveDown();break;case"ArrowUp":t.preventDefault(),this.list.moveUp();break;case"Enter":t.preventDefault(),this.visibleItems[this.list.selectedIndex]instanceof sg?this.toggleGroup(this.visibleItems[this.list.selectedIndex].id):this.exec()}},this._debounceInput=q((()=>{if("search"==this.mode){const t=this.parsedInput;t.section>-1?(this.activeSectionIndex=t.section,this.input.value="",this.updateCommands(!0)):this.updateCommands()}else if("none"==this.mode){const t=this.parsedInput,e=this.model.filter(t.value,!1);if(e.length>0){const t=this.visibleItems.findIndex((t=>t instanceof rg&&t.id===e[0].id));t>-1&&(this.list.selectedIndex=t,this.list.renderItems(!0))}}}),this.options.inputDelay),this._onInput=t=>{t.stopPropagation(),this._debounceInput()},this._onSectionSelect=async t=>{this.activeSectionIndex!=t.index&&(this.activeSectionIndex=t.index,this.updateCommands(!0),this.focus())},this._onDropdownChange=async t=>{this.activeSectionIndex=this.sections.findIndex((t=>t.id===this.dropdown.value)),this.updateCommands(!0),this.focus()},this._onSelect=t=>{const e=this.visibleItems[t.index];e instanceof rg?("search"==this.mode&&(this.input.value=e.name),t.trigger!=pp.Click&&t.trigger!=pp.Enter||this.exec()):(this.input.value="",t.trigger!=pp.Click&&t.trigger!=pp.Enter||this.toggleGroup(e.id)),setTimeout((()=>this.input.focus()))},this._itemRenderer=(t,e,i)=>this.visibleItems[e]instanceof sg?this.groupRenderer(t,this.visibleItems[e],i):this.commandRenderer(t,this.visibleItems[e],i),this._updateToken=0,this.renderTabs=()=>this.sections?.length>1?ln`
2704
2703
  <og-container
2705
2704
  .horizontalSliderPosition="${"top"==this.sectionPosition?"bottom":"top"}"
2706
2705
  scrollMode="horizontal"
@@ -2719,6 +2718,7 @@
2719
2718
  </og-container>
2720
2719
  `:"",this.renderDropdown=()=>this.sections?.length>1?ln`
2721
2720
  <og-dropdown-list
2721
+ style="${Un({flex:`0 0 ${this.dropdownWidth}px`})}"
2722
2722
  color="transparent"
2723
2723
  .value="${this.activeSection?.id}"
2724
2724
  @change="${this._onDropdownChange}"
@@ -2776,7 +2776,7 @@
2776
2776
  ${"bottom"==this.sectionPosition?this.renderSwitches():""}
2777
2777
 
2778
2778
  ${"bottom"==this.sectionPosition?this.renderTabs():""}
2779
- `,this.addEventListener("click",(t=>t.stopPropagation())),this.addEventListener("keydown",this._onKeyDown)}connectedCallback(){super.connectedCallback(),this.tabIndex=0}focus(){this.input?.focus()}clearFilter(t=!0){this.input.value="",this.focus(),t&&this.updateCommands()}async willUpdate(t){if(t.has("adapter")&&this.adapter){this.adapter.attach(this);const t=await this.adapter.getSections(),e=await this.adapter.getOptions(t?.length?t[0].id:null);this.sections=t,e&&(this.options=cg(e))}else t.has("commands")&&this.commands&&(this.model.clear(),this.commands.forEach((t=>this.model.register(t)))),t.has("options")&&(this.options=cg(this.options))}async updated(t){["commands","adapter","model","activeSectionIndex"].some((e=>t.has(e)))&&await this.updateCommands(!0)}async updateCommands(t=!1){if(this.adapter){this.model.clear();const e=this.activeSection?.switches?.filter((t=>t.checked)).map((t=>t.key))||[];if(t){const t=await this.adapter.getOptions(this.activeSection?.id);this.options=cg(t)}this._updateToken++;const i=this._updateToken,[o,r]=await Promise.all([this.adapter.getGroups({sectionId:this.activeSection?.id,filter:this.filterValue,switches:e}),this.adapter.getCommands({sectionId:this.activeSection?.id,filter:this.filterValue,switches:e})]);if(i!=this._updateToken)return;o?.forEach((t=>this.model.registerGroup(t))),r?.forEach((t=>this.model.register(t))),this.visibleItems=this.model.filter(null,this.showGroups,!0)}else this.visibleItems=this.model.filter(this.filterValue,this.showGroups);this.placeholder=this.activeSection?.placeholder||"",this.list.reset(),this.list.size=this.visibleItems.length,this.list.selectedIndex=this.visibleItems.findIndex((t=>t instanceof rg))??0,this.list.renderItems(!0),this.noResults=0==this.visibleItems.length}async toggleGroup(t){const e=this.model.groups.get(t);if(this.list.reset(),e.open)e.open=!1,this.visibleItems=this.model.filter(this.filterValue,this.showGroups,!0),this.list.size=this.visibleItems.length;else if(e.open=!0,this.adapter){const i=(await Promise.all([this.adapter.getCommands({sectionId:this.activeSection?.id,groupId:t,filter:this.filterValue})]))[0];i.length>0&&(e.commands.clear(),i.forEach((i=>{i.group&&i.group!=t||e.addCommand(i)}))),this.visibleItems=this.model.filter(null,this.showGroups,!0)}else this.visibleItems=this.model.filter(this.filterValue,this.showGroups,!0);this.list.size=this.visibleItems.length}getSectionTitle(t){return(t.title??t.id)+(t.triggerCommand?` (${t.triggerCommand})`:"")}layout(){this.listWrapper&&(this.listWrapper.style.transition="flex-basis 0.2s ease-in-out",this.listWrapper.style.flexBasis=Ot(this.list.offsetHeight),Nt(this.listWrapper,{h:this.list.offsetHeight}))}};fg.styles=[hg],ug([$n({type:Object})],fg.prototype,"options",void 0),ug([$n({type:String})],fg.prototype,"mode",void 0),ug([$n({type:String})],fg.prototype,"value",void 0),ug([$n({type:String,reflect:!0})],fg.prototype,"sectionPosition",void 0),ug([$n({type:String})],fg.prototype,"text",void 0),ug([$n({type:Array})],fg.prototype,"commands",void 0),ug([$n({type:Object})],fg.prototype,"adapter",void 0),ug([$n({type:Object})],fg.prototype,"target",void 0),ug([$n({type:String})],fg.prototype,"placeholder",void 0),ug([$n({type:Boolean})],fg.prototype,"showGroups",void 0),ug([$n({type:Object})],fg.prototype,"model",void 0),ug([An()],fg.prototype,"sections",void 0),ug([An()],fg.prototype,"activeSectionIndex",void 0),ug([An()],fg.prototype,"noResults",void 0),ug([On(".list")],fg.prototype,"listWrapper",void 0),ug([On("og-list")],fg.prototype,"list",void 0),ug([On("input")],fg.prototype,"input",void 0),ug([On("og-dropdown-list")],fg.prototype,"dropdown",void 0),fg=ug([In("og-commands")],fg);class vg extends hu{filterCommands(t,e){if(!t)return[];const i=null==e?.filter?null:new RegExp(ut(e.filter),"i");return null==i?t:t.filter((t=>i.test(t.id||t.name||"")))}getGroups(t){return[]}getCommands(t){return[]}getSections(t){return[{id:"default"}]}getOptions(t){return null}exec(t,e){}}class bg extends vg{get commands(){return this._commands}set commands(t){this._commands=t,this.map.clear();const e=t=>{t.forEach((t=>{this.map.set(t.id??t.name,t),t.next?.commands&&e(t.next.commands)}))};e(this._commands)}constructor(t){super(),this.map=new Map,this.commandChain=[],this._commands=[],this.commands=t}getCommands(t){const e=this.commandChain.length?this.commandChain[this.commandChain.length-1]:null,i=e?this.map.get(e.id)?.next?.commands:null;return this.filterCommands(i||this.commands,t)}exec(t,e){const i=this.map.get(t.id)?.next;i?.commands?.length?(this.commandChain.push(t),null==this._originalText&&(this._originalText=this.component.text),null==this._originalMode&&(this._originalMode=this.component.mode),null!=i.text&&(this.component.text=i.text),null!=i.mode&&(this.component.mode=i.mode)):this.reset(),this.component.updateCommands()}reset(){this.commandChain=[],this.component&&(this.component.text=this._originalText,this.component.mode=this._originalMode),this._originalText=null,this._originalMode=null}getOptions(){return null}}const yg={yes_no:t=>[{id:"Y",name:$o("Yes"),exec:t},{id:"N",name:$o("No"),exec:t}],apply:t=>[{id:"apply",name:$o("Apply"),exec:t},{id:"cancel",name:$o("Cancel"),exec:t}],ok:t=>[{id:"ok",name:"OK",exec:t},{id:"cancel",name:$o("Cancel"),exec:t}]},wg=(t,e)=>yg[t](e);class xg{get commands(){return this._commands}constructor(t){this.target=t,this._commands=[],this._onExec=t=>{Lr().info(`trigger command: ${t.command.id}`),this._resolveCallback&&this._resolveCallback({command:t.command,id:t.command?.id,value:t.value}),this._resolveCallback=null,this._rejectCallback=null,null==this.adapter.map.get(t.command.id)?.next&&this.close()}}clear(){this._commands=[],this._adapter=null}add(t){this._commands.push(...Array.isArray(t)?t:[t]),this._adapter=null}get adapter(){return this._adapter||(this._adapter=new bg(this._commands)),this._adapter}cleanCallbacks(){this._rejectCallback&&this._rejectCallback(),this._resolveCallback=null,this._rejectCallback=null}get menu(){return this._menu??(this._menu=yt("og-commands",{listeners:[["command.exec",this._onExec]]}))}get menuContainer(){return this._menuContainer||(this._menuContainer=yt("og-floating-window",{listeners:[["hide",()=>{this.target?.focus(),this.adapter?.reset()}]]}),this.menu.slot="content",this._menuContainer.appendChild(this.menu)),this._menuContainer}async open(t){return Lr().info("open menu"),this.target.shadowRoot.appendChild(this.menuContainer),this.menuContainer.show(),t??(t={content:null}),this.menu.text=t.text,this.menu.value=t.value,this.menu.mode=t.mode||"search",Array.isArray(t.content)?(this.menu.commands=t.content,this.menu.adapter=null):"string"==typeof t.content?(this.menu.commands=wg(t.content),this.menu.adapter=null):(this.menu.commands=null,this.menu.adapter=this.adapter),await this.menu.updateComplete,this.menu.focus(),this.updatePosition(),new Promise(((t,e)=>{this._resolveCallback=t,this._rejectCallback=e}))}close(){this.menuContainer.hide(!1),this.menuContainer.remove(),this.cleanCallbacks(),this.target?.focus()}updatePosition(){Nt(this.menuContainer,{w:.9*this.target.clientWidth}),Xt(this.menuContainer,this.target,{horizontal:!0,vertical:!1}),Ht(this.menuContainer,{t:50})}}const kg={TOP_HEIGHT:41,SIDEMENU_WIDTH:41,SIDEBAR_WIDTH:250,SIZER_TRESHOLD:5,SIDEBAR_HEADER_HEIGHT:30,ALERT_DEFAULT_HEIGHT:30,ALERT_MAX_HEIGHT:300,...G},Cg=ks`
2779
+ `,this.addEventListener("click",(t=>t.stopPropagation())),this.addEventListener("keydown",this._onKeyDown)}connectedCallback(){super.connectedCallback(),this.tabIndex=0}focus(){this.input?.focus()}clearFilter(t=!0){this.input.value="",this.focus(),t&&this.updateCommands()}async willUpdate(t){if(t.has("adapter")&&this.adapter){this.adapter.attach(this);const t=await this.adapter.getSections(),e=await this.adapter.getOptions(t?.length?t[0].id:null);this.sections=t,e&&(this.options=cg(e))}else t.has("commands")&&this.commands&&(this.model.clear(),this.commands.forEach((t=>this.model.register(t)))),t.has("options")&&(this.options=cg(this.options))}async updated(t){["commands","adapter","model","activeSectionIndex"].some((e=>t.has(e)))&&await this.updateCommands(!0)}async updateCommands(t=!1){if(this.adapter){this.model.clear();const e=this.activeSection?.switches?.filter((t=>t.checked)).map((t=>t.key))||[];if(t){const t=await this.adapter.getOptions(this.activeSection?.id);this.options=cg(t)}this._updateToken++;const i=this._updateToken,[o,r]=await Promise.all([this.adapter.getGroups({sectionId:this.activeSection?.id,filter:this.filterValue,switches:e}),this.adapter.getCommands({sectionId:this.activeSection?.id,filter:this.filterValue,switches:e})]);if(i!=this._updateToken)return;o?.forEach((t=>this.model.registerGroup(t))),r?.forEach((t=>this.model.register(t))),this.visibleItems=this.model.filter(null,this.showGroups,!0)}else this.visibleItems=this.model.filter(this.filterValue,this.showGroups);this.placeholder=this.activeSection?.placeholder||"",this.list.reset(),this.list.size=this.visibleItems.length,this.list.selectedIndex=this.visibleItems.findIndex((t=>t instanceof rg))??0,this.list.renderItems(!0),this.noResults=0==this.visibleItems.length}async toggleGroup(t){const e=this.model.groups.get(t);if(this.list.reset(),e.open)e.open=!1,this.visibleItems=this.model.filter(this.filterValue,this.showGroups,!0),this.list.size=this.visibleItems.length;else if(e.open=!0,this.adapter){const i=(await Promise.all([this.adapter.getCommands({sectionId:this.activeSection?.id,groupId:t,filter:this.filterValue})]))[0];i.length>0&&(e.commands.clear(),i.forEach((i=>{i.group&&i.group!=t||e.addCommand(i)}))),this.visibleItems=this.model.filter(null,this.showGroups,!0)}else this.visibleItems=this.model.filter(this.filterValue,this.showGroups,!0);this.list.size=this.visibleItems.length}getSectionTitle(t){return(t.title??t.id)+(t.triggerCommand?` (${t.triggerCommand})`:"")}layout(){this.listWrapper&&(this.listWrapper.style.transition="flex-basis 0.2s ease-in-out",this.listWrapper.style.flexBasis=Ot(this.list.offsetHeight),Nt(this.listWrapper,{h:this.list.offsetHeight}))}};fg.styles=[hg],ug([$n({type:Object})],fg.prototype,"options",void 0),ug([$n({type:String})],fg.prototype,"mode",void 0),ug([$n({type:String})],fg.prototype,"value",void 0),ug([$n({type:String,reflect:!0})],fg.prototype,"sectionPosition",void 0),ug([$n({type:Number})],fg.prototype,"dropdownWidth",void 0),ug([$n({type:String})],fg.prototype,"text",void 0),ug([$n({type:Array})],fg.prototype,"commands",void 0),ug([$n({type:Object})],fg.prototype,"adapter",void 0),ug([$n({type:Object})],fg.prototype,"target",void 0),ug([$n({type:String})],fg.prototype,"placeholder",void 0),ug([$n({type:Boolean})],fg.prototype,"showGroups",void 0),ug([$n({type:Object})],fg.prototype,"model",void 0),ug([An()],fg.prototype,"sections",void 0),ug([An()],fg.prototype,"activeSectionIndex",void 0),ug([An()],fg.prototype,"noResults",void 0),ug([On(".list")],fg.prototype,"listWrapper",void 0),ug([On("og-list")],fg.prototype,"list",void 0),ug([On("input")],fg.prototype,"input",void 0),ug([On("og-dropdown-list")],fg.prototype,"dropdown",void 0),fg=ug([In("og-commands")],fg);class vg extends hu{filterCommands(t,e){if(!t)return[];const i=null==e?.filter?null:new RegExp(ut(e.filter),"i");return null==i?t:t.filter((t=>i.test(t.id||t.name||"")))}getGroups(t){return[]}getCommands(t){return[]}getSections(t){return[{id:"default"}]}getOptions(t){return null}exec(t,e){}}class bg extends vg{get commands(){return this._commands}set commands(t){this._commands=t,this.map.clear();const e=t=>{t.forEach((t=>{this.map.set(t.id??t.name,t),t.next?.commands&&e(t.next.commands)}))};e(this._commands)}constructor(t){super(),this.map=new Map,this.commandChain=[],this._commands=[],this.commands=t}getCommands(t){const e=this.commandChain.length?this.commandChain[this.commandChain.length-1]:null,i=e?this.map.get(e.id)?.next?.commands:null;return this.filterCommands(i||this.commands,t)}exec(t,e){const i=this.map.get(t.id)?.next;i?.commands?.length?(this.commandChain.push(t),null==this._originalText&&(this._originalText=this.component.text),null==this._originalMode&&(this._originalMode=this.component.mode),null!=i.text&&(this.component.text=i.text),null!=i.mode&&(this.component.mode=i.mode)):this.reset(),this.component.updateCommands()}reset(){this.commandChain=[],this.component&&(this.component.text=this._originalText,this.component.mode=this._originalMode),this._originalText=null,this._originalMode=null}getOptions(){return null}}const yg={yes_no:t=>[{id:"Y",name:$o("Yes"),exec:t},{id:"N",name:$o("No"),exec:t}],apply:t=>[{id:"apply",name:$o("Apply"),exec:t},{id:"cancel",name:$o("Cancel"),exec:t}],ok:t=>[{id:"ok",name:"OK",exec:t},{id:"cancel",name:$o("Cancel"),exec:t}]},wg=(t,e)=>yg[t](e);class xg{get commands(){return this._commands}constructor(t){this.target=t,this._commands=[],this._onExec=t=>{Lr().info(`trigger command: ${t.command.id}`),this._resolveCallback&&this._resolveCallback({command:t.command,id:t.command?.id,value:t.value}),this._resolveCallback=null,this._rejectCallback=null,null==this.adapter.map.get(t.command.id)?.next&&this.close()}}clear(){this._commands=[],this._adapter=null}add(t){this._commands.push(...Array.isArray(t)?t:[t]),this._adapter=null}get adapter(){return this._adapter||(this._adapter=new bg(this._commands)),this._adapter}cleanCallbacks(){this._rejectCallback&&this._rejectCallback(),this._resolveCallback=null,this._rejectCallback=null}get menu(){return this._menu??(this._menu=yt("og-commands",{listeners:[["command.exec",this._onExec]]}))}get menuContainer(){return this._menuContainer||(this._menuContainer=yt("og-floating-window",{listeners:[["hide",()=>{this.target?.focus(),this.adapter?.reset()}]]}),this.menu.slot="content",this._menuContainer.appendChild(this.menu)),this._menuContainer}async open(t){return Lr().info("open menu"),this.target.shadowRoot.appendChild(this.menuContainer),this.menuContainer.show(),t??(t={content:null}),this.menu.text=t.text,this.menu.value=t.value,this.menu.mode=t.mode||"search",Array.isArray(t.content)?(this.menu.commands=t.content,this.menu.adapter=null):"string"==typeof t.content?(this.menu.commands=wg(t.content),this.menu.adapter=null):(this.menu.commands=null,this.menu.adapter=this.adapter),await this.menu.updateComplete,this.menu.focus(),this.updatePosition(),new Promise(((t,e)=>{this._resolveCallback=t,this._rejectCallback=e}))}close(){this.menuContainer.hide(!1),this.menuContainer.remove(),this.cleanCallbacks(),this.target?.focus()}updatePosition(){Nt(this.menuContainer,{w:.9*this.target.clientWidth}),Xt(this.menuContainer,this.target,{horizontal:!0,vertical:!1}),Ht(this.menuContainer,{t:50})}}const kg={TOP_HEIGHT:41,SIDEMENU_WIDTH:41,SIDEBAR_WIDTH:250,SIZER_TRESHOLD:5,SIDEBAR_HEADER_HEIGHT:30,ALERT_DEFAULT_HEIGHT:30,ALERT_MAX_HEIGHT:300,...G},Cg=ks`
2780
2780
  :host {
2781
2781
  display: flex;
2782
2782
  flex-direction: column;
@@ -2881,7 +2881,7 @@
2881
2881
  <div class="main"></div>
2882
2882
  ${"right"==this.options.sidebarPosition?this.renderSideMenu():null}
2883
2883
  </div>
2884
- `,this.components=new zg(this),this.sidebars=new Eg(this),this.alerts=new Mg(this),this.dialogs=new Lg(this),this.commands=new xg(this),this.shortcuts=new ms(this),this.options=Sg(),this.logger.info("init"),this.addEventListener("state",(t=>{t.target!=this&&(t.stopPropagation(),this.dispatchStateEvent())}))}connectedCallback(){super.connectedCallback(),this.tabIndex=0,this.logger.info("connected"),window.addEventListener("beforeunload",this._onWindowBeforeUnload)}disconnectedCallback(){window.removeEventListener("beforeunload",this._onWindowBeforeUnload)}layout(){this.container?.layout(),this.top?.layout()}setSourceData(t){this.sourceData=t,t.options&&(this.options=Sg(t.options,this.options))}async updated(){const t=this.compact?"single"==this.options?.componentMode?this.singleContainer:this.editorContainer:this.container;t.parentElement!=this.main&&(St(this.main),this.main.appendChild(t),t instanceof En&&t.requestUpdate());const e=(this.sourceData.sidemenu.items??[])[this.sourceData.sidemenu.activeIndex]?.id;e&&(this.sidebar1ComponentId=e),await(this.container?.updateComplete),this.layout()}_openComponent(t){"single"==this.options?.componentMode?(St(this.singleContainer),this.singleContainer.appendChild(this.createEditorComponent(t.id))):this.editorContainer.open(t)}async open(t){this.compact&&this.hideSidebar(),"single"==this.options?.componentMode?xt(this.singleContainer):xt(this.editorContainer);const e=t.component;return e?(t.id=this.components.register(t.id,t.component),delete t.component,this._openComponent(t),e):new Promise(((e,i)=>{this.components.enqueueComponentResolution(t.id,e,i),this.components.has(t.id)&&this.components.resolveComponentPromises(t.id,this.components.components.get(t.id)),this._openComponent(t),this.dispatchStateEvent()}))}async openDialog(t){return await this.dialogs.open(t)}openMenu(t){return this.commands.open(t)}openModalSidebar(t){return this.sidebars.openModalSidebar(t)}async toggleSidebar(t){t??(t=this.compact?this.sidebarHost.parentElement!=this.main:this.container.items[this.sidebarIndex].collapsed),t?this.showSidebar():this.hideSidebar()}async hideSidebar(){this.compact?this.sidebarHost.parentElement==this.main&&(St(this.main),this.main.appendChild(this.editorContainer)):await this.container.collapse(this.sidebarIndex,!0),this.layout()}async showSidebar(){this.compact?this.sidebarHost.parentElement!=this.main&&(St(this.main),this.main.appendChild(this.sidebarHost)):await this.container.collapse(this.sidebarIndex,!1),this.layout()}showAlert(t){return this.alerts.addAlert(t)}getState(){const t=this.container?.items[0];return{sidebar:{selectedItem:this.sidebar1ComponentId,width:t?.size,collapsed:!!t?.collapsed},layout:this.editorContainer?.model.getSourceData(),dialogs:[...Array.from(this.dialogs.items.entries()).map((([t,e])=>Object.assign({id:t},e.getOptions())))],components:[...this.components.components].reduce(((t,[e,i])=>{if(i.getState){const o=i.getState();o&&(t[e]=o)}return t}),{})}}async setState(t){this.state=t;const e=this.sourceData.sidemenu.items.findIndex((e=>e.id==t.sidebar.selectedItem));e>=0&&(this.sourceData.sidemenu.activeIndex=e,this.sidebar1ComponentId=t.sidebar.selectedItem),this.sourceData.editorLayout=t.layout,this._editorContainer=null,this.requestUpdate(),await this.updateComplete,this.sidemenu?.requestUpdate(),this.updateSidebarComponent(),this.updateMainComponent(),t.dialogs?.forEach((t=>this.openDialog(t)));for(const e in t.components)this.components.setState(e,t.components[e])}_onSidemenuSelect(t){const e=(this.sourceData.sidemenu.items??[])[t.index]?.id;e==this.sidebar1ComponentId?this.toggleSidebar():(this.toggleSidebar(!0),this.sidebar1ComponentId=e,this.updateSidebarComponent()),this.dispatchStateEvent()}updateSidebarComponent(){this.sidebarHost.componentId=this.sidebar1ComponentId}updateMainComponent(){this.container?.updateComponent(1)}async openSidebarComponent(t){this.sidebar1ComponentId=t.toString(),this.showSidebar(),this.updateSidebarComponent(),this.sidemenu.selectItem(t.toString()),await this.sidebarHost.updateComplete}};Ag.styles=[Cg],Ag.uniqueId=0,Ag.getUniqueId=()=>++Ig.uniqueId,Rg([On("og-overlay")],Ag.prototype,"overlay",void 0),Rg([On("og-bucket-top")],Ag.prototype,"top",void 0),Rg([On("og-bucket-sidemenu")],Ag.prototype,"sidemenu",void 0),Rg([On(".body")],Ag.prototype,"body",void 0),Rg([On(".main")],Ag.prototype,"main",void 0),Rg([$n({type:Object})],Ag.prototype,"createComponent",void 0),Rg([$n({type:Object})],Ag.prototype,"sourceData",void 0),Rg([$n({type:Object})],Ag.prototype,"options",void 0),Rg([$n({type:Object})],Ag.prototype,"logger",void 0),Rg([$n({type:Boolean})],Ag.prototype,"compact",void 0),Ag=Ig=Rg([In("og-bucket")],Ag);const Dg=ks`
2884
+ `,this.components=new zg(this),this.sidebars=new Eg(this),this.alerts=new Mg(this),this.dialogs=new Lg(this),this.commands=new xg(this),this.shortcuts=new ms(this),this.options=Sg(),this.logger.info("init"),this.addEventListener("state",(t=>{t.target!=this&&(t.stopPropagation(),this.dispatchStateEvent())}))}connectedCallback(){super.connectedCallback(),this.tabIndex=0,this.logger.info("connected"),window.addEventListener("beforeunload",this._onWindowBeforeUnload)}disconnectedCallback(){window.removeEventListener("beforeunload",this._onWindowBeforeUnload)}layout(){this.container?.layout(),this.top?.layout()}setSourceData(t){this.sourceData=t,t.options&&(this.options=Sg(t.options,this.options))}async updated(){const t=this.compact?"single"==this.options?.componentMode?this.singleContainer:this.editorContainer:this.container;t.parentElement!=this.main&&(St(this.main),this.main.appendChild(t),t instanceof En&&t.requestUpdate());const e=(this.sourceData.sidemenu.items??[])[this.sourceData.sidemenu.activeIndex]?.id;e&&(this.sidebar1ComponentId=e),await(this.container?.updateComplete),this.layout()}_openComponent(t){"single"==this.options?.componentMode?(St(this.singleContainer),this.singleContainer.appendChild(this.createEditorComponent(t.id))):this.editorContainer.open(t)}async open(t){this.compact&&this.hideSidebar(),"single"==this.options?.componentMode?xt(this.singleContainer):xt(this.editorContainer);const e=t.component;return e?(t.id=this.components.register(t.id,t.component),delete t.component,this._openComponent(t),e):new Promise(((e,i)=>{this.components.enqueueComponentResolution(t.id,e,i),this.components.has(t.id)&&this.components.resolveComponentPromises(t.id,this.components.components.get(t.id)),this._openComponent(t),this.dispatchStateEvent()}))}async openDialog(t){return await this.dialogs.open(t)}openMenu(t){return this.commands.open(t)}openModalSidebar(t){return this.sidebars.openModalSidebar(t)}async toggleSidebar(t){t??(t=this.compact?this.sidebarHost.parentElement!=this.main:this.container.items[this.sidebarIndex].collapsed),t?this.showSidebar():this.hideSidebar()}async hideSidebar(){this.compact?this.sidebarHost.parentElement==this.main&&(St(this.main),this.main.appendChild(this.editorContainer)):await this.container.collapse(this.sidebarIndex,!0),this.layout()}async showSidebar(){this.compact?this.sidebarHost.parentElement!=this.main&&(St(this.main),this.main.appendChild(this.sidebarHost)):await this.container.collapse(this.sidebarIndex,!1),this.layout()}showAlert(t){return this.alerts.addAlert(t)}getState(){const t=this.container?.items[0];return{sidebar:{selectedItem:this.sidebar1ComponentId,width:t?.size,collapsed:!!t?.collapsed},layout:this.editorContainer?.model.getSourceData(),dialogs:[...Array.from(this.dialogs.items.entries()).map((([t,e])=>Object.assign({id:t},e.getOptions())))],components:[...this.components.components].reduce(((t,[e,i])=>{if(i.getState){const o=i.getState();o&&(t[e]=o)}return t}),{})}}async setState(t){this.state=t;const e=this.sourceData.sidemenu.items.findIndex((e=>e.id==t.sidebar.selectedItem));e>=0&&(this.sourceData.sidemenu.activeIndex=e,this.sidebar1ComponentId=t.sidebar.selectedItem),this.sourceData.editorLayout=t.layout,this._editorContainer=null,this.requestUpdate(),await this.updateComplete,this.sidemenu?.requestUpdate(),this.updateSidebarComponent(),this.updateMainComponent(),t.dialogs?.forEach((t=>this.openDialog(t)));for(const e in t.components)this.components.setState(e,t.components[e])}_onSidemenuSelect(t){const e=(this.sourceData.sidemenu.items??[])[t.index]?.id;e==this.sidebar1ComponentId?this.toggleSidebar():(this.toggleSidebar(!0),this.sidebar1ComponentId=e,this.updateSidebarComponent(),this.dispatchEvent(new $g("sidebar.change"))),this.dispatchStateEvent()}updateSidebarComponent(){this.sidebarHost.componentId=this.sidebar1ComponentId}updateMainComponent(){this.container?.updateComponent(1)}async openSidebarComponent(t){this.sidebar1ComponentId=t.toString(),this.showSidebar(),this.updateSidebarComponent(),this.sidemenu.selectItem(t.toString()),await this.sidebarHost.updateComplete}};Ag.styles=[Cg],Ag.uniqueId=0,Ag.getUniqueId=()=>++Ig.uniqueId,Rg([On("og-overlay")],Ag.prototype,"overlay",void 0),Rg([On("og-bucket-top")],Ag.prototype,"top",void 0),Rg([On("og-bucket-sidemenu")],Ag.prototype,"sidemenu",void 0),Rg([On(".body")],Ag.prototype,"body",void 0),Rg([On(".main")],Ag.prototype,"main",void 0),Rg([$n({type:Object})],Ag.prototype,"createComponent",void 0),Rg([$n({type:Object})],Ag.prototype,"sourceData",void 0),Rg([$n({type:Object})],Ag.prototype,"options",void 0),Rg([$n({type:Object})],Ag.prototype,"logger",void 0),Rg([$n({type:Boolean})],Ag.prototype,"compact",void 0),Ag=Ig=Rg([In("og-bucket")],Ag);const Dg=ks`
2885
2885
  * {
2886
2886
  box-sizing: border-box;
2887
2887
  }
@@ -3977,7 +3977,7 @@
3977
3977
  padding-right: 2px;
3978
3978
  }
3979
3979
 
3980
- `,rv=(t,e,i)=>{for(const i of e)if(i[0]===t)return(0,i[1])();return i?.()},sv={enabled:!1,includeChildren:!0,includeParents:!0},nv={enabled:!0,reversed:!1},av={ROW_HEIGHT:22,RESIZE_TRESHOLD:10,ROW_HEADER_WIDTH:60,SLIDER_SIZE:12,EXPANDER_SIZE:13,MAX_CACHE_ITEMS:5e3,CACHE_CLEAN_INTERVAL:30,COMMENT_HIDE_TIMEOUT:1e3,SELECTOR_BORDER_WIDTH:1,MIN_ROW_HEIGHT:5,MIN_COL_WIDTH:5,SPARKLINE_GAP:4,AUTOSCROLL_TRESHOLD:100,AUTOSCROLL_RATIO:1.1,AUTOSCROLL_INTERVAL:100,DEFAULT_SPARKLINE_OPTIONS:{minValue:"auto",maxValue:"auto",type:"line",style:{color:"0094FF",weight:1},marker:{color:"ff0000"}},DEFAULT_OPTIONS:{rows:100,columns:20,readOnly:!1,rowNumbers:!0,rowPriority:2,rowTree:{enabled:!0},columnTree:{enabled:!0},colLetters:!0,emptyPlaceholder:!0,freezeTop:0,fontSize:14,rowHeight:22,rowResize:!0,columnWidth:100,columnResize:!0,columnPriority:1,freezeLeft:0,freezeRight:0,freezeBottom:0,maxSortingColumns:3,numberFormat:null,levelIndentFactor:2,cellIndentFactor:10,emptyClickable:!1,grid:!0,autofill:!0,undoRedo:!0,commandWindow:!0,cellCache:!0,singleCellModel:!1,zoom:1,editing:{rowInsertion:!0,rowDeletion:!0,colInsertion:!0,colDeletion:!0,rowOutline:!0,colOutline:!0,dateCalendarEditor:!1},comments:{hideTimeout:1e3,offsetX:30,offsetY:-30,zIndex:500,headerPosition:"top"},scrolling:{verticalOverscroll:!0,horizontalOverscroll:!0,scrollbarVisibilityTreshold:100},selecting:{enabled:!0,multiSelect:!0},events:{click:{mouseMoveTreshold:10}},clipboard:{pasteProps:["v","dv"],rowPasteMode:"rewrite_append",columnPasteMode:"rewrite"},print:{dpi:600,margins:{left:6.35,right:6.35,top:19.05,bottom:19.05,header:7.62,footer:7.62},orientation:"portrait",paper:"A4"}},MAX_COMMENT_AUTOHEIGHT:300,MIN_COMMENT_AUTOHEIGHT:25,...G},lv=/^(?!.*[\\\/\*\[\]\:\?"])(.{1,31})$/;function cv(t){return lv.test(t)}function hv(t){return["\\","/","*","[","]",":","?",'"'].forEach((e=>t=t.replace(new RegExp(`\\${e}`,"g"),""))),t}function dv(t,e){return!isNaN(t)&&null!=t||!isNaN(e)&&null!=e||(t=null==t?"":ct(t.toString()).toLowerCase(),e=null==e?"":ct(e.toString()).toLowerCase()),t>e?1:t<e?-1:0}function uv(t,e){const i=Q(e);return Q(t)?(t=t.toString().trim()).startsWith("=")?0==dv(e,i?t.substring(1):parseFloat(t.substring(1))):t.startsWith(">=")?dv(e,i?t.substring(2):parseFloat(t.substring(2)))>=0:t.startsWith("<=")?dv(e,i?t.substring(2):parseFloat(t.substring(2)))<=0:t.startsWith(">")?dv(e,i?t.substring(1):parseFloat(t.substring(1)))>0:t.startsWith("<")?dv(e,i?t.substring(1):parseFloat(t.substring(1)))<0:0==dv(e,i?t:isNaN(t)?t||"":parseFloat(t)):e==t}const pv=new Map([["=",["==",1,0]],["<>",["!=",1,0]],[">",[">",1,0]],["<",["<",1,0]],[">=",[">=",1,0]],["<=",["<=",1,0]],["+",["+",2,0]],["-",["-",2,0]],["*",["*",3,0]],["/",["/",3,0]]]),gv=t=>["=",">","<",">=","<="].includes(t),mv=t=>["+","-","*","/"].includes(t),fv=t=>mv(t)||gv(t);function vv(t,e,i){switch(i){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return t/e;case"=":return 0==dv(t,e);case">":return dv(t,e)>0;case"<":return dv(t,e)<0;case">=":return dv(t,e)>=0;case"<=":return dv(t,e)<=0;default:throw new Error(`Invalid operator: ${i}`)}}function bv(t,e,i){const o=Array.isArray(t),r=Array.isArray(e);if(!o&&!r)return[[vv(t,e,i)]];const s=Math.max(o?t.length:0,r?e.length:0),n=Math.max(o?t[0].length:0,r?e[0].length:0),a=[];for(let l=0;l<s;l++){const s=[];for(let a=0;a<n;a++){const n=o?t[l]?.[a]:t,c=r?e[l]?.[a]:e,h=null==n&&null==c?null:vv(n,c,i);s.push(h)}a.push(s)}return a}var yv;!function(t){t[t.Number=0]="Number",t[t.Boolean=1]="Boolean",t[t.String=2]="String",t[t.StringQuote=3]="StringQuote",t[t.Function=4]="Function",t[t.ArgumentSeparator=5]="ArgumentSeparator",t[t.OpenBracket=6]="OpenBracket",t[t.CloseBracket=7]="CloseBracket",t[t.Operator=8]="Operator",t[t.Cell=9]="Cell",t[t.Variable=10]="Variable",t[t.Range=11]="Range",t[t.Sheet=12]="Sheet",t[t.SheetQuote=13]="SheetQuote",t[t.SheetSeparator=14]="SheetSeparator",t[t.Unknown=15]="Unknown",t[t.Operand=16]="Operand"}(yv||(yv={}));const wv=t=>t===yv.Number||t===yv.Boolean||t===yv.String||t===yv.Cell||t===yv.Variable||t===yv.Range,xv=t=>t>=48&&t<=57,kv=t=>"true"===(t=t.toLowerCase())||"false"===t,Cv=t=>t>=65&&t<=90||t>=97&&t<=122||t>=192&&t<=687,Mv={decimalPoint:".",stringQuote:'"',sheetQuote:"'",argumentSeparator:","};class _v{constructor(t){this.options=Object.assign(Mv,t)}tokenize(t){const e=[],i=t.length;let o,r,s,n,a=0,l="",c=!1,h=!1,d=!1;for(;a<i;){if(o=t.charAt(a),r=o.charCodeAt(0),"="==o&&0==a)++a;else if(xv(r)){for(l=(d?"-":"")+o,++a;a<i;)if(o=t.charAt(a),r=o.charCodeAt(0),xv(r))l+=o,++a;else{if(o!==this.options.decimalPoint)break;l+=".",++a}d=!1,e.push([l,yv.Number])}else if(Cv(r)||"$"==o){l=o,s=null,++a;do{if(o=t.charAt(a),r=o.charCodeAt(0),Cv(r)||xv(r)||"."===o||"$"===o||"_"===o)"_"==o?s=yv.Variable:xv(r)&&!c&&null==s&&(s=yv.Cell),l+=o,++a,a==i&&e.push([l,s||yv.Variable]);else{if("("==o){e.push([l.toUpperCase(),yv.Function]),e.push([o,yv.OpenBracket]),++a;break}if("'"==o)e.push([l,yv.Sheet]),l="",e.push([o,yv.SheetQuote]),c=!0,++a;else if(":"==o)s=yv.Range,l+=o,++a;else{if(!c||" "!=o){if("!"==o){""!==l&&e.push([l,yv.Sheet]),e.push([o,yv.SheetSeparator]),c=!1,l="",++a;break}e.push([l,s||(kv(l)?yv.Boolean:yv.Variable)]);break}l+=o,++a}}}while(a<i)}else if(fv(o)){if("-"===o&&xv(t.charCodeAt(a+1))&&(null==n||"("==n[0]||gv(n[0])||n[1]==yv.ArgumentSeparator))d=!0;else{for(l=o;gv(t.charAt(a+1));)l+=t.charAt(++a);e.push([l,yv.Operator])}++a}else if("("===o)e.push([o,yv.OpenBracket]),++a;else if(")"===o)e.push([o,yv.CloseBracket]),++a;else if("'"===o)e.push([o,yv.SheetQuote]),c=!0,++a;else if(o===this.options.argumentSeparator)e.push([o,yv.ArgumentSeparator]),++a;else if(o===this.options.stringQuote){for(h=!1,e.push([o,yv.StringQuote]),l="";++a<i;){if(o=t.charAt(a),o===this.options.stringQuote){h=!0,++a;break}l+=o}e.push([l,yv.String]),h&&e.push([this.options.stringQuote,yv.StringQuote])}else e.push([o,yv.Unknown]),++a;n=e[e.length-1]}return e}}function Sv(t,e,i=null,o=!0){return t+=e,0==e?t:t>=0?i?o?t%i:Math.min(t,i-1):t:o&&i?i+t%i:Math.max(t,0)}const zv=/(?:'?([\w\s]*)'?!)?(\$?)([a-z]*)(\$?)(\d*)(?::(\$?)([a-z]*)(\$?)(\d*))?/i;class Ev{constructor(t,e,i,o,r){this.setCoords(t,e,i,o),this.sheet=r}setCoords(t,e,i,o){this.c1=null==t&&null==i?0:t,this.r1=null==e&&null==o?0:e,this.c2=null==o&&null!=t||null!=i?null==i?t:i:1/0,this.r2=null==i&&null!=e||null!=o?null==o?e:o:1/0,this.normalize()}get size(){return{columns:this.c2-this.c1+1,rows:this.r2-this.r1+1}}get count(){const{columns:t,rows:e}=this.size;return t*e}normalize(){const[t,e]=[Math.min(this.c1,this.c2),Math.max(this.c1,this.c2)],[i,o]=[Math.min(this.r1,this.r2),Math.max(this.r1,this.r2)];return this.c1=t,this.c2=e,this.r1=i,this.r2=o,this}move(t,e,i=null,o=null,r=!0){const s=Sv(this.c1,t,i,r);r&&(e+=this.c1+t!=s&&0!=t?t>0?1:-1:0),this.c1=s,this.r1=Sv(this.r1,e,o,r),this.c2=Sv(this.c2,t,i,r),this.r2=Sv(this.r2,e,o,r)}contains(t){return t.c1>=this.c1&&t.c2<=this.c2&&t.r1>=this.r1&&t.r2<=this.r2}containsColumn(t){return this.c1<=t&&this.c2>=t}containsRow(t){return this.r1<=t&&this.r2>=t}removeAnchors(){return this.c1Anchor=!1,this.c2Anchor=!1,this.r1Anchor=!1,this.r2Anchor=!1,this}addAnchors(){return this.c1Anchor=!0,this.c2Anchor=!0,this.r1Anchor=!0,this.r2Anchor=!0,this}shiftLeft(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1-=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2-=e),this}shiftRight(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1+=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2+=e),this}shiftUp(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1-=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2-=e),this}shiftDown(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1+=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2+=e),this}shift(t){const{index:e,offset:i,direction:o,maxIndex:r,ignoreAnchors:s}=t;switch(o){case"down":return this.shiftDown(e,i,r,s);case"up":return this.shiftUp(e,i,r,s);case"left":return this.shiftLeft(e,i,r,s);case"right":return this.shiftRight(e,i,r,s)}}intersect(t){this.normalize(),t.normalize();const e=Math.max(t.c1,this.c1),i=Math.min(t.c2,this.c2),o=Math.max(t.r1,this.r1),r=Math.min(t.r2,this.r2);return e<=i&&o<=r?new Ev(e,o,i,r,this.sheet):null}unite(t){return this.normalize(),t.normalize(),new Ev(Math.min(this.c1,t.c1),Math.min(this.r1,t.r1),Math.max(this.c2,t.c2),Math.max(this.r2,t.r2),this.sheet)}clone(){const t=new Ev(this.c1,this.r1,this.c2,this.r2,this.sheet);return t.c1Anchor=this.c1Anchor,t.r1Anchor=this.r1Anchor,t.c2Anchor=this.c2Anchor,t.r2Anchor=this.r2Anchor,t}equals(t,e=!1){return t.c1==this.c1&&t.r1==this.r1&&t.c2==this.c2&&t.r2==this.r2&&(0==e||t.c1Anchor==this.c1Anchor&&t.r1Anchor==this.r1Anchor&&t.c2Anchor==this.c2Anchor&&t.r2Anchor==this.r2Anchor)}get isCell(){return this.c2==this.c2&&this.r2==this.r1}get isRange(){return this.c2!=this.c1||this.r2!=this.r1}get isColumn(){return 0==this.r1&&this.r2==1/0}get isRow(){return 0==this.c1&&this.c2==1/0}get A1(){const t=this.isRange,e=(this.c1Anchor?"$":"")+(0!==this.c1||this.c2!==1/0?Rv(this.c1):"")+(0===this.r1&&this.r2===1/0?"":(this.r1Anchor?"$":"")+Lv(this.r1)),i=t?(this.c2Anchor?"$":"")+(!isNaN(this.c2)&&this.c2<1/0?Rv(this.c2):"")+(this.r2Anchor?"$":"")+(!isNaN(this.r2)&&this.r2<1/0?Lv(this.r2):""):e;return(null==this.sheet?"":((o=this.sheet).indexOf(" ")>-1?"'"+o+"'":o)+"!")+(e==i?e:e+":"+i);var o}get bounds(){return[[new Ev(this.c1,this.r1),this.c2<1/0?new Ev(this.c2,this.r1):null],[this.r2<1/0?new Ev(this.c1,this.r2):null,this.r2<1/0&&this.c2<1/0?new Ev(this.c2,this.r2):null]]}*cells(){for(let t=this.r1;t<=this.r2;t++)for(let e=this.c1;e<=this.c2;e++)yield new Ev(e,t)}static fromA1(t){const e=zv.exec(t),i=new Ev(e[3]?Tv(e[3]):null,e[5]?Iv(e[5]):null,e[7]?Tv(e[7]):null,e[9]?Iv(e[9]):null,e[1]||null);return!e[2]&&e[3]||(i.c1Anchor=!0),!e[4]&&e[5]||(i.r1Anchor=!0),(e[6]||e[2]&&!e[7])&&(i.c2Anchor=!0),(e[8]||e[4]&&!e[9])&&(i.r2Anchor=!0),i}}function Lv(t){return(t+1).toString()}function Iv(t){return parseInt(t)-1}function Rv(t){++t;let e,i="";for(;t>0;)e=(t-1)%26,i=String.fromCharCode(e+65)+i,t=(t-e-1)/26;return i}function Tv(t){const e=t.length;let i=0;for(let o=0;o<e;o++)i+=(t.charCodeAt(o)-64)*Math.pow(26,e-o-1);return i-1}function $v(t){return t.sort(((t,e)=>{const i=Math.min(t.r1,t.r2),o=Math.min(e.r1,e.r2),r=Math.min(t.c1,t.c2),s=Math.min(e.c1,e.c2);return i<o?-1:i>o?1:r<s?-1:s>r?1:0}))}function Av(t){return t.formula.cells.map((e=>t.cell.model.getCellByRange(e[1])))}function Dv(t){let e=t;for(;Array.isArray(e);)e=e.length>0?e[0]:null;return e}function Ov(t){return Array.isArray(t)?t:[[t]]}function Nv(t,e,i,o){if(!Array.isArray(t))return e(t,i,o);for(let o=0;o<t.length;o++)if(!1===Nv(t[o],e,null==i?o:i,null==i?void 0:o))return!1}Ev.fromA1s=(t,e=";")=>t.split(e).map((t=>Ev.fromA1(t))),Ev.toA1s=(t,e=";")=>t.map((t=>t.A1)).join(e),Ev.fromCoords=t=>new Ev(t.c1,t.r1,t.c2,t.r2),Ev.fullColumn=t=>new Ev(t,0,t,1/0),Ev.fullRow=t=>new Ev(0,t,1/0,t);const Pv=new Set(["SUMPRODUCT","FILTER"]),jv=t=>Pv.has(t),Hv=t=>!!(t&&t.length>0&&"="==t.charAt(0)),Fv=t=>Hv(t)?t:"="+(t??""),Bv=t=>Hv(t)?t.substring(1):t,Wv=["#5B97FF","#FF616B","#B77CFF","#00B02C","#FC58BE","#FF9000","#2EB0B3"],Vv=t=>Wv[t%Wv.length],Uv=new Map([["FORMULATEXT","_xlfn."],["CONCAT","_xlfn."],["INDIRECT","_xlfn."],["ISOWEEKNUM","_xlfn."],["SWITCH","_xlfn."],["XOR","_xlfn."]]);class Gv{get fn(){return this._fn??(this._fn=new Function("t","ctx","return "+this.compile()))}get tokens(){return this._tokens}get variables(){return this._variables}get cells(){return this._cells}get ranges(){return this._ranges}get colors(){if(!this._colors){let t;this._colors=new Map,this._tokens.forEach(((e,i)=>{if([yv.Cell,yv.Range].includes(e[1])){const o=(t?"'"+t+"'!":"")+e[0];this._colors.set(o,{color:Vv(this._colors.size),address:e[0],sheet:t,type:e[1],tokenIndex:i}),t=null}else e[1]==yv.Sheet&&(t=e[0])}))}return this._colors}constructor(t,e){this.expression=t,this.tokenizer=e,this._tokens=e.tokenize(this.expression),this.updateDependecies()}findTokenIndexAtPosition(t){let e=0;return this._tokens.findIndex((i=>{const o=i[0].length;if(t>=e&&t<=e+o)return!0;e+=o}))}findSheetTokenIndex(t){const e=this._tokens[t];if(![yv.Cell,yv.Range].includes(e[1]))return-1;if(0==t||this._tokens[t-1][1]!=yv.SheetSeparator)return-1;let i=t-2;for(;i>=0;){if(this._tokens[i][1]==yv.Sheet)return i;i--}return-1}removeSheetToken(t){if(this._tokens[t][1]!=yv.Sheet&&(t=this.findSheetTokenIndex(t)),t>-1){t>0&&this._tokens[t-1][1]==yv.SheetQuote&&t--;let e=t;for(;e<this._tokens.length&&[yv.SheetSeparator,yv.SheetQuote,yv.Sheet].includes(this._tokens[e][1]);)e++;return this._tokens.splice(t,e-t),e-t}return 0}getNamedColor(t){return this.colors.get(t)?.color??"inherit"}getTokenPosition(t){let e=0;for(let i=0;i<t;i++)e+=this._tokens[i][0].length;return{min:e,max:e+this._tokens[t][0].length}}updateToken(t,e){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens[t][0]=e}removeToken(t){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens.splice(t,1)}insertToken(t,e,i){this._fn=null,this._formula=null,this._xlFormula=null;const o=[];return i==yv.Sheet&&/\s/.test(e)?(o.push([this.tokenizer.options.sheetQuote,yv.SheetQuote]),o.push([e,yv.Sheet]),o.push([this.tokenizer.options.sheetQuote,yv.SheetQuote])):o.push([e,i]),o.push(["!",yv.SheetSeparator]),this._tokens.splice(t,0,...o),o.length}clone(){return new Gv(this.createFormulaString(),this.tokenizer)}updateDependecies(){let t;this._variables=[],this._cells=[],this._ranges=[],this._tokens.forEach(((e,i)=>{switch(e[1]){case yv.Sheet:t=e[0];break;case yv.Variable:this._variables.push([i,e[0],t]),t=void 0;break;case yv.Cell:this._cells.push([i,Ev.fromA1(e[0]),t]),t=void 0;break;case yv.Range:this._ranges.push([i,Ev.fromA1(e[0]),t]),t=void 0}}))}createFormulaString(t=!1,e=!1){const i=this.tokenizer.options;let o,r,s,n="";for(let l=0;l<this._tokens.length;l++)switch(o=this._tokens[l],o[1]){case yv.SheetQuote:n+="'";break;case yv.SheetSeparator:n+="!";break;case yv.Sheet:r=o[0],n+=t?`<span style="font-style:italic">${r}</span>`:r;break;case yv.Variable:n+=o[0];break;case yv.Range:case yv.Cell:s=(r?"'"+r+"'!":"")+o[0],n+=t?`<span style="color:${this.getNamedColor(s)}">${o[0]}</span>`:o[0],r=null;break;case yv.StringQuote:n+=i.stringQuote;break;case yv.String:n+=o[0].replace(new RegExp(i.stringQuote,"g"),"\\"+i.stringQuote);break;case yv.ArgumentSeparator:n+=i.argumentSeparator;break;case yv.Function:n+=(e?(a=o[0],Uv.get(a)??""):"")+o[0];break;case yv.Unknown:n+=t?`<span style="background:#f00;color:#fff">${o[0]}</span>`:o[0];break;default:n+=o[0]}var a;return n}createExpressionTree(){const t=[],e=[],i=this.tokens;let o,r,s,n,a,l=null;for(let c=0;c<i.length;c++)switch(o=i[c],o[1]){case yv.Sheet:l=o[0];break;case yv.Cell:case yv.Range:t.push({t:o[0],tt:o[1],s:l}),l=null;break;case yv.Number:case yv.String:case yv.Boolean:case yv.Variable:t.push({t:o[0],tt:o[1]});break;case yv.Operator:for(0==t.length&&t.push({t:"",tt:yv.Operand}),s=pv.get(o[0]);e.length>0&&(n=pv.get(e[e.length-1][0]),n)&&(0===s[2]&&s[1]<=n[1]||1===s[2]&&s[1]<n[1]);)r=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:r[0],tt:r[1],c:a});e.push(o);break;case yv.Function:case yv.OpenBracket:e.push(o);break;case yv.ArgumentSeparator:for(;e.length>0&&(r=e[e.length-1],![yv.OpenBracket,yv.ArgumentSeparator].includes(r[1]));)r=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:r[0],tt:r[1],c:a});e.push(o);break;case yv.CloseBracket:for(a=[];e.length>0&&e[e.length-1][1]!==yv.OpenBracket;)r=e.pop(),r[1]==yv.Operator?a.push({t:r[0],tt:r[1],c:[t.pop(),t.pop()].reverse()}):r[1]==yv.ArgumentSeparator&&t.length>0&&a.push(t.pop());e.pop(),e.length>0&&e[e.length-1][1]===yv.Function?(r=e.pop(),a=a.reverse(),t.length>0&&i[c-1][1]!==yv.OpenBracket&&a.unshift(t.pop()),t.push({t:r[0],tt:r[1],c:a})):t.push(...a)}for(;e.length>0;)r=e.pop(),t.push({t:r[0],tt:r[1],c:[t.pop(),t.pop()].reverse()});return t.pop()}createExpressionJSCode(t,e,i){let o;switch(t.tt){case yv.Range:return"t.rn('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.Cell:return"t.cl('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.Operand:return"t.cl()";case yv.Variable:return i||e?.tt===yv.Function?"t.nr('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")":"t.nv('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.String:return"'"+t.t.replace(/'/g,"\\'")+"'";case yv.Boolean:return"T"==t.t[0].toUpperCase()?"1":"0";case yv.Function:return o=t.c.map((e=>this.createExpressionJSCode(e,t,i||jv(t.t)))),"t.fn('"+t.t+"').call(ctx"+(o.length>0?","+o.join(","):"")+")";case yv.Operator:return i?(o=t.c.map((e=>this.createExpressionJSCode(e,t,i||jv(t.t)))),"t.op("+o[0]+","+o[1]+",'"+t.t+"')"):pv.has(t.t)?"("+t.c.map((e=>this.createExpressionJSCode(e,t,i))).join(pv.get(t.t)[0])+")":null;default:return t.t}}compile(){const t=this.createExpressionTree();return this.createExpressionJSCode(t)}toString(t=!1){return(t?"=":"")+(this._formula??(this._formula=this.createFormulaString()))}toExcelString(){return this._xlFormula??(this._xlFormula=this.createFormulaString(!1,!0))}shift(t){const{index:e,offset:i,direction:o,maxIndex:r,sheet:s,allSheets:n}=t;return this._cells&&this._cells.forEach((t=>{if(n||null==t[2]||t[2]==s){switch(o){case"up":t[1].shiftUp(e,i,r);break;case"right":t[1].shiftRight(e,i,r);break;case"down":t[1].shiftDown(e,i,r);break;case"left":t[1].shiftLeft(e,i,r)}this._tokens[t[0]][0]=t[1].A1}})),this._ranges&&this._ranges.forEach((t=>{if(n||null==t[2]||t[2]==s){switch(o){case"up":t[1].shiftUp(e,i,r);break;case"right":t[1].shiftRight(e,i,r);break;case"down":t[1].shiftDown(e,i,r);break;case"left":t[1].shiftLeft(e,i,r)}this._tokens[t[0]][0]=t[1].A1}})),this}hasSheetReference(t){for(const e of this._cells)if(e[2]==t)return!0;for(const e of this._ranges)if(e[2]==t)return!0;for(const e of this._variables)if(e[2]==t)return!0;return!1}renameSheet(t,e){let i=!1;return this._tokens.forEach((o=>{o[1]==yv.Sheet&&o[0]==t&&(o[0]=e,i=!0)})),i}}function qv(t,e){return e&&(t=gr(this.cell.model.options.locale,yr(e,"d"),!1)(t)),null==t?"":t.toString()}function Yv(t,e){return(t=null==t?"":t.toString()).substring(0,e)}function Zv(t,e){return(t=null==t?"":t.toString()).substring(Math.max(0,t.length-e),t.length)}function Xv(t,e,i){return(t=null==t?"":t.toString()).substring(e,e+i)}function Qv(...t){let e="";return Nv(t,(t=>e+=null==t?"":t.toString())),e}function Kv(...t){return Qv(...t)}function Jv(t){return(t=null==t?"":t.toString()).length}function tb(t){return(t=null==t?"":t.toString()).toLowerCase()}function eb(t){return(t=null==t?"":t.toString()).toUpperCase()}function ib(t){return t instanceof Date?t:Q(t)?Xo(t,Lo()):nr(t)}function ob(t){return tt(t)?t:sr(t instanceof Date?t:Xo(t,Lo()))}function rb(t){return Q(t)?ob(t):t}function sb(t,e){const i=ib(t).getDay();switch(e){case 2:return i;case 3:return i-1;default:return i%7+1}}function nb(t,e,i){return ar(ob(Dv(t)),e)}function ab(){return sr(le(new Date))}function lb(t){return null==(t=Dv(t))||""===t}function cb(t,e,i){return sr(new Date(t,e-1,i))}function hb(t){return ib(t).getFullYear()}function db(t){return ib(t).getMonth()+1}function ub(t){return ib(t).getDate()}function pb(t,e){const i=ib(t);return i.setMonth(i.getMonth()+e+1),i.setDate(0),sr(i)}function gb(t){return Ci(ib(t))}function mb(t){return Math.acos(t)}function fb(t){return Math.acosh(t)}function vb(t){return Math.PI/2-Math.atan(t)}function bb(t){return.5*Math.log((t+1)/(t-1))}function yb(t){return Math.asin(t)}function wb(t){return Math.asinh(t)}function xb(t){return Math.atan(t)}function kb(t){return Math.atanh(t)}function Cb(t){return Math.cos(t)}function Mb(t){return Math.cosh(t)}function _b(t){return 1/Math.tan(t)}function Sb(t){return 1/Math.tanh(t)}function zb(t){return 1/Math.sin(t)}function Eb(t){return 1/Math.sinh(t)}function Lb(t){return 180*t/Math.PI}function Ib(){return Math.PI}function Rb(t){return 1/Math.cos(t)}function Tb(t){return 1/Math.cosh(t)}function $b(t){return Math.sin(t)}function Ab(t){return Math.sinh(t)}function Db(t){return Math.tan(t)}function Ob(t){return Math.tanh(t)}function Nb(t){return Math.abs(t)}function Pb(t){if(t<0)throw new Error("#NUM");return Math.ceil(t)}function jb(t){return(t=Math.ceil(t))%2==0?t:t+1}function Hb(t){return Math.pow(Math.E,t)}function Fb(t){return t<0?-1:0==t?1:t*Fb(t-1)}function Bb(t){return t<=0?1:t*Bb(t-2)}function Wb(t){return Math.floor(t)}function Vb(t){return t%1!=0}function Ub(t){return!Vb(t)&&t%2==0}function Gb(t){return Vb(t)||t%2==1}function qb(t){return Math.log(t)}function Yb(t,e){return Math.log(t)/Math.log(e)}function Zb(t){return Math.log10(t)}function Xb(t,e){return t%e}function Qb(t){return(t=Math.ceil(t))%2==0?t+1:t}function Kb(t,e){return Math.pow(t,e)}function Jb(...t){let e=1;return Nv(t,(t=>e*=t||1)),e}function ty(t,e){return Math.floor(t/e)}function ey(t){return t*Math.PI/180}function iy(){return Math.random()}function oy(t,e){const i=Array(t).fill(null).map((()=>Array(e)));for(let o=0;o<t;o++)for(let t=0;t<e;t++)i[o][t]=Math.random();return i}function ry(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function sy(t,e){return t.toFixed(e)}function ny(t,e){return e=e||0,Math.floor(t*Math.pow(10,e))/Math.pow(10,e)}function ay(t,e){return e=e||0,Math.ceil(t*Math.pow(10,e))/Math.pow(10,e)}function ly(t,e,i=1,o=1){const r=Array(t).fill(null).map((()=>Array(e)));let s=i;for(let i=0;i<t;i++)for(let t=0;t<e;t++)r[i][t]=s,s+=o;return r}function cy(t){return t<0?-1:t>0?1:0}function hy(t){return Math.sqrt(t)}function dy(t){return Math.sqrt(Math.PI*t)}function uy(...t){let e=0;return Nv(t,(t=>e+=null==t?0:1)),e}function py(...t){let e=0;return Nv(t,(t=>e+=null==t?1:0)),e}function gy(t,e){let i=0;return Nv(t,(t=>i+=uv(e,t)?1:0)),i}function my(...t){let e=0;const i=new Map;return Nv(t,(t=>{i.has(t)||(i.set(t,t),++e)})),e}function fy(...t){let e=0;return Nv(t,(t=>e+=isNaN(t)||null==t||""===t?0:t)),e}function vy(t,e,i){let o=0;if(i){const r=Ov(i);Nv(t,((t,i,s)=>o+=uv(e,t)&&r[i]&&r[i][s]&&!isNaN(r[i][s])?r[i][s]:0))}else Nv(t,(t=>o+=uv(e,t)&&!isNaN(t)?t:0));return o}function by(t,e){let i=0;return Nv(t,(t=>i+=uv(e,t)&&!isNaN(t)?t*t:0)),i}function yy(...t){let e=0;const i=t.shift();if(0===t.length)Nv(i,(t=>e+=isNaN(t)?0:t));else{const o=Ov(t[0]);Nv(i,((t,i,r)=>e+=o[i]&&o[i][r]&&!isNaN(t)&&!isNaN(o[i][r])?t*o[i][r]:0))}return e}function wy(t,e){return t=null==t?"":t.toString(),e?e=>e==t:(t=t.toLowerCase(),e=>(e??"").toString().toLowerCase()==t)}function xy(t,e,i=1){const o=new Ev(Math.max((e||0)-1,0),Math.max((t||0)-1,0));return 1!=i&&2!=i||(o.r1Anchor=!0),1!=i&&3!=i||(o.c1Anchor=!0),o.A1}function ky(t,e,i,o=!1){let r,s;const n=wy(t,o);for(r=0;r<e.length;r++)for(s=0;s<e[r].length;s++)if(n(e[r][s]))return e[r][i-1];return null}function Cy(t,e,i,o=!1){let r,s;const n=wy(t,o);for(r=0;r<e.length;r++)for(s=0;s<e[r].length;s++)if(n(e[r][s]))return e[i-1][s];return null}function My(t,e,i){let o,r;t:for(o=0;o<e.length;o++)for(r=0;r<e[o].length;r++)if(e[o][r]==t)break t;return i?i[o]?i[o][r]:null:e[o][e[o].length-1]}function _y(t,...e){let i=null,o=0;return Nv(e,(e=>{if(t==++o)return i=e,!1})),i}function Sy(t){return(t?Ev.fromA1(t).c1:this.cell.c)+1}function zy(t){return(t?Ev.fromA1(t).r1:this.cell.r)+1}function Ey(t){return Array.isArray(t)?t[0]?.length:1}function Ly(t){return Array.isArray(t)?t.length:1}function Iy(){const t=Av(this)[0];return t&&t.hasFormula?" "+Fv(t.formula):""}function Ry(t,e,i){return e=e||1,i=i||1,Array.isArray(t)?t[e-1]?t[e-1][i-1]:null:1==e&&1==i?t:null}function Ty(t){const e=this.cell,i=e.model,o=i.getCellByA1(t);let r;return i.calculations.dependencies.cellDependencies.has(e.address)?r=i.calculations.dependencies.cellDependencies.get(e.address):(r=new Map,i.calculations.dependencies.cellDependencies.set(e.address,r)),r.set(o.address,[o.range]),i.calculations.dependencies.cellDependants.has(o.address)?r=i.calculations.dependencies.cellDependants.get(o.address):(r=new Map,i.calculations.dependencies.cellDependants.set(o.address,r)),r.set(e.address,[e.range]),o.value}function $y(t,e,i=0){let o,r;for(o=0;o<e.length;o++)for(r=0;r<e[o].length;r++){if(0==i&&e[o][r]==t)return Math.max(o+1,r+1);if(1==i&&e[o][r]>t)return Math.max(o+1,r+1);if(-1==i&&e[o][r]<t)return Math.max(o+1,r+1)}return null}function Ay(t,e,i,o,r){const s=Av(this)[0],n=[];o=o||1,r=r||1;for(let t=0;t<o;t++){const o=[];for(let n=0;n<r;n++){const r=s.model.rows[s.r+t+e].cell(s.c+n+i);o.push(r?s.value:null)}n.push(o)}return n}function Dy(t,e){const i=[];if(t.length==e.length)for(let o=0;o<t.length;o++){let r=!0;for(let t=0;t<e[o].length;t++)if(!e[o][t]){r=!1;break}r&&i.push(t[o])}return i}const Oy=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Ny=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]];function Py(t){const e=t*t;let i,o=Oy[0][4]*e,r=e;for(i=0;i<3;i+=1)o=(o+Oy[0][i])*e,r=(r+Ny[0][i])*e;return t*(o+Oy[0][3])/(r+Ny[0][3])}function jy(...t){let e=!0;return Nv(t,(t=>{if(!t)return e=!1})),e}function Hy(...t){let e=!1;return Nv(t,(t=>{if(t)return e=!0})),e}function Fy(...t){let e=null;return Nv(t,(t=>{e=null===e?!!t:!!t!=e})),e}function By(...t){const e=t[0];for(let i=1;i<t.length;i+=2){if(i==t.length-1)return t[i];if(e==t[i])return t[i+1]}return null}function Wy(t,e,i){return t?e:i}function Vy(t){return!t}function Uy(){return!1}function Gy(){return!0}function qy(t,e){return e=""===e?null:e,this.cell.hasError?(this.cell.error.handled=!0,e):t===1/0||t===-1/0||Number.isNaN(t)?e:t}var Yy=i(235),Zy=i.n(Yy),Xy=i(5949),Qy=i.n(Xy);function Ky(...t){let e=0,i=0;return Nv(t,(t=>{null==t||isNaN(t)||(e+=t||0,++i)})),e/i}function Jy(t,e){const i=Qy()(),o=Ov(t),r=Ov(e);for(let t=0;t<o.length;t++)for(let e=0;e<o[t].length;e++)i(o[t][e],(r[t]?r[t][e]:1)??1);return i()}function tw(...t){const e=function(t){const e=[];return Nv(t,(t=>e.push(t))),e}(t),i=Zy()(e.length,e,1);return e.reduce(((t,e)=>t+Math.abs(e-i)),0)/e.length}function ew(...t){let e=1/0;return Nv(t,(t=>e=Math.min(e,t))),e}function iw(...t){let e=-1/0;return Nv(t,(t=>e=Math.max(e,t))),e}function ow(t,e){Object.keys(e).forEach((i=>t.set(nt(i,"_").replace(/_/g,".").toUpperCase(),e[i])))}const rw=new Map;ow(rw,_),ow(rw,S),ow(rw,z),ow(rw,E),ow(rw,I),ow(rw,L),ow(rw,R);class sw{constructor(t){this.model=t,this.getModel=t=>{const e=t?this.model.getConnectedModel(t):this.model;if(e)return e;throw new Error(`Sheet "${t}" not found`)},this.cl=(t,e)=>{const i=this.getModel(e);if(null==t)return this.currentCell.value;const o=i.getCellByA1(t);return o?o.value:(this.currentCell.error={message:`undefined cell ${t}`},null)},this.rn=(t,e)=>this.getModel(e).getValuesInRange(Ev.fromA1(t)),this.nv=(t,e)=>this.getModel(e).getCellByName(t,this.currentCell.range).value,this.nr=(t,e)=>{const i=this.getModel(e).getValueMatrixByName(t);return 1===i.length&&1===i[0].length?i[0][0]:i},this.fn=t=>{const e=rw.get(t);if(e)return e;throw new Error(`Function "${t}" not found`)},this.op=(t,e,i)=>bv(t,e,i)}}function nw(t,e){const i=Array(e).fill(null);let o=0,r=[];if(t.length>1){r=t.map((t=>parseFloat(t.value)||0)),o=r[1]-r[0];for(let t=2;t<r.length;t++)if(r[t]-r[t-1]!==o){o=0;break}}if(0==o)for(let o=0;o<e;o++)i[o]=t[o%t.length]?.value;else{let t=r[r.length-1];for(let r=0;r<e;r++)t=i[r]=t+o}return i}function aw(t,e,i){const o=new Gv(t.formula,t.model.calculations.tokenizer),r=[];for(let t=0;t<i;t++)r.push(Fv(o.shift({index:0,offset:1,direction:e,allSheets:!0}).createFormulaString()));return r}function lw(t,e,i,o){const r=t.getCellMatrix(e);let s;"right"==o?s=Xr(r):"down"==o?s=Zr(r):"left"==o?s=qr(r):"up"==o&&(s=qr(Zr(r)));const n=new Array(i.size.rows);for(let t=0;t<i.size.rows;t++){n[t]=new Array(i.size.columns);for(let e=0;e<i.size.columns;e++){const i=r.length>t?r[t][r[t].length>e?e:0]:r[0][e];n[t][e]=i.hasDisplayValue?i.displayValue:null}}const a=i.size["down"==o||"up"==o?"rows":"columns"];let l=s.map((t=>t[t.length-1].hasFormula?aw(t[t.length-1],o,a):nw(t,a)));return"down"==o?l=Zr(l):"left"==o?l=qr(l):"up"==o&&(l=Yr(Zr(l))),t.spillValues({cell:t.getCellByRange(i.bounds[0][0]),values:l,propertyCell:t.getCellByRange(e.bounds[0][0]),displayValues:n})}function cw(t){return t.pattern&&"string"==typeof t.pattern&&(t.pattern=new RegExp(t.pattern)),t}function hw(t,e){const i=t.validation;if(!i)return!0;if(i.allowInvalid)return!0;let o=!0;return i.pattern&&(i.pattern.test((e??"").toString())||(o=!1)),i.validate&&(i.validate(t,e)||(o=!1)),o}class dw{get address(){return null}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get afterRenderer(){return this._afterRenderer}set afterRenderer(t){this._afterRenderer=t}get commentRenderer(){return this._commentRenderer}set commentRenderer(t){this._commentRenderer=t}get type(){return this._type}set type(t){this._type=t}get name(){return this._name}set name(t){this._name=t}get style(){return this._style}set style(t){this._style=t}get commentable(){return this._commentable}set commentable(t){this._commentable=t}get clickable(){return this._clickable}set clickable(t){this._clickable=t}get editable(){return this._editable}set editable(t){this._editable=t}get validation(){return this._validation}set validation(t){this._validation=t}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){this._formula=t?t.replace(/^=/,""):null}get value2(){return this.hasFormula?Fv(this.formula):null}get editorContent(){return this._editorContent}set editorContent(t){this._editorContent=t}get adapter(){return this._adapter}set adapter(t){this._adapter=t}get properties(){return this._properties}set properties(t){this._properties=t}getProperty(t){return this._properties?.[t]}setProperty(t,e){this._properties||(this._properties={}),this._properties[t]=e}get format(){return this._format}set format(t){this._format=t,this._valueFormatter=null}get valueFormatter(){return this._valueFormatter}constructor(t,e){this.model=t,this._type=null,this._clickable=!1,e&&this.populate(e)}populate(t){this._renderer=t.renderer,this._afterRenderer=t.afterRenderer,this._commentRenderer=t.commentRenderer,this._name=t.name,this._type=t.t,this._editorContent=t.content,this._adapter=t.adapter,this._format=t.z,this._formula=t.f,this._editable=t.e,this._commentable=t.commentable,this._clickable=t.clickable,this._validation=t.validation?cw(t.validation):null,this._properties=t.props,this._style=null==t.s?null:this.model.styles.add(t.s)?.id}update(t){const e={};if("renderer"in t&&(e.renderer=this._renderer,this._renderer=t.renderer),"afterRenderer"in t&&(this._afterRenderer=t.afterRenderer),"commentRenderer"in t&&(this._commentRenderer=t.commentRenderer),"name"in t&&(e.name=this._name,this._name=t.name),"t"in t&&(e.t=this._type,this._type=t.t),"content"in t&&(e.content=this._editorContent,this._editorContent=t.content),"adapter"in t&&(e.adapter=this._adapter,this._adapter=t.adapter),"z"in t&&(e.z=this._format,this._format=t.z),"f"in t&&(e.f=this._formula,this._formula=t.f),"e"in t&&(e.e=this._editable,this._editable=t.e),"commentable"in t&&(e.commentable=this._commentable,this._commentable=t.commentable),"clickable"in t&&(e.clickable=this._clickable,this._clickable=t.clickable),"validation"in t&&(e.validation=this._validation,this._validation=cw(t.validation)),"props"in t&&(e.props=this._properties,this._properties=t.props),"s"in t){const i=this.model.styles.add(t.s).id;this._style!==i&&(e.s=this._style,this._style=i)}return e}getSourceData(){const t={};return null!=this._type&&(t.t=this._type),null!=this._format&&(t.z=this._format),null!=this._formula&&(t.f=this._formula),null!=this._editable&&(t.e=this._editable),null!=this._commentable&&(t.commentable=this._commentable),null!=this._clickable&&(t.clickable=this._clickable),this._properties&&(t.props=rt(this._properties)),null!=this._editorContent&&(t.content=Z(this._editorContent)?rt(this._editorContent):this._editorContent),null!=this._style&&(t.s=this._style),null!=this._name&&(t.name=this._name),t}setStyleProperties(t,e=!1){this.style=e?this.model.styles.set(this.style,t).id:this.model.styles.duplicate(this.style,t).id}removeStyleProperties(t){null!==this.style&&this.model.styles.unset(this.style,t)}get composedStyle(){return this.model.styles.get(this.style)}}function uw(t){const e={};return t.split(";").forEach((t=>{const[i,o]=t.split(":");e[i]=o.trim()})),e}const pw=new Map([["thin",{width:1.5,style:"solid"}],["medium",{width:2,style:"solid"}],["thick",{width:3,style:"solid"}],["double",{width:3,style:"double"}],["dotted",{width:1.5,style:"dotted"}],["hair",{width:1,style:"solid"}],["dashed",{width:1.5,style:"dashed"}],["mediumDashed",{width:2,style:"dashed"}],["dashDot",{width:1.5,style:"dashed"}],["mediumDashDot",{width:2,style:"dashed"}],["dashDotDot",{width:1.5,style:"dotted"}],["mediumDashDotDot",{width:2,style:"dotted"}],["slantDashDot",{width:1.5,style:"dashed"}],["none",{width:1.5,style:"solid"}]]),gw=(()=>{const t=new Map;return pw.forEach(((e,i)=>{let o=t.get(e.style);o||(o=t.set(e.style,new Map).get(e.style)),o.set(e.width,i)})),t})();function mw(t){return"middle"==t?"center":t}function fw(t){return t="#"==t.charAt(0)?t.substring(1):t,/^[0-9a-fA-F]{3}$/.test(t)?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(t)?t:Wr(Br(t))}const vw=t=>{if("none"==t)return null;const e=t.split(" "),i=parseInt(e[0].charAt(0))||1,o=e.length>1?e[1]:"solid",r=gw.get(o);return{style:(r?r.get(i):null)??"thin",color:e.length>2?fw(e[2]):"CCCCCC"}},bw=t=>{const e=pw.get(t.style||"none");return e?[Ot(e.width),e.style,"none"==t.style?"var(--og-cell-background)":t.color?`#${t.color}`:"var(--og-border-color)"].join(" "):"none"},yw=(t,e)=>{const i="#"+(e.fgColor||"000000"),o="#"+(e.bgColor||"FFFFFF");switch(e.patternType){case"solid":t.backgroundColor=i||o;break;case"darkGray":t.backgroundColor=Nr(o,.75);break;case"mediumGray":t.backgroundColor=Nr(o,.5);break;case"lightGray":t.backgroundColor=Nr(o,.25);break;case"gray125":t.backgroundColor=Nr(o,.125);break;case"gray0625":t.backgroundColor=Nr(o,.0625);break;case"darkHorizontal":t.backgroundImage=`linear-gradient(0deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkVertical":t.backgroundImage=`linear-gradient(90deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkDown":t.backgroundImage=`linear-gradient(45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkUp":t.backgroundImage=`linear-gradient(-45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"lightHorizontal":t.backgroundImage=`linear-gradient(0deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightVertical":t.backgroundImage=`linear-gradient(90deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightDown":t.backgroundImage=`linear-gradient(45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightUp":t.backgroundImage=`linear-gradient(-45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"darkGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px";break;case"darkTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px"}return t},ww=(t,e)=>(t.backgroundImage=`linear-gradient(${(e.angle??0)+90}deg,${e.stops.map((t=>`#${t.rgb} ${100*t.v}%`)).join(",")})`,t),xw=t=>{const e=t.cssStyle?{...t.cssStyle}:{};return null!=t.bold&&(e.fontWeight=t.bold?"bold":"normal"),t.italic&&(e.fontStyle="italic"),t.underline?e.textDecoration="underline":t.strike&&(e.textDecoration="line-through"),t.sz&&(e.fontSize=Dt(t.sz)),t.color&&(e.color="#"+t.color),t.top&&(e.borderTop=bw(t.top)),t.right&&(e.borderRight=bw(t.right)),t.bottom&&(e.borderBottom=bw(t.bottom)),t.left&&(e.borderLeft=bw(t.left)),(t.top||t.right||t.bottom||t.left)&&(e.zIndex="1"),t.alignment&&t.alignment.vertical&&(e.display="flex",e.justifyContent=t.alignment.horizontal,e.alignItems="top"==t.alignment.vertical?"start":"bottom"==t.alignment.vertical?"end":"center"),t.alignment&&t.alignment.horizontal&&(e.textAlign=t.alignment.horizontal),t.alignment&&t.alignment.wrapText&&(e.display="flex",e.justifyContent=e.justifyContent??e.textAlign??"left",e.alignItems=e.alignItems??"center",e.whiteSpace="pre-wrap"),t.patternType?yw(e,t):t.stops&&t.stops.length?ww(e,t):t.fgColor?e.backgroundColor="#"+t.fgColor:t.bgColor&&(e.backgroundColor="#"+t.bgColor),e},kw=t=>{const e=Z(t)?t:uw(t),i={};let o;for(const t in e){const r=e[t];if(null!=r)switch(t){case"borderTop":case"border-top":i.top=vw(r);break;case"borderTopColor":case"border-top-color":i.top?i.top.color=fw(r):i.top={style:"thin",color:fw(r)};break;case"borderRight":case"border-right":i.right=vw(r);break;case"borderRightColor":case"border-right-color":i.right?i.right.color=fw(r):i.right={style:"thin",color:fw(r)};break;case"borderBottom":case"border-bottom":i.bottom=vw(r);break;case"borderBottomColor":case"border-bottom-color":i.bottom?i.bottom.color=fw(r):i.bottom={style:"thin",color:fw(r)};break;case"borderLeft":case"border-left":i.left=vw(r);break;case"borderLeftColor":case"border-left-color":i.left?i.left.color=fw(r):i.left={style:"thin",color:fw(r)};break;case"border":o=vw(r),i.top=i.top||o,i.right=i.right||o,i.bottom=i.bottom||o,i.left=i.left||o;break;case"textAlign":case"text-align":i.alignment=i.alignment||{},i.alignment.horizontal=r;break;case"verticalAlign":case"vertical-align":i.alignment=i.alignment||{},i.alignment.vertical=mw(r);break;case"whiteSpace":case"white-space":i.alignment=i.alignment||{},i.alignment.wrapText=r&&"nowrap"!=r;break;case"color":i.color=fw(r);break;case"background":case"backgroundColor":case"background-color":i.fgColor=fw(r);break;case"fontSize":case"font-size":i.sz=parseFloat(r);break;case"fontWeight":case"font-weight":i.bold="bold"==r;break;case"fontStyle":case"font-style":i.italic="italic"==r;break;default:i[t]=r}}return i},Cw={n:t=>{const e=Q(t)?parseFloat(t.replace(",",".")):t;return Number.isNaN(e)?t:e},t:t=>t,d:(t,e)=>{if(null==t||""===t)return null;if(Q(t))try{return K(t)?J(t):sr(Xo(t,e.model.options.formatLocale))}catch(i){return e.model.logger.error(`Invalid date value in cell ${e.address}: ${t}`),null}return t instanceof Date?sr(t):t},tm:t=>Q(t)?new Date(t):t,dt:t=>Q(t)?new Date(t):t,b:t=>!!t&&"0"!==t&&"false"!==t.toString().toLowerCase(),s:t=>t,m:t=>t,g:t=>{if(null==t||""===t)return null;const e=parseFloat(t.toString().replace(",","."));return isNaN(e)?t:e},a:t=>Q(t)&&""!==t?JSON.parse(t):t,h:t=>t},Mw=new Map;class _w extends dw{get tooltip(){return this._tooltip}set tooltip(t){this._tooltip=t}get hasTooltip(){return null!=this._tooltip}get merge(){return this.model.merges.mergedCells.get(this.address)}get row(){return this._row}set row(t){this._row=t}get r(){return this._row.index}get column(){return this._column}set column(t){this._column=t}get c(){return this._column.index}get hasValue(){return null!=this._value}get value(){return this._evaluated||this.evaluate(),this._value}set value(t){if(t&&Hv(t.toString()))this._value=void 0,this.formula=t;else{let e=Cw[this.type](t,this);hw(this,e)||(e=void 0),e!==this._value&&(this._value=e,this._displayValue=void 0),this.row.data&&this.column.data&&(this.row.data[this.column.data]=this._value)}}evaluate(){return this._value=Cw[this.type](this.model.calculations.evaluate(this),this),this._evaluated=!0,this._value}get value2(){return this.hasFormula?Fv(this.formula):this.value}get hasDisplayValue(){return null!=this._displayValue}get displayValue(){return this._displayValue}set displayValue(t){this._displayValue=t}get prefersDisplayValue(){return["s","m"].includes(this.type)}get error(){return this._error}set error(t){this._error=t}get hasError(){return!!this._error}clearError(){this._error=void 0}get spillRange(){return this._spillRange}get prevSpillRange(){return this._prevSpillRange}set spillRange(t){!this._spillRange||t&&this._spillRange.equals(t)||(this._prevSpillRange=this._spillRange),this._spillRange=t}get isSpillSource(){return null!=this._spillRange}get spillSource(){return this._spillSource}get isSpilled(){return null!=this._spillSource}spillValue(t,e){this.value=t,this._spillSource=e}clearSpilledValue(){this._spillSource=void 0,this._value=void 0}get hasSparkline(){return null===this._sparkline?this._sparkline=this.model.sparklines.has(this.address):this._sparkline}get hasComment(){return null===this._hasComment?this._hasComment=(this.model.comments.get(this.address)??[]).length>0:this._hasComment}get comments(){return this.model.comments.get(this.address)}get valueFormatter(){const t=super.valueFormatter??this.row.valueFormatter??this.column.valueFormatter;if(t)return t;const e=this.type,i=this.format,{formatLocale:o,fixNumberFormat:r}=this.model.options,s=this.value;if(null==s||""===s)return null;if("n"==e)return null!=i?gr(o,i,r):this.model.options.numberFormatter;if("g"==e){if(null!=i)return gr(o,i,r);if(tt(s))return this.model.options.numberFormatter}else{if("t"==e)return null==i?null:gr(o,i,!1);if("d"==e)return i?Qo(o,i):this.model.options.dateFormatter;if("s"==e&&this.editorContent)return(t=>{if(t=t||null,!Mw.has(t))if(t){const e=t.reduce(((t,e)=>t.set(e.k,e.v)),new Map);Mw.set(t,(t=>e.has(t)?e.get(t):t))}else Mw.set(t,(t=>t));return Mw.get(t)})(this.editorContent)}return null}get formattedValue(){return null==this.value?"":this.hasDisplayValue?this.displayValue:this.valueFormatter?this.valueFormatter(this.value):this.value.toString()}get elm1(){return this.row.priority>=this.column.priority?this.row:this.column}get elm2(){return this.row.priority<this.column.priority?this.row:this.column}get clickable(){return super.clickable??this.elm1.clickable??this.elm2.clickable}get type(){return super.type??this.elm1.type??this.elm2.type??"g"}set type(t){this._type=t}get editorContent(){return super.editorContent??this.elm1.editorContent??this.elm2.editorContent??null}get adapter(){return super.adapter??this.elm1.adapter??this.elm2.adapter}set adapter(t){this._adapter=t}get address(){return this.column.address+this.row.address}get range(){return Ev.fromA1(this.address)}get validation(){return super.validation??this.elm1.validation??this.elm2.validation??this.model.options.cellValidation}get editable(){return super.editable??this.elm1.editable??this.elm2.editable??this.model.options.editable}set editable(t){this._editable=t}get commentable(){return super.commentable??this.elm1.commentable??this.elm2.commentable??this.model.options.commentable}get renderer(){return super.renderer??this.elm1.renderer??this.elm2.renderer}get afterRenderer(){return super.afterRenderer??this.elm1.afterRenderer??this.elm2.afterRenderer??this.model.options.afterRenderer}get commentRenderer(){return super.commentRenderer??this.elm1.commentRenderer??this.elm2.commentRenderer??this.model.options.comments.renderer}get format(){return super.format??this.elm1.format??this.elm2.format}set format(t){super.format=t}get hyperlink(){return this._hyperlink}set hyperlink(t){this._hyperlink=t}get hasOwnFormula(){return!!this._formula}get hasFormula(){return null==this._hasFormula&&(this._hasFormula=!!this.formula),this._hasFormula}get formula(){return this._formula??this.elm1.formula??this.elm2.formula}set formula(t){super.formula=t,this.refreshFormula()}invalidateValue(){this.hasFormula?(this._value=void 0,this._evaluated=!1):this._evaluated=!0,this.clearError()}refreshFormula(){this.invalidateValue(),this._hasFormula=null}clearFormula(){this._formula=null,this._hasFormula=!1,this._evaluated=!0}constructor(t,e){super(t),this._evaluated=!0,this._sparkline=null,this._hasComment=null,this._hasStyle=null,this.row=t.rows[e.r],this.column=t.columns[e.c],this.populate(e)}populate(t){super.populate(t),this._tooltip=t.tooltip,this._hyperlink=t.hl,null!=t.f&&""!==t.f?this._evaluated=!1:null!=t.v&&(this.value=t.v),this._displayValue=t.dv}update(t){const e=super.update(t);return"tooltip"in t&&(e.tooltip=this._tooltip,this._tooltip=t.tooltip),"hl"in t&&(e.hl=this._hyperlink,this._hyperlink=t.hl),"f"in t?this._evaluated=!1:"v"in t&&(e.v=this.value,this.value=t.v),"dv"in t&&(e.dv=this._displayValue,this._displayValue=t.dv),e}getSourceData(t){const e=super.getSourceData();return this.merge&&(e.cs=this.merge.cs,e.rs=this.merge.rs),null!=this.value&&(e.v=this.value),this.hasTooltip&&(e.tooltip=this._tooltip),this._hyperlink&&(e.hl=this._hyperlink),t&&t.displayValue&&this.hasDisplayValue&&(e.dv=this._displayValue),e}createComposedStyle(t,e,i){const o=[];return t=t||this.column.style,e=e||this.row.style,null!=t&&null!=e?this.column.priority>this.row.priority?o.push(e,t):o.push(t,e):null!=t?o.push(t):null!=e&&o.push(e),null!=this.style&&o.push(this.style),null!=i&&o.push(i),o.length>0?this.model.styles.merge(...o):null}get composedStyle(){if(null===this._hasStyle){const t=this.createComposedStyle(null,null,this.model.conditionalFormats.evaluate(this));this._hasStyle=null!=t,this._composedStyle=t}return this._composedStyle}get calculatedIndent(){const t=this.composedStyle;return t?.alignment?.indent?t.alignment.indent:this.column.levelIndent&&this.row.level>0?this.row.level*this.model.options.levelIndentFactor:null}get cssStyle(){if(!1===this._hasStyle)return null;if(!this._cssStyle){const t=this.composedStyle;t&&(this._cssStyle=xw(t))}return this._cssStyle}invalidateStyle(){this._hasComment=null,this._hasStyle=null,this._composedStyle=null,this._cssStyle=null,this._sparkline=null}setStyleProperties(t){super.setStyleProperties(t),this.invalidateStyle()}removeStyleProperties(t){super.removeStyleProperties(t),this.invalidateStyle()}previewStyleProperties(t,e="cell"){const i=Object.assign({},this.createComposedStyle("column"==e?t:null,"row"==e?t:null)??{});if("cell"==e)for(const e in t)i[e]=t[e];this._hasStyle=!0,this._cssStyle=xw(i)}validate(){return!this.validation||hw(this,this.value)}toString(){return this.address}}const Sw={property:"value",enabled:!0};class zw extends(Tr(dw)){get comparer(){return this._comparer}set comparer(t){this._comparer=t}get filter(){return this._filter??(this.model.options.filters?.enabled?Sw:{enabled:!1})}set filter(t){this._filter=t}get hasFilter(){return this.filter.enabled}get sorting(){return this._sorting??this.model.options.columnSorting}set sorting(t){this._sorting=t}get width(){return this._width??this.model.options.columnWidth}set width(t){this._width=t}get levelIndent(){return this._levelIndent}set levelIndent(t){this._levelIndent=t}get levelButtons(){return this._levelButtons}set levelButtons(t){this._levelButtons=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return Rv(this.index)}get range(){return new Ev(this.index,null,this.index,null)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t;const e=this.index;this.model.rows.forEach((t=>t.cells[e]?.refreshFormula()))}constructor(t,e){super(t,e),null==this._priority&&(this._priority=t.options.columnPriority)}get mergedHeaders(){return this._mergedHeaders??(this._mergedHeaders=this._header?.filter((t=>t.cs>1||t.rs>1))??[])}updateMergedHeaders(){this._mergedHeaders=null}set header(t){this._mergedHeaders=null,this._header=t}get header(){if(!this._header||this._header.length<this.model.headerCount){this._header=this._header??[];for(let t=this._header.length;t<this.model.headerCount;t++)this._header.push({r:t})}return this._header}hasHeaderTooltip(t){const e=this.header?.[t];return e&&null!=e.tooltip}convertSourceHeader(t){return Array.isArray(t)?t.map(((t,e)=>{if(null==(t=t??{r:e}).height&&(t.height=t.h),t.r=e,null==t.style&&(t.style=t.s),t._style=null==t.style?null:this.model.styles.add(t.style).id,null!=this.model.options.headers?.style){const e=this.model.styles.add(this.model.options.headers.style).id;t._style=this.model.styles.merge(t._style,e).id}return t})):Q(t)?[{label:t,r:0}]:null}populate(t){super.populate(t),this._width=null==t.w||"auto"==t.w?null:t.w,this._levelIndent=t.levelIndent,this._levelButtons=t.levelButtons,this._header=this.convertSourceHeader(t.header),this._sorting=t.sorting,this._filter=Z(t.filter)?Object.assign({enabled:!0},t.filter):t.filter?Sw:!1===t.filter?{enabled:!1}:null,this._comparer=t.comparer,this.data=t.data,this._mergedHeaders=null,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._width&&(t.w=this._width),null!=this._levelIndent&&(t.levelIndent=this._levelIndent),null!=this._levelButtons&&(t.levelButtons=this._levelButtons),null!=this._header&&(t.header=this._header),null!=this._sorting&&(t.sorting=this._sorting),null!=this._filter&&(t.filter=this._filter),null!=this.data&&(t.data=this.data),t}expand(t){super.expand(t),this.model.indexVisibleColumns()}collapse(){super.collapse(),this.model.indexVisibleColumns()}get prev(){return this.model.columns[this.index-1]}get next(){return this.model.columns[this.index+1]}get prevVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t||0===t?null:this.model.visibleColumns[t-1]}get nextVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t?null:this.model.visibleColumns[t+1]}calculateRealColspan(t){let e=1,i=this.nextVisible;for(;i&&i.index-this.index<t&&e<t;)++e,i=i.nextVisible;return e}cell(t){return this.model.rows[t].cell(this.index)}clearCalculatedValues(){this.model.rows.forEach((t=>{const e=t.cells[this.index];e&&this.model.calculations.refreshFormula(e)}))}}var Ew;!function(t){t[t.Asc=1]="Asc",t[t.Desc=-1]="Desc"}(Ew||(Ew={}));const Lw={g:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,t:(t,e)=>(t.value||"").toString().localeCompare((e.value||"").toString()),s:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,m:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,n:(t,e)=>t.value-e.value,d:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),tm:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),dt:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),b:(t,e)=>t.value-e.value,h:(t,e)=>(t.value||"").localeCompare(e.value),a:()=>0},Iw={g:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,t:(t,e)=>(e.value||"").toString().localeCompare((t.value||"").toString()),s:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,m:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,n:(t,e)=>e.value-t.value,d:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),tm:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),dt:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),b:(t,e)=>e.value-t.value,h:(t,e)=>(e.value||"").localeCompare(t.value),a:()=>0},Rw=(t,e)=>t.origIndex-e.origIndex;class Tw{get settings(){return this._settings}set settings(t){this._settings=t||[],this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applySort(),Lr().info(`sorting applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=null){this.model=t,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}sort(t,e=null,i=!1){let o=this.get(t);return o&&o.ord==Ew.Desc&&null===e?(this.settings.splice(this.colMap.get(t),1),o=null):o?(o.ord=Ew.Desc,this.settings.splice(this.colMap.get(t),1)):o={c:t,ord:Ew.Asc},o&&(null!==e&&(o.ord=e),this.colMap.set(t,0),this.settings.unshift(o)),this.settings.length>this.model.options.maxSortingColumns&&this.settings.pop(),this.colMap.clear(),this.settings.forEach(((t,e)=>{t.index=e,this.colMap.set(t.c,e)})),i||(this.settings.length>0?this.applySort():this.resetSort()),o}applySort(){const t=this.model,e=this.settings.map((e=>{const i=t.columns[e.c];return i?i.comparer?e.ord==Ew.Asc?i.comparer:(t,e)=>-i.comparer(t,e):e.ord==Ew.Asc?Lw[i.type??"t"]:Iw[i.type??"t"]:(Lr().warn(`Column sorting: Column with index ${e.c} not found`),null)})).filter((t=>t)),i=e.length;let o,r,s;t.rowRoot.sort(((t,n)=>{if(!1===t.sortable||!1===n.sortable)return t.origIndex-n.origIndex;for(r=0;r<i;r++)if(s=this.settings[r].c,o=e[r](t.cell(s),n.cell(s)),0!=o)return o;return 0})),t.indexRowsByTree()}resetSort(){this.settings=[],this.colMap.clear(),this.model.rowRoot.sort(Rw),this.model.indexRowsByTree()}persistSort(){this.model.rows.forEach(((t,e)=>t.origIndex=e))}}class $w{get properties(){return this._properties}set properties(t){this._properties=t}constructor(t){t&&this.pupulate(t)}pupulate(t){this.author=t.author,this.text=t.text,this.date=t.date?new Date(t.date):null,this.data=t.data,this.readOnly=!!t.readOnly,this._properties=t.props}getSourceData(){const t={};return this._properties&&(t.props=this._properties),this.author&&(t.author=this.author),this.text&&(t.text=this.text),this.data&&(t.data=this.data),null!==this.readOnly&&(t.readOnly=this.readOnly),this.date&&(t.date=Qo("en-US")(this.date,"yyyy-MM-dd HH:mm:ss")),t}}class Aw{constructor(t,e){this.model=t,this._commentMap=new Map,this.has=t=>this._commentMap.has(t),this.delete=t=>this._commentMap.delete(t),this.cleanCell=t=>{this.has(t)&&this._commentMap.set(t,this.get(t).filter((t=>(t.text??"").length>0||null!=t.data)))},this.get=t=>(this.has(t)||this._commentMap.set(t,[]),this._commentMap.get(t)),this.set=(t,e)=>{this._commentMap.set(t,e?.map((t=>t instanceof $w?t:new $w(t)))||[]),this.cleanCell(t)},e&&this.populate(e)}populate(t){t.forEach((t=>{const e=t.a1||new Ev(t.c,t.r).A1;this._commentMap.has(e)||this._commentMap.set(e,[]),this._commentMap.get(e).push(new $w(t))})),this._commentMap.forEach((t=>{t.sort(((t,e)=>(e.date?e.date.getTime():0)-(t.date?t.date.getTime():0)))}))}shift(t){Array.from(this._commentMap.keys()).forEach((e=>{const i=Ev.fromA1(e);i.shift(t),i.A1!=e&&(this._commentMap.set(i.A1,this._commentMap.get(e)),this._commentMap.delete(e))}))}}function Dw(t,e,i){t.forEach((t=>t.forEach((t=>{t[1]==e&&(t[1]=i)}))))}class Ow{get cellDependencies(){return this._cellDependencies}get cellDependants(){return this._cellDependants}get rangeDependencies(){return this._rangeDependencies}get rangeDependants(){return this._rangeDependants}get sheetDependencies(){return this._sheetDependencies}get sheetDependants(){return this._sheetDependants}constructor(t,e="calculations"){this.model=t,this.modelPart=e,this._cellDependencies=new Map,this._cellDependants=new Map,this._rangeDependencies=new Map,this._rangeDependants=new Map,this._sheetDependencies=new Map,this._sheetDependants=new Map}clear(){this._cellDependants.clear(),this._cellDependencies.clear(),this._rangeDependencies.clear(),this._rangeDependants.clear()}clearCellDependecies(t){return this._cellDependencies.has(t)&&this._cellDependencies.delete(t),this._rangeDependencies.has(t)&&this._rangeDependants.delete(t),this}has(t){return this._cellDependencies.has(t)||this._rangeDependencies.has(t)}add(t,e,i){const o=Ev.fromA1(t).removeAnchors(),r=Ev.fromA1(e).removeAnchors();e=r.A1;const s=r.isRange,n=s?this._rangeDependencies:this._cellDependencies;let a=null;if((n.has(t)?n.get(t):n.set(t,new Map).get(t)).set(e,[r,i]),i){const t=this.model.getConnectedModel(i);t&&(t.calculations.dependencies.sheetDependants.set(this.model.name,this.model.name),this.sheetDependencies.set(i,i),a=s?t.calculations.dependencies.rangeDependants:t.calculations.dependencies.cellDependants),i=this.model.name}else a=s?this._rangeDependants:this._cellDependants;a&&(a.has(e)||a.set(e,new Map),a.get(e).set(t,[o,i]))}getDependants(t,e=null){let i,o;const r=t.A1;return e=e??new Map,this._cellDependants.has(r)&&this._cellDependants.get(r).forEach((([t,s])=>{e.has(t)||(s&&(o=this.model.getConnectedModel(s)),i=o||this.model,e.set(t,[i.getCellByRange(t),s]),o?o[this.modelPart].dependencies.getDependants(t).forEach(((t,i)=>{e.set(i,[t[0],t[1]??s])})):(t.A1!=r||o)&&i.calculations.dependencies.getDependants(t,e))})),this._rangeDependants.forEach(((i,o)=>{Ev.fromA1(o).contains(t)&&i.forEach((([t,i])=>{e.has(t)||(e.delete(t),this.getDependants(t,e.set(t,[(i?this.model.getConnectedModel(i):this.model).getCellByRange(t),i])))}))})),e}renameSheet(t,e){this._sheetDependants.has(t)&&(this._sheetDependants.delete(t),this._sheetDependants.set(e,e)),this._sheetDependencies.has(t)&&(this._sheetDependencies.delete(t),this._sheetDependencies.set(e,e)),Dw(this._cellDependants,t,e),Dw(this._cellDependencies,t,e),Dw(this._rangeDependants,t,e),Dw(this._rangeDependencies,t,e)}}class Nw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this._dependencies=new Ow(t,e)}}function Pw(t){return t instanceof RangeError?"Maximum call stack size exceeded"==t.message?"infinite loop":t.message:t.toString()}class jw extends Nw{get tokenizer(){return this._tokenizer}get formulas(){return this._formulas}constructor(t){super(t,"calculations"),this._tokenizer=new _v,this._formulas=new Map,this.context=new sw(t)}createFormula(t){const e=new Gv(t.formula,this.tokenizer);return this._formulas.set(t.address,e),t.hasOwnFormula&&(t.formula=e.createFormulaString()),this.createDependecies(t),e}createDependecies(t){const e=t.address;if(this.formulas.has(e)){const i=this.formulas.get(e);i.ranges.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.cells.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.variables.forEach((([i,o])=>{const r=this.model.getCellByName(o,t.range);r&&this._dependencies.add(e,r.address,null)}))}return this}refreshFormula(t){return t.refreshFormula(),this.formulas.delete(t.address),this.clearDependecies(t),this}updateDependencies(t){return this.clearDependecies(t).getFormula(t),this}getFormula(t){return this._formulas.has(t.address)?this._formulas.get(t.address):this.createFormula(t)}refresh(){this.dependencies.clear(),this._formulas.clear()}clearDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.formulas.delete(e),this}evaluateFormula(t,e){return this.context.currentCell=e,t.fn(this.context,{cell:e,formula:t})}evaluateExpression(t,e){this.context.currentCell=e;const i=new Gv(t,this.tokenizer);return i.fn(this.context,{cell:e,formula:i})}evaluate(t,e){if(!t)return null;let i=null;if(t.hasFormula){const o=this.getFormula(t);try{t.clearError(),this.context.currentCell=t,i=o.fn(this.context,{cell:t,formula:o}),Array.isArray(i)?(e||this.model.spillValues({cell:t,values:i}).range,i=i.length>0&&i[0].length>0?i[0][0]:null,e&&(t.value=i)):t.value=i}catch(e){t.error={message:Pw(e)}}}else i=t.value;return i}evaluateAll(){this.model.rows.forEach((t=>this.model.columns.forEach(((e,i)=>t.cell(i).evaluate()))))}calculateViewport(t){const e=[];return t.rows.forEach((t=>t.cells.forEach((t=>{if(t.hasFormula){if(!t.hasValue&&(this.evaluate(t),t.spillRange))for(const i of this.model.getRangeIterator(t.spillRange))e.push(i);e.push(t)}})))),e}shift(t){this.getFormulaCells().forEach((e=>{e.formula=this.getFormula(e).shift(t).createFormulaString(!1),this.updateDependencies(e)}));const e=this.model.name;return this.dependencies.sheetDependants.forEach((i=>{const o=this.model.getConnectedModel(i);o?.calculations.getFormulaCells().forEach((i=>{const r=o.calculations.getFormula(i);r.hasSheetReference(e)&&(i.formula=r.shift(t).createFormulaString(!1),o.calculations.updateDependencies(i))}))})),this}getFormulaCells(){const t=this.model,e=[];let i;const o=t.rows.length,r=t.columns.length;for(let s=0;s<o;s++){i=t.rows[s];for(let t=0;t<r;t++)i.hasCellFormula(t)&&e.push(i.cell(t))}return e}renameSheet(t,e){let i=!1;return this.dependencies.renameSheet(t,e),this.getFormulaCells().forEach((o=>{const r=this.getFormula(o);r.renameSheet(t,e)&&(o.formula=r.createFormulaString(),this.refreshFormula(o),i=!0)})),i}invalidateCellDependants(t){const e=[];return this.dependencies.getDependants(t.range).forEach((([t,i])=>{e.push([t,i]),t.invalidateValue()})),e}invalidateDependants(t){const e=new Map,i=new Map;for(const i of t)this.invalidateCellDependants(i).forEach((([t,i])=>e.set(t,i)));e.forEach(((t,e)=>i.set(e,t)));for(const i of t)e.set(i,null);return e.forEach(((t,e)=>{this.model.sparklines.dependencies.getDependants(e.range).forEach((([t,e])=>{i.set(t,e)})),this.model.conditionalFormats.dependencies.getDependants(e.range).forEach((([t,e])=>{this.model.conditionalFormats.invalidateExtremes(t),t.invalidateStyle(),i.set(t,e)}))})),i}}const Hw="#ff0000",Fw="#fcd53f",Bw="#00bb5e",Ww="#555555",Vw=new Map([["3Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","right"],color:Fw},{icon:["fas","up"],color:Bw}]],["3ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","right"],color:Ww},{icon:["fas","up"],color:Ww}]],["3Flags",[{icon:["fas","flag-pennant"],color:Hw},{icon:["fas","flag-pennant"],color:Fw},{icon:["fas","flag-pennant"],color:Bw}]],["3TrafficLights1",[{icon:["fas","circle"],color:Hw},{icon:["fas","circle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["3TrafficLights2",[{icon:["fas","square-o"],color:Hw},{icon:["fas","square-o"],color:Fw},{icon:["fas","square-o"],color:Bw}]],["3Signs",[{icon:["fas","square"],rotation:45,color:Hw},{icon:["fas","triangle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["3Symbols",[{icon:["fas","circle-xmark"],color:Hw},{icon:["fas","circle-exclamation"],color:Fw},{icon:["fas","circle-check"],color:Bw}]],["3Symbols2",[{icon:["fas","xmark"],color:Hw},{icon:["fas","exclamation"],color:Fw},{icon:["fas","check"],color:Bw}]],["3Stars",[{icon:["fal","star"],color:Fw},{icon:["fas","star-half-stroke"],color:Fw},{icon:["fas","star"],color:Fw}]],["3Triangles",[{icon:"caret-down",color:Hw},{icon:"dash",color:Fw},{icon:"caret-up",color:Bw}]],["4Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","down-right"],color:Fw},{icon:["fas","up-right"],color:Fw},{icon:["fas","up"],color:Bw}]],["4ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","down-right"],color:Ww},{icon:["fas","up-right"],color:Ww},{icon:["fas","up"],color:Ww}]],["4RedToBlack",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:"#b1b1b1"},{icon:["fas","circle"],color:"#edb2a3"},{icon:["fas","circle"],color:Hw}]],["4Rating",[{icon:"signal-bars-weak",color:"#4a7db1"},{icon:"signal-bars-fair",color:"#4a7db1"},{icon:"signal-bars-good",color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["4TrafficLights",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:Hw},{icon:["fas","circle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["5Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","down-right"],color:Fw},{icon:["fas","right"],color:Fw},{icon:["fas","up-right"],color:Fw},{icon:["fas","up"],color:Bw}]],["5ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","down-right"],color:Ww},{icon:["fas","right"],color:Ww},{icon:["fas","up-right"],color:Ww},{icon:["fas","up"],color:Ww}]],["5Rating",[{icon:["fal","signal-bars"]},{icon:["fal","signal-bars-weak"],color:"#4a7db1"},{icon:["fal","signal-bars-fair"],color:"#4a7db1"},{icon:["fal","signal-bars-good"],color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["5Quarters",[{icon:["fal","circle"],color:"#505050"},{icon:["fas","circle-quarter-stroke"],color:"#505050"},{icon:["fas","circle-half-stroke"],color:"#505050"},{icon:["fas","circle-three-quarters-stroke"],color:"#505050"},{icon:["fas","circle"],color:"#505050"}]]]),Uw=(t,e)=>{const i=Vw.get(t);return i?i[e]:null};class Gw extends Nw{constructor(t,e){super(t,"conditionalFormats"),this.formats=[],this.cellFormatMap=new Map,this.extremes=new Map,e&&this.populate(e)}populate(t){t.forEach((t=>{try{this.add(t)}catch(e){Lr().error(`conditional format error: ${JSON.stringify(t)}`,e)}}))}refresh(){this.dependencies.clear(),this.cellFormatMap.clear(),this.extremes.clear(),this.formats.forEach((t=>this.initConditionalFormat(t)))}clearCellDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.cellFormatMap.get(e).forEach((t=>({cf:t.cf}))),this}getExtremes(t){if(this.extremes.has(t.key))return this.extremes.get(t.key);const e=[1/0,-1/0];return t.ranges.forEach((t=>{for(const i of this.model.getValuesInRange(t))for(const t of i)null!=t&&(isNaN(t)||(e[0]=Math.min(e[0],t),e[1]=Math.max(e[1],t)))})),t.cmin&&("num"==t.cmin.t?e[0]=t.cmin.v:"percent"==t.cmin.t&&(e[0]=e[0]+(e[1]-e[0])*t.cmin.v/100)),t.cmax&&("num"==t.cmax.t?e[1]=t.cmax.v:"percent"==t.cmax.t&&(e[1]=e[0]+(e[1]-e[0])*t.cmax.v/100)),this.extremes.set(t.key,e),e}invalidateExtremes(t){this.cellFormatMap.get(t.address).forEach((t=>this.extremes.delete(t.cf.key)))}evaluateScaleFormat(t,e){const i=t.value;if(null==i)return null;const[o,r]=this.getExtremes(e.cf);let s;const n=(i-o)/(r-o);if(e.cf.cmid?.color)s=.5==n?"#"+e.cf.cmid.color:n>.5?Hr("#"+e.cf.cmid.color,"#"+e.cf.cmax.color,2*(n-.5)):Hr("#"+e.cf.cmin.color,"#"+e.cf.cmid.color,2*n);else{if(!e.cf.cmin?.color||!e.cf.cmax?.color)return null;s=Hr("#"+e.cf.cmin.color,"#"+e.cf.cmax.color,n)}return{color:Fr(s).substring(1),fgColor:s.substring(1)}}evaluateBarFormat(t,e){const i=t.value;if(null==i)return null;const o=this.getExtremes(e.cf);let r=o[0];const s=o[1],n=r<0;n||(r-=.1*(s-r));const a=Math.round(100*(i-r)/(s-r));e.initialized||(e.initialized=!0,e.cf.ranges.forEach((e=>this._dependencies.add(t.address,e.A1,null))));const l=[];if(n){const t=Math.round(-100*r/(s-r));i>=0?(l.push(`#00000000 ${t}%`),l.push(`#${e.cf.color} ${t}%`),l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`)):(l.push(`#00000000 ${a}%`),l.push(`#ff0000 ${a}%`),l.push(`#ff0000 ${t}%`),l.push(`#00000000 ${t}%`))}else l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`);return{cssStyle:{backgroundClip:"padding-box",backgroundImage:`linear-gradient(90deg, ${l.join(",")})`}}}evaluateFormulaFormat(t,e){if(!e.initialized&&e.cf.condition){e.initialized=!0;const i=t.address,o=new Gv(e.cf.condition,this.model.calculations.tokenizer);e.f=o.shift({index:0,offset:t.c-e.cf.firstCell.c1,direction:"right"}).shift({index:0,offset:t.r-e.cf.firstCell.r1,direction:"down"}),o.cells.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.ranges.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.variables.forEach((([e,o])=>{const r=this.model.getCellByName(o,t.range);r&&this._dependencies.add(i,r.address,null)}))}if(e.f&&!this.model.calculations.evaluateFormula(e.f,t))return null;const i={...e.cf.style};return i.color||Wr(Fr(Vr(e.cf.style.fgColor))),i}evaluateIconFormat(t,e){const i=t.value;if(null==i)return null;const[o,r]=this.getExtremes(e.cf);let s;for(let t=e.cf.thresh.length-1;t>=0;t--){const n=e.cf.thresh[t];if("percent"===n.t){if(null==s&&(s=100*(i-o)/(r-o)),s>=n.v)return{icon:Uw(e.cf.v,t)}}else if("num"===n.t&&i>=n.v)return{icon:Uw(e.cf.v,t)}}return null}evaluate(t){const e=t.address,i=this.cellFormatMap.get(e);if(!i)return null;let o=null,r=null;for(const e of i){try{switch(e.cf.type){case"formula":r=this.evaluateFormulaFormat(t,e);break;case"scale":r=this.evaluateScaleFormat(t,e);break;case"bar":r=this.evaluateBarFormat(t,e);break;case"icon":r=this.evaluateIconFormat(t,e);break;default:r=null}}catch(t){Lr().error(`Conditional format error: ${JSON.stringify(e)}`,t)}if(r&&(o=o?{...o,...r}:r,e.cf.stop))break}return o}initConditionalFormat(t){return t.firstCell=null,t.ranges.forEach((e=>{for(const i of new sx(e.intersect(this.model.gridRange))){const e=i.A1;"formula"===t.type&&(t.firstCell||(t.firstCell=i,t.formula=t.condition?new Gv(t.condition,this.model.calculations.tokenizer):null)),(this.cellFormatMap.get(e)||this.cellFormatMap.set(e,[]).get(e)).push({cf:t})}})),t}add(t){const e={key:t.ranges,ranges:Ev.fromA1s(t.ranges),type:t.type||"formula",firstCell:null,formula:null,style:t.style?this.model.styles.add(t.style):null,condition:t.condition,stop:!!t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh};this.formats.push(this.initConditionalFormat(e))}getSourceData(){return this.formats.map((t=>({type:t.type,ranges:Ev.toA1s(t.ranges),style:t.style,condition:t.condition,stop:t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh})))}}const qw=(t,e)=>{const i=new RegExp(`${ut(t)}`,"ig");return t=>(i.lastIndex=0,i.test(ct((t[e]??"").toString())))},Yw=(t,e)=>i=>!!i[e]===t,Zw=(t,e)=>{const i=t.map((t=>t.key?.toString()));return t=>null!=t[e]&&i.includes(t[e].toString())},Xw=(t,e)=>t=>!1,Qw=t=>!!t&&"object"==typeof t&&!Array.isArray(t)&&"range"===t.kind,Kw=t=>!(null!=t.from&&""!==t.from||null!=t.to&&""!==t.to),Jw=(t,e,i)=>{const o=t=>{if(null==t||""===t)return null;if(t instanceof Date)return t.getTime();if("d"===i||"dt"===i||"tm"===i){const e=new Date(t).getTime();return Number.isNaN(e)?null:e}const e="number"==typeof t?t:Number(t);return Number.isNaN(e)?null:e},r=o(t.from);let s=o(t.to);return null===s||"d"!==i&&"dt"!==i||(s+=86399999),t=>{const i=o(t[e]);return!(null===i||null!==r&&i<r||null!==s&&i>s)}},tx=(t,e,i)=>(i=i??"value",Qw(e)?Jw(e,i,t):"b"===t?Yw(e,i):"s"===t&&Array.isArray(e)?Zw(e,"value"):"s"===t?qw(e?.toString(),"formattedValue"):"m"===t&&Array.isArray(e)?Xw(e,i):qw(e?.toString(),"d"===t||"dt"===t||"tm"===t?"formattedValue":i));class ex extends Event{constructor(){super("filter",{bubbles:!1,cancelable:!0,composed:!0})}}class ix extends EventTarget{get settings(){return this._settings}set settings(t){this._settings=t||[],this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applyFilter(),Lr().info(`filtering applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=null){super(),this.model=t,this.custom=!1,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}filter(t,e=!0){const i=this.get(t.c),o=null===t.term||""===t.term||Qw(t.term)&&Kw(t.term);i&&o?(this.settings.splice(this.colMap.get(t.c),1),this.colMap.delete(t.c)):i?i.term=t.term:o||(this.colMap.set(t.c,this.settings.length),this.settings.push(t)),this.custom||(this.settings.length>0?this.applyFilter(!1):this.resetFilter(!1)),e&&this.dispatchEvent(new ex)}applyFilter(t=!0){const e=[];this.settings.forEach((t=>{const i=this.model.columns[t.c];e.push({c:t.c,matcher:tx(i.type,t.term,i.filter?.property)})}));const i=e.length,o=this.model.options.filters?.includeParents??!0,r=this.model.options.filters?.includeChildren??!0,s=new Set;this.model.rows.forEach((t=>{const n=s.has(t.index);(t=>{if(!t.filterable)return!0;for(let o=0;o<i;o++)if(!e[o].matcher(t.cell(e[o].c)))return!1;return!0})(t)?(t.filterState=Ir.Matched,o&&t.walkUp((t=>{if(s.has(t.index)&&t.filterState>0)return!1;t.filterState=Ir.ChildMatched,s.add(t.index)})),r&&t.walk((t=>{if(s.has(t.index)&&t.filterState>0)return!1;t.filterState=Ir.ParentMatched,s.add(t.index)}))):n||(t.filterState=Ir.Filtered),s.add(t.index)})),this.model.indexRows(),t&&this.dispatchEvent(new ex)}resetFilter(t=!0){this.settings=[],this.colMap.clear(),this.model.rows.forEach((t=>t.filterState=Ir.Matched)),this.model.indexRows(),t&&this.dispatchEvent(new ex)}}class ox extends Nw{constructor(t,e){super(t,"sparklines"),this.model=t,this.map=new Map,this.groups=new Map,this.extremes=new Map,this.maxIndex=0,this.updateRangeMap=!1,this.populate(e)}populate(t){t?.forEach((t=>{try{this.add(Ev.fromA1(t.location),Array.isArray(t.data)?t.data.map((t=>[Ev.fromA1(t)])):t.data.split(",").map((t=>[Ev.fromA1(t)])),ot({},av.DEFAULT_SPARKLINE_OPTIONS,t.options))}catch(e){this.model.logger.error(`sparkline error: ${JSON.stringify(t)}`,e)}}))}getSourceData(){const t=[];return this.groups.forEach((e=>{t.push({location:e.locRange.A1,data:e.dataRanges.map((t=>t[0].A1)).join(","),options:{minValue:e.minValue,maxValue:e.maxValue,type:e.type,style:e.style,marker:e.marker}})})),t}has(t){return this.map.has(t)}get(t){return this.map.get(t)}createDependencies(t){this.map.get(t)[1].forEach((e=>this._dependencies.add(t,e[0].A1,e[1])))}updateRangeMaps(){this.dependencies.clear(),this.map.clear(),this.groups.forEach(((t,e)=>this.createRangeMap(e,t.locRange,t.dataRanges)))}getValues(t){this.updateRangeMap&&this.updateRangeMaps();const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model;return this._dependencies.has(t)||this.createDependencies(t),e[1].flatMap((t=>i.getValuesInRange(t[0])[0]))}getExtremes(t){const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model,o=this.groups.get(e[0]);let r,s,n,a;return null==o.minValue||Q(o.minValue)?"auto"==(o.minValue||"auto")?(r=r??lt(...e[1].map((t=>i.getValuesInRange(t[0])))),n=r[0]):(this.extremes.has(e[0])||this.extremes.set(e[0],lt(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),s=this.extremes.get(e[0]),n=s[0]):n=o.minValue,null==o.maxValue||Q(o.maxValue)?"auto"==(o.maxValue||"auto")?(r=r??lt(...e[1].map((t=>i.getValuesInRange(t[0])))),a=r[1]):(this.extremes.has(e[0])||this.extremes.set(e[0],lt(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),s=this.extremes.get(e[0]),a=s[1]):a=o.maxValue,[n,a]}createRangeMap(t,e,i){e=e.intersect(this.model.gridRange);const o=i[0][0].size,r=e.size;if(r.columns>1&&r.rows>1)return void this.model.logger?.error(`invalid sparkline location range: ${e.A1}`);let s=!1;if(s=1==r.columns&&1==r.rows?o.rows>1:r.columns>1,s)for(let o=e.c1;o<=e.c2;o++)this.map.set(new Ev(o,e.r1).A1,[t,i.map((([t,i])=>[new Ev(t.c1+o-e.c1,t.r1,t.c1+o-e.c1,t.r2),i]))]);else for(let o=e.r1;o<=e.r2;o++)this.map.set(new Ev(e.c1,o).A1,[t,i.map((([t,i])=>[new Ev(t.c1,t.r1+o-e.r1,t.c2,t.r1+o-e.r1),i]))])}add(t,e,i){const o=++this.maxIndex;t&&e&&this.createRangeMap(o,t,e),this.groups.set(o,Object.assign({dataRanges:e,locRange:t},JSON.parse(JSON.stringify(av.DEFAULT_SPARKLINE_OPTIONS)),i))}update(t,e,i,o){const r=this.groups.get(t);Object.assign(r,{dataRanges:i,locRange:e},o),this.updateRangeMap=!0}delete(t){this.groups.delete(t),this.updateRangeMap=!0}shift(t){this.groups.forEach((e=>{e.dataRanges.forEach((([e])=>e.shift(t))),e.locRange.shift(t)})),this.updateRangeMaps()}}class rx extends Ev{constructor(t,e,i=!1){super(e.c1,e.r1,e.c2,e.r2),this.model=t,this.initializedOnly=i,this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}nextInitialized(){let t;for(;!this.done&&!t;)this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),t=this.model.rows[this.r].cells[this.c],this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;return t}next(){if(this.done)return{done:!0};this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;const t=this.model.rows[this.r+this.r1],e=this.c+this.c1,i=this.initializedOnly&&!t.isCellInitialized(e)?this.nextInitialized():t?.cell(e);return i?{done:!1,value:i}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class sx extends Ev{constructor(t){super(t.c1,t.r1,t.c2,t.r2),this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}next(){return this.done?{done:!0}:(this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c==this.size.columns-1&&this.r==this.size.rows-1,{done:!1,value:new Ev(this.c+this.c1,this.r+this.r1)})}}class nx extends Ev{constructor(t,e,i){super(e.c1,e.r1,e.c2,e.r2),this.model=t,this.i=0,this.done=!1,this.axis=i,this.key="rows"===i?"r1":"c1"}[Symbol.iterator](){return this}next(){if(this.done)return{done:!0};this.i<this.size[this.axis]-1&&this.i++,this.done=this.i>=this.size[this.axis]-1;const t=this.model[this.axis][this.i+this[this.key]];return t?{done:!1,value:t}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class ax{constructor(t,e){this.model=t,this.names=new Map,this.rangeMap=new Map,e&&this.populate(e)}populate(t){t.forEach((({name:t,ref:e})=>this.set(t,Z(e)?Ev.fromCoords(e):Ev.fromA1(e))))}set(t,e){this.names.set(t,e),this.rangeMap.set(e.A1,t)}delete(t){const e=this.names.get(t);e&&(this.rangeMap.delete(e.A1),this.names.delete(t))}findCellByName(t){let e;const i=this.model.rows,o=this.model.columns.length;for(let r=0;r<i.length;r++){e=i[r];for(let i=0;i<o;i++)if(e.hasCellName(i)){const o=e.cell(i);if(o.name==t)return o.range}}return null}getCellByName(t,e){const i=this.names.get(t)??this.findCellByName(t);return i?i.isColumn?this.model.rows.length>e.r1?this.model.columns[i.c1].cell(e.r1):null:i.isRow?this.model.columns.length>e.c1?this.model.rows[i.r1].cell(e.c1):null:this.model.rows[i.r1].cell(i.c1):null}getRangeByName(t,e=!0){const i=this.names.get(t);return e?i?.intersect(this.model.gridRange):i}shift(t){this.names.forEach(((e,i)=>{const o=e.A1;e.shift(t);const r=e.A1;o!=r&&(this.rangeMap.delete(o),this.rangeMap.set(r,i))}))}getSourceData(){const t=[];return this.names.forEach(((e,i)=>{t.push({name:i,ref:e.A1})})),t}}function lx(t,e=null){const i=ot({},av.DEFAULT_OPTIONS,e,ss(t,e));return i.numberFormat?i.numberFormatter=gr(i.formatLocale,i.numberFormat):i.numberFormatter||(i.numberFormatter=gr(i.formatLocale)),i.dateFormat?i.dateFormatter=Qo(i.formatLocale,i.dateFormat):i.dateFormatter||(i.dateFormatter=Qo(i.formatLocale)),i.columnSorting&&(i.sorting=i.sorting||{enabled:!0}),"boolean"==typeof i.filters&&(i.filters={enabled:i.filters}),i.filters=Object.assign({},sv,i.filters),"boolean"==typeof i.rowTree&&(i.rowTree={enabled:i.rowTree}),i.rowTree=Object.assign({},nv,i.rowTree),"boolean"==typeof i.columnTree&&(i.columnTree={enabled:i.columnTree}),i.columnTree=Object.assign({},nv,i.columnTree),i.cellValidation&&(i.cellValidation=cw(i.cellValidation)),i}class cx extends(Tr(dw)){get cells(){return this._cells}get data(){return this._data}set data(t){this._data=t}get height(){return this._height??this.model.options.rowHeight}set height(t){this._height=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return Lv(this.index)}get range(){return new Ev(null,this.index,null,this.index)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t,this.model.columns.forEach((t=>this.cell(t.index).refreshFormula()))}get values(){return this.model.columns.map((t=>this.cell(t.index).value))}cell(t,e){if(this.model.options.singleCellModel)return this._singleCell||(this._singleCell=new _w(this.model,{c:t,r:this.index})),this._singleCell.row=this,this._singleCell.column=this.model.columns[t],this._singleCell;let i=this._cells[t];if((e||!i)&&this.model.columns[t]){if(i=new _w(this.model,e??{c:t,r:this.index}),this._data){const e=this.model.columns[t].data;if(null!=e){const t=this._data[e];Z(t)?(t.comment&&this.model.comments.set(i.address,[t.comment]),i.populate(t)):i.hasValue||(i.value=t)}}i.name&&this.model.names.set(i.name,i.range),this._cells[t]=i}return i}constructor(t,e){super(t,e),this.isCellInitialized=t=>!!this.cells[t],this._cells=[],null==this._priority&&(this._priority=t.options.rowPriority)}populate(t){super.populate(t),this._height=null==t.h||"auto"==t.h?this.model.options.rowHeight:t.h,t.data&&(Array.isArray(t.data)?this._data=[...t.data]:this._data={...t.data}),null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._height&&this._height!=this.model.options.rowHeight&&(t.h=this._height),t}expand(t){super.expand(t),this.model.indexVisibleRows()}collapse(){super.collapse(),this.model.indexVisibleRows()}get prev(){return this.model.rows[this.index-1]}get next(){return this.model.rows[this.index+1]}get prevVisible(){let t=this.prev;for(;t&&!t.visible;)t=t.prev;return t}get nextVisible(){let t=this.next;for(;t&&!t.visible;)t=t.next;return t}hasCellFormula(t){return this.cells[t]&&this.cells[t].hasFormula||this._data&&this._data[this.model.columns[t].data]&&this._data[this.model.columns[t].data].f}hasCellName(t){return this.cells[t]&&null!=this.cells[t].name||this._data&&this._data[this.model.columns[t].data]&&null!=this._data[this.model.columns[t].data].name}insertColumns(t,e,i=!1){let o;const r=this.model.columns.length,s=this.model.calculations;if(i)for(let i=0;i<r;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=s.getFormula(o).shift({index:t,offset:e,direction:"right"}).createFormulaString(!1));t<this.cells.length&&this.cells.splice(t,0,...Array(e).fill(null))}deleteColumns(t,e,i=!1){let o;const r=this.model.columns.length,s=this.model.calculations;if(i)for(let i=0;i<r;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=s.getFormula(o).shift({index:t,offset:e,direction:"left"}).createFormulaString(!1));return t<this.cells.length?this.cells.splice(t,e):null}clearCalculatedValues(){this.cells.forEach((t=>t&&this.model.calculations.refreshFormula(t)))}}var hx=i(4418),dx=i.n(hx);const ux=t=>t?"1":"0",px=t=>null==t?"_":t,gx=t=>null==t?"_":t.toString(),mx=t=>null==t?"_":JSON.stringify(t),fx=t=>px(t&&t.color?t.color:"_")+px(t&&t.style?t.style:"_"),vx=t=>px(t?t.horizontal:null)+px(t?t.vertical:null)+px(t?t.horizontal:null)+gx(t?t.indent:null)+ux(t?t.wrapText:null)+gx(t?t.textRotation:null),bx=t=>dx()("s_"+ux(t.bold)+ux(t.italic)+ux(t.underline)+gx(t.sz)+px(t.font)+px(t.color)+fx(t.top)+fx(t.right)+fx(t.bottom)+fx(t.left)+px(t.patternType)+px(t.fgColor)+px(t.bgColor)+vx(t.alignment)+gx(t.angle)+mx(t.stops)+ux(t.hidden)+ux(t.editable)+mx(t.cssStyle)+mx(t.icon));function yx(t){const e={...t};return delete e.id,delete e.hash,e}class wx{constructor(t){this.model=t,this._count=0,this.hashmap=new Map,this.map=new Map}add(t){if(!isNaN(t))return this.get(t);const e=this.model.options.cssStyles?kw(t):t,i=e.hash?e.hash:bx(e);return this.hashmap.has(i)?this.map.get(this.hashmap.get(i)):(null==e.id&&(e.id=this._count),this._count=Math.max(e.id+1,this._count+1),e.hash=i,this.hashmap.set(i,e.id),this.map.set(e.id,e),e)}populate(t){t.forEach((t=>this.add(t)))}get(t){return this.map.has(t)?this.map.get(t):null}remove(t){const e="object"==typeof t?t:this.map.get(t);this.hashmap.delete(e.hash),this.map.delete(e.id)}merge(...t){const e=Object.assign({},...t.map((t=>Z(t)?t:this.get(t))));return this.add(yx(e))}duplicate(t,e){const i=this.get(t);return this.add(yx({...i,...e}))}set(t,e){let i=this.map.has(t)?this.map.get(t):{};for(const t in e)i[t]=e[t];return i=i.id?i:this.add(i),i}unset(t,e){if(this.map.has(t)){const i=this.map.get(t);for(const t of e)delete i[t]}}getSourceData(){return Array.from(this.map.values())}clean(){const t=new Map(Array.from(this.map.entries()).map((([t])=>[t,0])));this.model.columns.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)})),this.model.rows.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1),e.cells.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)}))})),t.forEach(((t,e)=>{0==t&&this.remove(e)}))}}function xx(t,e,i,o){const r=o??("rows"==i?e.rows:e.columns),s=function(t){const e=new Map;for(const i of t)e.has(i.level)||e.set(i.level,[]),e.get(i.level).push(i);return e}(r),n=t[i]??[];for(const t of n){let o;if(o=t.index>-1?[r[t.index]]:t.level>-1?s.get(t.level):r,t.name){const e=t.name instanceof RegExp?t.name:new RegExp(ut(t.name));o=o.filter((t=>e.test(t.name)))}o?.forEach((o=>{null!=t.priority&&(o.priority=t.priority),t.type?e.conditionalFormats.add(Object.assign({ranges:`${o.address}:${o.address}`},t)):(o.style=e.styles.add(t.style).id,"rows"==i&&null!=t.height?o.height=t.height:"columns"==i&&null!=t.width&&(o.width=t.width))}))}}function kx(t,e){for(const i of t)if(e[i.property]!=i.value)return!1;return!0}function Cx(t,e,i){const o=t.cells??[];for(const t of o)if(t.conditions?.length){const o=e.getRangeIterator(i??e.gridRange);for(const i of o)kx(t.conditions,i)&&(i.style=e.styles.add(t.style).id)}else if(t.type)e.conditionalFormats.add(Object.assign({ranges:"A:"+e.columns[e.columns.length-1].address},t));else for(const i of e.columns)null==i.style&&(i.style=e.styles.add(t.style).id)}function Mx(t,e,i){xx(t,e,"columns",i)}function _x(t,e,i){xx(t,e,"rows",i)}function Sx(t,e){Cx(t,e),Mx(t,e),_x(t,e)}var zx;!function(t){t[t.NONE=0]="NONE",t[t.MERGED=1]="MERGED",t[t.HIDDEN=2]="HIDDEN"}(zx||(zx={}));class Ex{get mergedCells(){return this._mergedCells}get hiddenCells(){return this._hiddenCells}constructor(t){this.model=t,this._mergedCells=new Map,this._hiddenCells=new Map}clear(){this._mergedCells.clear(),this._hiddenCells.clear()}getMergeState(t){return this._mergedCells.has(t)?zx.MERGED:this._hiddenCells.has(t)?zx.HIDDEN:zx.NONE}indexMergedRange(t){const e=t.A1,i=this._mergedCells.get(e);if(!i)return;const o=i.r,r=i.c,s=t.clone(),n=this.model.rows[o]?.cell(r);if(n)for(let t=0;t<i.rs;t++)for(let e=0;e<i.cs;e++)0==t&&0==e||(s.r1=o+t,s.c1=r+e,s.r2=s.r1,s.c2=s.c1,this._hiddenCells.set(s.A1,i));else this.remove(e)}add(t){const e=new Ev(t.c,t.r),i=e.A1;if(this._mergedCells.has(i))this.remove(i);else if(this._hiddenCells.has(i))return;this._mergedCells.set(i,t),this.indexMergedRange(e)}remove(t){const e=this._mergedCells.get(t);if(!e)return;this._mergedCells.delete(t);const i=e.r,o=e.c,r=new Ev(o,i);this._hiddenCells.delete(t);for(let t=0;t<e.rs;t++)for(let s=0;s<e.cs;s++)0==t&&0==s||(r.r1=i+t,r.c1=o+s,r.r2=r.r1,r.c2=r.c1,this._hiddenCells.delete(r.A1))}shift(t){const{index:e,offset:i,direction:o}=t,r={down:t=>{e<=t.r?t.r+=i:e>t.r&&e<t.r+t.rs&&(t.rs+=i)},up:t=>{e<=t.r?t.r-=i:e>t.r&&e<t.r+t.rs&&(t.rs-=i)},right:t=>{e<=t.c?t.c+=i:e>t.c&&e<t.c+t.cs&&(t.cs+=i)},left:t=>{e<=t.c?t.c-=i:e>t.c&&e<t.c+t.cs&&(t.cs-=i)}},s=[...this._mergedCells.values()];s.forEach((t=>this.remove(new Ev(t.c,t.r).A1))),s.forEach((t=>{r[o](t),this.add(t)}))}}const Lx=["index","name","rows","columns","cells","options","sparklines","rules","comments","styles","names","props","tab","theme"];class Ix{get mergedHeaders(){return this._mergedHeaders}get hasFilter(){return this._filter}get hasRowTree(){return this._maxRowLevel>0}get hasRowTreeEnabled(){return this.hasRowTree&&this.options.rowTree.enabled}get maxRowLevel(){return this._maxRowLevel}get hasColumnTree(){return this._maxColumnLevel>0}get hasColumnTreeEnabled(){return this.hasColumnTree&&this.options.columnTree.enabled}get maxColumnLevel(){return this._maxColumnLevel}get headerCount(){return this._headerCount}get columnHeaderCount(){return this.headerCount+(this.hasColumnTreeEnabled?1:0)+(this.hasFilter?1:0)}get properties(){return this._properties}set properties(t){this._properties=t}get theme(){return this._theme}set theme(t){this._theme=t}constructor(t,e,i){this.otherModels={},this.autofitColumns=new Set,this.autofitRows=new Set,this.merges=new Ex(this),this.styles=new wx(this),this.comments=new Aw(this),this.calculations=new jw(this),this.names=new ax(this),this.sorting=new Tw(this),this.filter=new ix(this),this.sparklines=new ox(this),this.conditionalFormats=new Gw(this),this._filter=!1,this._maxRowLevel=0,this._maxColumnLevel=0,this._headerCount=0,this._levelBasedRowTree=!0,this._levelBasedColTree=!0,this.clearRows=()=>(this.rowRoot.clearChildren(),this.rows=[],this.rows),this.clearColumns=()=>this.columns=[],this.logger=i,this.options=e??lx(t.options),this.populate(t)}getConnectedModel(t){return this.group?this.group.get(t):null}getModelByRange(t){return t.sheet?this.getConnectedModel(t.sheet):this}getCellByA1(t){return this.getCellByRange(Ev.fromA1(t))}getCellByRange(t){return this.getCellByCoords(t.r1,t.c1)}getCellByCoords(t,e){return this.rows[t]?.cell(e)}cell(t,e){return isNaN(t)?t instanceof Ev?this.getCellByRange(t):"string"==typeof t?this.getCellByA1(t):null:this.getCellByCoords(t,e||0)}createRows(t,e=new cx(this,{l:-1}),i=0){let o=!1,r=!1;this.autofitRows.clear();const s=t.map(((t,e)=>{t||(t={}),isNaN(t.l)||(o=!0),null!=t.p&&(r=!0),"auto"==t.h&&this.autofitRows.add(e);const s=new cx(this,t);return s.origIndex=e+i,s.name&&this.names.set(s.name,Ev.fullRow(e)),s}));let n=-1;return o?n=$r(s,e,{reverse:this.options.rowTree.reversed}):r?n=Ar(s,e):e.children=s,r||(o=!0),[e,s,n,o]}insertRowData(t,e,i){const o=this.createRows(i,new cx(this,{l:t.level}),e);if(this._maxRowLevel=Math.max(this._maxRowLevel,o[2]),t.insertChildren(o[0].children,e),this.indexRowsByTree(),this.theme){const t=o[1];_x(this.theme,this,t),Cx(this.theme,this,new Ev(0,t[0].index,1/0,t[t.length-1].index))}}applyTheme(t,e){if(e)for(const t of this.getInitializedCellIterator())t.invalidateStyle();Sx(t,this)}populate(t){this.index=t.index,this.name=t.name??this.name,this.tab=t.tab;let e=!1,i=!1;if(t.columns||(t.columns=new Array(this.options.columns).fill({})),t.rows||(t.rows=new Array(this.options.rows).fill({})),t.styles&&this.styles.populate(t.styles),this.autofitColumns.clear(),this.columns=t.columns.map(((t,o)=>{t||(t={}),t.l>0&&(e=!0),null!=t.p&&(i=!0),"auto"==t.w&&this.autofitColumns.add(o);const r=new zw(this,t);return this._filter=r.hasFilter||this._filter,r.name&&this.names.set(r.name,Ev.fullColumn(o)),r})),this._levelBasedColTree=e,this._maxColumnLevel=-1,this.colRoot=new zw(this,{l:-1}),e?this._maxColumnLevel=$r(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}):i?this._maxColumnLevel=Ar(this.columns,this.colRoot):this.colRoot.children=this.columns,i||(this._levelBasedColTree=!0),this.indexColumns(),this.indexVisibleColumns(),[this.rowRoot,this.rows,this._maxRowLevel,this._levelBasedRowTree]=this.createRows(t.rows),this.indexRows(),this.indexVisibleRows(),this.options.pageSize&&this.options.pageSize<=this.rows.length&&(this.rowRoot.count=1/0),this.merges.clear(),t.comments=t.comments||[],t.cells?.forEach(((e,i)=>{const o=this.rows[e.r]?this.rows[e.r].cell(e.c,e):null;o?(e.cs>1||e.rs>1)&&this.merges.add({r:o.r,c:o.c,rs:e.rs||1,cs:e.cs||1}):this.logger?.error(`invalid cell definition (index ${i}): ${JSON.stringify(e)}`),o&&e.comment&&t.comments.push(Object.assign(e.comment,{c:e.c,r:e.r}))})),t.sparklines)try{this.sparklines.populate(t.sparklines)}catch(t){Lr().error(`Sparkline init error: ${t}`)}if(t.names)try{this.names.populate(t.names)}catch(t){Lr().error(`Named range init error: ${t}`)}if(t.rules)try{this.conditionalFormats.populate(t.rules)}catch(t){Lr().error(`Conditional formats init error: ${t}`)}if(t.theme)try{this.applyTheme(t.theme),this._theme=t.theme}catch(t){Lr().error(`Theme init error: ${t}`)}if(t.comments)try{this.comments.populate(t.comments)}catch(t){Lr().error(`Comment init error: ${t}`)}this._properties=t.props,this.otherSourceData={};const o=new Set(Lx),r=Object.keys(t).filter((t=>!o.has(t)));r.forEach((e=>this.otherSourceData[e]=t[e])),this.options.sorting?.defaultSettings&&(this.sorting.settings=this.options.sorting.defaultSettings),this.options.filters?.defaultSettings&&(this.filter.settings=this.options.filters.defaultSettings),this.calcHeaderHeights()}getSourceData(){const t={index:this.index,name:this.name,tab:this.tab,columns:this.columns.map((t=>t.getSourceData())),rows:this.rows.map((t=>t.getSourceData())),styles:this.styles.getSourceData(),rules:this.conditionalFormats.getSourceData(),sparklines:this.sparklines.getSourceData(),names:this.names.getSourceData(),options:this.options};this._properties&&(t.props=this._properties);const e=[];let i;for(let t=0;t<this.rows.length;t++)for(let o=0;o<this.columns.length;o++)i=this.rows[t].cell(o).getSourceData(),Object.keys(i).length>0&&(i.r=t,i.c=o,e.push(i));e.length>0&&(t.cells=e);const o=[];return this.styles.clean(),this.styles.map.forEach((t=>o.push(t))),o.length>0&&(t.styles=o),new Set([...Object.keys(this.otherModels??{}),...Object.keys(this.otherSourceData??{})]).forEach((e=>t[e]=this.otherModels[e]?Array.from(this.otherModels[e]).map((t=>t.getSourceData())):this.otherSourceData[e])),t}calcHeaderHeights(){this._headerCount=0,this._headerHeights=[],this.columns.forEach((t=>{this._headerCount=t.header?t.header.length:this._headerCount,this._headerHeights.length<this._headerCount&&this._headerHeights.push(...Array(this._headerCount-this._headerHeights.length).fill(0)),t.header?.forEach(((t,e)=>{e>=this._headerHeights.length&&this._headerHeights.push(0),this._headerHeights[e]=Math.max(this._headerHeights[e],t.height??0)}))}))}indexRows(){this.visibleRows=[],this.rows.forEach(((t,e)=>{t.index=e,t.isLoaded||(t.collapsed=!0),t.hidden||t.filterState==Ir.Filtered||(t.visibleIndex=this.visibleRows.length,this.visibleRows.push(t))}))}indexVisibleRows(){this.visibleRows=[];let t=0;if(this._levelBasedRowTree){if(this.rowRoot.walkVisible((e=>{e.visibleIndex=t++,this.visibleRows.push(e)})),this.options.rowTree.reversed){const e=new Array(this.visibleRows.length);this.visibleRows.forEach(((i,o)=>{t=this.visibleRows.length-o-1,i.visibleIndex=t,e[t]=i})),this.visibleRows=e}}else this.rowRoot.walkVisible((t=>this.visibleRows[t.index]=t)),this.visibleRows=this.visibleRows.filter((e=>!!e&&(e.visibleIndex=t++,!0)))}indexRowsByTree(){this.rows=[];let t=0;this.rowRoot.walk((e=>{e.index=t++,this.rows.push(e)})),this.options.rowTree.reversed&&this.rows.reverse(),this.indexVisibleRows()}indexColumns(){this.visibleColumns=[],this.columns.forEach(((t,e)=>{t.index=e,t.hidden||this.visibleColumns.push(t)}))}indexVisibleColumns(){this.visibleColumns=[],this.visibleColumnIndex={};let t=0;if(this.colRoot.walkVisible((e=>{e.visibleIndex=t,this.visibleColumnIndex[e.index]=t++,this.visibleColumns.push(e)})),this.options.columnTree.reversed){this.visibleColumnIndex={};const e=new Array(this.visibleColumns.length);this.visibleColumns.forEach(((i,o)=>{t=this.visibleColumns.length-o-1,i.visibleIndex=t,this.visibleColumnIndex[i.index]=t,e[t]=i})),this.visibleColumns=e}this.indexHeaders()}indexHeaders(){this._mergedHeaders=[],this._headerCount=0,this.colRoot.walkVisible((t=>{this._headerCount=Math.max(t.header?t.header.length:0,this._headerCount),t.mergedHeaders.forEach((e=>this._mergedHeaders.push({h:e,c:t.index,r:e.r,cs:t.calculateRealColspan(e.cs??1),rs:e.rs??1})))})),this._mergedHeaders.forEach((t=>{if(!t.h.hidden)for(let e=t.c;e<t.c+t.cs;e++)for(let i=t.r;i<t.r+t.rs;i++)(i>t.r||e>t.c)&&this.columns[e]&&this.columns[e].header[i]&&(this.columns[e].header[i].hidden=!0)})),this.calcHeaderHeights()}removeHeader(t){this.columns.forEach((e=>{t<e.header.length&&e.header.splice(t,1)})),this.indexHeaders()}clear(){this.clearRows(),this.clearColumns(),this.resetViewport()}resetViewport(){return this._viewport=null,this}getViewport(t,e,i){const o=[],r=[];let s,n,a=e.h,l=0;for(l=0;l<i.t;l++)s=this.visibleRows[l],a-=s.height,o.push(s);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)s=this.visibleRows[l],a-=s.height;for(l=i.t+t.r;a>0&&l<this.visibleRows.length;)s=this.visibleRows[l++],a-=s.height,o.push(s);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)o.push(this.visibleRows[l]);let c=e.w,h=0;for(h=0;h<i.l;h++)n=this.visibleColumns[h],c-=n.width,r.push(n);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)n=this.visibleColumns[h],c-=n.width;for(h=i.l+t.c;c>0&&h<this.visibleColumns.length;)n=this.visibleColumns[h++],c-=n.width,r.push(n);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)r.push(this.visibleColumns[h]);return this._viewport={rows:o,columns:r}}calculateViewport(){return this._viewport?this.calculations.calculateViewport(this._viewport):[]}getValuesInRange(t,e=!1){if(!(t=t.intersect(this.gridRange)))return[];const{columns:i,rows:o}=t.size,r=new Array(o);let s,n=0,a=0;for(let o=t.r1;o<=t.r2;o++){r[n]=new Array(i),a=0,s=this.rows[o];for(let i=t.c1;i<=t.c2;i++)r[n][a++]=e?s.cell(i).formattedValue:s.cell(i).value;++n}return r}setRowExpandLevel(t){this.rows.forEach((e=>{e.collapsed=!e.isLoaded&&!e.isPartialyLoaded||e.level>=t,e.level<=t&&(e.hidden=!1)})),this.indexVisibleRows()}setColumnExpandLevel(t){this.columns.forEach((e=>e.collapsed=e.level>=t)),this.indexVisibleColumns()}getViewportRange(){return this._viewport?new Ev(this._viewport.columns[0].index,this._viewport.rows[0].index,this._viewport.columns[this._viewport.columns.length-1].index,this._viewport.rows[this._viewport.rows.length-1].index):null}get gridRange(){return new Ev(0,0,this.columns.length-1,this.rows.length-1)}getRangeIterator(t,e=!1){return new rx(this,e&&this._viewport?t.intersect(this.getViewportRange()):t.intersect(this.gridRange))}getInitializedCellIterator(){return new rx(this,this.gridRange,!0)}getRowIterator(t,e=!1){return t=e&&this._viewport?t.intersect(this.getViewportRange()):t.intersect(this.gridRange),new nx(this,t,"rows")}getColumnIterator(t,e=!1){return t=e&&this._viewport?t.intersect(this.getViewportRange()):t.intersect(this.gridRange),new nx(this,t,"columns")}getCellArray(t){const e=[];for(const i of this.getRangeIterator(t))e.push(i);return e}transformRangeToMatrix(t,e){let i,o,r;const s=[];for(let n=(t=t.intersect(this.gridRange)).r1;n<=t.r2;n++)if(i=this.rows[n],i){r=[];for(let s=t.c1;s<=t.c2;s++)o=i.cell(s),o&&r.push(e(o));s.push(r)}return s}getCellMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t))}getValueMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t.value))}shift(t){t.sheet=this.name,this.merges.shift(t),this.calculations.shift(t),this.names.shift(t),this.comments.shift(t),this.sparklines.shift(t)}clearCalculations(t=!1){t&&this.group?this.group.models.forEach((t=>t.calculations.refresh())):this.calculations.refresh()}refreshSparklines(){this.sparklines.updateRangeMaps();for(const t of this.getInitializedCellIterator())t.invalidateStyle()}clearCalculatedStyles(){this.conditionalFormats.refresh();const t=[];for(const e of this.getInitializedCellIterator())t.push(e),e.invalidateStyle()}insertColumns(t,e,i=!1){const o=this.columns[Math.min(this.columns.length-1,t)].parent;i&&++t,this.shift({index:t,offset:e,direction:"right"});for(let i=0;i<this.rows.length;i++)this.rows[i].insertColumns(t,e,!1);const r=new Array(e).fill(null).map((()=>new zw(this)));return this.columns.splice(t,0,...r),this.maxColumnLevel>0&&o.insertChildren(r,t-(o.index||-1)-1),this.indexColumns(),this.clearCalculations(!0),r}deleteColumns(t,e){const i=this.columns[t].parent;this.shift({index:t,offset:e,direction:"left"});const o=[];for(let i=0;i<this.rows.length;i++)o.push(this.rows[i].deleteColumns(t,e,!1));const r=this.columns.splice(t,e);return i?.deleteChildren(r),this.indexColumns(),this.clearCalculations(!0),r}insertRows(t,e,i=!1){const o=Math.min(this.rows.length-1,t),r=o<0?this.rowRoot:this.rows[o].parent;i&&++t;const s=isNaN(e)?e.length:e;this.shift({index:t,offset:s,direction:"down"});const n=isNaN(e)?e:new Array(s).fill(null).map((()=>new cx(this)));return this.rows.splice(t,0,...n),this.maxRowLevel>0&&r.insertChildren(n,t-(r.index||-1)-1),this.indexRows(),this.theme&&(_x(this.theme,this,n),Cx(this.theme,this,new Ev(0,n[0].index,1/0,n[n.length-1].index))),this.clearCalculations(!0),n}deleteRows(t,e){const i=this.rows[t].parent;this.shift({index:t,offset:e,direction:"up"});const o=this.rows.splice(t,e);return i?.deleteChildren(o),this.indexRows(),this.clearCalculations(!0),o}moveRows(t,e,i){const o=this.rows.splice(t,e);return this.rows.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"down",maxIndex:t+e-1}),this.indexRows(),this.clearCalculations(!0),o}moveColumns(t,e,i){const o=this.columns.splice(t,e);return this.columns.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"right",maxIndex:t+e-1}),this.indexColumns(),this.clearCalculations(!0),o}spillValues(t){const{cell:e,values:i,displayValues:o,propertyCell:r}=t,s=[],n=[],a=0===i.length||0===i[0].length;let l,c;const h=a?null:new Ev(e.c,e.r,e.c+i[0].length-1,e.r+i.length-1);if(e.spillRange&&this.getRangeIterator(e.spillRange,!0).forEach((t=>{e==t||h?.contains(t.range)||t.clearSpilledValue()})),e.spillRange=h,a)return{cells:s,oldValues:n,range:null};for(let t=h.r1;t<=h.r2;t++){if(l=this.rows[t],!l)continue;const a=t-h.r1;for(let t=h.c1;t<=h.c2;t++){const d=t-h.c1;c=l.cell(t),c.editable&&(n.push(c.value2),c.spillValue(i[a][d],e),r&&(c.format=r.format,c.type=r.type),o&&null!=o[a][d]&&(c.displayValue=o[a][d]),s.push(c))}}return{cells:s,oldValues:n,range:h}}getCellByName(t,e,i=!0){return this.names.getCellByName(t,e)||(this.group&&i?this.group.getCellByName(t,e):null)}getRangeByName(t,e=!0){return this.names.getRangeByName(t)||(this.group&&e?this.group.getRangeByName(t):null)}getValueMatrixByName(t,e=!0){const i=this.names.getRangeByName(t);return i?this.getValueMatrix(i):this.group&&e?this.group.getValueMatrixByName(t):null}rebuildRowTree(){const t=this._levelBasedRowTree?$r:Ar;this._maxRowLevel=t(this.rows,this.rowRoot,{reverse:this.options.rowTree.reversed}),this.indexRowsByTree()}rebuildColumnTree(){const t=this._levelBasedColTree?$r:Ar;this._maxColumnLevel=t(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}),this.indexColumns()}calculateCellOffset(t){let e=0,i=0;for(let i=0;i<t.c1&&this.columns[i];i++)e+=this.columns[i].width;for(let e=0;e<t.r1&&this.rows[e];e++)i+=this.rows[e].height;return{x:e,y:i}}}class Rx{get errors(){return this._errors}get(t){return this.models.get(t)}has(t){return this.models.has(t)}getNewName(){let t;do{t=`sheet${this._max}`}while(this.models.has(t));return t}add(t){if(t.index=t.index??this._max,++this._max,t.name=t.name||this.getNewName(),this.models.has(t.name))throw Error(`sheet "${t.name}" already exists`);return this.models.set(t.name,t),t.group=this,t}duplicate(t){const e=this.get(t);if(!e)return;const i=new Ix(e.getSourceData(),e.options);let o=1;for(;this.models.has(`${t}_${o}`);)++o;return i.name=`${t}_${o}`,this.add(i),i}remove(t){return this.models.delete(t),this}rename(t,e){if(this.has(t)){if(this.has(e))throw new Error(`Model '${e}' already exists`);const i=this.get(t);i.name=e,this.models.set(e,i),this.models.delete(t),this.models.forEach((i=>{i.calculations.renameSheet(t,e)&&i.calculateViewport()}))}return this}clear(){this.models.clear(),this._errors=[]}constructor(t){this._max=0,this.models=new Map,this.themes=new Map,this._errors=[],t&&this.populate(t)}populate(t){this.clear(),t.models.forEach((t=>{const e=new Ix(t);try{this.add(e)}catch(t){this.errors.push(t)}})),t.themes&&t.themes.forEach((t=>this.themes.set(t.name,t)))}getSourceData(){const t={models:[]};return this.models.forEach((e=>t.models.push(e.getSourceData()))),t}getCellByName(t,e){for(const i of this.models.values()){const o=i.getCellByName(t,e,!1);if(o)return o}return null}getRangeByName(t){for(const e of this.models.values()){const i=e.getRangeByName(t,!1);if(i)return i}return null}getValueMatrixByName(t){for(const e of this.models.values()){const i=e.getValueMatrixByName(t,!1);if(i)return i}return null}}class Tx{constructor(t){this.model=t,this.stack=[],this.restack=[]}push(t){return this.restack=[],t.timestamp||(t.timestamp=Date.now()),this.stack.push(t),this}pop(t=1){let e=0;const i=[];for(;e++<t&&this.stack.length>0;){const t=this.stack.pop();i.push(t),this.restack.push(t)}return i}pop2(t=1){let e=0;const i=[];for(;e++<t&&this.restack.length>0;){const t=this.restack.pop();i.push(t),this.stack.push(t)}return i}}class $x{get activeCellCoords(){return{c:this.range.c1+this.activeCell.c1,r:this.range.r1+this.activeCell.r1}}constructor(t,e,i,o){this.hidden=!1,this.range=new Ev(t,e,i,o),this.activeCell=new Ev(0,0)}static fromRange(t){return new $x(t.c1,t.r1,t.c2,t.r2)}setCoords(t,e,i,o){this.range.setCoords(t,e,i,o),this.activeCell.setCoords(0,0)}setRange(t){"string"==typeof t&&(t=Ev.fromA1(t)),this.range.setCoords(t.c1,t.r1,t.c2,t.r2),this.activeCell.setCoords(0,0)}move(t,e,i,o){this.range.setCoords(this.range.c1+this.activeCell.c1,this.range.r1+this.activeCell.r1,this.range.c1+this.activeCell.c2,this.range.r1+this.activeCell.r2),this.range.move(t,e,i,o,!1),this.activeCell.setCoords(0,0)}moveRange(t,e,i,o){this.range.move(t,e,i,o,!0)}moveActiveCell(t,e){const{columns:i,rows:o}=this.range.size;this.activeCell.move(t,e,i,o,!0)}}const Ax={...av,CUSTOM_CLIPBOARD_TYPE:"web application/json"};class Dx{constructor(t,e,i=Ax.MAX_CACHE_ITEMS){this.maxCacheItems=i,this.queue=[],this.disabled=!1,this.table=new Array(e).fill(null).map((()=>new Array(t)))}get(t,e){return this.table[e][t]}delete(t,e){return this.table[e][t]=null,this}deleteColumn(t){for(let e=0;e<this.table.length;e++)this.table[e][t]=null;return this}deleteRow(t){return this.table[t]=new Array(this.table[0].length).fill(null),this}set(t,e,i){this.disabled||(this.get(t,e)||this.queue.push([e,t]),this.table[e][t]=i)}clear(){this.queue=[],this.table=this.table.map((t=>new Array(t.length)))}clean(){if(this.maxCacheItems>0&&this.queue.length>this.maxCacheItems){let t=this.queue.length;for(let e=0;e<this.queue.length;e++){const i=this.queue[e];if(!this.table[i[0]][i[1]].parentNode&&(this.queue[e]=null,this.table[i[0]][i[1]]=null,--t<=this.maxCacheItems))break}t<this.queue.length&&(this.queue=this.queue.filter((t=>t)))}}}var Ox=function(t,e,i,o){var r,s=arguments.length,n=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(s<3?r(n):s>3?r(e,i,n):r(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n};const Nx=t=>{if(null==t||""===t)return"";if(t instanceof Date)return t.toLocaleDateString();if("string"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleDateString()}return String(t)};let Px=class extends En{constructor(){super(),this.render=()=>ln`
3980
+ `,rv=(t,e,i)=>{for(const i of e)if(i[0]===t)return(0,i[1])();return i?.()},sv={enabled:!1,includeChildren:!0,includeParents:!0},nv={enabled:!0,reversed:!1},av={ROW_HEIGHT:22,RESIZE_TRESHOLD:10,ROW_HEADER_WIDTH:60,SLIDER_SIZE:12,EXPANDER_SIZE:13,MAX_CACHE_ITEMS:5e3,CACHE_CLEAN_INTERVAL:30,COMMENT_HIDE_TIMEOUT:1e3,SELECTOR_BORDER_WIDTH:1,MIN_ROW_HEIGHT:5,MIN_COL_WIDTH:5,SPARKLINE_GAP:4,AUTOSCROLL_TRESHOLD:100,AUTOSCROLL_RATIO:1.1,AUTOSCROLL_INTERVAL:100,DEFAULT_SPARKLINE_OPTIONS:{minValue:"auto",maxValue:"auto",type:"line",style:{color:"0094FF",weight:1},marker:{color:"ff0000"}},DEFAULT_OPTIONS:{rows:100,columns:20,readOnly:!1,rowNumbers:!0,rowPriority:2,rowTree:{enabled:!0},columnTree:{enabled:!0},colLetters:!0,emptyPlaceholder:!0,freezeTop:0,fontSize:14,rowHeight:22,rowResize:!0,columnWidth:100,columnResize:!0,columnPriority:1,freezeLeft:0,freezeRight:0,freezeBottom:0,maxSortingColumns:3,numberFormat:null,levelIndentFactor:2,cellIndentFactor:10,emptyClickable:!1,grid:!0,autofill:!0,undoRedo:!0,commandWindow:!0,cellCache:!0,singleCellModel:!1,zoom:1,editing:{rowInsertion:!0,rowDeletion:!0,colInsertion:!0,colDeletion:!0,rowOutline:!0,colOutline:!0,dateCalendarEditor:!1},comments:{hideTimeout:1e3,offsetX:30,offsetY:-30,zIndex:500,headerPosition:"top"},scrolling:{verticalOverscroll:!0,horizontalOverscroll:!0,scrollbarVisibilityTreshold:100},selecting:{enabled:!0,multiSelect:!0},events:{click:{mouseMoveTreshold:10}},clipboard:{pasteProps:["v","dv"],rowPasteMode:"rewrite_append",columnPasteMode:"rewrite"},print:{dpi:600,margins:{left:6.35,right:6.35,top:19.05,bottom:19.05,header:7.62,footer:7.62},orientation:"portrait",paper:"A4"}},MAX_COMMENT_AUTOHEIGHT:300,MIN_COMMENT_AUTOHEIGHT:25,...G},lv=/^(?!.*[\\\/\*\[\]\:\?"])(.{1,31})$/;function cv(t){return lv.test(t)}function hv(t){return["\\","/","*","[","]",":","?",'"'].forEach((e=>t=t.replace(new RegExp(`\\${e}`,"g"),""))),t}function dv(t,e){return!isNaN(t)&&null!=t||!isNaN(e)&&null!=e||(t=null==t?"":ct(t.toString()).toLowerCase(),e=null==e?"":ct(e.toString()).toLowerCase()),t>e?1:t<e?-1:0}function uv(t,e){const i=Q(e);return Q(t)?(t=t.toString().trim()).startsWith("=")?0==dv(e,i?t.substring(1):parseFloat(t.substring(1))):t.startsWith(">=")?dv(e,i?t.substring(2):parseFloat(t.substring(2)))>=0:t.startsWith("<=")?dv(e,i?t.substring(2):parseFloat(t.substring(2)))<=0:t.startsWith(">")?dv(e,i?t.substring(1):parseFloat(t.substring(1)))>0:t.startsWith("<")?dv(e,i?t.substring(1):parseFloat(t.substring(1)))<0:0==dv(e,i?t:isNaN(t)?t||"":parseFloat(t)):e==t}const pv=new Map([["=",["==",1,0]],["<>",["!=",1,0]],[">",[">",1,0]],["<",["<",1,0]],[">=",[">=",1,0]],["<=",["<=",1,0]],["+",["+",2,0]],["-",["-",2,0]],["*",["*",3,0]],["/",["/",3,0]]]),gv=t=>["=",">","<",">=","<="].includes(t),mv=t=>["+","-","*","/"].includes(t),fv=t=>mv(t)||gv(t);function vv(t,e,i){switch(i){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return t/e;case"=":return 0==dv(t,e);case">":return dv(t,e)>0;case"<":return dv(t,e)<0;case">=":return dv(t,e)>=0;case"<=":return dv(t,e)<=0;default:throw new Error(`Invalid operator: ${i}`)}}function bv(t,e,i){const o=Array.isArray(t),r=Array.isArray(e);if(!o&&!r)return[[vv(t,e,i)]];const s=Math.max(o?t.length:0,r?e.length:0),n=Math.max(o?t[0].length:0,r?e[0].length:0),a=[];for(let l=0;l<s;l++){const s=[];for(let a=0;a<n;a++){const n=o?t[l]?.[a]:t,c=r?e[l]?.[a]:e,h=null==n&&null==c?null:vv(n,c,i);s.push(h)}a.push(s)}return a}var yv;!function(t){t[t.Number=0]="Number",t[t.Boolean=1]="Boolean",t[t.String=2]="String",t[t.StringQuote=3]="StringQuote",t[t.Function=4]="Function",t[t.ArgumentSeparator=5]="ArgumentSeparator",t[t.OpenBracket=6]="OpenBracket",t[t.CloseBracket=7]="CloseBracket",t[t.Operator=8]="Operator",t[t.Cell=9]="Cell",t[t.Variable=10]="Variable",t[t.Range=11]="Range",t[t.Sheet=12]="Sheet",t[t.SheetQuote=13]="SheetQuote",t[t.SheetSeparator=14]="SheetSeparator",t[t.Unknown=15]="Unknown",t[t.Operand=16]="Operand"}(yv||(yv={}));const wv=t=>t===yv.Number||t===yv.Boolean||t===yv.String||t===yv.Cell||t===yv.Variable||t===yv.Range,xv=t=>t>=48&&t<=57,kv=t=>"true"===(t=t.toLowerCase())||"false"===t,Cv=t=>t>=65&&t<=90||t>=97&&t<=122||t>=192&&t<=687,Mv={decimalPoint:".",stringQuote:'"',sheetQuote:"'",argumentSeparator:","};class _v{constructor(t){this.options=Object.assign(Mv,t)}tokenize(t){const e=[],i=t.length;let o,r,s,n,a=0,l="",c=!1,h=!1,d=!1;for(;a<i;){if(o=t.charAt(a),r=o.charCodeAt(0),"="==o&&0==a)++a;else if(xv(r)){for(l=(d?"-":"")+o,++a;a<i;)if(o=t.charAt(a),r=o.charCodeAt(0),xv(r))l+=o,++a;else{if(o!==this.options.decimalPoint)break;l+=".",++a}d=!1,e.push([l,yv.Number])}else if(Cv(r)||"$"==o){l=o,s=null,++a;do{if(o=t.charAt(a),r=o.charCodeAt(0),Cv(r)||xv(r)||"."===o||"$"===o||"_"===o)"_"==o?s=yv.Variable:xv(r)&&!c&&null==s&&(s=yv.Cell),l+=o,++a,a==i&&e.push([l,s||yv.Variable]);else{if("("==o){e.push([l.toUpperCase(),yv.Function]),e.push([o,yv.OpenBracket]),++a;break}if("'"==o)e.push([l,yv.Sheet]),l="",e.push([o,yv.SheetQuote]),c=!0,++a;else if(":"==o)s=yv.Range,l+=o,++a;else{if(!c||" "!=o){if("!"==o){""!==l&&e.push([l,yv.Sheet]),e.push([o,yv.SheetSeparator]),c=!1,l="",++a;break}e.push([l,s||(kv(l)?yv.Boolean:yv.Variable)]);break}l+=o,++a}}}while(a<i)}else if(fv(o)){if("-"===o&&xv(t.charCodeAt(a+1))&&(null==n||"("==n[0]||gv(n[0])||n[1]==yv.ArgumentSeparator))d=!0;else{for(l=o;gv(t.charAt(a+1));)l+=t.charAt(++a);e.push([l,yv.Operator])}++a}else if("("===o)e.push([o,yv.OpenBracket]),++a;else if(")"===o)e.push([o,yv.CloseBracket]),++a;else if("'"===o)e.push([o,yv.SheetQuote]),c=!0,++a;else if(o===this.options.argumentSeparator)e.push([o,yv.ArgumentSeparator]),++a;else if(o===this.options.stringQuote){for(h=!1,e.push([o,yv.StringQuote]),l="";++a<i;){if(o=t.charAt(a),o===this.options.stringQuote){h=!0,++a;break}l+=o}e.push([l,yv.String]),h&&e.push([this.options.stringQuote,yv.StringQuote])}else e.push([o,yv.Unknown]),++a;n=e[e.length-1]}return e}}function Sv(t,e,i=null,o=!0){return t+=e,0==e?t:t>=0?i?o?t%i:Math.min(t,i-1):t:o&&i?i+t%i:Math.max(t,0)}const zv=/(?:'?([\w\s]*)'?!)?(\$?)([a-z]*)(\$?)(\d*)(?::(\$?)([a-z]*)(\$?)(\d*))?/i;class Ev{constructor(t,e,i,o,r){this.setCoords(t,e,i,o),this.sheet=r}setCoords(t,e,i,o){this.c1=null==t&&null==i?0:t,this.r1=null==e&&null==o?0:e,this.c2=null==o&&null!=t||null!=i?null==i?t:i:1/0,this.r2=null==i&&null!=e||null!=o?null==o?e:o:1/0,this.normalize()}get size(){return{columns:this.c2-this.c1+1,rows:this.r2-this.r1+1}}get count(){const{columns:t,rows:e}=this.size;return t*e}normalize(){const[t,e]=[Math.min(this.c1,this.c2),Math.max(this.c1,this.c2)],[i,o]=[Math.min(this.r1,this.r2),Math.max(this.r1,this.r2)];return this.c1=t,this.c2=e,this.r1=i,this.r2=o,this}move(t,e,i=null,o=null,r=!0){const s=Sv(this.c1,t,i,r);r&&(e+=this.c1+t!=s&&0!=t?t>0?1:-1:0),this.c1=s,this.r1=Sv(this.r1,e,o,r),this.c2=Sv(this.c2,t,i,r),this.r2=Sv(this.r2,e,o,r)}contains(t){return t.c1>=this.c1&&t.c2<=this.c2&&t.r1>=this.r1&&t.r2<=this.r2}containsColumn(t){return this.c1<=t&&this.c2>=t}containsRow(t){return this.r1<=t&&this.r2>=t}removeAnchors(){return this.c1Anchor=!1,this.c2Anchor=!1,this.r1Anchor=!1,this.r2Anchor=!1,this}addAnchors(){return this.c1Anchor=!0,this.c2Anchor=!0,this.r1Anchor=!0,this.r2Anchor=!0,this}shiftLeft(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1-=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2-=e),this}shiftRight(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1+=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2+=e),this}shiftUp(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1-=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2-=e),this}shiftDown(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1+=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2+=e),this}shift(t){const{index:e,offset:i,direction:o,maxIndex:r,ignoreAnchors:s}=t;switch(o){case"down":return this.shiftDown(e,i,r,s);case"up":return this.shiftUp(e,i,r,s);case"left":return this.shiftLeft(e,i,r,s);case"right":return this.shiftRight(e,i,r,s)}}intersect(t){this.normalize(),t.normalize();const e=Math.max(t.c1,this.c1),i=Math.min(t.c2,this.c2),o=Math.max(t.r1,this.r1),r=Math.min(t.r2,this.r2);return e<=i&&o<=r?new Ev(e,o,i,r,this.sheet):null}unite(t){return this.normalize(),t.normalize(),new Ev(Math.min(this.c1,t.c1),Math.min(this.r1,t.r1),Math.max(this.c2,t.c2),Math.max(this.r2,t.r2),this.sheet)}clone(){const t=new Ev(this.c1,this.r1,this.c2,this.r2,this.sheet);return t.c1Anchor=this.c1Anchor,t.r1Anchor=this.r1Anchor,t.c2Anchor=this.c2Anchor,t.r2Anchor=this.r2Anchor,t}equals(t,e=!1){return t.c1==this.c1&&t.r1==this.r1&&t.c2==this.c2&&t.r2==this.r2&&(0==e||t.c1Anchor==this.c1Anchor&&t.r1Anchor==this.r1Anchor&&t.c2Anchor==this.c2Anchor&&t.r2Anchor==this.r2Anchor)}get isCell(){return this.c2==this.c2&&this.r2==this.r1}get isRange(){return this.c2!=this.c1||this.r2!=this.r1}get isColumn(){return 0==this.r1&&this.r2==1/0}get isRow(){return 0==this.c1&&this.c2==1/0}get A1(){const t=this.isRange,e=(this.c1Anchor?"$":"")+(0!==this.c1||this.c2!==1/0?Rv(this.c1):"")+(0===this.r1&&this.r2===1/0?"":(this.r1Anchor?"$":"")+Lv(this.r1)),i=t?(this.c2Anchor?"$":"")+(!isNaN(this.c2)&&this.c2<1/0?Rv(this.c2):"")+(this.r2Anchor?"$":"")+(!isNaN(this.r2)&&this.r2<1/0?Lv(this.r2):""):e;return(null==this.sheet?"":((o=this.sheet).indexOf(" ")>-1?"'"+o+"'":o)+"!")+(e==i?e:e+":"+i);var o}get bounds(){return[[new Ev(this.c1,this.r1),this.c2<1/0?new Ev(this.c2,this.r1):null],[this.r2<1/0?new Ev(this.c1,this.r2):null,this.r2<1/0&&this.c2<1/0?new Ev(this.c2,this.r2):null]]}*cells(){for(let t=this.r1;t<=this.r2;t++)for(let e=this.c1;e<=this.c2;e++)yield new Ev(e,t)}static fromA1(t){const e=zv.exec(t),i=new Ev(e[3]?Tv(e[3]):null,e[5]?Iv(e[5]):null,e[7]?Tv(e[7]):null,e[9]?Iv(e[9]):null,e[1]||null);return!e[2]&&e[3]||(i.c1Anchor=!0),!e[4]&&e[5]||(i.r1Anchor=!0),(e[6]||e[2]&&!e[7])&&(i.c2Anchor=!0),(e[8]||e[4]&&!e[9])&&(i.r2Anchor=!0),i}}function Lv(t){return(t+1).toString()}function Iv(t){return parseInt(t)-1}function Rv(t){++t;let e,i="";for(;t>0;)e=(t-1)%26,i=String.fromCharCode(e+65)+i,t=(t-e-1)/26;return i}function Tv(t){const e=t.length;let i=0;for(let o=0;o<e;o++)i+=(t.charCodeAt(o)-64)*Math.pow(26,e-o-1);return i-1}function $v(t){return t.sort(((t,e)=>{const i=Math.min(t.r1,t.r2),o=Math.min(e.r1,e.r2),r=Math.min(t.c1,t.c2),s=Math.min(e.c1,e.c2);return i<o?-1:i>o?1:r<s?-1:s>r?1:0}))}function Av(t){return t.formula.cells.map((e=>t.cell.model.getCellByRange(e[1])))}function Dv(t){let e=t;for(;Array.isArray(e);)e=e.length>0?e[0]:null;return e}function Ov(t){return Array.isArray(t)?t:[[t]]}function Nv(t,e,i,o){if(!Array.isArray(t))return e(t,i,o);for(let o=0;o<t.length;o++)if(!1===Nv(t[o],e,null==i?o:i,null==i?void 0:o))return!1}Ev.fromA1s=(t,e=";")=>t.split(e).map((t=>Ev.fromA1(t))),Ev.toA1s=(t,e=";")=>t.map((t=>t.A1)).join(e),Ev.fromCoords=t=>new Ev(t.c1,t.r1,t.c2,t.r2),Ev.fullColumn=t=>new Ev(t,0,t,1/0),Ev.fullRow=t=>new Ev(0,t,1/0,t);const Pv=new Set(["SUMPRODUCT","FILTER"]),jv=t=>Pv.has(t),Hv=t=>!!(t&&t.length>0&&"="==t.charAt(0)),Fv=t=>Hv(t)?t:"="+(t??""),Bv=t=>Hv(t)?t.substring(1):t,Wv=["#5B97FF","#FF616B","#B77CFF","#00B02C","#FC58BE","#FF9000","#2EB0B3"],Vv=t=>Wv[t%Wv.length],Uv=new Map([["FORMULATEXT","_xlfn."],["CONCAT","_xlfn."],["INDIRECT","_xlfn."],["ISOWEEKNUM","_xlfn."],["SWITCH","_xlfn."],["XOR","_xlfn."]]);class Gv{get fn(){return this._fn??(this._fn=new Function("t","ctx","return "+this.compile()))}get tokens(){return this._tokens}get variables(){return this._variables}get cells(){return this._cells}get ranges(){return this._ranges}get colors(){if(!this._colors){let t;this._colors=new Map,this._tokens.forEach(((e,i)=>{if([yv.Cell,yv.Range].includes(e[1])){const o=(t?"'"+t+"'!":"")+e[0];this._colors.set(o,{color:Vv(this._colors.size),address:e[0],sheet:t,type:e[1],tokenIndex:i}),t=null}else e[1]==yv.Sheet&&(t=e[0])}))}return this._colors}constructor(t,e){this.expression=t,this.tokenizer=e,this._tokens=e.tokenize(this.expression),this.updateDependecies()}findTokenIndexAtPosition(t){let e=0;return this._tokens.findIndex((i=>{const o=i[0].length;if(t>=e&&t<=e+o)return!0;e+=o}))}findSheetTokenIndex(t){const e=this._tokens[t];if(![yv.Cell,yv.Range].includes(e[1]))return-1;if(0==t||this._tokens[t-1][1]!=yv.SheetSeparator)return-1;let i=t-2;for(;i>=0;){if(this._tokens[i][1]==yv.Sheet)return i;i--}return-1}removeSheetToken(t){if(this._tokens[t][1]!=yv.Sheet&&(t=this.findSheetTokenIndex(t)),t>-1){t>0&&this._tokens[t-1][1]==yv.SheetQuote&&t--;let e=t;for(;e<this._tokens.length&&[yv.SheetSeparator,yv.SheetQuote,yv.Sheet].includes(this._tokens[e][1]);)e++;return this._tokens.splice(t,e-t),e-t}return 0}getNamedColor(t){return this.colors.get(t)?.color??"inherit"}getTokenPosition(t){let e=0;for(let i=0;i<t;i++)e+=this._tokens[i][0].length;return{min:e,max:e+this._tokens[t][0].length}}updateToken(t,e){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens[t][0]=e}removeToken(t){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens.splice(t,1)}insertToken(t,e,i){this._fn=null,this._formula=null,this._xlFormula=null;const o=[];return i==yv.Sheet&&/\s/.test(e)?(o.push([this.tokenizer.options.sheetQuote,yv.SheetQuote]),o.push([e,yv.Sheet]),o.push([this.tokenizer.options.sheetQuote,yv.SheetQuote])):o.push([e,i]),o.push(["!",yv.SheetSeparator]),this._tokens.splice(t,0,...o),o.length}clone(){return new Gv(this.createFormulaString(),this.tokenizer)}updateDependecies(){let t;this._variables=[],this._cells=[],this._ranges=[],this._tokens.forEach(((e,i)=>{switch(e[1]){case yv.Sheet:t=e[0];break;case yv.Variable:this._variables.push([i,e[0],t]),t=void 0;break;case yv.Cell:this._cells.push([i,Ev.fromA1(e[0]),t]),t=void 0;break;case yv.Range:this._ranges.push([i,Ev.fromA1(e[0]),t]),t=void 0}}))}createFormulaString(t=!1,e=!1){const i=this.tokenizer.options;let o,r,s,n="";for(let l=0;l<this._tokens.length;l++)switch(o=this._tokens[l],o[1]){case yv.SheetQuote:n+="'";break;case yv.SheetSeparator:n+="!";break;case yv.Sheet:r=o[0],n+=t?`<span style="font-style:italic">${r}</span>`:r;break;case yv.Variable:n+=o[0];break;case yv.Range:case yv.Cell:s=(r?"'"+r+"'!":"")+o[0],n+=t?`<span style="color:${this.getNamedColor(s)}">${o[0]}</span>`:o[0],r=null;break;case yv.StringQuote:n+=i.stringQuote;break;case yv.String:n+=o[0].replace(new RegExp(i.stringQuote,"g"),"\\"+i.stringQuote);break;case yv.ArgumentSeparator:n+=i.argumentSeparator;break;case yv.Function:n+=(e?(a=o[0],Uv.get(a)??""):"")+o[0];break;case yv.Unknown:n+=t?`<span style="background:#f00;color:#fff">${o[0]}</span>`:o[0];break;default:n+=o[0]}var a;return n}createExpressionTree(){const t=[],e=[],i=this.tokens;let o,r,s,n,a,l=null;for(let c=0;c<i.length;c++)switch(o=i[c],o[1]){case yv.Sheet:l=o[0];break;case yv.Cell:case yv.Range:t.push({t:o[0],tt:o[1],s:l}),l=null;break;case yv.Number:case yv.String:case yv.Boolean:case yv.Variable:t.push({t:o[0],tt:o[1]});break;case yv.Operator:for(0==t.length&&t.push({t:"",tt:yv.Operand}),s=pv.get(o[0]);e.length>0&&(n=pv.get(e[e.length-1][0]),n)&&(0===s[2]&&s[1]<=n[1]||1===s[2]&&s[1]<n[1]);)r=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:r[0],tt:r[1],c:a});e.push(o);break;case yv.Function:case yv.OpenBracket:e.push(o);break;case yv.ArgumentSeparator:for(;e.length>0&&(r=e[e.length-1],![yv.OpenBracket,yv.ArgumentSeparator].includes(r[1]));)r=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:r[0],tt:r[1],c:a});e.push(o);break;case yv.CloseBracket:for(a=[];e.length>0&&e[e.length-1][1]!==yv.OpenBracket;)r=e.pop(),r[1]==yv.Operator?a.push({t:r[0],tt:r[1],c:[t.pop(),t.pop()].reverse()}):r[1]==yv.ArgumentSeparator&&t.length>0&&a.push(t.pop());e.pop(),e.length>0&&e[e.length-1][1]===yv.Function?(r=e.pop(),a=a.reverse(),t.length>0&&i[c-1][1]!==yv.OpenBracket&&a.unshift(t.pop()),t.push({t:r[0],tt:r[1],c:a})):t.push(...a)}for(;e.length>0;)r=e.pop(),t.push({t:r[0],tt:r[1],c:[t.pop(),t.pop()].reverse()});return t.pop()}createExpressionJSCode(t,e,i){let o;switch(t.tt){case yv.Range:return"t.rn('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.Cell:return"t.cl('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.Operand:return"t.cl()";case yv.Variable:return i||e?.tt===yv.Function?"t.nr('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")":"t.nv('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case yv.String:return"'"+t.t.replace(/'/g,"\\'")+"'";case yv.Boolean:return"T"==t.t[0].toUpperCase()?"1":"0";case yv.Function:return o=t.c.map((e=>this.createExpressionJSCode(e,t,i||jv(t.t)))),"t.fn('"+t.t+"').call(ctx"+(o.length>0?","+o.join(","):"")+")";case yv.Operator:return i?(o=t.c.map((e=>this.createExpressionJSCode(e,t,i||jv(t.t)))),"t.op("+o[0]+","+o[1]+",'"+t.t+"')"):pv.has(t.t)?"("+t.c.map((e=>this.createExpressionJSCode(e,t,i))).join(pv.get(t.t)[0])+")":null;default:return t.t}}compile(){const t=this.createExpressionTree();return this.createExpressionJSCode(t)}toString(t=!1){return(t?"=":"")+(this._formula??(this._formula=this.createFormulaString()))}toExcelString(){return this._xlFormula??(this._xlFormula=this.createFormulaString(!1,!0))}shift(t){const{index:e,offset:i,direction:o,maxIndex:r,sheet:s,allSheets:n}=t;return this._cells&&this._cells.forEach((t=>{if(n||null==t[2]||t[2]==s){switch(o){case"up":t[1].shiftUp(e,i,r);break;case"right":t[1].shiftRight(e,i,r);break;case"down":t[1].shiftDown(e,i,r);break;case"left":t[1].shiftLeft(e,i,r)}this._tokens[t[0]][0]=t[1].A1}})),this._ranges&&this._ranges.forEach((t=>{if(n||null==t[2]||t[2]==s){switch(o){case"up":t[1].shiftUp(e,i,r);break;case"right":t[1].shiftRight(e,i,r);break;case"down":t[1].shiftDown(e,i,r);break;case"left":t[1].shiftLeft(e,i,r)}this._tokens[t[0]][0]=t[1].A1}})),this}hasSheetReference(t){for(const e of this._cells)if(e[2]==t)return!0;for(const e of this._ranges)if(e[2]==t)return!0;for(const e of this._variables)if(e[2]==t)return!0;return!1}renameSheet(t,e){let i=!1;return this._tokens.forEach((o=>{o[1]==yv.Sheet&&o[0]==t&&(o[0]=e,i=!0)})),i}}function qv(t,e){return e&&(t=gr(this.cell.model.options.locale,yr(e,"d"),!1)(t)),null==t?"":t.toString()}function Yv(t,e){return(t=null==t?"":t.toString()).substring(0,e)}function Zv(t,e){return(t=null==t?"":t.toString()).substring(Math.max(0,t.length-e),t.length)}function Xv(t,e,i){return(t=null==t?"":t.toString()).substring(e,e+i)}function Qv(...t){let e="";return Nv(t,(t=>e+=null==t?"":t.toString())),e}function Kv(...t){return Qv(...t)}function Jv(t){return(t=null==t?"":t.toString()).length}function tb(t){return(t=null==t?"":t.toString()).toLowerCase()}function eb(t){return(t=null==t?"":t.toString()).toUpperCase()}function ib(t){return t instanceof Date?t:Q(t)?Xo(t,Lo()):nr(t)}function ob(t){return tt(t)?t:sr(t instanceof Date?t:Xo(t,Lo()))}function rb(t){return Q(t)?ob(t):t}function sb(t,e){const i=ib(t).getDay();switch(e){case 2:return i;case 3:return i-1;default:return i%7+1}}function nb(t,e,i){return ar(ob(Dv(t)),e)}function ab(){return sr(le(new Date))}function lb(t){return null==(t=Dv(t))||""===t}function cb(t,e,i){return sr(new Date(t,e-1,i))}function hb(t){return ib(t).getFullYear()}function db(t){return ib(t).getMonth()+1}function ub(t){return ib(t).getDate()}function pb(t,e){const i=ib(t);return i.setMonth(i.getMonth()+e+1),i.setDate(0),sr(i)}function gb(t){return Ci(ib(t))}function mb(t){return Math.acos(t)}function fb(t){return Math.acosh(t)}function vb(t){return Math.PI/2-Math.atan(t)}function bb(t){return.5*Math.log((t+1)/(t-1))}function yb(t){return Math.asin(t)}function wb(t){return Math.asinh(t)}function xb(t){return Math.atan(t)}function kb(t){return Math.atanh(t)}function Cb(t){return Math.cos(t)}function Mb(t){return Math.cosh(t)}function _b(t){return 1/Math.tan(t)}function Sb(t){return 1/Math.tanh(t)}function zb(t){return 1/Math.sin(t)}function Eb(t){return 1/Math.sinh(t)}function Lb(t){return 180*t/Math.PI}function Ib(){return Math.PI}function Rb(t){return 1/Math.cos(t)}function Tb(t){return 1/Math.cosh(t)}function $b(t){return Math.sin(t)}function Ab(t){return Math.sinh(t)}function Db(t){return Math.tan(t)}function Ob(t){return Math.tanh(t)}function Nb(t){return Math.abs(t)}function Pb(t){if(t<0)throw new Error("#NUM");return Math.ceil(t)}function jb(t){return(t=Math.ceil(t))%2==0?t:t+1}function Hb(t){return Math.pow(Math.E,t)}function Fb(t){return t<0?-1:0==t?1:t*Fb(t-1)}function Bb(t){return t<=0?1:t*Bb(t-2)}function Wb(t){return Math.floor(t)}function Vb(t){return t%1!=0}function Ub(t){return!Vb(t)&&t%2==0}function Gb(t){return Vb(t)||t%2==1}function qb(t){return Math.log(t)}function Yb(t,e){return Math.log(t)/Math.log(e)}function Zb(t){return Math.log10(t)}function Xb(t,e){return t%e}function Qb(t){return(t=Math.ceil(t))%2==0?t+1:t}function Kb(t,e){return Math.pow(t,e)}function Jb(...t){let e=1;return Nv(t,(t=>e*=t||1)),e}function ty(t,e){return Math.floor(t/e)}function ey(t){return t*Math.PI/180}function iy(){return Math.random()}function oy(t,e){const i=Array(t).fill(null).map((()=>Array(e)));for(let o=0;o<t;o++)for(let t=0;t<e;t++)i[o][t]=Math.random();return i}function ry(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function sy(t,e){return t.toFixed(e)}function ny(t,e){return e=e||0,Math.floor(t*Math.pow(10,e))/Math.pow(10,e)}function ay(t,e){return e=e||0,Math.ceil(t*Math.pow(10,e))/Math.pow(10,e)}function ly(t,e,i=1,o=1){const r=Array(t).fill(null).map((()=>Array(e)));let s=i;for(let i=0;i<t;i++)for(let t=0;t<e;t++)r[i][t]=s,s+=o;return r}function cy(t){return t<0?-1:t>0?1:0}function hy(t){return Math.sqrt(t)}function dy(t){return Math.sqrt(Math.PI*t)}function uy(...t){let e=0;return Nv(t,(t=>e+=null==t?0:1)),e}function py(...t){let e=0;return Nv(t,(t=>e+=null==t?1:0)),e}function gy(t,e){let i=0;return Nv(t,(t=>i+=uv(e,t)?1:0)),i}function my(...t){let e=0;const i=new Map;return Nv(t,(t=>{i.has(t)||(i.set(t,t),++e)})),e}function fy(...t){let e=0;return Nv(t,(t=>e+=isNaN(t)||null==t||""===t?0:t)),e}function vy(t,e,i){let o=0;if(i){const r=Ov(i);Nv(t,((t,i,s)=>o+=uv(e,t)&&r[i]&&r[i][s]&&!isNaN(r[i][s])?r[i][s]:0))}else Nv(t,(t=>o+=uv(e,t)&&!isNaN(t)?t:0));return o}function by(t,e){let i=0;return Nv(t,(t=>i+=uv(e,t)&&!isNaN(t)?t*t:0)),i}function yy(...t){let e=0;const i=t.shift();if(0===t.length)Nv(i,(t=>e+=isNaN(t)?0:t));else{const o=Ov(t[0]);Nv(i,((t,i,r)=>e+=o[i]&&o[i][r]&&!isNaN(t)&&!isNaN(o[i][r])?t*o[i][r]:0))}return e}function wy(t,e){return t=null==t?"":t.toString(),e?e=>e==t:(t=t.toLowerCase(),e=>(e??"").toString().toLowerCase()==t)}function xy(t,e,i=1){const o=new Ev(Math.max((e||0)-1,0),Math.max((t||0)-1,0));return 1!=i&&2!=i||(o.r1Anchor=!0),1!=i&&3!=i||(o.c1Anchor=!0),o.A1}function ky(t,e,i,o=!1){let r,s;const n=wy(t,o);for(r=0;r<e.length;r++)for(s=0;s<e[r].length;s++)if(n(e[r][s]))return e[r][i-1];return null}function Cy(t,e,i,o=!1){let r,s;const n=wy(t,o);for(r=0;r<e.length;r++)for(s=0;s<e[r].length;s++)if(n(e[r][s]))return e[i-1][s];return null}function My(t,e,i){let o,r;t:for(o=0;o<e.length;o++)for(r=0;r<e[o].length;r++)if(e[o][r]==t)break t;return i?i[o]?i[o][r]:null:e[o][e[o].length-1]}function _y(t,...e){let i=null,o=0;return Nv(e,(e=>{if(t==++o)return i=e,!1})),i}function Sy(t){return(t?Ev.fromA1(t).c1:this.cell.c)+1}function zy(t){return(t?Ev.fromA1(t).r1:this.cell.r)+1}function Ey(t){return Array.isArray(t)?t[0]?.length:1}function Ly(t){return Array.isArray(t)?t.length:1}function Iy(){const t=Av(this)[0];return t&&t.hasFormula?" "+Fv(t.formula):""}function Ry(t,e,i){return e=e||1,i=i||1,Array.isArray(t)?t[e-1]?t[e-1][i-1]:null:1==e&&1==i?t:null}function Ty(t){const e=this.cell,i=e.model,o=i.getCellByA1(t);let r;return i.calculations.dependencies.cellDependencies.has(e.address)?r=i.calculations.dependencies.cellDependencies.get(e.address):(r=new Map,i.calculations.dependencies.cellDependencies.set(e.address,r)),r.set(o.address,[o.range]),i.calculations.dependencies.cellDependants.has(o.address)?r=i.calculations.dependencies.cellDependants.get(o.address):(r=new Map,i.calculations.dependencies.cellDependants.set(o.address,r)),r.set(e.address,[e.range]),o.value}function $y(t,e,i=0){let o,r;for(o=0;o<e.length;o++)for(r=0;r<e[o].length;r++){if(0==i&&e[o][r]==t)return Math.max(o+1,r+1);if(1==i&&e[o][r]>t)return Math.max(o+1,r+1);if(-1==i&&e[o][r]<t)return Math.max(o+1,r+1)}return null}function Ay(t,e,i,o,r){const s=Av(this)[0],n=[];o=o||1,r=r||1;for(let t=0;t<o;t++){const o=[];for(let n=0;n<r;n++){const r=s.model.rows[s.r+t+e].cell(s.c+n+i);o.push(r?s.value:null)}n.push(o)}return n}function Dy(t,e){const i=[];if(t.length==e.length)for(let o=0;o<t.length;o++){let r=!0;for(let t=0;t<e[o].length;t++)if(!e[o][t]){r=!1;break}r&&i.push(t[o])}return i}const Oy=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],Ny=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]];function Py(t){const e=t*t;let i,o=Oy[0][4]*e,r=e;for(i=0;i<3;i+=1)o=(o+Oy[0][i])*e,r=(r+Ny[0][i])*e;return t*(o+Oy[0][3])/(r+Ny[0][3])}function jy(...t){let e=!0;return Nv(t,(t=>{if(!t)return e=!1})),e}function Hy(...t){let e=!1;return Nv(t,(t=>{if(t)return e=!0})),e}function Fy(...t){let e=null;return Nv(t,(t=>{e=null===e?!!t:!!t!=e})),e}function By(...t){const e=t[0];for(let i=1;i<t.length;i+=2){if(i==t.length-1)return t[i];if(e==t[i])return t[i+1]}return null}function Wy(t,e,i){return t?e:i}function Vy(t){return!t}function Uy(){return!1}function Gy(){return!0}function qy(t,e){return e=""===e?null:e,this.cell.hasError?(this.cell.error.handled=!0,e):t===1/0||t===-1/0||Number.isNaN(t)?e:t}var Yy=i(235),Zy=i.n(Yy),Xy=i(5949),Qy=i.n(Xy);function Ky(...t){let e=0,i=0;return Nv(t,(t=>{null==t||isNaN(t)||(e+=t||0,++i)})),e/i}function Jy(t,e){const i=Qy()(),o=Ov(t),r=Ov(e);for(let t=0;t<o.length;t++)for(let e=0;e<o[t].length;e++)i(o[t][e],(r[t]?r[t][e]:1)??1);return i()}function tw(...t){const e=function(t){const e=[];return Nv(t,(t=>e.push(t))),e}(t),i=Zy()(e.length,e,1);return e.reduce(((t,e)=>t+Math.abs(e-i)),0)/e.length}function ew(...t){let e=1/0;return Nv(t,(t=>e=Math.min(e,t))),e}function iw(...t){let e=-1/0;return Nv(t,(t=>e=Math.max(e,t))),e}function ow(t,e){Object.keys(e).forEach((i=>t.set(nt(i,"_").replace(/_/g,".").toUpperCase(),e[i])))}const rw=new Map;ow(rw,_),ow(rw,S),ow(rw,z),ow(rw,E),ow(rw,I),ow(rw,L),ow(rw,R);class sw{constructor(t){this.model=t,this.getModel=t=>{const e=t?this.model.getConnectedModel(t):this.model;if(e)return e;throw new Error(`Sheet "${t}" not found`)},this.cl=(t,e)=>{const i=this.getModel(e);if(null==t)return this.currentCell.value;const o=i.getCellByA1(t);return o?o.value:(this.currentCell.error={message:`undefined cell ${t}`},null)},this.rn=(t,e)=>this.getModel(e).getValuesInRange(Ev.fromA1(t)),this.nv=(t,e)=>this.getModel(e).getCellByName(t,this.currentCell.range).value,this.nr=(t,e)=>{const i=this.getModel(e).getValueMatrixByName(t);return 1===i.length&&1===i[0].length?i[0][0]:i},this.fn=t=>{const e=rw.get(t);if(e)return e;throw new Error(`Function "${t}" not found`)},this.op=(t,e,i)=>bv(t,e,i)}}function nw(t,e){const i=Array(e).fill(null);let o=0,r=[];if(t.length>1){r=t.map((t=>parseFloat(t.value)||0)),o=r[1]-r[0];for(let t=2;t<r.length;t++)if(r[t]-r[t-1]!==o){o=0;break}}if(0==o)for(let o=0;o<e;o++)i[o]=t[o%t.length]?.value;else{let t=r[r.length-1];for(let r=0;r<e;r++)t=i[r]=t+o}return i}function aw(t,e,i){const o=new Gv(t.formula,t.model.calculations.tokenizer),r=[];for(let t=0;t<i;t++)r.push(Fv(o.shift({index:0,offset:1,direction:e,allSheets:!0}).createFormulaString()));return r}function lw(t,e,i,o){const r=t.getCellMatrix(e);let s;"right"==o?s=Xr(r):"down"==o?s=Zr(r):"left"==o?s=qr(r):"up"==o&&(s=qr(Zr(r)));const n=new Array(i.size.rows);for(let t=0;t<i.size.rows;t++){n[t]=new Array(i.size.columns);for(let e=0;e<i.size.columns;e++){const i=r.length>t?r[t][r[t].length>e?e:0]:r[0][e];n[t][e]=i.hasDisplayValue?i.displayValue:null}}const a=i.size["down"==o||"up"==o?"rows":"columns"];let l=s.map((t=>t[t.length-1].hasFormula?aw(t[t.length-1],o,a):nw(t,a)));return"down"==o?l=Zr(l):"left"==o?l=qr(l):"up"==o&&(l=Yr(Zr(l))),t.spillValues({cell:t.getCellByRange(i.bounds[0][0]),values:l,propertyCell:t.getCellByRange(e.bounds[0][0]),displayValues:n})}function cw(t){return t.pattern&&"string"==typeof t.pattern&&(t.pattern=new RegExp(t.pattern)),t}function hw(t,e){const i=t.validation;if(!i)return!0;if(i.allowInvalid)return!0;let o=!0;return i.pattern&&(i.pattern.test((e??"").toString())||(o=!1)),i.validate&&(i.validate(t,e)||(o=!1)),o}class dw{get address(){return null}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get afterRenderer(){return this._afterRenderer}set afterRenderer(t){this._afterRenderer=t}get commentRenderer(){return this._commentRenderer}set commentRenderer(t){this._commentRenderer=t}get type(){return this._type}set type(t){this._type=t}get name(){return this._name}set name(t){this._name=t}get style(){return this._style}set style(t){this._style=t}get commentable(){return this._commentable}set commentable(t){this._commentable=t}get clickable(){return this._clickable}set clickable(t){this._clickable=t}get editable(){return this._editable}set editable(t){this._editable=t}get validation(){return this._validation}set validation(t){this._validation=t}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){this._formula=t?t.replace(/^=/,""):null}get value2(){return this.hasFormula?Fv(this.formula):null}get editorContent(){return this._editorContent}set editorContent(t){this._editorContent=t}get adapter(){return this._adapter}set adapter(t){this._adapter=t}get properties(){return this._properties}set properties(t){this._properties=t}getProperty(t){return this._properties?.[t]}setProperty(t,e){this._properties||(this._properties={}),this._properties[t]=e}get format(){return this._format}set format(t){this._format=t,this._valueFormatter=null}get valueFormatter(){return this._valueFormatter}constructor(t,e){this.model=t,this._type=null,this._clickable=!1,e&&this.populate(e)}populate(t){this._renderer=t.renderer,this._afterRenderer=t.afterRenderer,this._commentRenderer=t.commentRenderer,this._name=t.name,this._type=t.t,this._editorContent=t.content,this._adapter=t.adapter,this._format=t.z,this._formula=t.f,this._editable=t.e,this._commentable=t.commentable,this._clickable=t.clickable,this._validation=t.validation?cw(t.validation):null,this._properties=t.props,this._style=null==t.s?null:this.model.styles.add(t.s)?.id}update(t){const e={};if("renderer"in t&&(e.renderer=this._renderer,this._renderer=t.renderer),"afterRenderer"in t&&(this._afterRenderer=t.afterRenderer),"commentRenderer"in t&&(this._commentRenderer=t.commentRenderer),"name"in t&&(e.name=this._name,this._name=t.name),"t"in t&&(e.t=this._type,this._type=t.t),"content"in t&&(e.content=this._editorContent,this._editorContent=t.content),"adapter"in t&&(e.adapter=this._adapter,this._adapter=t.adapter),"z"in t&&(e.z=this._format,this._format=t.z),"f"in t&&(e.f=this._formula,this._formula=t.f),"e"in t&&(e.e=this._editable,this._editable=t.e),"commentable"in t&&(e.commentable=this._commentable,this._commentable=t.commentable),"clickable"in t&&(e.clickable=this._clickable,this._clickable=t.clickable),"validation"in t&&(e.validation=this._validation,this._validation=cw(t.validation)),"props"in t&&(e.props=this._properties,this._properties=t.props),"s"in t){const i=this.model.styles.add(t.s).id;this._style!==i&&(e.s=this._style,this._style=i)}return e}getSourceData(){const t={};return null!=this._type&&(t.t=this._type),null!=this._format&&(t.z=this._format),null!=this._formula&&(t.f=this._formula),null!=this._editable&&(t.e=this._editable),null!=this._commentable&&(t.commentable=this._commentable),null!=this._clickable&&(t.clickable=this._clickable),this._properties&&(t.props=rt(this._properties)),null!=this._editorContent&&(t.content=Z(this._editorContent)?rt(this._editorContent):this._editorContent),null!=this._style&&(t.s=this._style),null!=this._name&&(t.name=this._name),t}setStyleProperties(t,e=!1){this.style=e?this.model.styles.set(this.style,t).id:this.model.styles.duplicate(this.style,t).id}removeStyleProperties(t){null!==this.style&&this.model.styles.unset(this.style,t)}get composedStyle(){return this.model.styles.get(this.style)}}function uw(t){const e={};return t.split(";").forEach((t=>{const[i,o]=t.split(":");e[i]=o.trim()})),e}const pw=new Map([["thin",{width:1.5,style:"solid"}],["medium",{width:2,style:"solid"}],["thick",{width:3,style:"solid"}],["double",{width:3,style:"double"}],["dotted",{width:1.5,style:"dotted"}],["hair",{width:1,style:"solid"}],["dashed",{width:1.5,style:"dashed"}],["mediumDashed",{width:2,style:"dashed"}],["dashDot",{width:1.5,style:"dashed"}],["mediumDashDot",{width:2,style:"dashed"}],["dashDotDot",{width:1.5,style:"dotted"}],["mediumDashDotDot",{width:2,style:"dotted"}],["slantDashDot",{width:1.5,style:"dashed"}],["none",{width:1.5,style:"solid"}]]),gw=(()=>{const t=new Map;return pw.forEach(((e,i)=>{let o=t.get(e.style);o||(o=t.set(e.style,new Map).get(e.style)),o.set(e.width,i)})),t})();function mw(t){return"middle"==t?"center":t}function fw(t){return t="#"==t.charAt(0)?t.substring(1):t,/^[0-9a-fA-F]{3}$/.test(t)?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:/^[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(t)?t:Wr(Br(t))}const vw=t=>{if("none"==t)return null;const e=t.split(" "),i=parseInt(e[0].charAt(0))||1,o=e.length>1?e[1]:"solid",r=gw.get(o);return{style:(r?r.get(i):null)??"thin",color:e.length>2?fw(e[2]):"CCCCCC"}},bw=t=>{const e=pw.get(t.style||"none");return e?[Ot(e.width),e.style,"none"==t.style?"var(--og-cell-background)":t.color?`#${t.color}`:"var(--og-border-color)"].join(" "):"none"},yw=(t,e)=>{const i="#"+(e.fgColor||"000000"),o="#"+(e.bgColor||"FFFFFF");switch(e.patternType){case"solid":t.backgroundColor=i||o;break;case"darkGray":t.backgroundColor=Nr(o,.75);break;case"mediumGray":t.backgroundColor=Nr(o,.5);break;case"lightGray":t.backgroundColor=Nr(o,.25);break;case"gray125":t.backgroundColor=Nr(o,.125);break;case"gray0625":t.backgroundColor=Nr(o,.0625);break;case"darkHorizontal":t.backgroundImage=`linear-gradient(0deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkVertical":t.backgroundImage=`linear-gradient(90deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkDown":t.backgroundImage=`linear-gradient(45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkUp":t.backgroundImage=`linear-gradient(-45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"lightHorizontal":t.backgroundImage=`linear-gradient(0deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightVertical":t.backgroundImage=`linear-gradient(90deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightDown":t.backgroundImage=`linear-gradient(45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightUp":t.backgroundImage=`linear-gradient(-45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"darkGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px";break;case"darkTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px"}return t},ww=(t,e)=>(t.backgroundImage=`linear-gradient(${(e.angle??0)+90}deg,${e.stops.map((t=>`#${t.rgb} ${100*t.v}%`)).join(",")})`,t),xw=t=>{const e=t.cssStyle?{...t.cssStyle}:{};return null!=t.bold&&(e.fontWeight=t.bold?"bold":"normal"),t.italic&&(e.fontStyle="italic"),t.underline?e.textDecoration="underline":t.strike&&(e.textDecoration="line-through"),t.sz&&(e.fontSize=Dt(t.sz)),t.color&&(e.color="#"+t.color),t.top&&(e.borderTop=bw(t.top)),t.right&&(e.borderRight=bw(t.right)),t.bottom&&(e.borderBottom=bw(t.bottom)),t.left&&(e.borderLeft=bw(t.left)),(t.top||t.right||t.bottom||t.left)&&(e.zIndex="1"),t.alignment&&t.alignment.vertical&&(e.display="flex",e.justifyContent=t.alignment.horizontal,e.alignItems="top"==t.alignment.vertical?"start":"bottom"==t.alignment.vertical?"end":"center"),t.alignment&&t.alignment.horizontal&&(e.textAlign=t.alignment.horizontal),t.alignment&&t.alignment.wrapText&&(e.display="flex",e.justifyContent=e.justifyContent??e.textAlign??"left",e.alignItems=e.alignItems??"center",e.whiteSpace="pre-wrap"),t.patternType?yw(e,t):t.stops&&t.stops.length?ww(e,t):t.fgColor?e.backgroundColor="#"+t.fgColor:t.bgColor&&(e.backgroundColor="#"+t.bgColor),e},kw=t=>{const e=Z(t)?t:uw(t),i={};let o;for(const t in e){const r=e[t];if(null!=r)switch(t){case"borderTop":case"border-top":i.top=vw(r);break;case"borderTopColor":case"border-top-color":i.top?i.top.color=fw(r):i.top={style:"thin",color:fw(r)};break;case"borderRight":case"border-right":i.right=vw(r);break;case"borderRightColor":case"border-right-color":i.right?i.right.color=fw(r):i.right={style:"thin",color:fw(r)};break;case"borderBottom":case"border-bottom":i.bottom=vw(r);break;case"borderBottomColor":case"border-bottom-color":i.bottom?i.bottom.color=fw(r):i.bottom={style:"thin",color:fw(r)};break;case"borderLeft":case"border-left":i.left=vw(r);break;case"borderLeftColor":case"border-left-color":i.left?i.left.color=fw(r):i.left={style:"thin",color:fw(r)};break;case"border":o=vw(r),i.top=i.top||o,i.right=i.right||o,i.bottom=i.bottom||o,i.left=i.left||o;break;case"textAlign":case"text-align":i.alignment=i.alignment||{},i.alignment.horizontal=r;break;case"verticalAlign":case"vertical-align":i.alignment=i.alignment||{},i.alignment.vertical=mw(r);break;case"whiteSpace":case"white-space":i.alignment=i.alignment||{},i.alignment.wrapText=r&&"nowrap"!=r;break;case"color":i.color=fw(r);break;case"background":case"backgroundColor":case"background-color":i.fgColor=fw(r);break;case"fontSize":case"font-size":i.sz=parseFloat(r);break;case"fontWeight":case"font-weight":i.bold="bold"==r;break;case"fontStyle":case"font-style":i.italic="italic"==r;break;default:i[t]=r}}return i},Cw={n:t=>{const e=Q(t)?parseFloat(t.replace(",",".")):t;return Number.isNaN(e)?t:e},t:t=>t,d:(t,e)=>{if(null==t||""===t)return null;if(Q(t))try{return K(t)?J(t):sr(Xo(t,e.model.options.formatLocale))}catch(i){return e.model.logger.error(`Invalid date value in cell ${e.address}: ${t}`),null}return t instanceof Date?sr(t):t},tm:t=>Q(t)?new Date(t):t,dt:t=>Q(t)?new Date(t):t,b:t=>!!t&&"0"!==t&&"false"!==t.toString().toLowerCase(),s:t=>t,m:t=>t,g:t=>{if(null==t||""===t)return null;const e=parseFloat(t.toString().replace(",","."));return isNaN(e)?t:e},a:t=>Q(t)&&""!==t?JSON.parse(t):t,h:t=>t},Mw=new Map;class _w extends dw{get tooltip(){return this._tooltip}set tooltip(t){this._tooltip=t}get hasTooltip(){return null!=this._tooltip}get merge(){return this.model.merges.mergedCells.get(this.address)}get row(){return this._row}set row(t){this._row=t}get r(){return this._row.index}get column(){return this._column}set column(t){this._column=t}get c(){return this._column.index}get hasValue(){return null!=this._value}get value(){return this._evaluated||this.evaluate(),this._value}set value(t){if(t&&Hv(t.toString()))this._value=void 0,this.formula=t;else{let e=Cw[this.type](t,this);hw(this,e)||(e=void 0),e!==this._value&&(this._value=e,this._displayValue=void 0),this.row.data&&this.column.data&&(this.row.data[this.column.data]=this._value)}}evaluate(){return this._value=Cw[this.type](this.model.calculations.evaluate(this),this),this._evaluated=!0,this._value}get value2(){return this.hasFormula?Fv(this.formula):this.value}get hasDisplayValue(){return null!=this._displayValue}get displayValue(){return this._displayValue}set displayValue(t){this._displayValue=t}get prefersDisplayValue(){return["s","m"].includes(this.type)}get error(){return this._error}set error(t){this._error=t}get hasError(){return!!this._error}clearError(){this._error=void 0}get spillRange(){return this._spillRange}get prevSpillRange(){return this._prevSpillRange}set spillRange(t){!this._spillRange||t&&this._spillRange.equals(t)||(this._prevSpillRange=this._spillRange),this._spillRange=t}get isSpillSource(){return null!=this._spillRange}get spillSource(){return this._spillSource}get isSpilled(){return null!=this._spillSource}spillValue(t,e){this.value=t,this._spillSource=e}clearSpilledValue(){this._spillSource=void 0,this._value=void 0}get hasSparkline(){return null===this._sparkline?this._sparkline=this.model.sparklines.has(this.address):this._sparkline}get hasComment(){return null===this._hasComment?this._hasComment=(this.model.comments.get(this.address)??[]).length>0:this._hasComment}get comments(){return this.model.comments.get(this.address)}get valueFormatter(){const t=super.valueFormatter??this.row.valueFormatter??this.column.valueFormatter;if(t)return t;const e=this.type,i=this.format,{formatLocale:o,fixNumberFormat:r}=this.model.options,s=this.value;if(null==s||""===s)return null;if("n"==e)return null!=i?gr(o,i,r):this.model.options.numberFormatter;if("g"==e){if(null!=i)return gr(o,i,r);if(tt(s))return this.model.options.numberFormatter}else{if("t"==e)return null==i?null:gr(o,i,!1);if("d"==e)return i?Qo(o,i):this.model.options.dateFormatter;if("s"==e&&this.editorContent)return(t=>{if(t=t||null,!Mw.has(t))if(t){const e=t.reduce(((t,e)=>t.set(e.k,e.v)),new Map);Mw.set(t,(t=>e.has(t)?e.get(t):t))}else Mw.set(t,(t=>t));return Mw.get(t)})(this.editorContent)}return null}get formattedValue(){return null==this.value?"":this.hasDisplayValue?this.displayValue:this.valueFormatter?this.valueFormatter(this.value):this.value.toString()}get elm1(){return this.row.priority>=this.column.priority?this.row:this.column}get elm2(){return this.row.priority<this.column.priority?this.row:this.column}get clickable(){return super.clickable??this.elm1.clickable??this.elm2.clickable}get type(){return super.type??this.elm1.type??this.elm2.type??"g"}set type(t){this._type=t}get editorContent(){return super.editorContent??this.elm1.editorContent??this.elm2.editorContent??null}get adapter(){return super.adapter??this.elm1.adapter??this.elm2.adapter}set adapter(t){this._adapter=t}get address(){return this.column.address+this.row.address}get range(){return Ev.fromA1(this.address)}get validation(){return super.validation??this.elm1.validation??this.elm2.validation??this.model.options.cellValidation}get editable(){return super.editable??this.elm1.editable??this.elm2.editable??this.model.options.editable}set editable(t){this._editable=t}get commentable(){return super.commentable??this.elm1.commentable??this.elm2.commentable??this.model.options.commentable}get renderer(){return super.renderer??this.elm1.renderer??this.elm2.renderer}get afterRenderer(){return super.afterRenderer??this.elm1.afterRenderer??this.elm2.afterRenderer??this.model.options.afterRenderer}get commentRenderer(){return super.commentRenderer??this.elm1.commentRenderer??this.elm2.commentRenderer??this.model.options.comments.renderer}get format(){return super.format??this.elm1.format??this.elm2.format}set format(t){super.format=t}get hyperlink(){return this._hyperlink}set hyperlink(t){this._hyperlink=t}get hasOwnFormula(){return!!this._formula}get hasFormula(){return null==this._hasFormula&&(this._hasFormula=!!this.formula),this._hasFormula}get formula(){return this._formula??this.elm1.formula??this.elm2.formula}set formula(t){super.formula=t,this.refreshFormula()}invalidateValue(){this.hasFormula?(this._value=void 0,this._evaluated=!1):this._evaluated=!0,this.clearError()}refreshFormula(){this.invalidateValue(),this._hasFormula=null}clearFormula(){this._formula=null,this._hasFormula=!1,this._evaluated=!0}constructor(t,e){super(t),this._evaluated=!0,this._sparkline=null,this._hasComment=null,this._hasStyle=null,this.row=t.rows[e.r],this.column=t.columns[e.c],this.populate(e)}populate(t){super.populate(t),this._tooltip=t.tooltip,this._hyperlink=t.hl,null!=t.f&&""!==t.f?this._evaluated=!1:null!=t.v&&(this.value=t.v),this._displayValue=t.dv}update(t){const e=super.update(t);return"tooltip"in t&&(e.tooltip=this._tooltip,this._tooltip=t.tooltip),"hl"in t&&(e.hl=this._hyperlink,this._hyperlink=t.hl),"f"in t?this._evaluated=!1:"v"in t&&(e.v=this.value,this.value=t.v),"dv"in t&&(e.dv=this._displayValue,this._displayValue=t.dv),e}getSourceData(t){const e=super.getSourceData();return this.merge&&(e.cs=this.merge.cs,e.rs=this.merge.rs),null!=this.value&&(e.v=this.value),this.hasTooltip&&(e.tooltip=this._tooltip),this._hyperlink&&(e.hl=this._hyperlink),t&&t.displayValue&&this.hasDisplayValue&&(e.dv=this._displayValue),e}createComposedStyle(t,e,i){const o=[];return t=t||this.column.style,e=e||this.row.style,null!=t&&null!=e?this.column.priority>this.row.priority?o.push(e,t):o.push(t,e):null!=t?o.push(t):null!=e&&o.push(e),null!=this.style&&o.push(this.style),null!=i&&o.push(i),o.length>0?this.model.styles.merge(...o):null}get composedStyle(){if(null===this._hasStyle){const t=this.createComposedStyle(null,null,this.model.conditionalFormats.evaluate(this));this._hasStyle=null!=t,this._composedStyle=t}return this._composedStyle}get calculatedIndent(){const t=this.composedStyle;return t?.alignment?.indent?t.alignment.indent:this.column.levelIndent&&this.row.level>0?this.row.level*this.model.options.levelIndentFactor:null}get cssStyle(){if(!1===this._hasStyle)return null;if(!this._cssStyle){const t=this.composedStyle;t&&(this._cssStyle=xw(t))}return this._cssStyle}invalidateStyle(){this._hasComment=null,this._hasStyle=null,this._composedStyle=null,this._cssStyle=null,this._sparkline=null}setStyleProperties(t){super.setStyleProperties(t),this.invalidateStyle()}removeStyleProperties(t){super.removeStyleProperties(t),this.invalidateStyle()}previewStyleProperties(t,e="cell"){const i=Object.assign({},this.createComposedStyle("column"==e?t:null,"row"==e?t:null)??{});if("cell"==e)for(const e in t)i[e]=t[e];this._hasStyle=!0,this._cssStyle=xw(i)}validate(){return!this.validation||hw(this,this.value)}toString(){return this.address}}const Sw={property:"value",enabled:!0};class zw extends(Tr(dw)){get comparer(){return this._comparer}set comparer(t){this._comparer=t}get filter(){return this._filter??(this.model.options.filters?.enabled?Sw:{enabled:!1})}set filter(t){this._filter=t}get hasFilter(){return this.filter.enabled}get sorting(){return this._sorting??this.model.options.columnSorting}set sorting(t){this._sorting=t}get width(){return this._width??this.model.options.columnWidth}set width(t){this._width=t}get levelIndent(){return this._levelIndent}set levelIndent(t){this._levelIndent=t}get levelButtons(){return this._levelButtons}set levelButtons(t){this._levelButtons=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return Rv(this.index)}get range(){return new Ev(this.index,null,this.index,null)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t;const e=this.index;this.model.rows.forEach((t=>t.cells[e]?.refreshFormula()))}constructor(t,e){super(t,e),null==this._priority&&(this._priority=t.options.columnPriority)}get mergedHeaders(){return this._mergedHeaders??(this._mergedHeaders=this._header?.filter((t=>t.cs>1||t.rs>1))??[])}updateMergedHeaders(){this._mergedHeaders=null}set header(t){this._mergedHeaders=null,this._header=t}get header(){if(!this._header||this._header.length<this.model.headerCount){this._header=this._header??[];for(let t=this._header.length;t<this.model.headerCount;t++)this._header.push({r:t})}return this._header}hasHeaderTooltip(t){const e=this.header?.[t];return e&&null!=e.tooltip}convertSourceHeader(t){return Array.isArray(t)?t.map(((t,e)=>{if(null==(t=t??{r:e}).height&&(t.height=t.h),t.r=e,null==t.style&&(t.style=t.s),t._style=null==t.style?null:this.model.styles.add(t.style).id,null!=this.model.options.headers?.style){const e=this.model.styles.add(this.model.options.headers.style).id;t._style=this.model.styles.merge(t._style,e).id}return t})):Q(t)?[{label:t,r:0}]:null}populate(t){super.populate(t),this._width=null==t.w||"auto"==t.w?null:t.w,this._levelIndent=t.levelIndent,this._levelButtons=t.levelButtons,this._header=this.convertSourceHeader(t.header),this._sorting=t.sorting,this._filter=Z(t.filter)?Object.assign({enabled:!0},t.filter):t.filter?Sw:!1===t.filter?{enabled:!1}:null,this._comparer=t.comparer,this.data=t.data,this._mergedHeaders=null,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._width&&(t.w=this._width),null!=this._levelIndent&&(t.levelIndent=this._levelIndent),null!=this._levelButtons&&(t.levelButtons=this._levelButtons),null!=this._header&&(t.header=this._header),null!=this._sorting&&(t.sorting=this._sorting),null!=this._filter&&(t.filter=this._filter),null!=this.data&&(t.data=this.data),t}expand(t){super.expand(t),this.model.indexVisibleColumns()}collapse(){super.collapse(),this.model.indexVisibleColumns()}get prev(){return this.model.columns[this.index-1]}get next(){return this.model.columns[this.index+1]}get prevVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t||0===t?null:this.model.visibleColumns[t-1]}get nextVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t?null:this.model.visibleColumns[t+1]}calculateRealColspan(t){let e=1,i=this.nextVisible;for(;i&&i.index-this.index<t&&e<t;)++e,i=i.nextVisible;return e}cell(t){return this.model.rows[t].cell(this.index)}clearCalculatedValues(){this.model.rows.forEach((t=>{const e=t.cells[this.index];e&&this.model.calculations.refreshFormula(e)}))}}var Ew;!function(t){t[t.Asc=1]="Asc",t[t.Desc=-1]="Desc"}(Ew||(Ew={}));const Lw={g:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,t:(t,e)=>(t.value||"").toString().localeCompare((e.value||"").toString()),s:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,m:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,n:(t,e)=>t.value-e.value,d:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),tm:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),dt:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),b:(t,e)=>t.value-e.value,h:(t,e)=>(t.value||"").localeCompare(e.value),a:()=>0},Iw={g:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,t:(t,e)=>(e.value||"").toString().localeCompare((t.value||"").toString()),s:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,m:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,n:(t,e)=>e.value-t.value,d:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),tm:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),dt:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),b:(t,e)=>e.value-t.value,h:(t,e)=>(e.value||"").localeCompare(t.value),a:()=>0},Rw=(t,e)=>t.origIndex-e.origIndex;class Tw{get settings(){return this._settings}set settings(t){this._settings=t||[],this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applySort(),Lr().info(`sorting applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=null){this.model=t,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}sort(t,e=null,i=!1){let o=this.get(t);return o&&o.ord==Ew.Desc&&null===e?(this.settings.splice(this.colMap.get(t),1),o=null):o?(o.ord=Ew.Desc,this.settings.splice(this.colMap.get(t),1)):o={c:t,ord:Ew.Asc},o&&(null!==e&&(o.ord=e),this.colMap.set(t,0),this.settings.unshift(o)),this.settings.length>this.model.options.maxSortingColumns&&this.settings.pop(),this.colMap.clear(),this.settings.forEach(((t,e)=>{t.index=e,this.colMap.set(t.c,e)})),i||(this.settings.length>0?this.applySort():this.resetSort()),o}applySort(){const t=this.model,e=this.settings.map((e=>{const i=t.columns[e.c];return i?i.comparer?e.ord==Ew.Asc?i.comparer:(t,e)=>-i.comparer(t,e):e.ord==Ew.Asc?Lw[i.type??"t"]:Iw[i.type??"t"]:(Lr().warn(`Column sorting: Column with index ${e.c} not found`),null)})).filter((t=>t)),i=e.length;let o,r,s;t.rowRoot.sort(((t,n)=>{if(!1===t.sortable||!1===n.sortable)return t.origIndex-n.origIndex;for(r=0;r<i;r++)if(s=this.settings[r].c,o=e[r](t.cell(s),n.cell(s)),0!=o)return o;return 0})),t.indexRowsByTree()}resetSort(){this.settings=[],this.colMap.clear(),this.model.rowRoot.sort(Rw),this.model.indexRowsByTree()}persistSort(){this.model.rows.forEach(((t,e)=>t.origIndex=e))}}class $w{get properties(){return this._properties}set properties(t){this._properties=t}constructor(t){t&&this.pupulate(t)}pupulate(t){this.author=t.author,this.text=t.text,this.date=t.date?new Date(t.date):null,this.data=t.data,this.readOnly=!!t.readOnly,this._properties=t.props}getSourceData(){const t={};return this._properties&&(t.props=this._properties),this.author&&(t.author=this.author),this.text&&(t.text=this.text),this.data&&(t.data=this.data),null!==this.readOnly&&(t.readOnly=this.readOnly),this.date&&(t.date=Qo("en-US")(this.date,"yyyy-MM-dd HH:mm:ss")),t}}class Aw{constructor(t,e){this.model=t,this._commentMap=new Map,this.has=t=>this._commentMap.has(t),this.delete=t=>this._commentMap.delete(t),this.cleanCell=t=>{this.has(t)&&this._commentMap.set(t,this.get(t).filter((t=>(t.text??"").length>0||null!=t.data)))},this.get=t=>(this.has(t)||this._commentMap.set(t,[]),this._commentMap.get(t)),this.set=(t,e)=>{this._commentMap.set(t,e?.map((t=>t instanceof $w?t:new $w(t)))||[]),this.cleanCell(t)},e&&this.populate(e)}populate(t){t.forEach((t=>{const e=t.a1||new Ev(t.c,t.r).A1;this._commentMap.has(e)||this._commentMap.set(e,[]),this._commentMap.get(e).push(new $w(t))})),this._commentMap.forEach((t=>{t.sort(((t,e)=>(e.date?e.date.getTime():0)-(t.date?t.date.getTime():0)))}))}shift(t){Array.from(this._commentMap.keys()).forEach((e=>{const i=Ev.fromA1(e);i.shift(t),i.A1!=e&&(this._commentMap.set(i.A1,this._commentMap.get(e)),this._commentMap.delete(e))}))}}function Dw(t,e,i){t.forEach((t=>t.forEach((t=>{t[1]==e&&(t[1]=i)}))))}class Ow{get cellDependencies(){return this._cellDependencies}get cellDependants(){return this._cellDependants}get rangeDependencies(){return this._rangeDependencies}get rangeDependants(){return this._rangeDependants}get sheetDependencies(){return this._sheetDependencies}get sheetDependants(){return this._sheetDependants}constructor(t,e="calculations"){this.model=t,this.modelPart=e,this._cellDependencies=new Map,this._cellDependants=new Map,this._rangeDependencies=new Map,this._rangeDependants=new Map,this._sheetDependencies=new Map,this._sheetDependants=new Map}clear(){this._cellDependants.clear(),this._cellDependencies.clear(),this._rangeDependencies.clear(),this._rangeDependants.clear()}clearCellDependecies(t){return this._cellDependencies.has(t)&&this._cellDependencies.delete(t),this._rangeDependencies.has(t)&&this._rangeDependants.delete(t),this}has(t){return this._cellDependencies.has(t)||this._rangeDependencies.has(t)}add(t,e,i){const o=Ev.fromA1(t).removeAnchors(),r=Ev.fromA1(e).removeAnchors();e=r.A1;const s=r.isRange,n=s?this._rangeDependencies:this._cellDependencies;let a=null;if((n.has(t)?n.get(t):n.set(t,new Map).get(t)).set(e,[r,i]),i){const t=this.model.getConnectedModel(i);t&&(t.calculations.dependencies.sheetDependants.set(this.model.name,this.model.name),this.sheetDependencies.set(i,i),a=s?t.calculations.dependencies.rangeDependants:t.calculations.dependencies.cellDependants),i=this.model.name}else a=s?this._rangeDependants:this._cellDependants;a&&(a.has(e)||a.set(e,new Map),a.get(e).set(t,[o,i]))}getDependants(t,e=null){let i,o;const r=t.A1;return e=e??new Map,this._cellDependants.has(r)&&this._cellDependants.get(r).forEach((([t,s])=>{e.has(t)||(s&&(o=this.model.getConnectedModel(s)),i=o||this.model,e.set(t,[i.getCellByRange(t),s]),o?o[this.modelPart].dependencies.getDependants(t).forEach(((t,i)=>{e.set(i,[t[0],t[1]??s])})):(t.A1!=r||o)&&i.calculations.dependencies.getDependants(t,e))})),this._rangeDependants.forEach(((i,o)=>{Ev.fromA1(o).contains(t)&&i.forEach((([t,i])=>{e.has(t)||(e.delete(t),this.getDependants(t,e.set(t,[(i?this.model.getConnectedModel(i):this.model).getCellByRange(t),i])))}))})),e}renameSheet(t,e){this._sheetDependants.has(t)&&(this._sheetDependants.delete(t),this._sheetDependants.set(e,e)),this._sheetDependencies.has(t)&&(this._sheetDependencies.delete(t),this._sheetDependencies.set(e,e)),Dw(this._cellDependants,t,e),Dw(this._cellDependencies,t,e),Dw(this._rangeDependants,t,e),Dw(this._rangeDependencies,t,e)}}class Nw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this._dependencies=new Ow(t,e)}}function Pw(t){return t instanceof RangeError?"Maximum call stack size exceeded"==t.message?"infinite loop":t.message:t.toString()}class jw extends Nw{get tokenizer(){return this._tokenizer}get formulas(){return this._formulas}constructor(t){super(t,"calculations"),this._tokenizer=new _v,this._formulas=new Map,this.context=new sw(t)}createFormula(t){const e=new Gv(t.formula,this.tokenizer);return this._formulas.set(t.address,e),t.hasOwnFormula&&(t.formula=e.createFormulaString()),this.createDependecies(t),e}createDependecies(t){const e=t.address;if(this.formulas.has(e)){const i=this.formulas.get(e);i.ranges.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.cells.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.variables.forEach((([i,o])=>{const r=this.model.getCellByName(o,t.range);r&&this._dependencies.add(e,r.address,null)}))}return this}refreshFormula(t){return t.refreshFormula(),this.formulas.delete(t.address),this.clearDependecies(t),this}updateDependencies(t){return this.clearDependecies(t).getFormula(t),this}getFormula(t){return this._formulas.has(t.address)?this._formulas.get(t.address):this.createFormula(t)}refresh(){this.dependencies.clear(),this._formulas.clear()}clearDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.formulas.delete(e),this}evaluateFormula(t,e){return this.context.currentCell=e,t.fn(this.context,{cell:e,formula:t})}evaluateExpression(t,e){this.context.currentCell=e;const i=new Gv(t,this.tokenizer);return i.fn(this.context,{cell:e,formula:i})}evaluate(t,e){if(!t)return null;let i=null;if(t.hasFormula){const o=this.getFormula(t);try{t.clearError(),this.context.currentCell=t,i=o.fn(this.context,{cell:t,formula:o}),Array.isArray(i)?(e||this.model.spillValues({cell:t,values:i}).range,i=i.length>0&&i[0].length>0?i[0][0]:null,e&&(t.value=i)):t.value=i}catch(e){t.error={message:Pw(e)}}}else i=t.value;return i}evaluateAll(){this.model.rows.forEach((t=>this.model.columns.forEach(((e,i)=>t.cell(i).evaluate()))))}calculateViewport(t){const e=[];return t.rows.forEach((t=>t.cells.forEach((t=>{if(t.hasFormula){if(!t.hasValue&&(this.evaluate(t),t.spillRange))for(const i of this.model.getRangeIterator(t.spillRange))e.push(i);e.push(t)}})))),e}shift(t){this.getFormulaCells().forEach((e=>{e.formula=this.getFormula(e).shift(t).createFormulaString(!1),this.updateDependencies(e)}));const e=this.model.name;return this.dependencies.sheetDependants.forEach((i=>{const o=this.model.getConnectedModel(i);o?.calculations.getFormulaCells().forEach((i=>{const r=o.calculations.getFormula(i);r.hasSheetReference(e)&&(i.formula=r.shift(t).createFormulaString(!1),o.calculations.updateDependencies(i))}))})),this}getFormulaCells(){const t=this.model,e=[];let i;const o=t.rows.length,r=t.columns.length;for(let s=0;s<o;s++){i=t.rows[s];for(let t=0;t<r;t++)i.hasCellFormula(t)&&e.push(i.cell(t))}return e}renameSheet(t,e){let i=!1;return this.dependencies.renameSheet(t,e),this.getFormulaCells().forEach((o=>{const r=this.getFormula(o);r.renameSheet(t,e)&&(o.formula=r.createFormulaString(),this.refreshFormula(o),i=!0)})),i}invalidateCellDependants(t){const e=[];return this.dependencies.getDependants(t.range).forEach((([t,i])=>{e.push([t,i]),t.invalidateValue()})),e}invalidateDependants(t){const e=new Map,i=new Map;for(const i of t)this.invalidateCellDependants(i).forEach((([t,i])=>e.set(t,i)));e.forEach(((t,e)=>i.set(e,t)));for(const i of t)e.set(i,null);return e.forEach(((t,e)=>{this.model.sparklines.dependencies.getDependants(e.range).forEach((([t,e])=>{i.set(t,e)})),this.model.conditionalFormats.dependencies.getDependants(e.range).forEach((([t,e])=>{this.model.conditionalFormats.invalidateExtremes(t),t.invalidateStyle(),i.set(t,e)}))})),i}}const Hw="#ff0000",Fw="#fcd53f",Bw="#00bb5e",Ww="#555555",Vw=new Map([["3Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","right"],color:Fw},{icon:["fas","up"],color:Bw}]],["3ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","right"],color:Ww},{icon:["fas","up"],color:Ww}]],["3Flags",[{icon:["fas","flag-pennant"],color:Hw},{icon:["fas","flag-pennant"],color:Fw},{icon:["fas","flag-pennant"],color:Bw}]],["3TrafficLights1",[{icon:["fas","circle"],color:Hw},{icon:["fas","circle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["3TrafficLights2",[{icon:["fas","square-o"],color:Hw},{icon:["fas","square-o"],color:Fw},{icon:["fas","square-o"],color:Bw}]],["3Signs",[{icon:["fas","square"],rotation:45,color:Hw},{icon:["fas","triangle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["3Symbols",[{icon:["fas","circle-xmark"],color:Hw},{icon:["fas","circle-exclamation"],color:Fw},{icon:["fas","circle-check"],color:Bw}]],["3Symbols2",[{icon:["fas","xmark"],color:Hw},{icon:["fas","exclamation"],color:Fw},{icon:["fas","check"],color:Bw}]],["3Stars",[{icon:["fal","star"],color:Fw},{icon:["fas","star-half-stroke"],color:Fw},{icon:["fas","star"],color:Fw}]],["3Triangles",[{icon:"caret-down",color:Hw},{icon:"dash",color:Fw},{icon:"caret-up",color:Bw}]],["4Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","down-right"],color:Fw},{icon:["fas","up-right"],color:Fw},{icon:["fas","up"],color:Bw}]],["4ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","down-right"],color:Ww},{icon:["fas","up-right"],color:Ww},{icon:["fas","up"],color:Ww}]],["4RedToBlack",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:"#b1b1b1"},{icon:["fas","circle"],color:"#edb2a3"},{icon:["fas","circle"],color:Hw}]],["4Rating",[{icon:"signal-bars-weak",color:"#4a7db1"},{icon:"signal-bars-fair",color:"#4a7db1"},{icon:"signal-bars-good",color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["4TrafficLights",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:Hw},{icon:["fas","circle"],color:Fw},{icon:["fas","circle"],color:Bw}]],["5Arrows",[{icon:["fas","down"],color:Hw},{icon:["fas","down-right"],color:Fw},{icon:["fas","right"],color:Fw},{icon:["fas","up-right"],color:Fw},{icon:["fas","up"],color:Bw}]],["5ArrowsGray",[{icon:["fas","down"],color:Ww},{icon:["fas","down-right"],color:Ww},{icon:["fas","right"],color:Ww},{icon:["fas","up-right"],color:Ww},{icon:["fas","up"],color:Ww}]],["5Rating",[{icon:["fal","signal-bars"]},{icon:["fal","signal-bars-weak"],color:"#4a7db1"},{icon:["fal","signal-bars-fair"],color:"#4a7db1"},{icon:["fal","signal-bars-good"],color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["5Quarters",[{icon:["fal","circle"],color:"#505050"},{icon:["fas","circle-quarter-stroke"],color:"#505050"},{icon:["fas","circle-half-stroke"],color:"#505050"},{icon:["fas","circle-three-quarters-stroke"],color:"#505050"},{icon:["fas","circle"],color:"#505050"}]]]),Uw=(t,e)=>{const i=Vw.get(t);return i?i[e]:null};class Gw extends Nw{constructor(t,e){super(t,"conditionalFormats"),this.formats=[],this.cellFormatMap=new Map,this.extremes=new Map,e&&this.populate(e)}populate(t){t.forEach((t=>{try{this.add(t)}catch(e){Lr().error(`conditional format error: ${JSON.stringify(t)}`,e)}}))}refresh(){this.dependencies.clear(),this.cellFormatMap.clear(),this.extremes.clear(),this.formats.forEach((t=>this.initConditionalFormat(t)))}clearCellDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.cellFormatMap.get(e).forEach((t=>({cf:t.cf}))),this}getExtremes(t){if(this.extremes.has(t.key))return this.extremes.get(t.key);const e=[1/0,-1/0];return t.ranges.forEach((t=>{for(const i of this.model.getValuesInRange(t))for(const t of i)null!=t&&(isNaN(t)||(e[0]=Math.min(e[0],t),e[1]=Math.max(e[1],t)))})),t.cmin&&("num"==t.cmin.t?e[0]=t.cmin.v:"percent"==t.cmin.t&&(e[0]=e[0]+(e[1]-e[0])*t.cmin.v/100)),t.cmax&&("num"==t.cmax.t?e[1]=t.cmax.v:"percent"==t.cmax.t&&(e[1]=e[0]+(e[1]-e[0])*t.cmax.v/100)),this.extremes.set(t.key,e),e}invalidateExtremes(t){this.cellFormatMap.get(t.address).forEach((t=>this.extremes.delete(t.cf.key)))}evaluateScaleFormat(t,e){const i=t.value;if(null==i)return null;const[o,r]=this.getExtremes(e.cf);let s;const n=(i-o)/(r-o);if(e.cf.cmid?.color)s=.5==n?"#"+e.cf.cmid.color:n>.5?Hr("#"+e.cf.cmid.color,"#"+e.cf.cmax.color,2*(n-.5)):Hr("#"+e.cf.cmin.color,"#"+e.cf.cmid.color,2*n);else{if(!e.cf.cmin?.color||!e.cf.cmax?.color)return null;s=Hr("#"+e.cf.cmin.color,"#"+e.cf.cmax.color,n)}return{color:Fr(s).substring(1),fgColor:s.substring(1)}}evaluateBarFormat(t,e){const i=t.value;if(null==i)return null;const o=this.getExtremes(e.cf);let r=o[0];const s=o[1],n=r<0;n||(r-=.1*(s-r));const a=Math.round(100*(i-r)/(s-r));e.initialized||(e.initialized=!0,e.cf.ranges.forEach((e=>this._dependencies.add(t.address,e.A1,null))));const l=[];if(n){const t=Math.round(-100*r/(s-r));i>=0?(l.push(`#00000000 ${t}%`),l.push(`#${e.cf.color} ${t}%`),l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`)):(l.push(`#00000000 ${a}%`),l.push(`#ff0000 ${a}%`),l.push(`#ff0000 ${t}%`),l.push(`#00000000 ${t}%`))}else l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`);return{cssStyle:{backgroundClip:"padding-box",backgroundImage:`linear-gradient(90deg, ${l.join(",")})`}}}evaluateFormulaFormat(t,e){if(!e.initialized&&e.cf.condition){e.initialized=!0;const i=t.address,o=new Gv(e.cf.condition,this.model.calculations.tokenizer);e.f=o.shift({index:0,offset:t.c-e.cf.firstCell.c1,direction:"right"}).shift({index:0,offset:t.r-e.cf.firstCell.r1,direction:"down"}),o.cells.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.ranges.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.variables.forEach((([e,o])=>{const r=this.model.getCellByName(o,t.range);r&&this._dependencies.add(i,r.address,null)}))}if(e.f&&!this.model.calculations.evaluateFormula(e.f,t))return null;const i={...e.cf.style};return i.color||Wr(Fr(Vr(e.cf.style.fgColor))),i}evaluateIconFormat(t,e){const i=t.value;if(null==i)return null;const[o,r]=this.getExtremes(e.cf);let s;for(let t=e.cf.thresh.length-1;t>=0;t--){const n=e.cf.thresh[t];if("percent"===n.t){if(null==s&&(s=100*(i-o)/(r-o)),s>=n.v)return{icon:Uw(e.cf.v,t)}}else if("num"===n.t&&i>=n.v)return{icon:Uw(e.cf.v,t)}}return null}evaluate(t){const e=t.address,i=this.cellFormatMap.get(e);if(!i)return null;let o=null,r=null;for(const e of i){try{switch(e.cf.type){case"formula":r=this.evaluateFormulaFormat(t,e);break;case"scale":r=this.evaluateScaleFormat(t,e);break;case"bar":r=this.evaluateBarFormat(t,e);break;case"icon":r=this.evaluateIconFormat(t,e);break;default:r=null}}catch(t){Lr().error(`Conditional format error: ${JSON.stringify(e)}`,t)}if(r&&(o=o?{...o,...r}:r,e.cf.stop))break}return o}initConditionalFormat(t){return t.firstCell=null,t.ranges.forEach((e=>{for(const i of new sx(e.intersect(this.model.gridRange))){const e=i.A1;"formula"===t.type&&(t.firstCell||(t.firstCell=i,t.formula=t.condition?new Gv(t.condition,this.model.calculations.tokenizer):null)),(this.cellFormatMap.get(e)||this.cellFormatMap.set(e,[]).get(e)).push({cf:t})}})),t}add(t){const e={key:t.ranges,ranges:Ev.fromA1s(t.ranges),type:t.type||"formula",firstCell:null,formula:null,style:t.style?this.model.styles.add(t.style):null,condition:t.condition,stop:!!t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh};this.formats.push(this.initConditionalFormat(e))}getSourceData(){return this.formats.map((t=>({type:t.type,ranges:Ev.toA1s(t.ranges),style:t.style,condition:t.condition,stop:t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh})))}}const qw=(t,e)=>{const i=new RegExp(`${ut(t)}`,"ig");return t=>(i.lastIndex=0,i.test(ct((t[e]??"").toString())))},Yw=(t,e)=>i=>!!i[e]===t,Zw=(t,e)=>{const i=t.map((t=>t.key?.toString()));return t=>null!=t[e]&&i.includes(t[e].toString())},Xw=(t,e)=>t=>!1,Qw=t=>!!t&&"object"==typeof t&&!Array.isArray(t)&&"range"===t.kind,Kw=t=>!(null!=t.from&&""!==t.from||null!=t.to&&""!==t.to),Jw=(t,e,i)=>{const o=t=>{if(null==t||""===t)return null;if(t instanceof Date)return t.getTime();if("d"===i||"dt"===i||"tm"===i){const e=new Date(t).getTime();return Number.isNaN(e)?null:e}const e="number"==typeof t?t:Number(t);return Number.isNaN(e)?null:e},r=o(t.from);let s=o(t.to);return null===s||"d"!==i&&"dt"!==i||(s+=86399999),t=>{const i=o(t[e]);return!(null===i||null!==r&&i<r||null!==s&&i>s)}},tx=(t,e,i)=>(i=i??"value",Qw(e)?Jw(e,i,t):"b"===t?Yw(e,i):"s"===t&&Array.isArray(e)?Zw(e,"value"):"s"===t?qw(e?.toString(),"formattedValue"):"m"===t&&Array.isArray(e)?Xw(e,i):qw(e?.toString(),"d"===t||"dt"===t||"tm"===t?"formattedValue":i));class ex extends Event{constructor(){super("filter",{bubbles:!1,cancelable:!0,composed:!0})}}class ix extends EventTarget{get settings(){return this._settings}set settings(t){this._settings=t||[],this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applyFilter(),Lr().info(`filtering applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=null){super(),this.model=t,this.custom=!1,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}filter(t,e=!0){const i=this.get(t.c),o=null===t.term||""===t.term||Qw(t.term)&&Kw(t.term);i&&o?(this.settings.splice(this.colMap.get(t.c),1),this.colMap.delete(t.c)):i?i.term=t.term:o||(this.colMap.set(t.c,this.settings.length),this.settings.push(t)),this.custom||(this.settings.length>0?this.applyFilter(!1):this.resetFilter(!1)),e&&this.dispatchEvent(new ex)}applyFilter(t=!0){const e=[];this.settings.forEach((t=>{const i=this.model.columns[t.c];e.push({c:t.c,matcher:tx(i.type,t.term,i.filter?.property)})}));const i=e.length,o=this.model.options.filters?.includeParents??!0,r=this.model.options.filters?.includeChildren??!0,s=new Set;this.model.rows.forEach((t=>{const n=s.has(t.index);(t=>{if(!t.filterable)return!0;for(let o=0;o<i;o++)if(!e[o].matcher(t.cell(e[o].c)))return!1;return!0})(t)?(t.filterState=Ir.Matched,o&&t.walkUp((t=>{if(s.has(t.index)&&t.filterState>0)return!1;t.filterState=Ir.ChildMatched,s.add(t.index)})),r&&t.walk((t=>{if(s.has(t.index)&&t.filterState>0)return!1;t.filterState=Ir.ParentMatched,s.add(t.index)}))):n||(t.filterState=Ir.Filtered),s.add(t.index)})),this.model.indexRows(),t&&this.dispatchEvent(new ex)}resetFilter(t=!0){this.settings=[],this.colMap.clear(),this.model.rows.forEach((t=>t.filterState=Ir.Matched)),this.model.indexRows(),t&&this.dispatchEvent(new ex)}}class ox extends Nw{constructor(t,e){super(t,"sparklines"),this.model=t,this.map=new Map,this.groups=new Map,this.extremes=new Map,this.maxIndex=0,this.updateRangeMap=!1,this.populate(e)}populate(t){t?.forEach((t=>{try{this.add(Ev.fromA1(t.location),Array.isArray(t.data)?t.data.map((t=>[Ev.fromA1(t)])):t.data.split(",").map((t=>[Ev.fromA1(t)])),ot({},av.DEFAULT_SPARKLINE_OPTIONS,t.options))}catch(e){this.model.logger.error(`sparkline error: ${JSON.stringify(t)}`,e)}}))}getSourceData(){const t=[];return this.groups.forEach((e=>{t.push({location:e.locRange.A1,data:e.dataRanges.map((t=>t[0].A1)).join(","),options:{minValue:e.minValue,maxValue:e.maxValue,type:e.type,style:e.style,marker:e.marker}})})),t}has(t){return this.map.has(t)}get(t){return this.map.get(t)}createDependencies(t){this.map.get(t)[1].forEach((e=>this._dependencies.add(t,e[0].A1,e[1])))}updateRangeMaps(){this.dependencies.clear(),this.map.clear(),this.groups.forEach(((t,e)=>this.createRangeMap(e,t.locRange,t.dataRanges)))}getValues(t){this.updateRangeMap&&this.updateRangeMaps();const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model;return this._dependencies.has(t)||this.createDependencies(t),e[1].flatMap((t=>i.getValuesInRange(t[0])[0]))}getExtremes(t){const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model,o=this.groups.get(e[0]);let r,s,n,a;return null==o.minValue||Q(o.minValue)?"auto"==(o.minValue||"auto")?(r=r??lt(...e[1].map((t=>i.getValuesInRange(t[0])))),n=r[0]):(this.extremes.has(e[0])||this.extremes.set(e[0],lt(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),s=this.extremes.get(e[0]),n=s[0]):n=o.minValue,null==o.maxValue||Q(o.maxValue)?"auto"==(o.maxValue||"auto")?(r=r??lt(...e[1].map((t=>i.getValuesInRange(t[0])))),a=r[1]):(this.extremes.has(e[0])||this.extremes.set(e[0],lt(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),s=this.extremes.get(e[0]),a=s[1]):a=o.maxValue,[n,a]}createRangeMap(t,e,i){e=e.intersect(this.model.gridRange);const o=i[0][0].size,r=e.size;if(r.columns>1&&r.rows>1)return void this.model.logger?.error(`invalid sparkline location range: ${e.A1}`);let s=!1;if(s=1==r.columns&&1==r.rows?o.rows>1:r.columns>1,s)for(let o=e.c1;o<=e.c2;o++)this.map.set(new Ev(o,e.r1).A1,[t,i.map((([t,i])=>[new Ev(t.c1+o-e.c1,t.r1,t.c1+o-e.c1,t.r2),i]))]);else for(let o=e.r1;o<=e.r2;o++)this.map.set(new Ev(e.c1,o).A1,[t,i.map((([t,i])=>[new Ev(t.c1,t.r1+o-e.r1,t.c2,t.r1+o-e.r1),i]))])}add(t,e,i){const o=++this.maxIndex;t&&e&&this.createRangeMap(o,t,e),this.groups.set(o,Object.assign({dataRanges:e,locRange:t},JSON.parse(JSON.stringify(av.DEFAULT_SPARKLINE_OPTIONS)),i))}update(t,e,i,o){const r=this.groups.get(t);Object.assign(r,{dataRanges:i,locRange:e},o),this.updateRangeMap=!0}delete(t){this.groups.delete(t),this.updateRangeMap=!0}shift(t){this.groups.forEach((e=>{e.dataRanges.forEach((([e])=>e.shift(t))),e.locRange.shift(t)})),this.updateRangeMaps()}}class rx extends Ev{constructor(t,e,i=!1){super(e?.c1,e?.r1,e?.c2,e?.r2),this.model=t,this.initializedOnly=i,this.r=0,this.c=-1,this.done=!1,e||(this.done=!0)}[Symbol.iterator](){return this}nextInitialized(){let t;for(;!this.done&&!t;)this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),t=this.model.rows[this.r].cells[this.c],this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;return t}next(){if(this.done)return{done:!0};this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;const t=this.model.rows[this.r+this.r1],e=this.c+this.c1,i=this.initializedOnly&&!t.isCellInitialized(e)?this.nextInitialized():t?.cell(e);return i?{done:!1,value:i}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class sx extends Ev{constructor(t){super(t.c1,t.r1,t.c2,t.r2),this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}next(){return this.done?{done:!0}:(this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c==this.size.columns-1&&this.r==this.size.rows-1,{done:!1,value:new Ev(this.c+this.c1,this.r+this.r1)})}}class nx extends Ev{constructor(t,e,i){super(e?.c1,e?.r1,e?.c2,e?.r2),this.model=t,this.i=0,this.done=!1,this.axis=i,this.key="rows"===i?"r1":"c1",e||(this.done=!0)}[Symbol.iterator](){return this}next(){if(this.done)return{done:!0};this.i<this.size[this.axis]-1&&this.i++,this.done=this.i>=this.size[this.axis]-1;const t=this.model[this.axis][this.i+this[this.key]];return t?{done:!1,value:t}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class ax{constructor(t,e){this.model=t,this.names=new Map,this.rangeMap=new Map,e&&this.populate(e)}populate(t){t.forEach((({name:t,ref:e})=>this.set(t,Z(e)?Ev.fromCoords(e):Ev.fromA1(e))))}set(t,e){this.names.set(t,e),this.rangeMap.set(e.A1,t)}delete(t){const e=this.names.get(t);e&&(this.rangeMap.delete(e.A1),this.names.delete(t))}findCellByName(t){let e;const i=this.model.rows,o=this.model.columns.length;for(let r=0;r<i.length;r++){e=i[r];for(let i=0;i<o;i++)if(e.hasCellName(i)){const o=e.cell(i);if(o.name==t)return o.range}}return null}getCellByName(t,e){const i=this.names.get(t)??this.findCellByName(t);return i?i.isColumn?this.model.rows.length>e.r1?this.model.columns[i.c1].cell(e.r1):null:i.isRow?this.model.columns.length>e.c1?this.model.rows[i.r1].cell(e.c1):null:this.model.rows[i.r1].cell(i.c1):null}getRangeByName(t,e=!0){const i=this.names.get(t);return e?i?.intersect(this.model.gridRange):i}shift(t){this.names.forEach(((e,i)=>{const o=e.A1;e.shift(t);const r=e.A1;o!=r&&(this.rangeMap.delete(o),this.rangeMap.set(r,i))}))}getSourceData(){const t=[];return this.names.forEach(((e,i)=>{t.push({name:i,ref:e.A1})})),t}}function lx(t,e=null){const i=ot({},av.DEFAULT_OPTIONS,e,ss(t,e));return i.numberFormat?i.numberFormatter=gr(i.formatLocale,i.numberFormat):i.numberFormatter||(i.numberFormatter=gr(i.formatLocale)),i.dateFormat?i.dateFormatter=Qo(i.formatLocale,i.dateFormat):i.dateFormatter||(i.dateFormatter=Qo(i.formatLocale)),i.columnSorting&&(i.sorting=i.sorting||{enabled:!0}),"boolean"==typeof i.filters&&(i.filters={enabled:i.filters}),i.filters=Object.assign({},sv,i.filters),"boolean"==typeof i.rowTree&&(i.rowTree={enabled:i.rowTree}),i.rowTree=Object.assign({},nv,i.rowTree),"boolean"==typeof i.columnTree&&(i.columnTree={enabled:i.columnTree}),i.columnTree=Object.assign({},nv,i.columnTree),i.cellValidation&&(i.cellValidation=cw(i.cellValidation)),i}class cx extends(Tr(dw)){get cells(){return this._cells}get data(){return this._data}set data(t){this._data=t}get height(){return this._height??this.model.options.rowHeight}set height(t){this._height=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return Lv(this.index)}get range(){return new Ev(null,this.index,null,this.index)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t,this.model.columns.forEach((t=>this.cell(t.index).refreshFormula()))}get values(){return this.model.columns.map((t=>this.cell(t.index).value))}cell(t,e){if(this.model.options.singleCellModel)return this._singleCell||(this._singleCell=new _w(this.model,{c:t,r:this.index})),this._singleCell.row=this,this._singleCell.column=this.model.columns[t],this._singleCell;let i=this._cells[t];if((e||!i)&&this.model.columns[t]){if(i=new _w(this.model,e??{c:t,r:this.index}),this._data){const e=this.model.columns[t].data;if(null!=e){const t=this._data[e];Z(t)?(t.comment&&this.model.comments.set(i.address,[t.comment]),i.populate(t)):i.hasValue||(i.value=t)}}i.name&&this.model.names.set(i.name,i.range),this._cells[t]=i}return i}constructor(t,e){super(t,e),this.isCellInitialized=t=>!!this.cells[t],this._cells=[],null==this._priority&&(this._priority=t.options.rowPriority)}populate(t){super.populate(t),this._height=null==t.h||"auto"==t.h?this.model.options.rowHeight:t.h,t.data&&(Array.isArray(t.data)?this._data=[...t.data]:this._data={...t.data}),null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._height&&this._height!=this.model.options.rowHeight&&(t.h=this._height),t}expand(t){super.expand(t),this.model.indexVisibleRows()}collapse(){super.collapse(),this.model.indexVisibleRows()}get prev(){return this.model.rows[this.index-1]}get next(){return this.model.rows[this.index+1]}get prevVisible(){let t=this.prev;for(;t&&!t.visible;)t=t.prev;return t}get nextVisible(){let t=this.next;for(;t&&!t.visible;)t=t.next;return t}hasCellFormula(t){return this.cells[t]&&this.cells[t].hasFormula||this._data&&this._data[this.model.columns[t].data]&&this._data[this.model.columns[t].data].f}hasCellName(t){return this.cells[t]&&null!=this.cells[t].name||this._data&&this._data[this.model.columns[t].data]&&null!=this._data[this.model.columns[t].data].name}insertColumns(t,e,i=!1){let o;const r=this.model.columns.length,s=this.model.calculations;if(i)for(let i=0;i<r;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=s.getFormula(o).shift({index:t,offset:e,direction:"right"}).createFormulaString(!1));t<this.cells.length&&this.cells.splice(t,0,...Array(e).fill(null))}deleteColumns(t,e,i=!1){let o;const r=this.model.columns.length,s=this.model.calculations;if(i)for(let i=0;i<r;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=s.getFormula(o).shift({index:t,offset:e,direction:"left"}).createFormulaString(!1));return t<this.cells.length?this.cells.splice(t,e):null}clearCalculatedValues(){this.cells.forEach((t=>t&&this.model.calculations.refreshFormula(t)))}}var hx=i(4418),dx=i.n(hx);const ux=t=>t?"1":"0",px=t=>null==t?"_":t,gx=t=>null==t?"_":t.toString(),mx=t=>null==t?"_":JSON.stringify(t),fx=t=>px(t&&t.color?t.color:"_")+px(t&&t.style?t.style:"_"),vx=t=>px(t?t.horizontal:null)+px(t?t.vertical:null)+px(t?t.horizontal:null)+gx(t?t.indent:null)+ux(t?t.wrapText:null)+gx(t?t.textRotation:null),bx=t=>dx()("s_"+ux(t.bold)+ux(t.italic)+ux(t.underline)+gx(t.sz)+px(t.font)+px(t.color)+fx(t.top)+fx(t.right)+fx(t.bottom)+fx(t.left)+px(t.patternType)+px(t.fgColor)+px(t.bgColor)+vx(t.alignment)+gx(t.angle)+mx(t.stops)+ux(t.hidden)+ux(t.editable)+mx(t.cssStyle)+mx(t.icon));function yx(t){const e={...t};return delete e.id,delete e.hash,e}class wx{constructor(t){this.model=t,this._count=0,this.hashmap=new Map,this.map=new Map}add(t){if(!isNaN(t))return this.get(t);const e=this.model.options.cssStyles?kw(t):t,i=e.hash?e.hash:bx(e);return this.hashmap.has(i)?this.map.get(this.hashmap.get(i)):(null==e.id&&(e.id=this._count),this._count=Math.max(e.id+1,this._count+1),e.hash=i,this.hashmap.set(i,e.id),this.map.set(e.id,e),e)}populate(t){t.forEach((t=>this.add(t)))}get(t){return this.map.has(t)?this.map.get(t):null}remove(t){const e="object"==typeof t?t:this.map.get(t);this.hashmap.delete(e.hash),this.map.delete(e.id)}merge(...t){const e=Object.assign({},...t.map((t=>Z(t)?t:this.get(t))));return this.add(yx(e))}duplicate(t,e){const i=this.get(t);return this.add(yx({...i,...e}))}set(t,e){let i=this.map.has(t)?this.map.get(t):{};for(const t in e)i[t]=e[t];return i=i.id?i:this.add(i),i}unset(t,e){if(this.map.has(t)){const i=this.map.get(t);for(const t of e)delete i[t]}}getSourceData(){return Array.from(this.map.values())}clean(){const t=new Map(Array.from(this.map.entries()).map((([t])=>[t,0])));this.model.columns.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)})),this.model.rows.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1),e.cells.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)}))})),t.forEach(((t,e)=>{0==t&&this.remove(e)}))}}function xx(t,e,i,o){const r=o??("rows"==i?e.rows:e.columns),s=function(t){const e=new Map;for(const i of t)e.has(i.level)||e.set(i.level,[]),e.get(i.level).push(i);return e}(r),n=t[i]??[];for(const t of n){let o;if(o=t.index>-1?[r[t.index]]:t.level>-1?s.get(t.level):r,t.name){const e=t.name instanceof RegExp?t.name:new RegExp(ut(t.name));o=o.filter((t=>e.test(t.name)))}o?.forEach((o=>{null!=t.priority&&(o.priority=t.priority),t.type?e.conditionalFormats.add(Object.assign({ranges:`${o.address}:${o.address}`},t)):(o.style=e.styles.add(t.style).id,"rows"==i&&null!=t.height?o.height=t.height:"columns"==i&&null!=t.width&&(o.width=t.width))}))}}function kx(t,e){for(const i of t)if(e[i.property]!=i.value)return!1;return!0}function Cx(t,e,i){const o=t.cells??[];for(const t of o)if(t.conditions?.length){const o=e.getRangeIterator(i??e.gridRange);for(const i of o)kx(t.conditions,i)&&(i.style=e.styles.add(t.style).id)}else if(t.type)e.conditionalFormats.add(Object.assign({ranges:"A:"+e.columns[e.columns.length-1].address},t));else for(const i of e.columns)null==i.style&&(i.style=e.styles.add(t.style).id)}function Mx(t,e,i){xx(t,e,"columns",i)}function _x(t,e,i){xx(t,e,"rows",i)}function Sx(t,e){Cx(t,e),Mx(t,e),_x(t,e)}var zx;!function(t){t[t.NONE=0]="NONE",t[t.MERGED=1]="MERGED",t[t.HIDDEN=2]="HIDDEN"}(zx||(zx={}));class Ex{get mergedCells(){return this._mergedCells}get hiddenCells(){return this._hiddenCells}constructor(t){this.model=t,this._mergedCells=new Map,this._hiddenCells=new Map}clear(){this._mergedCells.clear(),this._hiddenCells.clear()}getMergeState(t){return this._mergedCells.has(t)?zx.MERGED:this._hiddenCells.has(t)?zx.HIDDEN:zx.NONE}indexMergedRange(t){const e=t.A1,i=this._mergedCells.get(e);if(!i)return;const o=i.r,r=i.c,s=t.clone(),n=this.model.rows[o]?.cell(r);if(n)for(let t=0;t<i.rs;t++)for(let e=0;e<i.cs;e++)0==t&&0==e||(s.r1=o+t,s.c1=r+e,s.r2=s.r1,s.c2=s.c1,this._hiddenCells.set(s.A1,i));else this.remove(e)}add(t){const e=new Ev(t.c,t.r),i=e.A1;if(this._mergedCells.has(i))this.remove(i);else if(this._hiddenCells.has(i))return;this._mergedCells.set(i,t),this.indexMergedRange(e)}remove(t){const e=this._mergedCells.get(t);if(!e)return;this._mergedCells.delete(t);const i=e.r,o=e.c,r=new Ev(o,i);this._hiddenCells.delete(t);for(let t=0;t<e.rs;t++)for(let s=0;s<e.cs;s++)0==t&&0==s||(r.r1=i+t,r.c1=o+s,r.r2=r.r1,r.c2=r.c1,this._hiddenCells.delete(r.A1))}shift(t){const{index:e,offset:i,direction:o}=t,r={down:t=>{e<=t.r?t.r+=i:e>t.r&&e<t.r+t.rs&&(t.rs+=i)},up:t=>{e<=t.r?t.r-=i:e>t.r&&e<t.r+t.rs&&(t.rs-=i)},right:t=>{e<=t.c?t.c+=i:e>t.c&&e<t.c+t.cs&&(t.cs+=i)},left:t=>{e<=t.c?t.c-=i:e>t.c&&e<t.c+t.cs&&(t.cs-=i)}},s=[...this._mergedCells.values()];s.forEach((t=>this.remove(new Ev(t.c,t.r).A1))),s.forEach((t=>{r[o](t),this.add(t)}))}}const Lx=["index","name","rows","columns","cells","options","sparklines","rules","comments","styles","names","props","tab","theme"];class Ix{get mergedHeaders(){return this._mergedHeaders}get hasFilter(){return this._filter}get hasRowTree(){return this._maxRowLevel>0}get hasRowTreeEnabled(){return this.hasRowTree&&this.options.rowTree.enabled}get maxRowLevel(){return this._maxRowLevel}get hasColumnTree(){return this._maxColumnLevel>0}get hasColumnTreeEnabled(){return this.hasColumnTree&&this.options.columnTree.enabled}get maxColumnLevel(){return this._maxColumnLevel}get headerCount(){return this._headerCount}get columnHeaderCount(){return this.headerCount+(this.hasColumnTreeEnabled?1:0)+(this.hasFilter?1:0)}get properties(){return this._properties}set properties(t){this._properties=t}get theme(){return this._theme}set theme(t){this._theme=t}constructor(t,e,i){this.otherModels={},this.autofitColumns=new Set,this.autofitRows=new Set,this.merges=new Ex(this),this.styles=new wx(this),this.comments=new Aw(this),this.calculations=new jw(this),this.names=new ax(this),this.sorting=new Tw(this),this.filter=new ix(this),this.sparklines=new ox(this),this.conditionalFormats=new Gw(this),this._filter=!1,this._maxRowLevel=0,this._maxColumnLevel=0,this._headerCount=0,this._levelBasedRowTree=!0,this._levelBasedColTree=!0,this.clearRows=()=>(this.rowRoot.clearChildren(),this.rows=[],this.rows),this.clearColumns=()=>this.columns=[],this.logger=i,this.options=e??lx(t.options),this.populate(t)}getConnectedModel(t){return this.group?this.group.get(t):null}getModelByRange(t){return t.sheet?this.getConnectedModel(t.sheet):this}getCellByA1(t){return this.getCellByRange(Ev.fromA1(t))}getCellByRange(t){return this.getCellByCoords(t.r1,t.c1)}getCellByCoords(t,e){return this.rows[t]?.cell(e)}cell(t,e){return isNaN(t)?t instanceof Ev?this.getCellByRange(t):"string"==typeof t?this.getCellByA1(t):null:this.getCellByCoords(t,e||0)}createRows(t,e=new cx(this,{l:-1}),i=0){let o=!1,r=!1;this.autofitRows.clear();const s=t.map(((t,e)=>{t||(t={}),isNaN(t.l)||(o=!0),null!=t.p&&(r=!0),"auto"==t.h&&this.autofitRows.add(e);const s=new cx(this,t);return s.origIndex=e+i,s.name&&this.names.set(s.name,Ev.fullRow(e)),s}));let n=-1;return o?n=$r(s,e,{reverse:this.options.rowTree.reversed}):r?n=Ar(s,e):e.children=s,r||(o=!0),[e,s,n,o]}insertRowData(t,e,i){const o=this.createRows(i,new cx(this,{l:t.level}),e);if(this._maxRowLevel=Math.max(this._maxRowLevel,o[2]),t.insertChildren(o[0].children,e),this.indexRowsByTree(),this.theme){const t=o[1];_x(this.theme,this,t),Cx(this.theme,this,new Ev(0,t[0].index,1/0,t[t.length-1].index))}}applyTheme(t,e){if(e)for(const t of this.getInitializedCellIterator())t.invalidateStyle();Sx(t,this)}populate(t){this.index=t.index,this.name=t.name??this.name,this.tab=t.tab;let e=!1,i=!1;if(t.columns||(t.columns=new Array(this.options.columns).fill({})),t.rows||(t.rows=new Array(this.options.rows).fill({})),t.styles&&this.styles.populate(t.styles),this.autofitColumns.clear(),this.columns=t.columns.map(((t,o)=>{t||(t={}),t.l>0&&(e=!0),null!=t.p&&(i=!0),"auto"==t.w&&this.autofitColumns.add(o);const r=new zw(this,t);return this._filter=r.hasFilter||this._filter,r.name&&this.names.set(r.name,Ev.fullColumn(o)),r})),this._levelBasedColTree=e,this._maxColumnLevel=-1,this.colRoot=new zw(this,{l:-1}),e?this._maxColumnLevel=$r(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}):i?this._maxColumnLevel=Ar(this.columns,this.colRoot):this.colRoot.children=this.columns,i||(this._levelBasedColTree=!0),this.indexColumns(),this.indexVisibleColumns(),[this.rowRoot,this.rows,this._maxRowLevel,this._levelBasedRowTree]=this.createRows(t.rows),this.indexRows(),this.indexVisibleRows(),this.options.pageSize&&this.options.pageSize<=this.rows.length&&(this.rowRoot.count=1/0),this.merges.clear(),t.comments=t.comments||[],t.cells?.forEach(((e,i)=>{const o=this.rows[e.r]?this.rows[e.r].cell(e.c,e):null;o?(e.cs>1||e.rs>1)&&this.merges.add({r:o.r,c:o.c,rs:e.rs||1,cs:e.cs||1}):this.logger?.error(`invalid cell definition (index ${i}): ${JSON.stringify(e)}`),o&&e.comment&&t.comments.push(Object.assign(e.comment,{c:e.c,r:e.r}))})),t.sparklines)try{this.sparklines.populate(t.sparklines)}catch(t){Lr().error(`Sparkline init error: ${t}`)}if(t.names)try{this.names.populate(t.names)}catch(t){Lr().error(`Named range init error: ${t}`)}if(t.rules)try{this.conditionalFormats.populate(t.rules)}catch(t){Lr().error(`Conditional formats init error: ${t}`)}if(t.theme)try{this.applyTheme(t.theme),this._theme=t.theme}catch(t){Lr().error(`Theme init error: ${t}`)}if(t.comments)try{this.comments.populate(t.comments)}catch(t){Lr().error(`Comment init error: ${t}`)}this._properties=t.props,this.otherSourceData={};const o=new Set(Lx),r=Object.keys(t).filter((t=>!o.has(t)));r.forEach((e=>this.otherSourceData[e]=t[e])),this.options.sorting?.defaultSettings&&(this.sorting.settings=this.options.sorting.defaultSettings),this.options.filters?.defaultSettings&&(this.filter.settings=this.options.filters.defaultSettings),this.calcHeaderHeights()}getSourceData(){const t={index:this.index,name:this.name,tab:this.tab,columns:this.columns.map((t=>t.getSourceData())),rows:this.rows.map((t=>t.getSourceData())),styles:this.styles.getSourceData(),rules:this.conditionalFormats.getSourceData(),sparklines:this.sparklines.getSourceData(),names:this.names.getSourceData(),options:this.options};this._properties&&(t.props=this._properties);const e=[];let i;for(let t=0;t<this.rows.length;t++)for(let o=0;o<this.columns.length;o++)i=this.rows[t].cell(o).getSourceData(),Object.keys(i).length>0&&(i.r=t,i.c=o,e.push(i));e.length>0&&(t.cells=e);const o=[];return this.styles.clean(),this.styles.map.forEach((t=>o.push(t))),o.length>0&&(t.styles=o),new Set([...Object.keys(this.otherModels??{}),...Object.keys(this.otherSourceData??{})]).forEach((e=>t[e]=this.otherModels[e]?Array.from(this.otherModels[e]).map((t=>t.getSourceData())):this.otherSourceData[e])),t}calcHeaderHeights(){this._headerCount=0,this._headerHeights=[],this.columns.forEach((t=>{this._headerCount=t.header?t.header.length:this._headerCount,this._headerHeights.length<this._headerCount&&this._headerHeights.push(...Array(this._headerCount-this._headerHeights.length).fill(0)),t.header?.forEach(((t,e)=>{e>=this._headerHeights.length&&this._headerHeights.push(0),this._headerHeights[e]=Math.max(this._headerHeights[e],t.height??0)}))}))}indexRows(){this.visibleRows=[],this.rows.forEach(((t,e)=>{t.index=e,t.isLoaded||(t.collapsed=!0),t.hidden||t.filterState==Ir.Filtered||(t.visibleIndex=this.visibleRows.length,this.visibleRows.push(t))}))}indexVisibleRows(){this.visibleRows=[];let t=0;if(this._levelBasedRowTree){if(this.rowRoot.walkVisible((e=>{e.visibleIndex=t++,this.visibleRows.push(e)})),this.options.rowTree.reversed){const e=new Array(this.visibleRows.length);this.visibleRows.forEach(((i,o)=>{t=this.visibleRows.length-o-1,i.visibleIndex=t,e[t]=i})),this.visibleRows=e}}else this.rowRoot.walkVisible((t=>this.visibleRows[t.index]=t)),this.visibleRows=this.visibleRows.filter((e=>!!e&&(e.visibleIndex=t++,!0)))}indexRowsByTree(){this.rows=[];let t=0;this.rowRoot.walk((e=>{e.index=t++,this.rows.push(e)})),this.options.rowTree.reversed&&this.rows.reverse(),this.indexVisibleRows()}indexColumns(){this.visibleColumns=[],this.columns.forEach(((t,e)=>{t.index=e,t.hidden||this.visibleColumns.push(t)}))}indexVisibleColumns(){this.visibleColumns=[],this.visibleColumnIndex={};let t=0;if(this.colRoot.walkVisible((e=>{e.visibleIndex=t,this.visibleColumnIndex[e.index]=t++,this.visibleColumns.push(e)})),this.options.columnTree.reversed){this.visibleColumnIndex={};const e=new Array(this.visibleColumns.length);this.visibleColumns.forEach(((i,o)=>{t=this.visibleColumns.length-o-1,i.visibleIndex=t,this.visibleColumnIndex[i.index]=t,e[t]=i})),this.visibleColumns=e}this.indexHeaders()}indexHeaders(){this._mergedHeaders=[],this._headerCount=0,this.colRoot.walkVisible((t=>{this._headerCount=Math.max(t.header?t.header.length:0,this._headerCount),t.mergedHeaders.forEach((e=>this._mergedHeaders.push({h:e,c:t.index,r:e.r,cs:t.calculateRealColspan(e.cs??1),rs:e.rs??1})))})),this._mergedHeaders.forEach((t=>{if(!t.h.hidden)for(let e=t.c;e<t.c+t.cs;e++)for(let i=t.r;i<t.r+t.rs;i++)(i>t.r||e>t.c)&&this.columns[e]&&this.columns[e].header[i]&&(this.columns[e].header[i].hidden=!0)})),this.calcHeaderHeights()}removeHeader(t){this.columns.forEach((e=>{t<e.header.length&&e.header.splice(t,1)})),this.indexHeaders()}clear(){this.clearRows(),this.clearColumns(),this.resetViewport()}resetViewport(){return this._viewport=null,this}getViewport(t,e,i){const o=[],r=[];let s,n,a=e.h,l=0;for(l=0;l<i.t;l++)s=this.visibleRows[l],a-=s.height,o.push(s);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)s=this.visibleRows[l],a-=s.height;for(l=i.t+t.r;a>0&&l<this.visibleRows.length;)s=this.visibleRows[l++],a-=s.height,o.push(s);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)o.push(this.visibleRows[l]);let c=e.w,h=0;for(h=0;h<i.l;h++)n=this.visibleColumns[h],c-=n.width,r.push(n);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)n=this.visibleColumns[h],c-=n.width;for(h=i.l+t.c;c>0&&h<this.visibleColumns.length;)n=this.visibleColumns[h++],c-=n.width,r.push(n);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)r.push(this.visibleColumns[h]);return this._viewport={rows:o,columns:r}}calculateViewport(){return this._viewport?this.calculations.calculateViewport(this._viewport):[]}getValuesInRange(t,e=!1){if(!(t=t.intersect(this.gridRange)))return[];const{columns:i,rows:o}=t.size,r=new Array(o);let s,n=0,a=0;for(let o=t.r1;o<=t.r2;o++){r[n]=new Array(i),a=0,s=this.rows[o];for(let i=t.c1;i<=t.c2;i++)r[n][a++]=e?s.cell(i).formattedValue:s.cell(i).value;++n}return r}setRowExpandLevel(t){this.rows.forEach((e=>{e.collapsed=!e.isLoaded&&!e.isPartialyLoaded||e.level>=t,e.level<=t&&(e.hidden=!1)})),this.indexVisibleRows()}setColumnExpandLevel(t){this.columns.forEach((e=>e.collapsed=e.level>=t)),this.indexVisibleColumns()}getViewportRange(){return this._viewport&&this._viewport.columns.length&&this._viewport.rows.length?new Ev(this._viewport.columns[0].index,this._viewport.rows[0].index,this._viewport.columns[this._viewport.columns.length-1].index,this._viewport.rows[this._viewport.rows.length-1].index):null}get gridRange(){return new Ev(0,0,this.columns.length-1,this.rows.length-1)}getRangeIterator(t,e=!1){const i=e&&this._viewport?this.getViewportRange():this.gridRange;return new rx(this,i&&t.intersect(i))}getInitializedCellIterator(){return new rx(this,this.gridRange,!0)}getRowIterator(t,e=!1){const i=e&&this._viewport?this.getViewportRange():this.gridRange;return new nx(this,i&&t.intersect(i),"rows")}getColumnIterator(t,e=!1){const i=e&&this._viewport?this.getViewportRange():this.gridRange;return new nx(this,i&&t.intersect(i),"columns")}getCellArray(t){const e=[];for(const i of this.getRangeIterator(t))e.push(i);return e}transformRangeToMatrix(t,e){let i,o,r;const s=[];for(let n=(t=t.intersect(this.gridRange)).r1;n<=t.r2;n++)if(i=this.rows[n],i){r=[];for(let s=t.c1;s<=t.c2;s++)o=i.cell(s),o&&r.push(e(o));s.push(r)}return s}getCellMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t))}getValueMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t.value))}shift(t){t.sheet=this.name,this.merges.shift(t),this.calculations.shift(t),this.names.shift(t),this.comments.shift(t),this.sparklines.shift(t)}clearCalculations(t=!1){t&&this.group?this.group.models.forEach((t=>t.calculations.refresh())):this.calculations.refresh()}refreshSparklines(){this.sparklines.updateRangeMaps();for(const t of this.getInitializedCellIterator())t.invalidateStyle()}clearCalculatedStyles(){this.conditionalFormats.refresh();const t=[];for(const e of this.getInitializedCellIterator())t.push(e),e.invalidateStyle()}insertColumns(t,e,i=!1){const o=this.columns[Math.min(this.columns.length-1,t)].parent;i&&++t,this.shift({index:t,offset:e,direction:"right"});for(let i=0;i<this.rows.length;i++)this.rows[i].insertColumns(t,e,!1);const r=new Array(e).fill(null).map((()=>new zw(this)));return this.columns.splice(t,0,...r),this.maxColumnLevel>0&&o.insertChildren(r,t-(o.index||-1)-1),this.indexColumns(),this.clearCalculations(!0),r}deleteColumns(t,e){const i=this.columns[t].parent;this.shift({index:t,offset:e,direction:"left"});const o=[];for(let i=0;i<this.rows.length;i++)o.push(this.rows[i].deleteColumns(t,e,!1));const r=this.columns.splice(t,e);return i?.deleteChildren(r),this.indexColumns(),this.clearCalculations(!0),r}insertRows(t,e,i=!1){const o=Math.min(this.rows.length-1,t),r=o<0?this.rowRoot:this.rows[o].parent;i&&++t;const s=isNaN(e)?e.length:e;this.shift({index:t,offset:s,direction:"down"});const n=isNaN(e)?e:new Array(s).fill(null).map((()=>new cx(this)));return this.rows.splice(t,0,...n),this.maxRowLevel>0&&r.insertChildren(n,t-(r.index||-1)-1),this.indexRows(),this.theme&&(_x(this.theme,this,n),Cx(this.theme,this,new Ev(0,n[0].index,1/0,n[n.length-1].index))),this.clearCalculations(!0),n}deleteRows(t,e){const i=this.rows[t].parent;this.shift({index:t,offset:e,direction:"up"});const o=this.rows.splice(t,e);return i?.deleteChildren(o),this.indexRows(),this.clearCalculations(!0),o}moveRows(t,e,i){const o=this.rows.splice(t,e);return this.rows.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"down",maxIndex:t+e-1}),this.indexRows(),this.clearCalculations(!0),o}moveColumns(t,e,i){const o=this.columns.splice(t,e);return this.columns.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"right",maxIndex:t+e-1}),this.indexColumns(),this.clearCalculations(!0),o}spillValues(t){const{cell:e,values:i,displayValues:o,propertyCell:r}=t,s=[],n=[],a=0===i.length||0===i[0].length;let l,c;const h=a?null:new Ev(e.c,e.r,e.c+i[0].length-1,e.r+i.length-1);if(e.spillRange&&this.getRangeIterator(e.spillRange,!0).forEach((t=>{e==t||h?.contains(t.range)||t.clearSpilledValue()})),e.spillRange=h,a)return{cells:s,oldValues:n,range:null};for(let t=h.r1;t<=h.r2;t++){if(l=this.rows[t],!l)continue;const a=t-h.r1;for(let t=h.c1;t<=h.c2;t++){const d=t-h.c1;c=l.cell(t),c.editable&&(n.push(c.value2),c.spillValue(i[a][d],e),r&&(c.format=r.format,c.type=r.type),o&&null!=o[a][d]&&(c.displayValue=o[a][d]),s.push(c))}}return{cells:s,oldValues:n,range:h}}getCellByName(t,e,i=!0){return this.names.getCellByName(t,e)||(this.group&&i?this.group.getCellByName(t,e):null)}getRangeByName(t,e=!0){return this.names.getRangeByName(t)||(this.group&&e?this.group.getRangeByName(t):null)}getValueMatrixByName(t,e=!0){const i=this.names.getRangeByName(t);return i?this.getValueMatrix(i):this.group&&e?this.group.getValueMatrixByName(t):null}rebuildRowTree(){const t=this._levelBasedRowTree?$r:Ar;this._maxRowLevel=t(this.rows,this.rowRoot,{reverse:this.options.rowTree.reversed}),this.indexRowsByTree()}rebuildColumnTree(){const t=this._levelBasedColTree?$r:Ar;this._maxColumnLevel=t(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}),this.indexColumns()}calculateCellOffset(t){let e=0,i=0;for(let i=0;i<t.c1&&this.columns[i];i++)e+=this.columns[i].width;for(let e=0;e<t.r1&&this.rows[e];e++)i+=this.rows[e].height;return{x:e,y:i}}}class Rx{get errors(){return this._errors}get(t){return this.models.get(t)}has(t){return this.models.has(t)}getNewName(){let t;do{t=`sheet${this._max}`}while(this.models.has(t));return t}add(t){if(t.index=t.index??this._max,++this._max,t.name=t.name||this.getNewName(),this.models.has(t.name))throw Error(`sheet "${t.name}" already exists`);return this.models.set(t.name,t),t.group=this,t}duplicate(t){const e=this.get(t);if(!e)return;const i=new Ix(e.getSourceData(),e.options);let o=1;for(;this.models.has(`${t}_${o}`);)++o;return i.name=`${t}_${o}`,this.add(i),i}remove(t){return this.models.delete(t),this}rename(t,e){if(this.has(t)){if(this.has(e))throw new Error(`Model '${e}' already exists`);const i=this.get(t);i.name=e,this.models.set(e,i),this.models.delete(t),this.models.forEach((i=>{i.calculations.renameSheet(t,e)&&i.calculateViewport()}))}return this}clear(){this.models.clear(),this._errors=[]}constructor(t){this._max=0,this.models=new Map,this.themes=new Map,this._errors=[],t&&this.populate(t)}populate(t){this.clear(),t.models.forEach((t=>{const e=new Ix(t);try{this.add(e)}catch(t){this.errors.push(t)}})),t.themes&&t.themes.forEach((t=>this.themes.set(t.name,t)))}getSourceData(){const t={models:[]};return this.models.forEach((e=>t.models.push(e.getSourceData()))),t}getCellByName(t,e){for(const i of this.models.values()){const o=i.getCellByName(t,e,!1);if(o)return o}return null}getRangeByName(t){for(const e of this.models.values()){const i=e.getRangeByName(t,!1);if(i)return i}return null}getValueMatrixByName(t){for(const e of this.models.values()){const i=e.getValueMatrixByName(t,!1);if(i)return i}return null}}class Tx{constructor(t){this.model=t,this.stack=[],this.restack=[]}push(t){return this.restack=[],t.timestamp||(t.timestamp=Date.now()),this.stack.push(t),this}pop(t=1){let e=0;const i=[];for(;e++<t&&this.stack.length>0;){const t=this.stack.pop();i.push(t),this.restack.push(t)}return i}pop2(t=1){let e=0;const i=[];for(;e++<t&&this.restack.length>0;){const t=this.restack.pop();i.push(t),this.stack.push(t)}return i}}class $x{get activeCellCoords(){return{c:this.range.c1+this.activeCell.c1,r:this.range.r1+this.activeCell.r1}}constructor(t,e,i,o){this.hidden=!1,this.range=new Ev(t,e,i,o),this.activeCell=new Ev(0,0)}static fromRange(t){return new $x(t.c1,t.r1,t.c2,t.r2)}setCoords(t,e,i,o){this.range.setCoords(t,e,i,o),this.activeCell.setCoords(0,0)}setRange(t){"string"==typeof t&&(t=Ev.fromA1(t)),this.range.setCoords(t.c1,t.r1,t.c2,t.r2),this.activeCell.setCoords(0,0)}move(t,e,i,o){this.range.setCoords(this.range.c1+this.activeCell.c1,this.range.r1+this.activeCell.r1,this.range.c1+this.activeCell.c2,this.range.r1+this.activeCell.r2),this.range.move(t,e,i,o,!1),this.activeCell.setCoords(0,0)}moveRange(t,e,i,o){this.range.move(t,e,i,o,!0)}moveActiveCell(t,e){const{columns:i,rows:o}=this.range.size;this.activeCell.move(t,e,i,o,!0)}}const Ax={...av,CUSTOM_CLIPBOARD_TYPE:"web application/json"};class Dx{constructor(t,e,i=Ax.MAX_CACHE_ITEMS){this.maxCacheItems=i,this.queue=[],this.disabled=!1,this.table=new Array(e).fill(null).map((()=>new Array(t)))}get(t,e){return this.table[e][t]}delete(t,e){return this.table[e][t]=null,this}deleteColumn(t){for(let e=0;e<this.table.length;e++)this.table[e][t]=null;return this}deleteRow(t){return this.table[t]=new Array(this.table[0].length).fill(null),this}set(t,e,i){this.disabled||(this.get(t,e)||this.queue.push([e,t]),this.table[e][t]=i)}clear(){this.queue=[],this.table=this.table.map((t=>new Array(t.length)))}clean(){if(this.maxCacheItems>0&&this.queue.length>this.maxCacheItems){let t=this.queue.length;for(let e=0;e<this.queue.length;e++){const i=this.queue[e];if(!this.table[i[0]][i[1]].parentNode&&(this.queue[e]=null,this.table[i[0]][i[1]]=null,--t<=this.maxCacheItems))break}t<this.queue.length&&(this.queue=this.queue.filter((t=>t)))}}}var Ox=function(t,e,i,o){var r,s=arguments.length,n=s<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(s<3?r(n):s>3?r(e,i,n):r(e,i))||n);return s>3&&n&&Object.defineProperty(e,i,n),n};const Nx=t=>{if(null==t||""===t)return"";if(t instanceof Date)return t.toLocaleDateString();if("string"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleDateString()}return String(t)};let Px=class extends En{constructor(){super(),this.render=()=>ln`
3981
3981
  <og-icon id="filterIcon" .icon="${{icon:"filter"}}"></og-icon>
3982
3982
  <div class="text">${this.renderValue()}</div>
3983
3983
  `}connectedCallback(){super.connectedCallback()}renderValue(){return null==this.value?"":Y(this.value)?ln`<og-icon .icon="${this.value?"square-check":"square"}"></og-icon>`:(t=>!!t&&"object"==typeof t&&!Array.isArray(t)&&"range"===t.kind)(this.value)?(t=>{const e=Nx(t.from),i=Nx(t.to);return e&&i?`${e} – ${i}`:e?`≥ ${e}`:i?`≤ ${i}`:""})(this.value):"object"==typeof this.value?"":this.value}};Px.styles=ks`
@@ -8603,7 +8603,7 @@ milkdown-block-handle {
8603
8603
  border-left: none;
8604
8604
  height: 100%;
8605
8605
  }
8606
- `],DE([$n({type:Object})],OE.prototype,"item",void 0),DE([$n({type:String})],OE.prototype,"value",void 0),DE([On("og-dropdown")],OE.prototype,"dropdown",void 0),DE([On("og-button")],OE.prototype,"button",void 0),DE([On(".btn-content")],OE.prototype,"btnContent",void 0),OE=DE([In("og-toolbar-colorpicker")],OE);class NE{static init(t){this.path=t}static async get(){return this.xlsx||(this.xlsx=await this.load()),this.xlsx}static getSync(){return this.xlsx}static load(){if(!cs.require)throw new Error("AMDLoader is not initialized");return cs.require.config({paths:{xlsx:this.path+"/xlsx.full.min"}}),new Promise((t=>cs.require(["xlsx"],(()=>t(self.XLSX)))))}}const PE="aaaaaa",jE={bottom:{style:"thin",color:PE},top:{style:"thin",color:PE},right:{style:"thin",color:PE},left:{style:"thin",color:PE}},HE={exportHiddenRows:!0,exportHiddenColumns:!0,gridLines:!0,defaultBorders:!1,dropdownCells:"value"},FE={alignment:{vertical:"center",horizontal:"center"},bold:!0},BE={g:"n",b:"b",t:"s",n:"n",d:"d",dt:"d",s:"s",m:"s",tm:"s",h:"s",a:"z"};function WE(t,e){return(e.exportHiddenColumns?t.columns:t.visibleColumns).map((e=>({level:e.level,wpx:e.width,hidden:null==e.visibleIndex||t.visibleColumns[e.visibleIndex]!=e})))}function VE(t,e){const i=e.exportHiddenRows?t.rows:t.visibleRows,o=t.headerCount,r=new Array(i.length+o);return[...Array(o).keys()].map((t=>r[t]={level:0})),i.map(((e,i)=>r[i+o]={level:e.level,hpt:.75*e.height,hidden:null==e.visibleIndex||t.visibleRows[e.visibleIndex]!=e})),r}function UE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t=>t.c:e=>t.columns[e.c].visibleIndex,r=[];return t.merges.mergedCells.forEach((t=>{r.push({s:{c:o(t),r:t.r+i},e:{c:o(t)+t.cs-1,r:t.r+i+t.rs-1}})})),t.mergedHeaders.forEach((t=>{t.h?.hidden||r.push({s:{c:o(t),r:t.r},e:{c:o(t)+t.cs-1,r:t.r+t.rs-1}})})),r}function GE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t.columns:t.visibleColumns,r=XE(e);return[...Array(i).keys()].map((e=>o.map((i=>{const o=i.header[e],s={t:o?"s":"z",s:FE};return o&&(o.html?s.h=`<span>${o.label}</span>`:null!=o.label?s.v=o.label:s.t="z"),r&&(s.s||(s.s={}),s.s=Object.assign({},r,s.s)),null!=o._style&&(s.s=Object.assign({},s.s,ZE(t.styles.get(o._style)))),s}))))}function qE(t){return{rgb:t}}function YE(t){return"none"==t.style?null:{style:t.style,color:qE(t.color)}}function ZE(t){const e={};return t.color&&(e.color=qE(t.color)),t.bgColor&&(e.bgColor=qE(t.bgColor)),t.fgColor&&(e.fgColor=qE(t.fgColor)),t.patternType&&(e.patternType=t.patternType),t.alignment&&(e.alignment=t.alignment),null!=t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.bottom&&(e.bottom=YE(t.bottom)),t.top&&(e.top=YE(t.top)),t.right&&(e.right=YE(t.right)),t.left&&(e.left=YE(t.left)),null!=t.angle&&(e.angle=t.angle),t.stops&&(e.stops=t.stops.map((t=>({v:t.v,rgb:t.rgb})))),e}function XE(t){const e=!0===t.defaultBorders?jE:t.defaultBorders;return e?function(t){const e={};return t.bottom&&(e.bottom=YE(t.bottom)),t.top&&(e.top=YE(t.top)),t.right&&(e.right=YE(t.right)),t.left&&(e.left=YE(t.left)),e}(e):null}function QE(t,e){const i=NE.getSync();e=iL(e);const o=t.headerCount,r=new jw(t),s=new Array(o+t.rows.length),n=new Map,a=XE(e),l=t.options.dateFormat||"yyyy-MM-dd",c="displayValue"==e.dropdownCells;GE(t,e).forEach(((t,e)=>s[e]=t));const h=e.exportHiddenRows?t.rows:t.visibleRows,d=e.exportHiddenColumns?t.columns:t.visibleColumns;return h.forEach(((t,e)=>s[e+o]=d.map((e=>{const s=t.cell(e.index),h=s.type,d=BE[h],u={t:s.hasValue?d:"z"};s.hasFormula?(u.f=o>0?r.getFormula(s).clone().shift({index:0,offset:o,direction:"down"}).toExcelString():r?r.getFormula(s).toExcelString():s.formula,"d"==d&&(u.t="n",u.z=s.format??l)):s.hasValue&&!s.isSpilled&&("s"==u.t?u.v=c?s.formattedValue.toString():s.value.toString():"z"!=u.t&&(u.v=s.value),"g"==h?u.t=Q(u.v)?"s":"n":"d"==h?tt(u.v)&&(u.t="n"):"h"==h&&i.utils.html_to_rs&&(u.R=i.utils.html_to_rs(s.value)));const p=s.composedStyle;if(p&&(n.has(p.id)||n.set(p.id,ZE(p)),u.s={...n.get(p.id)}),function(t,e){const i=t.calculatedIndent;i>0&&(e.s||(e.s={}),e.s.alignment||(e.s.alignment={}),e.s.alignment.indent=i)}(s,u),s.hasComment){const t=s.model.comments.get(s.address),e=[];e.push({R:[]}),e.hidden=!0,e["!pos"]={x:0,y:0,w:400,h:200},t.forEach((t=>{if(!t.text)return;const i=t.author?t.author.name??t.author.id:null;let o="";i&&(o=i),t.date&&(o+=(o?" - ":"")+Zo(t.date,Yo({withTime:!0}))),o&&e[0].R.push({t:"s",v:o+"\n",s:{bold:!0}}),e[0].R.push({t:"s",v:t.text+"\n"})})),u.c=e}return"n"!=u.t&&"d"!=u.t||null!=u.z||(u.z=s.format??("d"==u.t?l:"General")),a&&(u.s||(u.s={}),u.s=Object.assign({},a,u.s)),u})))),s}function KE(t,e){return t||e?{t:(t=Object.assign({},e,t)).t,v:t.v,color:qE(t.color)}:null}function JE(t){const e=t.headerCount;return t.conditionalFormats.getSourceData().map((t=>({ref:Ev.fromA1s(t.ranges).map((t=>t.shiftDown(0,e,null,!0).A1)).join(" "),t:t.type,f:t.condition&&gv(t.condition[0])?"A1"+t.condition:t.condition??null,s:t.style?ZE(t.style):null,stop:t.stop,cmin:KE(t.cmin,"bar"==t.type?{t:"min",color:t.color}:null),cmid:t.cmid?KE(t.cmid,{v:50,t:"percentile"}):null,cmax:KE(t.cmax,"bar"==t.type?{t:"max",color:t.color}:null),color:qE(t.color),v:t.v,thresh:t.thresh})))}function tL(t){if(t.options.rowTree.reversed)return"below";const e=t.rows;if(e.length<2)return"above";for(let t=1;t<e.length;t++)if(e[t].level!=e[t-1].level)return e[t].parent==e[t-1]?"above":"below";return t.rows[0].level>t.rows[1].level?"below":"above"}function eL(t){return null==t.options.columnTree.reversed?t.columns.length<2?"left":t.columns[0].level>t.columns[1].level?"right":"left":t.options.columnTree.reversed?"right":"left"}const iL=t=>{const e=Object.assign({},HE,t);return e.defaultBorders&&(e.defaultBorders=jE),e},oL=t=>t/25.4;function rL(t){return t?{top:oL(t.top),bottom:oL(t.bottom),left:oL(t.left),right:oL(t.right),header:oL(t.header),footer:oL(t.footer)}:null}function sL(t,e){e=iL(e);const i={};return i["!cols"]=WE(t,e),i["!rows"]=VE(t,e),i["!merges"]=UE(t,e),i["!condfmt"]=JE(t),i["!outline"]={above:"above"==tL(t),left:"left"==eL(t)},t.options.freezeLeft||t.options.freezeTop?i["!freeze"]=`${Rv(t.options.freezeLeft)}${t.headerCount+t.options.freezeTop+1}`:t.headerCount>0&&(i["!freeze"]=`A${t.headerCount+1}`),i["!gridlines"]=e.gridLines,i["!print"]=function(t,e){const i=t.options.print??{},o={props:{}};o.props.scale=i.scale?i.scale:function(t){const e=t.options.print??{},i=Q(e.paper)?ts[e.paper]??ts.A4:e.paper,o=oL(i.width-e.margins.left-e.margins.right),r=t.columns.reduce(((t,e)=>t+e.width),0)/96;return Math.round(o/r*100)-2}(t),o.props.paper=i.paper,o.props.orientation=i.orientation,i.margins&&(o.margins=rL(i.margins));const r=i.rowBreaks;if(r?.length>0){o.rowBreaks=r.map((i=>({R:e.exportHiddenRows?i:t.rows[i].visibleIndex})));const i=t.options?.print?.rowTitles?Ev.fromA1(t.options?.print?.rowTitles):null;i&&(o.titles={s:{r:i.r1,c:-1},e:{r:i.r2,c:-1}})}return o}(t,e),i}async function nL(t,e){const i=NE.get(),o=i instanceof Promise?await i:i;e=iL(e);const r=o.utils.book_new();return t.forEach(((t,i)=>{t.calculations.evaluateAll();const s={...e,...t.exportOptions},n=o.utils.sheet_add_aoa(sL(t,s),QE(t,s));let a=t.name||`Sheet${i+1}`;t.name=a,a.length>31&&(a=a.substring(0,31)),o.utils.book_append_sheet(r,n,a)})),r.Workbook=r.Workbook||{},t.forEach((t=>{const e=r.SheetNames.indexOf(t.name);e<0||(r.Workbook.Sheets||(r.Workbook.Sheets=[]),r.Workbook.Sheets[e]||(r.Workbook.Sheets[e]={}),t.tab?.hidden&&(r.Workbook.Sheets[e].Hidden=1))})),r}async function aL(t,e=null){const i=NE.get(),o=i instanceof Promise?await i:i;return e?o.writeFile(t,e,{cellStyles:!0,bookSST:!0}):o.writeXLSX(t,{cellStyles:!0,bookSST:!0,type:"buffer"})}const lL={b:"b",s:"t",n:"n",d:"d",z:"g",e:"t"};function cL(t){return t.rgb}function hL(t){return{color:cL(t.color),style:t.style}}function dL(t){const e={};return t.color&&(e.color=cL(t.color)),t.bgColor&&(e.bgColor=cL(t.bgColor)),t.fgColor&&(e.fgColor=cL(t.fgColor)),e.fgColor||"000000"!=e.color||(e.color=null),t.alignment&&(e.alignment=t.alignment),t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.top&&(e.top=hL(t.top)),t.bottom&&(e.bottom=hL(t.bottom)),t.left&&(e.left=hL(t.left)),t.right&&(e.right=hL(t.right)),e}function uL(t,e){const i=t["!ref"]?Ev.fromA1(t["!ref"]):Ev.fromA1("A1:T100"),o={},r={};if(t["!freeze"]){const e=Ev.fromA1(t["!freeze"]);r.freezeLeft=e.c1,r.freezeTop=e.r1}return o.options=r,o.rows=function(t,e){const i=t["!rows"]??[],o=new Array(e);let r;for(let t=0;t<e;t++)r=i[t],o[t]={l:(r?r.level:0)||0,h:r?r.hpx:null};return o}(t,i.r2+1),o.columns=function(t,e){const i=t["!cols"]??[],o=new Array(e);let r;for(let t=0;t<e;t++)r=i[t],o[t]={l:(r?r.level:0)||0,w:r?r.wpx:null};return o}(t,i.c2+1),o.cells=function(t){const e=[],i=new Map;(t["!merges"]??[]).forEach((t=>{const e=new Ev(t.s.c,t.s.r);i.set(e.A1,{c:t.s.c,cs:t.e.c-t.s.c+1,r:t.s.r,rs:t.e.r-t.s.r+1})}));for(const o in t){if("!"==o[0])continue;const r=t[o],s=Ev.fromA1(o),n={r:s.r1,c:s.c1,t:lL[r.t]},a=i.get(o);a&&(n.cs=a.cs,n.rs=a.rs),r.s&&(n.s=dL(r.s)),r.f?n.f=Bv(r.f):n.v=r.v,["n","d"].includes(r.t)&&null!=r.z&&"General"!=r.z&&(n.z=yr(r.z,"d")),e.push(n)}return e}(t),o.names=e,o.rules=function(t){return t["!condfmt"]?.filter((t=>["formula","scale","bar"].includes(t.t))).map((t=>{const e={type:t.t,ranges:t.ref.toString().replace(/\s/g,";")};return e.style=t.s?dL(t.s):null,e.cmin=t.cmin?{t:t.cmin.t,color:t.cmin.color?cL(t.cmin.color):null}:null,e.cmid=t.cmid?{t:t.cmid.t,color:t.cmid.color?cL(t.cmid.color):null}:null,e.cmax=t.cmax?{t:t.cmax.t,color:t.cmax.color?cL(t.cmax.color):null}:null,e.color=t.color?cL(t.color):null,e.condition=t.f,e.stop=!0,e}))}(t),o}function pL(t){const e=new Map;return t.Workbook.Names.forEach((({Name:t,Ref:i})=>{const[o,r]=i.split("!");if(!r)return;let s=e.get(o);s||e.set(o,s=[]);const n=Ev.fromA1(r);n.c1Anchor&&!n.r1Anchor?(n.r1=0,n.r2=1/0):!n.c1Anchor&&n.r1Anchor&&(n.c1=0,n.c2=1/0),n.removeAnchors(),s.push({name:t,ref:n.A1})})),e}async function gL(t,e){return performance.mark("start_import"),fL(await t.arrayBuffer(),e)}function mL(t){const e=pL(t);performance.mark("sheets_start");const i={models:[],layout:{items:[{tabs:[]}]}};for(const o in t.Sheets)performance.mark(`sheet_start_${o}`),i.layout.items[0].tabs.push({id:o}),i.models.push({...uL(t.Sheets[o],e.get(o)),name:o}),performance.mark(`sheet_end_${o}`);return performance.mark("sheets_end"),i}async function fL(t,e){performance.mark("array_buffer");const i=t instanceof ArrayBuffer?new Uint8Array(t):t,o=(await NE.get()).read(i,Object.assign({cellNF:!0,cellText:!1,cellStyles:!0,type:"buffer"},e||{}));return performance.mark("wb_read"),mL(o)}class vL extends fu{init(t){NE.get(),t.commands.add({group:"plugin",name:"export xlsx",exec:async()=>{const e=t.getGridContainer().model.models;aL(await nL(Array.from(e,(t=>t[1]))),"export.xlsx")}}),t.addEventListener("drop",(async e=>{if(e.preventDefault(),e.dataTransfer.files.length){const i=e.dataTransfer.files[0];t.setSourceData(await gL(i))}}))}}vL.pluginName="xlsx";class bL{get dataRange(){return this._dataRange}set dataRange(t){this._dataRange=t,this.invalidateData()}get seriesRange(){return this._seriesRange}set seriesRange(t){this._seriesRange=t,this.invalidateData()}get categoriesRange(){return this._categoriesRange}set categoriesRange(t){this._categoriesRange=t,this.invalidateData()}get title(){return this._title}set title(t){this._title=t,this.invalidateData()}get size(){return this._size}set size(t){this._size=t}get location(){return this._location}set location(t){this._location=t,this.invalidateData()}get type(){return this._type}set type(t){this._type=t,this.invalidateData()}get grouping(){return this._grouping}set grouping(t){this._grouping=t,this.invalidateData()}get datasheetName(){return this.dataRange?.sheet}get dependencies(){if(this._dependencies)return this._dependencies;if(this._dependencies=new Set,this.seriesRange)for(const t of this.seriesRange.cells())this._dependencies.add(t.A1);if(this.categoriesRange)for(const t of this.categoriesRange.cells())this._dependencies.add(t.A1);if(this.dataRange)for(const t of this.dataRange.cells())this._dependencies.add(t.A1);return this._dependencies}invalidateData(){this._options=void 0,this._dependencies=void 0}constructor(t,e){this.model=t,this._inverted=!1,this.populate(e),this.init()}populate(t){this._dataRange=Ev.fromA1(t.dataRange),this._title=t.title,this._size=t.size,this._location=t.location,this._type=t.type,this._grouping=t.grouping,this.zIndex=t.zIndex,t.seriesRange&&(this._seriesRange=Ev.fromA1(t.seriesRange)),t.categoriesRange&&(this._categoriesRange=Ev.fromA1(t.categoriesRange))}getSourceData(){return{dataRange:this.dataRange.A1,seriesRange:this.seriesRange?.A1,categoriesRange:this.categoriesRange?.A1,title:this.title,size:this.size,location:this.location,type:this.type,grouping:this.grouping,zIndex:this.zIndex}}getSeriesData(t,e){return t.map(((t,i)=>{return{type:this.type,name:e[i],stacking:(o=this.grouping,"stacked"===o?"normal":"percentStacked"===o?"percent":void 0),data:t.map((t=>({y:t})))};var o}))}init(){if(this._options)return this._options;let t,e,i=this.model.getValueMatrix(this.dataRange);this.seriesRange&&(this._inverted=this.seriesRange.isColumn,t=this.model.getValueMatrix(this.seriesRange).flat()),this.categoriesRange&&(this._inverted=this.seriesRange.isRow,e=this.model.getValueMatrix(this.categoriesRange).flat()),this._inverted||(i=Zr(i));const o=i.length,r=i[0].length;return t||(t=Array.from({length:o},((t,e)=>`Series ${e+1}`))),e||(e=Array.from({length:r},((t,e)=>(e+1).toString()))),this._options={plotOptions:{},series:this.getSeriesData(i,t),xAxis:{categories:e}},"pie"==this.type&&(this._options.plotOptions.pie={dataLabels:{enabled:!1},showInLegend:!0},this._options.series[0].data.forEach(((t,i)=>{t.name=e[i]})),this._options.series=[this._options.series[0]]),this._options}getOptions(){return this._options||this.init(),this._options}}class yL extends fu{constructor(){super(...arguments),this.charts=new Map,this.dependencies=new Map,this.grids=new Set,this.getChartFactory=t=>()=>{const e=yt("og-plugin-chart");return e.model=t,this.charts.set(t.index,e),e},this._onEdit=t=>{if(!t.cells)return;const e=this.getAffectedModels(t.grid.model.name,t.cells.map((t=>t.address)));e.forEach((t=>this.charts.get(t)?.refresh()))}}get models(){return this.grid.model.otherModels[yL.pluginName]}getChartByModel(t){return this.charts.get(t.index)}getAffectedModels(t,e){const i=new Set;return e.forEach((e=>{const o=this.dependencies.get(t)?.get(e);o&&o.forEach((t=>i.add(t)))})),Array.from(i)}addModel(t){const e=new bL(this.grid.model,t);e.index=this.models.size;const i=e.datasheetName||this.grid.model.name,o=this.dependencies.get(i)??new Map;if(this.dependencies.set(i,o),null==e.title&&(e.title=`Chart #${this.models.size+1}`),e.dependencies.forEach((t=>{const i=o.get(t)||[];i.push(e.index),o.set(t,i)})),this.models.add(e),this.grid.objects.add({model:e,createComponent:this.getChartFactory(e)}),i){const t=this.grid.getConnectedGrid(i);this.grids.has(t)||(t.addEventListener("grid.edit",this._onEdit),this.grids.add(t))}return e}clear(){this.models.clear(),this.charts=new Map,this.dependencies=new Map}init(t){this.grid=t,t.model.otherModels[yL.pluginName]=new Set,t.addEventListener("grid.loadmodel",(t=>{this.clear(),t.grid.model.otherSourceData.charts&&t.grid.model.otherSourceData.charts.forEach((t=>this.addModel(t)))})),t.addEventListener("grid.edit",this._onEdit),this.grids.add(t)}}yL.pluginName="charts";class wL extends fu{constructor(){super(...arguments),this._onModelChange=t=>{this.getGridByModel(t.value).plugins.get("charts").getChartByModel(t.value).refresh()},this.openSidebar=()=>this.editor.rightSidebarComponent="charts",this.closeSidebar=()=>this.editor.rightSidebarComponent=null,this.toggleSidebar=(t=null)=>!1===(t??!1)||"charts"==this.editor.rightSidebarComponent?this.closeSidebar():this.openSidebar()}get editor(){return this._editor}getGridByModel(t){return this.editor.group.getGridByModel(t.model)}init(t){this._editor=t;const e=t.createComponent;t.createComponent=t=>"charts"===t?(this.chartList||(this.chartList=yt("og-plugin-chart-list"),this.chartList.addEventListener("change",this._onModelChange)),this.chartList.filter=this._filter,this._filter=null,this.chartList):e?e(t):null,t.addEventListener("editor.toolbar.init",(()=>{const e=t.toolbar.toolbar3Config.slice(),i=e.findIndex((t=>"sparklines"===t.id))||0;e.splice(i,0,{type:"togglebutton",id:"charts",icon:{icon:"chart-column"},title:"Charts"}),t.toolbar.toolbar3Config=e})),t.addEventListener("editor.toolbar.action",(t=>{"charts"===t.action.key&&this.toggleSidebar()})),t.addEventListener("grid.init",(t=>{t.grid.plugins.register(new yL)})),t.addEventListener("grid.object.activate",(t=>{t.object instanceof bL&&(this.openSidebar(),this.chartList?this.chartList.filter=t.object.title:this._filter=t.object.title)})),t.addEventListener("grid.object.deactivate",(()=>{this.chartList&&(this.chartList.filter=null)}))}}wL.pluginName="chartEditor";class xL{static init(t){"string"==typeof t?xL.path=t:xL.highcharts=t}static async get(){return this.highcharts||(this.highcharts=await this.load()),this.highcharts}static getSync(){return this.highcharts}static async load(){return window.Highcharts&&(xL.highcharts=window.Highcharts),xL.highcharts?xL.highcharts:this.loadViaScript()}static async loadViaScript(){const t=window.define,e=t&&t.amd;t&&(t.amd=void 0);try{const t=this.path.endsWith(".js")?this.path:`${this.path}/highcharts.js`;if(await hs.load(t),window.Highcharts)return xL.highcharts=window.Highcharts,window.Highcharts;throw new Error("Failed to load Highcharts")}catch(t){throw console.log(t),t}finally{t&&void 0!==e&&(t.amd=e)}}}const kL={chart:{styledMode:!0}};async function CL(t){const e=await xL.get(),i={chart:{type:"column",reflow:!1},title:{text:t.title},series:[{type:"column",name:"Corn",data:[387749,28e4,129e3,64300,54e3,34300]},{type:"column",name:"Wheat",data:[45321,14e4,1e4,140500,19500,113500]}]};return e.merge(i,t.getOptions())}async function ML(t,e){const i=await xL.get(),o=await CL(t);return i.chart(e,i.merge(o,kL,{chart:{}}))}const _L=ks`
8606
+ `],DE([$n({type:Object})],OE.prototype,"item",void 0),DE([$n({type:String})],OE.prototype,"value",void 0),DE([On("og-dropdown")],OE.prototype,"dropdown",void 0),DE([On("og-button")],OE.prototype,"button",void 0),DE([On(".btn-content")],OE.prototype,"btnContent",void 0),OE=DE([In("og-toolbar-colorpicker")],OE);class NE{static init(t){this.path=t}static async get(){return this.xlsx||(this.xlsx=await this.load()),this.xlsx}static getSync(){return this.xlsx}static load(){if(!cs.require)throw new Error("AMDLoader is not initialized");return cs.require.config({paths:{xlsx:this.path+"/xlsx.full.min"}}),new Promise((t=>cs.require(["xlsx"],(()=>t(self.XLSX)))))}}const PE="aaaaaa",jE={bottom:{style:"thin",color:PE},top:{style:"thin",color:PE},right:{style:"thin",color:PE},left:{style:"thin",color:PE}},HE={exportHiddenRows:!0,exportHiddenColumns:!0,gridLines:!0,defaultBorders:!1,dropdownCells:"value"},FE={alignment:{vertical:"center",horizontal:"center"},bold:!0},BE={g:"n",b:"b",t:"s",n:"n",d:"d",dt:"d",s:"s",m:"s",tm:"s",h:"s",a:"z"};function WE(t,e){return(e.exportHiddenColumns?t.columns:t.visibleColumns).map((e=>({level:e.level,wpx:e.width,hidden:null==e.visibleIndex||t.visibleColumns[e.visibleIndex]!=e})))}function VE(t,e){const i=e.exportHiddenRows?t.rows:t.visibleRows,o=t.headerCount,r=new Array(i.length+o);return[...Array(o).keys()].map((t=>r[t]={level:0})),i.map(((e,i)=>r[i+o]={level:e.level,hpt:.75*e.height,hidden:null==e.visibleIndex||t.visibleRows[e.visibleIndex]!=e})),r}function UE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t=>t.c:e=>t.columns[e.c].visibleIndex,r=[];return t.merges.mergedCells.forEach((t=>{r.push({s:{c:o(t),r:t.r+i},e:{c:o(t)+t.cs-1,r:t.r+i+t.rs-1}})})),t.mergedHeaders.forEach((t=>{t.h?.hidden||r.push({s:{c:o(t),r:t.r},e:{c:o(t)+t.cs-1,r:t.r+t.rs-1}})})),r}function GE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t.columns:t.visibleColumns,r=XE(e);return[...Array(i).keys()].map((e=>o.map((i=>{const o=i.header[e],s={t:o?"s":"z",s:FE};return o&&(o.html?s.h=`<span>${o.label}</span>`:null!=o.label?s.v=o.label:s.t="z"),r&&(s.s||(s.s={}),s.s=Object.assign({},r,s.s)),null!=o._style&&(s.s=Object.assign({},s.s,ZE(t.styles.get(o._style)))),s}))))}function qE(t){return{rgb:t}}function YE(t){return"none"==t.style?null:{style:t.style,color:qE(t.color)}}function ZE(t){const e={};return t.color&&(e.color=qE(t.color)),t.bgColor&&(e.bgColor=qE(t.bgColor)),t.fgColor&&(e.fgColor=qE(t.fgColor)),t.patternType&&(e.patternType=t.patternType),t.alignment&&(e.alignment=t.alignment),null!=t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.bottom&&(e.bottom=YE(t.bottom)),t.top&&(e.top=YE(t.top)),t.right&&(e.right=YE(t.right)),t.left&&(e.left=YE(t.left)),null!=t.angle&&(e.angle=t.angle),t.stops&&(e.stops=t.stops.map((t=>({v:t.v,rgb:t.rgb})))),e}function XE(t){const e=!0===t.defaultBorders?jE:t.defaultBorders;return e?function(t){const e={};return t.bottom&&(e.bottom=YE(t.bottom)),t.top&&(e.top=YE(t.top)),t.right&&(e.right=YE(t.right)),t.left&&(e.left=YE(t.left)),e}(e):null}function QE(t,e){const i=NE.getSync();e=iL(e);const o=t.headerCount,r=new jw(t),s=new Array(o+t.rows.length),n=new Map,a=XE(e),l=t.options.dateFormat||"yyyy-MM-dd",c="displayValue"==e.dropdownCells;GE(t,e).forEach(((t,e)=>s[e]=t));const h=e.exportHiddenRows?t.rows:t.visibleRows,d=e.exportHiddenColumns?t.columns:t.visibleColumns;return h.forEach(((t,e)=>s[e+o]=d.map((e=>{const s=t.cell(e.index),h=s.type,d=BE[h],u={t:s.hasValue?d:"z"};s.hasFormula?(u.f=o>0?r.getFormula(s).clone().shift({index:0,offset:o,direction:"down"}).toExcelString():r?r.getFormula(s).toExcelString():s.formula,"d"==d&&(u.t="n",u.z=s.format??l)):s.hasValue&&!s.isSpilled&&("s"==u.t?u.v=c?s.formattedValue.toString():s.value.toString():"z"!=u.t&&(u.v=s.value),"g"==h?u.t=Q(u.v)?"s":"n":"d"==h?tt(u.v)&&(u.t="n"):"h"==h&&i.utils.html_to_rs&&(u.R=i.utils.html_to_rs(s.value)));const p=s.composedStyle;if(p&&(n.has(p.id)||n.set(p.id,ZE(p)),u.s={...n.get(p.id)}),function(t,e){const i=t.calculatedIndent;i>0&&(e.s||(e.s={}),e.s.alignment||(e.s.alignment={}),e.s.alignment.indent=i)}(s,u),s.hasComment){const t=s.model.comments.get(s.address),e=[];e.push({R:[]}),e.hidden=!0,e["!pos"]={x:0,y:0,w:400,h:200},t.forEach((t=>{if(!t.text)return;const i=t.author?t.author.name??t.author.id:null;let o="";i&&(o=i),t.date&&(o+=(o?" - ":"")+Zo(t.date,Yo({withTime:!0}))),o&&e[0].R.push({t:"s",v:o+"\n",s:{bold:!0}}),e[0].R.push({t:"s",v:t.text+"\n"})})),u.c=e}return"n"!=u.t&&"d"!=u.t||null!=u.z||(u.z=s.format??("d"==u.t?l:"General")),a&&(u.s||(u.s={}),u.s=Object.assign({},a,u.s)),u})))),s}function KE(t,e){return t||e?{t:(t=Object.assign({},e,t)).t,v:t.v,color:qE(t.color)}:null}function JE(t){const e=t.headerCount;return t.conditionalFormats.getSourceData().map((t=>({ref:Ev.fromA1s(t.ranges).map((t=>t.shiftDown(0,e,null,!0).A1)).join(" "),t:t.type,f:t.condition&&gv(t.condition[0])?"A1"+t.condition:t.condition??null,s:t.style?ZE(t.style):null,stop:t.stop,cmin:KE(t.cmin,"bar"==t.type?{t:"min",color:t.color}:null),cmid:t.cmid?KE(t.cmid,{v:50,t:"percentile"}):null,cmax:KE(t.cmax,"bar"==t.type?{t:"max",color:t.color}:null),color:qE(t.color),v:t.v,thresh:t.thresh})))}function tL(t){if(t.options.rowTree.reversed)return"below";const e=t.rows;if(e.length<2)return"above";for(let t=1;t<e.length;t++)if(e[t].level!=e[t-1].level)return e[t].parent==e[t-1]?"above":"below";return t.rows[0].level>t.rows[1].level?"below":"above"}function eL(t){return null==t.options.columnTree.reversed?t.columns.length<2?"left":t.columns[0].level>t.columns[1].level?"right":"left":t.options.columnTree.reversed?"right":"left"}const iL=t=>{const e=Object.assign({},HE,t);return e.defaultBorders&&(e.defaultBorders=jE),e},oL=t=>t/25.4;function rL(t){return t?{top:oL(t.top),bottom:oL(t.bottom),left:oL(t.left),right:oL(t.right),header:oL(t.header),footer:oL(t.footer)}:null}function sL(t,e){e=iL(e);const i={};i["!cols"]=WE(t,e),i["!rows"]=VE(t,e),i["!merges"]=UE(t,e),i["!condfmt"]=JE(t),i["!outline"]={above:"above"==tL(t),left:"left"==eL(t)},t.options.freezeLeft||t.options.freezeTop?i["!freeze"]=`${Rv(t.options.freezeLeft)}${t.headerCount+t.options.freezeTop+1}`:t.headerCount>0&&(i["!freeze"]=`A${t.headerCount+1}`),i["!gridlines"]=e.gridLines,i["!print"]=function(t,e){const i=t.options.print??{},o={props:{}};o.props.scale=i.scale?i.scale:function(t){const e=t.options.print??{},i=Q(e.paper)?ts[e.paper]??ts.A4:e.paper,o=oL(i.width-e.margins.left-e.margins.right),r=t.columns.reduce(((t,e)=>t+e.width),0)/96;return Math.round(o/r*100)-2}(t),o.props.paper=i.paper,o.props.orientation=i.orientation,i.margins&&(o.margins=rL(i.margins));const r=i.rowBreaks;if(r?.length>0){o.rowBreaks=r.map((i=>({R:e.exportHiddenRows?i:t.rows[i].visibleIndex})));const i=t.options?.print?.rowTitles?Ev.fromA1(t.options?.print?.rowTitles):null;i&&(o.titles={s:{r:i.r1,c:-1},e:{r:i.r2,c:-1}})}return o}(t,e);const o=function(t,e){const i=e.exportHiddenColumns?t.columns:t.visibleColumns,o=i.find((t=>t.filter?.enabled));return o?new Ev(o.index,t.headerCount-1,i.length-1,t.headerCount-1):null}(t,e);return o&&(i["!autofilter"]={ref:o.A1}),i}async function nL(t,e){const i=NE.get(),o=i instanceof Promise?await i:i;e=iL(e);const r=o.utils.book_new();return t.forEach(((t,i)=>{t.calculations.evaluateAll();const s={...e,...t.exportOptions},n=o.utils.sheet_add_aoa(sL(t,s),QE(t,s));let a=t.name||`Sheet${i+1}`;t.name=a,a.length>31&&(a=a.substring(0,31)),o.utils.book_append_sheet(r,n,a)})),r.Workbook=r.Workbook||{},t.forEach((t=>{const e=r.SheetNames.indexOf(t.name);e<0||(r.Workbook.Sheets||(r.Workbook.Sheets=[]),r.Workbook.Sheets[e]||(r.Workbook.Sheets[e]={}),t.tab?.hidden&&(r.Workbook.Sheets[e].Hidden=1))})),r}async function aL(t,e=null){const i=NE.get(),o=i instanceof Promise?await i:i;return e?o.writeFile(t,e,{cellStyles:!0,bookSST:!0}):o.writeXLSX(t,{cellStyles:!0,bookSST:!0,type:"buffer"})}const lL={b:"b",s:"t",n:"n",d:"d",z:"g",e:"t"};function cL(t){return t.rgb}function hL(t){return{color:cL(t.color),style:t.style}}function dL(t){const e={};return t.color&&(e.color=cL(t.color)),t.bgColor&&(e.bgColor=cL(t.bgColor)),t.fgColor&&(e.fgColor=cL(t.fgColor)),e.fgColor||"000000"!=e.color||(e.color=null),t.alignment&&(e.alignment=t.alignment),t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.top&&(e.top=hL(t.top)),t.bottom&&(e.bottom=hL(t.bottom)),t.left&&(e.left=hL(t.left)),t.right&&(e.right=hL(t.right)),e}function uL(t,e){const i=t["!ref"]?Ev.fromA1(t["!ref"]):Ev.fromA1("A1:T100"),o={},r={};if(t["!freeze"]){const e=Ev.fromA1(t["!freeze"]);r.freezeLeft=e.c1,r.freezeTop=e.r1}return o.options=r,o.rows=function(t,e){const i=t["!rows"]??[],o=new Array(e);let r;for(let t=0;t<e;t++)r=i[t],o[t]={l:(r?r.level:0)||0,h:r?r.hpx:null};return o}(t,i.r2+1),o.columns=function(t,e){const i=t["!cols"]??[],o=new Array(e);let r;for(let t=0;t<e;t++)r=i[t],o[t]={l:(r?r.level:0)||0,w:r?r.wpx:null};return o}(t,i.c2+1),o.cells=function(t){const e=[],i=new Map;(t["!merges"]??[]).forEach((t=>{const e=new Ev(t.s.c,t.s.r);i.set(e.A1,{c:t.s.c,cs:t.e.c-t.s.c+1,r:t.s.r,rs:t.e.r-t.s.r+1})}));for(const o in t){if("!"==o[0])continue;const r=t[o],s=Ev.fromA1(o),n={r:s.r1,c:s.c1,t:lL[r.t]},a=i.get(o);a&&(n.cs=a.cs,n.rs=a.rs),r.s&&(n.s=dL(r.s)),r.f?n.f=Bv(r.f):n.v=r.v,["n","d"].includes(r.t)&&null!=r.z&&"General"!=r.z&&(n.z=yr(r.z,"d")),e.push(n)}return e}(t),o.names=e,o.rules=function(t){return t["!condfmt"]?.filter((t=>["formula","scale","bar"].includes(t.t))).map((t=>{const e={type:t.t,ranges:t.ref.toString().replace(/\s/g,";")};return e.style=t.s?dL(t.s):null,e.cmin=t.cmin?{t:t.cmin.t,color:t.cmin.color?cL(t.cmin.color):null}:null,e.cmid=t.cmid?{t:t.cmid.t,color:t.cmid.color?cL(t.cmid.color):null}:null,e.cmax=t.cmax?{t:t.cmax.t,color:t.cmax.color?cL(t.cmax.color):null}:null,e.color=t.color?cL(t.color):null,e.condition=t.f,e.stop=!0,e}))}(t),o}function pL(t){const e=new Map;return t.Workbook.Names.forEach((({Name:t,Ref:i})=>{const[o,r]=i.split("!");if(!r)return;let s=e.get(o);s||e.set(o,s=[]);const n=Ev.fromA1(r);n.c1Anchor&&!n.r1Anchor?(n.r1=0,n.r2=1/0):!n.c1Anchor&&n.r1Anchor&&(n.c1=0,n.c2=1/0),n.removeAnchors(),s.push({name:t,ref:n.A1})})),e}async function gL(t,e){return performance.mark("start_import"),fL(await t.arrayBuffer(),e)}function mL(t){const e=pL(t);performance.mark("sheets_start");const i={models:[],layout:{items:[{tabs:[]}]}};for(const o in t.Sheets)performance.mark(`sheet_start_${o}`),i.layout.items[0].tabs.push({id:o}),i.models.push({...uL(t.Sheets[o],e.get(o)),name:o}),performance.mark(`sheet_end_${o}`);return performance.mark("sheets_end"),i}async function fL(t,e){performance.mark("array_buffer");const i=t instanceof ArrayBuffer?new Uint8Array(t):t,o=(await NE.get()).read(i,Object.assign({cellNF:!0,cellText:!1,cellStyles:!0,type:"buffer"},e||{}));return performance.mark("wb_read"),mL(o)}class vL extends fu{init(t){NE.get(),t.commands.add({group:"plugin",name:"export xlsx",exec:async()=>{const e=t.getGridContainer().model.models;aL(await nL(Array.from(e,(t=>t[1]))),"export.xlsx")}}),t.addEventListener("drop",(async e=>{if(e.preventDefault(),e.dataTransfer.files.length){const i=e.dataTransfer.files[0];t.setSourceData(await gL(i))}}))}}vL.pluginName="xlsx";class bL{get dataRange(){return this._dataRange}set dataRange(t){this._dataRange=t,this.invalidateData()}get seriesRange(){return this._seriesRange}set seriesRange(t){this._seriesRange=t,this.invalidateData()}get categoriesRange(){return this._categoriesRange}set categoriesRange(t){this._categoriesRange=t,this.invalidateData()}get title(){return this._title}set title(t){this._title=t,this.invalidateData()}get size(){return this._size}set size(t){this._size=t}get location(){return this._location}set location(t){this._location=t,this.invalidateData()}get type(){return this._type}set type(t){this._type=t,this.invalidateData()}get grouping(){return this._grouping}set grouping(t){this._grouping=t,this.invalidateData()}get datasheetName(){return this.dataRange?.sheet}get dependencies(){if(this._dependencies)return this._dependencies;if(this._dependencies=new Set,this.seriesRange)for(const t of this.seriesRange.cells())this._dependencies.add(t.A1);if(this.categoriesRange)for(const t of this.categoriesRange.cells())this._dependencies.add(t.A1);if(this.dataRange)for(const t of this.dataRange.cells())this._dependencies.add(t.A1);return this._dependencies}invalidateData(){this._options=void 0,this._dependencies=void 0}constructor(t,e){this.model=t,this._inverted=!1,this.populate(e),this.init()}populate(t){this._dataRange=Ev.fromA1(t.dataRange),this._title=t.title,this._size=t.size,this._location=t.location,this._type=t.type,this._grouping=t.grouping,this.zIndex=t.zIndex,t.seriesRange&&(this._seriesRange=Ev.fromA1(t.seriesRange)),t.categoriesRange&&(this._categoriesRange=Ev.fromA1(t.categoriesRange))}getSourceData(){return{dataRange:this.dataRange.A1,seriesRange:this.seriesRange?.A1,categoriesRange:this.categoriesRange?.A1,title:this.title,size:this.size,location:this.location,type:this.type,grouping:this.grouping,zIndex:this.zIndex}}getSeriesData(t,e){return t.map(((t,i)=>{return{type:this.type,name:e[i],stacking:(o=this.grouping,"stacked"===o?"normal":"percentStacked"===o?"percent":void 0),data:t.map((t=>({y:t})))};var o}))}init(){if(this._options)return this._options;let t,e,i=this.model.getValueMatrix(this.dataRange);this.seriesRange&&(this._inverted=this.seriesRange.isColumn,t=this.model.getValueMatrix(this.seriesRange).flat()),this.categoriesRange&&(this._inverted=this.seriesRange.isRow,e=this.model.getValueMatrix(this.categoriesRange).flat()),this._inverted||(i=Zr(i));const o=i.length,r=i[0].length;return t||(t=Array.from({length:o},((t,e)=>`Series ${e+1}`))),e||(e=Array.from({length:r},((t,e)=>(e+1).toString()))),this._options={plotOptions:{},series:this.getSeriesData(i,t),xAxis:{categories:e}},"pie"==this.type&&(this._options.plotOptions.pie={dataLabels:{enabled:!1},showInLegend:!0},this._options.series[0].data.forEach(((t,i)=>{t.name=e[i]})),this._options.series=[this._options.series[0]]),this._options}getOptions(){return this._options||this.init(),this._options}}class yL extends fu{constructor(){super(...arguments),this.charts=new Map,this.dependencies=new Map,this.grids=new Set,this.getChartFactory=t=>()=>{const e=yt("og-plugin-chart");return e.model=t,this.charts.set(t.index,e),e},this._onEdit=t=>{if(!t.cells)return;const e=this.getAffectedModels(t.grid.model.name,t.cells.map((t=>t.address)));e.forEach((t=>this.charts.get(t)?.refresh()))}}get models(){return this.grid.model.otherModels[yL.pluginName]}getChartByModel(t){return this.charts.get(t.index)}getAffectedModels(t,e){const i=new Set;return e.forEach((e=>{const o=this.dependencies.get(t)?.get(e);o&&o.forEach((t=>i.add(t)))})),Array.from(i)}addModel(t){const e=new bL(this.grid.model,t);e.index=this.models.size;const i=e.datasheetName||this.grid.model.name,o=this.dependencies.get(i)??new Map;if(this.dependencies.set(i,o),null==e.title&&(e.title=`Chart #${this.models.size+1}`),e.dependencies.forEach((t=>{const i=o.get(t)||[];i.push(e.index),o.set(t,i)})),this.models.add(e),this.grid.objects.add({model:e,createComponent:this.getChartFactory(e)}),i){const t=this.grid.getConnectedGrid(i);this.grids.has(t)||(t.addEventListener("grid.edit",this._onEdit),this.grids.add(t))}return e}clear(){this.models.clear(),this.charts=new Map,this.dependencies=new Map}init(t){this.grid=t,t.model.otherModels[yL.pluginName]=new Set,t.addEventListener("grid.loadmodel",(t=>{this.clear(),t.grid.model.otherSourceData.charts&&t.grid.model.otherSourceData.charts.forEach((t=>this.addModel(t)))})),t.addEventListener("grid.edit",this._onEdit),this.grids.add(t)}}yL.pluginName="charts";class wL extends fu{constructor(){super(...arguments),this._onModelChange=t=>{this.getGridByModel(t.value).plugins.get("charts").getChartByModel(t.value).refresh()},this.openSidebar=()=>this.editor.rightSidebarComponent="charts",this.closeSidebar=()=>this.editor.rightSidebarComponent=null,this.toggleSidebar=(t=null)=>!1===(t??!1)||"charts"==this.editor.rightSidebarComponent?this.closeSidebar():this.openSidebar()}get editor(){return this._editor}getGridByModel(t){return this.editor.group.getGridByModel(t.model)}init(t){this._editor=t;const e=t.createComponent;t.createComponent=t=>"charts"===t?(this.chartList||(this.chartList=yt("og-plugin-chart-list"),this.chartList.addEventListener("change",this._onModelChange)),this.chartList.filter=this._filter,this._filter=null,this.chartList):e?e(t):null,t.addEventListener("editor.toolbar.init",(()=>{const e=t.toolbar.toolbar3Config.slice(),i=e.findIndex((t=>"sparklines"===t.id))||0;e.splice(i,0,{type:"togglebutton",id:"charts",icon:{icon:"chart-column"},title:"Charts"}),t.toolbar.toolbar3Config=e})),t.addEventListener("editor.toolbar.action",(t=>{"charts"===t.action.key&&this.toggleSidebar()})),t.addEventListener("grid.init",(t=>{t.grid.plugins.register(new yL)})),t.addEventListener("grid.object.activate",(t=>{t.object instanceof bL&&(this.openSidebar(),this.chartList?this.chartList.filter=t.object.title:this._filter=t.object.title)})),t.addEventListener("grid.object.deactivate",(()=>{this.chartList&&(this.chartList.filter=null)}))}}wL.pluginName="chartEditor";class xL{static init(t){"string"==typeof t?xL.path=t:xL.highcharts=t}static async get(){return this.highcharts||(this.highcharts=await this.load()),this.highcharts}static getSync(){return this.highcharts}static async load(){return window.Highcharts&&(xL.highcharts=window.Highcharts),xL.highcharts?xL.highcharts:this.loadViaScript()}static async loadViaScript(){const t=window.define,e=t&&t.amd;t&&(t.amd=void 0);try{const t=this.path.endsWith(".js")?this.path:`${this.path}/highcharts.js`;if(await hs.load(t),window.Highcharts)return xL.highcharts=window.Highcharts,window.Highcharts;throw new Error("Failed to load Highcharts")}catch(t){throw console.log(t),t}finally{t&&void 0!==e&&(t.amd=e)}}}const kL={chart:{styledMode:!0}};async function CL(t){const e=await xL.get(),i={chart:{type:"column",reflow:!1},title:{text:t.title},series:[{type:"column",name:"Corn",data:[387749,28e4,129e3,64300,54e3,34300]},{type:"column",name:"Wheat",data:[45321,14e4,1e4,140500,19500,113500]}]};return e.merge(i,t.getOptions())}async function ML(t,e){const i=await xL.get(),o=await CL(t);return i.chart(e,i.merge(o,kL,{chart:{}}))}const _L=ks`
8607
8607
  * {
8608
8608
  box-sizing: border-box;
8609
8609
  }
@@ -9953,4 +9953,4 @@ milkdown-block-handle {
9953
9953
  `:null}
9954
9954
  </div>
9955
9955
  </og-panel>
9956
- `:null,this.addEventListener("mousedown",(t=>t.stopPropagation()))}getTypeIndex(t){const e=this.types.findIndex((e=>e.type==t.type&&e.grouping==(t.grouping||"standard")));return e>-1?e:null}updateModel(){if(this.editTitle=!1,!this.model)return;this.titleInput&&(this.model.title=this.titleInput.value);const t=this.types[this.typeList.value];this.model.type=t.type,this.model.grouping=t.grouping,this.model.categoriesRange=this.categoryRangeInput?.value?Ev.fromA1(this.categoryRangeInput.value):null,this.model.seriesRange=this.seriesRangeInput?.value?Ev.fromA1(this.seriesRangeInput.value):null,this.model.dataRange=Ev.fromA1(this.dataRangeInput.value),this.dispatchEvent(new Qr({value:this.model}))}async updated(){this.editTitle&&this.titleInput&&(await this.titleInput.updateComplete,this.titleInput.focus(),this.titleInput.selectAll())}};AL.styles=[TL],$L([$n({type:Object})],AL.prototype,"model",void 0),$L([An()],AL.prototype,"editTitle",void 0),$L([On("#title")],AL.prototype,"titleInput",void 0),$L([On("#type")],AL.prototype,"typeList",void 0),$L([On("#dataRange")],AL.prototype,"dataRangeInput",void 0),$L([On("#seriesRange")],AL.prototype,"seriesRangeInput",void 0),$L([On("#categoryRange")],AL.prototype,"categoryRangeInput",void 0),AL=$L([In("og-plugin-chart-form")],AL);const DL=Ja().themes.get("og-dark");Object.assign(DL.definition,{"highcharts-title-font-size":"16px","highcharts-subtitle-font-size":"14px","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"rgb(48, 48, 48)","highcharts-neutral-color-100":"rgb(255, 255, 255)","highcharts-neutral-color-80":"rgb(214, 214, 214)","highcharts-neutral-color-60":"rgb(173, 173, 173)","highcharts-neutral-color-40":"rgb(133, 133, 133)","highcharts-neutral-color-20":"rgb(92, 92, 92)","highcharts-neutral-color-10":"rgb(71, 71, 71)","highcharts-neutral-color-5":"rgb(61, 61, 61)","highcharts-neutral-color-3":"rgb(57, 57, 57)","highcharts-highlight-color-100":"rgb(122, 167, 255)","highcharts-highlight-color-80":"rgb(108, 144, 214)","highcharts-highlight-color-60":"rgb(94, 121, 173)","highcharts-highlight-color-20":"rgb(65, 74, 92)","highcharts-highlight-color-10":"rgb(58, 63, 71)"});const OL=Ja().themes.get("og-light");Object.assign(OL.definition,{"highcharts-title-font-size":"16px","chart-background-color":"#2a2a2b","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"#ffffff","highcharts-neutral-color-100":"#000000","highcharts-neutral-color-80":"#333333","highcharts-neutral-color-60":"#666666","highcharts-neutral-color-40":"#999999","highcharts-neutral-color-20":"#cccccc","highcharts-neutral-color-10":"#e6e6e6","highcharts-neutral-color-5":"#f2f2f2","highcharts-neutral-color-3":"#f7f7f7","highcharts-highlight-color-100":"#0022ff","highcharts-highlight-color-80":"#334eff","highcharts-highlight-color-60":"#667aff","highcharts-highlight-color-20":"#ccd3ff","highcharts-highlight-color-10":"#e6e9ff","highcharts-positive-color":"#06b535","highcharts-negative-color":"#f21313","highcharts-annotation-color-0":"rgba(130, 170, 255, 0.4)","highcharts-annotation-color-1":"rgba(139, 191, 216, 0.4)","highcharts-annotation-color-2":"rgba(150, 216, 192, 0.4)","highcharts-annotation-color-3":"rgba(156, 229, 161, 0.4)","highcharts-annotation-color-4":"rgba(162, 241, 130, 0.4)","highcharts-annotation-color-5":"rgba(169, 255, 101, 0.4)"});var NL=i(6946),PL=i(6471),jL=i(4969),HL=i(9502),FL=i(7706),BL=i(1480),WL=i(2006),VL=i(7503),UL=i(7873),GL=i(8746),qL=i(2570),YL=i(8815),ZL=i(6390),XL=i(6593),QL=i(895),KL=i(9083),JL=i(6093),tI=i(9685),eI=i(9849),iI=i(8268),oI=i(4693),rI=i(3599),sI=i(782),nI=i(754),aI=i(5700),lI=i(4731),cI=i(7291),hI=i(597),dI=i(1474),uI=i(6224),pI=i(6239),gI=i(6828),mI=i(2212),fI=i(863),vI=i(3602),bI=i(1985),yI=i(886),wI=i(7201),xI=i(9937),kI=i(8450),CI=i(9630),MI=i(9766),_I=i(388),SI=i(1903),zI=i(398),EI=i(6105),LI=i(6147),II=i(5722),RI=i(5576),TI=i(3131),$I=i(6308),AI=i(9645),DI=i(3199),OI=i(871),NI=i(5251),PI=i(6426),jI=i(2643),HI=i(8522),FI=i(6398),BI=i(2525),WI=i(8434),VI=i(6138),UI=i(5835),GI=i(5654),qI=i(6659),YI=i(2977),ZI=i(4480),XI=i(9886),QI=i(6815),KI=i(1582),JI=i(2968),tR=i(394),eR=i(7024),iR=i(7853),oR=i(8249),rR=i(2869),sR=i(486),nR=i(5735),aR=i(470),lR=i(4612),cR=i(4018),hR=i(1476),dR=i(3194),uR=i(3525),pR=i(7541),gR=i(4104),mR=i(6686),fR=i(7719),vR=i(3898),bR=i(8153),yR=i(3690),wR=i(1776),xR=i(4980),kR=i(5578),CR=i(9613),MR=i(1119),_R=i(8444),SR=i(2978),zR=i(9130),ER=i(2127),LR=i(2732),IR=i(4287),RR=i(4045),TR=i(7642),$R=i(1367),AR=i(320),DR=i(821),OR=i(102),NR=i(7683),PR=i(3980),jR=i(576),HR=i(654),FR=i(73),BR=i(140),WR=i(8129),VR=i(5087),UR=i(6992),GR=i(8247),qR=i(8038),YR=i(5286),ZR=i(9179),XR=i(1808),QR=i(9459),KR=i(2883),JR=i(9124),tT=i(7067),eT=i(1054),iT=i(7325),oT=i(1272),rT=i(3359),sT=i(6562),nT=i(4193),aT=i(6348),lT=i(2435),cT=i(7544),hT=i(4470),dT=i(9111),uT=i(9318),pT=i(7294),gT=i(4479),mT=i(2409),fT=i(3091),vT=i(5789),bT=i(5890),yT=i(3874),wT=i(2907),xT=i(1175),kT=i(1686),CT=i(703),MT=i(6606),_T=i(4194),ST=i(6228),zT=i(62),ET=i(2072),LT=i(9744),IT=i(25),RT=i(2618),TT=i(1988),$T=i(8013),AT=i(1133),DT=i(362),OT=i(6845),NT=i(6800),PT=i(1103),jT=i(4933),HT=i(7284),FT=i(2620),BT=i(2366),WT=i(7457),VT=i(2449),UT=i(2),GT=i(5697),qT=i(7069),YT=i(4716),ZT=i(4740),XT=i(4557),QT=i(1868),KT=i(8647),JT=i(5127),t$=i(4816),e$=i(4009),i$=i(5104),o$=i(2830),r$=i(3093),s$=i(5029),n$=i(3514),a$=i(2142),l$=i(4999),c$=i(7523),h$=i(346),d$=i(7917),u$=i(3976),p$=i(9801),g$=i(2464),m$=i(5511),f$=i(5210),v$=i(5815),b$=i(3339),y$=i(7472),w$=i(8811),x$=i(8548),k$=i(6880),C$=i(1840),M$=i(5547),_$=i(4788),S$=i(9467),z$=i(9187),E$=i(9217),L$=i(7897),I$=i(2644),R$=i(6204),T$=i(1472),$$=i(1247),A$=i(7406),D$=i(925),O$=i(7455),N$=i(3771),P$=i(1549),j$=i(3541),H$=i(3140),F$=i(9800),B$=i(229),W$=i(2677),V$=i(1844),U$=i(3245),G$=i(9056),q$=i(7535),Y$=i(2359),Z$=i(15),X$=i(5569),Q$=i(2014),K$=i(1599),J$=i(6521),tA=i(232),eA=i(9745),iA=i(9594),oA=i(6979),rA=i(4494),sA=i(312),nA=i(4983),aA=i(1258),lA=i(6313),cA=i(12),hA=i(8003),dA=i(7830),uA=i(8875),pA=i(3911),gA=i(1817),mA=i(478),fA=i(2585),vA=i(6564),bA=i(2884),yA=i(3825),wA=i(7348),xA=i(9277),kA=i(4118),CA=i(9200),MA=i(51),_A=i(2872),SA=i(4702),zA=i(9281),EA=i(1394),LA=i(7295),IA=i(2936),RA=i(3789),TA=i(3614),$A=i(4827),AA=i(9204),DA=i(9113),OA=i(4058),NA=i(9939),PA=i(1139);const jA=[NL.mw,PL.mw,jL.mw,HL.mw,FL.mw,BL.mw,WL.mw,VL.mw,GL.mw,YL.mw,qL.mw,ZL.mw,XL.mw,QL.mw,KL.mw,JL.mw,tI.mw,eI.mw,iI.mw,oI.mw,rI.mw,sI.mw,nI.mw,aI.mw,lI.mw,cI.mw,hI.mw,dI.mw,uI.mw,gI.mw,mI.mw,fI.mw,vI.mw,bI.mw,yI.mw,wI.mw,xI.mw,kI.mw,CI.mw,MI.mw,_I.mw,SI.mw,EI.mw,zI.mw,LI.mw,II.mw,RI.mw,TI.mw,$I.mw,AI.mw,DI.mw,OI.mw,NI.mw,PI.mw,jI.mw,HI.mw,BI.mw,WI.mw,VI.mw,UI.mw,GI.mw,qI.mw,YI.mw,ZI.mw,XI.mw,QI.mw,KI.mw,JI.mw,tR.mw,eR.mw,iR.mw,oR.mw,rR.mw,sR.mw,nR.mw,FI.mw,aR.mw,lR.mw,cR.mw,hR.mw,dR.mw,uR.mw,pR.mw,gR.mw,mR.mw,fR.mw,vR.mw,bR.mw,yR.mw,wR.mw,xR.mw,kR.mw,CR.mw,MR.mw,_R.mw,SR.mw,zR.mw,ER.mw,LR.mw,IR.mw,RR.mw,TR.mw,$R.mw,AR.mw,DR.mw,OR.mw,NR.mw,PR.mw,jR.mw,HR.mw,FR.mw,BR.mw,WR.mw,VR.mw,UR.mw,GR.mw,qR.mw,pI.mw,YR.mw,ZR.mw,XR.mw,QR.mw,KR.mw,JR.mw,tT.mw,eT.mw,iT.mw,oT.mw,rT.mw,sT.mw,nT.mw,aT.mw,lT.mw,UL.mw,cT.mw,hT.mw],HA=[dT.mw,uT.mw,pT.mw,gT.mw,mT.mw,fT.mw,vT.mw,bT.mw,wT.mw,kT.mw,xT.mw,MT.mw,CT.mw,_T.mw,ST.mw,zT.mw,ET.mw,LT.mw,IT.mw,RT.mw,TT.mw,$T.mw,PT.mw,jT.mw,HT.mw,FT.mw,BT.mw,WT.mw,VT.mw,GT.mw,qT.mw,YT.mw,JT.mw,t$.mw,e$.mw,i$.mw,o$.mw,r$.mw,s$.mw,n$.mw,AT.mw,DT.mw,NT.mw,OT.mw,a$.mw,l$.mw,c$.mw,h$.mw,d$.mw,u$.mw,p$.mw,g$.mw,ZT.mw,XT.mw,QT.mw,KT.mw,f$.mw,v$.mw,b$.mw,y$.mw,w$.mw,x$.mw,k$.mw,C$.mw,M$.mw,_$.mw,S$.mw,z$.mw,E$.mw,L$.mw,I$.mw,R$.mw,T$.mw,$$.mw,A$.mw,m$.mw,D$.mw,O$.mw,N$.mw,P$.mw,j$.mw,H$.mw,F$.mw,B$.mw,W$.mw,V$.mw,U$.mw,G$.mw,q$.mw,Y$.mw,Z$.mw,X$.mw,Q$.mw,K$.mw,J$.mw,tA.mw,eA.mw,iA.mw,oA.mw,rA.mw,sA.mw,nA.mw,aA.mw,lA.mw,cA.mw,hA.mw,dA.mw,uA.mw,pA.mw,gA.mw,mA.mw,fA.mw,vA.mw,bA.mw,yA.mw,wA.mw,xA.mw,UT.mw,kA.mw,CA.mw,MA.mw,_A.mw,SA.mw,zA.mw,EA.mw,LA.mw,IA.mw,RA.mw,TA.mw,$A.mw,AA.mw,DA.mw,OA.mw,yT.mw,NA.mw,PA.mw],FA={xlsx:F,charts:B},BA={name:"@omegagrid/bundle",version:"0.10.46"};Ja().activate("light"),Wd.styleDefault="fal",Vd.add(jA),Vd.add(HA)})(),window.Omegagrid=o})();
9956
+ `:null,this.addEventListener("mousedown",(t=>t.stopPropagation()))}getTypeIndex(t){const e=this.types.findIndex((e=>e.type==t.type&&e.grouping==(t.grouping||"standard")));return e>-1?e:null}updateModel(){if(this.editTitle=!1,!this.model)return;this.titleInput&&(this.model.title=this.titleInput.value);const t=this.types[this.typeList.value];this.model.type=t.type,this.model.grouping=t.grouping,this.model.categoriesRange=this.categoryRangeInput?.value?Ev.fromA1(this.categoryRangeInput.value):null,this.model.seriesRange=this.seriesRangeInput?.value?Ev.fromA1(this.seriesRangeInput.value):null,this.model.dataRange=Ev.fromA1(this.dataRangeInput.value),this.dispatchEvent(new Qr({value:this.model}))}async updated(){this.editTitle&&this.titleInput&&(await this.titleInput.updateComplete,this.titleInput.focus(),this.titleInput.selectAll())}};AL.styles=[TL],$L([$n({type:Object})],AL.prototype,"model",void 0),$L([An()],AL.prototype,"editTitle",void 0),$L([On("#title")],AL.prototype,"titleInput",void 0),$L([On("#type")],AL.prototype,"typeList",void 0),$L([On("#dataRange")],AL.prototype,"dataRangeInput",void 0),$L([On("#seriesRange")],AL.prototype,"seriesRangeInput",void 0),$L([On("#categoryRange")],AL.prototype,"categoryRangeInput",void 0),AL=$L([In("og-plugin-chart-form")],AL);const DL=Ja().themes.get("og-dark");Object.assign(DL.definition,{"highcharts-title-font-size":"16px","highcharts-subtitle-font-size":"14px","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"rgb(48, 48, 48)","highcharts-neutral-color-100":"rgb(255, 255, 255)","highcharts-neutral-color-80":"rgb(214, 214, 214)","highcharts-neutral-color-60":"rgb(173, 173, 173)","highcharts-neutral-color-40":"rgb(133, 133, 133)","highcharts-neutral-color-20":"rgb(92, 92, 92)","highcharts-neutral-color-10":"rgb(71, 71, 71)","highcharts-neutral-color-5":"rgb(61, 61, 61)","highcharts-neutral-color-3":"rgb(57, 57, 57)","highcharts-highlight-color-100":"rgb(122, 167, 255)","highcharts-highlight-color-80":"rgb(108, 144, 214)","highcharts-highlight-color-60":"rgb(94, 121, 173)","highcharts-highlight-color-20":"rgb(65, 74, 92)","highcharts-highlight-color-10":"rgb(58, 63, 71)"});const OL=Ja().themes.get("og-light");Object.assign(OL.definition,{"highcharts-title-font-size":"16px","chart-background-color":"#2a2a2b","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"#ffffff","highcharts-neutral-color-100":"#000000","highcharts-neutral-color-80":"#333333","highcharts-neutral-color-60":"#666666","highcharts-neutral-color-40":"#999999","highcharts-neutral-color-20":"#cccccc","highcharts-neutral-color-10":"#e6e6e6","highcharts-neutral-color-5":"#f2f2f2","highcharts-neutral-color-3":"#f7f7f7","highcharts-highlight-color-100":"#0022ff","highcharts-highlight-color-80":"#334eff","highcharts-highlight-color-60":"#667aff","highcharts-highlight-color-20":"#ccd3ff","highcharts-highlight-color-10":"#e6e9ff","highcharts-positive-color":"#06b535","highcharts-negative-color":"#f21313","highcharts-annotation-color-0":"rgba(130, 170, 255, 0.4)","highcharts-annotation-color-1":"rgba(139, 191, 216, 0.4)","highcharts-annotation-color-2":"rgba(150, 216, 192, 0.4)","highcharts-annotation-color-3":"rgba(156, 229, 161, 0.4)","highcharts-annotation-color-4":"rgba(162, 241, 130, 0.4)","highcharts-annotation-color-5":"rgba(169, 255, 101, 0.4)"});var NL=i(6946),PL=i(6471),jL=i(4969),HL=i(9502),FL=i(7706),BL=i(1480),WL=i(2006),VL=i(7503),UL=i(7873),GL=i(8746),qL=i(2570),YL=i(8815),ZL=i(6390),XL=i(6593),QL=i(895),KL=i(9083),JL=i(6093),tI=i(9685),eI=i(9849),iI=i(8268),oI=i(4693),rI=i(3599),sI=i(782),nI=i(754),aI=i(5700),lI=i(4731),cI=i(7291),hI=i(597),dI=i(1474),uI=i(6224),pI=i(6239),gI=i(6828),mI=i(2212),fI=i(863),vI=i(3602),bI=i(1985),yI=i(886),wI=i(7201),xI=i(9937),kI=i(8450),CI=i(9630),MI=i(9766),_I=i(388),SI=i(1903),zI=i(398),EI=i(6105),LI=i(6147),II=i(5722),RI=i(5576),TI=i(3131),$I=i(6308),AI=i(9645),DI=i(3199),OI=i(871),NI=i(5251),PI=i(6426),jI=i(2643),HI=i(8522),FI=i(6398),BI=i(2525),WI=i(8434),VI=i(6138),UI=i(5835),GI=i(5654),qI=i(6659),YI=i(2977),ZI=i(4480),XI=i(9886),QI=i(6815),KI=i(1582),JI=i(2968),tR=i(394),eR=i(7024),iR=i(7853),oR=i(8249),rR=i(2869),sR=i(486),nR=i(5735),aR=i(470),lR=i(4612),cR=i(4018),hR=i(1476),dR=i(3194),uR=i(3525),pR=i(7541),gR=i(4104),mR=i(6686),fR=i(7719),vR=i(3898),bR=i(8153),yR=i(3690),wR=i(1776),xR=i(4980),kR=i(5578),CR=i(9613),MR=i(1119),_R=i(8444),SR=i(2978),zR=i(9130),ER=i(2127),LR=i(2732),IR=i(4287),RR=i(4045),TR=i(7642),$R=i(1367),AR=i(320),DR=i(821),OR=i(102),NR=i(7683),PR=i(3980),jR=i(576),HR=i(654),FR=i(73),BR=i(140),WR=i(8129),VR=i(5087),UR=i(6992),GR=i(8247),qR=i(8038),YR=i(5286),ZR=i(9179),XR=i(1808),QR=i(9459),KR=i(2883),JR=i(9124),tT=i(7067),eT=i(1054),iT=i(7325),oT=i(1272),rT=i(3359),sT=i(6562),nT=i(4193),aT=i(6348),lT=i(2435),cT=i(7544),hT=i(4470),dT=i(9111),uT=i(9318),pT=i(7294),gT=i(4479),mT=i(2409),fT=i(3091),vT=i(5789),bT=i(5890),yT=i(3874),wT=i(2907),xT=i(1175),kT=i(1686),CT=i(703),MT=i(6606),_T=i(4194),ST=i(6228),zT=i(62),ET=i(2072),LT=i(9744),IT=i(25),RT=i(2618),TT=i(1988),$T=i(8013),AT=i(1133),DT=i(362),OT=i(6845),NT=i(6800),PT=i(1103),jT=i(4933),HT=i(7284),FT=i(2620),BT=i(2366),WT=i(7457),VT=i(2449),UT=i(2),GT=i(5697),qT=i(7069),YT=i(4716),ZT=i(4740),XT=i(4557),QT=i(1868),KT=i(8647),JT=i(5127),t$=i(4816),e$=i(4009),i$=i(5104),o$=i(2830),r$=i(3093),s$=i(5029),n$=i(3514),a$=i(2142),l$=i(4999),c$=i(7523),h$=i(346),d$=i(7917),u$=i(3976),p$=i(9801),g$=i(2464),m$=i(5511),f$=i(5210),v$=i(5815),b$=i(3339),y$=i(7472),w$=i(8811),x$=i(8548),k$=i(6880),C$=i(1840),M$=i(5547),_$=i(4788),S$=i(9467),z$=i(9187),E$=i(9217),L$=i(7897),I$=i(2644),R$=i(6204),T$=i(1472),$$=i(1247),A$=i(7406),D$=i(925),O$=i(7455),N$=i(3771),P$=i(1549),j$=i(3541),H$=i(3140),F$=i(9800),B$=i(229),W$=i(2677),V$=i(1844),U$=i(3245),G$=i(9056),q$=i(7535),Y$=i(2359),Z$=i(15),X$=i(5569),Q$=i(2014),K$=i(1599),J$=i(6521),tA=i(232),eA=i(9745),iA=i(9594),oA=i(6979),rA=i(4494),sA=i(312),nA=i(4983),aA=i(1258),lA=i(6313),cA=i(12),hA=i(8003),dA=i(7830),uA=i(8875),pA=i(3911),gA=i(1817),mA=i(478),fA=i(2585),vA=i(6564),bA=i(2884),yA=i(3825),wA=i(7348),xA=i(9277),kA=i(4118),CA=i(9200),MA=i(51),_A=i(2872),SA=i(4702),zA=i(9281),EA=i(1394),LA=i(7295),IA=i(2936),RA=i(3789),TA=i(3614),$A=i(4827),AA=i(9204),DA=i(9113),OA=i(4058),NA=i(9939),PA=i(1139);const jA=[NL.mw,PL.mw,jL.mw,HL.mw,FL.mw,BL.mw,WL.mw,VL.mw,GL.mw,YL.mw,qL.mw,ZL.mw,XL.mw,QL.mw,KL.mw,JL.mw,tI.mw,eI.mw,iI.mw,oI.mw,rI.mw,sI.mw,nI.mw,aI.mw,lI.mw,cI.mw,hI.mw,dI.mw,uI.mw,gI.mw,mI.mw,fI.mw,vI.mw,bI.mw,yI.mw,wI.mw,xI.mw,kI.mw,CI.mw,MI.mw,_I.mw,SI.mw,EI.mw,zI.mw,LI.mw,II.mw,RI.mw,TI.mw,$I.mw,AI.mw,DI.mw,OI.mw,NI.mw,PI.mw,jI.mw,HI.mw,BI.mw,WI.mw,VI.mw,UI.mw,GI.mw,qI.mw,YI.mw,ZI.mw,XI.mw,QI.mw,KI.mw,JI.mw,tR.mw,eR.mw,iR.mw,oR.mw,rR.mw,sR.mw,nR.mw,FI.mw,aR.mw,lR.mw,cR.mw,hR.mw,dR.mw,uR.mw,pR.mw,gR.mw,mR.mw,fR.mw,vR.mw,bR.mw,yR.mw,wR.mw,xR.mw,kR.mw,CR.mw,MR.mw,_R.mw,SR.mw,zR.mw,ER.mw,LR.mw,IR.mw,RR.mw,TR.mw,$R.mw,AR.mw,DR.mw,OR.mw,NR.mw,PR.mw,jR.mw,HR.mw,FR.mw,BR.mw,WR.mw,VR.mw,UR.mw,GR.mw,qR.mw,pI.mw,YR.mw,ZR.mw,XR.mw,QR.mw,KR.mw,JR.mw,tT.mw,eT.mw,iT.mw,oT.mw,rT.mw,sT.mw,nT.mw,aT.mw,lT.mw,UL.mw,cT.mw,hT.mw],HA=[dT.mw,uT.mw,pT.mw,gT.mw,mT.mw,fT.mw,vT.mw,bT.mw,wT.mw,kT.mw,xT.mw,MT.mw,CT.mw,_T.mw,ST.mw,zT.mw,ET.mw,LT.mw,IT.mw,RT.mw,TT.mw,$T.mw,PT.mw,jT.mw,HT.mw,FT.mw,BT.mw,WT.mw,VT.mw,GT.mw,qT.mw,YT.mw,JT.mw,t$.mw,e$.mw,i$.mw,o$.mw,r$.mw,s$.mw,n$.mw,AT.mw,DT.mw,NT.mw,OT.mw,a$.mw,l$.mw,c$.mw,h$.mw,d$.mw,u$.mw,p$.mw,g$.mw,ZT.mw,XT.mw,QT.mw,KT.mw,f$.mw,v$.mw,b$.mw,y$.mw,w$.mw,x$.mw,k$.mw,C$.mw,M$.mw,_$.mw,S$.mw,z$.mw,E$.mw,L$.mw,I$.mw,R$.mw,T$.mw,$$.mw,A$.mw,m$.mw,D$.mw,O$.mw,N$.mw,P$.mw,j$.mw,H$.mw,F$.mw,B$.mw,W$.mw,V$.mw,U$.mw,G$.mw,q$.mw,Y$.mw,Z$.mw,X$.mw,Q$.mw,K$.mw,J$.mw,tA.mw,eA.mw,iA.mw,oA.mw,rA.mw,sA.mw,nA.mw,aA.mw,lA.mw,cA.mw,hA.mw,dA.mw,uA.mw,pA.mw,gA.mw,mA.mw,fA.mw,vA.mw,bA.mw,yA.mw,wA.mw,xA.mw,UT.mw,kA.mw,CA.mw,MA.mw,_A.mw,SA.mw,zA.mw,EA.mw,LA.mw,IA.mw,RA.mw,TA.mw,$A.mw,AA.mw,DA.mw,OA.mw,yT.mw,NA.mw,PA.mw],FA={xlsx:F,charts:B},BA={name:"@omegagrid/bundle",version:"0.10.48"};Ja().activate("light"),Wd.styleDefault="fal",Vd.add(jA),Vd.add(HA)})(),window.Omegagrid=o})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/bundle",
3
- "version": "0.10.46",
3
+ "version": "0.10.48",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Distribution package for Omegagrid library",
6
6
  "main": "omegagrid.js",
@@ -19,23 +19,23 @@
19
19
  "@fortawesome/fontawesome-svg-core": "^7.0.1",
20
20
  "@fortawesome/pro-light-svg-icons": "^7.0.1",
21
21
  "@fortawesome/pro-solid-svg-icons": "^7.0.1",
22
- "@omegagrid/bucket": "^0.10.46",
23
- "@omegagrid/calendar": "^0.10.46",
24
- "@omegagrid/code": "^0.10.46",
25
- "@omegagrid/commands": "^0.10.46",
26
- "@omegagrid/core": "^0.10.46",
27
- "@omegagrid/dialog": "^0.10.46",
28
- "@omegagrid/editor": "^0.10.46",
29
- "@omegagrid/form": "^0.10.46",
30
- "@omegagrid/grid": "^0.10.46",
31
- "@omegagrid/localize": "^0.10.46",
32
- "@omegagrid/markdown": "^0.10.46",
33
- "@omegagrid/plugin-charts": "^0.10.46",
34
- "@omegagrid/plugin-xlsx": "^0.10.46",
35
- "@omegagrid/statusbar": "^0.10.46",
36
- "@omegagrid/tabs": "^0.10.46",
37
- "@omegagrid/toolbar": "^0.10.46",
38
- "@omegagrid/tree": "^0.10.46",
22
+ "@omegagrid/bucket": "^0.10.48",
23
+ "@omegagrid/calendar": "^0.10.48",
24
+ "@omegagrid/code": "^0.10.48",
25
+ "@omegagrid/commands": "^0.10.48",
26
+ "@omegagrid/core": "^0.10.48",
27
+ "@omegagrid/dialog": "^0.10.48",
28
+ "@omegagrid/editor": "^0.10.48",
29
+ "@omegagrid/form": "^0.10.48",
30
+ "@omegagrid/grid": "^0.10.48",
31
+ "@omegagrid/localize": "^0.10.48",
32
+ "@omegagrid/markdown": "^0.10.48",
33
+ "@omegagrid/plugin-charts": "^0.10.48",
34
+ "@omegagrid/plugin-xlsx": "^0.10.48",
35
+ "@omegagrid/statusbar": "^0.10.48",
36
+ "@omegagrid/tabs": "^0.10.48",
37
+ "@omegagrid/toolbar": "^0.10.48",
38
+ "@omegagrid/tree": "^0.10.48",
39
39
  "lit": "^3.1.1"
40
40
  },
41
41
  "devDependencies": {