xiaodao-spreader 0.1.41 → 0.1.42
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.
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`).length,hn>I&&(I=hn)}}const ye=b+R,ke=Z*2+I*ye;return Math.min(500,Math.max(lt,Math.round(ke)))}Vt=Zt;function Vn(s){return A.value[s]===void 0}const U={getValue:(s,f)=>Hn(s,f),getFormat:(s,f)=>{var b;return(b=qe(S[wt(s,f)]))==null?void 0:b.numberFormat}},W=t.computed(()=>{const s=new Set,f=x.value;if(!f)return s;const{range:b}=f;for(let R=b.startRow+1;R<=b.endRow;R++)X(R)||s.add(R);return s});function X(s){return qf(x.value,s,U,i.value)}function Ce(){return W.value}function Ne(s){return tt(s)?!0:x.value?W.value.has(s):!1}function Ve(){let s=0;for(let f=0;f<c.rowCount;f++)Ne(f)||s++;return s}function He(s){let f=-1;for(let b=0;b<c.rowCount;b++)if(!Ne(b)&&(f++,f===s))return b;return-1}function Me(s){if(Ne(s))return-1;let f=0;for(let b=0;b<s;b++)Ne(b)||f++;return f}const Le=t.computed(()=>{const s=new Set,f=H.value;for(let b=0;b<f.length;b++){const R=f[b];if(R.collapsed)for(let I=Math.max(0,R.start);I<=R.end&&I<c.rowCount;I++)s.add(I)}return s}),be=t.computed(()=>{const s=new Set,f=z.value;for(let b=0;b<f.length;b++){const R=f[b];if(R.collapsed)for(let I=Math.max(0,R.start);I<=R.end&&I<c.colCount;I++)s.add(I)}return s});function tt(s){return Le.value.has(s)}function k(s){return be.value.has(s)}function q(s){return tt(s)}function re(s){return k(s)}function Se(s){return!Ne(s)}function Te(s){return!k(s)}function pe(s){return k(s)}function F(s){return pe(s)?0:je.value[s]??100}function p(s){return di(H.value,s)}function N(s){return di(z.value,s)}function bt(s){const f=s==="row"?H.value:z.value;let b=0;for(let R=0;R<f.length;R++){const I=f[R].level;I>b&&(b=I)}return b}function vt(s){return 0}const Kt=()=>vt(),Nt=()=>vt();function fo(){return H.value.map(s=>({...s}))}function mo(){return z.value.map(s=>({...s}))}function Xt(s=!1){var f,b;s||(Qt(K.value,$.value),(f=w.scheduleRender)==null||f.call(w),(b=w.emitModelData)==null||b.call(w))}function Gl(s,f){var R;const b=Or(H.value,s,f);return!b.ok||b.level===void 0?b:((R=w.saveUndo)==null||R.call(w),H.value=Jn(ri(H.value,"row",s,f,ui(H.value,"row")).outlines),Xt(),{ok:!0,level:b.level})}function Qn(s,f){var R;const b=Or(z.value,s,f);return!b.ok||b.level===void 0?b:((R=w.saveUndo)==null||R.call(w),z.value=Jn(ri(z.value,"column",s,f,ui(z.value,"column")).outlines),Xt(),{ok:!0,level:b.level})}function Io(s){var R;const f=H.value.some(I=>I.id===s),b=!f&&z.value.some(I=>I.id===s);return!f&&!b?!1:((R=w.saveUndo)==null||R.call(w),f?H.value=Jn(ii(H.value,s)):z.value=Jn(ii(z.value,s)),Xt(),!0)}function Ao(){var s;H.value.length&&((s=w.saveUndo)==null||s.call(w),H.value=Pl(),Xt())}function ql(){var s;z.value.length&&((s=w.saveUndo)==null||s.call(w),z.value=Pl(),Xt())}function bl(){var s;!H.value.length&&!z.value.length||((s=w.saveUndo)==null||s.call(w),H.value=Pl(),z.value=Pl(),Xt())}function Yl(s,f,b=!1){var ne;const R=ai(H.value,s,f),I=ai(z.value,s,f);R===H.value&&I===z.value||(b||(ne=w.saveUndo)==null||ne.call(w),H.value=R,z.value=I,Xt(b))}function $r(s){const f=H.value.find(b=>b.id===s)??z.value.find(b=>b.id===s);f&&Yl(s,!f.collapsed)}function zr(s,f){H.value.length&&(H.value=Jn(si(H.value,s,f)),Xt())}function jl(s,f){H.value.length&&(H.value=Jn(ci(H.value,s,f)),Xt())}function jo(s,f){z.value.length&&(z.value=Jn(si(z.value,s,f)),Xt())}function _r(s,f){z.value.length&&(z.value=Jn(ci(z.value,s,f)),Xt())}function yl(s,f){s&&(H.value=Jn([...s])),f&&(z.value=Jn([...f])),Xt(!0)}function Cl(){return x.value}function wl(s,f=!1){var b,R;x.value=s,!f&&(Qt(K.value,$.value),(b=w.scheduleRender)==null||b.call(w),(R=w.emitModelData)==null||R.call(w))}function Xo(s){var b,R;const f={range:{startCol:Math.min(s.startCol,s.endCol),endCol:Math.max(s.startCol,s.endCol),startRow:Math.min(s.startRow,s.endRow),endRow:Math.max(s.startRow,s.endRow)},columns:{}};x.value=f,Qt(K.value,$.value),(b=w.scheduleRender)==null||b.call(w),(R=w.emitModelData)==null||R.call(w)}function Xl(){var s,f;x.value&&(x.value=null,Qt(K.value,$.value),(s=w.scheduleRender)==null||s.call(w),(f=w.emitModelData)==null||f.call(w))}function Hr(s){var R,I;if(!x.value)return;const{[s]:f,...b}=x.value.columns;x.value={...x.value,columns:b},(R=w.scheduleRender)==null||R.call(w),(I=w.emitModelData)==null||I.call(w)}function Lo(s,f){var b,R;if(x.value){if(f)x.value={...x.value,columns:{...x.value.columns,[s]:f}};else{const{[s]:I,...ne}=x.value.columns;x.value={...x.value,columns:ne}}(b=w.scheduleRender)==null||b.call(w),(R=w.emitModelData)==null||R.call(w)}}function $o(s){const f=x.value;return f?Yf(f,s,U,i.value):{values:[],hasBlank:!1}}function Zo(s,f){const b=c.colCount,R=c.rowCount,I=(Xe,Qe)=>{const ht=S[eo(Xe,Qe)];return!!ht&&(ht.value!==""||ht.styleId!==void 0)};if(!I(s,f))return null;const ne=Xe=>{for(let Qe=0;Qe<b;Qe++)if(I(Qe,Xe))return!0;return!1},ie=(Xe,Qe,ht)=>{for(let Ct=Qe;Ct<=ht;Ct++)if(I(Xe,Ct))return!0;return!1};let ye=f;for(;ye>0&&ne(ye-1);)ye--;let ke=f;for(;ke<R-1&&ne(ke+1);)ke++;let Ue=s;for(;Ue>0&&ie(Ue-1,ye,ke);)Ue--;let _e=s;for(;_e<b-1&&ie(_e+1,ye,ke);)_e++;return{startCol:Ue,startRow:ye,endCol:_e,endRow:ke}}function Jo(){const s=we.value;if(!!s&&s.startRow!==s.endRow)return{startCol:Math.min(s.startCol,s.endCol),endCol:Math.max(s.startCol,s.endCol),startRow:Math.min(s.startRow,s.endRow),endRow:Math.max(s.startRow,s.endRow)};const b=Ke.value,R=s?s.startCol:b.col,I=s?s.startRow:b.row,ne=(Ue,_e)=>{const Xe=S[eo(Ue,_e)];return!!Xe&&(Xe.value!==""||Xe.styleId!==void 0)};let ie,ye;s?(ie=Math.min(s.startCol,s.endCol),ye=Math.max(s.startCol,s.endCol)):(ie=b.col,ye=b.col);let ke=I;for(;ke<c.rowCount-1;){const Ue=ke+1;let _e=!1,Xe=!1;for(let Qe=ie;Qe<=ye;Qe++){ne(Qe,Ue)&&(_e=!0);const ht=zn(Qe,Ue);ht&&(ht.range.startCol!==ht.range.endCol||ht.range.startRow!==ht.range.endRow)&&(Xe=!0)}if(Xe||!_e)break;ke++}return!ne(R,I)&&ke===I?Zl():{startCol:ie,endCol:ye,startRow:I,endRow:ke}}function Qo(){if(x.value){Xl();return}const s=Jo();s&&Xo(s)}function vl(s){const f=x.value;return f?s>=f.range.startCol&&s<=f.range.endCol:!1}function po(){return x.value?{...x.value.range}:null}function el(){return!!x.value}function tl(s){const f=x.value;return f?$a(f.columns[s]):!1}function Zl(){let s=1/0,f=1/0,b=-1,R=-1;for(const I in S){const ne=I.indexOf(",");if(ne<0)continue;const ie=parseInt(I.substring(0,ne),10),ye=parseInt(I.substring(ne+1),10),ke=S[I];ke&&(ke.value!==""||ke.styleId!==void 0)&&(ie<s&&(s=ie),ye<f&&(f=ye),ie>b&&(b=ie),ye>R&&(R=ye))}return b<0?null:{startCol:s,startRow:f,endCol:b,endRow:R}}const ho=t.computed(()=>{const s=[0];for(let f=0;f<c.rowCount;f++)s.push(s[f]+Vt(f));return s}),nl=t.computed(()=>Dt.value[c.colCount]),ol=t.computed(()=>ho.value[c.rowCount]);function eo(s,f){return`${s},${f}`}wt=eo;function ll(s){Reflect.deleteProperty(S,s)}function go(s,f){Re.value="cell";const b=ft(s,f);b?(Ke.value={col:b.range.startCol,row:b.range.startRow},we.value={...b.range}):(Ke.value={col:s,row:f},we.value={startCol:s,startRow:f,endCol:s,endRow:f})}function cn(s,f,b,R,I="cell"){const ne=ft(s,f);if(Ke.value=ne?{col:ne.range.startCol,row:ne.range.startRow}:{col:s,row:f},Re.value=I,I==="row"||I==="col"){const ie=Math.min(s,b),ye=Math.max(s,b),ke=Math.min(f,R),Ue=Math.max(f,R);we.value={startCol:ie,startRow:ke,endCol:ye,endRow:Ue}}else we.value=wn(s,f,b,R)}function vn(){cn(0,0,c.colCount-1,c.rowCount-1,"all")}function kn(s,f){const b=we.value;return b?(Re.value==="cell"||Re.value==="all",s>=b.startCol&&s<=b.endCol&&f>=b.startRow&&f<=b.endRow):!1}function Dn(s,f){return kn(s,f)}function zn(s,f){for(const b in se){const R=se[b];if(R&&s>=R.startCol&&s<=R.endCol&&f>=R.startRow&&f<=R.endRow)return{range:R,anchor:b}}return null}ft=zn;function No(s,f){return se[eo(s,f)]!==void 0}function to(s,f){const b=ft(s,f);if(b&&s===b.range.startCol&&f===b.range.startRow){const R=Dt.value[b.range.endCol+1]-Dt.value[s],I=ho.value[b.range.endRow+1]-ho.value[f];return{w:R,h:I}}return{w:F(s),h:Vt(f)}}function _n(s,f,b,R){let I=Math.min(s,b),ne=Math.max(s,b),ie=Math.min(f,R),ye=Math.max(f,R),ke=!0;for(;ke;){ke=!1;for(const Ue in se){const _e=se[Ue];if(!_e)continue;_e.startCol<=ne&&_e.endCol>=I&&_e.startRow<=ye&&_e.endRow>=ie&&(_e.startCol<I&&(I=_e.startCol,ke=!0),_e.endCol>ne&&(ne=_e.endCol,ke=!0),_e.startRow<ie&&(ie=_e.startRow,ke=!0),_e.endRow>ye&&(ye=_e.endRow,ke=!0))}}return{startCol:I,startRow:ie,endCol:ne,endRow:ye}}wn=_n;function Bo(s,f){var b;return((b=S[eo(s,f)])==null?void 0:b.value)??""}function Hn(s,f){return Mo(),Oa(s,f,S,c.colCount,c.rowCount)}function zo(s,f,b){var ke,Ue,_e;s>=0&&f>=0&&T(s,f);const R=eo(s,f);Mo(),te.invalidate(),fe.length>0&&Lt();const I=(ke=S[R])==null?void 0:ke.noteId;if(b===""||b==null){de.clear(R);const Xe=(Ue=S[R])==null?void 0:Ue.styleId;Xe!==void 0&&Xe>0?S[R]={value:"",styleId:Xe}:ll(R),de.markDirty(R);return}const ne=String(b);if(!ne.startsWith("=")){const Xe=qe(S[R]),Qe=typeof(Xe==null?void 0:Xe.numberFormat)=="string"?Xe.numberFormat:"";if(xn(Qe)){const ht=Xn(ne,i.value);if(ht){const qt={...Xe??{},numberFormat:ht.format};S[R]={value:String(ht.serial),styleId:ae(qt),noteId:I},de.clear(R),de.markDirty(R);return}const Ct=Vl(ne,i.value);if(Ct){const qt={...Xe??{},numberFormat:Ct.format};S[R]={value:String(Ct.num),styleId:ae(qt),noteId:I},de.clear(R),de.markDirty(R);return}}}const ie=(_e=S[R])==null?void 0:_e.styleId,ye={value:ne};ie!==void 0&&ie>0&&(ye.styleId=ie),I&&(ye.noteId=I),S[R]=ye,ne.startsWith("=")?de.set(R,Il(ne.slice(1),c.colCount,c.rowCount)):de.clear(R),de.markDirty(R)}function rl(s,f,b,R){for(let I=s;I<=f;I++)for(let ne=b;ne<=R;ne++){const ie=eo(I,ne);de.clear(ie),ll(ie),de.markDirty(ie)}te.invalidate(),fe.length>0&&Lt(),Wl(S,ge)}function dn(){return{cells:S,colCount:c.colCount,rowCount:c.rowCount,locale:i.value,getCellValue:(s,f)=>Hn(s,f)}}function bo(s,f){return G.length===0?null:fp(s,f,G,dn(),te)}function Bt(s){var b,R,I;(b=w.saveUndo)==null||b.call(w);const f={id:s.id||mp(),condition:s.condition,format:s.format,ranges:s.ranges,priority:s.priority,stopIfTrue:s.stopIfTrue,enabled:s.enabled!==!1};G.push(f),te.invalidate(),(R=w.scheduleRender)==null||R.call(w),(I=w.emitModelData)==null||I.call(w)}function xt(s,f){var R,I,ne;(R=w.saveUndo)==null||R.call(w);const b=G.findIndex(ie=>ie.id===s);b<0||(G[b]={...G[b],...f,id:s},te.invalidate(),(I=w.scheduleRender)==null||I.call(w),(ne=w.emitModelData)==null||ne.call(w))}function en(s){var b,R,I;(b=w.saveUndo)==null||b.call(w);const f=G.findIndex(ne=>ne.id===s);f<0||(G.splice(f,1),te.invalidate(),(R=w.scheduleRender)==null||R.call(w),(I=w.emitModelData)==null||I.call(w))}function kl(s,f){var ke,Ue,_e;(ke=w.saveUndo)==null||ke.call(w);const b=[...G].sort((Xe,Qe)=>Xe.priority-Qe.priority),R=b.findIndex(Xe=>Xe.id===s);if(R<0)return;const I=f==="up"?R-1:R+1;if(I<0||I>=b.length)return;const ne=b[R],ie=b[I],ye=ne.priority;ne.priority=ie.priority,ie.priority=ye,te.invalidate(),(Ue=w.scheduleRender)==null||Ue.call(w),(_e=w.emitModelData)==null||_e.call(w)}function Jl(){te.invalidate()}function Ql(s){var f,b,R;if((f=w.saveUndo)==null||f.call(w),s==="sheet")G.splice(0,G.length);else{const I=w.selection.value;if(!I)return;for(let ne=G.length-1;ne>=0;ne--){const ie=G[ne];ie.ranges=ie.ranges.filter(ye=>!(ye.startCol<=I.endCol&&ye.endCol>=I.startCol&&ye.startRow<=I.endRow&&ye.endRow>=I.startRow)),ie.ranges.length===0&&G.splice(ne,1)}}te.invalidate(),(b=w.scheduleRender)==null||b.call(w),(R=w.emitModelData)==null||R.call(w)}function Lt(){Ie.invalidate(),me.clear()}function Fn(){return{cells:S,colCount:c.colCount,rowCount:c.rowCount,locale:i.value,getCellValue:(s,f)=>Hn(s,f),getSheetCells:s=>w.getSheetCellsById?w.getSheetCellsById(s):null}}function tn(s,f){const b=ft(f,s),R=b?{col:b.range.startCol,row:b.range.startRow}:{col:f,row:s};return Ie.getRules(R.col,R.row,fe)}function Wn(s,f){const b=tn(s,f);return b.length?b[0]:null}function yo(s,f){return tn(s,f).length>0}function En(s,f){const b=ft(f,s),R=b?{col:b.range.startCol,row:b.range.startRow}:{col:f,row:s};return Ie.findRule(R.col,R.row,wp,fe)}function xo(s){const f=s.listSource,b=f&&f.type==="range"?`range:${f.sheetId??""}:${f.range.startCol},${f.range.startRow},${f.range.endCol},${f.range.endRow}`:`values:${(f&&f.type==="values"?f.values:s.values??[]).join("")}`,R=me.get(b);if(R)return R;const I=ei(s,Fn());return me.set(b,I),I}function er(s,f){const b=En(s,f);return b?{rule:b,items:xo(b)}:null}function tr(s,f){for(const b of tn(s,f)){if(b.enabled===!1||!b.showInputMessage)continue;const R=b.inputTitle??"",I=b.inputMessage??"";if(!(!R&&!I))return{title:R,message:I}}return null}function al(s,f,b){const R=tn(s,f);return R.length===0?{valid:!0}:ti(b,f,s,R,Fn())}function nr(s){const f=Fn(),b={stop:3,warning:2,information:1};let R=null,I=0;for(const ne of s){const ie=tn(ne.row,ne.col);if(ie.length===0)continue;const ye=ti(ne.value,ne.col,ne.row,ie,f);if(ye.valid)continue;const ke=b[Fr(ye.rule)]??0;ke>I&&(I=ke,R=ye)}return R??{valid:!0}}function or(s,f){return Za(s,f,S)}function El(s,f){return ep(s,f,S,ge)}function lr(s,f,b,R,I){var ie,ye,ke;I!=null&&I.silent||(ie=w.saveUndo)==null||ie.call(w);const ne=np(s,f,b,R,S,ge);return Wl(S,ge),(ye=w.scheduleRender)==null||ye.call(w),(ke=w.emitModelData)==null||ke.call(w),ne}function rr(s,f){var b,R,I;ge[s]&&((b=w.saveUndo)==null||b.call(w),op(s,f,ge),(R=w.scheduleRender)==null||R.call(w),(I=w.emitModelData)==null||I.call(w))}function Wr(s,f){var b,R,I;Za(s,f,S)&&((b=w.saveUndo)==null||b.call(w),lp(s,f,S,ge),Wl(S,ge),(R=w.scheduleRender)==null||R.call(w),(I=w.emitModelData)==null||I.call(w))}function Ur(){Wl(S,ge)}function Pr(s){return rp(s,S,ge)}function ar(s,f){var R,I,ne;f!=null&&f.silent||(R=w.saveUndo)==null||R.call(w);const b={...s,id:s.id||Ja(),ranges:(s.ranges??[]).map(ie=>({...ie})),enabled:s.enabled!==!1};return fe.push(b),Lt(),f!=null&&f.silent||((I=w.scheduleRender)==null||I.call(w),(ne=w.emitModelData)==null||ne.call(w)),b}function Kr(s,f,b){var I,ne,ie;const R=fe.findIndex(ye=>ye.id===s);if(R<0){ar({id:s,...f},b);return}b!=null&&b.silent||(I=w.saveUndo)==null||I.call(w),fe[R]={...fe[R],...f,id:s},Lt(),b!=null&&b.silent||((ne=w.scheduleRender)==null||ne.call(w),(ie=w.emitModelData)==null||ie.call(w))}function Gr(s,f){var R,I,ne;const b=fe.findIndex(ie=>ie.id===s);b<0||(f!=null&&f.silent||(R=w.saveUndo)==null||R.call(w),fe.splice(b,1),Lt(),f!=null&&f.silent||((I=w.scheduleRender)==null||I.call(w),(ne=w.emitModelData)==null||ne.call(w)))}function qr(s,f){var I,ne,ie,ye,ke,Ue;if(!s){if(fe.length===0)return;f!=null&&f.silent||(I=w.saveUndo)==null||I.call(w),fe.splice(0,fe.length),Lt(),f!=null&&f.silent||((ne=w.scheduleRender)==null||ne.call(w),(ie=w.emitModelData)==null||ie.call(w));return}const b={startCol:Math.min(s.startCol,s.endCol),endCol:Math.max(s.startCol,s.endCol),startRow:Math.min(s.startRow,s.endRow),endRow:Math.max(s.startRow,s.endRow)};if(fe.filter(_e=>(_e.ranges??[]).some(Xe=>!(Xe.endCol<b.startCol||Xe.startCol>b.endCol||Xe.endRow<b.startRow||Xe.startRow>b.endRow))).length!==0){f!=null&&f.silent||(ye=w.saveUndo)==null||ye.call(w);for(let _e=fe.length-1;_e>=0;_e--){const Xe=fe[_e],Qe=[];for(const ht of Xe.ranges??[])Qe.push(...oi(ht,b));Qe.length===0?fe.splice(_e,1):Xe.ranges=Qe}Lt(),f!=null&&f.silent||((ke=w.scheduleRender)==null||ke.call(w),(Ue=w.emitModelData)==null||Ue.call(w))}}function Yr(s){const f=[];for(const b of fe)for(const R of b.ranges??[]){const I=li(R,s);I&&f.push({rule:b,range:I})}return f}function jr(s,f,b){var R,I,ne;if(s.length){b!=null&&b.silent||(R=w.saveUndo)==null||R.call(w);for(let ie=fe.length-1;ie>=0;ie--){const ye=fe[ie],ke=[];for(const Ue of ye.ranges??[])ke.push(...oi(Ue,f));ke.length===0?fe.splice(ie,1):ye.ranges=ke}for(const ie of s){const ye=[];for(const ke of ie.ranges??[]){const Ue=li(ke,f);Ue&&ye.push(Ue)}ye.length&&fe.push({...ie,id:Ja(),ranges:ye})}Lt(),b!=null&&b.silent||((I=w.scheduleRender)==null||I.call(w),(ne=w.emitModelData)==null||ne.call(w))}}async function Rl(s,f,b){const R=s.severity??"stop";if(!(!s.rule||s.rule.showErrorMessage!==!1))return R==="stop"?"cancel":"continue";const ne=w.showValidationAlert;if(!ne)return R==="stop"?"cancel":"continue";Ee++;try{return await ne({severity:R,title:s.title??"",message:s.message??"",col:f,row:b})}catch{return"cancel"}finally{Ee=Math.max(0,Ee-1)}}function Ml(){return Ee>0}let Sl=()=>{};function ir(s){We.value||(We.value={...Ke.value},s!==void 0?rt.value=s:rt.value||(rt.value=Bo(Ke.value.col,Ke.value.row)))}async function Nl(){const s=We.value;if(!s)return!1;const f=s.col,b=s.row,R=rt.value,I=al(b,f,R);return!I.valid&&await Rl(I,f,b)!=="continue"?!1:(Sl(),zo(f,b,R),We.value=null,rt.value="",!0)}function Bl(){We.value=null,rt.value=""}function Xr(s,f){const b=Ke.value;let R=Math.max(0,b.col+s),I=Math.max(0,b.row+f);(R>=c.colCount||I>=c.rowCount)&&T(R,I);const ne=ft(b.col,b.row),ie=ft(R,I);ne&&ie&&ne.anchor===ie.anchor&&(s>0?R=ne.range.endCol+1:s<0&&(R=ne.range.startCol-1),f>0?I=ne.range.endRow+1:f<0&&(I=ne.range.startRow-1),(R>=c.colCount||I>=c.rowCount)&&T(R,I)),R=Math.max(0,Math.min(c.colCount-1,R)),I=Math.max(0,Math.min(c.rowCount-1,I)),go(R,I)}function Zr(s,f){j(f,s)}function sr(s){const f=Dt.value;if(s<0||s>=f[c.colCount])return-1;let b=0,R=c.colCount-1;for(;b<R;){const I=b+R+1>>1;f[I]<=s?b=I:R=I-1}return b}function cr(s){const f=ho.value;if(s<0||s>=f[c.rowCount])return-1;let b=0,R=c.rowCount-1;for(;b<R;){const I=b+R+1>>1;f[I]<=s?b=I:R=I-1}return b}function Jr(s,f){var I,ne;const b=Math.max(0,Math.min(Math.floor(s),c.rowCount)),R=Math.max(0,Math.min(Math.floor(f),c.colCount));V.rows=b,V.cols=R,(I=w.scheduleRender)==null||I.call(w),(ne=w.emitModelData)==null||ne.call(w)}function Qr(){var s,f;V.rows=0,V.cols=0,(s=w.scheduleRender)==null||s.call(w),(f=w.emitModelData)==null||f.call(w)}function pn(){return{rows:V.rows,cols:V.cols}}function no(){let s=0,f=0;if(V.cols>0){const b=je.value,R=Math.min(V.cols,b.length);for(let I=0;I<R;I++)s+=b[I]}if(V.rows>0)for(let b=0;b<V.rows;b++)f+=Vt(b);return{frozenRowsHeight:f,frozenColumnsWidth:s}}function ea(){const{frozenColumnsWidth:s,frozenRowsHeight:f}=no(),b=Kt(),R=Nt(),I=52+b+s,ne=24+R+f,ie=Math.max(0,Jt.w-52-b-11-s),ye=Math.max(0,Jt.h-24-R-11-f),ke=[];return f>0&&s>0&&ke.push({kind:"corner",x:52+b,y:24+R,width:s,height:f,scrollLeft:0,scrollTop:0}),f>0&&ke.push({kind:"rows",x:I,y:24+R,width:ie,height:f,scrollLeft:K.value,scrollTop:0}),s>0&&ke.push({kind:"columns",x:52+b,y:ne,width:s,height:ye,scrollLeft:0,scrollTop:$.value}),ke.push({kind:"body",x:I,y:ne,width:ie,height:ye,scrollLeft:K.value,scrollTop:$.value}),ke}function u(s,f){const b=Dt.value,R=ho.value,I=b[f]??0,ne=R[s]??0,ie=ft(f,s),ye=ie?(b[ie.range.endCol+1]??I)-I:(b[f+1]??I)-I,ke=ie?(R[ie.range.endRow+1]??ne)-ne:Vt(s),Ue=f<V.cols,_e=s<V.rows,Xe=(Ue?0:-K.value)+52+Kt()+I,Qe=(_e?0:-$.value)+24+Nt()+ne;return{x:Xe,y:Qe,width:ye,height:ke}}function y(s,f){const{frozenColumnsWidth:b,frozenRowsHeight:R}=no(),I=Kt(),ne=Nt();if(s<52+I||f<24+ne)return null;const ie=b>0&&s<52+I+b,ye=R>0&&f<24+ne+R,ke=ie?s-52-I:s-52-I+K.value,Ue=ye?f-24-ne:f-24-ne+$.value,_e=sr(ke),Xe=cr(Ue);return _e<0||Xe<0?null:{col:_e,row:Xe}}function D(s,f){return s<V.rows||f<V.cols}function j(s,f){if(D(s,f))return;const{frozenColumnsWidth:b,frozenRowsHeight:R}=no(),I=Math.max(0,Jt.w-52-Kt()-11-b),ne=Math.max(0,Jt.h-24-Nt()-11-R),ie=Dt.value,ye=ho.value,ke=(ie[f]??0)-b,Ue=(ye[s]??0)-R,_e=ft(f,s),Xe=_e?(ie[_e.range.endCol+1]??0)-(ie[f]??0):je.value[f]??0,Qe=_e?(ye[_e.range.endRow+1]??0)-(ye[s]??0):Vt(s);let ht=K.value,Ct=$.value;ke<ht?ht=ke:ke+Xe>ht+I&&(ht=ke+Xe-I),Ue<Ct?Ct=Ue:Ue+Qe>Ct+ne&&(Ct=Ue+Qe-ne),ht=Math.max(0,ht),Ct=Math.max(0,Ct),Qt(ht,Ct)}function T(s,f){var ne;const b=s+1,R=f+1;let I=!1;if(b>=c.colCount){const ie=Math.max(c.colCount+C,b),ye=ie-c.colCount,ke=je.value;for(let Ue=0;Ue<ye;Ue++)ke.push(100);c.colCount=ie,I=!0}if(R>=c.rowCount){const ie=Math.max(c.rowCount+h,R),ye=ie-c.rowCount,ke=A.value;for(let Ue=0;Ue<ye;Ue++)ke.push(void 0);c.rowCount=ie,I=!0}I&&((ne=w.scheduleRender)==null||ne.call(w))}function P(){return c.colCount!==r||c.rowCount!==d}function ee(s,f,b){const R=Nr(s,f,se);if(!R.ok){R.reason==="target-merge-size"&&window.alert(g(i.value,"autofillMergeSizeError"));return}const I=ja(s,f,{cells:S},b,i.value,c.colCount,c.rowCount,pt),ne=Object.entries(I.cells).map(([ye,ke])=>{const Ue=ye.indexOf(",");return{col:parseInt(ye.substring(0,Ue),10),row:parseInt(ye.substring(Ue+1),10),value:ke?ke.value:""}}),ie=nr(ne);if(!ie.valid){(async()=>await Rl(ie,f.startCol,f.startRow)==="continue"&&Q(s,f,b))();return}Q(s,f,b)}function Q(s,f,b){var ne,ie,ye;(ne=w.saveUndo)==null||ne.call(w),T(f.endCol,f.endRow);const R=ja(s,f,{cells:S},b,i.value,c.colCount,c.rowCount,pt);Mo();for(const[ke,Ue]of Object.entries(R.cells)){const _e=ke.indexOf(","),Xe=parseInt(ke.substring(0,_e),10),Qe=parseInt(ke.substring(_e+1),10),ht=zn(Xe,Qe);if(ht&&!(Xe===ht.range.startCol&&Qe===ht.range.startRow))continue;const Ct=Ue.value;Ct===""&&(Ue.styleId===void 0||Ue.styleId===0)?(de.clear(ke),ll(ke)):(S[ke]={value:Ct,...Ue.styleId!==void 0&&Ue.styleId>0?{styleId:Ue.styleId}:{}},Ct.startsWith("=")?de.set(ke,Il(Ct.slice(1),c.colCount,c.rowCount)):de.clear(ke)),de.markDirty(ke)}const I={startCol:Math.min(s.startCol,f.startCol),startRow:Math.min(s.startRow,f.startRow),endCol:Math.max(s.endCol,f.endCol),endRow:Math.max(s.endRow,f.endRow)};cn(I.startCol,I.startRow,I.endCol,I.endRow),(ie=w.scheduleRender)==null||ie.call(w),(ye=w.emitModelData)==null||ye.call(w)}function ue(s,f){var ne;let b=!1;const R=Math.max(1,Math.floor(s)),I=Math.max(1,Math.floor(f));if(R!==c.colCount){if(R>c.colCount){const ie=je.value;for(let ye=c.colCount;ye<R;ye++)ie.push(100)}else je.value=je.value.slice(0,R);c.colCount=R,b=!0}if(I!==c.rowCount){if(I>c.rowCount){const ie=A.value;for(let ye=c.rowCount;ye<I;ye++)ie.push(void 0)}else A.value=A.value.slice(0,I);c.rowCount=I,b=!0}b&&((ne=w.scheduleRender)==null||ne.call(w))}const w={props:a,locale:i,get colCount(){return c.colCount},get rowCount(){return c.rowCount},ensureCapacity:T,hasDynamicDims:P,setDims:ue,cells:S,styles:m,borders:M,merges:se,formulaDeps:de,selection:we,activeCell:Ke,editingCell:We,editValue:rt,colWidths:je,rowHeights:A,scrollX:K,scrollY:$,freeze:V,setFreeze:Jr,clearFreeze:Qr,getFreeze:pn,getFrozenMetrics:no,filter:x,getFilter:Cl,setFilter:wl,enableFilter:Xo,clearFilter:Xl,clearFilterColumn:Hr,setFilterColumn:Lo,getColumnCandidates:$o,getDataRange:Zl,getCurrentRegion:Zo,detectFilterRange:Jo,toggleAutoFilter:Qo,isColumnInFilterRange:vl,getFilterRange:po,isFilterEnabled:el,isFilterColumnActive:tl,isRowHidden:Ne,getFilteredOutRows:Ce,getVisibleRowCount:Ve,getVisibleRowAt:He,getVisibleRowIndex:Me,getViewportRegions:ea,cellToScreenRect:u,screenToCell:y,isCellFrozen:D,scrollCellIntoView:j,BASE_CELL_VPAD:Z,AUTO_ROW_BASE:lt,fontMetricsCache:ve,fontMetricsCanvas:ze,measureFontMetrics:it,_getFontMetricsForCell:an,getWrappedLines:sn,cellFontSize:mn,colPositions:Dt,getRowHeight:Zt,_isAutoRow:Vn,rowPositions:ho,totalWidth:nl,totalHeight:ol,selectCell:go,selectRange:cn,selectAll:vn,isSelected:kn,isCellSelected:Dn,selectionMode:Re,cellKey:eo,delCell:ll,findMerge:zn,_isMergeAnchor:No,_mergedSpan:to,expandSelectionForMerges:_n,getCellRaw:Bo,getCellValue:Hn,setCellValue:zo,clearCellsInRange:rl,startEdit:ir,commitEdit:Nl,cancelEdit:Bl,moveActive:Xr,ensureVisible:Zr,hitCol:sr,hitRow:cr,registerStyle:ae,resolveStyle:qe,rebuildStyleIndex:ut,syncStyles:J,registerBorder:O,resolveBorder:L,rebuildBorderIndex:le,syncBorders:$e,getCellBorderSide:et,getMergeOwner:oe,isSameMergeInternal:xe,getRowOutlines:fo,getColumnOutlines:mo,addRowGroup:Gl,addColumnGroup:Qn,removeOutline:Io,clearRowGroups:Ao,clearColumnGroups:ql,clearAllOutlines:bl,setOutlineCollapsed:Yl,toggleOutline:$r,getOutlineLevel:bt,getOutlineGutterSize:vt,getRowOutlineLevel:p,getColumnOutlineLevel:N,isRowCollapsed:q,isColumnCollapsed:re,isRowVisible:Se,isColumnVisible:Te,isColHidden:pe,getColWidth:F,adjustOutlinesForInsertRows:zr,adjustOutlinesForDeleteRows:jl,adjustOutlinesForInsertCols:jo,adjustOutlinesForDeleteCols:_r,syncOutlines:yl,viewSize:Jt,findHighlight:(s,f)=>null,autoFillState:Y,applyAutoFill:ee,conditionalFormats:G,resolveConditionalFormat:bo,addConditionalFormatRule:Bt,updateConditionalFormatRule:xt,removeConditionalFormatRule:en,moveConditionalFormatRule:kl,clearConditionalFormats:Ql,invalidateConditionalFormatCache:Jl,dataValidations:fe,getDataValidationRules:tn,getDataValidationRule:Wn,hasDataValidation:yo,getListValidation:En,getValidationDropdown:er,getValidationInputMessage:tr,validateCell:al,validateCells:nr,createDataValidation:ar,updateDataValidation:Kr,removeDataValidation:Gr,clearDataValidation:qr,getDataValidationsInRange:Yr,applyDataValidationsToRange:jr,invalidateDataValidationCache:Lt,isValidationAlertOpen:Ml,confirmInvalidValue:Rl,notes:ge,hasNote:or,getNote:El,setCellNote:lr,updateCellNote:rr,deleteCellNote:Wr,gcNotes:Ur,getNotesInRange:Pr};return Sl=()=>{var s;return(s=w.saveUndo)==null?void 0:s.call(w)},Qt=(s,f)=>{var b;return(b=w.clampScroll)==null?void 0:b.call(w,s,f)},w}function Wp(e,l){const n=t.ref([]),o=t.ref([]);function a(k){return Lp(k)}function i(){return l.saveSheet(),{sheets:l.sheets.value.map(k=>({id:k.id,name:k.name,cells:a(k.cells),styles:[...k.styles],borders:k.borders?[...k.borders]:[{}],merges:k.merges?{...k.merges}:{},selection:k.selection?{...k.selection}:null,activeCell:k.activeCell?{...k.activeCell}:{col:0,row:0},scrollX:k.scrollX,scrollY:k.scrollY,colWidths:[...k.colWidths],rowHeights:[...k.rowHeights],colCount:k.colCount,rowCount:k.rowCount,freeze:{...k.freeze},filter:k.filter?JSON.parse(JSON.stringify(k.filter)):null,conditionalFormats:k.conditionalFormats?k.conditionalFormats.map(q=>({...q,ranges:q.ranges.map(re=>({...re}))})):[],dataValidations:k.dataValidations?k.dataValidations.map(q=>({...q,ranges:(q.ranges??[]).map(re=>({...re}))})):[],rowOutlines:k.rowOutlines?k.rowOutlines.map(q=>({...q})):[],columnOutlines:k.columnOutlines?k.columnOutlines.map(q=>({...q})):[],notes:k.notes?Object.fromEntries(Object.entries(k.notes).map(([q,re])=>[q,{...re}])):{}})),styles:[...e.styles],activeSheetIndex:l.activeSheetIndex.value}}function r(k){const q=l.sheets.value;l.sheets.value=k.sheets.map((re,Se)=>{var pe;const Te=((pe=q[Se])==null?void 0:pe.freeze)??{rows:0,cols:0};return{...re,cells:a(re.cells),styles:[...re.styles],borders:re.borders?[...re.borders]:[{}],freeze:{rows:Te.rows,cols:Te.cols}}}),l.loadSheet(Math.max(0,Math.min(k.activeSheetIndex,l.sheets.value.length-1))),e.formulaDeps.rebuild(e.cells,e.colCount,e.rowCount)}function d(){const k=i(),q=n.value[n.value.length-1];q&&JSON.stringify(q)===JSON.stringify(k)||(n.value.push(k),o.value=[],n.value.length>50&&n.value.shift())}e.saveUndo=d;function c(){var k,q,re;n.value.length&&(o.value.push(i()),r(n.value.pop()),(k=e.invalidateConditionalFormatCache)==null||k.call(e),(q=e.invalidateDataValidationCache)==null||q.call(e),(re=e.scheduleRender)==null||re.call(e),t.nextTick(()=>{var Se;return(Se=e.emitModelData)==null?void 0:Se.call(e)}))}function C(){var k,q,re;o.value.length&&(n.value.push(i()),r(o.value.pop()),(k=e.invalidateConditionalFormatCache)==null||k.call(e),(q=e.invalidateDataValidationCache)==null||q.call(e),(re=e.scheduleRender)==null||re.call(e),t.nextTick(()=>{var Se;return(Se=e.emitModelData)==null?void 0:Se.call(e)}))}const h=t.computed(()=>n.value.length>0),S=t.computed(()=>o.value.length>0),m=t.computed(()=>!!e.selection.value),M=t.ref(null);function E(){var re;const k=e.selection.value;if(!k)return;const q={};for(let Se=k.startCol;Se<=k.endCol;Se++)for(let Te=k.startRow;Te<=k.endRow;Te++)q[`${Se-k.startCol},${Te-k.startRow}`]=((re=e.cells[e.cellKey(Se,Te)])==null?void 0:re.styleId)??0;M.value={styles:q}}function B(){var re,Se,Te;const k=M.value,q=e.selection.value;if(!(!k||!q)){d();for(let pe=q.startCol;pe<=q.endCol;pe++)for(let F=q.startRow;F<=q.endRow;F++){const p=e.findMerge(pe,F);if(p&&(pe!==p.range.startCol||F!==p.range.startRow))continue;const N=k.styles[`${pe-q.startCol},${F-q.startRow}`]??0,bt=e.cellKey(pe,F),vt=((re=e.cells[bt])==null?void 0:re.value)??"";if(vt===""&&N===0)e.delCell(bt);else{const Kt={value:vt};N>0&&(Kt.styleId=N),e.cells[bt]=Kt}}M.value=null,(Se=e.scheduleRender)==null||Se.call(e),(Te=e.emitModelData)==null||Te.call(e)}}function G(){var q,re,Se;const k=e.selection.value;if(k){d();for(let Te=k.startCol;Te<=k.endCol;Te++)for(let pe=k.startRow;pe<=k.endRow;pe++){const F=e.findMerge(Te,pe);if(F&&(Te!==F.range.startCol||pe!==F.range.startRow))continue;const p=e.cellKey(Te,pe),N=((q=e.cells[p])==null?void 0:q.value)??"";N===""?e.delCell(p):e.cells[p]={value:N}}(re=e.scheduleRender)==null||re.call(e),(Se=e.emitModelData)==null||Se.call(e)}}const te=t.computed(()=>Oi.map(k=>({...k,label:k.value===""?g(e.locale.value,"fontDefault"):k.label}))),ge=t.computed(()=>Ii.map(k=>({...k,label:String(k.value)}))),fe="\0",Ie=t.computed(()=>{const k=e.selection.value;if(!k)return"";let q,re=!1;for(let Se=k.startCol;Se<=k.endCol&&!re;Se++)for(let Te=k.startRow;Te<=k.endRow&&!re;Te++){const pe=e.findMerge(Se,Te);if(pe&&(Se!==pe.range.startCol||Te!==pe.range.startRow))continue;const F=e.resolveStyle(e.cells[e.cellKey(Se,Te)]),p=typeof(F==null?void 0:F.fontFamily)=="string"?F.fontFamily:"";q===void 0?q=p:p!==q&&(re=!0)}return re?fe:q??""}),me=t.computed(()=>{const k=e.selection.value;if(!k)return ao;let q,re=!1;for(let Se=k.startCol;Se<=k.endCol&&!re;Se++)for(let Te=k.startRow;Te<=k.endRow&&!re;Te++){const pe=e.findMerge(Se,Te);if(pe&&(Se!==pe.range.startCol||Te!==pe.range.startRow))continue;const F=e.cellFontSize(Se,Te);q===void 0?q=F:F!==q&&(re=!0)}return re?0:q??ao});function Ee(k,q){var Se,Te,pe;const re=e.selection.value;if(re){d();for(let F=re.startCol;F<=re.endCol;F++)for(let p=re.startRow;p<=re.endRow;p++){const N=e.findMerge(F,p);if(N&&(F!==N.range.startCol||p!==N.range.startRow))continue;const bt=e.cellKey(F,p),vt=((Se=e.cells[bt])==null?void 0:Se.value)??"";let Nt={...e.resolveStyle(e.cells[bt])??{}};if(q===""||q===null||q===void 0||q===0){const{[k]:mo,...Xt}=Nt;Nt=Xt}else Nt[k]=q;const fo=Object.keys(Nt).length?e.registerStyle(Nt):0;if(vt===""&&fo===0)e.delCell(bt);else{const mo={value:vt};fo>0&&(mo.styleId=fo),e.cells[bt]=mo}}(Te=e.scheduleRender)==null||Te.call(e),(pe=e.emitModelData)==null||pe.call(e)}}function Ae(k){Ee("fontFamily",k===""?"":k)}const ce=t.ref(!1),ae=t.ref(!1),qe=t.ref(!1),ut=t.ref(!1),J=t.ref(!1);function O(k){Ee("fontSize",k),ce.value=!1}const L=t.computed(()=>Wi.map(k=>({label:g(e.locale.value,k.labelKey),value:k.value,icon:k.icon}))),le=t.computed(()=>Ui.map(k=>({label:g(e.locale.value,k.labelKey),value:k.value,icon:k.icon}))),$e=t.computed(()=>{const k=e.selection.value;if(!k)return"left";const q=e.resolveStyle(e.cells[e.cellKey(k.startCol,k.startRow)]),re=typeof(q==null?void 0:q.textAlign)=="string"?q.textAlign:"";return re==="center"||re==="right"?re:"left"}),et=t.computed(()=>{const k=e.selection.value;if(!k)return"top";const q=e.resolveStyle(e.cells[e.cellKey(k.startCol,k.startRow)]),re=typeof(q==null?void 0:q.verticalAlign)=="string"?q.verticalAlign:"";return re==="middle"||re==="bottom"?re:"top"}),oe=t.computed(()=>{const k=e.selection.value;if(!k)return!1;const q=e.resolveStyle(e.cells[e.cellKey(k.startCol,k.startRow)]);return(q==null?void 0:q.wrap)==="wrap"});function xe(k){Ee("textAlign",k)}function se(k){Ee("verticalAlign",k)}function de(){if(!e.selection.value)return;const q=oe.value;Ee("wrap",q?void 0:"wrap")}const we=t.ref(""),Re=ce;t.watch(me,k=>{we.value=k===0?"":String(k)},{immediate:!0});function Ke(k){const q=k.replace(/[^\d]/g,"");we.value=q;const re=parseInt(q,10);!isNaN(re)&&re>=5&&re<=72&&re!==me.value&&Ee("fontSize",re)}function We(){const k=we.value.trim();if(!k){we.value=me.value===0?"":String(me.value);return}let q=parseInt(k,10);isNaN(q)?q=me.value===0?ao:me.value:q=Math.max(5,Math.min(72,q)),we.value=String(q),q!==me.value&&Ee("fontSize",q)}function rt(k){k.key==="Enter"&&k.target.blur()}function je(k){k&&k.preventDefault(),Re.value=!Re.value,Re.value&&(qe&&(qe.value=!1),ae&&(ae.value=!1),ut.value=!1,J.value=!1)}function A(){const k=me.value===0?ao:me.value,q=Math.min(72,k+1);Ee("fontSize",q),we.value=String(q),Re.value=!1}function K(){const k=me.value===0?ao:me.value,q=Math.max(5,k-1);Ee("fontSize",q),we.value=String(q),Re.value=!1}function $(k){const q=e.selection.value;if(!q)return!1;let re,Se=!1;for(let Te=q.startCol;Te<=q.endCol&&!Se;Te++)for(let pe=q.startRow;pe<=q.endRow&&!Se;pe++){const F=e.findMerge(Te,pe);if(F&&(Te!==F.range.startCol||pe!==F.range.startRow))continue;const p=e.resolveStyle(e.cells[e.cellKey(Te,pe)]),N=!!(p!=null&&p[k]);re===void 0?re=N:N!==re&&(Se=!0)}return!Se&&re===!0}const V=t.computed(()=>$("fontWeight")),x=t.computed(()=>$("fontStyle")),H=t.computed(()=>$("underline")),z=t.computed(()=>$("strikethrough"));function Y(){Ee("fontWeight",V.value?"":"bold")}function ve(){Ee("fontStyle",x.value?"":"italic")}function ze(){Ee("underline",H.value?"":"underline")}function it(){Ee("strikethrough",z.value?"":"line-through")}const Fe=t.ref(""),v=t.ref(""),Z=ut,lt=J;function wt(){Z.value=!Z.value,lt.value=!1,ae&&(ae.value=!1),qe&&(qe.value=!1)}function ft(){lt.value=!lt.value,Z.value=!1,ae&&(ae.value=!1),qe&&(qe.value=!1)}function At(k){ae&&(ae.value=k),k&&(Z.value=!1,lt.value=!1,qe&&(qe.value=!1))}function Ft(k){Fe.value=k,Ee("color",k===""?"":k)}function Vt(k){v.value=k,Ee("backgroundColor",k===""?"":k)}function wn(){Ee("color",Fe.value===""?"":Fe.value)}function an(){Ee("backgroundColor",v.value===""?"":v.value)}const sn=t.computed(()=>{const k=e.selection.value;if(!k)return"";let q,re=!1;for(let Se=k.startCol;Se<=k.endCol&&!re;Se++)for(let Te=k.startRow;Te<=k.endRow&&!re;Te++){const pe=e.findMerge(Se,Te);if(pe&&(Se!==pe.range.startCol||Te!==pe.range.startRow))continue;const F=e.resolveStyle(e.cells[e.cellKey(Se,Te)]),p=typeof(F==null?void 0:F.color)=="string"?F.color:"";q===void 0?q=p:p!==q&&(re=!0)}return re?"":q??""}),mn=t.computed(()=>{const k=e.selection.value;if(!k)return"";let q,re=!1;for(let Se=k.startCol;Se<=k.endCol&&!re;Se++)for(let Te=k.startRow;Te<=k.endRow&&!re;Te++){const pe=e.findMerge(Se,Te);if(pe&&(Se!==pe.range.startCol||Te!==pe.range.startRow))continue;const F=e.resolveStyle(e.cells[e.cellKey(Se,Te)]),p=typeof(F==null?void 0:F.backgroundColor)=="string"?F.backgroundColor:"";q===void 0?q=p:p!==q&&(re=!0)}return re?"":q??""}),Dt=t.computed(()=>pa(e.locale.value)),Jt=t.ref(!1),Qt=t.computed(()=>{const k=e.selection.value;if(!k)return so;let q,re=!1;for(let Se=k.startCol;Se<=k.endCol&&!re;Se++)for(let Te=k.startRow;Te<=k.endRow&&!re;Te++){const pe=e.findMerge(Se,Te);if(pe&&(Se!==pe.range.startCol||Te!==pe.range.startRow))continue;const F=e.resolveStyle(e.cells[e.cellKey(Se,Te)]),p=(F==null?void 0:F.numberFormatCategory)==="custom"?io:typeof(F==null?void 0:F.numberFormat)=="string"?F.numberFormat:"";q===void 0?q=p:p!==q&&(re=!0)}return re?jn:q??so});function $n(k){if((k==null?void 0:k.numberFormatCategory)==="custom")return io;const q=typeof(k==null?void 0:k.numberFormat)=="string"?k.numberFormat:"";return ma(q,e.locale.value)}const Zt=t.computed(()=>{const k=Qt.value;if(k!==jn)return k===io?io:ma(k,e.locale.value);const q=e.selection.value;if(!q)return so;let re,Se=!1;for(let Te=q.startCol;Te<=q.endCol&&!Se;Te++)for(let pe=q.startRow;pe<=q.endRow&&!Se;pe++){const F=e.findMerge(Te,pe);if(F&&(Te!==F.range.startCol||pe!==F.range.startRow))continue;const p=$n(e.resolveStyle(e.cells[e.cellKey(Te,pe)]));re===void 0?re=p:p!==re&&(Se=!0)}return Se?jn:re??so});function Vn(k){Ee("numberFormat",k),U()}function U(){const k=e.selection.value;if(k)for(let q=k.startCol;q<=k.endCol;q++)for(let re=k.startRow;re<=k.endRow;re++){const Se=e.findMerge(q,re);if(Se&&(q!==Se.range.startCol||re!==Se.range.startRow))continue;const Te=e.cellKey(q,re),pe=e.cells[Te],F=e.resolveStyle(pe);if((F==null?void 0:F.numberFormatCategory)!=="custom")continue;const{numberFormatCategory:p,...N}=F,bt=Object.keys(N).length?e.registerStyle(N):0,vt=(pe==null?void 0:pe.value)??"";if(vt===""&&bt===0)e.delCell(Te);else{const Kt={value:vt};bt>0&&(Kt.styleId=bt),e.cells[Te]=Kt}}}function W(k){if(k===io){Jt.value=!0;return}Vn(k)}function X(){Jt.value=!0}function Ce(){const k=e.selection.value;if(!k)return[];const q=[];for(let re=k.startCol;re<=k.endCol;re++)for(let Se=k.startRow;Se<=k.endRow;Se++){const Te=e.findMerge(re,Se);if(Te&&(re!==Te.range.startCol||Se!==Te.range.startRow))continue;const pe=e.cellKey(re,Se),F=e.cells[pe],p=e.resolveStyle(F),N=typeof(p==null?void 0:p.numberFormat)=="string"?p.numberFormat:so,bt=(F==null?void 0:F.value)??"",vt=bt.startsWith("=")?Oa(re,Se,e.cells,e.colCount,e.rowCount):bt;fa(N,vt)&&q.push({key:pe,nf:N,decimals:ss(N,vt)})}return q}const Ne=t.computed(()=>Ce().some(k=>k.decimals<yr)),Ve=t.computed(()=>Ce().some(k=>k.decimals>Cr));function He(k,q,re){var p;const Se=((p=e.cells[k])==null?void 0:p.value)??"",pe={...e.resolveStyle(e.cells[k])??{}};q===""?(delete pe.numberFormat,delete pe.numberFormatCategory):(pe.numberFormat=q,re==="custom"&&(pe.numberFormatCategory="custom"));const F=Object.keys(pe).length?e.registerStyle(pe):0;if(Se===""&&F===0)e.delCell(k);else{const N={value:Se};F>0&&(N.styleId=F),e.cells[k]=N}}function Me(k){var Se,Te;const q=Ce(),re=[];for(const pe of q){const F=pe.decimals+k;if(F<Cr||F>yr)continue;const p=ds(pe.nf,F);p==null||p===pe.nf||re.push({key:pe.key,code:p,category:xn(pe.nf)?"custom":void 0})}if(re.length){d();for(const pe of re)He(pe.key,pe.code,pe.category);(Se=e.scheduleRender)==null||Se.call(e),(Te=e.emitModelData)==null||Te.call(e)}}function Le(){Me(1)}function be(){Me(-1)}return{undoStack:n,redoStack:o,cloneCells:a,takeSnap:i,restoreSnap:r,saveUndo:d,undo:c,redo:C,canUndo:h,canRedo:S,hasSelection:m,paintFmt:M,onPaintFormat:E,applyPaintFormat:B,clearFormat:G,fontFamilyOptions:te,fontSizeOptions:ge,FONT_FAMILY_MIXED:fe,selFontFamily:Ie,selFontSize:me,applyStyleToSelection:Ee,onFontFamilyChange:Ae,onFontSizeChange:O,hAlignOptions:L,vAlignOptions:le,selHAlign:$e,selVAlign:et,selWrap:oe,onHAlignChange:xe,onVAlignChange:se,onWrapToggle:de,fontSizeInput:we,fontSizeMenuOpen:Re,onFontSizeInput:Ke,onFontSizeBlur:We,onFontSizeKeydown:rt,toggleFontSizeMenu:je,onFontSizeStepUp:A,onFontSizeStepDown:K,selFontWeight:V,selFontStyle:x,selUnderline:H,selStrikethrough:z,toggleFontWeight:Y,toggleFontStyle:ve,toggleUnderline:ze,toggleStrikethrough:it,cachedTextColor:Fe,cachedFillColor:v,textColorMenuOpen:Z,fillColorMenuOpen:lt,_toggleTextColorMenu:wt,_toggleFillColorMenu:ft,onBorderMenuToggle:At,onTextColorChange:Ft,onFillColorChange:Vt,applyCachedTextColor:wn,applyCachedFillColor:an,selTextColor:sn,selFillColor:mn,nfOptions:Dt,selNumberFormat:Qt,selNumberFormatDisplay:Zt,NF_NUMBER_FORMAT_MIXED:jn,nfDialogOpen:Jt,onNumberFormatChange:W,openNumberFormatDialog:X,applyNumberFormatCode:Vn,canIncreaseDecimals:Ne,canDecreaseDecimals:Ve,onIncreaseDecimals:Le,onDecreaseDecimals:be}}function Up(e,l){l.borderMenuOpen&&(e.borderMenuOpen=l.borderMenuOpen),l.mergeMenuOpen&&(e.mergeMenuOpen=l.mergeMenuOpen),(()=>{const o=e.borderMenuOpen,a=e.mergeMenuOpen;e.onBorderMenuToggle=i=>{o&&(o.value=i),i&&(e.textColorMenuOpen.value=!1,e.fillColorMenuOpen.value=!1,a&&(a.value=!1))},e.toggleFontSizeMenu=i=>{i&&i.preventDefault(),e.fontSizeMenuOpen.value=!e.fontSizeMenuOpen.value,e.fontSizeMenuOpen.value&&(a&&(a.value=!1),o&&(o.value=!1),e.textColorMenuOpen.value=!1,e.fillColorMenuOpen.value=!1)},e._toggleTextColorMenu=()=>{e.textColorMenuOpen.value=!e.textColorMenuOpen.value,e.fillColorMenuOpen.value=!1,o&&(o.value=!1),a&&(a.value=!1)},e._toggleFillColorMenu=()=>{e.fillColorMenuOpen.value=!e.fillColorMenuOpen.value,e.textColorMenuOpen.value=!1,o&&(o.value=!1),a&&(a.value=!1)}})()}const pi="#444",hi="#aaaaaa";function gi(e){return e==="dark"?hi:pi}const Ir=["top","right","bottom","left"];function hl(e){if(typeof e!="string")return;const l=e.trim();return l===""?void 0:l}function bi(e,l){const n=hl(e),o=hl(l);return n===void 0||o===void 0?n===o:n.toLowerCase()===o.toLowerCase()}function Kl(e){return!!e&&typeof e.width=="number"&&e.width>0}function Pp(e,l){const n={...e},o=hl(l);return o===void 0?delete n.color:n.color=o,n}function Kp(e,l){const n={...e};return l==="solid"?delete n.style:n.style=l,n}function yi(e,l,n,o){const a=e?{...e}:{};a.width=l;const i=hl(n);return i===void 0?delete a.color:a.color=i,o!==void 0&&(o==="solid"?delete a.style:a.style=o),a}function gl(e,l,n){const o=Math.min(l.startCol,l.endCol),a=Math.max(l.startCol,l.endCol),i=Math.min(l.startRow,l.endRow),r=Math.max(l.startRow,l.endRow);if(a<o||r<i||e==="none")return;if(e==="all"){for(let C=o;C<=a;C++)for(let h=i;h<=r;h++)for(const S of Ir)n({col:C,row:h,side:S});return}if(e==="outer"||e==="thickOuter"){for(let C=o;C<=a;C++)n({col:C,row:i,side:"top"}),n({col:C,row:r,side:"bottom"});for(let C=i;C<=r;C++)n({col:o,row:C,side:"left"}),n({col:a,row:C,side:"right"});return}const c={bottom:{side:"bottom",isEdge:(C,h)=>h===r},top:{side:"top",isEdge:(C,h)=>h===i},left:{side:"left",isEdge:(C,h)=>C===o},right:{side:"right",isEdge:(C,h)=>C===a}}[e];if(c)for(let C=o;C<=a;C++)for(let h=i;h<=r;h++)c.isEdge(C,h)&&n({col:C,row:h,side:c.side})}function Gp(e,l,n,o){const a=[];return gl(e,l,({col:i,row:r,side:d})=>{const c=o(i,r,d);if(!Kl(c))return;const C=Pp(c,n);bi(c==null?void 0:c.color,C.color)||a.push({col:i,row:r,side:d,next:C})}),a}function qp(e,l,n,o,a,i){const r={};for(const d of Ir)r[d]=yi(a(e,l,d),n,o,i);return r}function Yp(e,l,n){let o,a=!1,i=!1;if(gl(e,l,({col:r,row:d,side:c})=>{if(i)return;const C=n(r,d,c);if(!Kl(C))return;const h=hl(C.color);if(!a){o=h,a=!0;return}bi(o,h)||(i=!0)}),!(i||!a))return o}function jp(e,l,n,o){const a=[];return gl(e,l,({col:i,row:r,side:d})=>{const c=o(i,r,d);if(!Kl(c))return;const C=Kp(c,n);rn(c.style)!==n&&a.push({col:i,row:r,side:d,next:C})}),a}function Xp(e,l,n){let o,a=!1,i=!1;if(gl(e,l,({col:r,row:d,side:c})=>{if(i)return;const C=n(r,d,c);if(!Kl(C))return;const h=rn(C.style);if(!a){o=h,a=!0;return}h!==o&&(i=!0)}),!(i||!a))return o}function Zp(e,l){const n=t.ref("none"),o=t.ref(""),a=t.ref("solid"),i=t.ref(!1);function r(A,K,$){if(A<0||K<0||A>=e.colCount||K>=e.rowCount)return;const V=e.findMerge(A,K);return e.getCellBorderSide(e.cells[V?V.anchor:e.cellKey(A,K)],$)}function d(A,K,$,V){if(A<0||K<0||A>=e.colCount||K>=e.rowCount)return;const x=e.findMerge(A,K),H=x?x.anchor:e.cellKey(A,K);if(!e.cells[H]){if(!V)return;e.cells[H]={value:""}}_p(e.cells[H],$,V,e.styles,{get:Y=>e.resolveBorder(Y),getId:Y=>e.registerBorder(Y)},e.registerStyle)}function c(A,K,$){var ve;const V=e.findMerge(A,K),x=V?V.anchor:e.cellKey(A,K),H=((ve=e.cells[x])==null?void 0:ve.value)??"",z=e.resolveStyle(e.cells[x])?{...e.resolveStyle(e.cells[x])}:{},Y=e.registerBorder($);if(Y>0?z.borderId=Y:delete z.borderId,delete z.borderTopWidth,delete z.borderBottomWidth,delete z.borderLeftWidth,delete z.borderRightWidth,delete z.borderColor,H===""&&!Object.keys(z).length)e.delCell(x);else{const ze=e.registerStyle(z);e.cells[x]={value:H,styleId:ze||void 0}}}function C(A){var ze,it;n.value=A;const K=e.selection.value;if(!K)return;l.saveUndo();const{startCol:$,startRow:V,endCol:x,endRow:H}=K,z={startCol:$,startRow:V,endCol:x,endRow:H},Y=o.value||void 0,ve=(Fe,v,Z)=>r(Fe,v,Z);if(A==="none")for(let Fe=$;Fe<=x;Fe++)for(let v=V;v<=H;v++){const Z=e.findMerge(Fe,v);Z&&(Fe!==Z.range.startCol||v!==Z.range.startRow)||c(Fe,v,{})}else if(A==="all")for(let Fe=$;Fe<=x;Fe++)for(let v=V;v<=H;v++){const Z=e.findMerge(Fe,v);if(Z&&(Fe!==Z.range.startCol||v!==Z.range.startRow))continue;const lt=qp(Fe,v,1,Y,ve,a.value);for(const wt of Ir)lt[wt]&&(lt[wt].owner=!0);c(Fe,v,lt)}else{const Fe=A==="thickOuter"?2:1;gl(A,z,({col:v,row:Z,side:lt})=>{const wt=ve(v,Z,lt),ft=yi(wt,Fe,Y,a.value);ft.owner=!0,d(v,Z,lt,ft)})}(ze=e.scheduleRender)==null||ze.call(e),(it=e.emitModelData)==null||it.call(e)}function h(A){var H,z;o.value=A;const K=e.selection.value;if(!K)return;const $={startCol:Math.min(K.startCol,K.endCol),startRow:Math.min(K.startRow,K.endRow),endCol:Math.max(K.startCol,K.endCol),endRow:Math.max(K.startRow,K.endRow)},V=n.value==="none"?"all":n.value,x=Gp(V,$,A,(Y,ve,ze)=>r(Y,ve,ze));if(x.length!==0){l.saveUndo();for(const Y of x)Y.next.owner=!0,d(Y.col,Y.row,Y.side,Y.next);(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}}function S(A){var H,z,Y;a.value=A;const K=e.selection.value;if(!K)return;const $={startCol:Math.min(K.startCol,K.endCol),startRow:Math.min(K.startRow,K.endRow),endCol:Math.max(K.startCol,K.endCol),endRow:Math.max(K.startRow,K.endRow)},V=n.value==="none"?"all":n.value,x=jp(V,$,A,(ve,ze,it)=>r(ve,ze,it));if(x.length===0){(H=e.scheduleRender)==null||H.call(e);return}l.saveUndo();for(const ve of x)ve.next.owner=!0,d(ve.col,ve.row,ve.side,ve.next);(z=e.scheduleRender)==null||z.call(e),(Y=e.emitModelData)==null||Y.call(e)}const m=t.computed(()=>{const A=e.selection.value;if(!A)return"";const K=n.value==="none"?"all":n.value;return Yp(K,A,($,V,x)=>r($,V,x))??""}),M=t.computed(()=>{const A=e.selection.value;if(!A)return"";const K=n.value==="none"?"all":n.value;return Xp(K,A,($,V,x)=>r($,V,x))??""});function E(){C(n.value)}function B(A,K,$){const V=$.toLowerCase(),x=e.findMerge(A,K);if(x){if(V==="top"&&K!==x.range.startRow||V==="bottom"&&K!==x.range.endRow||V==="left"&&A!==x.range.startCol||V==="right"&&A!==x.range.endCol)return 0;const z=e.getCellBorderSide(e.cells[x.anchor],V);return(z==null?void 0:z.width)??0}const H=e.getCellBorderSide(e.cells[e.cellKey(A,K)],V);return(H==null?void 0:H.width)??0}const G=t.ref(!1);function te(A){G.value=A,A&&(l.textColorMenuOpen.value=!1,l.fillColorMenuOpen.value=!1,i.value=!1,l.fontSizeMenuOpen.value=!1)}function ge(A,K,$,V){const x=[];for(const H in e.merges){const z=e.merges[H];z&&z.startCol<=$&&z.endCol>=A&&z.startRow<=V&&z.endRow>=K&&x.push(H)}for(const H of x)Reflect.deleteProperty(e.merges,H)}function fe(){var H,z,Y;const A=e.selection.value;if(!A||A.startCol===A.endCol&&A.startRow===A.endRow)return;l.saveUndo(),ge(A.startCol,A.startRow,A.endCol,A.endRow);const K=e.cellKey(A.startCol,A.startRow),$=((H=e.cells[K])==null?void 0:H.value)??"";for(let ve=A.startCol;ve<=A.endCol;ve++)for(let ze=A.startRow;ze<=A.endRow;ze++)ve===A.startCol&&ze===A.startRow||e.clearCellsInRange(ve,ve,ze,ze);const V=e.resolveStyle(e.cells[K])?{...e.resolveStyle(e.cells[K])}:{};V.textAlign="center";const x=e.registerStyle(V);e.cells[K]={value:$,styleId:x||void 0},e.merges[K]={startCol:A.startCol,startRow:A.startRow,endCol:A.endCol,endRow:A.endRow},e.selectCell(A.startCol,A.startRow),(z=e.scheduleRender)==null||z.call(e),(Y=e.emitModelData)==null||Y.call(e)}function Ie(){var K,$,V;const A=e.selection.value;if(!(!A||A.startCol===A.endCol)){l.saveUndo();for(let x=A.startRow;x<=A.endRow;x++){ge(A.startCol,x,A.endCol,x);const H=e.cellKey(A.startCol,x);(K=e.cells[H])==null||K.value;for(let z=A.startCol+1;z<=A.endCol;z++)e.clearCellsInRange(z,z,x,x);e.merges[H]={startCol:A.startCol,startRow:x,endCol:A.endCol,endRow:x}}e.selectRange(A.startCol,A.startRow,A.endCol,A.endRow),($=e.scheduleRender)==null||$.call(e),(V=e.emitModelData)==null||V.call(e)}}function me(){var $,V,x;const A=e.selection.value;if(!A||A.startCol===A.endCol&&A.startRow===A.endRow)return;l.saveUndo(),ge(A.startCol,A.startRow,A.endCol,A.endRow);const K=e.cellKey(A.startCol,A.startRow);($=e.cells[K])==null||$.value;for(let H=A.startCol;H<=A.endCol;H++)for(let z=A.startRow;z<=A.endRow;z++)H===A.startCol&&z===A.startRow||e.clearCellsInRange(H,H,z,z);e.merges[K]={startCol:A.startCol,startRow:A.startRow,endCol:A.endCol,endRow:A.endRow},e.selectCell(A.startCol,A.startRow),(V=e.scheduleRender)==null||V.call(e),(x=e.emitModelData)==null||x.call(e)}function Ee(){var K,$;const A=e.selection.value;A&&(l.saveUndo(),ge(A.startCol,A.startRow,A.endCol,A.endRow),(K=e.scheduleRender)==null||K.call(e),($=e.emitModelData)==null||$.call(e))}function Ae(){const A=e.selection.value;if(!A)return;const K=e.findMerge(A.startCol,A.startRow);K&&A.startCol===K.range.startCol&&A.startRow===K.range.startRow&&A.endCol===K.range.endCol&&A.endRow===K.range.endRow?Ee():fe()}function ce(A){switch(A){case"mergeCenter":fe();break;case"mergeAcross":Ie();break;case"mergeCells":me();break;case"unmergeCells":Ee();break}}let ae=null,qe=[],ut=[];function J(A,K,$,V){ut=[];const x={startCol:A,endCol:K,startRow:$,endRow:V};for(const{rule:H,range:z}of e.getDataValidationsInRange(x))ut.push({...H,ranges:[{...z}]})}function O(A,K,$,V){qe=[];for(let x=$;x<=V;x++){const H=[];for(let z=A;z<=K;z++){const Y=e.cells[e.cellKey(z,x)];H.push((Y==null?void 0:Y.styleId)??0)}qe.push(H)}}function L(A,K,$,V){const x=e.cellKey(A,K);if(Mo(),$===""||$==null){e.formulaDeps.clear(x),V&&V>0?e.cells[x]={value:"",styleId:V}:e.delCell(x),e.formulaDeps.markDirty(x);return}e.cells[x]={value:$,styleId:V&&V>0?V:void 0},$.startsWith("=")?e.formulaDeps.set(x,Il($.slice(1),e.colCount,e.rowCount)):e.formulaDeps.clear(x),e.formulaDeps.markDirty(x)}function le(){const A=e.selection.value;if(!A)return;ae={...A},O(A.startCol,A.endCol,A.startRow,A.endRow),J(A.startCol,A.endCol,A.startRow,A.endRow);const K=[];for(let $=A.startRow;$<=A.endRow;$++){const V=[];for(let x=A.startCol;x<=A.endCol;x++)V.push(e.getCellRaw(x,$));K.push(V.join(" "))}mr(K.join(`
|
|
4
4
|
`))}function $e(){const A=e.selection.value;if(A){if(A.startCol===0&&A.endCol===e.colCount-1){ae={...A},O(0,e.colCount-1,A.startRow,A.endRow),J(0,e.colCount-1,A.startRow,A.endRow);const K=[];for(let $=A.startRow;$<=A.endRow;$++){const V=[];for(let x=0;x<e.colCount;x++)V.push(e.getCellRaw(x,$));K.push(V.join(" "))}mr(K.join(`
|
|
5
5
|
`))}else if(A.startRow===0&&A.endRow===e.rowCount-1){ae={...A},O(A.startCol,A.endCol,0,e.rowCount-1),J(A.startCol,A.endCol,0,e.rowCount-1);const K=[];for(let $=0;$<e.rowCount;$++){const V=[];for(let x=A.startCol;x<=A.endCol;x++)V.push(e.getCellRaw(x,$));K.push(V.join(" "))}mr(K.join(`
|
|
6
|
-
`))}}}async function et(){var Fe;let A;try{A=await navigator.clipboard.readText()}catch{return}if(!A&&A!=="")return;const K=A.split(/\r?\n/),$=e.activeCell.value,V=ae,x=V&&qe.length>0,H=K.map(v=>v.split(" ").length),z=H.length?Math.max(...H):0,Y=$.col+z-1,ve=$.row+K.length-1;Y>=0&&ve>=0&&e.ensureCapacity(Y,ve);const ze=[];for(let v=0;v<K.length;v++){const Z=K[v].split(" ");for(let lt=0;lt<Z.length;lt++){const wt=$.col+lt,ft=$.row+v;let At=Z[lt];At.startsWith("=")&&V&&(At=Al(At,wt-(V.startCol+lt),ft-(V.startRow+v),e.colCount,e.rowCount,pt));const Ft=x&&v<qe.length&<<(((Fe=qe[v])==null?void 0:Fe.length)??0)?qe[v][lt]??null:null;ze.push({c:wt,r:ft,val:At,styleId:Ft})}}const it=e.validateCells(ze.map(v=>({col:v.c,row:v.r,value:v.val})));if(!(!it.valid&&await e.confirmInvalidValue(it,$.col,$.row)!=="continue")){for(const v of ze)v.styleId!==null?L(v.c,v.r,v.val,v.styleId):e.setCellValue(v.c,v.r,v.val);if(V&&ut.length>0){const v=$.col-V.startCol,Z=$.row-V.startRow,lt={startCol:$.col,endCol:$.col+z-1,startRow:$.row,endRow:$.row+K.length-1},wt=ut.map(ft=>({...ft,ranges:ft.ranges.map(At=>Vp(At,v,Z))}));e.applyDataValidationsToRange(wt,lt,{silent:!0}),e.invalidateDataValidationCache()}}}function oe(){var A;if(l.saveUndo(),le(),e.selection.value){const K=e.selection.value;e.clearCellsInRange(K.startCol,K.endCol,K.startRow,K.endRow),(A=e.scheduleRender)==null||A.call(e)}}function xe(){var A;if(e.selection.value){const K=e.selection.value;e.clearCellsInRange(K.startCol,K.endCol,K.startRow,K.endRow),(A=e.scheduleRender)==null||A.call(e)}}function se(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=SUM(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=SUM(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=SUM(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=SUM(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}function de(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=AVERAGE(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=AVERAGE(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=AVERAGE(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=AVERAGE(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}function we(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=COUNT(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=COUNT(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=COUNT(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=COUNT(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}const Re=t.ref(!1);function Ke(A){Re.value=A,A&&(l.textColorMenuOpen.value=!1,l.fillColorMenuOpen.value=!1,i.value=!1,l.fontSizeMenuOpen.value=!1,G.value=!1)}function We(){se(),Re.value=!1}function rt(){de(),Re.value=!1}function je(){we(),Re.value=!1}return{cachedBorder:n,cachedBorderColor:o,cachedBorderLineStyle:a,selBorderColor:m,selBorderLineStyle:M,borderMenuOpen:i,onBorderChange:C,onBorderColorChange:h,onBorderLineStyleChange:S,setCellBorderSide:d,applyBorderToCell:c,applyCachedBorder:E,cellBorderWidth:B,mergeMenuOpen:G,onMergeMenuToggle:te,removeOverlappingMerges:ge,mergeAndCenter:fe,mergeAcross:Ie,mergeCells:me,unmergeCells:Ee,onApplyMerge:Ae,onMergeChange:ce,copySourceRange:null,copySourceStyles:[],captureStyles:O,captureDataValidations:J,setCellWithStyle:L,copyToClipboard:le,copyRowCol:$e,pasteFromClipboard:et,cutSelected:oe,clearSelected:xe,sumSelected:se,avgSelected:de,countSelected:we,calcMenuOpen:Re,onCalcMenuToggle:Ke,onCalcSum:We,onCalcAvg:rt,onCalcCount:je}}function Jp(e,l,n,o){const a={},i=o(l),r=o(n);return i!=null&&(a.width=`${i}px`),r!=null&&(a.height=`${r}px`),a["--sp-formula-bar-bg"]=e.formulaBarBg,a["--sp-formula-bar-border"]=e.formulaBarBorder,a["--sp-formula-bar-label-color"]=e.formulaBarLabelText,a["--sp-formula-bar-label-bg"]=e.formulaBarLabelBg,a["--sp-formula-bar-label-border"]=e.formulaBarLabelBorder,a["--sp-formula-bar-input-bg"]=e.formulaBarInputBg,a["--sp-formula-bar-input-border"]=e.formulaBarInputBorder,a["--sp-formula-bar-input-color"]=e.formulaBarInputText,a["--sp-formula-bar-input-focus-border"]=e.formulaBarInputFocusBorder,a["--sp-formula-bar-input-focus-shadow"]=e.formulaBarInputFocusShadow,a["--sp-wrapper-bg"]=e.wrapperBg,a["--sp-cell-editor-border"]=e.cellEditorBorder,a["--sp-cell-editor-color"]=e.cellEditorText,a["--sp-cell-editor-bg"]=e.cellEditorBg,a["--sp-cell-editor-shadow"]=e.cellEditorShadow,a["--sp-tab-bar-bg"]=e.tabBarBg,a["--sp-tab-bar-border"]=e.tabBarBorder,a["--sp-tab-active-bg"]=e.tabActiveBg,a["--sp-tab-active-color"]=e.tabActiveText,a["--sp-tab-active-border"]=e.tabActiveBorder,a["--sp-tab-inactive-bg"]=e.tabInactiveBg,a["--sp-tab-inactive-color"]=e.tabInactiveText,a["--sp-tab-inactive-border"]=e.tabInactiveBorder,a["--sp-tab-hover-bg"]=e.tabHoverBg,a["--sp-tab-add-btn-color"]=e.tabAddBtnColor,a["--sp-tab-add-btn-hover-bg"]=e.tabAddBtnHoverBg,a["--sp-tab-scroll-btn-color"]=e.tabScrollBtnColor,a["--sp-tab-scroll-btn-hover-bg"]=e.tabScrollBtnHoverBg,a["--sp-scroll-thumb"]=e.scrollbarThumb,a["--sp-scroll-thumb-hover"]=e.scrollbarThumbHover,a["--sp-scroll-btn-bg"]=e.scrollBtnBg,a["--sp-scroll-btn-color"]=e.scrollBtnColor,a["--sp-scroll-btn-hover-bg"]=e.scrollBtnHoverBg,a["--sp-scroll-btn-active-bg"]=e.scrollBtnActiveBg,a["--sp-scroll-track-bg"]=e.scrollTrackBg,a["--sp-toolbar-bg"]=e.toolbarBg,a["--sp-toolbar-border"]=e.toolbarBorder,a["--sp-toolbar-btn-color"]=e.toolbarBtnColor,a["--sp-toolbar-btn-hover-bg"]=e.toolbarBtnHoverBg,a["--sp-toolbar-btn-disabled-color"]=e.toolbarBtnDisabledColor,a["--sp-toolbar-btn-active-color"]=e.toolbarBtnActiveColor,a["--sp-toolbar-text-secondary"]=e.toolbarTextSecondary,a["--sp-toolbar-text-muted"]=e.toolbarTextMuted,a["--sp-toolbar-item-active-bg"]=e.toolbarItemActiveBg,a["--sp-border-default"]=e===na?hi:pi,a}function Ci(e){return e==="number"?0:1}function wi(e,l,n){var i;if(e==null||e.trim()==="")return{kind:"blank"};const o=l??"";if(o===Bn||o==="@")return{kind:"text",text:e};if(xn(o)){if(An(e))return{kind:"number",num:Number(e)};const r=Xn(e,n);return r?{kind:"number",num:r.serial}:{kind:"text",text:In(e,o,n)}}const a=co(o);if(a.kind==="date"||a.kind==="duration"){const r=Number(e);return Number.isFinite(r)?{kind:"number",num:r}:{kind:"text",text:In(e,o,n)}}if(a.kind==="number"){const r=Number(e);if(Number.isFinite(r)){const d=((i=a.sections.find(c=>c.hasDigits))==null?void 0:i.scale)??1;return{kind:"number",num:r*d}}return{kind:"text",text:In(e,o,n)}}return{kind:"text",text:In(e,o,n)}}function Qp(e,l,n,o){if(e.kind==="blank"||l.kind==="blank")return e.kind==="blank"&&l.kind==="blank"?0:e.kind==="blank"?1:-1;const a=Ci(e.kind),i=Ci(l.kind);if(a!==i)return n==="asc"?a-i:i-a;let r;return e.kind==="number"?r=(e.num??0)-(l.num??0):r=(e.text??"").localeCompare(l.text??"",o,{numeric:!0}),n==="asc"?r:-r}function e2(e,l,n){const o=e.map((a,i)=>i);return o.sort((a,i)=>{const r=Qp(e[a],e[i],l,n);return r!==0?r:a-i}),o}function t2(e){if(e.length<2||e[0].kind!=="text")return!1;for(let l=1;l<e.length;l++)if(e[l].kind==="number")return!0;return!1}function Ar(e){return e?JSON.parse(JSON.stringify(e)):null}function vi(e,l,n,o){if(!e)return null;const a=n-l+1,i={...e.range};return o?l<=i.endRow&&(l<=i.startRow&&(i.startRow+=a),i.endRow+=a):n<i.startRow?(i.startRow-=a,i.endRow-=a):l<=i.endRow&&(i.endRow-=Math.min(a,i.endRow-l+1),i.endRow<i.startRow&&(i.endRow=i.startRow)),{range:i,columns:e.columns}}function ki(e,l,n,o){if(!e)return null;const a=n-l+1,i={...e.range},r={};if(o){l<=i.endCol&&(l<=i.startCol&&(i.startCol+=a),i.endCol+=a);for(const d in e.columns){const c=Number(d);r[c>=l?c+a:c]=e.columns[d]}}else{n<i.startCol?(i.startCol-=a,i.endCol-=a):l<=i.endCol&&(i.endCol-=Math.min(a,i.endCol-l+1),i.endCol<i.startCol&&(i.endCol=i.startCol));for(const d in e.columns){const c=Number(d);c>=l&&c<=n||(r[c>n?c-a:c]=e.columns[d])}}return{range:i,columns:r}}function Ei(e,l,n,o){if(l==="row"){const a=e.startRow,i=e.endRow;let r,d;if(i<n)r=a,d=i;else if(a>n+o-1)r=a-o,d=i-o;else if(r=a<n?a:n,d=i>n+o-1?i-o:n-1,d<r)return null;return{...e,startRow:r,endRow:d}}else{const a=e.startCol,i=e.endCol;let r,d;if(i<n)r=a,d=i;else if(a>n+o-1)r=a-o,d=i-o;else if(r=a<n?a:n,d=i>n+o-1?i-o:n-1,d<r)return null;return{...e,startCol:r,endCol:d}}}function Ri(e,l,n,o){if(l==="row"){const a=e.startRow,i=e.endRow;return a>=n?{...e,startRow:a+o,endRow:i+o}:i<n?e:{...e,endRow:i+o}}else{const a=e.startCol,i=e.endCol;return a>=n?{...e,startCol:a+o,endCol:i+o}:i<n?e:{...e,endCol:i+o}}}function n2(e,l,n){var a;const o=n-l+1;for(let i=e.conditionalFormats.length-1;i>=0;i--){const r=e.conditionalFormats[i],d=r.ranges.map(c=>Ei(c,"row",l,o)).filter(c=>c!==null);d.length===0?e.conditionalFormats.splice(i,1):r.ranges=d}(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function o2(e,l,n){var a;const o=n-l+1;for(const i of e.conditionalFormats)i.ranges=i.ranges.map(r=>Ri(r,"row",l,o));(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function l2(e,l,n){var a;const o=n-l+1;for(let i=e.conditionalFormats.length-1;i>=0;i--){const r=e.conditionalFormats[i],d=r.ranges.map(c=>Ei(c,"col",l,o)).filter(c=>c!==null);d.length===0?e.conditionalFormats.splice(i,1):r.ranges=d}(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function r2(e,l,n){var a;const o=n-l+1;for(const i of e.conditionalFormats)i.ranges=i.ranges.map(r=>Ri(r,"col",l,o));(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function Mi(e,l,n,o){var a;for(let i=e.dataValidations.length-1;i>=0;i--){const r=e.dataValidations[i],d=(r.ranges??[]).map(c=>xp(c,l,n,o)).filter(c=>c!==null);d.length===0?e.dataValidations.splice(i,1):r.ranges=d}(a=e.invalidateDataValidationCache)==null||a.call(e)}function Si(e,l,n,o){var a;for(const i of e.dataValidations)i.ranges=(i.ranges??[]).map(r=>Tp(r,l,n,o));(a=e.invalidateDataValidationCache)==null||a.call(e)}function a2(e,l,n,o,a){function i(U,W){var Le;const X=W-U+1,Ce=J(U,W),Ne=[],Ve=[];for(const be in e.cells){const tt=be.indexOf(",");if(tt<0)continue;const k=parseInt(be.substring(0,tt),10),q=parseInt(be.substring(tt+1),10);q>=U&&q<=W?Ve.push(be):q>W&&Ne.push({oldKey:be,newKey:e.cellKey(k,q-X),cell:e.cells[be]})}for(const be of Ve)Reflect.deleteProperty(e.cells,be);for(const be of Ne)Reflect.deleteProperty(e.cells,be.oldKey),e.cells[be.newKey]=be.cell;(Le=e.gcNotes)==null||Le.call(e);const He=e.rowHeights.value,Me=new Array(He.length);for(let be=0;be<U;be++)Me[be]=He[be];for(let be=U;be<He.length-X;be++)Me[be]=He[be+X];for(let be=He.length-X;be<He.length;be++)Me[be]=void 0;e.rowHeights.value=Me,ut(Ce),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(vi(e.getFilter(),U,W,!1)),n2(e,U,W),Mi(e,"row",U,X),e.adjustOutlinesForDeleteRows(U,X)}function r(U,W){const X=W-U+1,Ce=e.rowCount,Ne=e.colCount,{lastRow:Ve}=C();Ve>=U&&Ve+X>=Ce&&e.ensureCapacity(Ne-1,Ce-1+X);const He=e.rowCount,Me=L(U,W),Le=[];for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10),Se=parseInt(k.substring(q+1),10);Se>=U&&Le.push({oldKey:k,newKey:e.cellKey(re,Se+X),cell:e.cells[k],oldRow:Se})}Le.sort((k,q)=>q.oldRow-k.oldRow);for(const k of Le)Reflect.deleteProperty(e.cells,k.oldKey),e.cells[k.newKey]=k.cell;for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(q+1),10);re>=U&&re<=W&&Reflect.deleteProperty(e.cells,k)}const be=e.rowHeights.value,tt=new Array(He);for(let k=0;k<U;k++)tt[k]=be[k];for(let k=U;k<=W;k++)tt[k]=void 0;for(let k=U;k<He;k++)tt[k+X]=be[k];e.rowHeights.value=tt,ut(Me),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(vi(e.getFilter(),U,W,!0)),o2(e,U,W),Si(e,"row",U,X),e.adjustOutlinesForInsertRows(U,X)}function d(U,W){const X=W-U+1,Ce=e.colCount,Ne=e.rowCount,{lastCol:Ve}=C();Ve>=U&&Ve+X>=Ce&&e.ensureCapacity(Ce-1+X,Ne-1);const He=e.colCount,Me=le(U,W),Le=[];for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10),Se=parseInt(k.substring(q+1),10);re>=U&&Le.push({oldKey:k,newKey:e.cellKey(re+X,Se),cell:e.cells[k],oldCol:re})}Le.sort((k,q)=>q.oldCol-k.oldCol);for(const k of Le)Reflect.deleteProperty(e.cells,k.oldKey),e.cells[k.newKey]=k.cell;for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10);re>=U&&re<=W&&Reflect.deleteProperty(e.cells,k)}const be=e.colWidths.value,tt=new Array(He);for(let k=0;k<U;k++)tt[k]=be[k];for(let k=U;k<=W;k++)tt[k]=100;for(let k=U;k<He;k++)tt[k+X]=be[k];e.colWidths.value=tt,ut(Me),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(ki(e.getFilter(),U,W,!0)),r2(e,U,W),Si(e,"col",U,X),e.adjustOutlinesForInsertCols(U,X)}function c(U,W){var Le;const X=W-U+1,Ce=O(U,W),Ne=[],Ve=[];for(const be in e.cells){const tt=be.indexOf(",");if(tt<0)continue;const k=parseInt(be.substring(0,tt),10),q=parseInt(be.substring(tt+1),10);k>=U&&k<=W?Ve.push(be):k>W&&Ne.push({oldKey:be,newKey:e.cellKey(k-X,q),cell:e.cells[be]})}for(const be of Ve)Reflect.deleteProperty(e.cells,be);for(const be of Ne)Reflect.deleteProperty(e.cells,be.oldKey),e.cells[be.newKey]=be.cell;(Le=e.gcNotes)==null||Le.call(e);const He=e.colWidths.value,Me=new Array(He.length);for(let be=0;be<U;be++)Me[be]=He[be];for(let be=U;be<He.length-X;be++)Me[be]=He[be+X];for(let be=He.length-X;be<He.length;be++)Me[be]=100;e.colWidths.value=Me,ut(Ce),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(ki(e.getFilter(),U,W,!1)),l2(e,U,W),Mi(e,"col",U,X),e.adjustOutlinesForDeleteCols(U,X)}function C(){let U=-1,W=-1;for(const X in e.cells){const Ce=X.split(",");if(Ce.length===2){const Ne=parseInt(Ce[0],10),Ve=parseInt(Ce[1],10),He=e.cells[X];He&&(He.value!==""||He.styleId!==void 0)&&(Ne>U&&(U=Ne),Ve>W&&(W=Ve))}}for(let X=e.colCount-1;X>=0;X--){const Ce=e.colWidths.value[X];if(Ce!==void 0&&Ce!==100){X>U&&(U=X);break}}for(let X=e.rowCount-1;X>=0;X--)if(e.rowHeights.value[X]!==void 0){X>W&&(W=X);break}return{lastCol:U,lastRow:W}}function h(U,W){const X=e.resolveStyle(e.cells[e.cellKey(U,W)]);return typeof(X==null?void 0:X.numberFormat)=="string"?X.numberFormat:""}function S(U,W,X){for(let Ce=W;Ce<=X;Ce++)if(e.getCellRaw(U,Ce).trim()!=="")return!0;return!1}function m(U){const{startRow:W,endRow:X,startCol:Ce,endCol:Ne}=U;let Ve=Ce,He=Ne;for(;Ve>0&&S(Ve-1,W,X);)Ve--;for(;He<e.colCount-1&&S(He+1,W,X);)He++;return{startRow:W,endRow:X,startCol:Ve,endCol:He}}function M(U){const W=m(U);return W.startCol!==U.startCol||W.endCol!==U.endCol}function E(U,W,X,Ce=U){let Ne,Ve;if(X)Ne=X.startRow,Ve=X.endRow;else{const k=e.selection.value,q=!!k&&k.startRow===k.endRow&&k.startCol===k.endCol;Ne=q||!k?0:k.startRow,Ve=q||!k?e.rowCount-1:k.endRow}let He=-1,Me=-1;for(let k=Ne;k<=Ve;k++){let q=!1;for(let re=U;re<=W;re++)if(e.getCellRaw(re,k).trim()!==""){q=!0;break}q&&(He<0&&(He=k),Me=k)}if(He<0)return null;const Le=[];for(let k=He;k<=Me;k++){const q=e.getCellRaw(Ce,k);Le.push(wi(q,h(Ce,k),e.locale.value))}const be=t2(Le)?He+1:He;let tt=!1;for(let k=He;k<=Me&&!tt;k++)for(let q=U;q<=W;q++){const re=e.cells[e.cellKey(q,k)];if(re&&re.value.startsWith("=")){tt=!0;break}}if(!tt)for(const k in e.merges){const q=e.merges[k];if(q&&q.startCol<=W&&q.endCol>=U&&q.startRow<=Ve&&q.endRow>=Ne){tt=!0;break}}return{firstRow:He,lastRow:Me,sortStart:be,blocked:tt}}function B(U,W){const X=E(U,W);return!!X&&!X.blocked&&X.sortStart<X.lastRow}function G(U,W,X){var Se,Te;const Ce=W??e.selection.value;if(!Ce)return;const Ne=Ce.startCol,Ve=Ce.endCol,He=X??Ne,Me=E(Ne,Ve,{startRow:Ce.startRow,endRow:Ce.endRow},He);if(!Me||Me.blocked||Me.sortStart>=Me.lastRow)return;const Le=Ve-Ne+1,be=Me.lastRow-Me.sortStart+1,tt=[],k=[];for(let pe=Me.sortStart;pe<=Me.lastRow;pe++){const F=new Array(Le);for(let N=Ne;N<=Ve;N++)F[N-Ne]=e.cells[e.cellKey(N,pe)]??null;tt.push(F);const p=e.getCellRaw(He,pe);k.push(wi(p,h(He,pe),e.locale.value))}const q=e2(k,U,e.locale.value);let re=!1;for(let pe=0;pe<be;pe++)if(q[pe]!==pe){re=!0;break}if(re){l.saveUndo();for(let pe=0;pe<be;pe++){const F=tt[q[pe]],p=Me.sortStart+pe;for(let N=Ne;N<=Ve;N++){const bt=e.cellKey(N,p),vt=F[N-Ne],Kt=vt?vt.value:"",Nt=(Se=e.cells[bt])==null?void 0:Se.styleId;Kt!==""||Nt!==void 0?e.cells[bt]={value:Kt,styleId:Nt}:e.delCell(bt)}}Mo();for(let pe=Me.sortStart;pe<=Me.lastRow;pe++)for(let F=Ne;F<=Ve;F++)e.formulaDeps.markDirty(e.cellKey(F,pe));(Te=e.scheduleRender)==null||Te.call(e),H()}}const te=t.ref(!1),ge=t.ref(null);function fe(U){const W=e.selection.value;if(!W||!M(W))return!1;const X=m(W);return ge.value={order:U,originalRange:W,expandedRange:X},te.value=!0,!0}function Ie(U){const W=ge.value;if(!W)return;const{order:X,originalRange:Ce,expandedRange:Ne}=W;te.value=!1,ge.value=null,G(X,U?Ne:Ce,Ce.startCol),Ae.value=X}function me(){te.value=!1,ge.value=null}const Ee=t.ref(!1),Ae=t.ref("asc");function ce(U){Ee.value=U,U&&(l.textColorMenuOpen.value=!1,l.fillColorMenuOpen.value=!1,l.fontSizeMenuOpen.value=!1)}function ae(U){fe(U)||(Ae.value=U,G(U))}function qe(){fe(Ae.value)||G(Ae.value)}function ut(U){Object.keys(e.merges).forEach(W=>Reflect.deleteProperty(e.merges,W));for(const W of U)if(!(W.newRange.startCol>W.newRange.endCol||W.newRange.startRow>W.newRange.endRow)&&(e.merges[W.newAnchorKey]={...W.newRange},W.anchorCell)){const X=W.anchorCell.value,Ce=W.anchorCell.styleId;X===""&&!Ce||(e.cells[W.newAnchorKey]={value:X,styleId:Ce||void 0})}}function J(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const He=e.cells[Ne]?{value:e.cells[Ne].value,styleId:e.cells[Ne].styleId??0}:{value:"",styleId:0},{startCol:Me,endCol:Le}=Ve;let{startRow:be,endRow:tt}=Ve;if(be>W){be-=X,tt-=X,Ce.push({newAnchorKey:e.cellKey(Me,be),newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(tt<U){Ce.push({newAnchorKey:Ne,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(be>=U&&tt<=W||(be>=U&&be<=W&&(be=U),tt>=U&&tt<=W?tt=U-1:tt>W&&(tt-=X),be>tt))continue;const k=Me,q=be,re=e.cellKey(k,q),Te=Ne.split(",").map(Number)[1],pe=Te>=U&&Te<=W||k!==Ve.startCol||q!==Te;Ce.push({newAnchorKey:re,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt},anchorCell:pe?He:void 0})}return Ce}function O(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const He=e.cells[Ne]?{value:e.cells[Ne].value,styleId:e.cells[Ne].styleId??0}:{value:"",styleId:0};let{startCol:Me,endCol:Le}=Ve;const{startRow:be,endRow:tt}=Ve;if(Me>W){Me-=X,Le-=X,Ce.push({newAnchorKey:e.cellKey(Me,be),newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(Le<U){Ce.push({newAnchorKey:Ne,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(Me>=U&&Le<=W||(Me>=U&&Me<=W&&(Me=U),Le>=U&&Le<=W?Le=U-1:Le>W&&(Le-=X),Me>Le))continue;const k=Me,q=be,re=e.cellKey(k,q),Te=Ne.split(",").map(Number)[0],pe=Te>=U&&Te<=W||k!==Te||q!==Ve.startRow;Ce.push({newAnchorKey:re,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt},anchorCell:pe?He:void 0})}return Ce}function L(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const{startCol:He,endCol:Me}=Ve;let{startRow:Le,endRow:be}=Ve;be<U?Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}):Le<U?(be+=X,Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}})):(Le+=X,be+=X,Ce.push({newAnchorKey:e.cellKey(He,Le),newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}))}return Ce}function le(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;let{startCol:He,endCol:Me}=Ve;const{startRow:Le,endRow:be}=Ve;Me<U?Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}):He<U?(Me+=X,Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}})):(He+=X,Me+=X,Ce.push({newAnchorKey:e.cellKey(He,Le),newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}))}return Ce}let $e=0;function et(){return $e++,`s_${$e}`}function oe(U){if(!Array.isArray(U))return[];const W=[];for(const X of U){if(!X||typeof X!="object")continue;const Ce=X;if(!Ce.type||!Array.isArray(Ce.ranges)||Ce.ranges.length===0)continue;const Ne=Ce.ranges.filter(Ve=>!!Ve&&typeof Ve.startCol=="number"&&typeof Ve.startRow=="number"&&typeof Ve.endCol=="number"&&typeof Ve.endRow=="number").map(Ve=>({startCol:Math.min(Ve.startCol,Ve.endCol),endCol:Math.max(Ve.startCol,Ve.endCol),startRow:Math.min(Ve.startRow,Ve.endRow),endRow:Math.max(Ve.startRow,Ve.endRow)}));Ne.length&&W.push({...Ce,id:Ce.id||`dv_${W.length}`,ranges:Ne})}return W}function xe(U,W){const X=Math.max(1,(W==null?void 0:W.colCount)??e.colCount),Ce=Math.max(1,(W==null?void 0:W.rowCount)??e.rowCount),Ne=new Array(X).fill(100),Ve=new Array(Ce).fill(void 0);return{id:et(),name:U,cells:{},merges:{},styles:[{}],borders:[{}],selection:{startCol:0,startRow:0,endCol:0,endRow:0},activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:Ne,rowHeights:Ve,colCount:X,rowCount:Ce,freeze:{rows:0,cols:0},filter:null,conditionalFormats:[],dataValidations:[],rowOutlines:[],columnOutlines:[],notes:{}}}const se=t.ref([xe("Sheet1")]),de=t.ref(0);function we(){const U=se.value[de.value];if(!U)return;U.cells={...e.cells},U.merges={...e.merges},U.selection=e.selection.value?{...e.selection.value}:null,U.activeCell={...e.activeCell.value},U.scrollX=e.scrollX.value,U.scrollY=e.scrollY.value,U.colWidths=[...e.colWidths.value],U.rowHeights=[...e.rowHeights.value],U.styles=[...e.styles],U.borders=[...e.borders],U.colCount=e.colCount,U.rowCount=e.rowCount,U.freeze={rows:e.freeze.rows,cols:e.freeze.cols},U.filter=Ar(e.getFilter()),U.conditionalFormats=[...e.conditionalFormats],U.dataValidations=[...e.dataValidations];const W=Object.entries(e.notes).map(([X,Ce])=>[X,{...Ce}]);U.notes=Object.fromEntries(W),U.rowOutlines=e.getRowOutlines(),U.columnOutlines=e.getColumnOutlines()}function Re(U){var tt,k,q;const W=se.value[U];if(!W)return;Object.keys(e.cells).forEach(re=>e.delCell(re)),Object.assign(e.cells,W.cells),Object.keys(e.merges).forEach(re=>Reflect.deleteProperty(e.merges,re)),W.merges&&Object.assign(e.merges,W.merges),e.selection.value=W.selection?{...W.selection}:null,e.activeCell.value={...W.activeCell};const X=e.activeCell.value,Ce=e.selection.value,Ne=e.findMerge(X.col,X.row);Ne&&Ne.anchor===e.cellKey(X.col,X.row)&&(!Ce||Ce.startCol===X.col&&Ce.startRow===X.row&&Ce.endCol===X.col&&Ce.endRow===X.row)&&e.selectCell(X.col,X.row),e.scrollX.value=W.scrollX,e.scrollY.value=W.scrollY,e.colWidths.value=[...W.colWidths],e.rowHeights.value=[...W.rowHeights];const Ve=Math.max(1,W.colCount??e.colCount),He=Math.max(1,W.rowCount??e.rowCount);if((tt=e.setDims)==null||tt.call(e,Ve,He),e.freeze.rows=Math.max(0,Math.min(W.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(W.freeze.cols,e.colCount)),W.filter){const re=W.filter.range;e.setFilter({range:{startCol:Math.max(0,Math.min(re.startCol,e.colCount-1)),endCol:Math.max(0,Math.min(re.endCol,e.colCount-1)),startRow:Math.max(0,Math.min(re.startRow,e.rowCount-1)),endRow:Math.max(0,Math.min(re.endRow,e.rowCount-1))},columns:{...W.filter.columns}},!0)}else e.setFilter(null,!0);e.syncStyles(W.styles),e.syncBorders(W.borders??[{}]);const Me=W.conditionalFormats?W.conditionalFormats.map(re=>({...re,ranges:re.ranges.map(Se=>({...Se}))})):[];e.conditionalFormats.splice(0,e.conditionalFormats.length,...Me),(k=e.invalidateConditionalFormatCache)==null||k.call(e);const Le=oe(W.dataValidations);e.dataValidations.splice(0,e.dataValidations.length,...Le),(q=e.invalidateDataValidationCache)==null||q.call(e);const be=Xa(W.notes);Object.keys(e.notes).forEach(re=>{e.notes[re]=void 0}),Object.assign(e.notes,be),e.syncOutlines(W.rowOutlines,W.columnOutlines),de.value=U}function Ke(U){U===de.value||U<0||U>=se.value.length||(e.cancelEdit(),we(),Re(U))}function We(U){return l.saveUndo(),e.cancelEdit(),we(),se.value.push(xe(U??`Sheet${se.value.length+1}`)),Re(se.value.length-1),se.value.length-1}function rt(U){return se.value.length<=1||(l.saveUndo(),e.cancelEdit(),se.value.splice(U,1),Re(Math.min(U,se.value.length-1))),de.value}function je(U,W){se.value[U]&&W.trim()&&(l.saveUndo(),se.value[U].name=W.trim())}function A(U){l.saveUndo(),e.cancelEdit(),we();const W=se.value[U];if(!W)return U;let X=W.name;const Ce=X.match(/^(.*?)\s*\((\d+)\)$/);let Ne=Ce?parseInt(Ce[2],10)+1:2;Ce&&(X=Ce[1]);let Ve=`${X} (${Ne})`;const He=new Set(se.value.map(Le=>Le.name));for(;He.has(Ve);)Ne++,Ve=`${X} (${Ne})`;const Me={id:et(),name:Ve,cells:{...W.cells},merges:W.merges?{...W.merges}:{},styles:[...W.styles],borders:W.borders?[...W.borders]:[{}],selection:W.selection?{...W.selection}:null,activeCell:W.activeCell?{...W.activeCell}:{col:0,row:0},scrollX:W.scrollX,scrollY:W.scrollY,colWidths:[...W.colWidths],rowHeights:[...W.rowHeights],colCount:W.colCount,rowCount:W.rowCount,freeze:{...W.freeze},filter:Ar(W.filter),conditionalFormats:W.conditionalFormats?W.conditionalFormats.map(Le=>({...Le})):[],dataValidations:oe(W.dataValidations),rowOutlines:W.rowOutlines?W.rowOutlines.map(Le=>({...Le})):[],columnOutlines:W.columnOutlines?W.columnOutlines.map(Le=>({...Le})):[],notes:Xa(W.notes)};return se.value.splice(U+1,0,Me),Re(U+1),U+1}function K(U,W){var Ve;const X=U+W;if(X<0||X>=se.value.length)return;l.saveUndo();const Ce=de.value,Ne=se.value.splice(U,1)[0];se.value.splice(X,0,Ne),Ce===U?de.value=X:U<Ce&&X>=Ce?de.value=Ce-1:U>Ce&&X<=Ce&&(de.value=Ce+1),(Ve=e.scheduleRender)==null||Ve.call(e)}const $=t.computed(()=>se.value.length);let V="";const x=n;function H(){we();const U=se.value.map(X=>{const Ce={};for(const[Me,Le]of Object.entries(X.cells))Ce[Me]={value:Le.value},Le.styleId&&Le.styleId>0&&(Ce[Me].styleId=Le.styleId),Le.noteId&&(Ce[Me].noteId=Le.noteId);const Ne={name:X.name,cells:Ce};X.styles&&X.styles.length>1&&(Ne.styles=[...X.styles]),X.borders&&X.borders.length>1&&(Ne.borders=[...X.borders]),X.merges&&Object.keys(X.merges).length&&(Ne.merges={...X.merges});const Ve={};for(let Me=0;Me<X.colWidths.length;Me++)X.colWidths[Me]!==100&&(Ve[Me]=X.colWidths[Me]);Object.keys(Ve).length&&(Ne.colWidths=Ve);const He={};for(let Me=0;Me<X.rowHeights.length;Me++){const Le=X.rowHeights[Me];Le!=null&&(He[Me]=Le)}return Object.keys(He).length&&(Ne.rowHeights=He),(X.freeze.rows!==0||X.freeze.cols!==0)&&(Ne.freeze={rows:X.freeze.rows,cols:X.freeze.cols}),X.filter&&(Ne.filter=Ar(X.filter)),X.conditionalFormats&&X.conditionalFormats.length&&(Ne.conditionalFormats=X.conditionalFormats.map(Me=>({...Me}))),X.dataValidations&&X.dataValidations.length&&(Ne.dataValidations=X.dataValidations.map(Me=>({...Me,ranges:Me.ranges.map(Le=>({...Le}))}))),X.notes&&Object.keys(X.notes).length&&(Ne.notes=Object.fromEntries(Object.entries(X.notes).map(([Me,Le])=>[Me,{...Le}]))),X.rowOutlines&&X.rowOutlines.length&&(Ne.rowOutlines=X.rowOutlines.map(Me=>({...Me}))),X.columnOutlines&&X.columnOutlines.length&&(Ne.columnOutlines=X.columnOutlines.map(Me=>({...Me}))),Ne}),W=JSON.stringify(U);W!==V&&(V=W,x.value=U,a&&(a.value=W))}e.emitModelData=H;let z=!1;function Y(){z||(z=!0,Promise.resolve().then(()=>{z=!1,H()}))}const ve=t.computed(()=>e.props.theme==="dark"?na:Ki),ze=t.computed(()=>Jp(ve.value,e.props.width,e.props.height,Do)),it=t.computed(()=>{const U={};for(const[W,X]of Object.entries(ze.value))W.startsWith("--")&&(U[W]=X);return U}),Fe=t.ref(null),v=t.ref(null),Z=t.ref(null),lt=t.ref(null),wt=t.ref(null),ft=t.reactive({w:800,h:600});e.viewSize&&t.watch(ft,U=>{e.viewSize&&(e.viewSize.w=U.w,e.viewSize.h=U.h)},{deep:!0});const At=48,Ft=28,Vt=11,wn=()=>At+e.getOutlineGutterSize("row"),an=()=>Ft+e.getOutlineGutterSize("column"),sn=t.computed(()=>Math.max(0,e.totalWidth.value-Math.max(0,ft.w-wn()-Vt))),mn=t.computed(()=>Math.max(0,e.totalHeight.value-Math.max(0,ft.h-an()-Vt)));function Dt(U,W){const X=Math.max(0,ft.w-wn()-Vt),Ce=Math.max(0,ft.h-an()-Vt),Ne=U??e.scrollX.value,Ve=W??e.scrollY.value,He=40,Me=Math.max(0,e.totalWidth.value-X),Le=Math.max(0,e.totalHeight.value-Ce);if(Ne>=Me-He&&Ne>e.scrollX.value||Ve>=Le-He&&Ve>e.scrollY.value){const be=Math.max(0,Math.ceil((Ne+X)/100)+2),tt=Math.max(0,Math.ceil((Ve+Ce)/24)+2);e.ensureCapacity(be,tt)}e.scrollX.value=Math.max(0,Math.min(Ne,Math.max(0,e.totalWidth.value-X))),e.scrollY.value=Math.max(0,Math.min(Ve,Math.max(0,e.totalHeight.value-Ce)))}e.clampScroll=Dt;function Jt(){var U;return typeof window>"u"?!1:!((U=window.matchMedia)!=null&&U.call(window,"(hover: none) and (pointer: coarse)").matches)}function Qt(U=!1){t.nextTick(()=>{const W=lt.value;if(W){if(!e.editingCell.value&&!Jt()){document.activeElement===W&&W.blur();return}W.focus({preventScroll:!0}),U&&W.select()}})}function $n(){Qt()}function Zt(){var W;const U=e.selection.value;if(U){l.saveUndo();for(let X=U.startRow;X<=U.endRow;X++)e.rowHeights.value[X]=void 0;(W=e.scheduleRender)==null||W.call(e),H()}}function Vn(){var W;const U=e.selection.value;if(U){l.saveUndo();for(let X=U.startCol;X<=U.endCol;X++)e.colWidths.value[X]=100;(W=e.scheduleRender)==null||W.call(e),H()}}return{deleteRows:i,insertRows:r,insertCols:d,deleteCols:c,sortSelectedColumns:G,canSortColumns:B,sortMenuOpen:Ee,cachedSortOrder:Ae,onSortMenuToggle:ce,onSortChange:ae,applyCachedSort:qe,sortConfirmOpen:te,prepareSortConfirmation:fe,confirmSort:Ie,cancelSortConfirmation:me,sheets:se,activeSheetIndex:de,saveSheet:we,loadSheet:Re,switchSheet:Ke,addSheet:We,removeSheet:rt,renameSheet:je,dupSheet:A,moveSheet:K,sheetCount:$,mkSheet:xe,emitModelData:H,scheduleOptEmit:Y,themeColors:ve,outerStyle:ze,toolbarThemeVars:it,wrapperRef:Fe,canvasRef:v,freezeCanvasRef:Z,editInputRef:lt,formulaBarRef:wt,viewSize:ft,maxScrollX:sn,maxScrollY:mn,clampScroll:Dt,canFocusHiddenEditor:Jt,focusEditInput:Qt,onCanvasFocus:$n,resetRowHeight:Zt,resetColWidth:Vn,modelData:x}}function Ni(e,l){let n=-1,o=-1;const a=(r,d)=>{Number.isInteger(r)&&r>=0&&r>n&&(n=r),Number.isInteger(d)&&d>=0&&d>o&&(o=d)},i=r=>{r&&a(Math.max(r.startCol,r.endCol),Math.max(r.startRow,r.endRow))};for(const r of Object.keys(e.cells)){const d=r.indexOf(",");d<0||a(Number(r.slice(0,d)),Number(r.slice(d+1)))}for(const r of Object.values(e.merges??{}))i(r);if(e.colWidths)for(const[r,d]of Object.entries(e.colWidths)){const c=Number(r);Number.isInteger(c)&&c>=0&&d>=30&&a(c,-1)}if(e.rowHeights)for(const[r,d]of Object.entries(e.rowHeights)){const c=Number(r);Number.isInteger(c)&&c>=0&&d!=null&&d>=24&&a(-1,c)}for(const r of e.conditionalFormats??[])for(const d of r.ranges??[])i(d);for(const r of e.dataValidations??[])for(const d of r.ranges??[])i(d);e.filter&&i(e.filter.range);for(const r of e.rowOutlines??[])a(-1,r.end);for(const r of e.columnOutlines??[])a(r.end,-1);return{colCount:Math.max(1,l.colCount,n+1),rowCount:Math.max(1,l.rowCount,o+1)}}function Bi(e){return!!e&&e.width!==void 0&&e.width>0}function Pt(e,l,n,o){const a=Bi(e),i=Bi(l);if(!a&&!i)return;if(a&&!i)return e;if(!a&&i)return l;const r=!!e.owner,d=!!l.owner;if(r&&!d)return e;if(d&&!r)return l;const c=e.width??0,C=l.width??0;return c>C?e:C>c?l:e}function xi(e,l){if(!e||typeof e!="object")return null;const n=e,o=n.columns??{},a=Object.keys(o).map(r=>Number(r)).filter(r=>!Number.isNaN(r));if(!n.range||typeof n.range.startRow!="number"){const r=a.length?Math.min(...a):0,d=a.length?Math.max(...a):0;let c=0;for(const C in l){const h=C.indexOf(",");if(h<0)continue;const S=parseInt(C.substring(h+1),10);S>c&&(c=S)}return{range:{startCol:r,startRow:0,endCol:d,endRow:Math.max(0,c)},columns:o}}const i={...n.range};for(const r of a)r<i.startCol&&(i.startCol=r),r>i.endCol&&(i.endCol=r);return{range:i,columns:o}}function i2(e,l,n,o,a){let i=!1,r=null,d=1,c,C=()=>{},h=()=>{},S=()=>{};function m(){i||(i=!0,requestAnimationFrame(()=>{i=!1,O(),L()}))}e.scheduleRender=m;function M(u){const{frozenColumnsWidth:y}=e.getFrozenMetrics(),D=y>0&&u<ce()+y?u-ce():u-ce()+e.scrollX.value;return e.hitCol(D)}function E(u){const{frozenRowsHeight:y}=e.getFrozenMetrics(),D=y>0&&u<ae()+y?u-ae():u-ae()+e.scrollY.value;return e.hitRow(D)}let B=gi(e.props.theme);function G(u,y,D,j,T,P,ee,Q){const ue=va(Q,P);if(!ue){D===T?u.fillRect(y,D,j-y,P):u.fillRect(y,D,P,T-D);return}if(u.save(),u.strokeStyle=ee,u.lineWidth=P,u.lineCap=Q==="dotted"?"round":"butt",u.setLineDash(ue),u.beginPath(),D===T){const w=D+P/2;u.moveTo(y,w),u.lineTo(j,w)}else{const w=y+P/2;u.moveTo(w,D),u.lineTo(w,T)}u.stroke(),u.setLineDash([]),u.restore()}const te=14,ge=9,fe=16,Ie=Math.min(ge-1,9);function me(u){return 0}const Ee=()=>me(),Ae=()=>me(),ce=()=>52+Ee(),ae=()=>24+Ae();function qe(u,y){return fe+2+(y-u.level)*ge}function ut(u,y){return 3+(y-u.level)*ge}function J(u,y){const D=new Int8Array(y).fill(-1);if(!u.length)return D;const j=[...u].sort((P,ee)=>P.start-ee.start),T=new Map;j.forEach((P,ee)=>T.set(P.id,ee%2));for(const P of j){const ee=T.get(P.id),Q=Math.min(P.end,y-1);for(let ue=Math.max(0,P.start);ue<=Q;ue++)D[ue]===-1&&(D[ue]=ee)}return D}function O(){const u=o.wrapperRef.value,y=o.canvasRef.value;if(!u||!y||(r=y.getContext("2d"),!r))return;d=window.devicePixelRatio||1;const D=u.getBoundingClientRect(),j=D.width,T=D.height;o.viewSize.w=j,o.viewSize.h=T,y.width=j*d,y.height=T*d,y.style.width=j+"px",y.style.height=T+"px",r.setTransform(d,0,0,d,0,0);const P=e.scrollX.value,ee=e.scrollY.value,Q=52,ue=24,w=Ee(),s=Ae(),f=Q+w,b=ue+s,R=o.themeColors.value,I=e.getFilter(),ne=e.colPositions.value,ie=e.rowPositions.value,ye=J(e.getRowOutlines(),e.rowCount),ke=J(e.getColumnOutlines(),e.colCount),{frozenRowsHeight:Ue,frozenColumnsWidth:_e}=e.getFrozenMetrics(),Xe=f+_e,Qe=b+Ue,ht=Math.max(0,j-f-11-_e),Ct=Math.max(0,T-b-11-Ue),qt=Math.max(0,e.freeze.cols-1),$t=Math.max(0,e.freeze.rows-1),Yt=Math.max(e.freeze.cols,e.hitCol(_e+P));let nn=Yt;for(let _=Yt;_<e.colCount&&!(f+ne[_]-P>=j);_++)nn=_;const un=Math.max(e.freeze.rows,e.hitRow(Ue+ee));let oo=un;for(let _=un;_<e.rowCount&&!(b+ie[_]-ee>=T);_++)oo=_;let hn=Yt,on=nn,Un=un,Rn=oo;_e>0&&(hn=0,on=Math.max(on,qt)),Ue>0&&(Un=0,Rn=Math.max(Rn,$t));let _o=hn,Pn=Un;for(const _ in e.merges){const Oe=e.merges[_];Oe&&(Oe.startRow>Rn||Oe.endRow<Un||Oe.startCol>on||Oe.endCol<hn||(Oe.startCol<_o&&(_o=Oe.startCol),Oe.startRow<Pn&&(Pn=Oe.startRow)))}const Ho=new Array(Pn);for(let _=Pn;_<=Rn;_++)Ho[_]=ie[_+1]-ie[_];r.fillStyle=R.bg,r.fillRect(0,0,j,T),r.fillStyle=R.gridBg,r.fillRect(f,b,j-f,T-b);const St=e.selection.value,gt=e.editingCell.value;C=(_,Oe,Ge,yt,It,jt)=>{const Rt=e.dataValidations.length>0;for(let Be=yt;Be<=It;Be++)if(!e.isRowCollapsed(Be))for(let Pe=Oe;Pe<=Ge;Pe++){if(e.isColumnCollapsed(Pe)||e.findMerge(Pe,Be))continue;const Ze=e.cellToScreenRect(Be,Pe),Ye=Ze.x,dt=Ze.y,st=Ze.width,nt=Ze.height;if(Ye+st<f||dt+nt<b||Ye>j||dt>T)continue;const Ht=e.findHighlight?e.findHighlight(Pe,Be):null,Wt=e.resolveStyle(e.cells[e.cellKey(Pe,Be)]),Mt=typeof(Wt==null?void 0:Wt.backgroundColor)=="string"?Wt.backgroundColor:"";Mt&&(_.fillStyle=Mt,_.fillRect(Ye,dt,st,nt));const ct=e.resolveConditionalFormat(Pe,Be);if(ct!=null&&ct.backgroundColor&&(_.fillStyle=ct.backgroundColor,_.fillRect(Ye,dt,st,nt)),Ht&&(_.fillStyle=Ht==="active"?R.findActiveBg:R.findMatchBg,_.fillRect(Ye,dt,st,nt)),e.isSelected(Pe,Be)&&(_.fillStyle=R.selectionBg,e.selectionMode.value==="row"||e.selectionMode.value==="col"?_.fillRect(Ye,dt,(ne[Pe+1]??0)-ne[Pe],jt[Be]):_.fillRect(Ye,dt,st,nt)),e.activeCell.value.col===Pe&&e.activeCell.value.row===Be&&(_.strokeStyle=R.activeCellBorder,_.lineWidth=2,_.strokeRect(Ye+1,dt+1,st-2,nt-2)),Ht==="active"&&(_.strokeStyle=R.findActiveBg,_.lineWidth=2,_.strokeRect(Ye+1,dt+1,st-2,nt-2)),_.strokeStyle=R.gridLine,_.lineWidth=.5,_.strokeRect(Ye+.25,dt+.25,st-.5,nt-.5),!(gt&>.col===Pe&>.row===Be)){const De=e.resolveStyle(e.cells[e.cellKey(Pe,Be)]),he=e.getCellValue(Pe,Be),ot=typeof(De==null?void 0:De.numberFormat)=="string"?De.numberFormat:"",Je=he?In(he,ot,e.locale.value):"";if(Je){const mt=e.cellFontSize(Pe,Be),kt=typeof(De==null?void 0:De.fontFamily)=="string"&&De.fontFamily?De.fontFamily:Vo,Tt=(De==null?void 0:De.fontWeight)==="bold"||(ct==null?void 0:ct.fontWeight)==="bold"?"bold":"normal",gn=(De==null?void 0:De.fontStyle)==="italic"||(ct==null?void 0:ct.fontStyle)==="italic"?"italic":"normal",qn=(De==null?void 0:De.underline)==="underline"||(ct==null?void 0:ct.underline)==="underline",lo=(De==null?void 0:De.strikethrough)==="line-through"||(ct==null?void 0:ct.strikethrough)==="line-through",bn=(ct==null?void 0:ct.color)||(typeof(De==null?void 0:De.color)=="string"?De.color:""),On=typeof(De==null?void 0:De.textAlign)=="string"?De.textAlign:br(he,ot)?"right":"left",yn=typeof(De==null?void 0:De.verticalAlign)=="string"?De.verticalAlign:"top";_.fillStyle=bn||R.cellText,_.font=`${gn} ${Tt} ${mt}px ${kt}`,_.textBaseline="alphabetic",_.save(),_.beginPath(),_.rect(Ye+5,dt+1,st-10,nt-2),_.clip();const ro=(De==null?void 0:De.wrap)==="wrap";let ln=st-10;I&&Be===I.range.startRow&&Pe>=I.range.startCol&&Pe<=I.range.endCol&&(ln=st-10-mn);let Mn=Je;const Sn=!ro&&da(ot),Yn=Je===Tl||ua(he,ot);if(Yn||Sn){if(Yn){const Uo=Math.max(1,_.measureText("#").width),xl=Math.max(1,Math.floor(ln/Uo));Mn="#".repeat(xl)}else if(e.getWrappedLines(_,Je,1e9,!1).some(vo=>vo&&_.measureText(vo).width>ln)){const vo=Math.max(1,_.measureText("#").width),cl=Math.max(1,Math.floor(ln/vo));Mn="#".repeat(cl)}}const fn=e.getWrappedLines(_,Mn,ln,ro),{ascent:wo,descent:sl}=e.measureFontMetrics(kt,mt,Tt,gn),dr=wo+sl,O2=fn.length*dr;let ur;yn==="middle"?ur=dt+(nt-O2)/2+wo:yn==="bottom"?ur=dt+nt-e.BASE_CELL_VPAD-sl-(fn.length-1)*dr:ur=dt+e.BASE_CELL_VPAD+wo;for(let Uo=0;Uo<fn.length;Uo++){const xl=fn[Uo],vo=ur+Uo*dr,cl=_.measureText(xl);let To;if(On==="center"?To=Ye+st/2-cl.width/2:On==="right"?To=Ye+st-5-cl.width:To=Ye+5,_.fillText(xl,To,vo),qn&&(_.strokeStyle=bn||R.cellText,_.lineWidth=1,_.beginPath(),_.moveTo(To,vo+sl+1),_.lineTo(To+cl.width,vo+sl+1),_.stroke()),lo){_.strokeStyle=bn||R.cellText,_.lineWidth=1;const Di=vo-wo+dr*.42;_.beginPath(),_.moveTo(To,Di),_.lineTo(To+cl.width,Di),_.stroke()}}_.restore()}}if(I&&Be===I.range.startRow&&Pe>=I.range.startCol&&Pe<=I.range.endCol&&Ne(_,Ye,dt,st,nt,$a(I.columns[Pe]),R),Rt&&e.getListValidation(Be,Pe)){const De=e.activeCell.value.col===Pe&&e.activeCell.value.row===Be;Zt(_,Ye,dt,st,nt,De||e.isSelected(Pe,Be),R)}e.hasNote(Be,Pe)&&Vn(_,Ye,dt,st,nt)}};const Et=(_,Oe,Ge)=>{const yt=e.findMerge(_,Oe);return yt?e.getCellBorderSide(e.cells[yt.anchor],Ge):e.getCellBorderSide(e.cells[e.cellKey(_,Oe)],Ge)};h=(_,Oe,Ge,yt,It,jt)=>{_.fillStyle=B;for(let Rt=yt;Rt<=It;Rt++)if(!e.isRowCollapsed(Rt))for(let Be=Oe;Be<=Ge;Be++){if(e.isColumnCollapsed(Be)||e.findMerge(Be,Rt))continue;const at=e.cellToScreenRect(Rt,Be),Ze=at.x,Ye=at.y,dt=at.width,st=at.height;if(Ze+dt<f||Ye+st<b||Ze>j||Ye>T)continue;const nt=e.cells[e.cellKey(Be,Rt)],Ht={top:e.getCellBorderSide(nt,"top"),right:e.getCellBorderSide(nt,"right"),bottom:e.getCellBorderSide(nt,"bottom"),left:e.getCellBorderSide(nt,"left")},Wt={top:Et(Be,Rt-1,"bottom"),left:Et(Be-1,Rt,"right"),bottom:Et(Be,Rt+1,"top"),right:Et(Be+1,Rt,"left")},Mt=Pt(Wt.top,Ht.top),ct=Pt(Wt.left,Ht.left),De=Pt(Ht.bottom,Wt.bottom),he=Pt(Ht.right,Wt.right),ot=(Mt==null?void 0:Mt.width)??0,Je=(ct==null?void 0:ct.width)??0,mt=(De==null?void 0:De.width)??0,kt=(he==null?void 0:he.width)??0;ot>0&&G(_,Ze,Ye,Ze+dt,Ye,ot,(Mt==null?void 0:Mt.color)||B,rn(Mt==null?void 0:Mt.style)),mt>0&&G(_,Ze,Ye+st-mt,Ze+dt,Ye+st-mt,mt,(De==null?void 0:De.color)||B,rn(De==null?void 0:De.style)),Je>0&&G(_,Ze,Ye,Ze,Ye+st,Je,(ct==null?void 0:ct.color)||B,rn(ct==null?void 0:ct.style)),kt>0&&G(_,Ze+dt-kt,Ye,Ze+dt-kt,Ye+st,kt,(he==null?void 0:he.color)||B,rn(he==null?void 0:he.style));const Tt=Be>0&&e.isColumnCollapsed(Be-1),gn=Be<e.colCount-1&&e.isColumnCollapsed(Be+1),qn=Rt>0&&e.isRowCollapsed(Rt-1),lo=Rt<e.rowCount-1&&e.isRowCollapsed(Rt+1),bn=Be<e.freeze.cols&&(()=>{try{const yn=_.canvas;return yn?String(yn.className||"")==="grid-canvas":!1}catch{return!1}})(),On=Rt<e.freeze.rows&&(()=>{try{const yn=_.canvas;return yn?String(yn.className||"")==="grid-canvas":!1}catch{return!1}})();ot>0&&Je>0&&!Tt&&!qn&&(_.fillStyle=(Mt==null?void 0:Mt.color)||(ct==null?void 0:ct.color)||B,_.fillRect(Ze-Je,Ye-ot,Je,ot)),ot>0&&kt>0&&!gn&&!qn&&!bn&&(_.fillStyle=(Mt==null?void 0:Mt.color)||(he==null?void 0:he.color)||B,_.fillRect(Ze+dt,Ye-ot,kt,ot)),mt>0&&Je>0&&!Tt&&!lo&&!On&&(_.fillStyle=(De==null?void 0:De.color)||(ct==null?void 0:ct.color)||B,_.fillRect(Ze-Je,Ye+st,Je,mt)),mt>0&&kt>0&&!gn&&!lo&&!bn&&!On&&(_.fillStyle=(De==null?void 0:De.color)||(he==null?void 0:he.color)||B,_.fillRect(Ze+dt,Ye+st,kt,mt))}};const Kn=(_,Oe,Ge,yt,It,jt,Rt)=>{const Be=e.resolveStyle(e.cells[e.cellKey(Oe,Ge)]),Pe=e.getCellValue(Oe,Ge),at=typeof(Be==null?void 0:Be.numberFormat)=="string"?Be.numberFormat:"",Ze=Pe?In(Pe,at,e.locale.value):"";if(!Ze||yt-10<=0||It-2<=0)return;const dt=e.cellFontSize(Oe,Ge),st=typeof(Be==null?void 0:Be.fontFamily)=="string"&&Be.fontFamily?Be.fontFamily:Vo,nt=e.resolveConditionalFormat(Oe,Ge),Ht=(Be==null?void 0:Be.fontWeight)==="bold"||(nt==null?void 0:nt.fontWeight)==="bold"?"bold":"normal",Wt=(Be==null?void 0:Be.fontStyle)==="italic"||(nt==null?void 0:nt.fontStyle)==="italic"?"italic":"normal",Mt=(Be==null?void 0:Be.underline)==="underline"||(nt==null?void 0:nt.underline)==="underline",ct=(Be==null?void 0:Be.strikethrough)==="line-through"||(nt==null?void 0:nt.strikethrough)==="line-through",De=(nt==null?void 0:nt.color)||(typeof(Be==null?void 0:Be.color)=="string"?Be.color:""),he=typeof(Be==null?void 0:Be.textAlign)=="string"?Be.textAlign:br(Pe,at)?"right":"left",ot=typeof(Be==null?void 0:Be.verticalAlign)=="string"?Be.verticalAlign:"top";_.fillStyle=De||R.cellText,_.font=`${Wt} ${Ht} ${dt}px ${st}`,_.textBaseline="alphabetic",_.save(),_.beginPath(),_.rect(jt+5,Rt+1,yt-10,It-2),_.clip();const Je=(Be==null?void 0:Be.wrap)==="wrap",mt=yt-10;let kt=Ze;const Tt=!Je&&da(at),gn=Ze===Tl||ua(Pe,at);if(gn||Tt){if(gn){const ln=Math.max(1,_.measureText("#").width),Mn=Math.max(1,Math.floor(mt/ln));kt="#".repeat(Mn)}else if(e.getWrappedLines(_,Ze,1e9,!1).some(Sn=>Sn&&_.measureText(Sn).width>mt)){const Sn=Math.max(1,_.measureText("#").width),Yn=Math.max(1,Math.floor(mt/Sn));kt="#".repeat(Yn)}}const qn=e.getWrappedLines(_,kt,mt,Je),{ascent:lo,descent:bn}=e.measureFontMetrics(st,dt,Ht,Wt),On=lo+bn,yn=qn.length*On;let ro;ot==="middle"?ro=Rt+(It-yn)/2+lo:ot==="bottom"?ro=Rt+It-e.BASE_CELL_VPAD-bn-(qn.length-1)*On:ro=Rt+e.BASE_CELL_VPAD+lo;for(let ln=0;ln<qn.length;ln++){const Mn=qn[ln],Sn=ro+ln*On,Yn=_.measureText(Mn);let fn;if(he==="center"?fn=jt+yt/2-Yn.width/2:he==="right"?fn=jt+yt-5-Yn.width:fn=jt+5,_.fillText(Mn,fn,Sn),Mt&&(_.strokeStyle=De||R.cellText,_.lineWidth=1,_.beginPath(),_.moveTo(fn,Sn+bn+1),_.lineTo(fn+Yn.width,Sn+bn+1),_.stroke()),ct){_.strokeStyle=De||R.cellText,_.lineWidth=1;const wo=Sn-lo+On*.42;_.beginPath(),_.moveTo(fn,wo),_.lineTo(fn+Yn.width,wo),_.stroke()}}_.restore()},Gn=(_,Oe,Ge,yt,It,jt,Rt,Be)=>{const Pe=Oe.startCol,at=Oe.endCol,Ze=Oe.startRow,Ye=Oe.endRow,dt=yt,st=jt,nt=Rt&&at+1===e.freeze.cols&&e.freeze.cols<e.colCount&&e.isColumnCollapsed(e.freeze.cols),Ht=Rt&&at>=e.freeze.cols||nt,Wt=Be&&Ye+1===e.freeze.rows&&e.freeze.rows<e.rowCount&&e.isRowCollapsed(e.freeze.rows),Mt=Be&&Ye>=e.freeze.rows||Wt,ct=e.cells[e.cellKey(Pe,Ze)],De={top:e.getCellBorderSide(ct,"top"),right:e.getCellBorderSide(ct,"right"),bottom:e.getCellBorderSide(ct,"bottom"),left:e.getCellBorderSide(ct,"left")};_.fillStyle=B;for(let he=Pe;he<=at;he++){if(Rt&&he>=e.freeze.cols||e.isSameMergeInternal(he,Ze-1,he,Ze))continue;const ot=Et(he,Ze-1,"bottom"),Je=Pt(ot,De.top);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.cols?Q+ne[he]:Q+ne[he]-P,kt=(ne[he+1]??0)-ne[he];G(_,mt,dt,mt+kt,dt,Je.width,Je.color||B,rn(Je.style))}}if(!Mt)for(let he=Pe;he<=at;he++){if(Rt&&he>=e.freeze.cols||e.isSameMergeInternal(he,Ye,he,Ye+1))continue;const ot=Et(he,Ye+1,"top"),Je=Pt(De.bottom,ot);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.cols?Q+ne[he]:Q+ne[he]-P,kt=(ne[he+1]??0)-ne[he],Tt=dt+st-Je.width;G(_,mt,Tt,mt+kt,Tt,Je.width,Je.color||B,rn(Je.style))}}for(let he=Ze;he<=Ye;he++){if(Be&&he>=e.freeze.rows||e.isSameMergeInternal(Pe-1,he,Pe,he))continue;const ot=Et(Pe-1,he,"right"),Je=Pt(ot,De.left);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.rows?ue+ie[he]:ue+ie[he]-ee,kt=ie[he+1]-ie[he];G(_,Ge,mt,Ge,mt+kt,Je.width,Je.color||B,rn(Je.style))}}if(!Ht)for(let he=Ze;he<=Ye;he++){if(Be&&he>=e.freeze.rows||e.isSameMergeInternal(at,he,at+1,he))continue;const ot=Et(at+1,he,"left"),Je=Pt(De.right,ot);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.rows?ue+ie[he]:ue+ie[he]-ee,kt=ie[he+1]-ie[he],Tt=Ge+It-Je.width;G(_,Tt,mt,Tt,mt+kt,Je.width,Je.color||B,rn(Je.style))}}{const he=e.isSameMergeInternal(Pe,Ze-1,Pe,Ze)?De.top:Pt(Et(Pe,Ze-1,"bottom"),De.top),ot=e.isSameMergeInternal(Pe-1,Ze,Pe,Ze)?De.left:Pt(Et(Pe-1,Ze,"right"),De.left),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=Pe>0&&e.isColumnCollapsed(Pe-1),Tt=Ze>0&&e.isRowCollapsed(Ze-1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge-mt,yt-Je,mt,Je))}if(!Ht){const he=e.isSameMergeInternal(at,Ze-1,at,Ze)?De.top:Pt(Et(at,Ze-1,"bottom"),De.top),ot=e.isSameMergeInternal(at,Ze,at+1,Ze)?De.right:Pt(De.right,Et(at+1,Ze,"left")),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=at<e.colCount-1&&e.isColumnCollapsed(at+1),Tt=Ze>0&&e.isRowCollapsed(Ze-1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge+It,yt-Je,mt,Je))}if(!Mt){const he=e.isSameMergeInternal(Pe,Ye,Pe,Ye+1)?De.bottom:Pt(De.bottom,Et(Pe,Ye+1,"top")),ot=e.isSameMergeInternal(Pe-1,Ye,Pe,Ye)?De.left:Pt(Et(Pe-1,Ye,"right"),De.left),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=Pe>0&&e.isColumnCollapsed(Pe-1),Tt=Ye<e.rowCount-1&&e.isRowCollapsed(Ye+1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge-mt,yt+jt,mt,Je))}if(!Ht&&!Mt){const he=e.isSameMergeInternal(at,Ye,at,Ye+1)?De.bottom:Pt(De.bottom,Et(at,Ye+1,"top")),ot=e.isSameMergeInternal(at,Ye,at+1,Ye)?De.right:Pt(De.right,Et(at+1,Ye,"left")),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=at<e.colCount-1&&e.isColumnCollapsed(at+1),Tt=Ye<e.rowCount-1&&e.isRowCollapsed(Ye+1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge+It,yt+jt,mt,Je))}};S=(_,Oe,Ge,yt,It)=>{var at,Ze;const jt=Oe+yt,Rt=Ge+It,Be=Oe<Xe,Pe=Ge<Qe;for(const Ye in e.merges){const dt=e.merges[Ye];if(!dt)continue;const st=dt.startCol,nt=dt.startRow,Ht=dt.endCol,Wt=dt.endRow,Mt=e.cellToScreenRect(nt,st),ct=e.cellToScreenRect(Wt,Ht),De=Mt.x,he=Mt.y,ot=ct.x+ct.width-De,Je=ct.y+ct.height-he,mt=Be&&Ht>=e.freeze.cols?Math.min(jt,Xe):Math.min(De+ot,jt),kt=Pe&&Wt>=e.freeze.rows?Math.min(Rt,Qe):Math.min(he+Je,Rt),Tt=Math.max(De,Oe),gn=Math.max(he,Ge);if(mt<=Tt||kt<=gn)continue;const qn=(at=e.resolveStyle(e.cells[e.cellKey(st,nt)]))==null?void 0:at.backgroundColor,bn=((Ze=e.resolveConditionalFormat(st,nt))==null?void 0:Ze.backgroundColor)||qn;bn&&(_.fillStyle=bn,_.fillRect(Tt,gn,mt-Tt,kt-gn)),e.isSelected(st,nt)&&(_.fillStyle=R.selectionBg,_.fillRect(Tt,gn,mt-Tt,kt-gn)),_.strokeStyle=R.gridLine,_.lineWidth=.5;const On=De+.25,yn=he+.25,ro=mt-De-.5,ln=kt-he-.5;if(ro>0&&ln>0&&_.strokeRect(On,yn,ro,ln),Gn(_,dt,De,he,ot,Je,Be,Pe),e.activeCell.value.col===st&&e.activeCell.value.row===nt&&(_.strokeStyle=R.activeCellBorder,_.lineWidth=2,_.strokeRect(De+1,he+1,ot-2,Je-2)),e.getListValidation(nt,st)){const Mn=e.activeCell.value.col===st&&e.activeCell.value.row===nt;Zt(_,De,he,ot,Je,Mn,R)}if(e.hasNote(nt,st)&&Vn(_,De,he,ot,Je),!(e.editingCell.value&&e.editingCell.value.col===st&&e.editingCell.value.row===nt)){const Mn=ne[Ht+1]-ne[st],Sn=ie[Wt+1]-ie[nt],Yn=st<e.freeze.cols,fn=nt<e.freeze.rows,wo=Be?De:Yn?De-P:De,sl=Pe?he:fn?he-ee:he;Kn(_,st,nt,Mn,Sn,wo,sl)}}},r.save(),r.beginPath();const Wo=_e>0?2:0,zt=Ue>0?2:0;r.rect(Xe-Wo,Qe-zt,ht+Wo,Ct+zt),r.clip(),C(r,_o,on,Pn,Rn,Ho),h(r,_o,on,Pn,Rn,Ho),S(r,Xe,Qe,ht,Ct),r.restore(),_e>0&&(r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(Xe+.5,ue),r.lineTo(Xe+.5,T),r.stroke()),Ue>0&&(r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(Q,Qe+.5),r.lineTo(j,Qe+.5),r.stroke()),r.fillStyle=R.headerBg,r.fillRect(f,s,j-f,ue);for(let _=Yt;_<=nn;_++){const Oe=f+ne[_]-P;if(e.isColumnCollapsed(_))continue;const Ge=(ne[_+1]??0)-ne[_];if(Oe+Ge<f||Oe>j)continue;const yt=ke[_];yt===0?(r.fillStyle=R.outlineGroupBg1,r.fillRect(Oe,s,Ge,ue)):yt===1&&(r.fillStyle=R.outlineGroupBg2,r.fillRect(Oe,s,Ge,ue)),St&&_>=St.startCol&&_<=St.endCol&&(r.fillStyle=R.selectionBg,r.fillRect(Oe,s,Ge,ue)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(Oe+.25,s+.25,Ge-.5,ue-.5),St&&_>=St.startCol&&_<=St.endCol&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(Oe,s+ue-1),r.lineTo(Oe+Ge,s+ue-1),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(pt(_),Oe+Ge/2,s+ue/2)}if(_e>0){r.fillStyle=R.headerBg,r.fillRect(f,s,_e,ue);for(let _=0;_<=qt;_++){const Oe=f+ne[_];if(e.isColumnCollapsed(_))continue;const Ge=(ne[_+1]??0)-ne[_];Oe+Ge<f||Oe>j||(St&&_>=St.startCol&&_<=St.endCol&&(r.fillStyle=R.selectionBg,r.fillRect(Oe,s,Ge,ue)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(Oe+.25,s+.25,Ge-.5,ue-.5),St&&_>=St.startCol&&_<=St.endCol&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(Oe,s+ue-1),r.lineTo(Oe+Ge,s+ue-1),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(pt(_),Oe+Ge/2,s+ue/2))}}r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(f,b+.5),r.lineTo(j,b+.5),r.stroke(),r.fillStyle=R.headerBg,r.fillRect(0,b,f,T-b);for(let _=un;_<=oo;_++){if(e.isRowHidden(_))continue;const Oe=b+ie[_]-ee,Ge=Ho[_];if(Oe+Ge<b||Oe>T)continue;const yt=ye[_];yt===0?(r.fillStyle=R.outlineGroupBg1,r.fillRect(w,Oe,Q,Ge)):yt===1&&(r.fillStyle=R.outlineGroupBg2,r.fillRect(w,Oe,Q,Ge)),St&&_>=St.startRow&&_<=St.endRow&&(r.fillStyle=R.selectionBg,r.fillRect(w,Oe,Q,Ge)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(w+.25,Oe+.25,Q-.5,Ge-.5),St&&_>=St.startRow&&_<=St.endRow&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(w+Q-1,Oe),r.lineTo(w+Q-1,Oe+Ge),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(String(_+1),w+Q/2,Oe+Ge/2+.5)}if(Ue>0){r.fillStyle=R.headerBg,r.fillRect(0,b,f,Ue);for(let _=0;_<=$t;_++){if(e.isRowHidden(_))continue;const Oe=b+ie[_],Ge=Ho[_];Oe+Ge<b||Oe>T||(St&&_>=St.startRow&&_<=St.endRow&&(r.fillStyle=R.selectionBg,r.fillRect(w,Oe,Q,Ge)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(w+.25,Oe+.25,Q-.5,Ge-.5),St&&_>=St.startRow&&_<=St.endRow&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(w+Q-1,Oe),r.lineTo(w+Q-1,Oe+Ge),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(String(_+1),w+Q/2,Oe+Ge/2+.5))}}r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(f+.5,b),r.lineTo(f+.5,T),r.stroke(),r.fillStyle=R.headerBg,r.fillRect(w,s,Q,ue),r.strokeStyle=R.headerSep,r.lineWidth=1,r.strokeRect(w+.5,s+.5,Q-1,ue-1);const _t=Math.min(Q,ue)*.32;r.fillStyle=R.activeCellBorder,r.beginPath(),r.moveTo(w+Q-1,s+ue-1-_t),r.lineTo(w+Q-1-_t,s+ue-1),r.lineTo(w+Q-1,s+ue-1),r.closePath(),r.fill();const Co=e.getOutlineLevel("row"),il=e.getOutlineLevel("column");if(e.getRowOutlines().length)for(const _ of e.getRowOutlines()){const Oe=qe(_,Co),Ge=b+ie[_.start]-ee,yt=Oe-Ie/2,It=Ge-Ie/2;r.fillStyle=R.headerBg,r.strokeStyle=R.headerText,r.lineWidth=1,$n(r,Math.round(yt),Math.round(It),Ie,Ie,2),r.fill(),r.stroke(),r.strokeStyle=R.headerText,r.lineWidth=1.4,r.beginPath(),r.moveTo(Oe-2,Ge),r.lineTo(Oe+2,Ge),r.stroke(),_.collapsed&&(r.beginPath(),r.moveTo(Oe,Ge-2),r.lineTo(Oe,Ge+2),r.stroke())}if(e.getColumnOutlines().length)for(const _ of e.getColumnOutlines()){const Oe=ut(_,il),Ge=f+ne[_.start]-P,yt=Ge-Ie/2,It=Oe-Ie/2;r.fillStyle=R.headerBg,r.strokeStyle=R.headerText,r.lineWidth=1,$n(r,Math.round(yt),Math.round(It),Ie,Ie,2),r.fill(),r.stroke(),r.strokeStyle=R.headerText,r.lineWidth=1.4,r.beginPath(),r.moveTo(Ge-2,Oe),r.lineTo(Ge+2,Oe),r.stroke(),_.collapsed&&(r.beginPath(),r.moveTo(Ge,Oe-2),r.lineTo(Ge,Oe+2),r.stroke())}le(r,R),$e(r,R)}function L(){const u=o.freezeCanvasRef.value,y=o.wrapperRef.value;if(!u||!y)return;const D=u.getContext("2d");if(!D)return;const j=y.getBoundingClientRect(),T=j.width,P=j.height,ee=52,Q=24,ue=Ee(),w=Ae(),s=ee+ue,f=Q+w,b=o.themeColors.value,R=e.colPositions.value,I=e.rowPositions.value,ne=e.scrollX.value,ie=e.scrollY.value;u.width=T*d,u.height=P*d,u.style.width=T+"px",u.style.height=P+"px",D.setTransform(d,0,0,d,0,0),D.clearRect(0,0,T,P);const{frozenRowsHeight:ye,frozenColumnsWidth:ke}=e.getFrozenMetrics(),Ue=s+ke,_e=f+ye,Xe=Math.max(0,T-s-11-ke),Qe=Math.max(0,P-f-11-ye),ht=Math.max(0,e.freeze.cols-1),Ct=Math.max(0,e.freeze.rows-1),qt=Math.max(e.freeze.cols,e.hitCol(ke+ne));let $t=qt;for(let gt=qt;gt<e.colCount&&!(s+R[gt]-ne>=T);gt++)$t=gt;const Yt=Math.max(e.freeze.rows,e.hitRow(ye+ie));let nn=Yt;for(let gt=Yt;gt<e.rowCount&&!(f+I[gt]-ie>=P);gt++)nn=gt;let un=qt,oo=$t,hn=Yt,on=nn;ke>0&&(un=0,oo=Math.max(oo,ht)),ye>0&&(hn=0,on=Math.max(on,Ct));let Un=un,Rn=hn;for(const gt in e.merges){const Et=e.merges[gt];Et&&(Et.startRow>on||Et.endRow<hn||Et.startCol>oo||Et.endCol<un||(Et.startCol<Un&&(Un=Et.startCol),Et.startRow<Rn&&(Rn=Et.startRow)))}const _o=new Array(Rn);for(let gt=Rn;gt<=on;gt++)_o[gt]=I[gt+1]-I[gt];const Pn=(gt,Et,Kn)=>{const Gn=e.findMerge(gt,Et);return Gn?e.getCellBorderSide(e.cells[Gn.anchor],Kn):e.getCellBorderSide(e.cells[e.cellKey(gt,Et)],Kn)},Ho=(gt,Et,Kn,Gn,Wo)=>{gt.fillStyle=B;for(let zt=Gn;zt<=Wo;zt++)for(let _t=Et;_t<=Kn;_t++){if(e.isRowCollapsed(zt)||e.isColumnCollapsed(_t))continue;const Co=e.findMerge(_t,zt);if(Co&&!(_t===Co.range.startCol&&zt===Co.range.startRow))continue;const il=e.cellToScreenRect(zt,_t),_=il.x,Oe=il.y,Ge=il.width,yt=il.height;if(_+Ge<s||Oe+yt<f||_>T||Oe>P)continue;const It=e.cells[e.cellKey(_t,zt)],jt={top:e.getCellBorderSide(It,"top"),right:e.getCellBorderSide(It,"right"),bottom:e.getCellBorderSide(It,"bottom"),left:e.getCellBorderSide(It,"left")};if(Co)continue;const Rt={top:Pn(_t,zt-1,"bottom"),left:Pn(_t-1,zt,"right"),bottom:Pn(_t,zt+1,"top"),right:Pn(_t+1,zt,"left")},Be=Pt(Rt.top,jt.top),Pe=Pt(Rt.left,jt.left),at=Pt(jt.bottom,Rt.bottom),Ze=Pt(jt.right,Rt.right),Ye=(Be==null?void 0:Be.width)??0,dt=(Pe==null?void 0:Pe.width)??0,st=(at==null?void 0:at.width)??0,nt=(Ze==null?void 0:Ze.width)??0;Ye>0&&G(gt,_,Oe,_+Ge,Oe,Ye,(Be==null?void 0:Be.color)||B,rn(Be==null?void 0:Be.style)),st>0&&G(gt,_,Oe+yt-st,_+Ge,Oe+yt-st,st,(at==null?void 0:at.color)||B,rn(at==null?void 0:at.style)),dt>0&&G(gt,_,Oe,_,Oe+yt,dt,(Pe==null?void 0:Pe.color)||B,rn(Pe==null?void 0:Pe.style)),nt>0&&G(gt,_+Ge-nt,Oe,_+Ge-nt,Oe+yt,nt,(Ze==null?void 0:Ze.color)||B,rn(Ze==null?void 0:Ze.style));const Ht=_t>0&&e.isColumnCollapsed(_t-1),Wt=_t<e.colCount-1&&e.isColumnCollapsed(_t+1),Mt=zt>0&&e.isRowCollapsed(zt-1),ct=zt<e.rowCount-1&&e.isRowCollapsed(zt+1),De=_t<e.freeze.cols,he=zt<e.freeze.rows;Ye>0&&dt>0&&!Ht&&!Mt&&(gt.fillStyle=(Be==null?void 0:Be.color)||(Pe==null?void 0:Pe.color)||B,gt.fillRect(_-dt,Oe-Ye,dt,Ye)),Ye>0&&nt>0&&!Wt&&!Mt&&!De&&(gt.fillStyle=(Be==null?void 0:Be.color)||(Ze==null?void 0:Ze.color)||B,gt.fillRect(_+Ge,Oe-Ye,nt,Ye)),st>0&&dt>0&&!Ht&&!ct&&!he&&(gt.fillStyle=(at==null?void 0:at.color)||(Pe==null?void 0:Pe.color)||B,gt.fillRect(_-dt,Oe+yt,dt,st)),st>0&&nt>0&&!Wt&&!ct&&!De&&!he&&(gt.fillStyle=(at==null?void 0:at.color)||(Ze==null?void 0:Ze.color)||B,gt.fillRect(_+Ge,Oe+yt,nt,st))}},St=(gt,Et,Kn,Gn,Wo,zt,_t,Co)=>{Kn<=0||Gn<=0||(D.save(),D.beginPath(),D.rect(gt,Et,Kn,Gn),D.clip(),D.fillStyle=b.gridBg,D.fillRect(gt,Et,Kn,Gn),C(D,Wo,zt,_t,Co,_o),Ho(D,Wo,zt,_t,Co),S(D,gt,Et,Kn,Gn),D.restore())};ke>0&&ye>0&&St(ee,Q,ke,ye,0,ht,0,Ct),ye>0&&St(Ue,Q,Xe,ye,Un,oo,0,Ct),ke>0&&St(ee,_e,ke,Qe,0,ht,Rn,on),D.strokeStyle=b.headerSep,D.lineWidth=1,ke>0&&(D.beginPath(),D.moveTo(Ue+.5,Q),D.lineTo(Ue+.5,P),D.stroke()),ye>0&&(D.beginPath(),D.moveTo(ee,_e+.5),D.lineTo(T,_e+.5),D.stroke()),D.fillStyle=b.headerBg,D.fillRect(0,0,ee,Q),D.strokeStyle=b.headerSep,D.lineWidth=1,D.strokeRect(.5,.5,ee-.5,Q-.5),le(D,b),$e(D,b)}function le(u,y){const D=e.selection.value;if(!D||e.editingCell.value)return;const j=e.cellToScreenRect(D.endRow,D.endCol),T=j.x+j.width-6/2,P=j.y+j.height-6/2;if(T<ce()||P<ae())return;const{frozenColumnsWidth:ee,frozenRowsHeight:Q}=e.getFrozenMetrics();if(ee>0&&D.endCol>=e.freeze.cols&&T<ce()+ee||Q>0&&D.endRow>=e.freeze.rows&&P<ae()+Q)return;const ue=Nr(D,D,e.merges).ok;u.fillStyle=ue?y.activeCellBorder:y.scrollTrack,u.fillRect(T,P,6,6),u.strokeStyle="#fff",u.lineWidth=1,u.strokeRect(T+.5,P+.5,6-1,6-1)}function $e(u,y){const D=e.autoFillState.value;if(!D.active||!D.preview||!D.targetRange)return;const j=D.targetRange,T=e.cellToScreenRect(j.startRow,j.startCol),P=e.cellToScreenRect(j.endRow,j.endCol),ee=T.x,Q=T.y,ue=P.x+P.width-ee,w=P.y+P.height-Q;Q<ae()||ee<ce()||(u.fillStyle=y.selectionBg,u.fillRect(ee,Q,ue,w),u.strokeStyle=y.activeCellBorder,u.lineWidth=1.5,u.setLineDash([4,3]),u.strokeRect(ee+.5,Q+.5,ue-1,w-1),u.setLineDash([]))}const et=t.computed(()=>pt(e.activeCell.value.col)+String(e.activeCell.value.row+1)),oe=t.ref(""),xe=t.ref(!1),se=t.computed(()=>e.editingCell.value?oe.value:e.getCellRaw(e.activeCell.value.col,e.activeCell.value.row));t.watch(()=>e.editingCell.value,(u,y)=>{if(u&&!y){const D=e.editValue.value||e.getCellRaw(u.col,u.row)||"";oe.value=D,We=!1}else!u&&y&&(oe.value="",xe.value=!1,We=!1)},{immediate:!0}),t.watch(()=>[e.activeCell.value.col,e.activeCell.value.row],()=>{e.editingCell.value||(oe.value="",We=!1)});function de(){e.editingCell.value||(e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(),m())}function we(u){const y=u.target.value;e.editingCell.value?e.editValue.value=y:e.startEdit(y),oe.value=y,We=!0}function Re(u){var D,j;const y={...e.activeCell.value};e.editingCell.value?(e.editValue.value=u,e.commitEdit()):((D=e.saveUndo)==null||D.call(e),e.setCellValue(y.col,y.row,u)),oe.value="",We=!1,m(),(j=o.emitModelData)==null||j.call(o)}let Ke=!1,We=!1;function rt(){var P,ee,Q;if(Ke)return;const u=o.formulaBarRef.value,y=!!(u&&typeof document<"u"&&document.activeElement===u);if(!e.editingCell.value&&!y&&!We)return;const D={...e.activeCell.value},j=e.editingCell.value?e.editingCell.value.col:D.col,T=e.editingCell.value?e.editingCell.value.row:D.row;if(!e.editingCell.value){const ue=e.getCellRaw(j,T),w=oe.value!==ue;if(!We)return;Ke=!0,w&&((P=e.saveUndo)==null||P.call(e),e.setCellValue(j,T,oe.value),m(),(ee=o.emitModelData)==null||ee.call(o)),(Q=o.formulaBarRef.value)==null||Q.blur(),oe.value="",xe.value=!1,We=!1,t.nextTick(()=>{Ke=!1});return}Ke=!0,We?(e.editValue.value=oe.value,e.commitEdit().then(ue=>{var w,s;ue&&(e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row)),(w=o.formulaBarRef.value)==null||w.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(s=o.emitModelData)==null||s.call(o),t.nextTick(()=>{Ke=!1})})):y?(oe.value=e.editValue.value,e.commitEdit().then(ue=>{var w,s;ue&&(e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row)),(w=o.formulaBarRef.value)==null||w.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(s=o.emitModelData)==null||s.call(o),t.nextTick(()=>{Ke=!1})})):e.commitEdit().then(()=>{var ue,w;(ue=o.formulaBarRef.value)==null||ue.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(w=o.emitModelData)==null||w.call(o),t.nextTick(()=>{Ke=!1})})}function je(){var u;Ke||(Ke=!0,e.editingCell.value&&e.cancelEdit(),(u=o.formulaBarRef.value)==null||u.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),t.nextTick(()=>{Ke=!1}))}function A(u){if(!u.isComposing){if(u.key==="Enter"&&(u.altKey||u.metaKey)&&!u.ctrlKey){u.preventDefault(),u.stopPropagation();const y=u.target;if(!y)return;e.editingCell.value||e.startEdit();const D=y.selectionStart??y.value.length,j=y.selectionEnd??y.value.length,T=y.value,P=T.substring(0,D)+`
|
|
6
|
+
`))}}}async function et(){var Fe;let A;try{A=await navigator.clipboard.readText()}catch{return}if(!A&&A!=="")return;const K=A.split(/\r?\n/),$=e.activeCell.value,V=ae,x=V&&qe.length>0,H=K.map(v=>v.split(" ").length),z=H.length?Math.max(...H):0,Y=$.col+z-1,ve=$.row+K.length-1;Y>=0&&ve>=0&&e.ensureCapacity(Y,ve);const ze=[];for(let v=0;v<K.length;v++){const Z=K[v].split(" ");for(let lt=0;lt<Z.length;lt++){const wt=$.col+lt,ft=$.row+v;let At=Z[lt];At.startsWith("=")&&V&&(At=Al(At,wt-(V.startCol+lt),ft-(V.startRow+v),e.colCount,e.rowCount,pt));const Ft=x&&v<qe.length&<<(((Fe=qe[v])==null?void 0:Fe.length)??0)?qe[v][lt]??null:null;ze.push({c:wt,r:ft,val:At,styleId:Ft})}}const it=e.validateCells(ze.map(v=>({col:v.c,row:v.r,value:v.val})));if(!(!it.valid&&await e.confirmInvalidValue(it,$.col,$.row)!=="continue")){for(const v of ze)v.styleId!==null?L(v.c,v.r,v.val,v.styleId):e.setCellValue(v.c,v.r,v.val);if(V&&ut.length>0){const v=$.col-V.startCol,Z=$.row-V.startRow,lt={startCol:$.col,endCol:$.col+z-1,startRow:$.row,endRow:$.row+K.length-1},wt=ut.map(ft=>({...ft,ranges:ft.ranges.map(At=>Vp(At,v,Z))}));e.applyDataValidationsToRange(wt,lt,{silent:!0}),e.invalidateDataValidationCache()}}}function oe(){var A;if(l.saveUndo(),le(),e.selection.value){const K=e.selection.value;e.clearCellsInRange(K.startCol,K.endCol,K.startRow,K.endRow),(A=e.scheduleRender)==null||A.call(e)}}function xe(){var A;if(e.selection.value){const K=e.selection.value;e.clearCellsInRange(K.startCol,K.endCol,K.startRow,K.endRow),(A=e.scheduleRender)==null||A.call(e)}}function se(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=SUM(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=SUM(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=SUM(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=SUM(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}function de(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=AVERAGE(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=AVERAGE(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=AVERAGE(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=AVERAGE(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}function we(){var H,z;const A=e.selection.value;if(!A)return;l.saveUndo();const K=A.startCol,$=A.startRow,V=A.endCol,x=A.endRow;if($===x)if(V+1<e.colCount){const Y=`${pt(K)}${$+1}:${pt(V)}${$+1}`;e.setCellValue(V+1,$,`=COUNT(${Y})`)}else{const Y=`${pt(K)}${$+1}:${pt(V-1)}${$+1}`;e.setCellValue(V,$,`=COUNT(${Y})`)}else for(let Y=K;Y<=V;Y++)if(x+1<e.rowCount){const ve=`${pt(Y)}${$+1}:${pt(Y)}${x+1}`;e.setCellValue(Y,x+1,`=COUNT(${ve})`)}else{const ve=`${pt(Y)}${$+1}:${pt(Y)}${x}`;e.setCellValue(Y,x,`=COUNT(${ve})`)}(H=e.scheduleRender)==null||H.call(e),(z=e.emitModelData)==null||z.call(e)}const Re=t.ref(!1);function Ke(A){Re.value=A,A&&(l.textColorMenuOpen.value=!1,l.fillColorMenuOpen.value=!1,i.value=!1,l.fontSizeMenuOpen.value=!1,G.value=!1)}function We(){se(),Re.value=!1}function rt(){de(),Re.value=!1}function je(){we(),Re.value=!1}return{cachedBorder:n,cachedBorderColor:o,cachedBorderLineStyle:a,selBorderColor:m,selBorderLineStyle:M,borderMenuOpen:i,onBorderChange:C,onBorderColorChange:h,onBorderLineStyleChange:S,setCellBorderSide:d,applyBorderToCell:c,applyCachedBorder:E,cellBorderWidth:B,mergeMenuOpen:G,onMergeMenuToggle:te,removeOverlappingMerges:ge,mergeAndCenter:fe,mergeAcross:Ie,mergeCells:me,unmergeCells:Ee,onApplyMerge:Ae,onMergeChange:ce,copySourceRange:null,copySourceStyles:[],captureStyles:O,captureDataValidations:J,setCellWithStyle:L,copyToClipboard:le,copyRowCol:$e,pasteFromClipboard:et,cutSelected:oe,clearSelected:xe,sumSelected:se,avgSelected:de,countSelected:we,calcMenuOpen:Re,onCalcMenuToggle:Ke,onCalcSum:We,onCalcAvg:rt,onCalcCount:je}}function Jp(e,l,n,o){const a={},i=o(l),r=o(n);return i!=null&&(a.width=`${i}px`),r!=null&&(a.height=`${r}px`),a["--sp-formula-bar-bg"]=e.formulaBarBg,a["--sp-formula-bar-border"]=e.formulaBarBorder,a["--sp-formula-bar-label-color"]=e.formulaBarLabelText,a["--sp-formula-bar-label-bg"]=e.formulaBarLabelBg,a["--sp-formula-bar-label-border"]=e.formulaBarLabelBorder,a["--sp-formula-bar-input-bg"]=e.formulaBarInputBg,a["--sp-formula-bar-input-border"]=e.formulaBarInputBorder,a["--sp-formula-bar-input-color"]=e.formulaBarInputText,a["--sp-formula-bar-input-focus-border"]=e.formulaBarInputFocusBorder,a["--sp-formula-bar-input-focus-shadow"]=e.formulaBarInputFocusShadow,a["--sp-wrapper-bg"]=e.wrapperBg,a["--sp-cell-editor-border"]=e.cellEditorBorder,a["--sp-cell-editor-color"]=e.cellEditorText,a["--sp-cell-editor-bg"]=e.cellEditorBg,a["--sp-cell-editor-shadow"]=e.cellEditorShadow,a["--sp-tab-bar-bg"]=e.tabBarBg,a["--sp-tab-bar-border"]=e.tabBarBorder,a["--sp-tab-active-bg"]=e.tabActiveBg,a["--sp-tab-active-color"]=e.tabActiveText,a["--sp-tab-active-border"]=e.tabActiveBorder,a["--sp-tab-inactive-bg"]=e.tabInactiveBg,a["--sp-tab-inactive-color"]=e.tabInactiveText,a["--sp-tab-inactive-border"]=e.tabInactiveBorder,a["--sp-tab-hover-bg"]=e.tabHoverBg,a["--sp-tab-add-btn-color"]=e.tabAddBtnColor,a["--sp-tab-add-btn-hover-bg"]=e.tabAddBtnHoverBg,a["--sp-tab-scroll-btn-color"]=e.tabScrollBtnColor,a["--sp-tab-scroll-btn-hover-bg"]=e.tabScrollBtnHoverBg,a["--sp-scroll-thumb"]=e.scrollbarThumb,a["--sp-scroll-thumb-hover"]=e.scrollbarThumbHover,a["--sp-scroll-btn-bg"]=e.scrollBtnBg,a["--sp-scroll-btn-color"]=e.scrollBtnColor,a["--sp-scroll-btn-hover-bg"]=e.scrollBtnHoverBg,a["--sp-scroll-btn-active-bg"]=e.scrollBtnActiveBg,a["--sp-scroll-track-bg"]=e.scrollTrackBg,a["--sp-toolbar-bg"]=e.toolbarBg,a["--sp-toolbar-border"]=e.toolbarBorder,a["--sp-toolbar-btn-color"]=e.toolbarBtnColor,a["--sp-toolbar-btn-hover-bg"]=e.toolbarBtnHoverBg,a["--sp-toolbar-btn-disabled-color"]=e.toolbarBtnDisabledColor,a["--sp-toolbar-btn-active-color"]=e.toolbarBtnActiveColor,a["--sp-toolbar-text-secondary"]=e.toolbarTextSecondary,a["--sp-toolbar-text-muted"]=e.toolbarTextMuted,a["--sp-toolbar-item-active-bg"]=e.toolbarItemActiveBg,a["--sp-border-default"]=e===na?hi:pi,a}function Ci(e){return e==="number"?0:1}function wi(e,l,n){var i;if(e==null||e.trim()==="")return{kind:"blank"};const o=l??"";if(o===Bn||o==="@")return{kind:"text",text:e};if(xn(o)){if(An(e))return{kind:"number",num:Number(e)};const r=Xn(e,n);return r?{kind:"number",num:r.serial}:{kind:"text",text:In(e,o,n)}}const a=co(o);if(a.kind==="date"||a.kind==="duration"){const r=Number(e);return Number.isFinite(r)?{kind:"number",num:r}:{kind:"text",text:In(e,o,n)}}if(a.kind==="number"){const r=Number(e);if(Number.isFinite(r)){const d=((i=a.sections.find(c=>c.hasDigits))==null?void 0:i.scale)??1;return{kind:"number",num:r*d}}return{kind:"text",text:In(e,o,n)}}return{kind:"text",text:In(e,o,n)}}function Qp(e,l,n,o){if(e.kind==="blank"||l.kind==="blank")return e.kind==="blank"&&l.kind==="blank"?0:e.kind==="blank"?1:-1;const a=Ci(e.kind),i=Ci(l.kind);if(a!==i)return n==="asc"?a-i:i-a;let r;return e.kind==="number"?r=(e.num??0)-(l.num??0):r=(e.text??"").localeCompare(l.text??"",o,{numeric:!0}),n==="asc"?r:-r}function e2(e,l,n){const o=e.map((a,i)=>i);return o.sort((a,i)=>{const r=Qp(e[a],e[i],l,n);return r!==0?r:a-i}),o}function t2(e){if(e.length<2||e[0].kind!=="text")return!1;for(let l=1;l<e.length;l++)if(e[l].kind==="number")return!0;return!1}function Ar(e){return e?JSON.parse(JSON.stringify(e)):null}function vi(e,l,n,o){if(!e)return null;const a=n-l+1,i={...e.range};return o?l<=i.endRow&&(l<=i.startRow&&(i.startRow+=a),i.endRow+=a):n<i.startRow?(i.startRow-=a,i.endRow-=a):l<=i.endRow&&(i.endRow-=Math.min(a,i.endRow-l+1),i.endRow<i.startRow&&(i.endRow=i.startRow)),{range:i,columns:e.columns}}function ki(e,l,n,o){if(!e)return null;const a=n-l+1,i={...e.range},r={};if(o){l<=i.endCol&&(l<=i.startCol&&(i.startCol+=a),i.endCol+=a);for(const d in e.columns){const c=Number(d);r[c>=l?c+a:c]=e.columns[d]}}else{n<i.startCol?(i.startCol-=a,i.endCol-=a):l<=i.endCol&&(i.endCol-=Math.min(a,i.endCol-l+1),i.endCol<i.startCol&&(i.endCol=i.startCol));for(const d in e.columns){const c=Number(d);c>=l&&c<=n||(r[c>n?c-a:c]=e.columns[d])}}return{range:i,columns:r}}function Ei(e,l,n,o){if(l==="row"){const a=e.startRow,i=e.endRow;let r,d;if(i<n)r=a,d=i;else if(a>n+o-1)r=a-o,d=i-o;else if(r=a<n?a:n,d=i>n+o-1?i-o:n-1,d<r)return null;return{...e,startRow:r,endRow:d}}else{const a=e.startCol,i=e.endCol;let r,d;if(i<n)r=a,d=i;else if(a>n+o-1)r=a-o,d=i-o;else if(r=a<n?a:n,d=i>n+o-1?i-o:n-1,d<r)return null;return{...e,startCol:r,endCol:d}}}function Ri(e,l,n,o){if(l==="row"){const a=e.startRow,i=e.endRow;return a>=n?{...e,startRow:a+o,endRow:i+o}:i<n?e:{...e,endRow:i+o}}else{const a=e.startCol,i=e.endCol;return a>=n?{...e,startCol:a+o,endCol:i+o}:i<n?e:{...e,endCol:i+o}}}function n2(e,l,n){var a;const o=n-l+1;for(let i=e.conditionalFormats.length-1;i>=0;i--){const r=e.conditionalFormats[i],d=r.ranges.map(c=>Ei(c,"row",l,o)).filter(c=>c!==null);d.length===0?e.conditionalFormats.splice(i,1):r.ranges=d}(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function o2(e,l,n){var a;const o=n-l+1;for(const i of e.conditionalFormats)i.ranges=i.ranges.map(r=>Ri(r,"row",l,o));(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function l2(e,l,n){var a;const o=n-l+1;for(let i=e.conditionalFormats.length-1;i>=0;i--){const r=e.conditionalFormats[i],d=r.ranges.map(c=>Ei(c,"col",l,o)).filter(c=>c!==null);d.length===0?e.conditionalFormats.splice(i,1):r.ranges=d}(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function r2(e,l,n){var a;const o=n-l+1;for(const i of e.conditionalFormats)i.ranges=i.ranges.map(r=>Ri(r,"col",l,o));(a=e.invalidateConditionalFormatCache)==null||a.call(e)}function Mi(e,l,n,o){var a;for(let i=e.dataValidations.length-1;i>=0;i--){const r=e.dataValidations[i],d=(r.ranges??[]).map(c=>xp(c,l,n,o)).filter(c=>c!==null);d.length===0?e.dataValidations.splice(i,1):r.ranges=d}(a=e.invalidateDataValidationCache)==null||a.call(e)}function Si(e,l,n,o){var a;for(const i of e.dataValidations)i.ranges=(i.ranges??[]).map(r=>Tp(r,l,n,o));(a=e.invalidateDataValidationCache)==null||a.call(e)}function a2(e,l,n,o,a){function i(U,W){var Le;const X=W-U+1,Ce=J(U,W),Ne=[],Ve=[];for(const be in e.cells){const tt=be.indexOf(",");if(tt<0)continue;const k=parseInt(be.substring(0,tt),10),q=parseInt(be.substring(tt+1),10);q>=U&&q<=W?Ve.push(be):q>W&&Ne.push({oldKey:be,newKey:e.cellKey(k,q-X),cell:e.cells[be]})}for(const be of Ve)Reflect.deleteProperty(e.cells,be);for(const be of Ne)Reflect.deleteProperty(e.cells,be.oldKey),e.cells[be.newKey]=be.cell;(Le=e.gcNotes)==null||Le.call(e);const He=e.rowHeights.value,Me=new Array(He.length);for(let be=0;be<U;be++)Me[be]=He[be];for(let be=U;be<He.length-X;be++)Me[be]=He[be+X];for(let be=He.length-X;be<He.length;be++)Me[be]=void 0;e.rowHeights.value=Me,ut(Ce),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(vi(e.getFilter(),U,W,!1)),n2(e,U,W),Mi(e,"row",U,X),e.adjustOutlinesForDeleteRows(U,X)}function r(U,W){const X=W-U+1,Ce=e.rowCount,Ne=e.colCount,{lastRow:Ve}=C();Ve>=U&&Ve+X>=Ce&&e.ensureCapacity(Ne-1,Ce-1+X);const He=e.rowCount,Me=L(U,W),Le=[];for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10),Se=parseInt(k.substring(q+1),10);Se>=U&&Le.push({oldKey:k,newKey:e.cellKey(re,Se+X),cell:e.cells[k],oldRow:Se})}Le.sort((k,q)=>q.oldRow-k.oldRow);for(const k of Le)Reflect.deleteProperty(e.cells,k.oldKey),e.cells[k.newKey]=k.cell;for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(q+1),10);re>=U&&re<=W&&Reflect.deleteProperty(e.cells,k)}const be=e.rowHeights.value,tt=new Array(He);for(let k=0;k<U;k++)tt[k]=be[k];for(let k=U;k<=W;k++)tt[k]=void 0;for(let k=U;k<He;k++)tt[k+X]=be[k];e.rowHeights.value=tt,ut(Me),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(vi(e.getFilter(),U,W,!0)),o2(e,U,W),Si(e,"row",U,X),e.adjustOutlinesForInsertRows(U,X)}function d(U,W){const X=W-U+1,Ce=e.colCount,Ne=e.rowCount,{lastCol:Ve}=C();Ve>=U&&Ve+X>=Ce&&e.ensureCapacity(Ce-1+X,Ne-1);const He=e.colCount,Me=le(U,W),Le=[];for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10),Se=parseInt(k.substring(q+1),10);re>=U&&Le.push({oldKey:k,newKey:e.cellKey(re+X,Se),cell:e.cells[k],oldCol:re})}Le.sort((k,q)=>q.oldCol-k.oldCol);for(const k of Le)Reflect.deleteProperty(e.cells,k.oldKey),e.cells[k.newKey]=k.cell;for(const k in e.cells){const q=k.indexOf(",");if(q<0)continue;const re=parseInt(k.substring(0,q),10);re>=U&&re<=W&&Reflect.deleteProperty(e.cells,k)}const be=e.colWidths.value,tt=new Array(He);for(let k=0;k<U;k++)tt[k]=be[k];for(let k=U;k<=W;k++)tt[k]=100;for(let k=U;k<He;k++)tt[k+X]=be[k];e.colWidths.value=tt,ut(Me),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(ki(e.getFilter(),U,W,!0)),r2(e,U,W),Si(e,"col",U,X),e.adjustOutlinesForInsertCols(U,X)}function c(U,W){var Le;const X=W-U+1,Ce=O(U,W),Ne=[],Ve=[];for(const be in e.cells){const tt=be.indexOf(",");if(tt<0)continue;const k=parseInt(be.substring(0,tt),10),q=parseInt(be.substring(tt+1),10);k>=U&&k<=W?Ve.push(be):k>W&&Ne.push({oldKey:be,newKey:e.cellKey(k-X,q),cell:e.cells[be]})}for(const be of Ve)Reflect.deleteProperty(e.cells,be);for(const be of Ne)Reflect.deleteProperty(e.cells,be.oldKey),e.cells[be.newKey]=be.cell;(Le=e.gcNotes)==null||Le.call(e);const He=e.colWidths.value,Me=new Array(He.length);for(let be=0;be<U;be++)Me[be]=He[be];for(let be=U;be<He.length-X;be++)Me[be]=He[be+X];for(let be=He.length-X;be<He.length;be++)Me[be]=100;e.colWidths.value=Me,ut(Ce),e.freeze.rows=Math.max(0,Math.min(e.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(e.freeze.cols,e.colCount)),e.setFilter(ki(e.getFilter(),U,W,!1)),l2(e,U,W),Mi(e,"col",U,X),e.adjustOutlinesForDeleteCols(U,X)}function C(){let U=-1,W=-1;for(const X in e.cells){const Ce=X.split(",");if(Ce.length===2){const Ne=parseInt(Ce[0],10),Ve=parseInt(Ce[1],10),He=e.cells[X];He&&(He.value!==""||He.styleId!==void 0)&&(Ne>U&&(U=Ne),Ve>W&&(W=Ve))}}for(let X=e.colCount-1;X>=0;X--){const Ce=e.colWidths.value[X];if(Ce!==void 0&&Ce!==100){X>U&&(U=X);break}}for(let X=e.rowCount-1;X>=0;X--)if(e.rowHeights.value[X]!==void 0){X>W&&(W=X);break}return{lastCol:U,lastRow:W}}function h(U,W){const X=e.resolveStyle(e.cells[e.cellKey(U,W)]);return typeof(X==null?void 0:X.numberFormat)=="string"?X.numberFormat:""}function S(U,W,X){for(let Ce=W;Ce<=X;Ce++)if(e.getCellRaw(U,Ce).trim()!=="")return!0;return!1}function m(U){const{startRow:W,endRow:X,startCol:Ce,endCol:Ne}=U;let Ve=Ce,He=Ne;for(;Ve>0&&S(Ve-1,W,X);)Ve--;for(;He<e.colCount-1&&S(He+1,W,X);)He++;return{startRow:W,endRow:X,startCol:Ve,endCol:He}}function M(U){const W=m(U);return W.startCol!==U.startCol||W.endCol!==U.endCol}function E(U,W,X,Ce=U){let Ne,Ve;if(X)Ne=X.startRow,Ve=X.endRow;else{const k=e.selection.value,q=!!k&&k.startRow===k.endRow&&k.startCol===k.endCol;Ne=q||!k?0:k.startRow,Ve=q||!k?e.rowCount-1:k.endRow}let He=-1,Me=-1;for(let k=Ne;k<=Ve;k++){let q=!1;for(let re=U;re<=W;re++)if(e.getCellRaw(re,k).trim()!==""){q=!0;break}q&&(He<0&&(He=k),Me=k)}if(He<0)return null;const Le=[];for(let k=He;k<=Me;k++){const q=e.getCellRaw(Ce,k);Le.push(wi(q,h(Ce,k),e.locale.value))}const be=t2(Le)?He+1:He;let tt=!1;for(let k=He;k<=Me&&!tt;k++)for(let q=U;q<=W;q++){const re=e.cells[e.cellKey(q,k)];if(re&&re.value.startsWith("=")){tt=!0;break}}if(!tt)for(const k in e.merges){const q=e.merges[k];if(q&&q.startCol<=W&&q.endCol>=U&&q.startRow<=Ve&&q.endRow>=Ne){tt=!0;break}}return{firstRow:He,lastRow:Me,sortStart:be,blocked:tt}}function B(U,W){const X=E(U,W);return!!X&&!X.blocked&&X.sortStart<X.lastRow}function G(U,W,X){var Se,Te;const Ce=W??e.selection.value;if(!Ce)return;const Ne=Ce.startCol,Ve=Ce.endCol,He=X??Ne,Me=E(Ne,Ve,{startRow:Ce.startRow,endRow:Ce.endRow},He);if(!Me||Me.blocked||Me.sortStart>=Me.lastRow)return;const Le=Ve-Ne+1,be=Me.lastRow-Me.sortStart+1,tt=[],k=[];for(let pe=Me.sortStart;pe<=Me.lastRow;pe++){const F=new Array(Le);for(let N=Ne;N<=Ve;N++)F[N-Ne]=e.cells[e.cellKey(N,pe)]??null;tt.push(F);const p=e.getCellRaw(He,pe);k.push(wi(p,h(He,pe),e.locale.value))}const q=e2(k,U,e.locale.value);let re=!1;for(let pe=0;pe<be;pe++)if(q[pe]!==pe){re=!0;break}if(re){l.saveUndo();for(let pe=0;pe<be;pe++){const F=tt[q[pe]],p=Me.sortStart+pe;for(let N=Ne;N<=Ve;N++){const bt=e.cellKey(N,p),vt=F[N-Ne],Kt=vt?vt.value:"",Nt=(Se=e.cells[bt])==null?void 0:Se.styleId;Kt!==""||Nt!==void 0?e.cells[bt]={value:Kt,styleId:Nt}:e.delCell(bt)}}Mo();for(let pe=Me.sortStart;pe<=Me.lastRow;pe++)for(let F=Ne;F<=Ve;F++)e.formulaDeps.markDirty(e.cellKey(F,pe));(Te=e.scheduleRender)==null||Te.call(e),H()}}const te=t.ref(!1),ge=t.ref(null);function fe(U){const W=e.selection.value;if(!W||!M(W))return!1;const X=m(W);return ge.value={order:U,originalRange:W,expandedRange:X},te.value=!0,!0}function Ie(U){const W=ge.value;if(!W)return;const{order:X,originalRange:Ce,expandedRange:Ne}=W;te.value=!1,ge.value=null,G(X,U?Ne:Ce,Ce.startCol),Ae.value=X}function me(){te.value=!1,ge.value=null}const Ee=t.ref(!1),Ae=t.ref("asc");function ce(U){Ee.value=U,U&&(l.textColorMenuOpen.value=!1,l.fillColorMenuOpen.value=!1,l.fontSizeMenuOpen.value=!1)}function ae(U){fe(U)||(Ae.value=U,G(U))}function qe(){fe(Ae.value)||G(Ae.value)}function ut(U){Object.keys(e.merges).forEach(W=>Reflect.deleteProperty(e.merges,W));for(const W of U)if(!(W.newRange.startCol>W.newRange.endCol||W.newRange.startRow>W.newRange.endRow)&&(e.merges[W.newAnchorKey]={...W.newRange},W.anchorCell)){const X=W.anchorCell.value,Ce=W.anchorCell.styleId;X===""&&!Ce||(e.cells[W.newAnchorKey]={value:X,styleId:Ce||void 0})}}function J(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const He=e.cells[Ne]?{value:e.cells[Ne].value,styleId:e.cells[Ne].styleId??0}:{value:"",styleId:0},{startCol:Me,endCol:Le}=Ve;let{startRow:be,endRow:tt}=Ve;if(be>W){be-=X,tt-=X,Ce.push({newAnchorKey:e.cellKey(Me,be),newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(tt<U){Ce.push({newAnchorKey:Ne,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(be>=U&&tt<=W||(be>=U&&be<=W&&(be=U),tt>=U&&tt<=W?tt=U-1:tt>W&&(tt-=X),be>tt))continue;const k=Me,q=be,re=e.cellKey(k,q),Te=Ne.split(",").map(Number)[1],pe=Te>=U&&Te<=W||k!==Ve.startCol||q!==Te;Ce.push({newAnchorKey:re,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt},anchorCell:pe?He:void 0})}return Ce}function O(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const He=e.cells[Ne]?{value:e.cells[Ne].value,styleId:e.cells[Ne].styleId??0}:{value:"",styleId:0};let{startCol:Me,endCol:Le}=Ve;const{startRow:be,endRow:tt}=Ve;if(Me>W){Me-=X,Le-=X,Ce.push({newAnchorKey:e.cellKey(Me,be),newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(Le<U){Ce.push({newAnchorKey:Ne,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt}});continue}if(Me>=U&&Le<=W||(Me>=U&&Me<=W&&(Me=U),Le>=U&&Le<=W?Le=U-1:Le>W&&(Le-=X),Me>Le))continue;const k=Me,q=be,re=e.cellKey(k,q),Te=Ne.split(",").map(Number)[0],pe=Te>=U&&Te<=W||k!==Te||q!==Ve.startRow;Ce.push({newAnchorKey:re,newRange:{startCol:Me,startRow:be,endCol:Le,endRow:tt},anchorCell:pe?He:void 0})}return Ce}function L(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;const{startCol:He,endCol:Me}=Ve;let{startRow:Le,endRow:be}=Ve;be<U?Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}):Le<U?(be+=X,Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}})):(Le+=X,be+=X,Ce.push({newAnchorKey:e.cellKey(He,Le),newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}))}return Ce}function le(U,W){const X=W-U+1,Ce=[];for(const Ne in e.merges){const Ve=e.merges[Ne];if(!Ve)continue;let{startCol:He,endCol:Me}=Ve;const{startRow:Le,endRow:be}=Ve;Me<U?Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}):He<U?(Me+=X,Ce.push({newAnchorKey:Ne,newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}})):(He+=X,Me+=X,Ce.push({newAnchorKey:e.cellKey(He,Le),newRange:{startCol:He,startRow:Le,endCol:Me,endRow:be}}))}return Ce}let $e=0;function et(){return $e++,`s_${$e}`}function oe(U){if(!Array.isArray(U))return[];const W=[];for(const X of U){if(!X||typeof X!="object")continue;const Ce=X;if(!Ce.type||!Array.isArray(Ce.ranges)||Ce.ranges.length===0)continue;const Ne=Ce.ranges.filter(Ve=>!!Ve&&typeof Ve.startCol=="number"&&typeof Ve.startRow=="number"&&typeof Ve.endCol=="number"&&typeof Ve.endRow=="number").map(Ve=>({startCol:Math.min(Ve.startCol,Ve.endCol),endCol:Math.max(Ve.startCol,Ve.endCol),startRow:Math.min(Ve.startRow,Ve.endRow),endRow:Math.max(Ve.startRow,Ve.endRow)}));Ne.length&&W.push({...Ce,id:Ce.id||`dv_${W.length}`,ranges:Ne})}return W}function xe(U,W){const X=Math.max(1,(W==null?void 0:W.colCount)??e.colCount),Ce=Math.max(1,(W==null?void 0:W.rowCount)??e.rowCount),Ne=new Array(X).fill(100),Ve=new Array(Ce).fill(void 0);return{id:et(),name:U,cells:{},merges:{},styles:[{}],borders:[{}],selection:{startCol:0,startRow:0,endCol:0,endRow:0},activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:Ne,rowHeights:Ve,colCount:X,rowCount:Ce,freeze:{rows:0,cols:0},filter:null,conditionalFormats:[],dataValidations:[],rowOutlines:[],columnOutlines:[],notes:{}}}const se=t.ref([xe("Sheet1")]),de=t.ref(0);function we(){const U=se.value[de.value];if(!U)return;U.cells={...e.cells},U.merges={...e.merges},U.selection=e.selection.value?{...e.selection.value}:null,U.activeCell={...e.activeCell.value},U.scrollX=e.scrollX.value,U.scrollY=e.scrollY.value,U.colWidths=[...e.colWidths.value],U.rowHeights=[...e.rowHeights.value],U.styles=[...e.styles],U.borders=[...e.borders],U.colCount=e.colCount,U.rowCount=e.rowCount,U.freeze={rows:e.freeze.rows,cols:e.freeze.cols},U.filter=Ar(e.getFilter()),U.conditionalFormats=[...e.conditionalFormats],U.dataValidations=[...e.dataValidations];const W=Object.entries(e.notes).map(([X,Ce])=>[X,{...Ce}]);U.notes=Object.fromEntries(W),U.rowOutlines=e.getRowOutlines(),U.columnOutlines=e.getColumnOutlines()}function Re(U){var tt,k,q;const W=se.value[U];if(!W)return;Object.keys(e.cells).forEach(re=>e.delCell(re)),Object.assign(e.cells,W.cells),Object.keys(e.merges).forEach(re=>Reflect.deleteProperty(e.merges,re)),W.merges&&Object.assign(e.merges,W.merges),e.selection.value=W.selection?{...W.selection}:null,e.activeCell.value={...W.activeCell};const X=e.activeCell.value,Ce=e.selection.value,Ne=e.findMerge(X.col,X.row);Ne&&Ne.anchor===e.cellKey(X.col,X.row)&&(!Ce||Ce.startCol===X.col&&Ce.startRow===X.row&&Ce.endCol===X.col&&Ce.endRow===X.row)&&e.selectCell(X.col,X.row),e.scrollX.value=W.scrollX,e.scrollY.value=W.scrollY,e.colWidths.value=[...W.colWidths],e.rowHeights.value=[...W.rowHeights];const Ve=Math.max(1,W.colCount??e.colCount),He=Math.max(1,W.rowCount??e.rowCount);if((tt=e.setDims)==null||tt.call(e,Ve,He),e.freeze.rows=Math.max(0,Math.min(W.freeze.rows,e.rowCount)),e.freeze.cols=Math.max(0,Math.min(W.freeze.cols,e.colCount)),W.filter){const re=W.filter.range;e.setFilter({range:{startCol:Math.max(0,Math.min(re.startCol,e.colCount-1)),endCol:Math.max(0,Math.min(re.endCol,e.colCount-1)),startRow:Math.max(0,Math.min(re.startRow,e.rowCount-1)),endRow:Math.max(0,Math.min(re.endRow,e.rowCount-1))},columns:{...W.filter.columns}},!0)}else e.setFilter(null,!0);e.syncStyles(W.styles),e.syncBorders(W.borders??[{}]);const Me=W.conditionalFormats?W.conditionalFormats.map(re=>({...re,ranges:re.ranges.map(Se=>({...Se}))})):[];e.conditionalFormats.splice(0,e.conditionalFormats.length,...Me),(k=e.invalidateConditionalFormatCache)==null||k.call(e);const Le=oe(W.dataValidations);e.dataValidations.splice(0,e.dataValidations.length,...Le),(q=e.invalidateDataValidationCache)==null||q.call(e);const be=Xa(W.notes);Object.keys(e.notes).forEach(re=>{e.notes[re]=void 0}),Object.assign(e.notes,be),e.syncOutlines(W.rowOutlines,W.columnOutlines),de.value=U}function Ke(U){U===de.value||U<0||U>=se.value.length||(e.cancelEdit(),we(),Re(U))}function We(U){return l.saveUndo(),e.cancelEdit(),we(),se.value.push(xe(U??`Sheet${se.value.length+1}`)),Re(se.value.length-1),se.value.length-1}function rt(U){return se.value.length<=1||(l.saveUndo(),e.cancelEdit(),se.value.splice(U,1),Re(Math.min(U,se.value.length-1))),de.value}function je(U,W){se.value[U]&&W.trim()&&(l.saveUndo(),se.value[U].name=W.trim())}function A(U){l.saveUndo(),e.cancelEdit(),we();const W=se.value[U];if(!W)return U;let X=W.name;const Ce=X.match(/^(.*?)\s*\((\d+)\)$/);let Ne=Ce?parseInt(Ce[2],10)+1:2;Ce&&(X=Ce[1]);let Ve=`${X} (${Ne})`;const He=new Set(se.value.map(Le=>Le.name));for(;He.has(Ve);)Ne++,Ve=`${X} (${Ne})`;const Me={id:et(),name:Ve,cells:{...W.cells},merges:W.merges?{...W.merges}:{},styles:[...W.styles],borders:W.borders?[...W.borders]:[{}],selection:W.selection?{...W.selection}:null,activeCell:W.activeCell?{...W.activeCell}:{col:0,row:0},scrollX:W.scrollX,scrollY:W.scrollY,colWidths:[...W.colWidths],rowHeights:[...W.rowHeights],colCount:W.colCount,rowCount:W.rowCount,freeze:{...W.freeze},filter:Ar(W.filter),conditionalFormats:W.conditionalFormats?W.conditionalFormats.map(Le=>({...Le})):[],dataValidations:oe(W.dataValidations),rowOutlines:W.rowOutlines?W.rowOutlines.map(Le=>({...Le})):[],columnOutlines:W.columnOutlines?W.columnOutlines.map(Le=>({...Le})):[],notes:Xa(W.notes)};return se.value.splice(U+1,0,Me),Re(U+1),U+1}function K(U,W){var Ve;const X=U+W;if(X<0||X>=se.value.length)return;l.saveUndo();const Ce=de.value,Ne=se.value.splice(U,1)[0];se.value.splice(X,0,Ne),Ce===U?de.value=X:U<Ce&&X>=Ce?de.value=Ce-1:U>Ce&&X<=Ce&&(de.value=Ce+1),(Ve=e.scheduleRender)==null||Ve.call(e)}const $=t.computed(()=>se.value.length);let V="";const x=n;function H(){we();const U=se.value.map(X=>{const Ce={};for(const[Me,Le]of Object.entries(X.cells))Ce[Me]={value:Le.value},Le.styleId&&Le.styleId>0&&(Ce[Me].styleId=Le.styleId),Le.noteId&&(Ce[Me].noteId=Le.noteId);const Ne={name:X.name,cells:Ce};X.styles&&X.styles.length>1&&(Ne.styles=[...X.styles]),X.borders&&X.borders.length>1&&(Ne.borders=[...X.borders]),X.merges&&Object.keys(X.merges).length&&(Ne.merges={...X.merges});const Ve={};for(let Me=0;Me<X.colWidths.length;Me++)X.colWidths[Me]!==100&&(Ve[Me]=X.colWidths[Me]);Object.keys(Ve).length&&(Ne.colWidths=Ve);const He={};for(let Me=0;Me<X.rowHeights.length;Me++){const Le=X.rowHeights[Me];Le!=null&&(He[Me]=Le)}return Object.keys(He).length&&(Ne.rowHeights=He),(X.freeze.rows!==0||X.freeze.cols!==0)&&(Ne.freeze={rows:X.freeze.rows,cols:X.freeze.cols}),X.filter&&(Ne.filter=Ar(X.filter)),X.conditionalFormats&&X.conditionalFormats.length&&(Ne.conditionalFormats=X.conditionalFormats.map(Me=>({...Me}))),X.dataValidations&&X.dataValidations.length&&(Ne.dataValidations=X.dataValidations.map(Me=>({...Me,ranges:Me.ranges.map(Le=>({...Le}))}))),X.notes&&Object.keys(X.notes).length&&(Ne.notes=Object.fromEntries(Object.entries(X.notes).map(([Me,Le])=>[Me,{...Le}]))),X.rowOutlines&&X.rowOutlines.length&&(Ne.rowOutlines=X.rowOutlines.map(Me=>({...Me}))),X.columnOutlines&&X.columnOutlines.length&&(Ne.columnOutlines=X.columnOutlines.map(Me=>({...Me}))),Ne}),W=JSON.stringify(U);W!==V&&(V=W,x.value=U,a&&(a.value=W))}e.emitModelData=H;let z=!1;function Y(){z||(z=!0,Promise.resolve().then(()=>{z=!1,H()}))}const ve=t.computed(()=>e.props.theme==="dark"?na:Ki),ze=t.computed(()=>Jp(ve.value,e.props.width,e.props.height,Do)),it=t.computed(()=>{const U={};for(const[W,X]of Object.entries(ze.value))W.startsWith("--")&&(U[W]=X);return U}),Fe=t.ref(null),v=t.ref(null),Z=t.ref(null),lt=t.ref(null),wt=t.ref(null),ft=t.reactive({w:800,h:600});e.viewSize&&t.watch(ft,U=>{e.viewSize&&(e.viewSize.w=U.w,e.viewSize.h=U.h)},{deep:!0});const At=48,Ft=28,Vt=11,wn=()=>At+e.getOutlineGutterSize("row"),an=()=>Ft+e.getOutlineGutterSize("column"),sn=t.computed(()=>Math.max(0,e.totalWidth.value-Math.max(0,ft.w-wn()-Vt))),mn=t.computed(()=>Math.max(0,e.totalHeight.value-Math.max(0,ft.h-an()-Vt)));function Dt(U,W){const X=Math.max(0,ft.w-wn()-Vt),Ce=Math.max(0,ft.h-an()-Vt),Ne=U??e.scrollX.value,Ve=W??e.scrollY.value,He=40,Me=Math.max(0,e.totalWidth.value-X),Le=Math.max(0,e.totalHeight.value-Ce);if(Ne>=Me-He&&Ne>e.scrollX.value||Ve>=Le-He&&Ve>e.scrollY.value){const be=Math.max(0,Math.ceil((Ne+X)/100)+2),tt=Math.max(0,Math.ceil((Ve+Ce)/24)+2);e.ensureCapacity(be,tt)}e.scrollX.value=Math.max(0,Math.min(Ne,Math.max(0,e.totalWidth.value-X))),e.scrollY.value=Math.max(0,Math.min(Ve,Math.max(0,e.totalHeight.value-Ce)))}e.clampScroll=Dt;function Jt(){var U;return typeof window>"u"?!1:!((U=window.matchMedia)!=null&&U.call(window,"(hover: none) and (pointer: coarse)").matches)}function Qt(U=!1){t.nextTick(()=>{const W=lt.value;if(W){if(!e.editingCell.value&&!Jt()){document.activeElement===W&&W.blur();return}W.focus({preventScroll:!0}),U&&W.select()}})}function $n(){Qt()}function Zt(){var W;const U=e.selection.value;if(U){l.saveUndo();for(let X=U.startRow;X<=U.endRow;X++)e.rowHeights.value[X]=void 0;(W=e.scheduleRender)==null||W.call(e),H()}}function Vn(){var W;const U=e.selection.value;if(U){l.saveUndo();for(let X=U.startCol;X<=U.endCol;X++)e.colWidths.value[X]=100;(W=e.scheduleRender)==null||W.call(e),H()}}return{deleteRows:i,insertRows:r,insertCols:d,deleteCols:c,sortSelectedColumns:G,canSortColumns:B,sortMenuOpen:Ee,cachedSortOrder:Ae,onSortMenuToggle:ce,onSortChange:ae,applyCachedSort:qe,sortConfirmOpen:te,prepareSortConfirmation:fe,confirmSort:Ie,cancelSortConfirmation:me,sheets:se,activeSheetIndex:de,saveSheet:we,loadSheet:Re,switchSheet:Ke,addSheet:We,removeSheet:rt,renameSheet:je,dupSheet:A,moveSheet:K,sheetCount:$,mkSheet:xe,emitModelData:H,scheduleOptEmit:Y,themeColors:ve,outerStyle:ze,toolbarThemeVars:it,wrapperRef:Fe,canvasRef:v,freezeCanvasRef:Z,editInputRef:lt,formulaBarRef:wt,viewSize:ft,maxScrollX:sn,maxScrollY:mn,clampScroll:Dt,canFocusHiddenEditor:Jt,focusEditInput:Qt,onCanvasFocus:$n,resetRowHeight:Zt,resetColWidth:Vn,modelData:x}}function Ni(e,l){let n=-1,o=-1;const a=(r,d)=>{Number.isInteger(r)&&r>=0&&r>n&&(n=r),Number.isInteger(d)&&d>=0&&d>o&&(o=d)},i=r=>{r&&a(Math.max(r.startCol,r.endCol),Math.max(r.startRow,r.endRow))};for(const r of Object.keys(e.cells)){const d=r.indexOf(",");d<0||a(Number(r.slice(0,d)),Number(r.slice(d+1)))}for(const r of Object.values(e.merges??{}))i(r);if(e.colWidths)for(const[r,d]of Object.entries(e.colWidths)){const c=Number(r);Number.isInteger(c)&&c>=0&&d>=30&&a(c,-1)}if(e.rowHeights)for(const[r,d]of Object.entries(e.rowHeights)){const c=Number(r);Number.isInteger(c)&&c>=0&&d!=null&&d>=24&&a(-1,c)}for(const r of e.conditionalFormats??[])for(const d of r.ranges??[])i(d);for(const r of e.dataValidations??[])for(const d of r.ranges??[])i(d);e.filter&&i(e.filter.range);for(const r of e.rowOutlines??[])a(-1,r.end);for(const r of e.columnOutlines??[])a(r.end,-1);return{colCount:Math.max(1,l.colCount,n+1),rowCount:Math.max(1,l.rowCount,o+1)}}function Bi(e){return!!e&&e.width!==void 0&&e.width>0}function Pt(e,l,n,o){const a=Bi(e),i=Bi(l);if(!a&&!i)return;if(a&&!i)return e;if(!a&&i)return l;const r=!!e.owner,d=!!l.owner;if(r&&!d)return e;if(d&&!r)return l;const c=e.width??0,C=l.width??0;return c>C?e:C>c?l:e}function xi(e,l){if(!e||typeof e!="object")return null;const n=e,o=n.columns??{},a=Object.keys(o).map(r=>Number(r)).filter(r=>!Number.isNaN(r));if(!n.range||typeof n.range.startRow!="number"){const r=a.length?Math.min(...a):0,d=a.length?Math.max(...a):0;let c=0;for(const C in l){const h=C.indexOf(",");if(h<0)continue;const S=parseInt(C.substring(h+1),10);S>c&&(c=S)}return{range:{startCol:r,startRow:0,endCol:d,endRow:Math.max(0,c)},columns:o}}const i={...n.range};for(const r of a)r<i.startCol&&(i.startCol=r),r>i.endCol&&(i.endCol=r);return{range:i,columns:o}}function i2(e,l,n,o,a){let i=!1,r=null,d=1,c,C=()=>{},h=()=>{},S=()=>{};function m(){i||(i=!0,requestAnimationFrame(()=>{i=!1,O(),L()}))}e.scheduleRender=m;function M(u){const{frozenColumnsWidth:y}=e.getFrozenMetrics(),D=y>0&&u<ce()+y?u-ce():u-ce()+e.scrollX.value;return e.hitCol(D)}function E(u){const{frozenRowsHeight:y}=e.getFrozenMetrics(),D=y>0&&u<ae()+y?u-ae():u-ae()+e.scrollY.value;return e.hitRow(D)}let B=gi(e.props.theme);function G(u,y,D,j,T,P,ee,Q){const ue=va(Q,P);if(!ue){u.fillStyle=ee,D===T?u.fillRect(y,D,j-y,P):u.fillRect(y,D,P,T-D);return}if(u.save(),u.strokeStyle=ee,u.lineWidth=P,u.lineCap=Q==="dotted"?"round":"butt",u.setLineDash(ue),u.beginPath(),D===T){const w=D+P/2;u.moveTo(y,w),u.lineTo(j,w)}else{const w=y+P/2;u.moveTo(w,D),u.lineTo(w,T)}u.stroke(),u.setLineDash([]),u.restore()}const te=14,ge=9,fe=16,Ie=Math.min(ge-1,9);function me(u){return 0}const Ee=()=>me(),Ae=()=>me(),ce=()=>52+Ee(),ae=()=>24+Ae();function qe(u,y){return fe+2+(y-u.level)*ge}function ut(u,y){return 3+(y-u.level)*ge}function J(u,y){const D=new Int8Array(y).fill(-1);if(!u.length)return D;const j=[...u].sort((P,ee)=>P.start-ee.start),T=new Map;j.forEach((P,ee)=>T.set(P.id,ee%2));for(const P of j){const ee=T.get(P.id),Q=Math.min(P.end,y-1);for(let ue=Math.max(0,P.start);ue<=Q;ue++)D[ue]===-1&&(D[ue]=ee)}return D}function O(){const u=o.wrapperRef.value,y=o.canvasRef.value;if(!u||!y||(r=y.getContext("2d"),!r))return;d=window.devicePixelRatio||1;const D=u.getBoundingClientRect(),j=D.width,T=D.height;o.viewSize.w=j,o.viewSize.h=T,y.width=j*d,y.height=T*d,y.style.width=j+"px",y.style.height=T+"px",r.setTransform(d,0,0,d,0,0);const P=e.scrollX.value,ee=e.scrollY.value,Q=52,ue=24,w=Ee(),s=Ae(),f=Q+w,b=ue+s,R=o.themeColors.value,I=e.getFilter(),ne=e.colPositions.value,ie=e.rowPositions.value,ye=J(e.getRowOutlines(),e.rowCount),ke=J(e.getColumnOutlines(),e.colCount),{frozenRowsHeight:Ue,frozenColumnsWidth:_e}=e.getFrozenMetrics(),Xe=f+_e,Qe=b+Ue,ht=Math.max(0,j-f-11-_e),Ct=Math.max(0,T-b-11-Ue),qt=Math.max(0,e.freeze.cols-1),$t=Math.max(0,e.freeze.rows-1),Yt=Math.max(e.freeze.cols,e.hitCol(_e+P));let nn=Yt;for(let _=Yt;_<e.colCount&&!(f+ne[_]-P>=j);_++)nn=_;const un=Math.max(e.freeze.rows,e.hitRow(Ue+ee));let oo=un;for(let _=un;_<e.rowCount&&!(b+ie[_]-ee>=T);_++)oo=_;let hn=Yt,on=nn,Un=un,Rn=oo;_e>0&&(hn=0,on=Math.max(on,qt)),Ue>0&&(Un=0,Rn=Math.max(Rn,$t));let _o=hn,Pn=Un;for(const _ in e.merges){const Oe=e.merges[_];Oe&&(Oe.startRow>Rn||Oe.endRow<Un||Oe.startCol>on||Oe.endCol<hn||(Oe.startCol<_o&&(_o=Oe.startCol),Oe.startRow<Pn&&(Pn=Oe.startRow)))}const Ho=new Array(Pn);for(let _=Pn;_<=Rn;_++)Ho[_]=ie[_+1]-ie[_];r.fillStyle=R.bg,r.fillRect(0,0,j,T),r.fillStyle=R.gridBg,r.fillRect(f,b,j-f,T-b);const St=e.selection.value,gt=e.editingCell.value;C=(_,Oe,Ge,yt,It,jt)=>{const Rt=e.dataValidations.length>0;for(let Be=yt;Be<=It;Be++)if(!e.isRowCollapsed(Be))for(let Pe=Oe;Pe<=Ge;Pe++){if(e.isColumnCollapsed(Pe)||e.findMerge(Pe,Be))continue;const Ze=e.cellToScreenRect(Be,Pe),Ye=Ze.x,dt=Ze.y,st=Ze.width,nt=Ze.height;if(Ye+st<f||dt+nt<b||Ye>j||dt>T)continue;const Ht=e.findHighlight?e.findHighlight(Pe,Be):null,Wt=e.resolveStyle(e.cells[e.cellKey(Pe,Be)]),Mt=typeof(Wt==null?void 0:Wt.backgroundColor)=="string"?Wt.backgroundColor:"";Mt&&(_.fillStyle=Mt,_.fillRect(Ye,dt,st,nt));const ct=e.resolveConditionalFormat(Pe,Be);if(ct!=null&&ct.backgroundColor&&(_.fillStyle=ct.backgroundColor,_.fillRect(Ye,dt,st,nt)),Ht&&(_.fillStyle=Ht==="active"?R.findActiveBg:R.findMatchBg,_.fillRect(Ye,dt,st,nt)),e.isSelected(Pe,Be)&&(_.fillStyle=R.selectionBg,e.selectionMode.value==="row"||e.selectionMode.value==="col"?_.fillRect(Ye,dt,(ne[Pe+1]??0)-ne[Pe],jt[Be]):_.fillRect(Ye,dt,st,nt)),e.activeCell.value.col===Pe&&e.activeCell.value.row===Be&&(_.strokeStyle=R.activeCellBorder,_.lineWidth=2,_.strokeRect(Ye+1,dt+1,st-2,nt-2)),Ht==="active"&&(_.strokeStyle=R.findActiveBg,_.lineWidth=2,_.strokeRect(Ye+1,dt+1,st-2,nt-2)),_.strokeStyle=R.gridLine,_.lineWidth=.5,_.strokeRect(Ye+.25,dt+.25,st-.5,nt-.5),!(gt&>.col===Pe&>.row===Be)){const De=e.resolveStyle(e.cells[e.cellKey(Pe,Be)]),he=e.getCellValue(Pe,Be),ot=typeof(De==null?void 0:De.numberFormat)=="string"?De.numberFormat:"",Je=he?In(he,ot,e.locale.value):"";if(Je){const mt=e.cellFontSize(Pe,Be),kt=typeof(De==null?void 0:De.fontFamily)=="string"&&De.fontFamily?De.fontFamily:Vo,Tt=(De==null?void 0:De.fontWeight)==="bold"||(ct==null?void 0:ct.fontWeight)==="bold"?"bold":"normal",gn=(De==null?void 0:De.fontStyle)==="italic"||(ct==null?void 0:ct.fontStyle)==="italic"?"italic":"normal",qn=(De==null?void 0:De.underline)==="underline"||(ct==null?void 0:ct.underline)==="underline",lo=(De==null?void 0:De.strikethrough)==="line-through"||(ct==null?void 0:ct.strikethrough)==="line-through",bn=(ct==null?void 0:ct.color)||(typeof(De==null?void 0:De.color)=="string"?De.color:""),On=typeof(De==null?void 0:De.textAlign)=="string"?De.textAlign:br(he,ot)?"right":"left",yn=typeof(De==null?void 0:De.verticalAlign)=="string"?De.verticalAlign:"top";_.fillStyle=bn||R.cellText,_.font=`${gn} ${Tt} ${mt}px ${kt}`,_.textBaseline="alphabetic",_.save(),_.beginPath(),_.rect(Ye+5,dt+1,st-10,nt-2),_.clip();const ro=(De==null?void 0:De.wrap)==="wrap";let ln=st-10;I&&Be===I.range.startRow&&Pe>=I.range.startCol&&Pe<=I.range.endCol&&(ln=st-10-mn);let Mn=Je;const Sn=!ro&&da(ot),Yn=Je===Tl||ua(he,ot);if(Yn||Sn){if(Yn){const Uo=Math.max(1,_.measureText("#").width),xl=Math.max(1,Math.floor(ln/Uo));Mn="#".repeat(xl)}else if(e.getWrappedLines(_,Je,1e9,!1).some(vo=>vo&&_.measureText(vo).width>ln)){const vo=Math.max(1,_.measureText("#").width),cl=Math.max(1,Math.floor(ln/vo));Mn="#".repeat(cl)}}const fn=e.getWrappedLines(_,Mn,ln,ro),{ascent:wo,descent:sl}=e.measureFontMetrics(kt,mt,Tt,gn),dr=wo+sl,O2=fn.length*dr;let ur;yn==="middle"?ur=dt+(nt-O2)/2+wo:yn==="bottom"?ur=dt+nt-e.BASE_CELL_VPAD-sl-(fn.length-1)*dr:ur=dt+e.BASE_CELL_VPAD+wo;for(let Uo=0;Uo<fn.length;Uo++){const xl=fn[Uo],vo=ur+Uo*dr,cl=_.measureText(xl);let To;if(On==="center"?To=Ye+st/2-cl.width/2:On==="right"?To=Ye+st-5-cl.width:To=Ye+5,_.fillText(xl,To,vo),qn&&(_.strokeStyle=bn||R.cellText,_.lineWidth=1,_.beginPath(),_.moveTo(To,vo+sl+1),_.lineTo(To+cl.width,vo+sl+1),_.stroke()),lo){_.strokeStyle=bn||R.cellText,_.lineWidth=1;const Di=vo-wo+dr*.42;_.beginPath(),_.moveTo(To,Di),_.lineTo(To+cl.width,Di),_.stroke()}}_.restore()}}if(I&&Be===I.range.startRow&&Pe>=I.range.startCol&&Pe<=I.range.endCol&&Ne(_,Ye,dt,st,nt,$a(I.columns[Pe]),R),Rt&&e.getListValidation(Be,Pe)){const De=e.activeCell.value.col===Pe&&e.activeCell.value.row===Be;Zt(_,Ye,dt,st,nt,De||e.isSelected(Pe,Be),R)}e.hasNote(Be,Pe)&&Vn(_,Ye,dt,st,nt)}};const Et=(_,Oe,Ge)=>{const yt=e.findMerge(_,Oe);return yt?e.getCellBorderSide(e.cells[yt.anchor],Ge):e.getCellBorderSide(e.cells[e.cellKey(_,Oe)],Ge)};h=(_,Oe,Ge,yt,It,jt)=>{_.fillStyle=B;for(let Rt=yt;Rt<=It;Rt++)if(!e.isRowCollapsed(Rt))for(let Be=Oe;Be<=Ge;Be++){if(e.isColumnCollapsed(Be)||e.findMerge(Be,Rt))continue;const at=e.cellToScreenRect(Rt,Be),Ze=at.x,Ye=at.y,dt=at.width,st=at.height;if(Ze+dt<f||Ye+st<b||Ze>j||Ye>T)continue;const nt=e.cells[e.cellKey(Be,Rt)],Ht={top:e.getCellBorderSide(nt,"top"),right:e.getCellBorderSide(nt,"right"),bottom:e.getCellBorderSide(nt,"bottom"),left:e.getCellBorderSide(nt,"left")},Wt={top:Et(Be,Rt-1,"bottom"),left:Et(Be-1,Rt,"right"),bottom:Et(Be,Rt+1,"top"),right:Et(Be+1,Rt,"left")},Mt=Pt(Wt.top,Ht.top),ct=Pt(Wt.left,Ht.left),De=Pt(Ht.bottom,Wt.bottom),he=Pt(Ht.right,Wt.right),ot=(Mt==null?void 0:Mt.width)??0,Je=(ct==null?void 0:ct.width)??0,mt=(De==null?void 0:De.width)??0,kt=(he==null?void 0:he.width)??0;ot>0&&G(_,Ze,Ye,Ze+dt,Ye,ot,(Mt==null?void 0:Mt.color)||B,rn(Mt==null?void 0:Mt.style)),mt>0&&G(_,Ze,Ye+st-mt,Ze+dt,Ye+st-mt,mt,(De==null?void 0:De.color)||B,rn(De==null?void 0:De.style)),Je>0&&G(_,Ze,Ye,Ze,Ye+st,Je,(ct==null?void 0:ct.color)||B,rn(ct==null?void 0:ct.style)),kt>0&&G(_,Ze+dt-kt,Ye,Ze+dt-kt,Ye+st,kt,(he==null?void 0:he.color)||B,rn(he==null?void 0:he.style));const Tt=Be>0&&e.isColumnCollapsed(Be-1),gn=Be<e.colCount-1&&e.isColumnCollapsed(Be+1),qn=Rt>0&&e.isRowCollapsed(Rt-1),lo=Rt<e.rowCount-1&&e.isRowCollapsed(Rt+1),bn=Be<e.freeze.cols&&(()=>{try{const yn=_.canvas;return yn?String(yn.className||"")==="grid-canvas":!1}catch{return!1}})(),On=Rt<e.freeze.rows&&(()=>{try{const yn=_.canvas;return yn?String(yn.className||"")==="grid-canvas":!1}catch{return!1}})();ot>0&&Je>0&&!Tt&&!qn&&(_.fillStyle=(Mt==null?void 0:Mt.color)||(ct==null?void 0:ct.color)||B,_.fillRect(Ze-Je,Ye-ot,Je,ot)),ot>0&&kt>0&&!gn&&!qn&&!bn&&(_.fillStyle=(Mt==null?void 0:Mt.color)||(he==null?void 0:he.color)||B,_.fillRect(Ze+dt,Ye-ot,kt,ot)),mt>0&&Je>0&&!Tt&&!lo&&!On&&(_.fillStyle=(De==null?void 0:De.color)||(ct==null?void 0:ct.color)||B,_.fillRect(Ze-Je,Ye+st,Je,mt)),mt>0&&kt>0&&!gn&&!lo&&!bn&&!On&&(_.fillStyle=(De==null?void 0:De.color)||(he==null?void 0:he.color)||B,_.fillRect(Ze+dt,Ye+st,kt,mt))}};const Kn=(_,Oe,Ge,yt,It,jt,Rt)=>{const Be=e.resolveStyle(e.cells[e.cellKey(Oe,Ge)]),Pe=e.getCellValue(Oe,Ge),at=typeof(Be==null?void 0:Be.numberFormat)=="string"?Be.numberFormat:"",Ze=Pe?In(Pe,at,e.locale.value):"";if(!Ze||yt-10<=0||It-2<=0)return;const dt=e.cellFontSize(Oe,Ge),st=typeof(Be==null?void 0:Be.fontFamily)=="string"&&Be.fontFamily?Be.fontFamily:Vo,nt=e.resolveConditionalFormat(Oe,Ge),Ht=(Be==null?void 0:Be.fontWeight)==="bold"||(nt==null?void 0:nt.fontWeight)==="bold"?"bold":"normal",Wt=(Be==null?void 0:Be.fontStyle)==="italic"||(nt==null?void 0:nt.fontStyle)==="italic"?"italic":"normal",Mt=(Be==null?void 0:Be.underline)==="underline"||(nt==null?void 0:nt.underline)==="underline",ct=(Be==null?void 0:Be.strikethrough)==="line-through"||(nt==null?void 0:nt.strikethrough)==="line-through",De=(nt==null?void 0:nt.color)||(typeof(Be==null?void 0:Be.color)=="string"?Be.color:""),he=typeof(Be==null?void 0:Be.textAlign)=="string"?Be.textAlign:br(Pe,at)?"right":"left",ot=typeof(Be==null?void 0:Be.verticalAlign)=="string"?Be.verticalAlign:"top";_.fillStyle=De||R.cellText,_.font=`${Wt} ${Ht} ${dt}px ${st}`,_.textBaseline="alphabetic",_.save(),_.beginPath(),_.rect(jt+5,Rt+1,yt-10,It-2),_.clip();const Je=(Be==null?void 0:Be.wrap)==="wrap",mt=yt-10;let kt=Ze;const Tt=!Je&&da(at),gn=Ze===Tl||ua(Pe,at);if(gn||Tt){if(gn){const ln=Math.max(1,_.measureText("#").width),Mn=Math.max(1,Math.floor(mt/ln));kt="#".repeat(Mn)}else if(e.getWrappedLines(_,Ze,1e9,!1).some(Sn=>Sn&&_.measureText(Sn).width>mt)){const Sn=Math.max(1,_.measureText("#").width),Yn=Math.max(1,Math.floor(mt/Sn));kt="#".repeat(Yn)}}const qn=e.getWrappedLines(_,kt,mt,Je),{ascent:lo,descent:bn}=e.measureFontMetrics(st,dt,Ht,Wt),On=lo+bn,yn=qn.length*On;let ro;ot==="middle"?ro=Rt+(It-yn)/2+lo:ot==="bottom"?ro=Rt+It-e.BASE_CELL_VPAD-bn-(qn.length-1)*On:ro=Rt+e.BASE_CELL_VPAD+lo;for(let ln=0;ln<qn.length;ln++){const Mn=qn[ln],Sn=ro+ln*On,Yn=_.measureText(Mn);let fn;if(he==="center"?fn=jt+yt/2-Yn.width/2:he==="right"?fn=jt+yt-5-Yn.width:fn=jt+5,_.fillText(Mn,fn,Sn),Mt&&(_.strokeStyle=De||R.cellText,_.lineWidth=1,_.beginPath(),_.moveTo(fn,Sn+bn+1),_.lineTo(fn+Yn.width,Sn+bn+1),_.stroke()),ct){_.strokeStyle=De||R.cellText,_.lineWidth=1;const wo=Sn-lo+On*.42;_.beginPath(),_.moveTo(fn,wo),_.lineTo(fn+Yn.width,wo),_.stroke()}}_.restore()},Gn=(_,Oe,Ge,yt,It,jt,Rt,Be)=>{const Pe=Oe.startCol,at=Oe.endCol,Ze=Oe.startRow,Ye=Oe.endRow,dt=yt,st=jt,nt=Rt&&at+1===e.freeze.cols&&e.freeze.cols<e.colCount&&e.isColumnCollapsed(e.freeze.cols),Ht=Rt&&at>=e.freeze.cols||nt,Wt=Be&&Ye+1===e.freeze.rows&&e.freeze.rows<e.rowCount&&e.isRowCollapsed(e.freeze.rows),Mt=Be&&Ye>=e.freeze.rows||Wt,ct=e.cells[e.cellKey(Pe,Ze)],De={top:e.getCellBorderSide(ct,"top"),right:e.getCellBorderSide(ct,"right"),bottom:e.getCellBorderSide(ct,"bottom"),left:e.getCellBorderSide(ct,"left")};_.fillStyle=B;for(let he=Pe;he<=at;he++){if(Rt&&he>=e.freeze.cols||e.isSameMergeInternal(he,Ze-1,he,Ze))continue;const ot=Et(he,Ze-1,"bottom"),Je=Pt(ot,De.top);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.cols?Q+ne[he]:Q+ne[he]-P,kt=(ne[he+1]??0)-ne[he];G(_,mt,dt,mt+kt,dt,Je.width,Je.color||B,rn(Je.style))}}if(!Mt)for(let he=Pe;he<=at;he++){if(Rt&&he>=e.freeze.cols||e.isSameMergeInternal(he,Ye,he,Ye+1))continue;const ot=Et(he,Ye+1,"top"),Je=Pt(De.bottom,ot);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.cols?Q+ne[he]:Q+ne[he]-P,kt=(ne[he+1]??0)-ne[he],Tt=dt+st-Je.width;G(_,mt,Tt,mt+kt,Tt,Je.width,Je.color||B,rn(Je.style))}}for(let he=Ze;he<=Ye;he++){if(Be&&he>=e.freeze.rows||e.isSameMergeInternal(Pe-1,he,Pe,he))continue;const ot=Et(Pe-1,he,"right"),Je=Pt(ot,De.left);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.rows?ue+ie[he]:ue+ie[he]-ee,kt=ie[he+1]-ie[he];G(_,Ge,mt,Ge,mt+kt,Je.width,Je.color||B,rn(Je.style))}}if(!Ht)for(let he=Ze;he<=Ye;he++){if(Be&&he>=e.freeze.rows||e.isSameMergeInternal(at,he,at+1,he))continue;const ot=Et(at+1,he,"left"),Je=Pt(De.right,ot);if(Je&&Je.width&&Je.width>0){const mt=he<e.freeze.rows?ue+ie[he]:ue+ie[he]-ee,kt=ie[he+1]-ie[he],Tt=Ge+It-Je.width;G(_,Tt,mt,Tt,mt+kt,Je.width,Je.color||B,rn(Je.style))}}{const he=e.isSameMergeInternal(Pe,Ze-1,Pe,Ze)?De.top:Pt(Et(Pe,Ze-1,"bottom"),De.top),ot=e.isSameMergeInternal(Pe-1,Ze,Pe,Ze)?De.left:Pt(Et(Pe-1,Ze,"right"),De.left),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=Pe>0&&e.isColumnCollapsed(Pe-1),Tt=Ze>0&&e.isRowCollapsed(Ze-1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge-mt,yt-Je,mt,Je))}if(!Ht){const he=e.isSameMergeInternal(at,Ze-1,at,Ze)?De.top:Pt(Et(at,Ze-1,"bottom"),De.top),ot=e.isSameMergeInternal(at,Ze,at+1,Ze)?De.right:Pt(De.right,Et(at+1,Ze,"left")),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=at<e.colCount-1&&e.isColumnCollapsed(at+1),Tt=Ze>0&&e.isRowCollapsed(Ze-1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge+It,yt-Je,mt,Je))}if(!Mt){const he=e.isSameMergeInternal(Pe,Ye,Pe,Ye+1)?De.bottom:Pt(De.bottom,Et(Pe,Ye+1,"top")),ot=e.isSameMergeInternal(Pe-1,Ye,Pe,Ye)?De.left:Pt(Et(Pe-1,Ye,"right"),De.left),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=Pe>0&&e.isColumnCollapsed(Pe-1),Tt=Ye<e.rowCount-1&&e.isRowCollapsed(Ye+1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge-mt,yt+jt,mt,Je))}if(!Ht&&!Mt){const he=e.isSameMergeInternal(at,Ye,at,Ye+1)?De.bottom:Pt(De.bottom,Et(at,Ye+1,"top")),ot=e.isSameMergeInternal(at,Ye,at+1,Ye)?De.right:Pt(De.right,Et(at+1,Ye,"left")),Je=(he==null?void 0:he.width)??0,mt=(ot==null?void 0:ot.width)??0,kt=at<e.colCount-1&&e.isColumnCollapsed(at+1),Tt=Ye<e.rowCount-1&&e.isRowCollapsed(Ye+1);Je>0&&mt>0&&!kt&&!Tt&&(_.fillStyle=(he==null?void 0:he.color)||(ot==null?void 0:ot.color)||B,_.fillRect(Ge+It,yt+jt,mt,Je))}};S=(_,Oe,Ge,yt,It)=>{var at,Ze;const jt=Oe+yt,Rt=Ge+It,Be=Oe<Xe,Pe=Ge<Qe;for(const Ye in e.merges){const dt=e.merges[Ye];if(!dt)continue;const st=dt.startCol,nt=dt.startRow,Ht=dt.endCol,Wt=dt.endRow,Mt=e.cellToScreenRect(nt,st),ct=e.cellToScreenRect(Wt,Ht),De=Mt.x,he=Mt.y,ot=ct.x+ct.width-De,Je=ct.y+ct.height-he,mt=Be&&Ht>=e.freeze.cols?Math.min(jt,Xe):Math.min(De+ot,jt),kt=Pe&&Wt>=e.freeze.rows?Math.min(Rt,Qe):Math.min(he+Je,Rt),Tt=Math.max(De,Oe),gn=Math.max(he,Ge);if(mt<=Tt||kt<=gn)continue;const qn=(at=e.resolveStyle(e.cells[e.cellKey(st,nt)]))==null?void 0:at.backgroundColor,bn=((Ze=e.resolveConditionalFormat(st,nt))==null?void 0:Ze.backgroundColor)||qn;bn&&(_.fillStyle=bn,_.fillRect(Tt,gn,mt-Tt,kt-gn)),e.isSelected(st,nt)&&(_.fillStyle=R.selectionBg,_.fillRect(Tt,gn,mt-Tt,kt-gn)),_.strokeStyle=R.gridLine,_.lineWidth=.5;const On=De+.25,yn=he+.25,ro=mt-De-.5,ln=kt-he-.5;if(ro>0&&ln>0&&_.strokeRect(On,yn,ro,ln),Gn(_,dt,De,he,ot,Je,Be,Pe),e.activeCell.value.col===st&&e.activeCell.value.row===nt&&(_.strokeStyle=R.activeCellBorder,_.lineWidth=2,_.strokeRect(De+1,he+1,ot-2,Je-2)),e.getListValidation(nt,st)){const Mn=e.activeCell.value.col===st&&e.activeCell.value.row===nt;Zt(_,De,he,ot,Je,Mn,R)}if(e.hasNote(nt,st)&&Vn(_,De,he,ot,Je),!(e.editingCell.value&&e.editingCell.value.col===st&&e.editingCell.value.row===nt)){const Mn=ne[Ht+1]-ne[st],Sn=ie[Wt+1]-ie[nt],Yn=st<e.freeze.cols,fn=nt<e.freeze.rows,wo=Be?De:Yn?De-P:De,sl=Pe?he:fn?he-ee:he;Kn(_,st,nt,Mn,Sn,wo,sl)}}},r.save(),r.beginPath();const Wo=_e>0?2:0,zt=Ue>0?2:0;r.rect(Xe-Wo,Qe-zt,ht+Wo,Ct+zt),r.clip(),C(r,_o,on,Pn,Rn,Ho),h(r,_o,on,Pn,Rn,Ho),S(r,Xe,Qe,ht,Ct),r.restore(),_e>0&&(r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(Xe+.5,ue),r.lineTo(Xe+.5,T),r.stroke()),Ue>0&&(r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(Q,Qe+.5),r.lineTo(j,Qe+.5),r.stroke()),r.fillStyle=R.headerBg,r.fillRect(f,s,j-f,ue);for(let _=Yt;_<=nn;_++){const Oe=f+ne[_]-P;if(e.isColumnCollapsed(_))continue;const Ge=(ne[_+1]??0)-ne[_];if(Oe+Ge<f||Oe>j)continue;const yt=ke[_];yt===0?(r.fillStyle=R.outlineGroupBg1,r.fillRect(Oe,s,Ge,ue)):yt===1&&(r.fillStyle=R.outlineGroupBg2,r.fillRect(Oe,s,Ge,ue)),St&&_>=St.startCol&&_<=St.endCol&&(r.fillStyle=R.selectionBg,r.fillRect(Oe,s,Ge,ue)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(Oe+.25,s+.25,Ge-.5,ue-.5),St&&_>=St.startCol&&_<=St.endCol&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(Oe,s+ue-1),r.lineTo(Oe+Ge,s+ue-1),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(pt(_),Oe+Ge/2,s+ue/2)}if(_e>0){r.fillStyle=R.headerBg,r.fillRect(f,s,_e,ue);for(let _=0;_<=qt;_++){const Oe=f+ne[_];if(e.isColumnCollapsed(_))continue;const Ge=(ne[_+1]??0)-ne[_];Oe+Ge<f||Oe>j||(St&&_>=St.startCol&&_<=St.endCol&&(r.fillStyle=R.selectionBg,r.fillRect(Oe,s,Ge,ue)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(Oe+.25,s+.25,Ge-.5,ue-.5),St&&_>=St.startCol&&_<=St.endCol&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(Oe,s+ue-1),r.lineTo(Oe+Ge,s+ue-1),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(pt(_),Oe+Ge/2,s+ue/2))}}r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(f,b+.5),r.lineTo(j,b+.5),r.stroke(),r.fillStyle=R.headerBg,r.fillRect(0,b,f,T-b);for(let _=un;_<=oo;_++){if(e.isRowHidden(_))continue;const Oe=b+ie[_]-ee,Ge=Ho[_];if(Oe+Ge<b||Oe>T)continue;const yt=ye[_];yt===0?(r.fillStyle=R.outlineGroupBg1,r.fillRect(w,Oe,Q,Ge)):yt===1&&(r.fillStyle=R.outlineGroupBg2,r.fillRect(w,Oe,Q,Ge)),St&&_>=St.startRow&&_<=St.endRow&&(r.fillStyle=R.selectionBg,r.fillRect(w,Oe,Q,Ge)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(w+.25,Oe+.25,Q-.5,Ge-.5),St&&_>=St.startRow&&_<=St.endRow&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(w+Q-1,Oe),r.lineTo(w+Q-1,Oe+Ge),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(String(_+1),w+Q/2,Oe+Ge/2+.5)}if(Ue>0){r.fillStyle=R.headerBg,r.fillRect(0,b,f,Ue);for(let _=0;_<=$t;_++){if(e.isRowHidden(_))continue;const Oe=b+ie[_],Ge=Ho[_];Oe+Ge<b||Oe>T||(St&&_>=St.startRow&&_<=St.endRow&&(r.fillStyle=R.selectionBg,r.fillRect(w,Oe,Q,Ge)),r.strokeStyle=R.headerBorder,r.lineWidth=.5,r.strokeRect(w+.25,Oe+.25,Q-.5,Ge-.5),St&&_>=St.startRow&&_<=St.endRow&&(r.strokeStyle=R.activeCellBorder,r.lineWidth=2,r.beginPath(),r.moveTo(w+Q-1,Oe),r.lineTo(w+Q-1,Oe+Ge),r.stroke()),r.fillStyle=R.headerText,r.font='11px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',r.textAlign="center",r.textBaseline="middle",r.fillText(String(_+1),w+Q/2,Oe+Ge/2+.5))}}r.strokeStyle=R.headerSep,r.lineWidth=1,r.beginPath(),r.moveTo(f+.5,b),r.lineTo(f+.5,T),r.stroke(),r.fillStyle=R.headerBg,r.fillRect(w,s,Q,ue),r.strokeStyle=R.headerSep,r.lineWidth=1,r.strokeRect(w+.5,s+.5,Q-1,ue-1);const _t=Math.min(Q,ue)*.32;r.fillStyle=R.activeCellBorder,r.beginPath(),r.moveTo(w+Q-1,s+ue-1-_t),r.lineTo(w+Q-1-_t,s+ue-1),r.lineTo(w+Q-1,s+ue-1),r.closePath(),r.fill();const Co=e.getOutlineLevel("row"),il=e.getOutlineLevel("column");if(e.getRowOutlines().length)for(const _ of e.getRowOutlines()){const Oe=qe(_,Co),Ge=b+ie[_.start]-ee,yt=Oe-Ie/2,It=Ge-Ie/2;r.fillStyle=R.headerBg,r.strokeStyle=R.headerText,r.lineWidth=1,$n(r,Math.round(yt),Math.round(It),Ie,Ie,2),r.fill(),r.stroke(),r.strokeStyle=R.headerText,r.lineWidth=1.4,r.beginPath(),r.moveTo(Oe-2,Ge),r.lineTo(Oe+2,Ge),r.stroke(),_.collapsed&&(r.beginPath(),r.moveTo(Oe,Ge-2),r.lineTo(Oe,Ge+2),r.stroke())}if(e.getColumnOutlines().length)for(const _ of e.getColumnOutlines()){const Oe=ut(_,il),Ge=f+ne[_.start]-P,yt=Ge-Ie/2,It=Oe-Ie/2;r.fillStyle=R.headerBg,r.strokeStyle=R.headerText,r.lineWidth=1,$n(r,Math.round(yt),Math.round(It),Ie,Ie,2),r.fill(),r.stroke(),r.strokeStyle=R.headerText,r.lineWidth=1.4,r.beginPath(),r.moveTo(Ge-2,Oe),r.lineTo(Ge+2,Oe),r.stroke(),_.collapsed&&(r.beginPath(),r.moveTo(Ge,Oe-2),r.lineTo(Ge,Oe+2),r.stroke())}le(r,R),$e(r,R)}function L(){const u=o.freezeCanvasRef.value,y=o.wrapperRef.value;if(!u||!y)return;const D=u.getContext("2d");if(!D)return;const j=y.getBoundingClientRect(),T=j.width,P=j.height,ee=52,Q=24,ue=Ee(),w=Ae(),s=ee+ue,f=Q+w,b=o.themeColors.value,R=e.colPositions.value,I=e.rowPositions.value,ne=e.scrollX.value,ie=e.scrollY.value;u.width=T*d,u.height=P*d,u.style.width=T+"px",u.style.height=P+"px",D.setTransform(d,0,0,d,0,0),D.clearRect(0,0,T,P);const{frozenRowsHeight:ye,frozenColumnsWidth:ke}=e.getFrozenMetrics(),Ue=s+ke,_e=f+ye,Xe=Math.max(0,T-s-11-ke),Qe=Math.max(0,P-f-11-ye),ht=Math.max(0,e.freeze.cols-1),Ct=Math.max(0,e.freeze.rows-1),qt=Math.max(e.freeze.cols,e.hitCol(ke+ne));let $t=qt;for(let gt=qt;gt<e.colCount&&!(s+R[gt]-ne>=T);gt++)$t=gt;const Yt=Math.max(e.freeze.rows,e.hitRow(ye+ie));let nn=Yt;for(let gt=Yt;gt<e.rowCount&&!(f+I[gt]-ie>=P);gt++)nn=gt;let un=qt,oo=$t,hn=Yt,on=nn;ke>0&&(un=0,oo=Math.max(oo,ht)),ye>0&&(hn=0,on=Math.max(on,Ct));let Un=un,Rn=hn;for(const gt in e.merges){const Et=e.merges[gt];Et&&(Et.startRow>on||Et.endRow<hn||Et.startCol>oo||Et.endCol<un||(Et.startCol<Un&&(Un=Et.startCol),Et.startRow<Rn&&(Rn=Et.startRow)))}const _o=new Array(Rn);for(let gt=Rn;gt<=on;gt++)_o[gt]=I[gt+1]-I[gt];const Pn=(gt,Et,Kn)=>{const Gn=e.findMerge(gt,Et);return Gn?e.getCellBorderSide(e.cells[Gn.anchor],Kn):e.getCellBorderSide(e.cells[e.cellKey(gt,Et)],Kn)},Ho=(gt,Et,Kn,Gn,Wo)=>{gt.fillStyle=B;for(let zt=Gn;zt<=Wo;zt++)for(let _t=Et;_t<=Kn;_t++){if(e.isRowCollapsed(zt)||e.isColumnCollapsed(_t))continue;const Co=e.findMerge(_t,zt);if(Co&&!(_t===Co.range.startCol&&zt===Co.range.startRow))continue;const il=e.cellToScreenRect(zt,_t),_=il.x,Oe=il.y,Ge=il.width,yt=il.height;if(_+Ge<s||Oe+yt<f||_>T||Oe>P)continue;const It=e.cells[e.cellKey(_t,zt)],jt={top:e.getCellBorderSide(It,"top"),right:e.getCellBorderSide(It,"right"),bottom:e.getCellBorderSide(It,"bottom"),left:e.getCellBorderSide(It,"left")};if(Co)continue;const Rt={top:Pn(_t,zt-1,"bottom"),left:Pn(_t-1,zt,"right"),bottom:Pn(_t,zt+1,"top"),right:Pn(_t+1,zt,"left")},Be=Pt(Rt.top,jt.top),Pe=Pt(Rt.left,jt.left),at=Pt(jt.bottom,Rt.bottom),Ze=Pt(jt.right,Rt.right),Ye=(Be==null?void 0:Be.width)??0,dt=(Pe==null?void 0:Pe.width)??0,st=(at==null?void 0:at.width)??0,nt=(Ze==null?void 0:Ze.width)??0;Ye>0&&G(gt,_,Oe,_+Ge,Oe,Ye,(Be==null?void 0:Be.color)||B,rn(Be==null?void 0:Be.style)),st>0&&G(gt,_,Oe+yt-st,_+Ge,Oe+yt-st,st,(at==null?void 0:at.color)||B,rn(at==null?void 0:at.style)),dt>0&&G(gt,_,Oe,_,Oe+yt,dt,(Pe==null?void 0:Pe.color)||B,rn(Pe==null?void 0:Pe.style)),nt>0&&G(gt,_+Ge-nt,Oe,_+Ge-nt,Oe+yt,nt,(Ze==null?void 0:Ze.color)||B,rn(Ze==null?void 0:Ze.style));const Ht=_t>0&&e.isColumnCollapsed(_t-1),Wt=_t<e.colCount-1&&e.isColumnCollapsed(_t+1),Mt=zt>0&&e.isRowCollapsed(zt-1),ct=zt<e.rowCount-1&&e.isRowCollapsed(zt+1),De=_t<e.freeze.cols,he=zt<e.freeze.rows;Ye>0&&dt>0&&!Ht&&!Mt&&(gt.fillStyle=(Be==null?void 0:Be.color)||(Pe==null?void 0:Pe.color)||B,gt.fillRect(_-dt,Oe-Ye,dt,Ye)),Ye>0&&nt>0&&!Wt&&!Mt&&!De&&(gt.fillStyle=(Be==null?void 0:Be.color)||(Ze==null?void 0:Ze.color)||B,gt.fillRect(_+Ge,Oe-Ye,nt,Ye)),st>0&&dt>0&&!Ht&&!ct&&!he&&(gt.fillStyle=(at==null?void 0:at.color)||(Pe==null?void 0:Pe.color)||B,gt.fillRect(_-dt,Oe+yt,dt,st)),st>0&&nt>0&&!Wt&&!ct&&!De&&!he&&(gt.fillStyle=(at==null?void 0:at.color)||(Ze==null?void 0:Ze.color)||B,gt.fillRect(_+Ge,Oe+yt,nt,st))}},St=(gt,Et,Kn,Gn,Wo,zt,_t,Co)=>{Kn<=0||Gn<=0||(D.save(),D.beginPath(),D.rect(gt,Et,Kn,Gn),D.clip(),D.fillStyle=b.gridBg,D.fillRect(gt,Et,Kn,Gn),C(D,Wo,zt,_t,Co,_o),Ho(D,Wo,zt,_t,Co),S(D,gt,Et,Kn,Gn),D.restore())};ke>0&&ye>0&&St(ee,Q,ke,ye,0,ht,0,Ct),ye>0&&St(Ue,Q,Xe,ye,Un,oo,0,Ct),ke>0&&St(ee,_e,ke,Qe,0,ht,Rn,on),D.strokeStyle=b.headerSep,D.lineWidth=1,ke>0&&(D.beginPath(),D.moveTo(Ue+.5,Q),D.lineTo(Ue+.5,P),D.stroke()),ye>0&&(D.beginPath(),D.moveTo(ee,_e+.5),D.lineTo(T,_e+.5),D.stroke()),D.fillStyle=b.headerBg,D.fillRect(0,0,ee,Q),D.strokeStyle=b.headerSep,D.lineWidth=1,D.strokeRect(.5,.5,ee-.5,Q-.5),le(D,b),$e(D,b)}function le(u,y){const D=e.selection.value;if(!D||e.editingCell.value)return;const j=e.cellToScreenRect(D.endRow,D.endCol),T=j.x+j.width-6/2,P=j.y+j.height-6/2;if(T<ce()||P<ae())return;const{frozenColumnsWidth:ee,frozenRowsHeight:Q}=e.getFrozenMetrics();if(ee>0&&D.endCol>=e.freeze.cols&&T<ce()+ee||Q>0&&D.endRow>=e.freeze.rows&&P<ae()+Q)return;const ue=Nr(D,D,e.merges).ok;u.fillStyle=ue?y.activeCellBorder:y.scrollTrack,u.fillRect(T,P,6,6),u.strokeStyle="#fff",u.lineWidth=1,u.strokeRect(T+.5,P+.5,6-1,6-1)}function $e(u,y){const D=e.autoFillState.value;if(!D.active||!D.preview||!D.targetRange)return;const j=D.targetRange,T=e.cellToScreenRect(j.startRow,j.startCol),P=e.cellToScreenRect(j.endRow,j.endCol),ee=T.x,Q=T.y,ue=P.x+P.width-ee,w=P.y+P.height-Q;Q<ae()||ee<ce()||(u.fillStyle=y.selectionBg,u.fillRect(ee,Q,ue,w),u.strokeStyle=y.activeCellBorder,u.lineWidth=1.5,u.setLineDash([4,3]),u.strokeRect(ee+.5,Q+.5,ue-1,w-1),u.setLineDash([]))}const et=t.computed(()=>pt(e.activeCell.value.col)+String(e.activeCell.value.row+1)),oe=t.ref(""),xe=t.ref(!1),se=t.computed(()=>e.editingCell.value?oe.value:e.getCellRaw(e.activeCell.value.col,e.activeCell.value.row));t.watch(()=>e.editingCell.value,(u,y)=>{if(u&&!y){const D=e.editValue.value||e.getCellRaw(u.col,u.row)||"";oe.value=D,We=!1}else!u&&y&&(oe.value="",xe.value=!1,We=!1)},{immediate:!0}),t.watch(()=>[e.activeCell.value.col,e.activeCell.value.row],()=>{e.editingCell.value||(oe.value="",We=!1)});function de(){e.editingCell.value||(e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(),m())}function we(u){const y=u.target.value;e.editingCell.value?e.editValue.value=y:e.startEdit(y),oe.value=y,We=!0}function Re(u){var D,j;const y={...e.activeCell.value};e.editingCell.value?(e.editValue.value=u,e.commitEdit()):((D=e.saveUndo)==null||D.call(e),e.setCellValue(y.col,y.row,u)),oe.value="",We=!1,m(),(j=o.emitModelData)==null||j.call(o)}let Ke=!1,We=!1;function rt(){var P,ee,Q;if(Ke)return;const u=o.formulaBarRef.value,y=!!(u&&typeof document<"u"&&document.activeElement===u);if(!e.editingCell.value&&!y&&!We)return;const D={...e.activeCell.value},j=e.editingCell.value?e.editingCell.value.col:D.col,T=e.editingCell.value?e.editingCell.value.row:D.row;if(!e.editingCell.value){const ue=e.getCellRaw(j,T),w=oe.value!==ue;if(!We)return;Ke=!0,w&&((P=e.saveUndo)==null||P.call(e),e.setCellValue(j,T,oe.value),m(),(ee=o.emitModelData)==null||ee.call(o)),(Q=o.formulaBarRef.value)==null||Q.blur(),oe.value="",xe.value=!1,We=!1,t.nextTick(()=>{Ke=!1});return}Ke=!0,We?(e.editValue.value=oe.value,e.commitEdit().then(ue=>{var w,s;ue&&(e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row)),(w=o.formulaBarRef.value)==null||w.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(s=o.emitModelData)==null||s.call(o),t.nextTick(()=>{Ke=!1})})):y?(oe.value=e.editValue.value,e.commitEdit().then(ue=>{var w,s;ue&&(e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row)),(w=o.formulaBarRef.value)==null||w.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(s=o.emitModelData)==null||s.call(o),t.nextTick(()=>{Ke=!1})})):e.commitEdit().then(()=>{var ue,w;(ue=o.formulaBarRef.value)==null||ue.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),(w=o.emitModelData)==null||w.call(o),t.nextTick(()=>{Ke=!1})})}function je(){var u;Ke||(Ke=!0,e.editingCell.value&&e.cancelEdit(),(u=o.formulaBarRef.value)==null||u.blur(),oe.value="",xe.value=!1,We=!1,m(),o.focusEditInput(),t.nextTick(()=>{Ke=!1}))}function A(u){if(!u.isComposing){if(u.key==="Enter"&&(u.altKey||u.metaKey)&&!u.ctrlKey){u.preventDefault(),u.stopPropagation();const y=u.target;if(!y)return;e.editingCell.value||e.startEdit();const D=y.selectionStart??y.value.length,j=y.selectionEnd??y.value.length,T=y.value,P=T.substring(0,D)+`
|
|
7
7
|
`+T.substring(j),ee=D+1;oe.value=P,xe.value||(xe.value=!0),t.nextTick(()=>{try{y.setSelectionRange(ee,ee)}catch{}if(xe.value)try{y.scrollTop=y.scrollHeight}catch{}try{y.focus({preventScroll:!0})}catch{}});return}u.key==="Enter"?(u.preventDefault(),rt()):u.key==="Escape"&&(u.preventDefault(),je())}}function K(){rt()}const $=t.ref(null),V=t.ref("");function x(u){$.value===null&&(o.switchSheet(u),m())}function H(u){u!==o.activeSheetIndex.value&&(o.saveSheet(),o.loadSheet(u),m()),$.value=u,V.value=o.sheets.value[u].name,t.nextTick(()=>{const y=document.querySelector(".tab-rename-input");y==null||y.focus(),y==null||y.select()})}function z(){$.value!==null&&(o.renameSheet($.value,V.value),t.nextTick(()=>o.emitModelData())),$.value=null,V.value=""}function Y(){$.value=null,V.value=""}function ve(u){u.key==="Enter"?(u.preventDefault(),z()):u.key==="Escape"&&(u.preventDefault(),Y())}const ze=t.ref(null);t.watch(ze,u=>{u===null&&tt()});const it=t.ref(null);let Fe=null,v=null;function Z(){Fe&&(clearTimeout(Fe),Fe=null),v=null}function lt(u,y,D){Z(),it.value={mode:D,row:u,col:y}}function wt(){Z(),it.value=null}function ft(u,y){lt(u,y,"edit")}function At(u,y,D,j){const T=e.getNote(u,y);D?T?e.updateCellNote(T.id,D):e.setCellNote(u,y,D,j||ta):T&&e.deleteCellNote(u,y),wt(),m()}function Ft(u,y){e.deleteCellNote(u,y),wt(),m()}function Vt(u,y){var Q;if(((Q=it.value)==null?void 0:Q.mode)==="edit")return;const j=u>=ce()&&y>=ae()?e.screenToCell(u,y):null,T=j&&j.col>=0&&j.row>=0&&e.hasNote(j.row,j.col)?j:null,P=it.value&&it.value.mode==="view"?it.value:null;P&&`${P.col}${P.row}`;const ee=T?`${T.col},${T.row}`:null;v&&`${v.col},${v.row}`===ee||(v=T?{row:T.row,col:T.col}:null,Fe&&(clearTimeout(Fe),Fe=null),ee&&(Fe=setTimeout(()=>{var ue;Fe=null,((ue=it.value)==null?void 0:ue.mode)!=="edit"&&(it.value={mode:"view",row:T.row,col:T.col},m())},300)))}function wn(u,y){if(u<ce()||y<ae())return null;const D=e.screenToCell(u,y);if(!D)return null;const{col:j,row:T}=D;if(!e.hasNote(T,j))return null;const P=e.cellToScreenRect(T,j),ee=5,Q=P.x+P.width-1.5,ue=P.y+1.5,w=u-Q,s=y-ue;return w<=1&&s>=-1&&s-w<=ee+1?{row:T,col:j}:null}const an=t.ref(null),sn=t.ref(null),mn=18,Dt=2,Jt=2,Qt=new Path2D("M180.053333 361.386667a32 32 0 0 1 45.226667 0L512 648.106667l286.72-286.72a32 32 0 1 1 45.226667 45.226666l-309.333334 309.333334a32 32 0 0 1-45.226666 0L180.053333 406.613333a32 32 0 0 1 0-45.226666z");function $n(u,y,D,j,T,P){const ee=Math.min(P,j/2,T/2);u.beginPath(),u.moveTo(y+ee,D),u.arcTo(y+j,D,y+j,D+T,ee),u.arcTo(y+j,D+T,y,D+T,ee),u.arcTo(y,D+T,y,D,ee),u.arcTo(y,D,y+j,D,ee),u.closePath()}function Zt(u,y,D,j,T,P,ee){if(j<te+4||T<10)return;const Q=y+j-te,ue=D+1,w=T-2;u.save(),P&&(u.fillStyle=ee.selectionBg,u.fillRect(Q,ue,te,w)),u.fillStyle=ee.activeCellBorder;const s=6,f=4,b=Q+te/2,R=ue+w/2;u.beginPath(),u.moveTo(b-s/2,R-f/2+.5),u.lineTo(b+s/2,R-f/2+.5),u.lineTo(b,R+f/2+.5),u.closePath(),u.fill(),u.restore()}function Vn(u,y,D,j,T){if(j<8||T<8)return;const P=5,ee=y+j-1.5,Q=D+1.5;u.save(),u.fillStyle="#d93025",u.beginPath(),u.moveTo(ee,Q),u.lineTo(ee-P,Q),u.lineTo(ee,Q+P),u.closePath(),u.fill(),u.restore()}function U(u,y){if(e.dataValidations.length===0)return null;const D=e.screenToCell(u,y);if(!D)return null;const j=e.findMerge(D.col,D.row),T=j?j.range.startCol:D.col,P=j?j.range.startRow:D.row;if(!e.getListValidation(P,T))return null;const ee=e.cellToScreenRect(P,T);if(ee.width<te+4)return null;const Q=ee.x+ee.width-te;return u<Q||u>ee.x+ee.width||y<ee.y||y>ee.y+ee.height?null:{col:T,row:P}}function W(u,y){const D=e.getValidationDropdown(y,u);if(!D)return!1;const j=o.canvasRef.value;if(!j)return!1;e.activeCell.value.col===u&&e.activeCell.value.row===y||e.selectCell(u,y),e.ensureVisible(u,y),m();const T=e.cellToScreenRect(y,u),P=j.getBoundingClientRect();return sn.value={col:u,row:y,rule:D.rule,items:D.items,current:e.getCellRaw(u,y),x:P.left+T.x,y:P.top+T.y,width:T.width,height:T.height},!0}function X(){sn.value&&(sn.value=null,m())}async function Ce(u){var P;const y=sn.value;if(!y)return;const{col:D,row:j}=y;sn.value=null;const T=e.validateCell(j,D,u);if(!T.valid&&await e.confirmInvalidValue(T,D,j)!=="continue"){m(),o.focusEditInput();return}l.saveUndo(),e.setCellValue(D,j,u),(P=e.emitModelData)==null||P.call(e),m(),o.focusEditInput()}function Ne(u,y,D,j,T,P,ee){const Q=Math.min(j,mn)-Dt,ue=y+j-Q-Dt,w=D+Dt,s=T-2*Dt;u.save(),u.fillStyle=P?ee.activeCellBorder:"#ececec",$n(u,ue,w,Q,s,Jt),u.fill();const f=Math.min(Q,s)*.72;u.translate(ue+Q/2,w+s/2),u.scale(f/1024,f/1024),u.translate(-512,-512),u.fillStyle=P?"#ffffff":"#5a5a5a",u.fill(Qt),u.restore()}function Ve(u,y){const D=e.getFilter();if(!D)return-1;const j=e.screenToCell(u,y);if(!j)return-1;const{col:T,row:P}=j;if(P!==D.range.startRow||T<D.range.startCol||T>D.range.endCol)return-1;const ee=e.cellToScreenRect(P,T),Q=Math.min(ee.width,mn)-Dt,ue=ee.x+ee.width-Q-Dt,w=ee.x+ee.width-Dt;return u>=ue&&u<=w&&y>=ee.y+Dt&&y<=ee.y+ee.height-Dt?T:-1}function He(u){const y=e.getFilter();if(!y)return;const D=o.canvasRef.value;if(!D)return;const j=D.getBoundingClientRect(),T=e.cellToScreenRect(y.range.startRow,u);an.value={col:u,x:j.left+T.x+T.width-mn,y:j.top+T.y+2}}function Me(){an.value=null}let Le=null,be=null;function tt(){Le&&(document.removeEventListener("click",Le),Le=null),be&&(document.removeEventListener("touchstart",be,{capture:!0}),be=null)}function k(u,y){const D=e.getOutlineLevel("row"),j=e.getOutlineLevel("column"),T=e.rowPositions.value,P=e.colPositions.value,ee=e.scrollX.value,Q=e.scrollY.value,ue=Ie/2+1;if(y>=ae())for(const w of e.getRowOutlines()){const s=qe(w,D),f=ae()+T[w.start]-Q;if(Math.abs(u-s)<=ue&&Math.abs(y-f)<=ue)return{kind:"toggle",outlineId:w.id}}if(u>=ce())for(const w of e.getColumnOutlines()){const s=ut(w,j),f=ce()+P[w.start]-ee;if(Math.abs(y-s)<=ue&&Math.abs(u-f)<=ue)return{kind:"toggle",outlineId:w.id}}return null}function q(u){for(const y of u)e.removeOutline(y);o.emitModelData(),m()}function re(u){const y=e.selection.value;if(!y)return pe("outlineNeedRowsOrColumns"),!1;let D;if(u==="row"){if(y.startCol!==0||y.endCol!==e.colCount-1)return pe("outlineNeedRowsOrColumns"),!1;if(y.startRow===y.endRow)return pe("outlineInvalidRange"),!1;D=e.addRowGroup(y.startRow,y.endRow)}else{if(y.startRow!==0||y.endRow!==e.rowCount-1)return pe("outlineNeedRowsOrColumns"),!1;if(y.startCol===y.endCol)return pe("outlineInvalidRange"),!1;D=e.addColumnGroup(y.startCol,y.endCol)}return D.ok?!0:(pe(D.code==="outlineCrossing"?"outlineCrossing":D.code==="outlineTooDeep"?"outlineTooDeep":"outlineInvalidRange"),!1)}function Se(u){const y=e.selection.value;if(!y||u==="row"&&(y.startCol!==0||y.endCol!==e.colCount-1)||u==="column"&&(y.startRow!==0||y.endRow!==e.rowCount-1))return pe("outlineNeedRowsOrColumns"),!1;const D=u==="row"?e.getRowOutlines():e.getColumnOutlines(),j=u==="row"?y.startRow:y.startCol,T=u==="row"?y.endRow:y.endCol,P=D.filter(ee=>j<=ee.start&&ee.end<=T);return P.length?(q(P.map(ee=>ee.id)),!0):(pe("outlineUngroupPartial"),!1)}function Te(u,y){const D=u==="row"?e.getRowOutlines():e.getColumnOutlines();if(D.length&&!D.every(j=>j.collapsed===y)){l.saveUndo();for(const j of D)e.setOutlineCollapsed(j.id,y,!0);o.emitModelData(),m()}}function pe(u){const y=g(e.locale.value,u);if(c){c(y);return}window.alert(y)}function F(u,y,D){tt();const j=140,T=D.length*28+8,P=Nn(o.wrapperRef.value),ee=P.right,Q=P.bottom;u+j>ee&&(u-=j),y+T>Q&&(y-=T),p.value=!1,ze.value={x:u,y,items:D},t.nextTick(()=>bt()),Le=()=>{ze.value=null,tt()},be=ue=>{const w=ue.target;w&&w.closest(".context-menu")||(ze.value=null,tt())},setTimeout(()=>{document.addEventListener("click",Le,{once:!0}),document.addEventListener("touchstart",be,{capture:!0})},0)}const p=t.ref(!1);function N(u,y){}function bt(){const y=document.querySelector(".context-menu"),D=ze.value;if(!y||!D){p.value=!1;return}const j=D.x+140,T=Nn(o.wrapperRef.value),P=T.right,ee=T.bottom,Q=y.style.transform;y.style.transform="none";let ue=0;if(y.querySelectorAll(".context-menu__item").forEach(s=>{const f=s.querySelector(":scope > .context-submenu");if(!f)return;const b=f.style.display;f.style.display="block";const R=f.getBoundingClientRect(),I=R.width,ne=R.height;f.style.display=b,I>ue&&(ue=I),s.getBoundingClientRect().top+ne>ee-8?(f.style.top="auto",f.style.bottom="-5px"):(f.style.top="",f.style.bottom="")}),y.style.transform=Q,ue===0){p.value=!0;return}const w=P-j;p.value=w<ue+8}function vt(u,y){u.preventDefault(),u.stopPropagation(),F(u.clientX,u.clientY,[{label:g(e.locale.value,"insert"),action:()=>{o.addSheet(),m()}},{label:g(e.locale.value,"copy"),action:()=>{o.dupSheet(y)}},{label:g(e.locale.value,"rename"),action:()=>{H(y)}},{label:g(e.locale.value,"delete"),action:()=>{o.removeSheet(y),m()},disabled:o.sheetCount.value<=1},{label:g(e.locale.value,"moveSheetLeft"),action:()=>{o.moveSheet(y,-1)},disabled:y===0},{label:g(e.locale.value,"moveSheetRight"),action:()=>{o.moveSheet(y,1)},disabled:y===o.sheets.value.length-1}])}function Kt(u){u.preventDefault(),!(u.target.closest(".tab-item")||u.target.closest(".tab-bar__add-btn"))&&F(u.clientX,u.clientY,[{label:g(e.locale.value,"insert"),action:()=>{o.addSheet(),m()}}])}function Nt(u){u.preventDefault(),e.selectAll(),m(),F(u.clientX,u.clientY,[{label:g(e.locale.value,"cut"),action:()=>{n.cutSelected(),o.emitModelData()}},{label:g(e.locale.value,"copy"),action:()=>n.copyToClipboard()},{label:g(e.locale.value,"paste"),action:()=>{l.saveUndo(),n.pasteFromClipboard().then(()=>{m(),t.nextTick(()=>o.emitModelData())})}},{label:g(e.locale.value,"delete"),action:()=>{l.saveUndo(),n.clearSelected();for(let y=0;y<e.colCount;y++)e.colWidths.value[y]=100;for(let y=0;y<e.rowCount;y++)e.rowHeights.value[y]=void 0;m(),o.emitModelData()}}])}function fo(u,y){u.preventDefault();const D=u.clientX,j=u.clientY,T=e.selection.value;T&&T.startCol===0&&T.endCol===e.colCount-1&&y>=T.startRow&&y<=T.endRow||(e.selectRange(0,y,e.colCount-1,y,"row"),m());const P=e.selection.value;F(u.clientX,u.clientY,[{label:g(e.locale.value,"insert"),action:()=>{l.saveUndo(),o.insertRows(P.startRow,P.startRow),e.selectRange(0,P.startRow,e.colCount-1,P.startRow,"row"),m(),o.emitModelData()}},{label:g(e.locale.value,"cut"),action:()=>{l.saveUndo(),n.copyRowCol(),e.clearCellsInRange(0,e.colCount-1,P.startRow,P.endRow),m(),o.emitModelData()}},{label:g(e.locale.value,"copy"),action:()=>n.copyRowCol()},{label:g(e.locale.value,"paste"),action:()=>{l.saveUndo(),n.pasteFromClipboard().then(()=>{m(),t.nextTick(()=>o.emitModelData())})}},{label:g(e.locale.value,"delete"),action:()=>{l.saveUndo(),o.deleteRows(P.startRow,P.endRow),m(),o.emitModelData()}},{label:`${g(e.locale.value,"rowHeight")}...`,action:()=>bl("row",D,j)},{label:g(e.locale.value,"autoRowHeight"),action:()=>o.resetRowHeight()},{label:g(e.locale.value,"freezeToRow"),action:()=>{e.setFreeze(y+1,e.freeze.cols),m()}},{label:g(e.locale.value,"outlineGroup"),children:[{label:g(e.locale.value,"outlineAddRowGroup"),action:()=>re("row")},{label:g(e.locale.value,"outlineUngroupRows"),action:()=>Se("row")},{label:g(e.locale.value,"outlineClear"),action:()=>e.clearRowGroups()},{label:g(e.locale.value,"outlineExpandAll"),action:()=>Te("row",!1)},{label:g(e.locale.value,"outlineCollapseAll"),action:()=>Te("row",!0)}]}])}function mo(u,y){u.preventDefault();const D=u.clientX,j=u.clientY,T=e.selection.value;T&&T.startRow===0&&T.endRow===e.rowCount-1&&y>=T.startCol&&y<=T.endCol||(e.selectRange(y,0,y,e.rowCount-1,"col"),m());const P=e.selection.value,ee=!o.canSortColumns(P.startCol,P.endCol);F(u.clientX,u.clientY,[{label:g(e.locale.value,"insert"),action:()=>{l.saveUndo(),o.insertCols(P.startCol,P.startCol),e.selectRange(P.startCol,0,P.startCol,e.rowCount-1,"col"),m(),o.emitModelData()}},{label:g(e.locale.value,"cut"),action:()=>{l.saveUndo(),n.copyRowCol(),e.clearCellsInRange(P.startCol,P.endCol,0,e.rowCount-1),m(),o.emitModelData()}},{label:g(e.locale.value,"copy"),action:()=>n.copyRowCol()},{label:g(e.locale.value,"paste"),action:()=>{l.saveUndo(),n.pasteFromClipboard().then(()=>{m(),t.nextTick(()=>o.emitModelData())})}},{label:g(e.locale.value,"delete"),action:()=>{l.saveUndo(),o.deleteCols(P.startCol,P.endCol),m(),o.emitModelData()}},{label:g(e.locale.value,"sort"),disabled:ee,children:[{label:g(e.locale.value,"sortAsc"),action:()=>{o.prepareSortConfirmation("asc")||o.sortSelectedColumns("asc")},disabled:ee},{label:g(e.locale.value,"sortDesc"),action:()=>{o.prepareSortConfirmation("desc")||o.sortSelectedColumns("desc")},disabled:ee}]},{label:`${g(e.locale.value,"colWidth")}...`,action:()=>bl("col",D,j)},{label:g(e.locale.value,"defaultColWidth"),action:()=>o.resetColWidth()},{label:g(e.locale.value,"freezeToCol"),action:()=>{e.setFreeze(e.freeze.rows,y+1),m()}},{label:g(e.locale.value,"outlineGroup"),children:[{label:g(e.locale.value,"outlineAddColumnGroup"),action:()=>re("column")},{label:g(e.locale.value,"outlineUngroupColumns"),action:()=>Se("column")},{label:g(e.locale.value,"outlineClear"),action:()=>e.clearColumnGroups()},{label:g(e.locale.value,"outlineExpandAll"),action:()=>Te("column",!1)},{label:g(e.locale.value,"outlineCollapseAll"),action:()=>Te("column",!0)}]}])}function Xt(u,y,D){u.preventDefault(),e.isSelected(y,D)||(e.selectCell(y,D),m());const j=e.selection.value,T=!!(j&&j.startCol===j.endCol&&j.startRow===j.endRow);F(u.clientX,u.clientY,[{label:g(e.locale.value,"cut"),action:()=>{n.cutSelected(),o.emitModelData()}},{label:g(e.locale.value,"copy"),action:()=>n.copyToClipboard()},{label:g(e.locale.value,"paste"),action:()=>{l.saveUndo(),n.pasteFromClipboard().then(()=>{m(),t.nextTick(()=>o.emitModelData())})}},{label:g(e.locale.value,"delete"),action:()=>{l.saveUndo(),n.clearSelected(),m(),o.emitModelData()}},{label:g(e.locale.value,"calculate"),children:[{label:g(e.locale.value,"sum"),action:n.sumSelected,disabled:T},{label:g(e.locale.value,"avg"),action:n.avgSelected,disabled:T},{label:g(e.locale.value,"count"),action:n.countSelected,disabled:T}]},{label:`${g(e.locale.value,"dv")}...`,action:()=>{var P;return(P=e.requestDataValidationDialog)==null?void 0:P.call(e)}},{label:g(e.locale.value,"dvClearValidation"),action:()=>{l.saveUndo(),e.clearDataValidation(e.selection.value),m(),o.emitModelData()}},...T?[{label:e.hasNote(D,y)?g(e.locale.value,"editNote"):g(e.locale.value,"newNote"),action:()=>ft(D,y)},...e.hasNote(D,y)?[{label:g(e.locale.value,"deleteNote"),action:()=>Ft(D,y)}]:[]]:[]])}const Gl=t.ref(null),Qn=t.ref(null);let Io=null,Ao=null;function ql(){Io&&(document.removeEventListener("mousedown",Io),Io=null),Ao&&(document.removeEventListener("touchstart",Ao),Ao=null)}function bl(u,y,D){ql();const j=e.selection.value;let T="";if(j){const s=u==="row"?e.getRowHeight(j.startRow):e.colWidths.value[j.startCol];T=s!=null&&s>0?String(Math.round(s)):""}const P=220,ee=118;let Q=y,ue=D;const w=Nn(o.wrapperRef.value);Q=Math.max(w.left+8,Math.min(w.right-P-8,Q)),ue=Math.max(w.top+8,Math.min(w.bottom-ee-8,ue)),Qn.value={type:u,x:Q,y:ue,value:T,error:""},Io=()=>{Qn.value=null},Ao=()=>{Qn.value=null},setTimeout(()=>{document.addEventListener("mousedown",Io,{once:!0}),document.addEventListener("touchstart",Ao,{once:!0})},0),t.nextTick(()=>{const s=Gl.value;s&&(s.focus(),s.select())})}function Yl(u){const y=Qn.value;if(!y)return;const D=u.target,j=D.value,T=j.replace(/[^\d]/g,"");y.value=T,j!==T&&(D.value=T),y.error=""}function $r(u){u.key==="Enter"?(u.preventDefault(),jl()):u.key==="Escape"&&(u.preventDefault(),jo())}function zr(){const u=Qn.value;if(!u)return;const y=u.value.trim(),D=Number(y),j=u.type==="row",T=j?24:30,P=j?500:1e3;if(y===""||!Number.isFinite(D)){jo();return}const ee=Math.max(T,Math.min(P,Math.round(D)));u.value=String(ee),u.error=""}function jl(){const u=Qn.value,y=e.selection.value;if(!u||!y)return;const D=u.value.trim(),j=Number(D),T=u.type==="row",P=T?24:30,ee=T?500:1e3;if(D===""||!Number.isFinite(j)){u.error=g(e.locale.value,"dimNumberError");return}if(j<P||j>ee){u.error=g(e.locale.value,"dimRangeError").replace("{min}",String(P)).replace("{max}",String(ee));return}const Q=j;if(l.saveUndo(),T)for(let ue=y.startRow;ue<=y.endRow;ue++)e.rowHeights.value[ue]=Q;else for(let ue=y.startCol;ue<=y.endCol;ue++)e.colWidths.value[ue]=Q;m(),o.emitModelData(),jo()}function jo(){ql(),Qn.value=null}const _r=t.computed(()=>{const u=!e.editingCell.value,y=e.editingCell.value??e.activeCell.value,D=y.col,j=y.row,T=e.resolveStyle(e.cells[e.cellKey(D,j)]),P=e.cellFontSize(D,j),ee=typeof(T==null?void 0:T.fontFamily)=="string"&&T.fontFamily?T.fontFamily:Vo,Q=(T==null?void 0:T.fontWeight)==="bold"?"bold":"normal",ue=(T==null?void 0:T.fontStyle)==="italic"?"italic":"normal",w=(T==null?void 0:T.underline)==="underline"?"underline":(T==null?void 0:T.strikethrough)==="line-through"?"line-through":"none",s=(T==null?void 0:T.underline)==="underline"&&(T==null?void 0:T.strikethrough)==="line-through"?"underline line-through":w,f=typeof(T==null?void 0:T.color)=="string"?T.color:void 0,b=typeof(T==null?void 0:T.backgroundColor)=="string"?T.backgroundColor:void 0,R=typeof(T==null?void 0:T.numberFormat)=="string"?T.numberFormat:"",I=e.editValue.value??e.getCellValue(D,j),ne=typeof(T==null?void 0:T.textAlign)=="string"?T.textAlign:br(I,R)?"right":"left",ie=typeof(T==null?void 0:T.verticalAlign)=="string"?T.verticalAlign:"top",ye=e.findMerge(D,j),ke=ye?e.rowPositions.value[ye.range.endRow+1]-e.rowPositions.value[j]:e.getRowHeight(j),Ue=2,{ascent:_e,descent:Xe}=e.measureFontMetrics(ee,P,Q,ue),Qe=_e+Xe,Ct=(e.editValue.value?e.editValue.value.split(`
|
|
8
8
|
`).length:1)*Qe,qt=e.BASE_CELL_VPAD-Ue;let $t=0,Yt=0;ie==="middle"?($t=Math.floor((ke-Ct)/2),Yt=Math.max(0,ke-Ct-$t)):ie==="top"?($t=qt,Yt=Math.max(0,ke-Ct-$t)):ie==="bottom"&&(Yt=qt,$t=Math.max(0,ke-Ct-Yt));const nn=e.cellToScreenRect(j,D);return{left:`${nn.x}px`,top:`${nn.y}px`,width:`${nn.width}px`,height:`${nn.height}px`,fontFamily:ee,fontSize:`${P}px`,lineHeight:1,fontWeight:Q,fontStyle:ue,textDecoration:s,textAlign:ne,paddingTop:`${$t}px`,paddingRight:"3px",paddingBottom:`${Yt}px`,paddingLeft:"3px",opacity:u?0:1,pointerEvents:u?"none":"auto",color:u?"transparent":f,caretColor:u?"transparent":void 0,borderColor:u?"transparent":void 0,background:u?"transparent":b,boxShadow:u?"none":void 0}});function yl(){return Math.max(0,o.viewSize.w-ce()-11)}function Cl(){return Math.max(0,o.viewSize.h-ae()-11)}const wl=t.computed(()=>Math.max(0,yl()-e.getFrozenMetrics().frozenColumnsWidth)),Xo=t.computed(()=>Math.max(0,Cl()-e.getFrozenMetrics().frozenRowsHeight)),Xl=t.computed(()=>ce()+e.getFrozenMetrics().frozenColumnsWidth),Hr=t.computed(()=>ae()+e.getFrozenMetrics().frozenRowsHeight),Lo=t.computed(()=>Math.max(0,wl.value-11*2)),$o=t.computed(()=>Math.max(0,Xo.value-11*2)),Zo=t.computed(()=>o.maxScrollX.value<=0?Lo.value:Math.max(24,wl.value/e.totalWidth.value*Lo.value)),Jo=t.computed(()=>o.maxScrollX.value<=0?0:e.scrollX.value/o.maxScrollX.value*(Lo.value-Zo.value)),Qo=t.computed(()=>o.maxScrollY.value<=0?$o.value:Math.max(24,Xo.value/e.totalHeight.value*$o.value)),vl=t.computed(()=>o.maxScrollY.value<=0?0:e.scrollY.value/o.maxScrollY.value*($o.value-Qo.value));let po=null,el=0,tl=0;function Zl(u){u.preventDefault(),po="v",el=u.clientY,tl=e.scrollY.value,document.addEventListener("mousemove",nl),document.addEventListener("mouseup",ol)}function ho(u){u.preventDefault(),po="h",el=u.clientX,tl=e.scrollX.value,document.addEventListener("mousemove",nl),document.addEventListener("mouseup",ol)}function nl(u){if(po==="v"){const D=(u.clientY-el)/($o.value-Qo.value);o.clampScroll(null,tl+D*o.maxScrollY.value),m()}else if(po==="h"){const D=(u.clientX-el)/(Lo.value-Zo.value);o.clampScroll(tl+D*o.maxScrollX.value,null),m()}}function ol(){po=null,document.removeEventListener("mousemove",nl),document.removeEventListener("mouseup",ol)}function eo(u){if(po)return;const y=u.currentTarget.getBoundingClientRect(),D=u.clientY-y.top;D<vl.value?o.clampScroll(null,e.scrollY.value-Cl()):D>vl.value+Qo.value&&o.clampScroll(null,e.scrollY.value+Cl()),m()}function ll(u){if(po)return;const y=u.currentTarget.getBoundingClientRect(),D=u.clientX-y.left;D<Jo.value?o.clampScroll(e.scrollX.value-yl(),null):D>Jo.value+Zo.value&&o.clampScroll(e.scrollX.value+yl(),null),m()}let go=!1,cn=0,vn=0,kn=!1,Dn=!1,zn=0,No=0,to=0,_n=0,Bo=0,Hn=0,zo=0,rl=0,dn=!1,bo=!1,Bt=0,xt=0,en="cell",kl=0,Jl=-1,Ql=-1,Lt=null,Fn=!1,tn=0,Wn=0,yo=!1,En=null,xo=null,er=0,tr=0;function al(u,y){const D=e.selection.value;if(!D||e.editingCell.value||!Nr(D,D,e.merges).ok)return!1;const j=e.cellToScreenRect(D.endRow,D.endCol),T=j.x+j.width-6,P=j.y+j.height-6,ee=4;return u>=T-ee&&u<=T+6+ee&&y>=P-ee&&y<=P+6+ee}function nr(){En=requestAnimationFrame(or)}function or(){if(!e.autoFillState.value.active||!xo){En=null;return}const u=8;o.clampScroll(e.scrollX.value+xo.x*u*.1,e.scrollY.value+xo.y*u*.1);const y=e.screenToCell(er,tr),D=e.autoFillState.value.sourceRange;if(y&&D){const j=Pa(D,{col:y.col,row:y.row});j?e.autoFillState.value={...e.autoFillState.value,targetRange:j.targetRange,direction:j.direction}:e.autoFillState.value={...e.autoFillState.value,targetRange:null,direction:null}}m(),En=requestAnimationFrame(or)}function El(){En!==null&&(cancelAnimationFrame(En),En=null),xo=null}function lr(u,y){er=u,tr=y;const D=e.screenToCell(u,y),j=e.autoFillState.value.sourceRange;if(D&&j){const w=Pa(j,{col:D.col,row:D.row});w?e.autoFillState.value={...e.autoFillState.value,targetRange:w.targetRange,direction:w.direction}:e.autoFillState.value={...e.autoFillState.value,targetRange:null,direction:null}}const T=30,P=o.viewSize.w,ee=o.viewSize.h;let Q=0,ue=0;u<ce()+T?Q=-(ce()+T-u):u>P-11-T&&(Q=u-(P-11-T)),y<ae()+T?ue=-(ae()+T-y):y>ee-11-T&&(ue=y-(ee-11-T)),Q!==0||ue!==0?(xo={x:Q,y:ue},En===null&&nr()):(xo=null,En!==null&&(cancelAnimationFrame(En),En=null)),m()}function rr(){El();const u=e.autoFillState.value;u.targetRange&&u.direction&&u.sourceRange&&e.applyAutoFill(u.sourceRange,u.targetRange,u.direction),e.autoFillState.value={active:!1,sourceRange:null,targetRange:null,direction:null,preview:!1}}function Wr(u){var w;if(u.button!==0)return;u.preventDefault(),ze.value=null;const y=Eo(u,o.canvasRef.value),D=U(y.x,y.y);if(D){if(e.editingCell.value){e.commitEdit().then(s=>{s&&W(D.col,D.row)});return}W(D.col,D.row);return}((w=it.value)==null?void 0:w.mode)==="edit"&&wt();const j=wn(y.x,y.y);if(j){lt(j.row,j.col,"view"),o.emitModelData();return}else it.value&&wt();const T=Ve(y.x,y.y);if(T>=0){He(T);return}const P=k(y.x,y.y);if(P){P.kind==="toggle"&&(e.toggleOutline(P.outlineId),m(),o.emitModelData());return}if(y.y<ae()&&y.x>=ce()){const s=y.x-ce()+e.scrollX.value,f=M(y.x),b=f>=0?e.cellToScreenRect(0,f).x+e.colWidths.value[f]:-1;if(f>=0&&Math.abs(y.x-b)<=4){l.saveUndo(),kn=!0,zn=f,to=e.colWidths.value[f],_n=s,m();return}}if(y.x<ce()&&y.y>=ae()){const s=y.y-ae()+e.scrollY.value,f=E(y.y),b=f>=0?e.cellToScreenRect(f,0).y+e.getRowHeight(f):-1;if(f>=0&&Math.abs(y.y-b)<=4){l.saveUndo(),Dn=!0,No=f,to=e.getRowHeight(f),_n=s,m();return}}if(al(y.x,y.y)){const s=e.selection.value;s&&(e.autoFillState.value={active:!0,sourceRange:{...s},targetRange:null,direction:null,preview:!0},m());return}if(y.x<ce()||y.y<ae()){{const s=o.formulaBarRef.value,f=!!(s&&typeof document<"u"&&document.activeElement===s);(e.editingCell.value||f||We)&&rt()}if(y.y<ae()&&y.x>=ce()){const s=M(y.x);s>=0&&(e.selectRange(s,0,s,e.rowCount-1,"col"),go=!0,cn=s,vn=0)}else if(y.x<ce()&&y.y>=ae()){const s=E(y.y);s>=0&&(e.selectRange(0,s,e.colCount-1,s,"row"),go=!0,cn=0,vn=s)}else y.x<ce()&&y.y<ae()&&e.selectAll();m();return}const ee=e.screenToCell(y.x,y.y);if(!ee)return;const Q=ee.col,ue=ee.row;{const s=o.formulaBarRef.value,f=!!(s&&typeof document<"u"&&document.activeElement===s);(e.editingCell.value||f||We)&&rt()}if(u.shiftKey&&e.selection.value){const s=e.selection.value;e.selectRange(s.startCol,s.startRow,Q,ue)}else e.selectCell(Q,ue);go=!0,cn=Q,vn=ue,o.focusEditInput(),m()}function Ur(u){if(kn){const ee=Eo(u,o.canvasRef.value).x-ce()+e.scrollX.value-_n,Q=to+ee;Q>=30&&Q<=1e3?e.colWidths.value[zn]=Q:Q<30?e.colWidths.value[zn]=30:e.colWidths.value[zn]=1e3,m();return}if(Dn){const ee=Eo(u,o.canvasRef.value).y-ae()+e.scrollY.value-_n,Q=to+ee;Q>=24&&Q<=500?e.rowHeights.value[No]=Q:Q<24?e.rowHeights.value[No]=24:e.rowHeights.value[No]=500,m();return}if(e.autoFillState.value.active){const P=Eo(u,o.canvasRef.value);lr(P.x,P.y);return}if(!go){const P=o.canvasRef.value;if(!P)return;if(l.paintFmt.value){P.style.cursor="copy";return}const ee=Eo(u,P);if(wn(ee.x,ee.y)&&(P.style.cursor="pointer"),Vt(ee.x,ee.y),k(ee.x,ee.y)){P.style.cursor="pointer";return}if(Ve(ee.x,ee.y)>=0){P.style.cursor="pointer";return}if(U(ee.x,ee.y)){P.style.cursor="pointer";return}if(ee.y<ae()&&ee.x>=ce()){const Q=M(ee.x),ue=Q>=0?e.cellToScreenRect(0,Q).x+e.colWidths.value[Q]:-1;if(Q>=0&&Math.abs(ee.x-ue)<=4){P.style.cursor="col-resize";return}}if(ee.x<ce()&&ee.y>=ae()){const Q=E(ee.y),ue=Q>=0?e.cellToScreenRect(Q,0).y+e.getRowHeight(Q):-1;if(Q>=0&&Math.abs(ee.y-ue)<=4){P.style.cursor="row-resize";return}}if(al(ee.x,ee.y)){P.style.cursor="crosshair";return}P.style.cursor="cell";return}const y=Eo(u,o.canvasRef.value);if(cn<0||vn<0)return;if(y.x<ce()||y.y<ae()){if(y.y<ae()&&y.x>=ce()){const P=M(y.x);P>=0&&e.selectRange(Math.min(cn,P),0,Math.max(cn,P),e.rowCount-1,"col")}else if(y.x<ce()&&y.y>=ae()){const P=E(y.y);P>=0&&e.selectRange(0,Math.min(vn,P),e.colCount-1,Math.max(vn,P),"row")}m();return}const D=e.screenToCell(y.x,y.y);if(!D)return;const j=D.col,T=D.row;vn===0&&cn>=0&&e.selection.value&&e.selection.value.startRow===0&&e.selection.value.endRow===e.rowCount-1?e.selectRange(Math.min(cn,j),0,Math.max(cn,j),e.rowCount-1,"col"):cn===0&&vn>=0&&e.selection.value&&e.selection.value.startCol===0&&e.selection.value.endCol===e.colCount-1?e.selectRange(0,Math.min(vn,T),e.colCount-1,Math.max(vn,T),"row"):e.selectRange(cn,vn,j,T),m()}function Pr(u){const y=kn||Dn;if(go=!1,kn=!1,Dn=!1,y&&o.scheduleOptEmit(),e.autoFillState.value.active){rr();return}l.paintFmt.value&&l.applyPaintFormat()}function ar(){El();const u=kn||Dn;go=!1,kn=!1,Dn=!1,u&&o.scheduleOptEmit()}function Kr(u){u.preventDefault();const y=Eo(u,o.canvasRef.value);if(y.x<ce()&&y.y<ae()){Nt(u);return}if(y.y<ae()&&y.x>=ce()){const D=M(y.x);D>=0&&mo(u,D);return}if(y.x<ce()&&y.y>=ae()){const D=E(y.y);D>=0&&fo(u,D);return}if(y.x>=ce()&&y.y>=ae()){const D=e.screenToCell(y.x,y.y);D&&Xt(u,D.col,D.row)}}function Gr(u){const y=Eo(u,o.canvasRef.value);if(y.x<ce()||y.y<ae())return;const D=e.screenToCell(y.x,y.y);if(!D)return;const j=D.col,T=D.row;{const P=o.formulaBarRef.value,ee=!!(P&&typeof document<"u"&&document.activeElement===P);(e.editingCell.value||ee||We)&&rt()}e.selectCell(j,T),e.ensureVisible(j,T),e.startEdit(),m(),o.focusEditInput()}function qr(u){const y=e.scrollX.value+u.deltaX,D=e.scrollY.value+u.deltaY,j=40,T=o.maxScrollX.value,P=o.maxScrollY.value;if(y>=T-j&&u.deltaX>0||D>=P-j&&u.deltaY>0){const ee=Math.max(0,o.viewSize.w-28-11),Q=Math.max(0,o.viewSize.h-28-11),ue=Math.max(0,Math.ceil((y+ee)/100)+2),w=Math.max(0,Math.ceil((D+Q)/24)+2);e.ensureCapacity(ue,w)}o.clampScroll(y,D),m()}function Yr(u){if(u.touches.length!==1){dn=!1;return}const y=u.touches[0],D=o.canvasRef.value;if(!D)return;const j=D.getBoundingClientRect(),T=y.clientX-j.left,P=y.clientY-j.top,ee=y.clientX,Q=y.clientY,ue=(s,f)=>({clientX:s,clientY:f,preventDefault(){}});{const s=o.formulaBarRef.value,f=!!(s&&typeof document<"u"&&document.activeElement===s);(e.editingCell.value||f||We)&&rt()}if(al(T,P)){u.preventDefault();const s=e.selection.value;s&&(e.autoFillState.value={active:!0,sourceRange:{...s},targetRange:null,direction:null,preview:!0},dn=!0,bo=!1,en="cell",Bo=T,Hn=P,zo=e.scrollX.value,rl=e.scrollY.value);return}const w=Ve(T,P);if(w>=0){u.preventDefault(),He(w);return}if(P<ae()&&T>=ce()){const s=M(T);if(s>=0){const f=e.cellToScreenRect(0,s).x+e.colWidths.value[s];if(Math.abs(T-f)<=8){u.preventDefault(),l.saveUndo(),kn=!0,zn=s,to=e.colWidths.value[s],_n=T-ce()+e.scrollX.value,dn=!0,bo=!1;return}}}if(T<ce()&&P>=ae()){const s=E(P);if(s>=0){const f=e.cellToScreenRect(s,0).y+e.getRowHeight(s);if(Math.abs(P-f)<=8){u.preventDefault(),l.saveUndo(),Dn=!0,No=s,to=e.getRowHeight(s),_n=P-ae()+e.scrollY.value,dn=!0,bo=!1;return}}}T>=ce()&&P>=ae()?(u.preventDefault(),dn=!0,bo=!1,Fn=!1,yo=!1,en="cell",Bo=T,Hn=P,zo=e.scrollX.value,rl=e.scrollY.value,Bt=M(T),xt=E(P),Lt!==null&&clearTimeout(Lt),Lt=window.setTimeout(()=>{const s=e.selection.value;if(!!s&&Bt>=s.startCol&&Bt<=s.endCol&&xt>=s.startRow&&xt<=s.endRow){yo=!0,Xt(ue(ee,Q),Bt,xt);return}Fn=!0,tn=Bt,Wn=xt,Bt>=0&&xt>=0&&(e.selectCell(Bt,xt),m())},450)):T>=0&&P>=0&&(T<ce()||P<ae())&&(u.preventDefault(),dn=!0,bo=!1,Fn=!1,Bo=T,Hn=P,zo=e.scrollX.value,rl=e.scrollY.value,P<ae()&&T>=ce()?(en="col",Bt=M(T),xt=-1):T<ce()&&P>=ae()?(en="row",xt=E(P),Bt=-1):(en="all",Bt=-1,xt=-1),(en==="col"||en==="row"||en==="all")&&(Lt!==null&&clearTimeout(Lt),Lt=window.setTimeout(()=>{const s=e.selection.value;if(en==="all"){yo=!0,Nt(ue(ee,Q));return}if(en==="col"){if(!!s&&s.startRow===0&&s.endRow===e.rowCount-1&&Bt>=s.startCol&&Bt<=s.endCol){yo=!0,mo(ue(ee,Q),Bt);return}Fn=!0,tn=Bt,Wn=-1,Bt>=0&&(e.selectRange(Bt,0,Bt,e.rowCount-1,"col"),m())}else{if(!!s&&s.startCol===0&&s.endCol===e.colCount-1&&xt>=s.startRow&&xt<=s.endRow){yo=!0,fo(ue(ee,Q),xt);return}Fn=!0,tn=-1,Wn=xt,xt>=0&&(e.selectRange(0,xt,e.colCount-1,xt,"row"),m())}},450)))}function jr(u){if(!dn||u.touches.length!==1)return;const y=u.touches[0],D=o.canvasRef.value;if(!D)return;const j=D.getBoundingClientRect(),T=y.clientX-j.left,P=y.clientY-j.top;if(e.autoFillState.value.active){u.preventDefault(),lr(T,P);return}if(kn){const ee=T-ce()+e.scrollX.value-_n;let Q=to+ee;Q=Q<30?30:Q>1e3?1e3:Q,e.colWidths.value[zn]=Q,u.preventDefault(),m();return}if(Dn){const ee=P-ae()+e.scrollY.value-_n;let Q=to+ee;Q=Q<24?24:Q>500?500:Q,e.rowHeights.value[No]=Q,u.preventDefault(),m();return}if(Fn){if(u.preventDefault(),tn>=0&&Wn>=0){const ee=M(T),Q=E(P);ee>=0&&Q>=0&&(e.selectRange(tn,Wn,ee,Q),m())}else if(Wn===-1&&tn>=0){const ee=M(T);ee>=0&&(e.selectRange(Math.min(tn,ee),0,Math.max(tn,ee),e.rowCount-1,"col"),m())}else if(tn===-1&&Wn>=0){const ee=E(P);ee>=0&&(e.selectRange(0,Math.min(Wn,ee),e.colCount-1,Math.max(Wn,ee),"row"),m())}return}Lt!==null&&(clearTimeout(Lt),Lt=null),(Math.abs(T-Bo)>8||Math.abs(P-Hn)>8)&&(bo=!0,u.preventDefault(),o.clampScroll(zo+(Bo-T),rl+(Hn-P)),m())}function Rl(){if(dn){if(Lt!==null&&(clearTimeout(Lt),Lt=null),yo){yo=!1,dn=!1;return}if(e.autoFillState.value.active){rr(),dn=!1;return}if(kn||Dn){kn=!1,Dn=!1,o.scheduleOptEmit(),l.paintFmt.value&&l.applyPaintFormat(),dn=!1;return}if(Fn){Fn=!1,l.paintFmt.value&&l.applyPaintFormat(),dn=!1;return}if(dn=!1,!bo){if(en==="cell"&&Bt>=0&&xt>=0){const u=Date.now();Bt===Jl&&xt===Ql&&u-kl<300?(e.selectCell(Bt,xt),e.startEdit(),m(),o.focusEditInput(),kl=0):(e.commitEdit(),e.selectCell(Bt,xt),m(),kl=u),Jl=Bt,Ql=xt,o.focusEditInput()}else en==="col"&&Bt>=0?(e.commitEdit(),e.selectRange(Bt,0,Bt,e.rowCount-1,"col"),m()):en==="row"&&xt>=0?(e.commitEdit(),e.selectRange(0,xt,e.colCount-1,xt,"row"),m()):en==="all"&&(e.commitEdit(),e.selectAll(),m());l.paintFmt.value&&!e.editingCell.value&&l.applyPaintFormat()}}}function Ml(u){return u.isComposing||u.key==="Process"||u.keyCode===229}function Sl(u){return u.key.length===1&&!u.ctrlKey&&!u.metaKey&&!u.altKey}function ir(u){if(e.autoFillState.value.active){u.key==="Escape"&&(u.preventDefault(),El(),e.autoFillState.value={active:!1,sourceRange:null,targetRange:null,direction:null,preview:!1},m());return}if(e.editingCell.value)return;const y=u.ctrlKey||u.metaKey,D=u.shiftKey;switch(!0){case(u.altKey&&u.key==="ArrowDown"):u.preventDefault(),W(e.activeCell.value.col,e.activeCell.value.row);return;case(y&&(u.key==="c"||u.key==="C")):u.preventDefault(),n.copyToClipboard();return;case(y&&(u.key==="x"||u.key==="X")):u.preventDefault(),n.cutSelected();return;case(y&&(u.key==="z"||u.key==="Z")):u.preventDefault(),l.undo();return;case(y&&(u.key==="y"||u.key==="Y")):u.preventDefault(),l.redo();return;case(y&&(u.key==="v"||u.key==="V")):u.preventDefault(),l.saveUndo(),n.pasteFromClipboard().then(()=>{m(),t.nextTick(()=>o.emitModelData())});return;case(y&&(u.key==="a"||u.key==="A")):u.preventDefault(),e.selectAll(),m();return;case(y&&D&&(u.key==="l"||u.key==="L")):u.preventDefault(),e.toggleAutoFilter(),m();return;case(y&&u.key==="Home"):u.preventDefault(),e.selectCell(0,0),e.ensureVisible(0,0),m();return;case(y&&u.key==="End"):u.preventDefault(),e.selectCell(e.colCount-1,e.rowCount-1),e.ensureVisible(e.colCount-1,e.rowCount-1),m();return;case u.key==="Home":u.preventDefault(),e.selectCell(0,e.activeCell.value.row),e.ensureVisible(0,e.activeCell.value.row),m();return;case u.key==="End":u.preventDefault(),e.selectCell(e.colCount-1,e.activeCell.value.row),e.ensureVisible(e.colCount-1,e.activeCell.value.row),m();return;case u.key==="ArrowUp":u.preventDefault(),e.moveActive(0,-1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="ArrowDown":u.preventDefault(),e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="ArrowLeft":u.preventDefault(),e.moveActive(-1,0),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="ArrowRight":u.preventDefault(),e.moveActive(1,0),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="Tab":u.preventDefault(),e.moveActive(D?-1:1,0),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="Enter":u.preventDefault(),e.moveActive(0,D?-1:1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m();return;case u.key==="F2":u.preventDefault(),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(),m(),o.focusEditInput();return;case(D&&u.key==="F2"):u.preventDefault(),ft(e.activeCell.value.row,e.activeCell.value.col);return;case u.key==="Delete":case u.key==="Backspace":u.preventDefault(),l.saveUndo(),n.clearSelected(),m();return;case u.key==="Escape":u.preventDefault(),e.cancelEdit(),l.paintFmt.value=null,m();return;case Sl(u):if(Ml(u)){e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(""),m(),o.focusEditInput();return}u.preventDefault(),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(u.key),m(),t.nextTick(()=>{const j=o.editInputRef.value;j&&(j.focus(),j.setSelectionRange(1,1))});return}}let Nl=!1,Bl=!1;function Xr(u){const y=u.target.value;if(!e.editingCell.value){e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(y),oe.value=y,m();return}e.editValue.value=y,oe.value=y}function Zr(){Nl=!0,e.editingCell.value||(e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),e.startEdit(""),oe.value="",m())}function sr(u){Nl=!1,Bl=!0,setTimeout(()=>{Bl=!1},0);const y=u.target.value;e.editValue.value=y,oe.value=y}function cr(u){if(!e.editingCell.value){if(Sl(u)||Ml(u))return;ir(u);return}if(!(Nl||Ml(u))&&!(Bl&&(u.key==="Enter"||u.key==="Escape")))if(u.key==="Enter"&&(u.altKey||u.metaKey)){u.preventDefault();const y=o.editInputRef.value;if(!y)return;const D=y.selectionStart??y.value.length,j=y.selectionEnd??y.value.length,T=y.value,P=T.slice(0,D)+`
|
|
9
|
-
`+T.slice(j);e.editValue.value=P,y.value=P,y.selectionStart=y.selectionEnd=D+1,m()}else u.key==="Enter"?(u.preventDefault(),e.commitEdit().then(y=>{if(!y){m(),o.focusEditInput();return}e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m(),o.focusEditInput()})):u.key==="Tab"?(u.preventDefault(),e.commitEdit().then(y=>{if(!y){m(),o.focusEditInput();return}e.moveActive(u.shiftKey?-1:1,0),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m(),o.focusEditInput()})):u.key==="Escape"&&(u.preventDefault(),e.cancelEdit(),m(),o.focusEditInput())}function Jr(u){e.editingCell.value}function Qr(){setTimeout(()=>{e.isValidationAlertOpen()||e.editingCell.value&&e.commitEdit().then(()=>m())},0)}let pn=null;function no(){var y;const u=(y=o.wrapperRef.value)==null?void 0:y.getBoundingClientRect();if(u){const D=Do(e.props.width),j=Do(e.props.height);D!=null?o.viewSize.w=D:o.viewSize.w=u.width,j!=null?o.viewSize.h=j:o.viewSize.h=u.height}o.clampScroll(null,null),m()}function ea(){t.onMounted(()=>{const u=Do(e.props.width),y=Do(e.props.height);(u==null||y==null)&&(pn=new ResizeObserver(()=>no()),o.wrapperRef.value&&pn.observe(o.wrapperRef.value)),t.nextTick(()=>{no(),o.focusEditInput()}),e.selectCell(0,0),o.modelData.value&&o.modelData.value.length>0&&(a.value=JSON.stringify(o.modelData.value),o.sheets.value=o.modelData.value.map(D=>{const j=Ni(D,{colCount:e.props.colCount,rowCount:e.props.rowCount}),T=o.mkSheet(D.name,j),{cells:P,styles:ee}=fi(D.cells);if(Object.assign(T.cells,P),T.styles=D.styles??ee,D.borders)T.borders=D.borders;else{const Q=mi(T.styles);T.styles=Q.styles,T.borders=Q.borders}if(D.colWidths)for(const[Q,ue]of Object.entries(D.colWidths)){const w=Number(Q);w>=0&&w<T.colCount&&ue>=30&&(T.colWidths[w]=ue)}if(D.rowHeights)for(const[Q,ue]of Object.entries(D.rowHeights)){const w=Number(Q);w>=0&&w<T.rowCount&&ue>=24&&(T.rowHeights[w]=ue)}if(D.merges)for(const[Q,ue]of Object.entries(D.merges))T.merges[Q]={...ue};return T.freeze=D.freeze?{rows:D.freeze.rows,cols:D.freeze.cols}:{rows:0,cols:0},T.filter=xi(D.filter,T.cells),T.dataValidations=Array.isArray(D.dataValidations)?[...D.dataValidations]:[],T.notes=D.notes?Object.fromEntries(Object.entries(D.notes).map(([Q,ue])=>[Q,{...ue}])):{},T}),o.sheets.value.length>0&&o.loadSheet(0))}),t.watch(()=>[e.props.width,e.props.height],()=>{const u=Do(e.props.width),y=Do(e.props.height);u!=null&&y!=null?(pn==null||pn.disconnect(),pn=null):!pn&&o.wrapperRef.value&&(pn=new ResizeObserver(()=>no()),pn.observe(o.wrapperRef.value)),t.nextTick(()=>no())}),t.watch(()=>e.props.theme,()=>{B=gi(e.props.theme),m()}),t.watch(()=>({...e.cells}),()=>t.nextTick(()=>o.emitModelData()),{deep:!1}),t.watch(()=>({...e.merges}),()=>{t.nextTick(()=>o.emitModelData()),m()},{deep:!1}),t.watch(o.activeSheetIndex,()=>t.nextTick(()=>o.emitModelData())),t.watch(()=>o.modelData.value,u=>{if(!u||u.length===0)return;const y=JSON.stringify(u);if(y===a.value)return;a.value=y;const D=e.selection.value?{...e.selection.value}:null,j={...e.activeCell.value};o.sheets.value=u.map(Q=>{const ue=Ni(Q,{colCount:e.props.colCount,rowCount:e.props.rowCount}),w=o.mkSheet(Q.name,ue),{cells:s,styles:f}=fi(Q.cells);if(Object.assign(w.cells,s),w.styles=Q.styles??f,Q.borders)w.borders=Q.borders;else{const b=mi(w.styles);w.styles=b.styles,w.borders=b.borders}if(Q.colWidths)for(const[b,R]of Object.entries(Q.colWidths)){const I=Number(b);I>=0&&I<w.colCount&&R>=30&&(w.colWidths[I]=R)}if(Q.rowHeights)for(const[b,R]of Object.entries(Q.rowHeights)){const I=Number(b);I>=0&&I<w.rowCount&&R>=24&&(w.rowHeights[I]=R)}if(Q.merges)for(const[b,R]of Object.entries(Q.merges))w.merges[b]={...R};return w.freeze=Q.freeze?{rows:Q.freeze.rows,cols:Q.freeze.cols}:{rows:0,cols:0},w.filter=xi(Q.filter,w.cells),w.dataValidations=Array.isArray(Q.dataValidations)?[...Q.dataValidations]:[],w.rowOutlines=Array.isArray(Q.rowOutlines)?Q.rowOutlines.map(b=>({...b})):[],w.columnOutlines=Array.isArray(Q.columnOutlines)?Q.columnOutlines.map(b=>({...b})):[],w.notes=Q.notes?Object.fromEntries(Object.entries(Q.notes).map(([b,R])=>[b,{...R}])):{},w}),o.sheets.value.length>0&&o.loadSheet(0),D&&(e.selection.value=D),e.activeCell.value=j;const T=e.activeCell.value,P=e.selection.value,ee=e.findMerge(T.col,T.row);ee&&ee.anchor===e.cellKey(T.col,T.row)&&(!P||P.startCol===T.col&&P.startRow===T.row&&P.endCol===T.col&&P.endRow===T.row)&&e.selectCell(T.col,T.row),m()},{deep:!0}),t.onBeforeUnmount(()=>{pn==null||pn.disconnect()})}return{scheduleRender:m,render:O,renderFrozenOverlay:L,activeCellLabel:et,formulaBarDisplay:se,formulaBarDraft:oe,formulaBarExpanded:xe,onFormulaBarFocus:de,onFormulaBarInput:we,onFormulaBarKeydown:A,onFormulaBarBlur:K,acceptFormulaBarEdit:rt,cancelFormulaBarEdit:je,insertFunctionIntoCell:Re,renTab:$,renTabVal:V,onTabClick:x,onTabDblClick:H,commitTabRename:z,cclTabRename:Y,onTabRenameKd:ve,ctxMenu:ze,ctxSubmenuLeft:p,filterPopup:an,isFilterButtonHit:Ve,openFilterPopup:He,closeFilterPopup:Me,validationDropdown:sn,isValidationDropdownHit:U,openValidationDropdown:W,closeValidationDropdown:X,onValidationDropdownSelect:Ce,onCtxItemEnter:N,onTabCtxMenu:vt,onTabBarCtx:Kt,onCornerCtx:Nt,onRowHdrCtx:fo,onColHdrCtx:mo,onCellCtx:Xt,noteUi:it,openNote:lt,closeNote:wt,editNoteAt:ft,saveNoteAt:At,removeNoteAt:Ft,isNoteIndicatorHit:wn,dimInputRef:Gl,dimPanel:Qn,openDimPanel:bl,onDimInput:Yl,onDimKeydown:$r,onDimBlur:zr,applyDimPanel:jl,closeDimPanel:jo,outlineGroupRows:()=>re("row"),outlineGroupCols:()=>re("column"),outlineUngroupRows:()=>Se("row"),outlineUngroupCols:()=>Se("column"),outlineExpandRows:()=>Te("row",!1),outlineCollapseRows:()=>Te("row",!0),outlineExpandCols:()=>Te("column",!1),outlineCollapseCols:()=>Te("column",!0),get showOutlineAlert(){return c},set showOutlineAlert(u){c=u},editInputStyle:_r,hScrollbarW:wl,vScrollbarH:Xo,hScrollbarLeft:Xl,vScrollbarTop:Hr,hTrackW:Lo,vTrackH:$o,hThumbW:Zo,hThumbL:Jo,vThumbH:Qo,vThumbT:vl,onVStart:Zl,onHStart:ho,onSbMove:nl,onSbUp:ol,onVTrk:eo,onHTrk:ll,onMouseDown:Wr,onMouseMove:Ur,onMouseUp:Pr,onMouseLeave:ar,onCanvasCtx:Kr,onDblClick:Gr,onWheel:qr,onTouchStart:Yr,onTouchMove:jr,onTouchEnd:Rl,onKeydown:ir,onEditInput:Xr,onEditCompositionStart:Zr,onEditCompositionEnd:sr,onEditKd:cr,onEditPaste:Jr,onEditBlur:Qr,applySize:no,setupLifecycle:ea}}function s2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ti(e,l,n,o){return l?o?n?e===l:e.toLowerCase()===l.toLowerCase():n?e.includes(l):e.toLowerCase().includes(l.toLowerCase()):!1}function c2(e,l,n,o){if(!l)return e;if(o){const i=e.indexOf(l);return i<0?e:e.slice(0,i)+n+e.slice(i+l.length)}const a=e.toLowerCase().indexOf(l.toLowerCase());return a<0?e:e.slice(0,a)+n+e.slice(a+l.length)}function d2(e,l,n,o){return l?o?e.indexOf(l)<0?e:e.split(l).join(n):e.toLowerCase().indexOf(l.toLowerCase())<0?e:e.replace(new RegExp(s2(l),"gi"),()=>n):e}function Lr(e,l,n,o,a,i,r){const d=[];if(r){for(let c=r.startRow;c<=r.endRow;c++)for(let C=r.startCol;C<=r.endCol;C++){const h=e[n(C,c)];h&&Ti(h.value,o,a,i)&&d.push({sheetIndex:l,col:C,row:c})}return d}for(const c in e){const C=e[c];if(C&&Ti(C.value,o,a,i)){const h=c.split(","),S=Number(h[0]),m=Number(h[1]);!Number.isNaN(S)&&!Number.isNaN(m)&&d.push({sheetIndex:l,col:S,row:m})}}return d}function u2(e,l,n,o){const a=t.ref(!1),i=t.ref(""),r=t.ref(""),d=t.ref("sheet"),c=t.ref(!1),C=t.ref(!1),h=t.ref(-1),S=t.ref([]),m=t.ref(""),M=t.ref(0),E=t.ref(""),B=t.computed(()=>{const oe=new Set,xe=n.activeSheetIndex.value;for(const se of S.value)se.sheetIndex===xe&&oe.add(`${se.col},${se.row}`);return oe}),G=t.computed(()=>{if(h.value<0||h.value>=S.value.length)return null;const oe=S.value[h.value];return oe.sheetIndex!==n.activeSheetIndex.value?null:`${oe.col},${oe.row}`});e.findHighlight=(oe,xe)=>{const se=`${oe},${xe}`;return G.value===se?"active":B.value.has(se)?"match":null};function te(oe){var de,we;const xe=e.cellKey(oe.col,oe.row);if(oe.sheetIndex===n.activeSheetIndex.value)return((de=e.cells[xe])==null?void 0:de.value)??"";const se=n.sheets.value[oe.sheetIndex];return((we=se==null?void 0:se.cells[xe])==null?void 0:we.value)??""}function ge(oe,xe){const se=e.cellKey(oe.col,oe.row);if(oe.sheetIndex===n.activeSheetIndex.value)e.setCellValue(oe.col,oe.row,xe);else{const de=n.sheets.value[oe.sheetIndex];if(!de)return;const we=de.cells[se];de.cells[se]={value:String(xe),styleId:we==null?void 0:we.styleId}}}function fe(){if(E.value){m.value=E.value;return}if(!i.value){m.value="";return}if(d.value==="selection"&&!e.selection.value){m.value=g(e.locale.value,"findNeedSelection");return}if(S.value.length===0){m.value=g(e.locale.value,"findNoResult");return}m.value=""}function Ie(){const oe=i.value,xe=[];if(oe)if(d.value==="workbook")n.sheets.value.forEach((se,de)=>{xe.push(...Lr(se.cells,de,e.cellKey,oe,c.value,C.value))});else if(d.value==="selection"){const se=e.selection.value;se&&xe.push(...Lr(e.cells,n.activeSheetIndex.value,e.cellKey,oe,c.value,C.value,se))}else xe.push(...Lr(e.cells,n.activeSheetIndex.value,e.cellKey,oe,c.value,C.value));S.value=xe,xe.length===0?h.value=-1:h.value>=xe.length?h.value=xe.length-1:h.value<0&&(h.value=0),fe()}function me(){if(h.value<0||h.value>=S.value.length)return;const oe=S.value[h.value];oe.sheetIndex!==n.activeSheetIndex.value&&n.switchSheet(oe.sheetIndex),d.value==="selection"?e.activeCell.value={col:oe.col,row:oe.row}:e.selectCell(oe.col,oe.row),e.ensureVisible(oe.col,oe.row)}const Ee=typeof requestAnimationFrame=="function"?requestAnimationFrame:oe=>setTimeout(oe,16);let Ae=!1,ce=!1;function ae(oe){if(Ae){ce=ce||oe;return}Ae=!0,ce=oe,Ee(()=>{var xe;Ae=!1,Ie(),ce&&S.value.length>0&&h.value>=0&&me(),ce=!1,(xe=e.scheduleRender)==null||xe.call(e)})}function qe(){var oe;a.value=!0,M.value++,Ie(),S.value.length>0&&(h.value=0,me()),(oe=e.scheduleRender)==null||oe.call(e)}function ut(){qe()}function J(){var oe;a.value=!1,S.value=[],h.value=-1,E.value="",m.value="",(oe=e.scheduleRender)==null||oe.call(e)}function O(){var oe;S.value.length!==0&&(h.value=(h.value+1)%S.value.length,me(),(oe=e.scheduleRender)==null||oe.call(e))}function L(){var oe;S.value.length!==0&&(h.value=(h.value-1+S.value.length)%S.value.length,me(),(oe=e.scheduleRender)==null||oe.call(e))}function le(){var we,Re;if(h.value<0||h.value>=S.value.length)return;const oe=S.value[h.value],xe=te(oe),se=c2(xe,i.value,r.value,c.value);if(se===xe)return;l.saveUndo(),ge(oe,se);const de=h.value;Ie(),S.value.length>0?(h.value=Math.min(de,S.value.length-1),O()):h.value=-1,(we=e.emitModelData)==null||we.call(e),(Re=e.scheduleRender)==null||Re.call(e)}function $e(){var de,we;const oe=i.value;if(!oe||S.value.length===0)return;l.saveUndo();let xe=0;const se=S.value.slice();for(const Re of se){const Ke=te(Re),We=d2(Ke,oe,r.value,c.value);We!==Ke&&(ge(Re,We),xe++)}S.value=[],h.value=-1,E.value=g(e.locale.value,"findReplacedAll").replace("{n}",String(xe)),fe(),(de=e.emitModelData)==null||de.call(e),(we=e.scheduleRender)==null||we.call(e)}function et(){const oe=xe=>{if(!(xe.ctrlKey||xe.metaKey))return;const de=xe.key.toLowerCase();(de==="f"||de==="h")&&(xe.preventDefault(),qe())};window.addEventListener("keydown",oe),t.onBeforeUnmount(()=>window.removeEventListener("keydown",oe))}return t.watch(i,()=>{a.value&&(E.value="",h.value=0,ae(!0))}),t.watch([d,c,C],()=>{a.value&&(E.value="",h.value=0,ae(!0))}),t.watch(e.cells,()=>{a.value&&ae(!1)},{deep:!0}),t.watch(()=>e.selection.value,()=>{a.value&&d.value==="selection"&&(h.value=0,ae(!0))}),t.watch([()=>l.undoStack.value.length,()=>l.redoStack.value.length],()=>{a.value&&ae(!1)}),{open:a,findText:i,replaceText:r,scope:d,matchCase:c,matchEntireCell:C,currentIndex:h,results:S,message:m,focusToken:M,activeSheetMatches:B,activeMatchKey:G,openFind:qe,openReplace:ut,close:J,recompute:Ie,findNext:O,findPrev:L,replace:le,replaceAll:$e,setupLifecycle:et}}const f2={class:"formula-bar__cell-label"},m2={class:"formula-bar__buttons"},p2=["title","aria-label"],h2=["title","aria-label"],g2=["title","aria-label"],b2=["rows","value"],y2=["title"],C2={key:0,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},w2={key:1,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},v2=["value"],k2={key:2,class:"sb-corner"},E2=["onClick","onMouseenter"],R2={class:"context-menu__label"},M2={key:0,class:"context-menu__arrow",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"22869"},S2=["onClick"],N2={key:0,class:"cf-modal-mask"},B2={key:0,class:"cf-modal-mask"},x2={class:"dim-panel__title"},T2={class:"dim-panel__body"},V2=["value"],D2={key:0,class:"dim-panel__error"},F2={class:"dim-panel__footer"},Vi=Ot(t.defineComponent({__name:"spreader",props:t.mergeModels({rowCount:{default:200},colCount:{default:26},width:{},height:{},theme:{default:"light"},locale:{default:"zh-CN"},noteAuthor:{default:ta}},{data:{default:()=>[]},dataModifiers:{}}),emits:["update:data"],setup(e){const l=e,n=t.useModel(e,"data"),o={value:""},a=Hp(l,{rowCount:l.rowCount,colCount:l.colCount,theme:l.theme,locale:l.locale}),i={sheets:t.ref([]),activeSheetIndex:t.ref(0),saveSheet:()=>{},loadSheet:F=>{},mkSheet:F=>({id:"",name:F,cells:{},merges:{},styles:[{}],borders:[{}],selection:null,activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:[],rowHeights:[],colCount:0,rowCount:0,freeze:{rows:0,cols:0},filter:null,conditionalFormats:[],dataValidations:[],rowOutlines:[],columnOutlines:[],notes:{}})},r=Wp(a,i),d=Zp(a,r);Up(r,{borderMenuOpen:d.borderMenuOpen,mergeMenuOpen:d.mergeMenuOpen});const c=a2(a,r,n,void 0,o);i.sheets=c.sheets,i.activeSheetIndex=c.activeSheetIndex,i.saveSheet=c.saveSheet,i.loadSheet=c.loadSheet,i.mkSheet=c.mkSheet;function C(){const F=document.documentElement,p=c.toolbarThemeVars.value;for(const[N,bt]of Object.entries(p))F.style.setProperty(N,bt)}t.watch(()=>c.toolbarThemeVars.value,C,{immediate:!0,deep:!0}),t.onBeforeUnmount(()=>{const F=document.documentElement;for(const p of Object.keys(c.toolbarThemeVars.value))F.style.removeProperty(p)});const h=i2(a,r,d,c,o);h.setupLifecycle();const S=u2(a,r,c);S.setupLifecycle();const m=t.reactive(a),M=t.reactive(r),E=t.reactive(d),B=t.reactive(c),G=c.sheets,te=c.activeSheetIndex,ge=c.sortMenuOpen,fe=c.cachedSortOrder,Ie=t.ref(!1),me=t.ref(!1),Ee=t.ref(!1),Ae=t.ref(!1),ce=t.ref(!1),ae=t.ref(!1),qe=t.ref(!1),ut=t.computed(()=>{const F=m.selection;return F?F.startCol===0&&F.endCol===m.colCount-1?"rows":F.startRow===0&&F.endRow===m.rowCount-1?"cols":null:null}),J=t.reactive(h),O=t.reactive(S),L=t.computed(()=>{const F=m.selection;return!!F&&F.startCol===F.endCol&&F.startRow===F.endRow}),le=t.computed(()=>{const F=m.selection;return F?c.canSortColumns(F.startCol,F.endCol):!1}),$e=t.computed(()=>{if(m.getFilter()!==null)return!0;const F=m.selection;if(!F)return!0;const p=Math.min(F.startCol,F.endCol),N=Math.max(F.startCol,F.endCol),bt=Math.min(F.startRow,F.endRow),vt=Math.max(F.startRow,F.endRow);for(const Kt in m.merges){const Nt=m.merges[Kt];if(!(Nt.startCol===Nt.endCol&&Nt.startRow===Nt.endRow)&&p<=Nt.endCol&&N>=Nt.startCol&&bt<=Nt.endRow&&vt>=Nt.startRow)return!1}return!0}),et=t.computed(()=>{const F=M.selNumberFormat;if(F!==jn&&F!==io)return F;const p=m.activeCell,N=a.resolveStyle(m.cells[m.cellKey(p.col,p.row)]);return typeof(N==null?void 0:N.numberFormat)=="string"?N.numberFormat:""});function oe(F){r.nfDialogOpen.value=F}const xe=t.ref(!1);function se(){xe.value=!0}function de(F){xe.value=F}function we(F){h.insertFunctionIntoCell(F)}function Re(){m.toggleAutoFilter(),J.scheduleRender()}function Ke(F){const p=m.getFilter();return p?m.getCellValue(F,p.range.startRow):""}const We=t.computed(()=>{const F=m.selection,p=F?F.startRow:m.activeCell.row,N=F?F.startCol:m.activeCell.col;return p===0&&N===0});function rt(F){const p=m.freeze;if(F==="panes"){const N=m.selection,bt=N?N.startRow:m.activeCell.row,vt=N?N.startCol:m.activeCell.col;m.setFreeze(bt,vt)}else F==="firstRow"?m.setFreeze(1,p.cols):F==="firstCol"?m.setFreeze(p.rows,1):F==="unfreeze"&&m.clearFreeze();J.scheduleRender()}const je=t.ref(null),A=t.ref(!1),K=t.ref(!1),$=t.ref(null),V=t.ref("create"),x=t.computed(()=>{const F=m.selection;if(F){const N=pt(F.startCol)+(F.startRow+1),bt=pt(F.endCol)+(F.endRow+1);return F.startCol===F.endCol&&F.startRow===F.endRow?N:`${N}:${bt}`}const p=m.activeCell;return pt(p.col)+(p.row+1)});function H(F){var bt;let p;["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(F)?p={type:"cellIs",operator:F,value:""}:F==="textContains"?p={type:"textContains",value:""}:F==="textNotContains"?p={type:"textNotContains",value:""}:F==="blank"?p={type:"blank"}:F==="notBlank"?p={type:"notBlank"}:F==="duplicate"?p={type:"duplicate"}:F==="unique"?p={type:"unique"}:p={type:"cellIs",operator:"greaterThan",value:""},$.value={id:"",condition:p,format:{backgroundColor:"#DEEBF7",color:"#17375E"},ranges:[],priority:0,stopIfTrue:!1,enabled:!0},V.value="create",(bt=je.value)==null||bt.closeOverflow(),K.value=!0}function z(){var F;$.value={id:"",condition:{type:"cellIs",operator:"greaterThan",value:""},format:{backgroundColor:"#DEEBF7",color:"#17375E"},ranges:[],priority:0,stopIfTrue:!1,enabled:!0},V.value="create",(F=je.value)==null||F.closeOverflow(),K.value=!0}function Y(){var F;(F=je.value)==null||F.closeOverflow(),A.value=!0}function ve(F){m.clearConditionalFormats(F),J.scheduleRender()}function ze(F){F.id?m.updateConditionalFormatRule(F.id,F):m.addConditionalFormatRule(F),K.value=!1}function it(F){var p;$.value=F,V.value="edit",(p=je.value)==null||p.closeOverflow(),K.value=!0}function Fe(F){m.removeConditionalFormatRule(F)}function v(F,p){m.moveConditionalFormatRule(F,p)}function Z(F,p){m.updateConditionalFormatRule(F,{enabled:p})}const lt=t.ref(!1),wt=t.ref(null),ft=t.ref("create"),At=t.computed(()=>{const F=m.selection;if(F){const N=pt(F.startCol)+(F.startRow+1),bt=pt(F.endCol)+(F.endRow+1);return F.startCol===F.endCol&&F.startRow===F.endRow?N:`${N}:${bt}`}const p=m.activeCell;return pt(p.col)+(p.row+1)}),Ft=t.ref(null);let Vt=null;function wn(F){return new Promise(p=>{Vt=p,Ft.value={...F}})}a.showValidationAlert=wn;const an=t.ref(null);function sn(F){an.value=F}function mn(){an.value=null}h.showOutlineAlert=sn,a.getSheetCellsById=F=>{const p=c.sheets.value.findIndex(N=>N.id===F||N.name===F);return p<0?null:p===c.activeSheetIndex.value?a.cells:c.sheets.value[p].cells},a.requestDataValidationDialog=()=>Dt();function Dt(){var N;const F=m.activeCell,p=a.getDataValidationRule(F.row,F.col);wt.value=p?JSON.parse(JSON.stringify(p)):null,ft.value=p?"edit":"create",(N=je.value)==null||N.closeOverflow(),lt.value=!0}function Jt(F){if(F.type==="any"){F.ranges.forEach(p=>a.clearDataValidation(p)),lt.value=!1,h.scheduleRender();return}F.id?a.updateDataValidation(F.id,F):a.createDataValidation(F),lt.value=!1,h.scheduleRender()}function Qt(){const F=m.selection;F&&a.clearDataValidation(F),lt.value=!1,h.scheduleRender()}function $n(F){Ft.value=null;const p=Vt;Vt=null,t.nextTick(()=>{const N=m.editingCell;N&&(a.selectCell(N.col,N.row),a.ensureVisible(N.col,N.row),h.scheduleRender(),c.focusEditInput())}),p==null||p(F)}const Zt=t.computed(()=>{const F=m.activeCell,p=a.getValidationInputMessage(F.row,F.col);if(!p)return null;const N=a.cellToScreenRect(F.row,F.col),bt=c.wrapperRef.value,vt=bt?bt.getBoundingClientRect():{left:0,top:0};return{title:p.title,message:p.message,x:vt.left+N.x,y:vt.top+N.y,width:N.width,height:N.height}}),Vn=t.computed(()=>{const F=h.noteUi.value;if(!F)return null;const p=a.cellToScreenRect(F.row,F.col);return{x:p.x,y:p.y,width:p.width,height:p.height}}),U=t.computed(()=>{const F=h.noteUi.value;return F?a.getNote(F.row,F.col)??null:null}),W=t.computed(()=>g(m.locale,"notePlaceholder")),X=t.computed(()=>{const F=h.noteUi.value;if(!F)return!1;const p=m.freeze;return F.row<p.rows&&F.col<p.cols});function Ce(F){r.fontSizeMenuOpen.value=F}function Ne(F){r.textColorMenuOpen.value=F}function Ve(F){r.fillColorMenuOpen.value=F}function He(F){switch(F){case"group-rows":h.outlineGroupRows();break;case"group-cols":h.outlineGroupCols();break;case"ungroup-rows":h.outlineUngroupRows();break;case"ungroup-cols":h.outlineUngroupCols();break;case"clear-rows":a.clearRowGroups();break;case"clear-cols":a.clearColumnGroups();break;case"expand-rows":h.outlineExpandRows();break;case"expand-cols":h.outlineExpandCols();break;case"collapse-rows":h.outlineCollapseRows();break;case"collapse-cols":h.outlineCollapseCols();break}}function Me(F){h.renTabVal.value=F}function Le(){h.ctxMenu.value=null}const be=F=>{c.formulaBarRef.value=F};function tt(){h.formulaBarExpanded.value=!h.formulaBarExpanded.value}const k=t.ref(null),q=F=>{c.wrapperRef.value=F,k.value=F},re=F=>{c.canvasRef.value=F},Se=F=>{c.freezeCanvasRef.value=F},Te=F=>{c.editInputRef.value=F},pe=F=>{h.dimInputRef.value=F};return(F,p)=>(t.openBlock(),t.createElementBlock("div",{class:"spreadsheet-outer",style:t.normalizeStyle(B.outerStyle)},[t.createVNode(hu,{ref_key:"toolbarRef",ref:je,locale:m.locale,"can-undo":M.canUndo,"can-redo":M.canRedo,"paint-fmt-active":M.paintFmt!==null,"has-selection":M.hasSelection,"font-family-options":M.fontFamilyOptions,"font-size-options":M.fontSizeOptions,"sel-font-family":M.selFontFamily,"sel-font-size":M.selFontSize,"font-size-input":M.fontSizeInput,"font-size-menu-open":M.fontSizeMenuOpen,"sel-font-weight":M.selFontWeight,"sel-font-style":M.selFontStyle,"sel-underline":M.selUnderline,"sel-strikethrough":M.selStrikethrough,"sel-text-color":M.selTextColor,"text-color-menu-open":M.textColorMenuOpen,"sel-fill-color":M.selFillColor,"fill-color-menu-open":M.fillColorMenuOpen,"cached-text-color":M.cachedTextColor,"cached-fill-color":M.cachedFillColor,"border-menu-open":E.borderMenuOpen,"cached-border":E.cachedBorder,"cached-border-color":E.cachedBorderColor,"cached-border-line-style":E.cachedBorderLineStyle,"sort-menu-open":t.unref(ge),"cached-sort-order":t.unref(fe),"can-sort":le.value,"outline-menu-open":Ie.value,"outline-axis":ut.value,"can-filter":$e.value,"filter-active":m.getFilter()!==null,"h-align-options":M.hAlignOptions,"v-align-options":M.vAlignOptions,"sel-h-align":M.selHAlign,"sel-v-align":M.selVAlign,"sel-wrap":M.selWrap,"merge-menu-open":E.mergeMenuOpen,"calc-menu-open":E.calcMenuOpen,"cf-menu-open":me.value,"freeze-menu-open":Ee.value,"font-menu-open":Ae.value,"h-align-menu-open":ce.value,"v-align-menu-open":ae.value,"num-fmt-menu-open":qe.value,"is-single-cell":L.value,"has-freeze":m.freeze.rows>0||m.freeze.cols>0,"freeze-panes-disabled":We.value,"sel-number-format":M.selNumberFormatDisplay,"nf-options":M.nfOptions,"can-increase-decimals":M.canIncreaseDecimals,"can-decrease-decimals":M.canDecreaseDecimals,"boundary-el":k.value,"theme-vars":B.toolbarThemeVars,onUndo:p[0]||(p[0]=N=>M.undo()),onRedo:p[1]||(p[1]=N=>M.redo()),onPaintFormat:M.onPaintFormat,onClearFormat:p[2]||(p[2]=N=>M.clearFormat()),onNumberFormatChange:p[3]||(p[3]=N=>M.onNumberFormatChange(N)),onIncreaseDecimals:M.onIncreaseDecimals,onDecreaseDecimals:M.onDecreaseDecimals,onFontFamilyChange:p[4]||(p[4]=N=>M.onFontFamilyChange(N)),onFontSizeInput:p[5]||(p[5]=N=>M.onFontSizeInput(N)),onFontSizeBlur:M.onFontSizeBlur,onFontSizeKeydown:p[6]||(p[6]=N=>M.onFontSizeKeydown(N)),onFontSizeChange:p[7]||(p[7]=N=>M.onFontSizeChange(N)),"onUpdate:fontSizeMenuOpen":p[8]||(p[8]=N=>Ce(N)),onFontSizeToggle:p[9]||(p[9]=N=>M.toggleFontSizeMenu()),onFontSizeStepUp:M.onFontSizeStepUp,onFontSizeStepDown:M.onFontSizeStepDown,onBoldToggle:M.toggleFontWeight,onItalicToggle:M.toggleFontStyle,onUnderlineToggle:M.toggleUnderline,onStrikethroughToggle:M.toggleStrikethrough,onTextColorChange:p[10]||(p[10]=N=>M.onTextColorChange(N)),"onUpdate:textColorMenuOpen":p[11]||(p[11]=N=>Ne(N)),onFillColorChange:p[12]||(p[12]=N=>M.onFillColorChange(N)),"onUpdate:fillColorMenuOpen":p[13]||(p[13]=N=>Ve(N)),onApplyTextColor:M.applyCachedTextColor,onApplyFillColor:M.applyCachedFillColor,"onUpdate:borderMenuOpen":p[14]||(p[14]=N=>M.onBorderMenuToggle(N)),onBorderChange:p[15]||(p[15]=N=>E.onBorderChange(N)),onBorderColorChange:p[16]||(p[16]=N=>E.onBorderColorChange(N)),onBorderLineStyleChange:p[17]||(p[17]=N=>E.onBorderLineStyleChange(N)),onApplyBorder:E.applyCachedBorder,"onUpdate:sortMenuOpen":p[18]||(p[18]=N=>B.onSortMenuToggle(N)),onSortChange:p[19]||(p[19]=N=>B.onSortChange(N)),onApplySort:B.applyCachedSort,"onUpdate:outlineMenuOpen":p[20]||(p[20]=N=>Ie.value=N),onOutlineAction:p[21]||(p[21]=N=>He(N)),onToggleFilter:Re,onFreezeChange:p[22]||(p[22]=N=>rt(N)),onHAlignChange:p[23]||(p[23]=N=>M.onHAlignChange(N)),onVAlignChange:p[24]||(p[24]=N=>M.onVAlignChange(N)),onWrapToggle:M.onWrapToggle,"onUpdate:mergeMenuOpen":p[25]||(p[25]=N=>E.onMergeMenuToggle(N)),onMergeChange:p[26]||(p[26]=N=>E.onMergeChange(N)),onApplyMerge:E.onApplyMerge,"onUpdate:calcMenuOpen":p[27]||(p[27]=N=>E.onCalcMenuToggle(N)),"onUpdate:cfMenuOpen":p[28]||(p[28]=N=>me.value=N),"onUpdate:freezeMenuOpen":p[29]||(p[29]=N=>Ee.value=N),"onUpdate:fontMenuOpen":p[30]||(p[30]=N=>Ae.value=N),"onUpdate:hAlignMenuOpen":p[31]||(p[31]=N=>ce.value=N),"onUpdate:vAlignMenuOpen":p[32]||(p[32]=N=>ae.value=N),"onUpdate:numFmtMenuOpen":p[33]||(p[33]=N=>qe.value=N),onCalcSum:E.onCalcSum,onCalcAvg:E.onCalcAvg,onCalcCount:E.onCalcCount,onFind:p[34]||(p[34]=N=>t.unref(S).openFind()),onCfPreset:p[35]||(p[35]=N=>H(N)),onCfNewRule:z,onCfManage:Y,onCfClear:p[36]||(p[36]=N=>ve(N)),onOpenDataValidation:Dt},null,8,["locale","can-undo","can-redo","paint-fmt-active","has-selection","font-family-options","font-size-options","sel-font-family","sel-font-size","font-size-input","font-size-menu-open","sel-font-weight","sel-font-style","sel-underline","sel-strikethrough","sel-text-color","text-color-menu-open","sel-fill-color","fill-color-menu-open","cached-text-color","cached-fill-color","border-menu-open","cached-border","cached-border-color","cached-border-line-style","sort-menu-open","cached-sort-order","can-sort","outline-menu-open","outline-axis","can-filter","filter-active","h-align-options","v-align-options","sel-h-align","sel-v-align","sel-wrap","merge-menu-open","calc-menu-open","cf-menu-open","freeze-menu-open","font-menu-open","h-align-menu-open","v-align-menu-open","num-fmt-menu-open","is-single-cell","has-freeze","freeze-panes-disabled","sel-number-format","nf-options","can-increase-decimals","can-decrease-decimals","boundary-el","theme-vars","onPaintFormat","onIncreaseDecimals","onDecreaseDecimals","onFontSizeBlur","onFontSizeStepUp","onFontSizeStepDown","onBoldToggle","onItalicToggle","onUnderlineToggle","onStrikethroughToggle","onApplyTextColor","onApplyFillColor","onApplyBorder","onApplySort","onWrapToggle","onApplyMerge","onCalcSum","onCalcAvg","onCalcCount"]),t.createVNode(Pu,{open:O.open,"find-text":O.findText,"replace-text":O.replaceText,scope:O.scope,"match-case":O.matchCase,"match-entire-cell":O.matchEntireCell,"current-index":O.currentIndex,total:O.results.length,message:O.message,"focus-token":O.focusToken,locale:m.locale,"theme-vars":B.toolbarThemeVars,"onUpdate:findText":p[37]||(p[37]=N=>t.unref(S).findText.value=N),"onUpdate:replaceText":p[38]||(p[38]=N=>t.unref(S).replaceText.value=N),"onUpdate:scope":p[39]||(p[39]=N=>t.unref(S).scope.value=N),"onUpdate:matchCase":p[40]||(p[40]=N=>t.unref(S).matchCase.value=N),"onUpdate:matchEntireCell":p[41]||(p[41]=N=>t.unref(S).matchEntireCell.value=N),onPrev:p[42]||(p[42]=N=>t.unref(S).findPrev()),onNext:p[43]||(p[43]=N=>t.unref(S).findNext()),onReplace:p[44]||(p[44]=N=>t.unref(S).replace()),onReplaceAll:p[45]||(p[45]=N=>t.unref(S).replaceAll()),onClose:p[46]||(p[46]=N=>t.unref(S).close())},null,8,["open","find-text","replace-text","scope","match-case","match-entire-cell","current-index","total","message","focus-token","locale","theme-vars"]),t.createVNode(yf,{"model-open":M.nfDialogOpen,locale:m.locale,"current-format":et.value,"is-custom":M.selNumberFormat===t.unref(io),"onUpdate:modelOpen":p[47]||(p[47]=N=>oe(N)),onApply:p[48]||(p[48]=N=>M.applyNumberFormatCode(N))},null,8,["model-open","locale","current-format","is-custom"]),t.createVNode(Nf,{"model-open":B.sortConfirmOpen,locale:m.locale,"onUpdate:modelOpen":p[49]||(p[49]=N=>B.sortConfirmOpen=N),onConfirm:p[50]||(p[50]=N=>B.confirmSort(N)),onCancel:p[51]||(p[51]=N=>B.cancelSortConfirmation())},null,8,["model-open","locale"]),t.createVNode(Kf,{"model-open":xe.value,locale:m.locale,"onUpdate:modelOpen":p[52]||(p[52]=N=>de(N)),onInsert:p[53]||(p[53]=N=>we(N))},null,8,["model-open","locale"]),t.createElementVNode("div",{class:t.normalizeClass(["formula-bar",{"formula-bar--expanded":J.formulaBarExpanded}])},[t.createElementVNode("div",f2,t.toDisplayString(J.activeCellLabel),1),t.createElementVNode("div",m2,[t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--cancel",title:t.unref(g)(m.locale,"formulaBarCancel"),"aria-label":t.unref(g)(m.locale,"cancel"),onMousedown:p[54]||(p[54]=t.withModifiers(()=>{},["prevent"])),onClick:p[55]||(p[55]=t.withModifiers((...N)=>J.cancelFormulaBarEdit&&J.cancelFormulaBarEdit(...N),["stop"]))},[...p[118]||(p[118]=[t.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 3l8 8M11 3l-8 8",fill:"none",stroke:"#e53935","stroke-width":"1.8","stroke-linecap":"round"})],-1)])],40,p2),t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--accept",title:t.unref(g)(m.locale,"formulaBarAccept"),"aria-label":t.unref(g)(m.locale,"accept"),onMousedown:p[56]||(p[56]=t.withModifiers(()=>{},["prevent"])),onClick:p[57]||(p[57]=t.withModifiers((...N)=>J.acceptFormulaBarEdit&&J.acceptFormulaBarEdit(...N),["stop"]))},[...p[119]||(p[119]=[t.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M2.5 7.5l3.5 3.5L12 3.5",fill:"none",stroke:"#2e7d32","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,h2),t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--fx",title:t.unref(g)(m.locale,"insertFunctionTitle"),"aria-label":t.unref(g)(m.locale,"insertFunctionTitle"),onMousedown:p[58]||(p[58]=t.withModifiers(()=>{},["prevent"])),onClick:t.withModifiers(se,["stop"])},[...p[120]||(p[120]=[t.createElementVNode("svg",{class:"formula-bar__fx-icon",width:"16",height:"16",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},[t.createElementVNode("path",{fill:"currentColor",d:"M841 370c3-3.3 2.7-8.3-0.6-11.3-1.5-1.3-3.4-2.1-5.3-2.1h-72.6c-2.4 0-4.6 1-6.1 2.8L633.5 504.6c-2.9 3.4-7.9 3.8-11.3 0.9-0.9-0.8-1.6-1.7-2.1-2.8l-63.5-141.3c-1.3-2.9-4.1-4.7-7.3-4.7H380.7l0.9-4.7 8-42.3c10.5-55.4 38-81.4 85.8-81.4 18.6 0 35.5 1.7 48.8 4.7l14.1-66.8c-22.6-4.7-35.2-6.1-54.9-6.1-103.3 0-156.4 44.3-175.9 147.3l-9.4 49.4h-97.6c-3.8 0-7.1 2.7-7.8 6.4L181.9 415c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H284l-89 429.9c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H269c3.8 0 7.1-2.7 7.8-6.4l89.7-433.1h135.8l68.2 139.1c1.4 2.9 1 6.4-1.2 8.8l-180.6 203c-2.9 3.3-2.6 8.4 0.7 11.3 1.5 1.3 3.4 2 5.3 2h72.7c2.4 0 4.6-1 6.1-2.8l123.7-146.7c2.8-3.4 7.9-3.8 11.3-1 0.9 0.8 1.6 1.7 2.1 2.8L676.4 784c1.3 2.8 4.1 4.7 7.3 4.7h64.6c4.4 0 8-3.6 8-8 0-1.2-0.3-2.4-0.8-3.5l-95.2-198.9c-1.4-2.9-0.9-6.4 1.3-8.8L841 370z"})],-1)])],40,g2)]),t.createElementVNode("textarea",{ref:be,class:t.normalizeClass(["formula-bar__input",{"formula-bar__input--expanded":J.formulaBarExpanded}]),rows:J.formulaBarExpanded?3:1,value:J.formulaBarDisplay,spellcheck:"false",onFocus:p[59]||(p[59]=(...N)=>J.onFormulaBarFocus&&J.onFormulaBarFocus(...N)),onInput:p[60]||(p[60]=(...N)=>J.onFormulaBarInput&&J.onFormulaBarInput(...N)),onKeydown:p[61]||(p[61]=(...N)=>J.onFormulaBarKeydown&&J.onFormulaBarKeydown(...N)),onBlur:p[62]||(p[62]=(...N)=>J.onFormulaBarBlur&&J.onFormulaBarBlur(...N))},null,42,b2),t.createElementVNode("button",{type:"button",class:"formula-bar__toggle",title:t.unref(g)(m.locale,J.formulaBarExpanded?"formulaBarCollapse":"formulaBarExpand"),onMousedown:p[63]||(p[63]=t.withModifiers(()=>{},["prevent"])),onClick:t.withModifiers(tt,["stop"])},[J.formulaBarExpanded?(t.openBlock(),t.createElementBlock("svg",w2,[...p[122]||(p[122]=[t.createElementVNode("path",{d:"M2 8l4-4 4 4",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",C2,[...p[121]||(p[121]=[t.createElementVNode("path",{d:"M2 4l4 4 4-4",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))],40,y2)],2),t.createElementVNode("div",{ref:q,class:"spreadsheet-wrapper"},[t.createElementVNode("canvas",{ref:re,class:"grid-canvas",tabindex:"0",onMousedown:p[64]||(p[64]=(...N)=>J.onMouseDown&&J.onMouseDown(...N)),onMousemove:p[65]||(p[65]=(...N)=>J.onMouseMove&&J.onMouseMove(...N)),onMouseup:p[66]||(p[66]=(...N)=>J.onMouseUp&&J.onMouseUp(...N)),onMouseleave:p[67]||(p[67]=(...N)=>J.onMouseLeave&&J.onMouseLeave(...N)),onDblclick:p[68]||(p[68]=(...N)=>J.onDblClick&&J.onDblClick(...N)),onWheel:p[69]||(p[69]=t.withModifiers((...N)=>J.onWheel&&J.onWheel(...N),["prevent"])),onFocus:p[70]||(p[70]=(...N)=>B.onCanvasFocus&&B.onCanvasFocus(...N)),onKeydown:p[71]||(p[71]=(...N)=>J.onKeydown&&J.onKeydown(...N)),onContextmenu:p[72]||(p[72]=(...N)=>J.onCanvasCtx&&J.onCanvasCtx(...N)),onTouchstart:p[73]||(p[73]=t.withModifiers((...N)=>J.onTouchStart&&J.onTouchStart(...N),["prevent"])),onTouchmove:p[74]||(p[74]=t.withModifiers((...N)=>J.onTouchMove&&J.onTouchMove(...N),["prevent"])),onTouchend:p[75]||(p[75]=(...N)=>J.onTouchEnd&&J.onTouchEnd(...N))},null,32),t.createElementVNode("canvas",{ref:Se,class:"grid-canvas grid-canvas--freeze","aria-hidden":"true"}),t.createElementVNode("textarea",{ref:Te,class:"cell-editor",value:m.editValue,style:t.normalizeStyle(J.editInputStyle),onInput:p[76]||(p[76]=(...N)=>J.onEditInput&&J.onEditInput(...N)),onKeydown:p[77]||(p[77]=(...N)=>J.onEditKd&&J.onEditKd(...N)),onCompositionstart:p[78]||(p[78]=(...N)=>J.onEditCompositionStart&&J.onEditCompositionStart(...N)),onCompositionend:p[79]||(p[79]=(...N)=>J.onEditCompositionEnd&&J.onEditCompositionEnd(...N)),onBlur:p[80]||(p[80]=(...N)=>J.onEditBlur&&J.onEditBlur(...N)),onPaste:p[81]||(p[81]=(...N)=>J.onEditPaste&&J.onEditPaste(...N))},null,44,v2),B.maxScrollY>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:"v-scrollbar",style:t.normalizeStyle({top:J.vScrollbarTop+"px",height:`calc(100% - ${J.vScrollbarTop+t.unref(11)}px)`})},[t.createElementVNode("button",{class:"sb-btn sb-btn--up",title:"",onMousedown:p[82]||(p[82]=t.withModifiers(N=>{B.clampScroll(null,m.scrollY-50),J.scheduleRender()},["prevent"]))},[...p[123]||(p[123]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--up"},null,-1)])],32),t.createElementVNode("div",{class:"sb-track sb-track--v",onMousedown:p[84]||(p[84]=(...N)=>J.onVTrk&&J.onVTrk(...N))},[t.createElementVNode("div",{class:"sb-thumb sb-thumb--v",style:t.normalizeStyle({top:J.vThumbT+"px",height:J.vThumbH+"px"}),onMousedown:p[83]||(p[83]=(...N)=>J.onVStart&&J.onVStart(...N))},null,36)],32),t.createElementVNode("button",{class:"sb-btn sb-btn--down",onMousedown:p[85]||(p[85]=t.withModifiers(N=>{B.clampScroll(null,m.scrollY+50),J.scheduleRender()},["prevent"]))},[...p[124]||(p[124]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--down"},null,-1)])],32)],4)):t.createCommentVNode("",!0),B.maxScrollX>0?(t.openBlock(),t.createElementBlock("div",{key:1,class:"h-scrollbar",style:t.normalizeStyle({left:J.hScrollbarLeft+"px",width:`calc(100% - ${J.hScrollbarLeft+t.unref(11)}px)`})},[t.createElementVNode("button",{class:"sb-btn sb-btn--left",onMousedown:p[86]||(p[86]=t.withModifiers(N=>{B.clampScroll(m.scrollX-50,null),J.scheduleRender()},["prevent"]))},[...p[125]||(p[125]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--left"},null,-1)])],32),t.createElementVNode("div",{class:"sb-track sb-track--h",onMousedown:p[88]||(p[88]=(...N)=>J.onHTrk&&J.onHTrk(...N))},[t.createElementVNode("div",{class:"sb-thumb sb-thumb--h",style:t.normalizeStyle({left:J.hThumbL+"px",width:J.hThumbW+"px"}),onMousedown:p[87]||(p[87]=(...N)=>J.onHStart&&J.onHStart(...N))},null,36)],32),t.createElementVNode("button",{class:"sb-btn sb-btn--right",onMousedown:p[89]||(p[89]=t.withModifiers(N=>{B.clampScroll(m.scrollX+50,null),J.scheduleRender()},["prevent"]))},[...p[126]||(p[126]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--right"},null,-1)])],32)],4)):t.createCommentVNode("",!0),B.maxScrollX>0&&B.maxScrollY>0?(t.openBlock(),t.createElementBlock("div",k2)):t.createCommentVNode("",!0),J.noteUi&&Vn.value?(t.openBlock(),t.createBlock(J1,{key:3,anchor:Vn.value,mode:J.noteUi.mode,note:U.value,author:l.noteAuthor,locale:m.locale,placeholder:W.value,"boundary-el":k.value,frozen:X.value,onSave:p[90]||(p[90]=N=>t.unref(h).saveNoteAt(J.noteUi.row,J.noteUi.col,N,l.noteAuthor)),onDelete:p[91]||(p[91]=N=>t.unref(h).removeNoteAt(J.noteUi.row,J.noteUi.col)),onClose:p[92]||(p[92]=N=>t.unref(h).closeNote())},null,8,["anchor","mode","note","author","locale","placeholder","boundary-el","frozen"])):t.createCommentVNode("",!0)]),t.createVNode(Bu,{locale:m.locale,sheets:t.unref(G),"active-sheet-index":t.unref(te),"ren-tab":J.renTab,"ren-tab-val":J.renTabVal,"boundary-el":k.value,onTabClick:p[93]||(p[93]=N=>J.onTabClick(N)),onTabDblclick:p[94]||(p[94]=N=>J.onTabDblClick(N)),onTabContextmenu:p[95]||(p[95]=N=>J.onTabCtxMenu(N.ev,N.i)),onTabRenameInput:p[96]||(p[96]=N=>Me(N)),onTabRenameKeydown:p[97]||(p[97]=N=>J.onTabRenameKd(N)),onTabRenameCommit:J.commitTabRename,onTabbarContextmenu:p[98]||(p[98]=N=>J.onTabBarCtx(N)),onDeleteSheet:p[99]||(p[99]=N=>{B.removeSheet(N),J.scheduleRender()}),onAddSheet:p[100]||(p[100]=N=>{B.addSheet(),J.scheduleRender()})},null,8,["locale","sheets","active-sheet-index","ren-tab","ren-tab-val","boundary-el","onTabRenameCommit"]),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"menu-pop"},{default:t.withCtx(()=>[J.ctxMenu?(t.openBlock(),t.createElementBlock("div",{key:0,class:"context-menu",style:t.normalizeStyle({left:J.ctxMenu.x+"px",top:J.ctxMenu.y+"px"}),onClick:p[101]||(p[101]=t.withModifiers(()=>{},["stop"]))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(J.ctxMenu.items,(N,bt)=>(t.openBlock(),t.createElementBlock("div",{key:bt,class:t.normalizeClass(["context-menu__item",{"context-menu__item--disabled":N.disabled}]),onClick:vt=>!N.disabled&&N.action&&(N.action(),Le()),onMouseenter:vt=>J.onCtxItemEnter(vt,N)},[t.createElementVNode("span",R2,t.toDisplayString(N.label),1),N.children?(t.openBlock(),t.createElementBlock("svg",M2,[...p[127]||(p[127]=[t.createElementVNode("path",{d:"M361.386667 180.053333a32 32 0 0 0 0 45.226667L648.106667 512l-286.72 286.72a32 32 0 1 0 45.226666 45.226667l309.333334-309.333334a32 32 0 0 0 0-45.226666L406.613333 180.053333a32 32 0 0 0-45.226666 0z","p-id":"22870"},null,-1)])])):t.createCommentVNode("",!0),N.children?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["context-submenu",{"context-submenu--left":J.ctxSubmenuLeft}])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(N.children,(vt,Kt)=>(t.openBlock(),t.createElementBlock("div",{key:Kt,class:t.normalizeClass(["context-menu__item",{"context-menu__item--disabled":vt.disabled}]),onClick:t.withModifiers(Nt=>!vt.disabled&&vt.action&&(vt.action(),Le()),["stop"])},t.toDisplayString(vt.label),11,S2))),128))],2)):t.createCommentVNode("",!0)],42,E2))),128))],4)):t.createCommentVNode("",!0)]),_:1})])),J.filterPopup?(t.openBlock(),t.createBlock(ym,{key:J.filterPopup.col,col:J.filterPopup.col,"header-label":Ke(J.filterPopup.col),anchor:{x:J.filterPopup.x,y:J.filterPopup.y},locale:m.locale,"get-filter":m.getFilter,"set-filter":m.setFilter,"set-filter-column":m.setFilterColumn,"clear-filter-column":m.clearFilterColumn,"get-column-candidates":m.getColumnCandidates,close:J.closeFilterPopup,"boundary-el":k.value},null,8,["col","header-label","anchor","locale","get-filter","set-filter","set-filter-column","clear-filter-column","get-column-candidates","close","boundary-el"])):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[A.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[103]||(p[103]=t.withModifiers(N=>A.value=!1,["self"]))},[t.createVNode(Om,{locale:m.locale,rules:m.conditionalFormats,"theme-vars":B.toolbarThemeVars,onNew:z,onEdit:it,onDelete:Fe,onMove:v,onToggle:Z,onClose:p[102]||(p[102]=N=>A.value=!1)},null,8,["locale","rules","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[K.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[105]||(p[105]=t.withModifiers(N=>K.value=!1,["self"]))},[t.createVNode(w0,{locale:m.locale,mode:V.value,rule:$.value,"default-range-text":x.value,"theme-vars":B.toolbarThemeVars,onSave:ze,onCancel:p[104]||(p[104]=N=>K.value=!1)},null,8,["locale","mode","rule","default-range-text","theme-vars"])])):t.createCommentVNode("",!0)])),J.validationDropdown?(t.openBlock(),t.createBlock(D1,{key:`${J.validationDropdown.col},${J.validationDropdown.row}`,items:J.validationDropdown.items,current:J.validationDropdown.current,locale:m.locale,x:J.validationDropdown.x,y:J.validationDropdown.y,width:J.validationDropdown.width,height:J.validationDropdown.height,"boundary-el":k.value,onSelect:p[106]||(p[106]=N=>t.unref(h).onValidationDropdownSelect(N)),onClose:p[107]||(p[107]=N=>t.unref(h).closeValidationDropdown())},null,8,["items","current","locale","x","y","width","height","boundary-el"])):t.createCommentVNode("",!0),Zt.value?(t.openBlock(),t.createBlock(U1,{key:2,title:Zt.value.title,message:Zt.value.message,x:Zt.value.x,y:Zt.value.y,width:Zt.value.width,height:Zt.value.height},null,8,["title","message","x","y","width","height"])):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[lt.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[109]||(p[109]=t.withModifiers(N=>lt.value=!1,["self"]))},[t.createVNode(E1,{locale:m.locale,mode:ft.value,rule:wt.value,"default-range-text":At.value,"theme-vars":B.toolbarThemeVars,onSave:Jt,onClear:Qt,onCancel:p[108]||(p[108]=N=>lt.value=!1)},null,8,["locale","mode","rule","default-range-text","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[Ft.value?(t.openBlock(),t.createElementBlock("div",N2,[t.createVNode(za,{locale:m.locale,severity:Ft.value.severity,title:Ft.value.title,message:Ft.value.message,"theme-vars":B.toolbarThemeVars,onResolve:$n},null,8,["locale","severity","title","message","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[an.value?(t.openBlock(),t.createElementBlock("div",B2,[t.createVNode(za,{locale:m.locale,severity:"information",title:t.unref(g)(m.locale,"outlineAlertTitle"),message:an.value,"theme-vars":B.toolbarThemeVars,onResolve:mn},null,8,["locale","title","message","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"menu-pop"},{default:t.withCtx(()=>[J.dimPanel?(t.openBlock(),t.createElementBlock("div",{key:0,class:"dim-panel",style:t.normalizeStyle({left:J.dimPanel.x+"px",top:J.dimPanel.y+"px"}),onMousedown:p[115]||(p[115]=t.withModifiers(()=>{},["stop"])),onTouchstart:p[116]||(p[116]=t.withModifiers(()=>{},["stop"])),onClick:p[117]||(p[117]=t.withModifiers(()=>{},["stop"]))},[t.createElementVNode("div",x2,t.toDisplayString(J.dimPanel.type==="row"?t.unref(g)(m.locale,"rowHeight"):t.unref(g)(m.locale,"colWidth")),1),t.createElementVNode("div",T2,[t.createElementVNode("input",{ref:pe,class:t.normalizeClass(["dim-panel__input",{"dim-panel__input--error":J.dimPanel.error}]),type:"number",step:"1",min:"1",inputmode:"numeric",value:J.dimPanel.value,onInput:p[110]||(p[110]=(...N)=>J.onDimInput&&J.onDimInput(...N)),onKeydown:p[111]||(p[111]=(...N)=>J.onDimKeydown&&J.onDimKeydown(...N)),onBlur:p[112]||(p[112]=(...N)=>J.onDimBlur&&J.onDimBlur(...N))},null,42,V2)]),J.dimPanel.error?(t.openBlock(),t.createElementBlock("div",D2,t.toDisplayString(J.dimPanel.error),1)):t.createCommentVNode("",!0),t.createElementVNode("div",F2,[t.createElementVNode("button",{class:"dim-panel__btn dim-panel__btn--primary",onClick:p[113]||(p[113]=(...N)=>J.applyDimPanel&&J.applyDimPanel(...N))},t.toDisplayString(t.unref(g)(m.locale,"ok")),1),t.createElementVNode("button",{class:"dim-panel__btn",onClick:p[114]||(p[114]=(...N)=>J.closeDimPanel&&J.closeDimPanel(...N))},t.toDisplayString(t.unref(g)(m.locale,"cancel")),1)])],36)):t.createCommentVNode("",!0)]),_:1})]))],4))}}),[["__scopeId","data-v-9f2d05cf"]]);ko.Spreader=Vi,ko.default=Vi,Object.defineProperties(ko,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
9
|
+
`+T.slice(j);e.editValue.value=P,y.value=P,y.selectionStart=y.selectionEnd=D+1,m()}else u.key==="Enter"?(u.preventDefault(),e.commitEdit().then(y=>{if(!y){m(),o.focusEditInput();return}e.moveActive(0,1),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m(),o.focusEditInput()})):u.key==="Tab"?(u.preventDefault(),e.commitEdit().then(y=>{if(!y){m(),o.focusEditInput();return}e.moveActive(u.shiftKey?-1:1,0),e.ensureVisible(e.activeCell.value.col,e.activeCell.value.row),m(),o.focusEditInput()})):u.key==="Escape"&&(u.preventDefault(),e.cancelEdit(),m(),o.focusEditInput())}function Jr(u){e.editingCell.value}function Qr(){setTimeout(()=>{e.isValidationAlertOpen()||e.editingCell.value&&e.commitEdit().then(()=>m())},0)}let pn=null;function no(){var y;const u=(y=o.wrapperRef.value)==null?void 0:y.getBoundingClientRect();if(u){const D=Do(e.props.width),j=Do(e.props.height);D!=null?o.viewSize.w=D:o.viewSize.w=u.width,j!=null?o.viewSize.h=j:o.viewSize.h=u.height}o.clampScroll(null,null),m()}function ea(){t.onMounted(()=>{const u=Do(e.props.width),y=Do(e.props.height);(u==null||y==null)&&(pn=new ResizeObserver(()=>no()),o.wrapperRef.value&&pn.observe(o.wrapperRef.value)),t.nextTick(()=>{no(),o.focusEditInput()}),e.selectCell(0,0),o.modelData.value&&o.modelData.value.length>0&&(a.value=JSON.stringify(o.modelData.value),o.sheets.value=o.modelData.value.map(D=>{const j=Ni(D,{colCount:e.props.colCount,rowCount:e.props.rowCount}),T=o.mkSheet(D.name,j),{cells:P,styles:ee}=fi(D.cells);if(Object.assign(T.cells,P),T.styles=D.styles??ee,D.borders)T.borders=D.borders;else{const Q=mi(T.styles);T.styles=Q.styles,T.borders=Q.borders}if(D.colWidths)for(const[Q,ue]of Object.entries(D.colWidths)){const w=Number(Q);w>=0&&w<T.colCount&&ue>=30&&(T.colWidths[w]=ue)}if(D.rowHeights)for(const[Q,ue]of Object.entries(D.rowHeights)){const w=Number(Q);w>=0&&w<T.rowCount&&ue>=24&&(T.rowHeights[w]=ue)}if(D.merges)for(const[Q,ue]of Object.entries(D.merges))T.merges[Q]={...ue};return T.freeze=D.freeze?{rows:D.freeze.rows,cols:D.freeze.cols}:{rows:0,cols:0},T.filter=xi(D.filter,T.cells),T.dataValidations=Array.isArray(D.dataValidations)?[...D.dataValidations]:[],T.notes=D.notes?Object.fromEntries(Object.entries(D.notes).map(([Q,ue])=>[Q,{...ue}])):{},T}),o.sheets.value.length>0&&o.loadSheet(0))}),t.watch(()=>[e.props.width,e.props.height],()=>{const u=Do(e.props.width),y=Do(e.props.height);u!=null&&y!=null?(pn==null||pn.disconnect(),pn=null):!pn&&o.wrapperRef.value&&(pn=new ResizeObserver(()=>no()),pn.observe(o.wrapperRef.value)),t.nextTick(()=>no())}),t.watch(()=>e.props.theme,()=>{B=gi(e.props.theme),m()}),t.watch(()=>({...e.cells}),()=>t.nextTick(()=>o.emitModelData()),{deep:!1}),t.watch(()=>({...e.merges}),()=>{t.nextTick(()=>o.emitModelData()),m()},{deep:!1}),t.watch(o.activeSheetIndex,()=>t.nextTick(()=>o.emitModelData())),t.watch(()=>o.modelData.value,u=>{if(!u||u.length===0)return;const y=JSON.stringify(u);if(y===a.value)return;a.value=y;const D=e.selection.value?{...e.selection.value}:null,j={...e.activeCell.value};o.sheets.value=u.map(Q=>{const ue=Ni(Q,{colCount:e.props.colCount,rowCount:e.props.rowCount}),w=o.mkSheet(Q.name,ue),{cells:s,styles:f}=fi(Q.cells);if(Object.assign(w.cells,s),w.styles=Q.styles??f,Q.borders)w.borders=Q.borders;else{const b=mi(w.styles);w.styles=b.styles,w.borders=b.borders}if(Q.colWidths)for(const[b,R]of Object.entries(Q.colWidths)){const I=Number(b);I>=0&&I<w.colCount&&R>=30&&(w.colWidths[I]=R)}if(Q.rowHeights)for(const[b,R]of Object.entries(Q.rowHeights)){const I=Number(b);I>=0&&I<w.rowCount&&R>=24&&(w.rowHeights[I]=R)}if(Q.merges)for(const[b,R]of Object.entries(Q.merges))w.merges[b]={...R};return w.freeze=Q.freeze?{rows:Q.freeze.rows,cols:Q.freeze.cols}:{rows:0,cols:0},w.filter=xi(Q.filter,w.cells),w.dataValidations=Array.isArray(Q.dataValidations)?[...Q.dataValidations]:[],w.rowOutlines=Array.isArray(Q.rowOutlines)?Q.rowOutlines.map(b=>({...b})):[],w.columnOutlines=Array.isArray(Q.columnOutlines)?Q.columnOutlines.map(b=>({...b})):[],w.notes=Q.notes?Object.fromEntries(Object.entries(Q.notes).map(([b,R])=>[b,{...R}])):{},w}),o.sheets.value.length>0&&o.loadSheet(0),D&&(e.selection.value=D),e.activeCell.value=j;const T=e.activeCell.value,P=e.selection.value,ee=e.findMerge(T.col,T.row);ee&&ee.anchor===e.cellKey(T.col,T.row)&&(!P||P.startCol===T.col&&P.startRow===T.row&&P.endCol===T.col&&P.endRow===T.row)&&e.selectCell(T.col,T.row),m()},{deep:!0}),t.onBeforeUnmount(()=>{pn==null||pn.disconnect()})}return{scheduleRender:m,render:O,renderFrozenOverlay:L,activeCellLabel:et,formulaBarDisplay:se,formulaBarDraft:oe,formulaBarExpanded:xe,onFormulaBarFocus:de,onFormulaBarInput:we,onFormulaBarKeydown:A,onFormulaBarBlur:K,acceptFormulaBarEdit:rt,cancelFormulaBarEdit:je,insertFunctionIntoCell:Re,renTab:$,renTabVal:V,onTabClick:x,onTabDblClick:H,commitTabRename:z,cclTabRename:Y,onTabRenameKd:ve,ctxMenu:ze,ctxSubmenuLeft:p,filterPopup:an,isFilterButtonHit:Ve,openFilterPopup:He,closeFilterPopup:Me,validationDropdown:sn,isValidationDropdownHit:U,openValidationDropdown:W,closeValidationDropdown:X,onValidationDropdownSelect:Ce,onCtxItemEnter:N,onTabCtxMenu:vt,onTabBarCtx:Kt,onCornerCtx:Nt,onRowHdrCtx:fo,onColHdrCtx:mo,onCellCtx:Xt,noteUi:it,openNote:lt,closeNote:wt,editNoteAt:ft,saveNoteAt:At,removeNoteAt:Ft,isNoteIndicatorHit:wn,dimInputRef:Gl,dimPanel:Qn,openDimPanel:bl,onDimInput:Yl,onDimKeydown:$r,onDimBlur:zr,applyDimPanel:jl,closeDimPanel:jo,outlineGroupRows:()=>re("row"),outlineGroupCols:()=>re("column"),outlineUngroupRows:()=>Se("row"),outlineUngroupCols:()=>Se("column"),outlineExpandRows:()=>Te("row",!1),outlineCollapseRows:()=>Te("row",!0),outlineExpandCols:()=>Te("column",!1),outlineCollapseCols:()=>Te("column",!0),get showOutlineAlert(){return c},set showOutlineAlert(u){c=u},editInputStyle:_r,hScrollbarW:wl,vScrollbarH:Xo,hScrollbarLeft:Xl,vScrollbarTop:Hr,hTrackW:Lo,vTrackH:$o,hThumbW:Zo,hThumbL:Jo,vThumbH:Qo,vThumbT:vl,onVStart:Zl,onHStart:ho,onSbMove:nl,onSbUp:ol,onVTrk:eo,onHTrk:ll,onMouseDown:Wr,onMouseMove:Ur,onMouseUp:Pr,onMouseLeave:ar,onCanvasCtx:Kr,onDblClick:Gr,onWheel:qr,onTouchStart:Yr,onTouchMove:jr,onTouchEnd:Rl,onKeydown:ir,onEditInput:Xr,onEditCompositionStart:Zr,onEditCompositionEnd:sr,onEditKd:cr,onEditPaste:Jr,onEditBlur:Qr,applySize:no,setupLifecycle:ea}}function s2(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ti(e,l,n,o){return l?o?n?e===l:e.toLowerCase()===l.toLowerCase():n?e.includes(l):e.toLowerCase().includes(l.toLowerCase()):!1}function c2(e,l,n,o){if(!l)return e;if(o){const i=e.indexOf(l);return i<0?e:e.slice(0,i)+n+e.slice(i+l.length)}const a=e.toLowerCase().indexOf(l.toLowerCase());return a<0?e:e.slice(0,a)+n+e.slice(a+l.length)}function d2(e,l,n,o){return l?o?e.indexOf(l)<0?e:e.split(l).join(n):e.toLowerCase().indexOf(l.toLowerCase())<0?e:e.replace(new RegExp(s2(l),"gi"),()=>n):e}function Lr(e,l,n,o,a,i,r){const d=[];if(r){for(let c=r.startRow;c<=r.endRow;c++)for(let C=r.startCol;C<=r.endCol;C++){const h=e[n(C,c)];h&&Ti(h.value,o,a,i)&&d.push({sheetIndex:l,col:C,row:c})}return d}for(const c in e){const C=e[c];if(C&&Ti(C.value,o,a,i)){const h=c.split(","),S=Number(h[0]),m=Number(h[1]);!Number.isNaN(S)&&!Number.isNaN(m)&&d.push({sheetIndex:l,col:S,row:m})}}return d}function u2(e,l,n,o){const a=t.ref(!1),i=t.ref(""),r=t.ref(""),d=t.ref("sheet"),c=t.ref(!1),C=t.ref(!1),h=t.ref(-1),S=t.ref([]),m=t.ref(""),M=t.ref(0),E=t.ref(""),B=t.computed(()=>{const oe=new Set,xe=n.activeSheetIndex.value;for(const se of S.value)se.sheetIndex===xe&&oe.add(`${se.col},${se.row}`);return oe}),G=t.computed(()=>{if(h.value<0||h.value>=S.value.length)return null;const oe=S.value[h.value];return oe.sheetIndex!==n.activeSheetIndex.value?null:`${oe.col},${oe.row}`});e.findHighlight=(oe,xe)=>{const se=`${oe},${xe}`;return G.value===se?"active":B.value.has(se)?"match":null};function te(oe){var de,we;const xe=e.cellKey(oe.col,oe.row);if(oe.sheetIndex===n.activeSheetIndex.value)return((de=e.cells[xe])==null?void 0:de.value)??"";const se=n.sheets.value[oe.sheetIndex];return((we=se==null?void 0:se.cells[xe])==null?void 0:we.value)??""}function ge(oe,xe){const se=e.cellKey(oe.col,oe.row);if(oe.sheetIndex===n.activeSheetIndex.value)e.setCellValue(oe.col,oe.row,xe);else{const de=n.sheets.value[oe.sheetIndex];if(!de)return;const we=de.cells[se];de.cells[se]={value:String(xe),styleId:we==null?void 0:we.styleId}}}function fe(){if(E.value){m.value=E.value;return}if(!i.value){m.value="";return}if(d.value==="selection"&&!e.selection.value){m.value=g(e.locale.value,"findNeedSelection");return}if(S.value.length===0){m.value=g(e.locale.value,"findNoResult");return}m.value=""}function Ie(){const oe=i.value,xe=[];if(oe)if(d.value==="workbook")n.sheets.value.forEach((se,de)=>{xe.push(...Lr(se.cells,de,e.cellKey,oe,c.value,C.value))});else if(d.value==="selection"){const se=e.selection.value;se&&xe.push(...Lr(e.cells,n.activeSheetIndex.value,e.cellKey,oe,c.value,C.value,se))}else xe.push(...Lr(e.cells,n.activeSheetIndex.value,e.cellKey,oe,c.value,C.value));S.value=xe,xe.length===0?h.value=-1:h.value>=xe.length?h.value=xe.length-1:h.value<0&&(h.value=0),fe()}function me(){if(h.value<0||h.value>=S.value.length)return;const oe=S.value[h.value];oe.sheetIndex!==n.activeSheetIndex.value&&n.switchSheet(oe.sheetIndex),d.value==="selection"?e.activeCell.value={col:oe.col,row:oe.row}:e.selectCell(oe.col,oe.row),e.ensureVisible(oe.col,oe.row)}const Ee=typeof requestAnimationFrame=="function"?requestAnimationFrame:oe=>setTimeout(oe,16);let Ae=!1,ce=!1;function ae(oe){if(Ae){ce=ce||oe;return}Ae=!0,ce=oe,Ee(()=>{var xe;Ae=!1,Ie(),ce&&S.value.length>0&&h.value>=0&&me(),ce=!1,(xe=e.scheduleRender)==null||xe.call(e)})}function qe(){var oe;a.value=!0,M.value++,Ie(),S.value.length>0&&(h.value=0,me()),(oe=e.scheduleRender)==null||oe.call(e)}function ut(){qe()}function J(){var oe;a.value=!1,S.value=[],h.value=-1,E.value="",m.value="",(oe=e.scheduleRender)==null||oe.call(e)}function O(){var oe;S.value.length!==0&&(h.value=(h.value+1)%S.value.length,me(),(oe=e.scheduleRender)==null||oe.call(e))}function L(){var oe;S.value.length!==0&&(h.value=(h.value-1+S.value.length)%S.value.length,me(),(oe=e.scheduleRender)==null||oe.call(e))}function le(){var we,Re;if(h.value<0||h.value>=S.value.length)return;const oe=S.value[h.value],xe=te(oe),se=c2(xe,i.value,r.value,c.value);if(se===xe)return;l.saveUndo(),ge(oe,se);const de=h.value;Ie(),S.value.length>0?(h.value=Math.min(de,S.value.length-1),O()):h.value=-1,(we=e.emitModelData)==null||we.call(e),(Re=e.scheduleRender)==null||Re.call(e)}function $e(){var de,we;const oe=i.value;if(!oe||S.value.length===0)return;l.saveUndo();let xe=0;const se=S.value.slice();for(const Re of se){const Ke=te(Re),We=d2(Ke,oe,r.value,c.value);We!==Ke&&(ge(Re,We),xe++)}S.value=[],h.value=-1,E.value=g(e.locale.value,"findReplacedAll").replace("{n}",String(xe)),fe(),(de=e.emitModelData)==null||de.call(e),(we=e.scheduleRender)==null||we.call(e)}function et(){const oe=xe=>{if(!(xe.ctrlKey||xe.metaKey))return;const de=xe.key.toLowerCase();(de==="f"||de==="h")&&(xe.preventDefault(),qe())};window.addEventListener("keydown",oe),t.onBeforeUnmount(()=>window.removeEventListener("keydown",oe))}return t.watch(i,()=>{a.value&&(E.value="",h.value=0,ae(!0))}),t.watch([d,c,C],()=>{a.value&&(E.value="",h.value=0,ae(!0))}),t.watch(e.cells,()=>{a.value&&ae(!1)},{deep:!0}),t.watch(()=>e.selection.value,()=>{a.value&&d.value==="selection"&&(h.value=0,ae(!0))}),t.watch([()=>l.undoStack.value.length,()=>l.redoStack.value.length],()=>{a.value&&ae(!1)}),{open:a,findText:i,replaceText:r,scope:d,matchCase:c,matchEntireCell:C,currentIndex:h,results:S,message:m,focusToken:M,activeSheetMatches:B,activeMatchKey:G,openFind:qe,openReplace:ut,close:J,recompute:Ie,findNext:O,findPrev:L,replace:le,replaceAll:$e,setupLifecycle:et}}const f2={class:"formula-bar__cell-label"},m2={class:"formula-bar__buttons"},p2=["title","aria-label"],h2=["title","aria-label"],g2=["title","aria-label"],b2=["rows","value"],y2=["title"],C2={key:0,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},w2={key:1,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true"},v2=["value"],k2={key:2,class:"sb-corner"},E2=["onClick","onMouseenter"],R2={class:"context-menu__label"},M2={key:0,class:"context-menu__arrow",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"22869"},S2=["onClick"],N2={key:0,class:"cf-modal-mask"},B2={key:0,class:"cf-modal-mask"},x2={class:"dim-panel__title"},T2={class:"dim-panel__body"},V2=["value"],D2={key:0,class:"dim-panel__error"},F2={class:"dim-panel__footer"},Vi=Ot(t.defineComponent({__name:"spreader",props:t.mergeModels({rowCount:{default:200},colCount:{default:26},width:{},height:{},theme:{default:"light"},locale:{default:"zh-CN"},noteAuthor:{default:ta}},{data:{default:()=>[]},dataModifiers:{}}),emits:["update:data"],setup(e){const l=e,n=t.useModel(e,"data"),o={value:""},a=Hp(l,{rowCount:l.rowCount,colCount:l.colCount,theme:l.theme,locale:l.locale}),i={sheets:t.ref([]),activeSheetIndex:t.ref(0),saveSheet:()=>{},loadSheet:F=>{},mkSheet:F=>({id:"",name:F,cells:{},merges:{},styles:[{}],borders:[{}],selection:null,activeCell:{col:0,row:0},scrollX:0,scrollY:0,colWidths:[],rowHeights:[],colCount:0,rowCount:0,freeze:{rows:0,cols:0},filter:null,conditionalFormats:[],dataValidations:[],rowOutlines:[],columnOutlines:[],notes:{}})},r=Wp(a,i),d=Zp(a,r);Up(r,{borderMenuOpen:d.borderMenuOpen,mergeMenuOpen:d.mergeMenuOpen});const c=a2(a,r,n,void 0,o);i.sheets=c.sheets,i.activeSheetIndex=c.activeSheetIndex,i.saveSheet=c.saveSheet,i.loadSheet=c.loadSheet,i.mkSheet=c.mkSheet;function C(){const F=document.documentElement,p=c.toolbarThemeVars.value;for(const[N,bt]of Object.entries(p))F.style.setProperty(N,bt)}t.watch(()=>c.toolbarThemeVars.value,C,{immediate:!0,deep:!0}),t.onBeforeUnmount(()=>{const F=document.documentElement;for(const p of Object.keys(c.toolbarThemeVars.value))F.style.removeProperty(p)});const h=i2(a,r,d,c,o);h.setupLifecycle();const S=u2(a,r,c);S.setupLifecycle();const m=t.reactive(a),M=t.reactive(r),E=t.reactive(d),B=t.reactive(c),G=c.sheets,te=c.activeSheetIndex,ge=c.sortMenuOpen,fe=c.cachedSortOrder,Ie=t.ref(!1),me=t.ref(!1),Ee=t.ref(!1),Ae=t.ref(!1),ce=t.ref(!1),ae=t.ref(!1),qe=t.ref(!1),ut=t.computed(()=>{const F=m.selection;return F?F.startCol===0&&F.endCol===m.colCount-1?"rows":F.startRow===0&&F.endRow===m.rowCount-1?"cols":null:null}),J=t.reactive(h),O=t.reactive(S),L=t.computed(()=>{const F=m.selection;return!!F&&F.startCol===F.endCol&&F.startRow===F.endRow}),le=t.computed(()=>{const F=m.selection;return F?c.canSortColumns(F.startCol,F.endCol):!1}),$e=t.computed(()=>{if(m.getFilter()!==null)return!0;const F=m.selection;if(!F)return!0;const p=Math.min(F.startCol,F.endCol),N=Math.max(F.startCol,F.endCol),bt=Math.min(F.startRow,F.endRow),vt=Math.max(F.startRow,F.endRow);for(const Kt in m.merges){const Nt=m.merges[Kt];if(!(Nt.startCol===Nt.endCol&&Nt.startRow===Nt.endRow)&&p<=Nt.endCol&&N>=Nt.startCol&&bt<=Nt.endRow&&vt>=Nt.startRow)return!1}return!0}),et=t.computed(()=>{const F=M.selNumberFormat;if(F!==jn&&F!==io)return F;const p=m.activeCell,N=a.resolveStyle(m.cells[m.cellKey(p.col,p.row)]);return typeof(N==null?void 0:N.numberFormat)=="string"?N.numberFormat:""});function oe(F){r.nfDialogOpen.value=F}const xe=t.ref(!1);function se(){xe.value=!0}function de(F){xe.value=F}function we(F){h.insertFunctionIntoCell(F)}function Re(){m.toggleAutoFilter(),J.scheduleRender()}function Ke(F){const p=m.getFilter();return p?m.getCellValue(F,p.range.startRow):""}const We=t.computed(()=>{const F=m.selection,p=F?F.startRow:m.activeCell.row,N=F?F.startCol:m.activeCell.col;return p===0&&N===0});function rt(F){const p=m.freeze;if(F==="panes"){const N=m.selection,bt=N?N.startRow:m.activeCell.row,vt=N?N.startCol:m.activeCell.col;m.setFreeze(bt,vt)}else F==="firstRow"?m.setFreeze(1,p.cols):F==="firstCol"?m.setFreeze(p.rows,1):F==="unfreeze"&&m.clearFreeze();J.scheduleRender()}const je=t.ref(null),A=t.ref(!1),K=t.ref(!1),$=t.ref(null),V=t.ref("create"),x=t.computed(()=>{const F=m.selection;if(F){const N=pt(F.startCol)+(F.startRow+1),bt=pt(F.endCol)+(F.endRow+1);return F.startCol===F.endCol&&F.startRow===F.endRow?N:`${N}:${bt}`}const p=m.activeCell;return pt(p.col)+(p.row+1)});function H(F){var bt;let p;["equal","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","between","notBetween"].includes(F)?p={type:"cellIs",operator:F,value:""}:F==="textContains"?p={type:"textContains",value:""}:F==="textNotContains"?p={type:"textNotContains",value:""}:F==="blank"?p={type:"blank"}:F==="notBlank"?p={type:"notBlank"}:F==="duplicate"?p={type:"duplicate"}:F==="unique"?p={type:"unique"}:p={type:"cellIs",operator:"greaterThan",value:""},$.value={id:"",condition:p,format:{backgroundColor:"#DEEBF7",color:"#17375E"},ranges:[],priority:0,stopIfTrue:!1,enabled:!0},V.value="create",(bt=je.value)==null||bt.closeOverflow(),K.value=!0}function z(){var F;$.value={id:"",condition:{type:"cellIs",operator:"greaterThan",value:""},format:{backgroundColor:"#DEEBF7",color:"#17375E"},ranges:[],priority:0,stopIfTrue:!1,enabled:!0},V.value="create",(F=je.value)==null||F.closeOverflow(),K.value=!0}function Y(){var F;(F=je.value)==null||F.closeOverflow(),A.value=!0}function ve(F){m.clearConditionalFormats(F),J.scheduleRender()}function ze(F){F.id?m.updateConditionalFormatRule(F.id,F):m.addConditionalFormatRule(F),K.value=!1}function it(F){var p;$.value=F,V.value="edit",(p=je.value)==null||p.closeOverflow(),K.value=!0}function Fe(F){m.removeConditionalFormatRule(F)}function v(F,p){m.moveConditionalFormatRule(F,p)}function Z(F,p){m.updateConditionalFormatRule(F,{enabled:p})}const lt=t.ref(!1),wt=t.ref(null),ft=t.ref("create"),At=t.computed(()=>{const F=m.selection;if(F){const N=pt(F.startCol)+(F.startRow+1),bt=pt(F.endCol)+(F.endRow+1);return F.startCol===F.endCol&&F.startRow===F.endRow?N:`${N}:${bt}`}const p=m.activeCell;return pt(p.col)+(p.row+1)}),Ft=t.ref(null);let Vt=null;function wn(F){return new Promise(p=>{Vt=p,Ft.value={...F}})}a.showValidationAlert=wn;const an=t.ref(null);function sn(F){an.value=F}function mn(){an.value=null}h.showOutlineAlert=sn,a.getSheetCellsById=F=>{const p=c.sheets.value.findIndex(N=>N.id===F||N.name===F);return p<0?null:p===c.activeSheetIndex.value?a.cells:c.sheets.value[p].cells},a.requestDataValidationDialog=()=>Dt();function Dt(){var N;const F=m.activeCell,p=a.getDataValidationRule(F.row,F.col);wt.value=p?JSON.parse(JSON.stringify(p)):null,ft.value=p?"edit":"create",(N=je.value)==null||N.closeOverflow(),lt.value=!0}function Jt(F){if(F.type==="any"){F.ranges.forEach(p=>a.clearDataValidation(p)),lt.value=!1,h.scheduleRender();return}F.id?a.updateDataValidation(F.id,F):a.createDataValidation(F),lt.value=!1,h.scheduleRender()}function Qt(){const F=m.selection;F&&a.clearDataValidation(F),lt.value=!1,h.scheduleRender()}function $n(F){Ft.value=null;const p=Vt;Vt=null,t.nextTick(()=>{const N=m.editingCell;N&&(a.selectCell(N.col,N.row),a.ensureVisible(N.col,N.row),h.scheduleRender(),c.focusEditInput())}),p==null||p(F)}const Zt=t.computed(()=>{const F=m.activeCell,p=a.getValidationInputMessage(F.row,F.col);if(!p)return null;const N=a.cellToScreenRect(F.row,F.col),bt=c.wrapperRef.value,vt=bt?bt.getBoundingClientRect():{left:0,top:0};return{title:p.title,message:p.message,x:vt.left+N.x,y:vt.top+N.y,width:N.width,height:N.height}}),Vn=t.computed(()=>{const F=h.noteUi.value;if(!F)return null;const p=a.cellToScreenRect(F.row,F.col);return{x:p.x,y:p.y,width:p.width,height:p.height}}),U=t.computed(()=>{const F=h.noteUi.value;return F?a.getNote(F.row,F.col)??null:null}),W=t.computed(()=>g(m.locale,"notePlaceholder")),X=t.computed(()=>{const F=h.noteUi.value;if(!F)return!1;const p=m.freeze;return F.row<p.rows&&F.col<p.cols});function Ce(F){r.fontSizeMenuOpen.value=F}function Ne(F){r.textColorMenuOpen.value=F}function Ve(F){r.fillColorMenuOpen.value=F}function He(F){switch(F){case"group-rows":h.outlineGroupRows();break;case"group-cols":h.outlineGroupCols();break;case"ungroup-rows":h.outlineUngroupRows();break;case"ungroup-cols":h.outlineUngroupCols();break;case"clear-rows":a.clearRowGroups();break;case"clear-cols":a.clearColumnGroups();break;case"expand-rows":h.outlineExpandRows();break;case"expand-cols":h.outlineExpandCols();break;case"collapse-rows":h.outlineCollapseRows();break;case"collapse-cols":h.outlineCollapseCols();break}}function Me(F){h.renTabVal.value=F}function Le(){h.ctxMenu.value=null}const be=F=>{c.formulaBarRef.value=F};function tt(){h.formulaBarExpanded.value=!h.formulaBarExpanded.value}const k=t.ref(null),q=F=>{c.wrapperRef.value=F,k.value=F},re=F=>{c.canvasRef.value=F},Se=F=>{c.freezeCanvasRef.value=F},Te=F=>{c.editInputRef.value=F},pe=F=>{h.dimInputRef.value=F};return(F,p)=>(t.openBlock(),t.createElementBlock("div",{class:"spreadsheet-outer",style:t.normalizeStyle(B.outerStyle)},[t.createVNode(hu,{ref_key:"toolbarRef",ref:je,locale:m.locale,"can-undo":M.canUndo,"can-redo":M.canRedo,"paint-fmt-active":M.paintFmt!==null,"has-selection":M.hasSelection,"font-family-options":M.fontFamilyOptions,"font-size-options":M.fontSizeOptions,"sel-font-family":M.selFontFamily,"sel-font-size":M.selFontSize,"font-size-input":M.fontSizeInput,"font-size-menu-open":M.fontSizeMenuOpen,"sel-font-weight":M.selFontWeight,"sel-font-style":M.selFontStyle,"sel-underline":M.selUnderline,"sel-strikethrough":M.selStrikethrough,"sel-text-color":M.selTextColor,"text-color-menu-open":M.textColorMenuOpen,"sel-fill-color":M.selFillColor,"fill-color-menu-open":M.fillColorMenuOpen,"cached-text-color":M.cachedTextColor,"cached-fill-color":M.cachedFillColor,"border-menu-open":E.borderMenuOpen,"cached-border":E.cachedBorder,"cached-border-color":E.cachedBorderColor,"cached-border-line-style":E.cachedBorderLineStyle,"sort-menu-open":t.unref(ge),"cached-sort-order":t.unref(fe),"can-sort":le.value,"outline-menu-open":Ie.value,"outline-axis":ut.value,"can-filter":$e.value,"filter-active":m.getFilter()!==null,"h-align-options":M.hAlignOptions,"v-align-options":M.vAlignOptions,"sel-h-align":M.selHAlign,"sel-v-align":M.selVAlign,"sel-wrap":M.selWrap,"merge-menu-open":E.mergeMenuOpen,"calc-menu-open":E.calcMenuOpen,"cf-menu-open":me.value,"freeze-menu-open":Ee.value,"font-menu-open":Ae.value,"h-align-menu-open":ce.value,"v-align-menu-open":ae.value,"num-fmt-menu-open":qe.value,"is-single-cell":L.value,"has-freeze":m.freeze.rows>0||m.freeze.cols>0,"freeze-panes-disabled":We.value,"sel-number-format":M.selNumberFormatDisplay,"nf-options":M.nfOptions,"can-increase-decimals":M.canIncreaseDecimals,"can-decrease-decimals":M.canDecreaseDecimals,"boundary-el":k.value,"theme-vars":B.toolbarThemeVars,onUndo:p[0]||(p[0]=N=>M.undo()),onRedo:p[1]||(p[1]=N=>M.redo()),onPaintFormat:M.onPaintFormat,onClearFormat:p[2]||(p[2]=N=>M.clearFormat()),onNumberFormatChange:p[3]||(p[3]=N=>M.onNumberFormatChange(N)),onIncreaseDecimals:M.onIncreaseDecimals,onDecreaseDecimals:M.onDecreaseDecimals,onFontFamilyChange:p[4]||(p[4]=N=>M.onFontFamilyChange(N)),onFontSizeInput:p[5]||(p[5]=N=>M.onFontSizeInput(N)),onFontSizeBlur:M.onFontSizeBlur,onFontSizeKeydown:p[6]||(p[6]=N=>M.onFontSizeKeydown(N)),onFontSizeChange:p[7]||(p[7]=N=>M.onFontSizeChange(N)),"onUpdate:fontSizeMenuOpen":p[8]||(p[8]=N=>Ce(N)),onFontSizeToggle:p[9]||(p[9]=N=>M.toggleFontSizeMenu()),onFontSizeStepUp:M.onFontSizeStepUp,onFontSizeStepDown:M.onFontSizeStepDown,onBoldToggle:M.toggleFontWeight,onItalicToggle:M.toggleFontStyle,onUnderlineToggle:M.toggleUnderline,onStrikethroughToggle:M.toggleStrikethrough,onTextColorChange:p[10]||(p[10]=N=>M.onTextColorChange(N)),"onUpdate:textColorMenuOpen":p[11]||(p[11]=N=>Ne(N)),onFillColorChange:p[12]||(p[12]=N=>M.onFillColorChange(N)),"onUpdate:fillColorMenuOpen":p[13]||(p[13]=N=>Ve(N)),onApplyTextColor:M.applyCachedTextColor,onApplyFillColor:M.applyCachedFillColor,"onUpdate:borderMenuOpen":p[14]||(p[14]=N=>M.onBorderMenuToggle(N)),onBorderChange:p[15]||(p[15]=N=>E.onBorderChange(N)),onBorderColorChange:p[16]||(p[16]=N=>E.onBorderColorChange(N)),onBorderLineStyleChange:p[17]||(p[17]=N=>E.onBorderLineStyleChange(N)),onApplyBorder:E.applyCachedBorder,"onUpdate:sortMenuOpen":p[18]||(p[18]=N=>B.onSortMenuToggle(N)),onSortChange:p[19]||(p[19]=N=>B.onSortChange(N)),onApplySort:B.applyCachedSort,"onUpdate:outlineMenuOpen":p[20]||(p[20]=N=>Ie.value=N),onOutlineAction:p[21]||(p[21]=N=>He(N)),onToggleFilter:Re,onFreezeChange:p[22]||(p[22]=N=>rt(N)),onHAlignChange:p[23]||(p[23]=N=>M.onHAlignChange(N)),onVAlignChange:p[24]||(p[24]=N=>M.onVAlignChange(N)),onWrapToggle:M.onWrapToggle,"onUpdate:mergeMenuOpen":p[25]||(p[25]=N=>E.onMergeMenuToggle(N)),onMergeChange:p[26]||(p[26]=N=>E.onMergeChange(N)),onApplyMerge:E.onApplyMerge,"onUpdate:calcMenuOpen":p[27]||(p[27]=N=>E.onCalcMenuToggle(N)),"onUpdate:cfMenuOpen":p[28]||(p[28]=N=>me.value=N),"onUpdate:freezeMenuOpen":p[29]||(p[29]=N=>Ee.value=N),"onUpdate:fontMenuOpen":p[30]||(p[30]=N=>Ae.value=N),"onUpdate:hAlignMenuOpen":p[31]||(p[31]=N=>ce.value=N),"onUpdate:vAlignMenuOpen":p[32]||(p[32]=N=>ae.value=N),"onUpdate:numFmtMenuOpen":p[33]||(p[33]=N=>qe.value=N),onCalcSum:E.onCalcSum,onCalcAvg:E.onCalcAvg,onCalcCount:E.onCalcCount,onFind:p[34]||(p[34]=N=>t.unref(S).openFind()),onCfPreset:p[35]||(p[35]=N=>H(N)),onCfNewRule:z,onCfManage:Y,onCfClear:p[36]||(p[36]=N=>ve(N)),onOpenDataValidation:Dt},null,8,["locale","can-undo","can-redo","paint-fmt-active","has-selection","font-family-options","font-size-options","sel-font-family","sel-font-size","font-size-input","font-size-menu-open","sel-font-weight","sel-font-style","sel-underline","sel-strikethrough","sel-text-color","text-color-menu-open","sel-fill-color","fill-color-menu-open","cached-text-color","cached-fill-color","border-menu-open","cached-border","cached-border-color","cached-border-line-style","sort-menu-open","cached-sort-order","can-sort","outline-menu-open","outline-axis","can-filter","filter-active","h-align-options","v-align-options","sel-h-align","sel-v-align","sel-wrap","merge-menu-open","calc-menu-open","cf-menu-open","freeze-menu-open","font-menu-open","h-align-menu-open","v-align-menu-open","num-fmt-menu-open","is-single-cell","has-freeze","freeze-panes-disabled","sel-number-format","nf-options","can-increase-decimals","can-decrease-decimals","boundary-el","theme-vars","onPaintFormat","onIncreaseDecimals","onDecreaseDecimals","onFontSizeBlur","onFontSizeStepUp","onFontSizeStepDown","onBoldToggle","onItalicToggle","onUnderlineToggle","onStrikethroughToggle","onApplyTextColor","onApplyFillColor","onApplyBorder","onApplySort","onWrapToggle","onApplyMerge","onCalcSum","onCalcAvg","onCalcCount"]),t.createVNode(Pu,{open:O.open,"find-text":O.findText,"replace-text":O.replaceText,scope:O.scope,"match-case":O.matchCase,"match-entire-cell":O.matchEntireCell,"current-index":O.currentIndex,total:O.results.length,message:O.message,"focus-token":O.focusToken,locale:m.locale,"theme-vars":B.toolbarThemeVars,"onUpdate:findText":p[37]||(p[37]=N=>t.unref(S).findText.value=N),"onUpdate:replaceText":p[38]||(p[38]=N=>t.unref(S).replaceText.value=N),"onUpdate:scope":p[39]||(p[39]=N=>t.unref(S).scope.value=N),"onUpdate:matchCase":p[40]||(p[40]=N=>t.unref(S).matchCase.value=N),"onUpdate:matchEntireCell":p[41]||(p[41]=N=>t.unref(S).matchEntireCell.value=N),onPrev:p[42]||(p[42]=N=>t.unref(S).findPrev()),onNext:p[43]||(p[43]=N=>t.unref(S).findNext()),onReplace:p[44]||(p[44]=N=>t.unref(S).replace()),onReplaceAll:p[45]||(p[45]=N=>t.unref(S).replaceAll()),onClose:p[46]||(p[46]=N=>t.unref(S).close())},null,8,["open","find-text","replace-text","scope","match-case","match-entire-cell","current-index","total","message","focus-token","locale","theme-vars"]),t.createVNode(yf,{"model-open":M.nfDialogOpen,locale:m.locale,"current-format":et.value,"is-custom":M.selNumberFormat===t.unref(io),"onUpdate:modelOpen":p[47]||(p[47]=N=>oe(N)),onApply:p[48]||(p[48]=N=>M.applyNumberFormatCode(N))},null,8,["model-open","locale","current-format","is-custom"]),t.createVNode(Nf,{"model-open":B.sortConfirmOpen,locale:m.locale,"onUpdate:modelOpen":p[49]||(p[49]=N=>B.sortConfirmOpen=N),onConfirm:p[50]||(p[50]=N=>B.confirmSort(N)),onCancel:p[51]||(p[51]=N=>B.cancelSortConfirmation())},null,8,["model-open","locale"]),t.createVNode(Kf,{"model-open":xe.value,locale:m.locale,"onUpdate:modelOpen":p[52]||(p[52]=N=>de(N)),onInsert:p[53]||(p[53]=N=>we(N))},null,8,["model-open","locale"]),t.createElementVNode("div",{class:t.normalizeClass(["formula-bar",{"formula-bar--expanded":J.formulaBarExpanded}])},[t.createElementVNode("div",f2,t.toDisplayString(J.activeCellLabel),1),t.createElementVNode("div",m2,[t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--cancel",title:t.unref(g)(m.locale,"formulaBarCancel"),"aria-label":t.unref(g)(m.locale,"cancel"),onMousedown:p[54]||(p[54]=t.withModifiers(()=>{},["prevent"])),onClick:p[55]||(p[55]=t.withModifiers((...N)=>J.cancelFormulaBarEdit&&J.cancelFormulaBarEdit(...N),["stop"]))},[...p[118]||(p[118]=[t.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M3 3l8 8M11 3l-8 8",fill:"none",stroke:"#e53935","stroke-width":"1.8","stroke-linecap":"round"})],-1)])],40,p2),t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--accept",title:t.unref(g)(m.locale,"formulaBarAccept"),"aria-label":t.unref(g)(m.locale,"accept"),onMousedown:p[56]||(p[56]=t.withModifiers(()=>{},["prevent"])),onClick:p[57]||(p[57]=t.withModifiers((...N)=>J.acceptFormulaBarEdit&&J.acceptFormulaBarEdit(...N),["stop"]))},[...p[119]||(p[119]=[t.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true"},[t.createElementVNode("path",{d:"M2.5 7.5l3.5 3.5L12 3.5",fill:"none",stroke:"#2e7d32","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],40,h2),t.createElementVNode("button",{type:"button",class:"formula-bar__btn formula-bar__btn--fx",title:t.unref(g)(m.locale,"insertFunctionTitle"),"aria-label":t.unref(g)(m.locale,"insertFunctionTitle"),onMousedown:p[58]||(p[58]=t.withModifiers(()=>{},["prevent"])),onClick:t.withModifiers(se,["stop"])},[...p[120]||(p[120]=[t.createElementVNode("svg",{class:"formula-bar__fx-icon",width:"16",height:"16",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},[t.createElementVNode("path",{fill:"currentColor",d:"M841 370c3-3.3 2.7-8.3-0.6-11.3-1.5-1.3-3.4-2.1-5.3-2.1h-72.6c-2.4 0-4.6 1-6.1 2.8L633.5 504.6c-2.9 3.4-7.9 3.8-11.3 0.9-0.9-0.8-1.6-1.7-2.1-2.8l-63.5-141.3c-1.3-2.9-4.1-4.7-7.3-4.7H380.7l0.9-4.7 8-42.3c10.5-55.4 38-81.4 85.8-81.4 18.6 0 35.5 1.7 48.8 4.7l14.1-66.8c-22.6-4.7-35.2-6.1-54.9-6.1-103.3 0-156.4 44.3-175.9 147.3l-9.4 49.4h-97.6c-3.8 0-7.1 2.7-7.8 6.4L181.9 415c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H284l-89 429.9c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H269c3.8 0 7.1-2.7 7.8-6.4l89.7-433.1h135.8l68.2 139.1c1.4 2.9 1 6.4-1.2 8.8l-180.6 203c-2.9 3.3-2.6 8.4 0.7 11.3 1.5 1.3 3.4 2 5.3 2h72.7c2.4 0 4.6-1 6.1-2.8l123.7-146.7c2.8-3.4 7.9-3.8 11.3-1 0.9 0.8 1.6 1.7 2.1 2.8L676.4 784c1.3 2.8 4.1 4.7 7.3 4.7h64.6c4.4 0 8-3.6 8-8 0-1.2-0.3-2.4-0.8-3.5l-95.2-198.9c-1.4-2.9-0.9-6.4 1.3-8.8L841 370z"})],-1)])],40,g2)]),t.createElementVNode("textarea",{ref:be,class:t.normalizeClass(["formula-bar__input",{"formula-bar__input--expanded":J.formulaBarExpanded}]),rows:J.formulaBarExpanded?3:1,value:J.formulaBarDisplay,spellcheck:"false",onFocus:p[59]||(p[59]=(...N)=>J.onFormulaBarFocus&&J.onFormulaBarFocus(...N)),onInput:p[60]||(p[60]=(...N)=>J.onFormulaBarInput&&J.onFormulaBarInput(...N)),onKeydown:p[61]||(p[61]=(...N)=>J.onFormulaBarKeydown&&J.onFormulaBarKeydown(...N)),onBlur:p[62]||(p[62]=(...N)=>J.onFormulaBarBlur&&J.onFormulaBarBlur(...N))},null,42,b2),t.createElementVNode("button",{type:"button",class:"formula-bar__toggle",title:t.unref(g)(m.locale,J.formulaBarExpanded?"formulaBarCollapse":"formulaBarExpand"),onMousedown:p[63]||(p[63]=t.withModifiers(()=>{},["prevent"])),onClick:t.withModifiers(tt,["stop"])},[J.formulaBarExpanded?(t.openBlock(),t.createElementBlock("svg",w2,[...p[122]||(p[122]=[t.createElementVNode("path",{d:"M2 8l4-4 4 4",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(t.openBlock(),t.createElementBlock("svg",C2,[...p[121]||(p[121]=[t.createElementVNode("path",{d:"M2 4l4 4 4-4",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))],40,y2)],2),t.createElementVNode("div",{ref:q,class:"spreadsheet-wrapper"},[t.createElementVNode("canvas",{ref:re,class:"grid-canvas",tabindex:"0",onMousedown:p[64]||(p[64]=(...N)=>J.onMouseDown&&J.onMouseDown(...N)),onMousemove:p[65]||(p[65]=(...N)=>J.onMouseMove&&J.onMouseMove(...N)),onMouseup:p[66]||(p[66]=(...N)=>J.onMouseUp&&J.onMouseUp(...N)),onMouseleave:p[67]||(p[67]=(...N)=>J.onMouseLeave&&J.onMouseLeave(...N)),onDblclick:p[68]||(p[68]=(...N)=>J.onDblClick&&J.onDblClick(...N)),onWheel:p[69]||(p[69]=t.withModifiers((...N)=>J.onWheel&&J.onWheel(...N),["prevent"])),onFocus:p[70]||(p[70]=(...N)=>B.onCanvasFocus&&B.onCanvasFocus(...N)),onKeydown:p[71]||(p[71]=(...N)=>J.onKeydown&&J.onKeydown(...N)),onContextmenu:p[72]||(p[72]=(...N)=>J.onCanvasCtx&&J.onCanvasCtx(...N)),onTouchstart:p[73]||(p[73]=t.withModifiers((...N)=>J.onTouchStart&&J.onTouchStart(...N),["prevent"])),onTouchmove:p[74]||(p[74]=t.withModifiers((...N)=>J.onTouchMove&&J.onTouchMove(...N),["prevent"])),onTouchend:p[75]||(p[75]=(...N)=>J.onTouchEnd&&J.onTouchEnd(...N))},null,32),t.createElementVNode("canvas",{ref:Se,class:"grid-canvas grid-canvas--freeze","aria-hidden":"true"}),t.createElementVNode("textarea",{ref:Te,class:"cell-editor",value:m.editValue,style:t.normalizeStyle(J.editInputStyle),onInput:p[76]||(p[76]=(...N)=>J.onEditInput&&J.onEditInput(...N)),onKeydown:p[77]||(p[77]=(...N)=>J.onEditKd&&J.onEditKd(...N)),onCompositionstart:p[78]||(p[78]=(...N)=>J.onEditCompositionStart&&J.onEditCompositionStart(...N)),onCompositionend:p[79]||(p[79]=(...N)=>J.onEditCompositionEnd&&J.onEditCompositionEnd(...N)),onBlur:p[80]||(p[80]=(...N)=>J.onEditBlur&&J.onEditBlur(...N)),onPaste:p[81]||(p[81]=(...N)=>J.onEditPaste&&J.onEditPaste(...N))},null,44,v2),B.maxScrollY>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:"v-scrollbar",style:t.normalizeStyle({top:J.vScrollbarTop+"px",height:`calc(100% - ${J.vScrollbarTop+t.unref(11)}px)`})},[t.createElementVNode("button",{class:"sb-btn sb-btn--up",title:"",onMousedown:p[82]||(p[82]=t.withModifiers(N=>{B.clampScroll(null,m.scrollY-50),J.scheduleRender()},["prevent"]))},[...p[123]||(p[123]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--up"},null,-1)])],32),t.createElementVNode("div",{class:"sb-track sb-track--v",onMousedown:p[84]||(p[84]=(...N)=>J.onVTrk&&J.onVTrk(...N))},[t.createElementVNode("div",{class:"sb-thumb sb-thumb--v",style:t.normalizeStyle({top:J.vThumbT+"px",height:J.vThumbH+"px"}),onMousedown:p[83]||(p[83]=(...N)=>J.onVStart&&J.onVStart(...N))},null,36)],32),t.createElementVNode("button",{class:"sb-btn sb-btn--down",onMousedown:p[85]||(p[85]=t.withModifiers(N=>{B.clampScroll(null,m.scrollY+50),J.scheduleRender()},["prevent"]))},[...p[124]||(p[124]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--down"},null,-1)])],32)],4)):t.createCommentVNode("",!0),B.maxScrollX>0?(t.openBlock(),t.createElementBlock("div",{key:1,class:"h-scrollbar",style:t.normalizeStyle({left:J.hScrollbarLeft+"px",width:`calc(100% - ${J.hScrollbarLeft+t.unref(11)}px)`})},[t.createElementVNode("button",{class:"sb-btn sb-btn--left",onMousedown:p[86]||(p[86]=t.withModifiers(N=>{B.clampScroll(m.scrollX-50,null),J.scheduleRender()},["prevent"]))},[...p[125]||(p[125]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--left"},null,-1)])],32),t.createElementVNode("div",{class:"sb-track sb-track--h",onMousedown:p[88]||(p[88]=(...N)=>J.onHTrk&&J.onHTrk(...N))},[t.createElementVNode("div",{class:"sb-thumb sb-thumb--h",style:t.normalizeStyle({left:J.hThumbL+"px",width:J.hThumbW+"px"}),onMousedown:p[87]||(p[87]=(...N)=>J.onHStart&&J.onHStart(...N))},null,36)],32),t.createElementVNode("button",{class:"sb-btn sb-btn--right",onMousedown:p[89]||(p[89]=t.withModifiers(N=>{B.clampScroll(m.scrollX+50,null),J.scheduleRender()},["prevent"]))},[...p[126]||(p[126]=[t.createElementVNode("span",{class:"sb-arrow sb-arrow--right"},null,-1)])],32)],4)):t.createCommentVNode("",!0),B.maxScrollX>0&&B.maxScrollY>0?(t.openBlock(),t.createElementBlock("div",k2)):t.createCommentVNode("",!0),J.noteUi&&Vn.value?(t.openBlock(),t.createBlock(J1,{key:3,anchor:Vn.value,mode:J.noteUi.mode,note:U.value,author:l.noteAuthor,locale:m.locale,placeholder:W.value,"boundary-el":k.value,frozen:X.value,onSave:p[90]||(p[90]=N=>t.unref(h).saveNoteAt(J.noteUi.row,J.noteUi.col,N,l.noteAuthor)),onDelete:p[91]||(p[91]=N=>t.unref(h).removeNoteAt(J.noteUi.row,J.noteUi.col)),onClose:p[92]||(p[92]=N=>t.unref(h).closeNote())},null,8,["anchor","mode","note","author","locale","placeholder","boundary-el","frozen"])):t.createCommentVNode("",!0)]),t.createVNode(Bu,{locale:m.locale,sheets:t.unref(G),"active-sheet-index":t.unref(te),"ren-tab":J.renTab,"ren-tab-val":J.renTabVal,"boundary-el":k.value,onTabClick:p[93]||(p[93]=N=>J.onTabClick(N)),onTabDblclick:p[94]||(p[94]=N=>J.onTabDblClick(N)),onTabContextmenu:p[95]||(p[95]=N=>J.onTabCtxMenu(N.ev,N.i)),onTabRenameInput:p[96]||(p[96]=N=>Me(N)),onTabRenameKeydown:p[97]||(p[97]=N=>J.onTabRenameKd(N)),onTabRenameCommit:J.commitTabRename,onTabbarContextmenu:p[98]||(p[98]=N=>J.onTabBarCtx(N)),onDeleteSheet:p[99]||(p[99]=N=>{B.removeSheet(N),J.scheduleRender()}),onAddSheet:p[100]||(p[100]=N=>{B.addSheet(),J.scheduleRender()})},null,8,["locale","sheets","active-sheet-index","ren-tab","ren-tab-val","boundary-el","onTabRenameCommit"]),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"menu-pop"},{default:t.withCtx(()=>[J.ctxMenu?(t.openBlock(),t.createElementBlock("div",{key:0,class:"context-menu",style:t.normalizeStyle({left:J.ctxMenu.x+"px",top:J.ctxMenu.y+"px"}),onClick:p[101]||(p[101]=t.withModifiers(()=>{},["stop"]))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(J.ctxMenu.items,(N,bt)=>(t.openBlock(),t.createElementBlock("div",{key:bt,class:t.normalizeClass(["context-menu__item",{"context-menu__item--disabled":N.disabled}]),onClick:vt=>!N.disabled&&N.action&&(N.action(),Le()),onMouseenter:vt=>J.onCtxItemEnter(vt,N)},[t.createElementVNode("span",R2,t.toDisplayString(N.label),1),N.children?(t.openBlock(),t.createElementBlock("svg",M2,[...p[127]||(p[127]=[t.createElementVNode("path",{d:"M361.386667 180.053333a32 32 0 0 0 0 45.226667L648.106667 512l-286.72 286.72a32 32 0 1 0 45.226666 45.226667l309.333334-309.333334a32 32 0 0 0 0-45.226666L406.613333 180.053333a32 32 0 0 0-45.226666 0z","p-id":"22870"},null,-1)])])):t.createCommentVNode("",!0),N.children?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["context-submenu",{"context-submenu--left":J.ctxSubmenuLeft}])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(N.children,(vt,Kt)=>(t.openBlock(),t.createElementBlock("div",{key:Kt,class:t.normalizeClass(["context-menu__item",{"context-menu__item--disabled":vt.disabled}]),onClick:t.withModifiers(Nt=>!vt.disabled&&vt.action&&(vt.action(),Le()),["stop"])},t.toDisplayString(vt.label),11,S2))),128))],2)):t.createCommentVNode("",!0)],42,E2))),128))],4)):t.createCommentVNode("",!0)]),_:1})])),J.filterPopup?(t.openBlock(),t.createBlock(ym,{key:J.filterPopup.col,col:J.filterPopup.col,"header-label":Ke(J.filterPopup.col),anchor:{x:J.filterPopup.x,y:J.filterPopup.y},locale:m.locale,"get-filter":m.getFilter,"set-filter":m.setFilter,"set-filter-column":m.setFilterColumn,"clear-filter-column":m.clearFilterColumn,"get-column-candidates":m.getColumnCandidates,close:J.closeFilterPopup,"boundary-el":k.value},null,8,["col","header-label","anchor","locale","get-filter","set-filter","set-filter-column","clear-filter-column","get-column-candidates","close","boundary-el"])):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[A.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[103]||(p[103]=t.withModifiers(N=>A.value=!1,["self"]))},[t.createVNode(Om,{locale:m.locale,rules:m.conditionalFormats,"theme-vars":B.toolbarThemeVars,onNew:z,onEdit:it,onDelete:Fe,onMove:v,onToggle:Z,onClose:p[102]||(p[102]=N=>A.value=!1)},null,8,["locale","rules","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[K.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[105]||(p[105]=t.withModifiers(N=>K.value=!1,["self"]))},[t.createVNode(w0,{locale:m.locale,mode:V.value,rule:$.value,"default-range-text":x.value,"theme-vars":B.toolbarThemeVars,onSave:ze,onCancel:p[104]||(p[104]=N=>K.value=!1)},null,8,["locale","mode","rule","default-range-text","theme-vars"])])):t.createCommentVNode("",!0)])),J.validationDropdown?(t.openBlock(),t.createBlock(D1,{key:`${J.validationDropdown.col},${J.validationDropdown.row}`,items:J.validationDropdown.items,current:J.validationDropdown.current,locale:m.locale,x:J.validationDropdown.x,y:J.validationDropdown.y,width:J.validationDropdown.width,height:J.validationDropdown.height,"boundary-el":k.value,onSelect:p[106]||(p[106]=N=>t.unref(h).onValidationDropdownSelect(N)),onClose:p[107]||(p[107]=N=>t.unref(h).closeValidationDropdown())},null,8,["items","current","locale","x","y","width","height","boundary-el"])):t.createCommentVNode("",!0),Zt.value?(t.openBlock(),t.createBlock(U1,{key:2,title:Zt.value.title,message:Zt.value.message,x:Zt.value.x,y:Zt.value.y,width:Zt.value.width,height:Zt.value.height},null,8,["title","message","x","y","width","height"])):t.createCommentVNode("",!0),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[lt.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cf-modal-mask",onClick:p[109]||(p[109]=t.withModifiers(N=>lt.value=!1,["self"]))},[t.createVNode(E1,{locale:m.locale,mode:ft.value,rule:wt.value,"default-range-text":At.value,"theme-vars":B.toolbarThemeVars,onSave:Jt,onClear:Qt,onCancel:p[108]||(p[108]=N=>lt.value=!1)},null,8,["locale","mode","rule","default-range-text","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[Ft.value?(t.openBlock(),t.createElementBlock("div",N2,[t.createVNode(za,{locale:m.locale,severity:Ft.value.severity,title:Ft.value.title,message:Ft.value.message,"theme-vars":B.toolbarThemeVars,onResolve:$n},null,8,["locale","severity","title","message","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[an.value?(t.openBlock(),t.createElementBlock("div",B2,[t.createVNode(za,{locale:m.locale,severity:"information",title:t.unref(g)(m.locale,"outlineAlertTitle"),message:an.value,"theme-vars":B.toolbarThemeVars,onResolve:mn},null,8,["locale","title","message","theme-vars"])])):t.createCommentVNode("",!0)])),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createVNode(t.Transition,{name:"menu-pop"},{default:t.withCtx(()=>[J.dimPanel?(t.openBlock(),t.createElementBlock("div",{key:0,class:"dim-panel",style:t.normalizeStyle({left:J.dimPanel.x+"px",top:J.dimPanel.y+"px"}),onMousedown:p[115]||(p[115]=t.withModifiers(()=>{},["stop"])),onTouchstart:p[116]||(p[116]=t.withModifiers(()=>{},["stop"])),onClick:p[117]||(p[117]=t.withModifiers(()=>{},["stop"]))},[t.createElementVNode("div",x2,t.toDisplayString(J.dimPanel.type==="row"?t.unref(g)(m.locale,"rowHeight"):t.unref(g)(m.locale,"colWidth")),1),t.createElementVNode("div",T2,[t.createElementVNode("input",{ref:pe,class:t.normalizeClass(["dim-panel__input",{"dim-panel__input--error":J.dimPanel.error}]),type:"number",step:"1",min:"1",inputmode:"numeric",value:J.dimPanel.value,onInput:p[110]||(p[110]=(...N)=>J.onDimInput&&J.onDimInput(...N)),onKeydown:p[111]||(p[111]=(...N)=>J.onDimKeydown&&J.onDimKeydown(...N)),onBlur:p[112]||(p[112]=(...N)=>J.onDimBlur&&J.onDimBlur(...N))},null,42,V2)]),J.dimPanel.error?(t.openBlock(),t.createElementBlock("div",D2,t.toDisplayString(J.dimPanel.error),1)):t.createCommentVNode("",!0),t.createElementVNode("div",F2,[t.createElementVNode("button",{class:"dim-panel__btn dim-panel__btn--primary",onClick:p[113]||(p[113]=(...N)=>J.applyDimPanel&&J.applyDimPanel(...N))},t.toDisplayString(t.unref(g)(m.locale,"ok")),1),t.createElementVNode("button",{class:"dim-panel__btn",onClick:p[114]||(p[114]=(...N)=>J.closeDimPanel&&J.closeDimPanel(...N))},t.toDisplayString(t.unref(g)(m.locale,"cancel")),1)])],36)):t.createCommentVNode("",!0)]),_:1})]))],4))}}),[["__scopeId","data-v-0652e8b8"]]);ko.Spreader=Vi,ko.default=Vi,Object.defineProperties(ko,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|