@univerjs/sheets-ui 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";var Ns=Object.defineProperty;var As=(o,t,e)=>t in o?Ns(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var R=(o,t,e)=>(As(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("@univerjs/docs"),l=require("@univerjs/core"),_=require("@univerjs/sheets"),P=require("@wendellhu/redi"),B=require("rxjs"),v=require("@univerjs/ui"),Yo=require("@univerjs/docs-ui"),y=require("@univerjs/engine-render"),G=require("@wendellhu/redi/react-bindings"),Ds=require("rxjs/operators"),re=require("@univerjs/design"),vn=require("@univerjs/engine-numfmt"),Z=require("@univerjs/engine-formula"),U=require("react"),Oe=require("clsx"),Ps="SheetUI";function Xn(o,t){if(o==null)return;const e=t.getRenderById(o);if(e==null)return;const{mainComponent:n,scene:i,engine:r,components:s}=e,a=n,c=s.get(te.DOCS_VIEW_KEY.BACKGROUND);return{document:a,docBackground:c,scene:i,engine:r}}const bo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Ln=["零","一","二","三","四","五","六","七","八","九"],vi=["","万","亿","万亿","亿亿"],Hs=["","十","百","千"],hr={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Ge(o){if(!o)return 0;let t=0,e=0,n=0,i=!1;const r=o.split("");for(let s=0;s<r.length;s++){const a=bo[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(e+=n);else{const c=hr[r[s]],d=c.value;i=c.secUnit,i?(e=(e+n)*d,t+=e,e=0):e+=n*d,n=0}}return t+e}function Ls(o){let t="",e="",n=0,i=!0;for(;o>0;){const r=o%10;r===0?i||(i=!0,e=Ln[r]+e):(i=!1,t=Ln[r],t+=Hs[n],e=t+e),n++,o=Math.floor(o/10)}return e}function Us(o){let t=0,e="",n="",i=!1;if(o===0)return Ln[0];for(;o>0;){const r=o%1e4;i&&(n=Ln[0]+n),e=Ls(r),e+=r!==0?vi[t]:vi[0],n=e+n,i=r<1e3&&r>0,o=Math.floor(o/1e4),t++}return n}function Vs(o){if(!o)return!1;let t=!0;if(o)if(o.length===1)o==="日"||o in bo?t=!0:t=!1;else{const e=o.split("");for(let n=0;n<e.length;n++)if(!(e[n]in bo||e[n]in hr)){t=!1;break}}return t}function ln(o){if(!o)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(o);if(e){const n=o.match(t);if(n&&n.length>0){const i=n[n.length-1],r=o.lastIndexOf(i),s=o.substr(0,r),a=o.substr(r+i.length);return{isExtendNumber:!0,matchTxt:Number(i),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Bs(o){let t;return o.length===2&&(o==="周一"||o==="周二"||o==="周三"||o==="周四"||o==="周五"||o==="周六"||o==="周日")?t=!0:t=!1,t}function ks(o){let t;return o.length===3&&(o==="星期一"||o==="星期二"||o==="星期三"||o==="星期四"||o==="星期五"||o==="星期六"||o==="星期日")?t=!0:t=!1,t}function Fs(o,t){let e=0;for(let n=0;n<o.length&&o[n]<t;n++)e++;return e}function Jt(o){let t=!0;const e=o[1]-o[0];for(let n=1;n<o.length;n++)if(o[n]-o[n-1]!==e){t=!1;break}return t}function Ws(o,t,e){const n=[],i=Math.floor(t/o),r=t%o;let s=0;if(i>0){for(let a=0;a<i;a++)for(let c=0;c<e.length;c++)n[e[c]+a*o]=s,s++;for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]+o*i]=s,s++}else for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]]=s,s++;return n}function ht(o,t){const e=[];for(let n=1;n<=t;n++){const i=(n-1)%o.length,r=l.Tools.deepClone(o[i]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function js(o,t){var n;const e=[];for(let i=1;i<=t;i++){const r=(i-1)%o.length,s={s:(n=o[r])==null?void 0:n.s};e.push(s)}return e}function $s(o){let t=!0;const e=o[1]/o[0];for(let n=1;n<o.length;n++)if(o[n]/o[n-1]!==e){t=!1;break}return t}function zs(o){const t=[];for(let e=1;e<=o;e++)t.push(e);return t}function Ii(o,t,e){var r,s,a,c;const n=[],i=[];for(let d=0;d<o.length;d++)i.push(Number((r=o[d])==null?void 0:r.v));if(o.length>2&&$s(i))for(let d=1;d<=t;d++){const u=(d-1)%o.length,h=l.Tools.deepClone(o[u]),m=Number((s=o[o.length-1])==null?void 0:s.v)*(Number((a=o[1])==null?void 0:a.v)/Number((c=o[0])==null?void 0:c.v))**d;h&&(h.t!==l.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const d=zs(o.length);for(let u=1;u<=t;u++){const h=(u-1)%o.length,m=l.Tools.deepClone(o[h]),g=e===l.Direction.DOWN||e===l.Direction.RIGHT,f=Ys(o.length+u,i,d,g);m&&(m.t!==l.CellValueType.BOOLEAN&&(m.v=f),n.push(m))}}return n}function Ys(o,t,e,n=!0){function i(h){let m=0;for(let g=0;g<h.length;g++)m+=h[g];return m/h.length}const r=i(e),s=i(t);let a=0,c=0;for(let h=0;h<e.length;h++)a+=(e[h]-r)*(t[h]-s),c+=(e[h]-r)*(e[h]-r);let d;c===0?d=n?1:-1:d=a/c;const u=s-d*r;return Math.round((u+d*o)*1e5)/1e5}function Ri(o,t,e){var r;const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const a=(s-1)%o.length,c=l.Tools.deepClone(o[a]),d=`${(r=o[o.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(i),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+e*s);if(!d||!h)continue;const g=d.lastIndexOf(h),f=d.substr(0,g)+m.toString()+d.substr(g+h.length);c&&(c.v=f,n.push(c))}return n}function Tt(o,t,e,n=0){var a,c;const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const r=i[n],s=[];for(let d=1;d<=t;d++){const u=(d-1)%o.length,h=l.Tools.deepClone(o[u]);let m=0;if(((a=o[o.length-1])==null?void 0:a.v)===r[0])m=7+e*d;else{const f=`${(c=o[o.length-1])==null?void 0:c.v}`;if(f){const S=f.substr(f.length-1,1);m=Ge(S)+e*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const g=m%7;h&&(h.v=r[g],s.push(h))}return s}function Mi(o,t,e){var i;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%o.length,a=l.Tools.deepClone(o[s]),c=`${(i=o[o.length-1])==null?void 0:i.v}`,d=Ge(c)+e*r;let u;d<=0?u="零":u=Us(d),a&&(a.v=u,n.push(a))}return n}const Yt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Xs(o){let t=!1;return Object.keys(Yt).forEach(e=>{Yt[e].includes(o)&&(t=!0)}),t}function so(o){let t="";const e=[];return Object.keys(Yt).forEach(n=>{Yt[n].includes(o)&&(t=n,e.push(...Yt[n]))}),{name:t,series:e}}function bi(o,t,e,n){var s;const i=n.length,r=[];for(let a=1;a<=t;a++){const c=(a-1)%o.length,d=l.Tools.deepClone(o[c]),u=`${(s=o[o.length-1])==null?void 0:s.v}`;let h=n.indexOf(u)+e*a;h<0&&(h+=Math.abs(e)*i);const m=h%i;d&&(d.v=n[m],r.push(d))}return r}function Gs(o,t){const e=[];let n;if(t.startRow<o.startRow)n=l.Direction.UP;else if(t.endRow>o.endRow)n=l.Direction.DOWN;else if(t.startColumn<o.startColumn)n=l.Direction.LEFT;else if(t.endColumn>o.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const i=o.endRow-o.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/i),a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:o.startRow+(d+1)*i,col:o.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow+(s+1)*i,col:o.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:o.endColumn-o.startColumn}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:o.startRow-(d+1)*i,col:o.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow-(s+1)*i,col:o.startColumn},relativeRange:{startRow:i-a,endRow:i-1,startColumn:0,endColumn:o.endColumn-o.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const i=o.endColumn-o.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/i),a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)e.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(d+1)*i},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(s+1)*i},relativeRange:{startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)e.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(d+1)*i},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(s+1)*i},relativeRange:{startRow:0,startColumn:i-a,endRow:o.endRow-o.startRow,endColumn:i-1}})}}return e}function Zs(o){const t=new l.ObjectMatrix;return o.forEach(e=>{const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e;for(let a=n;a<=r;a++)for(let c=i;c<=s;c++)t.setValue(a,c,{v:null,p:null,f:null,si:null})}),t.getData()}function Rt(o,t,e,n){const i=t.get(l.IUniverInstanceService),r=e?i.getUnit(e,l.UniverInstanceType.UNIVER_SHEET):i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=n?r==null?void 0:r.getSheetBySheetId(n):r==null?void 0:r.getActiveSheet();if(!s)return null;const{startRow:a,endRow:c,startColumn:d,endColumn:u}=o,h=[],m=[];for(let g=a;g<=c;g++)s.getRowFiltered(g)||h.push(g);for(let g=d;g<=u;g++)m.push(g);return{rows:h,cols:m}}function mt(o){const{rows:t,cols:e}=o;return{startRow:t[0],endRow:t[t.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function en(o){let t=[],e=[];const n=[];return o.forEach(i=>{t.push(...i.rows),e.push(...i.cols)}),t=Array.from(new Set(t)).sort((i,r)=>i-r),e=Array.from(new Set(e)).sort((i,r)=>i-r),o.forEach(i=>{n.push({startRow:t.findIndex(r=>r===i.rows[0]),endRow:t.findIndex(r=>r===i.rows[i.rows.length-1]),startColumn:e.findIndex(r=>r===i.cols[0]),endColumn:e.findIndex(r=>r===i.cols[i.cols.length-1])})}),{ranges:n,mapFunc:(i,r)=>({row:t[i],col:e[r]})}}function Ks(o){const t=new l.ObjectMatrix;return o.forEach(e=>{const{rows:n,cols:i}=e;n.forEach(r=>{i.forEach(s=>{t.setValue(r,s,{v:null,p:null,f:null,si:null})})})}),t.getData()}var vt=(o=>(o.Append="APPEND",o.Default="DEFAULT",o.Only="ONLY",o))(vt||{}),ue=(o=>(o.NUMBER="number",o.DATE="date",o.EXTEND_NUMBER="extendNumber",o.CHN_NUMBER="chnNumber",o.CHN_WEEK2="chnWeek2",o.CHN_WEEK3="chnWeek3",o.LOOP_SERIES="loopSeries",o.FORMULA="formula",o.OTHER="other",o))(ue||{}),oe=(o=>(o.COPY="0",o.SERIES="1",o.ONLY_FORMAT="2",o.NO_FORMAT="3",o))(oe||{});const qs={type:ue.NUMBER,priority:1e3,match:o=>typeof(o==null?void 0:o.v)=="number"||(o==null?void 0:o.t)===l.CellValueType.NUMBER,isContinue:(o,t)=>o.type===ue.NUMBER,applyFunctions:{[oe.SERIES]:(o,t,e)=>{const{data:n}=o;return e===l.Direction.LEFT||e===l.Direction.UP?(n.reverse(),Ii(n,t,e).reverse()):Ii(n,t,e)}}},mr={type:ue.OTHER,priority:0,match:()=>!0,isContinue:(o,t)=>o.type===ue.OTHER},Qs={type:ue.EXTEND_NUMBER,priority:900,match:o=>ln(`${o==null?void 0:o.v}`||"").isExtendNumber,isContinue:(o,t)=>{var e;if(o.type===ue.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:i}=ln(`${(e=o.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=ln(`${t==null?void 0:t.v}`||"");if(n===r&&i===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.UP||e===l.Direction.LEFT;let r;if(n.length===1)return r=i?-1:1,be(Ri(n,t,r),i);const s=[];for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;d&&s.push(Number(ln(d).matchTxt))}return i&&(n.reverse(),s.reverse()),Jt(s)?(r=s[1]-s[0],be(Ri(n,t,r),i)):ht(n,t)}}},Js={type:ue.CHN_NUMBER,priority:830,match:o=>!!Vs(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var c,d,u;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return i?m=-1:m=1,h&&(h==="日"||Ge(h)<7)?be(Tt(n,t,m),i):be(Mi(n,t,m),i)}let r=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):r&&Ge(m)>0&&Ge(m)<7?s.push(Ge(m)+a*7):s.push(Ge(m))}if(i&&(n.reverse(),s.reverse()),Jt(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return be(Tt(n,t,m),i)}const h=s[1]-s[0];return be(Mi(n,t,h),i)}return ht(n,t)}}},ea={type:ue.CHN_WEEK2,priority:820,match:o=>!!Bs(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,be(Tt(n,t,c,1),i)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Ge(u)+s*7)}if(i&&(n.reverse(),r.reverse()),Jt(r)){const c=r[1]-r[0];return be(Tt(n,t,c,1),i)}return ht(n,t)}}},ta={type:ue.CHN_WEEK3,priority:810,match:o=>ks(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,be(Tt(n,t,c,2),i)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Ge(u)+s*7)}}if(i&&(n.reverse(),r.reverse()),Jt(r)){const c=r[1]-r[0];return be(Tt(n,t,c,2),i)}return ht(n,t)}}},na={type:ue.LOOP_SERIES,priority:800,match:o=>Xs(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>{var e;return o.type===ue.LOOP_SERIES?so(`${(e=o.cellData)==null?void 0:e.v}`||"").name===so(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(o,t,e)=>{var c,d;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP,{series:r}=so(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return i?u=-1:u=1,be(bi(n,t,u,r),i)}const s=[];let a=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===r[0]?u===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(h)+a*7))}if(i&&(n.reverse(),s.reverse()),Jt(s)){const u=s[1]-s[0];return be(bi(n,t,u,r),i)}return ht(n,t)}}};function be(o,t){return t?o.reverse():o}var oa=Object.defineProperty,ia=Object.getOwnPropertyDescriptor,ra=(o,t,e,n)=>{for(var i=n>1?void 0:n?ia(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&oa(t,e,i),i},cn=(o,t)=>(e,n)=>t(e,n,o);exports.AutoFillService=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_rules",[]);R(this,"_hooks",[]);R(this,"_applyType$",new B.BehaviorSubject(oe.SERIES));R(this,"_isFillingStyle",!0);R(this,"_autoFillLocation$",new B.BehaviorSubject(null));R(this,"autoFillLocation$",this._autoFillLocation$.asObservable());R(this,"_showMenu$",new B.BehaviorSubject(!1));R(this,"showMenu$",this._showMenu$.asObservable());R(this,"_direction",l.Direction.DOWN);R(this,"applyType$",this._applyType$.asObservable());R(this,"_menu$",new B.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));R(this,"menu$",this._menu$.asObservable());this._univerInstanceService=e,this._selectionManagerService=n,this._commandService=i,this._undoRedoService=r,this._init()}_init(){this._rules=[qs,Qs,Js,ea,ta,na,mr].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((i,r)=>(r.priority||0)>(i.priority||0)?r:i,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=vt.Append),this._hooks.push(e),l.toDisposable(()=>{const n=this._hooks.findIndex(i=>i===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(i=>i.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(i=>i.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:i,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!i||!r)return[];const s=this._hooks.filter(u=>{var h;return!((h=u.disable)!=null&&h.call(u,{source:e,target:n,unitId:i,subUnitId:r},this._direction,this.applyType))}),a=s.filter(u=>u.type===vt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(u=>u.type===vt.Default)),d=s.filter(u=>u.type===vt.Append)||[];return[...c,...d]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(i=>i.value===e?{...i,disable:n}:i))}setShowMenu(e){this._showMenu$.next(e)}fillData(e,n){var S,p;const{source:i,target:r,unitId:s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId()}=this.autoFillLocation||{},c=this.direction;if(!i||!r||s!==e||a!==n)return!1;const d=l.Rectangle.union(mt(i),mt(r)),u=this.applyType,h=this.getActiveHooks();this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{selections:[{primary:{...(p=(S=this._selectionManagerService.getLast())==null?void 0:S.primary)!=null?p:d},range:{...d,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:s,subUnitId:a});const m=[],g=[];return h.forEach(I=>{var T;const{undos:M,redos:b}=((T=I.onFillData)==null?void 0:T.call(I,{source:i,target:r,unitId:s,subUnitId:a},c,u))||{};M&&m.push(...M),b&&g.push(...b)}),g.every(I=>this._commandService.syncExecuteCommand(I.id,I.params))&&this._undoRedoService.pushUndoRedo({unitID:s,undoMutations:m,redoMutations:g}),h.forEach(I=>{var M;(M=I.onAfterFillData)==null||M.call(I,{source:i,target:r,unitId:s,subUnitId:a},c,u)}),this.setShowMenu(!0),!0}};exports.AutoFillService=ra([l.OnLifecycle(l.LifecycleStages.Rendered,exports.AutoFillService),cn(0,P.Inject(l.IUniverInstanceService)),cn(1,P.Inject(_.SelectionManagerService)),cn(2,l.ICommandService),cn(3,l.IUndoRedoService)],exports.AutoFillService);const yt=P.createIdentifier("univer.auto-fill-service"),Un={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(o,t)=>o.get(yt).fillData(t.unitId,t.subUnitId)},In={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(l.IUniverInstanceService),n=o.get(l.ICommandService),i=o.get(l.IUndoRedoService),r=_.getSheetCommandTarget(e);if(!r)return!1;const{unitId:s,subUnitId:a}=r,{clearRange:c,selectionRange:d}=t,u={subUnitId:a,unitId:s,cellValue:Zs([c])},h=_.SetRangeValuesUndoMutationFactory(o,u),{startColumn:m,startRow:g}=d;return n.executeCommand(_.SetSelectionsOperation.id,{selections:[{primary:{startColumn:m,startRow:g,endColumn:m,endRow:g,actualRow:g,actualColumn:m,isMerge:!1,isMergedMainCell:!1},range:{...d}}],unitId:s,subUnitId:a}),n.syncExecuteCommand(_.SetRangeValuesMutation.id,u)?(i.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetRangeValuesMutation.id,params:h}],redoMutations:[{id:_.SetRangeValuesMutation.id,params:u}]}),!0):!1}};function Xo(o){return o.getContextValue(l.FOCUSING_SHEET)}function ne(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(l.EDITOR_ACTIVATED)}function gr(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(l.EDITOR_ACTIVATED)&&!o.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function sa(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)}function aa(o){return o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)}function fr(o){return o.getContextValue(l.FOCUSING_FORMULA_EDITOR)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function la(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function Gt(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)&&!o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&!o.getContextValue(l.FOCUSING_EDITOR_STANDALONE)}var ie=(o=>(o.MAIN="__SpreadsheetRender__",o.ROW="__SpreadsheetRowHeader__",o.COLUMN="__SpreadsheetColumnHeader__",o.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",o))(ie||{}),W=(o=>(o.VIEW_MAIN="viewMain",o.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",o.VIEW_MAIN_TOP="viewMainTop",o.VIEW_MAIN_LEFT="viewMainLeft",o.VIEW_ROW_TOP="viewRowTop",o.VIEW_ROW_BOTTOM="viewRowBottom",o.VIEW_COLUMN_LEFT="viewColumnLeft",o.VIEW_COLUMN_RIGHT="viewColumnRight",o.VIEW_LEFT_TOP="viewLeftTop",o))(W||{});const Ti=0,tt=2,ca=3,To=[10,400],wi=1001;var da=Object.defineProperty,ua=Object.getOwnPropertyDescriptor,ha=(o,t,e,n)=>{for(var i=n>1?void 0:n?ua(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&da(t,e,i),i},Ei=(o,t)=>(e,n)=>t(e,n,o);exports.SheetSkeletonManagerService=class{constructor(t,e){R(this,"_currentSkeleton",{unitId:"",sheetId:""});R(this,"_sheetSkeletonParam",[]);R(this,"_currentSkeleton$",new B.BehaviorSubject(null));R(this,"currentSkeleton$",this._currentSkeleton$.asObservable());R(this,"_currentSkeletonBefore$",new B.BehaviorSubject(null));R(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._univerInstanceService=t,this._injector=e}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getSkeleton(this._currentSkeleton)}getUnitSkeleton(t,e){return this._getSkeleton({unitId:t,sheetId:e})}setCurrent(t){this._setCurrent(t)}removeSkeleton(t){const e=this._sheetSkeletonParam.findIndex(n=>n.unitId===t.unitId);e!==-1&&(this._sheetSkeletonParam[e].skeleton.dispose(),this._sheetSkeletonParam.splice(e,1),this._currentSkeletonBefore$.next(null),this._currentSkeleton$.next(null))}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getSkeleton(t);if(e!=null)this._reCalculate(e);else{const{unitId:i,sheetId:r}=t,s=this._univerInstanceService.getUniverSheetInstance(t.unitId),a=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:i,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getSkeleton(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getSkeleton(t);if(e)return e.skeleton;const n=this._univerInstanceService.getUniverSheetInstance(t.unitId),i=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!i||!n)return;const r=this._buildSkeleton(i,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getSkeleton(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(y.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}};exports.SheetSkeletonManagerService=ha([Ei(0,l.IUniverInstanceService),Ei(1,P.Inject(P.Injector))],exports.SheetSkeletonManagerService);class ma{constructor(){R(this,"_startColumn",-1);R(this,"_startRow",-1);R(this,"_endColumn",-1);R(this,"_endRow",-1);R(this,"_startX",0);R(this,"_startY",0);R(this,"_endX",0);R(this,"_endY",0);R(this,"_currentCell");R(this,"_rangeType",l.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(t){const{startColumn:e,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return e===s&&n===a&&i===c&&r===d}isInclude(t){const{startColumn:e,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=t;return!(c<e||s>i||a>r||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(t,e){const{startColumn:n,startRow:i,endColumn:r,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=t;this._startColumn=n,this._startRow=i,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const yi=.3;class Vn extends l.Disposable{constructor(e,n,i=!0,r){super();R(this,"_leftControl");R(this,"_rightControl");R(this,"_topControl");R(this,"_bottomControl");R(this,"_backgroundControlTop");R(this,"_backgroundControlBottom");R(this,"_backgroundControlMiddleLeft");R(this,"_backgroundControlMiddleRight");R(this,"_fillControl");R(this,"_selectionShape");R(this,"_rowHeaderBackground");R(this,"_rowHeaderBorder");R(this,"_rowHeaderGroup");R(this,"_rowHeaderHighlight");R(this,"_columnHeaderBackground");R(this,"_columnHeaderBorder");R(this,"_columnHeaderGroup");R(this,"_columnHeaderHighlight");R(this,"_topLeftWidget");R(this,"_topCenterWidget");R(this,"_topRightWidget");R(this,"_middleLeftWidget");R(this,"_middleRightWidget");R(this,"_bottomLeftWidget");R(this,"_bottomCenterWidget");R(this,"_bottomRightWidget");R(this,"_dashRect");R(this,"_selectionModel");R(this,"_selectionStyle");R(this,"_rowHeaderWidth",0);R(this,"_columnHeaderHeight",0);R(this,"_widgetRects",[]);R(this,"_dispose$",new B.BehaviorSubject(this));R(this,"dispose$",this._dispose$.asObservable());R(this,"selectionMoving$",new B.Subject);R(this,"selectionMoved$",new B.Subject);R(this,"selectionScaling$",new B.Subject);R(this,"selectionScaled$",new B.Subject);R(this,"selectionFilling$",new B.Subject);R(this,"_selectionFilled$",new B.Subject);R(this,"selectionFilled$",this._selectionFilled$.asObservable());R(this,"_defaultStyle");R(this,"_currentStyle");R(this,"_isHelperSelection",!0);R(this,"_antLineOffset",0);R(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=i,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,n=0,i=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,i)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,i,r,s,a,c,d,u,h,m,g,f,S,p,I,M,b,T,w,E,O,x,A,k;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(i=this._topControl)==null||i.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(a=this._backgroundControlMiddleLeft)==null||a.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(d=this._backgroundControlBottom)==null||d.dispose(),(u=this._fillControl)==null||u.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(f=this._rowHeaderGroup)==null||f.dispose(),(S=this._rowHeaderBackground)==null||S.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(I=this._columnHeaderBorder)==null||I.dispose(),(M=this._columnHeaderGroup)==null||M.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(T=this._topCenterWidget)==null||T.dispose(),(w=this._topRightWidget)==null||w.dispose(),(E=this._middleLeftWidget)==null||E.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(A=this._bottomCenterWidget)==null||A.dispose(),(k=this._bottomRightWidget)==null||k.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const i=e.mergeInfo;n={startRow:i.startRow,endRow:i.endRow,startColumn:i.startColumn,endColumn:i.endColumn,startX:i.startX,endX:i.endX,startY:i.startY,endY:i.endY}}else{const{actualRow:i,actualColumn:r,startX:s,endX:a,startY:c,endY:d}=e;n={startRow:i,endRow:i,startColumn:r,endColumn:r,startX:s,endX:a,startY:c,endY:d}}return n}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,n,i){const{startX:r,startY:s,endX:a,endY:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d),this._currentStyle=e;const{stroke:u=d.stroke,widgets:h=d.widgets,hasAutoFill:m=d.hasAutoFill,AutofillStroke:g=d.AutofillStroke,strokeDash:f,isAnimationDash:S}=e;let{strokeWidth:p=d.strokeWidth,AutofillSize:I=d.AutofillSize,AutofillStrokeWidth:M=d.AutofillStrokeWidth}=e;const b=this._getScale(),T=(p+_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/b;p/=b,I/=b,M/=b<1?1:b;const w=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/b,E=y.FIX_ONE_PIXEL_BLUR_OFFSET/b;if(this.leftControl.transformByState({height:c-s,left:-T+E,width:p,strokeWidth:w,top:-w/2+E}),this.leftControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:c-s,left:a-r-T+E,width:p,strokeWidth:w,top:-w/2+E}),this.rightControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:a-r+p,top:-T+E,left:-T+E,height:p,strokeWidth:w}),this.topControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:a-r+p,top:c-s-T+E,height:p,left:-T+E,strokeWidth:w}),this.bottomControl.setProps({fill:u,stroke:_.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),f==null||c-s>1e6||a-r>1e5)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/b;this.dashRect.transformByState({height:c-s,width:a-r,strokeWidth:O,left:-O/2+E,top:-O/2+E}),this.dashRect.setProps({strokeDashArray:[0,f/b]}),this._stopAntLineAnimation(),S!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:u,stroke:g,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:I-M,height:I-M,left:a-r-I/2+M/2-E,top:c-s-I/2+M/2-E,strokeWidth:M}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,i),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=i||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=_.getNormalSelectionStyle(this._themeService),this._selectionModel=new ma;const e=this._zIndex;this._leftControl=new y.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new y.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new y.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new y.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new y.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new y.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new y.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new y.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new y.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new y.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const i=this.getScene();i.addObject(this._selectionShape,ca),this.disposeWithMe(l.toDisposable(i.onTransformChangeObservable.add(r=>{r.type===y.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new y.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new y.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new y.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new y.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new y.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new y.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],y.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new y.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new y.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new y.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new y.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new y.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new y.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new y.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new y.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,i){const{startX:r,startY:s,endX:a,endY:c,rangeType:d}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u);const h=this._getScale(),{stroke:m,hasRowHeader:g,rowHeaderFill:f=u.rowHeaderFill,rowHeaderStroke:S=u.rowHeaderStroke,hasColumnHeader:p,columnHeaderFill:I=u.columnHeaderFill,columnHeaderStroke:M=u.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=u.rowHeaderStrokeWidth,columnHeaderStrokeWidth:T=u.columnHeaderStrokeWidth}=e;if(b/=h,T/=h,p===!0){let w=I;this._isHeaderHighlight&&d===l.RANGE_TYPE.COLUMN&&(w=new l.ColorKit(m).setAlpha(yi).toString()),this._columnHeaderBackground.setProps({fill:w}),this._columnHeaderBackground.resize(a-r,i),this._columnHeaderBorder.setProps({fill:M}),this._columnHeaderBorder.transformByState({width:a-r,height:T,top:i-T+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),g===!0){let w=f;this._isHeaderHighlight&&d===l.RANGE_TYPE.ROW&&(w=new l.ColorKit(m).setAlpha(yi).toString()),this._rowHeaderBackground.setProps({fill:w}),this._rowHeaderBackground.resize(n,c-s),this._rowHeaderBorder.setProps({fill:S}),this._rowHeaderBorder.transformByState({width:b,height:c-s,left:n-b+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:i,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const c=this._getScale(),{fill:d=a.fill}=e;let{strokeWidth:u=a.strokeWidth}=e;u/=c;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-i),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:g,endX:f,endY:S}=h,p=u/2,I={left:-p,top:-p,width:r-n+p*2,height:g-i+p};I.height<0&&(I.width=0,I.height=0),this._backgroundControlTop.transformByState(I);const M={left:-p,top:g-i,width:m-n+p,height:S-g};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleLeft.transformByState(M);const b={left:f-n-p,top:g-i,width:r-f+p*2,height:S-g};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const T={left:-p,top:S-i,width:r-n+p*2,height:s-S+p};T.height<0&&(T.width=0,T.height=0),this._backgroundControlBottom.transformByState(T),this._backgroundControlTop.setProps({fill:d}),this._backgroundControlMiddleLeft.setProps({fill:d}),this._backgroundControlMiddleRight.setProps({fill:d}),this._backgroundControlBottom.setProps({fill:d})}_updateWidgets(e){const{startX:n,startY:i,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const{stroke:c=a.stroke,widgets:d=a.widgets,widgetStroke:u=a.widgetStroke}=e,h=this._getScale();let{widgetSize:m=a.widgetSize,widgetStrokeWidth:g=a.widgetStrokeWidth}=e;m/=h,g/=h;const f={left:-m/2+g/2,center:(r-n)/2-m/2+g/2,right:r-n-m/2+g/2,top:-m/2,middle:(s-i)/2-m/2,bottom:s-i-m/2+g/2},S=m-g;this._widgetRects.forEach(p=>{p.setProps({fill:c,stroke:u})}),d.tl===!0?(this._topLeftWidget.transformByState({height:S,width:S,left:f.left,top:f.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),d.tc===!0?(this._topCenterWidget.transformByState({height:S,width:S,left:f.center,top:f.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),d.tr===!0?(this._topRightWidget.transformByState({height:S,width:S,left:f.right,top:f.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),d.ml===!0?(this._middleLeftWidget.transformByState({height:S,width:S,left:f.left,top:f.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),d.mr===!0?(this._middleRightWidget.transformByState({height:S,width:S,left:f.right,top:f.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),d.bl===!0?(this._bottomLeftWidget.transformByState({height:S,width:S,left:f.left,top:f.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),d.bc===!0?(this._bottomCenterWidget.transformByState({height:S,width:S,left:f.center,top:f.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),d.br===!0?(this._bottomRightWidget.transformByState({height:S,width:S,left:f.right,top:f.bottom,strokeWidth:g}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const i of n)if(e[i]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,y.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=y.requestNewFrame(()=>{this._startAntLineAnimation()})}}const Oi="__SpreadsheetHelperSelectionTempRect",ga=35;class xi{constructor(t,e,n,i,r){R(this,"_startOffsetX",0);R(this,"_startOffsetY",0);R(this,"_relativeSelectionPositionRow",0);R(this,"_relativeSelectionPositionColumn",0);R(this,"_relativeSelectionRowLength",0);R(this,"_relativeSelectionColumnLength",0);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_helperSelection");R(this,"_scrollTimer");R(this,"_activeViewport");R(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});R(this,"_isInMergeState",!1);R(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=i,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(exports.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case W.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case W.VIEW_MAIN_TOP:case W.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case W.VIEW_MAIN_LEFT:case W.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case W.VIEW_MAIN_LEFT_TOP:case W.VIEW_COLUMN_LEFT:case W.VIEW_ROW_TOP:case W.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:t,rightControl:e,topControl:n,bottomControl:i}=this._control;[t,e,n,i].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(y.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var E;const n=this._scene,i=n.getScrollXYByRelativeCoords(y.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,i),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let g=m+this._relativeSelectionRowLength;g>u&&(g=u,g-m<this._relativeSelectionRowLength&&(m=g-this._relativeSelectionRowLength));let f=d+this._relativeSelectionPositionColumn;f<0&&(f=0);let S=f+this._relativeSelectionColumnLength;S>h&&(S=h,S-f<this._relativeSelectionColumnLength&&(f=S-this._relativeSelectionColumnLength));const p=this._skeleton.getNoMergeCellPositionByIndex(m,f),I=this._skeleton.getNoMergeCellPositionByIndex(g,S),M=(p==null?void 0:p.startY)||0,b=(I==null?void 0:I.endY)||0,T=(p==null?void 0:p.startX)||0,w=(I==null?void 0:I.endX)||0;(E=this._helperSelection)==null||E.transformByState({left:T,top:M,width:w-T,height:b-M}),this._targetSelection={startY:M,endY:b,startX:T,endX:w,startRow:m,endRow:g,startColumn:f,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,i=this._scene,r=i.getRelativeCoord(y.Vector2.FromArray([e,n])),{x:s,y:a}=r,c=i.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=i.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:g}=h,{startRow:f,startColumn:S,endRow:p,endColumn:I}=this._control.model;let M=0,b=0;m<f?M-=1:m>p&&(M+=1),g<S?b-=1:g>I&&(b+=1),this._relativeSelectionPositionRow=f-m+M,this._relativeSelectionPositionColumn=S-g+b,this._relativeSelectionRowLength=p-f,this._relativeSelectionColumnLength=I-S;const T=this._control.selectionStyle,w=this._getScale();this.isHelperSelection&&(this._helperSelection=new y.Rect(Oi,{stroke:T.stroke,strokeWidth:T.strokeWidth/w}),i.addObject(this._helperSelection));const E=i.getViewport(W.VIEW_MAIN),O=y.ScrollTimer.create(i);O.startScroll(s,a,E),this._scrollTimer=O,i.disableEvent(),this._moveObserver=i.onPointerMoveObserver.add(x=>{const{offsetX:A,offsetY:k}=x,{x:N,y:L}=i.getRelativeCoord(y.Vector2.FromArray([A,k]));this._controlMoving(N,L),i.setCursor(y.CURSOR_TYPE.MOVE),O.scrolling(N,L,()=>{this._controlMoving(N,L)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var A,k;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(k=this._scrollTimer)==null||k.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[y.CURSOR_TYPE.NORTH_WEST_RESIZE,y.CURSOR_TYPE.NORTH_RESIZE,y.CURSOR_TYPE.NORTH_EAST_RESIZE,y.CURSOR_TYPE.WEST_RESIZE,y.CURSOR_TYPE.EAST_RESIZE,y.CURSOR_TYPE.SOUTH_WEST_RESIZE,y.CURSOR_TYPE.SOUTH_RESIZE,y.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,i,r,s,a,c].forEach((u,h)=>{u.onPointerEnterObserver.add(()=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(()=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(t,e,n){const i=this._scene,r=i.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=i.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(t,e,s,a,r),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=d,p=u;n===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(g=d,f=u,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.NORTH_RESIZE?(g=d,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===y.CURSOR_TYPE.NORTH_EAST_RESIZE?(g=d,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,p=u):n===y.CURSOR_TYPE.WEST_RESIZE?(g=this._relativeSelectionPositionRow,f=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===y.CURSOR_TYPE.SOUTH_WEST_RESIZE?(g=this._relativeSelectionPositionRow,f=u,S=d,p=this._relativeSelectionPositionColumn):n===y.CURSOR_TYPE.SOUTH_RESIZE&&(g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=d,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:I,startColumn:M,endRow:b,endColumn:T}=this._swapPositions(g,f,S,p),w=this._skeleton.getNoMergeCellPositionByIndex(I,M),E=this._skeleton.getNoMergeCellPositionByIndex(b,T),O=(w==null?void 0:w.startY)||0,x=(E==null?void 0:E.endY)||0,A=(w==null?void 0:w.startX)||0,k=(E==null?void 0:E.endX)||0;this._targetSelection={startY:O,endY:x,startX:A,endX:k,startRow:g,endRow:S,startColumn:f,endColumn:p},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:i}=t,r=this._scene,s=r.getRelativeCoord(y.Vector2.FromArray([n,i])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=i;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,e===y.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===y.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===y.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===y.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===y.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const g=y.ScrollTimer.create(r);g.startScroll(a,c),this._scrollTimer=g,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(f=>{const{offsetX:S,offsetY:p}=f,{x:I,y:M}=r.getRelativeCoord(y.Vector2.FromArray([S,p]));this._widgetMoving(I,M,e),r.setCursor(e),g.scrolling(I,M,()=>{this._widgetMoving(I,M,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var S;const f=this._scene;f.resetCursor(),this._clearObserverEvent(),f.enableEvent(),(S=this._scrollTimer)==null||S.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(y.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var k,N,L;const n=this._scene,i=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,i),{row:c,column:d}=a,u=n.getRelativeCoord(y.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,I=!1,M=!0;if((d<f||d>p)&&c>=g&&c<=S){const V=this._fillRuler(d,f,p,this._relativeSelectionColumnLength,m);f=V.startRowOrColumn,p=V.endRowOrColumn,I=V.isLighten,M=!1}else if((c<g||c>S)&&d>=f&&d<=p){const V=this._fillRuler(c,g,S,this._relativeSelectionRowLength,h);g=V.startRowOrColumn,S=V.endRowOrColumn,I=V.isLighten}else if(Math.abs(this._startOffsetX-u.x-i.x)/2>Math.abs(this._startOffsetY-u.y-i.y)){const V=this._fillRuler(d,f,p,this._relativeSelectionColumnLength,m);f=V.startRowOrColumn,p=V.endRowOrColumn,I=V.isLighten,M=!1}else{const V=this._fillRuler(c,g,S,this._relativeSelectionRowLength,h);g=V.startRowOrColumn,S=V.endRowOrColumn,I=V.isLighten}const b=this._skeleton.getNoMergeCellPositionByIndex(g,f),T=this._skeleton.getNoMergeCellPositionByIndex(S,p),w=(b==null?void 0:b.startY)||0,E=(T==null?void 0:T.endY)||0,O=(b==null?void 0:b.startX)||0,x=(T==null?void 0:T.endX)||0;I?this._controlHandler((V,j)=>{const z=new l.ColorKit(this._fillControlColors[j]).lighten(ga).toRgbString();V.setProps({fill:z})}):this._controlHandler((V,j)=>{V.setProps({fill:this._fillControlColors[j]})});const A=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===S&&M===!0||f===p&&M===!1?(k=this._helperSelection)==null||k.hide():((N=this._helperSelection)==null||N.transformByState({left:O-A/2,top:w-A/2,width:x-O,height:E-w}),(L=this._helperSelection)==null||L.show()),this._targetSelection={startY:w,endY:E,startX:O,endX:x,startRow:g,endRow:S,startColumn:f,endColumn:p},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,i=this._scene,r=i.getRelativeCoord(y.Vector2.FromArray([e,n])),{x:s,y:a}=r;this._startOffsetX=s,this._startOffsetY=a;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const m=this._control.selectionStyle;let g=m==null?void 0:m.stroke,f=m==null?void 0:m.strokeWidth;const S=_.getNormalSelectionStyle(this._themeService);g==null&&(g=S.stroke),f==null&&(f=S.strokeWidth);const p=this._getScale();f/=p;const I=_.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/p,M=new l.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new y.Rect(Oi,{stroke:M,strokeWidth:f+I/2}),i.addObject(this._helperSelection)),this._activeViewport=i.getActiveViewportByCoord(y.Vector2.FromArray([e,n]));const b=i.getViewport(W.VIEW_MAIN),T=y.ScrollTimer.create(i,this._activeViewport.viewPortKey===W.VIEW_MAIN?y.ScrollTimerType.ALL:y.ScrollTimerType.NONE);T.startScroll(s,a,b),this._scrollTimer=T,i.disableEvent(),this._controlHandler(w=>{this._fillControlColors.push(w.fill)}),this._moveObserver=i.onPointerMoveObserver.add(w=>{var L;const{offsetX:E,offsetY:O}=w,x=i.getActiveViewportByCoord(y.Vector2.FromArray([E,O])),{x:A,y:k}=i.getRelativeCoord(y.Vector2.FromArray([E,O]));this._fillMoving(A,k),i.setCursor(y.CURSOR_TYPE.CROSSHAIR);const N=this._targetSelection;if(b&&x&&((L=this._activeViewport)==null?void 0:L.viewPortKey)!==(x==null?void 0:x.viewPortKey)){let V;N.startRow!==c?(T.scrollTimerType=y.ScrollTimerType.Y,V={...N,endRow:N.startRow}):N.endRow!==u?(T.scrollTimerType=y.ScrollTimerType.Y,V={...N,startRow:N.endRow}):N.startColumn!==d?(T.scrollTimerType=y.ScrollTimerType.X,V={...N,endColumn:N.startColumn}):(T.scrollTimerType=y.ScrollTimerType.X,V={...N,startColumn:N.endColumn}),this._isSelectionInViewport(V,x)&&(b.scrollTo({x:T.scrollTimerType===y.ScrollTimerType.X?0:void 0,y:T.scrollTimerType===y.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}T.scrolling(A,k,()=>{this._fillMoving(A,k)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var E,O;(E=this._helperSelection)==null||E.dispose();const w=this._scene;w.resetCursor(),this._clearObserverEvent(),w.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,i){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:e,top:t,right:i,bottom:n},m={left:c,top:a,right:u,bottom:d};if(y.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,i){const r=Math.min(t,n),s=Math.min(e,i),a=Math.max(t,n),c=Math.max(e,i);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[e,n,i,r,s,a,c,d,u];for(let m=0,g=h.length;m<g;m++){const f=h[m];t(f,m)}}_fillRuler(t,e,n,i,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const a=e-t,c=i+1,d=Math.ceil(a/c);let u=e-d*c;u<0&&(u=e-(d-1)*c),e=u}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const a=t-n,c=i+1,d=Math.ceil(a/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var fa=Object.defineProperty,_a=Object.getOwnPropertyDescriptor,Sa=(o,t,e,n)=>{for(var i=n>1?void 0:n?_a(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&fa(t,e,i),i},dn=(o,t)=>(e,n)=>t(e,n,o);exports.SelectionRenderService=class{constructor(t,e,n,i){R(this,"hasSelection",!1);R(this,"_downObserver");R(this,"_moveObserver");R(this,"_upObserver");R(this,"_controlFillConfig$",new B.BehaviorSubject(null));R(this,"controlFillConfig$",this._controlFillConfig$.asObservable());R(this,"_selectionControls",[]);R(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});R(this,"_startOffsetX",0);R(this,"_startOffsetY",0);R(this,"_scrollTimer");R(this,"_cancelDownObserver");R(this,"_cancelUpObserver");R(this,"_skeleton");R(this,"_scene");R(this,"_isHeaderHighlight",!0);R(this,"_isDetectMergedCell",!0);R(this,"_selectionStyle");R(this,"_isSelectionEnabled",!0);R(this,"_isShowPreviousEnable",0);R(this,"_isRemainLastEnable",!0);R(this,"_isSkipRemainLastEnable",!1);R(this,"_isSingleSelection",!1);R(this,"_selectionMoveEnd$",new B.BehaviorSubject([]));R(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());R(this,"_selectionMoving$",new B.Subject);R(this,"selectionMoving$",this._selectionMoving$.asObservable());R(this,"_selectionMoveStart$",new B.Subject);R(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());R(this,"_activeViewport");R(this,"_usable$",new B.BehaviorSubject(!1));R(this,"usable$",this._usable$.asObservable());this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=i,this._selectionStyle=_.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(_.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:i}=t,r=this._skeleton;let s=t.style;s==null&&(s=_.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new Vn(a,e.length,this._isHeaderHighlight,this._themeService);new xi(c,r,a,this._themeService,this._injector);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,i),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),e.push(c)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:i,columnHeaderHeight:r}=n;for(let s=0,a=t.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:d,style:u}=t[s];e[s].update(c,i,r,u,d)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||(e==null?void 0:e.getViewports()[0]),this._usable$.next(!!(t&&e))}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(W.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(W.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const i=n.model,r=i.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=l.RANGE_TYPE.NORMAL,i,r=y.ScrollTimerType.ALL){var X,J;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=t,d=this._scene;if(d==null||s==null)return;i!=null&&(this._activeViewport=i);const u=d.getViewport(W.VIEW_MAIN),h=d.getRelativeCoord(y.Vector2.FromArray([a,c]));let{x:m,y:g}=h;this._startOffsetX=m,this._startOffsetY=g;const f=d.getScrollXYByRelativeCoords(h),{scaleX:S,scaleY:p}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(g=0);const I=this._getSelectedRangeWithMerge(m,g,S,p,f);if(!I)return!1;const{rangeWithCoord:M,primaryWithCoord:b}=I,{startRow:T,startColumn:w,endColumn:E,endRow:O,startY:x,endY:A,startX:k,endX:N}=M,{rowHeaderWidth:L,columnHeaderHeight:V}=s,j={startColumn:w,startRow:T,endColumn:E,endRow:O,startY:x,endY:A,startX:k,endX:N,rangeType:n};this._startSelectionRange=j;let z=this.getActiveSelection();const q=this.getCurrentControls();if(!q)return!1;for(const ee of q){if(t.button===2&&ee.model.isInclude(j)){z=ee;return}if(ee.model.isEqual(j)){z=ee;break}t.shiftKey||ee.clearHighlight()}if(q.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||q.length>0&&this._isSingleSelection&&!t.shiftKey){for(const ee of q)ee.dispose();q.length=0}const K=z&&z.model.currentCell;if(z&&t.shiftKey&&K){const{actualRow:ee,actualColumn:ce,mergeInfo:Ce}=K,De=Math.min(ee,j.startRow,Ce.startRow),Pe=Math.max(ee,j.endRow,Ce.endRow),We=Math.min(ce,j.startColumn,Ce.startColumn),je=Math.max(ce,j.endColumn,Ce.endColumn),he=s.getMergeBounding(De,We,Pe,je),de=s.getNoMergeCellPositionByIndex(he.startRow,he.startColumn),se=s.getNoMergeCellPositionByIndex(he.endRow,he.endColumn),$e={startColumn:he.startColumn,startRow:he.startRow,endColumn:he.endColumn,endRow:he.endRow,startY:de.startY,endY:se.endY,startX:de.startX,endX:se.endX,rangeType:n},pe=s.getCellByIndex(ee,ce);this._startSelectionRange={startColumn:pe.mergeInfo.startColumn,startRow:pe.mergeInfo.startRow,endColumn:pe.mergeInfo.endColumn,endRow:pe.mergeInfo.endRow,startY:pe.mergeInfo.startY||0,endY:pe.mergeInfo.endY||0,startX:pe.mergeInfo.startX||0,endX:pe.mergeInfo.endX||0,rangeType:n},z.update($e,L,V,this._selectionStyle,K)}else this._isRemainLastEnable&&z&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?z.update(j,L,V,this._selectionStyle,b):(z=new Vn(d,q.length+e,this._isHeaderHighlight,this._themeService),new xi(z,s,d,this._themeService,this._injector),z.update(j,L,V,this._selectionStyle,b),q.push(z));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const $=d.getActiveViewportByCoord(y.Vector2.FromArray([m,g])),Q=y.ScrollTimer.create(this._scene,r);Q.startScroll((X=u==null?void 0:u.left)!=null?X:0,(J=u==null?void 0:u.top)!=null?J:0,u),this._scrollTimer=Q,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,g,z,n);let D=0,H=0,F=m,Y=g;this._moveObserver=d.onPointerMoveObserver.add(ee=>{var pe,Ht,Lt,mi,gi,fi,_i,Si,pi,Ci;const{offsetX:ce,offsetY:Ce}=ee,{x:De,y:Pe}=d.getRelativeCoord(y.Vector2.FromArray([ce,Ce]));this._moving(De,Pe,z,n);let We=De,je=Pe;const he=this.getActiveSelection(),de=(pe=this._sheetSkeletonManagerService.getCurrent())==null?void 0:pe.skeleton.getWorksheetConfig().freeze,se=he==null?void 0:he.model,$e=(Ht=d.getActiveViewportByCoord(y.Vector2.FromArray([ce,Ce])))!=null?Ht:this._getViewportByCell(se==null?void 0:se.endRow,se==null?void 0:se.endColumn);if($&&$e&&u){const no=F<u.left&&De>u.left||F>u.left&&De<u.left,oo=Y<u.top&&Pe>u.top||Y>u.top&&Pe<u.top;no&&(D+=1),oo&&(H+=1);const He=$.viewPortKey,Ut=$e.viewPortKey;if(He===W.VIEW_ROW_TOP)Ce<u.top&&((Lt=se==null?void 0:se.endRow)!=null?Lt:0)<((mi=de==null?void 0:de.startRow)!=null?mi:0)?je=u.top:oo&&H%2===1&&u.scrollTo({y:0});else if(He===W.VIEW_COLUMN_LEFT)ce<u.left&&((gi=se==null?void 0:se.endColumn)!=null?gi:0)<((fi=de==null?void 0:de.startColumn)!=null?fi:0)?We=u.left:no&&D%2===1&&u.scrollTo({x:0});else if(He===Ut){let ze=!1,rt=!1;He===W.VIEW_MAIN_LEFT_TOP?(ze=!0,rt=!0):He===W.VIEW_MAIN_TOP?rt=!0:He===W.VIEW_MAIN_LEFT&&(ze=!0),((_i=se==null?void 0:se.endRow)!=null?_i:0)>((Si=de==null?void 0:de.startRow)!=null?Si:0)&&(rt=!1),((pi=se==null?void 0:se.endColumn)!=null?pi:0)>((Ci=de==null?void 0:de.startColumn)!=null?Ci:0)&&(ze=!1),ze&&(We=u.left),rt&&(je=u.top)}else{const ze={x:$.scrollX,y:$.scrollY},rt={x:$e.scrollX,y:$e.scrollY},io=ze.x!==rt.x&&no&&D%2===1,ro=ze.y!==rt.y&&oo&&H%2===1;(io||ro)&&(u.scrollTo({x:io?ze.x:void 0,y:ro?ze.y:void 0}),io||(We=u.left),ro||(je=u.top)),(He===W.VIEW_MAIN_LEFT_TOP&&Ut===W.VIEW_MAIN_LEFT||Ut===W.VIEW_MAIN_LEFT_TOP&&He===W.VIEW_MAIN_LEFT)&&(We=u.left),(He===W.VIEW_MAIN_LEFT_TOP&&Ut===W.VIEW_MAIN_TOP||Ut===W.VIEW_MAIN_LEFT_TOP&&He===W.VIEW_MAIN_TOP)&&(je=u.top)}F=De,Y=Pe}Q.scrolling(We,je,()=>{this._moving(De,Pe,z,n)})}),this._upObserver=d.onPointerUpObserver.add(ee=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionToCoord(t){const{range:e,primary:n,style:i}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:i}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:i,endColumn:r,rangeType:s}=t,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const d=c.getNoMergeCellPositionByIndex(e,n),u=c.getNoMergeCellPositionByIndex(i,r);return{startRow:e,startColumn:n,endRow:i,endColumn:r,rangeType:s,startY:(d==null?void 0:d.startY)||0,endY:(u==null?void 0:u.endY)||0,startX:(d==null?void 0:d.startX)||0,endX:(u==null?void 0:u.endX)||0}}convertCellRangeToInfo(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(i,r),g=n.getNoMergeCellPositionByIndex(c,d),f=n.getNoMergeCellPositionByIndex(u,h);return{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(g==null?void 0:g.startY)||0,endY:(f==null?void 0:f.endY)||0,startX:(g==null?void 0:g.startX)||0,endX:(f==null?void 0:f.endX)||0}}}_moving(t,e,n,i){var J;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:g,endColumn:f}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},S=s.getViewport(W.VIEW_MAIN),p=(J=this._getViewportByCell(m,f))!=null?J:S,I=s.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),p),{scaleX:M,scaleY:b}=s.getAncestorScale(),{rowHeaderWidth:T,columnHeaderHeight:w}=r;i===l.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:i===l.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const E=this._getSelectedRangeWithMerge(t,e,M,b,I);if(!E)return!1;const{rangeWithCoord:O,primaryWithCoord:x}=E,{startRow:A,startColumn:k,endColumn:N,endRow:L}=O,V=Math.min(A,a),j=Math.min(k,c),z=Math.max(L,d),q=Math.max(N,u);let K={startRow:V,startColumn:j,endRow:z,endColumn:q};if(this._isDetectMergedCell&&(K=r.getSelectionBounding(V,j,z,q)),!K)return!1;const{startRow:$,startColumn:Q,endRow:D,endColumn:H}=K,F=r.getNoMergeCellPositionByIndex($,Q),Y=r.getNoMergeCellPositionByIndex(D,H),X={startColumn:Q,startRow:$,endColumn:H,endRow:D,startY:(F==null?void 0:F.startY)||0,endY:(Y==null?void 0:Y.endY)||0,startX:(F==null?void 0:F.startX)||0,endX:(Y==null?void 0:Y.endX)||0};(g!==Q||h!==$||f!==H||m!==D)&&n!=null&&(n.update(X,T,w),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,i;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(i=t.getEngine())==null?void 0:i.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(i=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(i=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,i,r){var I;if(this._isDetectMergedCell){const M=(I=this._skeleton)==null?void 0:I.calculateCellIndexByPosition(t,e,n,i,r),b=l.makeCellToSelection(M);return b==null?void 0:{primaryWithCoord:M,rangeWithCoord:b}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(t,e,n,i,r),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d),{startX:h,startY:m,endX:g,endY:f}=u,S={startY:m,endY:f,startX:h,endX:g,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:f,startX:h,endX:g,mergeInfo:S},rangeWithCoord:S}}};exports.SelectionRenderService=Sa([dn(0,P.Inject(l.ThemeService)),dn(1,v.IShortcutService),dn(2,P.Inject(exports.SheetSkeletonManagerService)),dn(3,P.Inject(P.Injector))],exports.SelectionRenderService);const Ne=P.createIdentifier("deprecated.univer.sheet.selection-render-service");var pa=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,va=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ca(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&pa(t,e,i),i},Vt=(o,t)=>(e,n)=>t(e,n,o);const Ia=1e4,tn=P.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends l.Disposable{constructor(e,n,i,r,s){super();R(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=i,this._sheetSkeletonManagerService=r,this._themeService=s}addShape(e,n=[],i=Ia){const r=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:i,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const e=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId();this._shapeMap.forEach(i=>{var M;const{unitId:r,subUnitId:s,selection:a,control:c,zIndex:d}=i;if(c&&c.dispose(),r!==e||s!==n)return;const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:g}=this._selectionRenderService.convertSelectionToCoord(a),f=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!h||!f)return;const{rowHeaderWidth:S,columnHeaderHeight:p}=f,I=new Vn(h,d,!1,this._themeService);I.update(m,S,p,u,g),i.control=I})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:i}=n;i&&i.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=va([Vt(0,l.IUniverInstanceService),Vt(1,y.IRenderManagerService),Vt(2,Ne),Vt(3,P.Inject(exports.SheetSkeletonManagerService)),Vt(4,P.Inject(l.ThemeService))],exports.MarkSelectionService);const Ra=10,Ma=6;function ba(){return l.Tools.generateRandomId(Ma)}function Ta(o){const t=o.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class wa{constructor(){R(this,"_cache",new l.LRUMap(Ra))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}function _r(o,t){const e=t!=null?t:o.style,n={},i=o.tagName.toLowerCase();switch(i){case"b":case"em":case"strong":{n.bl=l.BooleanNumber.TRUE;break}case"s":{n.st={s:l.BooleanNumber.TRUE};break}case"u":{n.ul={s:l.BooleanNumber.TRUE};break}case"i":{n.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{n.va=i==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}return Ea(e,n),n}function Ea(o,t){for(let e=0;e<o.length;e++){const n=o[e],i=o.getPropertyValue(n);switch(n){case"font-family":{t.ff=i;break}case"font-size":{const r=Number.parseInt(i);if(!Number.isNaN(r)){if(i.endsWith("pt"))t.fs=r;else if(i.endsWith("px")){const s=r*.75;t.fs=s}}break}case"font-style":{i==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{(Number(i)>400||i==="bold")&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(i)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(i)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(i)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const r=new l.ColorKit(i);r.isValid&&(t.cl={rgb:r.toRgbString()});break}case"background-color":{const r=new l.ColorKit(i),s=r.isValid?r.toRgbString():"";s!==v.DEFAULT_BACKGROUND_COLOR_RGB&&s!==v.DEFAULT_BACKGROUND_COLOR_RGBA&&(t.bg={rgb:r.toRgbString()});break}}}}function ya(o){const t=new DOMParser,e=`<x-univer id="univer-root">${o}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function wo(o,t){const e=[];for(let n=0,i=o.length;n<i;n++)o[n]===l.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=l.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=l.Tools.deepClone(t.paragraphStyle));return e}const Oa=["color_color","background_background","font-size_fontSize","text-align_textAlign","vertical-align_verticalAlign","font-weight_fontWeight","font-style_fontStyle","font-family_fontFamily","text-decoration_textDecoration","white-space_whiteSpace","word-wrap_wordWrap"],xa=["border-left_borderLeft","border-right_borderRight","border-top_borderTop","border-bottom_borderBottom"];function Ni(o,t){const e=o.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(o)}function Na(o){o.style.display="none",o.style.width="0",o.style.height="0",o.setAttribute("tabindex","-1"),o.setAttribute("aria-hidden","true"),o.setAttribute("title","hidden iframe")}const Yn=class Yn{constructor(t){R(this,"styleCache",new Map);R(this,"styleRules",[]);R(this,"afterProcessRules",[]);R(this,"htmlElement");R(this,"getCurrentSkeleton");this.getCurrentSkeleton=t.getCurrentSkeleton,this.htmlElement=document.createElement("iframe"),this.htmlElement.style.display="none",document.body.appendChild(this.htmlElement),Na(this.htmlElement)}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){this.htmlElement.contentDocument&&(this.htmlElement.contentDocument.open(),this.htmlElement.contentDocument.write(t),this.htmlElement.contentDocument.close()),t=t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style[\s\S]*?<\/style>/g,"");const e=Yn.pluginList.find(g=>g.checkPasteType(t));e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]);const n=new l.ObjectMatrix,i=ya(t),r={dataStream:"",textRuns:[]},s=[],a=[],c=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),d=[];this.process(null,i==null?void 0:i.childNodes,r,d);const{paragraphs:u,dataStream:h,textRuns:m}=r;if(u){const g=u.map(f=>f.startIndex+1);g.unshift(0);for(let f=0;f<g.length;f++){let S;f===g.length-1?S=`${h.substring(g[f])}\r
2
- `:S=`${h.substring(g[f],g[f+1]-1)}\r
3
- `;const p=[];m==null||m.forEach(M=>{M.st>=g[f]&&M.ed<=g[f+1]&&p.push({st:M.st-g[f],ed:M.ed-g[f],ts:M.ts})});const I=this._generateDocumentDataModelSnapshot({body:{dataStream:S,textRuns:p,paragraphs:wo(S)}});n.setValue(n.getLength(),0,{v:S,p:I}),s.push({})}}else if(h){const g=`${h}\r
4
- `,f={dataStream:g,textRuns:m,paragraphs:wo(g)},S=this._generateDocumentDataModelSnapshot({body:f});n.setValue(0,0,{v:h,p:S}),s.push({})}return c&&c.forEach(g=>{const f=n.getDataRange().endRow+1,{cellMatrix:S,rowProperties:p,colProperties:I}=this._parseTable(g);S&&S.forValue((M,b,T)=>{n.setValue(f+M,b,T)}),I&&a.push(...I),s.push(...p)}),{rowProperties:s,colProperties:a,cellMatrix:n}}_parseTable(t){var s,a;const e=new l.ObjectMatrix,n=(s=Da(t))!=null?s:[],{rowProperties:i=[]}=Aa(t),r=Ha(this.htmlElement,(a=this.getCurrentSkeleton())==null?void 0:a.skeleton);return r&&r.forValue((c,d,u)=>{var g,f,S,p,I,M,b,T,w,E,O,x,A,k,N,L,V,j,z,q,K,$,Q,D;let h=v.handleStringToStyle(void 0,u.style);if((p=(S=(f=(g=u==null?void 0:u.richTextParma)==null?void 0:g.p)==null?void 0:f.body)==null?void 0:S.textRuns)!=null&&p.length){const H=(M=(I=u==null?void 0:u.richTextParma)==null?void 0:I.v)==null?void 0:M.length;for(let F=0;F<((E=(w=(T=(b=u==null?void 0:u.richTextParma)==null?void 0:b.p)==null?void 0:T.body)==null?void 0:w.textRuns)==null?void 0:E.length);F++){const Y=(A=(x=(O=u==null?void 0:u.richTextParma)==null?void 0:O.p)==null?void 0:x.body)==null?void 0:A.textRuns[F];Y.st===0&&Y.ed===H&&(h={...Y.ts,...h},(L=(N=(k=u==null?void 0:u.richTextParma)==null?void 0:k.p)==null?void 0:N.body)==null||L.textRuns.splice(F,1),F--)}((q=(z=(j=(V=u==null?void 0:u.richTextParma)==null?void 0:V.p)==null?void 0:j.body)==null?void 0:z.textRuns)==null?void 0:q.length)===0&&(u.content=(K=u==null?void 0:u.richTextParma)==null?void 0:K.v,delete u.richTextParma)}const m=(D=(Q=($=u==null?void 0:u.richTextParma)==null?void 0:$.p)==null?void 0:Q.body)!=null&&D.textRuns?{v:u.richTextParma.v,p:u.richTextParma.p,s:h,rowSpan:u.rowSpan,colSpan:u.colSpan}:{v:u.content,s:h,rowSpan:u.rowSpan,colSpan:u.colSpan};e.setValue(c,d,m)}),{rowProperties:i,colProperties:n,cellMatrix:e}}_generateDocumentDataModelSnapshot(t){var a;const e=this.getCurrentSkeleton();if(e==null)return null;const{skeleton:n}=e,i=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...i==null?void 0:i.getSnapshot(),...t};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(t,e,n,i){var r,s;for(const a of e)if(a.nodeName.toLowerCase()==="table")i.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;t&&this.styleCache.has(t)&&(d=this.styleCache.get(t));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(a.nodeType===Node.ELEMENT_NODE){if(a.nodeName==="STYLE")continue;const c=t?this.styleCache.get(t):{},d=this.styleRules.find(({filter:g})=>Ni(a,g)),u=d?d.getStyle(a):_r(a);this.styleCache.set(a,{...c,...u});const{childNodes:h}=a;this.process(a,h,n,i);const m=this.afterProcessRules.find(({filter:g})=>Ni(a,g));m&&m.handler(n,a)}}dispose(){document.body.removeChild(this.htmlElement)}};R(Yn,"pluginList",[]);let wt=Yn;function Aa(o){const t=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=o.matchAll(t);if(!e)return{rowProperties:[],rowCount:0};const i=Array.from(e).map(r=>Sr(r[1]));return{rowProperties:i,rowCount:i.length}}function Sr(o){if(!o)return{};const t={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let n;for(;(n=e.exec(o))!==null;){const[,i,,r,s]=n,a=r!==void 0?r:s;t[i]=a}return t}function Da(o){const t=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=o.match(t),n=/<col([\s\S]*?)>/g;let i;return e!=null&&e[2]?i=e[2].matchAll(n):i=o.matchAll(n),i?Array.from(i).map(r=>Sr(r[1])):null}function Pa(o){const t={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&#39;":"'","&nbsp;":" "};return o.replace(/&lt;|&gt;|&amp;|&quot;|&#39;|&nbsp;|<br>/g,e=>t[e])}function ge(o,t){if(!o)return"";const e=/border(-top|-right|-bottom|-left)?\s*:\s*([^;]+);/g,n={},i=o.replace(e,(s,a,c)=>{const d=`border${a||""}`;return n[d]=c.trim(),""});let r=t.map(s=>s==="border"&&n[s]?`border: ${n[s]};`:n[s]?`${s}: ${n[s]};`:"").filter(s=>s).join(" ");return r+=` ${i.trim()}`,r.trim()}function Ha(o,t){var r,s,a;const e=new l.ObjectMatrix,n=(r=o.contentDocument)==null?void 0:r.querySelector("table");if(!n)return e;const i=n==null?void 0:n.querySelectorAll("tr");for(let c=0;c<i.length;c++){const u=i[c].querySelectorAll("td, th");let h=0;for(let m=0;m<u.length;){const g=u[m];let f="";const S=Number(g.getAttribute("rowSpan"))||1,p=Number(g.getAttribute("colSpan"))||1;if(f=La(g),S>1&&p>1&&!f.includes("border-top")&&!f.includes("border-left")){const T=Ai((s=e.getValue(c-1,m))==null?void 0:s.style,"border-bottom"),w=Ai((a=e.getValue(c,m-1))==null?void 0:a.style,"border-right");T&&(f+=`border-top:${T};`),w&&(f+=`border-left:${w};`)}const{cellText:I,cellRichStyle:M}=Ua(g,t),b=S>1||p>1?{rowSpan:S,colSpan:p,content:I,style:f,richTextParma:{p:M,v:I}}:{content:I,style:f,richTextParma:{p:M,v:I}};if(e.getValue(c,h)){h+=1;continue}else S>1||p>1?Va(e,f,b,{colSpan:p,rowSpan:S,rowIndex:c,colIndex:m,colSetValueIndex:h}):e.setValue(c,h,b),h+=p,m++}}return e}function pr(o,t,e,n=new Map){var i;for(const r of t)if(r.nodeType===Node.TEXT_NODE){const s=(i=r.nodeValue)==null?void 0:i.replace(/[\r\n]/g,"");let a;o&&n.has(o)&&(a=n.get(o)),e.dataStream+=s,a&&Object.getOwnPropertyNames(a).length&&e.textRuns.push({st:e.dataStream.length-s.length,ed:e.dataStream.length,ts:a})}else{if(r.nodeType===Node.COMMENT_NODE||r.nodeName==="STYLE")continue;if(r.nodeType===Node.ELEMENT_NODE){const s=o?n.get(o):{},a=getComputedStyle(r),c=_r(r,a);n.set(r,{...s,...c});const{childNodes:d}=r;pr(r,d,e,n)}}}function Ai(o,t){if(!o||!t)return null;const e=new RegExp(`(${t}\\s*:\\s*[^;]+);`,"i"),n=o.match(e);return n?n[1]:null}function La(o){let t="";const e=o.getAttribute("class"),n=getComputedStyle(o);if(e)Oa.forEach(i=>{const[r,s]=i.split("_"),a=n.getPropertyValue(r)||n[s];a&&(t+=`${r}:${a};`)});else{const r=/<\w+\s+[^>]*?style="([^"]*)"/gi.exec(o.outerHTML);r!=null&&r[1]&&(t=r[1])}return xa.forEach(i=>{const[r,s]=i.split("_"),a=n.getPropertyValue(r)||n[s];a&&(t+=`${r}:${a};`)}),t}function Ua(o,t){var r;let e="",n;if(/<[^>]+>/.test(o.innerHTML)&&t){const s={dataStream:"",textRuns:[]};pr(null,o.childNodes,s);const a=(r=t.getBlankCellDocumentModel())==null?void 0:r.documentModel,c=a==null?void 0:a.getSnapshot(),d=`${s.dataStream}\r
5
- `,u={...c,body:{dataStream:d,textRuns:s.textRuns,paragraphs:wo(d)}};a==null||a.reset(u),n=a==null?void 0:a.getSnapshot(),e=s.dataStream}else e=Pa(o.innerHTML.replace(/[\r\n]/g,""));return{cellText:e,cellRichStyle:n}}function Va(o,t,e,n){const{rowSpan:i,colSpan:r,rowIndex:s,colSetValueIndex:a}=n;if(i===1){for(let c=a;c<a+r;c++)o.setValue(s,c,{style:ge(t,["border-top","border-bottom"])});o.setValue(s,a+r-1,{style:ge(t,["border-top","border-bottom","border-right"])}),o.setValue(s,a,{...e,style:ge(t,["border-top","border-bottom","border-left"])})}else if(r===1){for(let c=s;c<s+i;c++)o.setValue(c,a,{style:ge(t,["border-left","border-right"])});o.setValue(s+i-1,a,{style:ge(t,["border-left","border-right","border-bottom"])}),o.setValue(s,a,{...e,style:ge(t,["border-left","border-right","border-top"])})}else{for(let c=a;c<a+r;c++)o.setValue(s,c,{style:ge(t,["border-top"])}),o.setValue(s+i-1,c,{style:ge(t,["border-bottom"])});for(let c=s;c<s+i;c++)o.setValue(c,a,{style:ge(t,["border-left"])}),o.setValue(c,a+r-1,{style:ge(t,["border-right"])});o.setValue(s+i-1,a,{style:ge(t,["border-left","border-bottom"])}),o.setValue(s,a+r-1,{style:ge(t,["border-right","border-top"])}),o.setValue(s+i-1,a+r-1,{style:ge(t,["border-right","border-bottom"])}),o.setValue(s,a,{...e,style:ge(t,["border-top","border-left"])});for(let c=s;c<s+i;c++)for(let d=a;d<a+r;d++)o.getValue(c,d)||o.setValue(c,d,{style:ge(t,[])})}}var Je=(o=>(o.COPY="COPY",o.CUT="CUT",o))(Je||{});function Ba(o,t,e,n,i){const r=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,o)}).filter(d=>!!d),s=Go(r),a=Zo(s),c=t.map(d=>{if(!i.has(`${o}-${d}`)){const u=n.getValue(o,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=o;h<o+u.rowSpan;h++)for(let m=d;m<d+u.colSpan;m++)i.add(`${h}-${m}`);return ka(o,d,e,n)}return null}).filter(d=>!!d).join("");return`<tr${a}>${c}</tr>`}function ka(o,t,e,n){const i=n.getValue(o,t),r=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,o,t,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(d=>!!d),s=Go(r),a=Zo(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,o,t))||""},"");return`<td${a}>${c}</td>`}function Fa(o,t){return`<colgroup>${o.map(n=>{const i=t.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),r=Go(i);return`<col ${Zo(r)}>`}).join("")}</colgroup>`}function Go(o){return o.reduce((t,e)=>(Object.keys(e).forEach(i=>{t[i]?t[i]+=`;${e[i]}`:t[i]=e[i]}),t),{})}function Zo(o){return Object.keys(o).reduce((t,e)=>(t+=` ${e}="${o[e]}"`,t),"")}function Wa(o,t){const e=[];for(let n=o;n<=t;n++)e.push(n);return e}class ja{convert(t,e,n){const{startColumn:i,endColumn:r}=e,s=Fa(Wa(i,r),n),a=[],c=new Set,{startRow:d,endRow:u,startColumn:h,endColumn:m}=t.getDataRange();for(let f=d;f<=u;f++){const S=Array.from({length:m-h+1},(p,I)=>h+I);a.push(Ba(f,S,n,t,c))}return`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
6
- <tbody>${a.join("")}</tbody></table>`}}const $a=(o,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,i=h=>h.endColumn-h.startColumn+1,r=n(t)%n(o),s=i(t)%i(o),a={startRow:0,endRow:n(o)-1,startColumn:0,endColumn:i(o)-1},c=Math.floor(n(t)/n(o)),d=Math.floor(i(t)/i(o)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const g=n(o)*(h-1),f=i(o)*(m-1),S={startRow:g+t.startRow,endRow:g+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};u.push({repeatRelativeRange:a,startRange:S})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const m=n(o)*(h-1),g=0,f={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else if(r&&!s&&!e)for(let h=1;h<=d;h++){const g=i(o)*(h-1),f={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};u.push({repeatRelativeRange:a,startRange:f})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};async function za(o){return o?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(o):!1}function Ya(...o){if(o.length===1)return o[0];const t=new l.ObjectMatrix;return o.forEach(e=>{e&&new l.ObjectMatrix(e).forValue((i,r,s)=>{t.setValue(i,r,{...t.getValue(i,r),...s})})}),t.getMatrix()}function Xa(o,t){return o.id===t.id&&o.params.unitId===t.params.unitId&&o.params.subUnitId===t.params.subUnitId}function Eo(o){const t=[];for(let e=0;e<o.length;){let n=1;if(o[e].id===_.SetRangeValuesMutation.id){const i=o[e],r=[i];for(;e+n<o.length&&Xa(i,o[e+n]);)r.push(o[e+n]),n+=1;const s=Ya(...r.map(a=>a.params.cellValue||{}));t.push({...i,params:{...i.params,cellValue:s}})}else t.push(o[e]);e+=n}return t}function ao(o,t){const{startRow:e,endRow:n,startColumn:i,endColumn:r}=o;for(let s=e;s<=n;s++)for(let a=i;a<=r;a++)if(t.rows.includes(s)&&t.cols.includes(a))return!0}function Di(o,t){const{startRow:e,endRow:n,startColumn:i,endColumn:r}=t;for(let s=e;s<=n;s++)if(!o.rows.includes(s))return!1;for(let s=i;s<=r;s++)if(!o.cols.includes(s))return!1;return!0}var Ga=Object.defineProperty,Za=Object.getOwnPropertyDescriptor,Ka=(o,t,e,n)=>{for(var i=n>1?void 0:n?Za(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ga(t,e,i),i},ve=(o,t)=>(e,n)=>t(e,n,o);const fe={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};wt.use(Yo.PastePluginWord);wt.use(Yo.PastePluginLark);wt.use(Yo.PastePluginUniver);const Ot=P.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends l.Disposable{constructor(e,n,i,r,s,a,c,d,u,h,m,g,f){super();R(this,"_clipboardHooks",[]);R(this,"_clipboardHooks$",new B.BehaviorSubject([]));R(this,"clipboardHooks$",this._clipboardHooks$.asObservable());R(this,"_htmlToUSM");R(this,"_usmToHtml");R(this,"_copyContentCache");R(this,"_copyMarkId",null);this._logService=e,this._univerInstanceService=n,this._selectionManagerService=i,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._notificationService=u,this._platformService=h,this._localeService=m,this._errorService=g,this._injector=f,this._htmlToUSM=new wt({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new ja,this._copyContentCache=new wa,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}generateCopyContent(e,n,i){const r=this._clipboardHooks;r.forEach(a=>{var c;return(c=a.onBeforeCopy)==null?void 0:c.call(a,e,n,i)});const s=this._generateCopyContent(e,n,i,r);return r.forEach(a=>{var c;return(c=a.onAfterCopy)==null?void 0:c.call(a)}),s}async copy(e=Je.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),r=i.getActiveSheet(),s=this.generateCopyContent(i.getUnitId(),r.getSheetId(),n.range);if(!s)return!1;const{html:a,plain:c,matrixFragment:d,copyId:u,discreteRange:h}=s;this._copyContentCache.set(u,{unitId:i.getUnitId(),subUnitId:r.getSheetId(),range:h,matrix:d,copyType:e}),await this._clipboardInterfaceService.write(c,a),this._markSelectionService.removeAllShapes();const m=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:m}),!0}async cut(){return this.copy(Je.CUT)}async paste(e,n=fe.DEFAULT_PASTE){const i=e.types,r=i.indexOf(v.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(v.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=i.indexOf(v.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(v.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._platformService.isWindows&&await za(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,fe.DEFAULT_PASTE):n?this._pastePlainText(n,fe.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(i=>i.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(i=>{const r=i.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),l.toDisposable(()=>{const i=this._clipboardHooks.indexOf(e);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,i,r){const s=this._univerInstanceService.getUniverSheetInstance(e),a=s==null?void 0:s.getSheetBySheetId(n);if(!s||!a)return null;const c=r.reduce((T,w)=>{var O;const E=(O=w.getFilteredOutRows)==null?void 0:O.call(w,i);return E==null||E.forEach(x=>T.add(x)),T},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:m}=i,g=a.getMatrixWithMergedCells(u,d,m,h,!0),f=new l.ObjectMatrix;let S=u;const p={rows:[],cols:[]};for(let T=u;T<=m;T++)if(!c.has(T)){p.rows.push(T);for(let w=d;w<=h;w++){const E=g.getValue(T,w);E?f.setValue(S-u,w-d,{...Pi(),...l.Tools.deepClone(E)}):f.setValue(S-u,w-d,Pi())}S+=1}for(let T=d;T<=h;T++)p.cols.push(T);let I=this._usmToHtml.convert(g,i,r);const M=qa(f),b=ba();return I=I.replace(/(<[a-z]+)/,(T,w)=>`${w} data-copy-id="${b}"`),{copyId:b,plain:M,html:I,matrixFragment:f,discreteRange:p}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const i=this._getPastingTarget();if(!i.selection)return!1;const r={get:this._injector.get.bind(this._injector)},s=Rt(i.selection.range,r,i.unitId,i.subUnitId);if(!s)return!1;const{unitId:a,subUnitId:c}=i,d=this._clipboardHooks,u=[];if(d.some(S=>{var p;return u.push(S)&&((p=S.onBeforePaste)==null?void 0:p.call(S,{unitId:a,subUnitId:c,range:s}))===!1}))return u.forEach(S=>{var p;return(p=S.onAfterPaste)==null?void 0:p.call(S,!1)}),!1;const m=[],g=[];u.forEach(S=>{var I;const p=(I=S.onPastePlainText)==null?void 0:I.call(S,{unitId:a,subUnitId:c,range:s},e,{pasteType:n});p&&(m.push(...p.redos),g.push(...p.undos))});const f=m.every(S=>this._commandService.executeCommand(S.id,S.params));return f&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:g,redoMutations:m}),f}async _pasteHTML(e,n){const i=Ta(e);return i&&this._copyContentCache.get(i)?this._pasteInternal(i,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){var u;const{rowProperties:i,colProperties:r,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const a=this._getPastedRange(s);if(!a)return!1;const c=(u=this._univerInstanceService.getUniverSheetInstance(a.unitId))==null?void 0:u.getSheetBySheetId(a.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d&&d.some(m=>ao(m,a.pastedRange)&&!Di(a.pastedRange,m))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:i,colProperties:r,cellMatrix:s},a,n)}async _pasteInternal(e,n){var T,w;const i=l.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:a,subUnitId:c}=i||{};if(!s||!i||!r||!a||!c||!s||!i)return!1;const d=(T=this._univerInstanceService.getUniverSheetInstance(a))==null?void 0:T.getStyles();s.forValue((E,O,x)=>{if(typeof x.s=="string"){const A=l.Tools.deepClone(x);A.s=d==null?void 0:d.getStyleByCell(x),s.setValue(E,O,A)}});const u=this._getPastedRange(s);if(!u)return!1;const h=(w=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:w.getSheetBySheetId(u.subUnitId);if(!h)return!1;const m=h==null?void 0:h.getMergeData();if(m&&m.some(O=>ao(O,u.pastedRange)&&!Di(u.pastedRange,O)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const g=h.getColumnManager(),f=h.getRowManager(),S=h.getConfig().defaultColumnWidth,p=h.getConfig().defaultRowHeight,I=[],M=[];if(r.cols.forEach(E=>{const O=g.getColumnOrCreate(E);I.push({width:`${O.w||S}`})}),r.rows.forEach(E=>{const O=f.getRowOrCreate(E);M.push({height:`${O.ah||O.h||p}`})}),i.copyType===Je.CUT){const E=u.pastedRange.rows[0],O=r.rows[r.rows.length-1]-r.rows[0]+E;u.pastedRange.rows=Array.from(new Array(O+1).keys()).slice(E)}const b=this._pasteUSM({cellMatrix:s,colProperties:I,rowProperties:M},u,n,{range:r,unitId:i.unitId,subUnitId:i.subUnitId,copyType:i.copyType,copyId:e});return i.copyType===Je.CUT&&(this._copyContentCache.set(e,{...i,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),b}_pasteUSM(e,n,i,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=n,m=h.cols.length,g=this._clipboardHooks,f=[];if(g.some(O=>{var x;return f.push(O)&&((x=O.onBeforePaste)==null?void 0:x.call(O,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(O=>{var x;return(x=O.onAfterPaste)==null?void 0:x.call(O,!1)}),!1;if(!c)return!1;const p=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,I={copyType:(r==null?void 0:r.copyType)||Je.COPY,copyId:r==null?void 0:r.copyId,pasteType:i};let M=[],b=[];f.filter(O=>!O.specialPasteInfo&&O.id!==fe.DEFAULT_PASTE||i===O.id).forEach(O=>{var k,N,L;if(s){const V=(k=O.onPasteRows)==null?void 0:k.call(O,{range:h,unitId:d,subUnitId:u},s,{pasteType:i});V&&(M.push(...V.redos),b.push(...V.undos))}const x=(N=O.onPasteColumns)==null?void 0:N.call(O,{range:h,unitId:d,subUnitId:u},a||new Array(m).map(()=>({})),{pasteType:i});x&&(M.push(...x.redos),b.push(...x.undos));const A=(L=O.onPasteCells)==null?void 0:L.call(O,p,{range:h,unitId:d,subUnitId:u},c,I);A&&(M.push(...A.redos),b.push(...A.undos))});const w=this._getSetSelectionOperation(d,u,h,c);w&&M.push(w),M=Eo(M),b=Eo(b),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:b,redoMutationsInfo:M});const E=M.every(O=>this._commandService.executeCommand(O.id,O.params));return E&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:b,redoMutations:M}),E}_getSetSelectionOperation(e,n,i,r){var b;const s=(b=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:b.getSheetBySheetId(n);if(!s)return null;const{rows:a,cols:c}=i,d=a[0],u=c[0],h=a[a.length-1],m=c[c.length-1],g={startRow:d,endRow:d,startColumn:u,endColumn:u},f=_.getPrimaryForRange(g,s),S=r.getValue(0,0),p=(S==null?void 0:S.rowSpan)||1,I=(S==null?void 0:S.colSpan)||1;if(p>1||I>1){const T={startRow:d,endRow:d+p-1,startColumn:u,endColumn:u+I-1};f.startRow=T.startRow,f.endRow=T.endRow,f.startColumn=T.startColumn,f.endColumn=T.endColumn,f.isMerged=!0,f.isMergedMainCell=!0}const M={unitId:e,subUnitId:n,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:d,endRow:h,startColumn:u,endColumn:m},primary:f,style:null}]};return{id:_.SetSelectionsOperation.id,params:M}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),i=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:i}}_transformPastedData(e,n,i){const r=this._getPastingTarget(),{selection:s,unitId:a,subUnitId:c}=r;if(!s)return null;const d={get:this._injector.get.bind(this._injector)},u=Rt(s.range,d,a,c);if(!u)return null;const{ranges:[h],mapFunc:m}=en([u]),{startRow:g,startColumn:f,endRow:S,endColumn:p}=h,I=S-g+1,M=p-f+1,b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getActiveSheet();if(!T)return null;const E=T.getMergeData().filter(L=>u.rows.includes(L.startRow)&&u.cols.includes(L.startColumn)),O=E[0];let x=0,A=0,k=0,N=0;if(O&&(x=O.startRow,A=O.startColumn,k=O.endRow,N=O.endColumn),I%e===0&&M%n===0)if(E.length>0&&(I!==e||M!==n))if(x===u.rows[0]&&A===u.cols[0]&&k===u.rows[I-1]&&N===u.cols[M-1])if(nl(i))for(let V=0;V<I;V++)for(let j=0;j<M;j++){const z=i.getValue(V%e,j%n);z&&i.setValue(V,j,z)}else i.forValue((V,j,z)=>{z.s=null,delete z.colSpan,delete z.rowSpan});else for(let L=0;L<I;L++)for(let V=0;V<M;V++){const j=i.getValue(L%e,V%n);j&&i.setValue(L,V,j)}else for(let L=0;L<I;L++)for(let V=0;V<M;V++){const j=i.getValue(L%e,V%n);j&&i.setValue(L,V,j)}else if(E.length>0){const{row:L,col:V}=m(g,f);if(this._topLeftCellsMatch(e,n,{topRow:L,leftCol:V})){const z=this._expandOrShrinkRowsCols(a,c,u,n,e);u.rows=z.rows,u.cols=z.cols}else{if(S>O.endRow||p>O.endColumn)return null;i.forValue((z,q,K)=>{K.s=null,delete K.colSpan,delete K.rowSpan})}}else{const L=this._expandOrShrinkRowsCols(a,c,u,n,e);u.rows=L.rows,u.cols=L.cols}return{pastedRange:u,unitId:a,subUnitId:c}}_getPastedRange(e){var T;const n=this._getPastingTarget(),{selection:i,unitId:r,subUnitId:s}=n;if(!i)return null;const a={get:this._injector.get.bind(this._injector)},c=Rt(i.range,a,r,s);if(!c)return null;const{startColumn:d,endColumn:u,startRow:h,endRow:m}=e.getDataRange(),g=m-h+1,f=u-d+1,S=c.rows.length,p=c.cols.length,I=(T=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:T.getSheetBySheetId(s);if(!I)return null;const M=I==null?void 0:I.getMergeData();if(S%g===0&&p%f===0&&!(M==null?void 0:M.some(E=>ao(E,c)))){for(let E=0;E<S;E++)for(let O=0;O<p;O++){const x=e.getValue(E%g,O%f);x&&e.setValue(E,O,x)}return{pastedRange:c,unitId:r,subUnitId:s}}const b=this._expandOrShrinkRowsCols(r,s,c,f,g);return c.rows=b.rows,c.cols=b.cols,{pastedRange:c,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,n,i,r,s){const{rows:a,cols:c}=i,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(n);let h,m;if(a.length>=s)h=a.slice(0,s);else{h=a.slice(0);let g=a[a.length-1]+1;for(;h.length<s;)u.getRowFiltered(g)||h.push(g),g++}if(c.length>=r)m=c.slice(0,r);else{m=c.slice(0);let g=c[c.length-1]+1;for(;m.length<r;)m.push(g),g++}return{rows:h,cols:m}}_topLeftCellsMatch(e,n,i){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:a,leftCol:c}=i,d=el(a+e-1,c,c+n-1,s),u=tl(c+n-1,a,a+e-1,s);return!d&&!u}};exports.SheetClipboardService=Ka([ve(0,l.ILogService),ve(1,l.IUniverInstanceService),ve(2,P.Inject(_.SelectionManagerService)),ve(3,v.IClipboardInterfaceService),ve(4,l.IUndoRedoService),ve(5,l.ICommandService),ve(6,tn),ve(7,P.Inject(exports.SheetSkeletonManagerService)),ve(8,v.INotificationService),ve(9,v.IPlatformService),ve(10,P.Inject(l.LocaleService)),ve(11,P.Inject(l.ErrorService)),ve(12,P.Inject(P.Injector))],exports.SheetClipboardService);function qa(o){let t="";const e=o.getLength();return o.forRow((n,i)=>{const r=[];i.forEach(s=>{const a=o.getValue(n,s);if(a){const c=Qa(a);r.push(c)}}),t+=r.join(" "),n!==e-1&&(t+=`
7
- `)}),t}function Qa(o){const t=l.extractPureTextFromCell(o);return Ja((t==null?void 0:t.toString())||"")}const Ja=o=>o.replace(/&/g,"&amp;").replace(/\uFEFF/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");function el(o,t,e,n){return n.getMergeData().some(i=>i.startRow<=o&&o<i.endRow&&t<=i.startColumn&&i.startColumn<=e)}function tl(o,t,e,n){return n.getMergeData().some(i=>i.startColumn<=o&&o<i.endColumn&&t<=i.startRow&&i.startRow<=e)}function nl(o){let t=0;return o.forValue((e,n,i)=>{if(i&&t++,t>1)return!1}),t>1}function Pi(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ko=998,Cr={id:v.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:Ko,preconditions:Xo,handler:async o=>o.get(Ot).copy()},ol={id:v.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:Ko,preconditions:Xo,handler:async o=>o.get(Ot).cut()},xt={id:v.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ko,preconditions:Xo,handler:async(o,t)=>{const n=await o.get(v.IClipboardInterfaceService).read(),i=o.get(Ot);return n.length!==0?i.paste(n[0],t==null?void 0:t.value):!1}},vr={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_VALUE})},Ir={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_FORMAT})},Rr={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_COL_WIDTH})},Mr={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_BESIDES_BORDER})};var Gn=(o=>(o.MergeAll="mergeAll",o.MergeVertical="mergeVertical",o.MergeHorizontal="mergeHorizontal",o))(Gn||{});function et(o,t,e,n,i=!0,r=1,s=!0){let a={...o};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(t){case l.Direction.UP:for(c=o.startRow-r;c>-1&&!e.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,i&&(a=et(a,l.Direction.LEFT,e,n,!1)));break;case l.Direction.DOWN:for(c=o.endRow+r;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,i&&(a=et(a,l.Direction.RIGHT,e,n,!1)));break;case l.Direction.LEFT:for(c=o.startColumn-r;c>-1&&!e.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,i&&(a=et(a,l.Direction.UP,e,n,!1)));break;case l.Direction.RIGHT:for(c=o.endColumn+r;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,i&&(a=et(a,l.Direction.DOWN,e,n,!1)));break}return a}function qo(o,t,e){const n={...o},{startRow:i,startColumn:r,endRow:s,endColumn:a}=Zt(o,t,e);let c=Bt(e,i,r,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=Bt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue(S=>{f=Math.min(S,f)}),n.startRow=f}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){u=!1;break}const{hasValue:m,matrix:g}=Bt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((S,p,I)=>{f=Math.max(S+(I.rowSpan||1)-1,f)}),n.endRow=f}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:g}=Bt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((S,p)=>{f=Math.min(p,f)}),n.startColumn=f}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){u=!1;break}const{hasValue:m,matrix:g}=Bt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((S,p,I)=>{f=Math.max(p+(I.colSpan||1)-1,f)}),n.endColumn=f}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return _.alignToMergedCellsBorders(n,e,!0)}function br(o,t,e){return et(o,t,e,void 0,!1,1,!1)}function il(o,t,e){const n=qo(o,t,e);return _.alignToMergedCellsBorders(l.Rectangle.union(n,o),e,!0)}function rl(o,t,e){const n=br(o,t,e),i={startRow:Math.min(o.startRow,n.startRow),startColumn:Math.min(o.startColumn,n.startColumn),endRow:Math.max(o.endRow,n.endRow),endColumn:Math.max(o.endColumn,n.endColumn)};return _.alignToMergedCellsBorders(l.Rectangle.union(o,i),e)}function sl(o,t,e,n){const i=l.getReverseDirection(e),r=qo(Zt(o,i,n),e,n);return e===l.Direction.UP&&r.startRow<=o.startRow?_.alignToMergedCellsBorders({...t,startColumn:o.startColumn,endColumn:o.endColumn},n,!0):e===l.Direction.DOWN&&r.endRow>=o.endRow?_.alignToMergedCellsBorders({...t,startColumn:o.startColumn,endColumn:o.endColumn},n,!0):e===l.Direction.LEFT&&r.startColumn<=o.startColumn?_.alignToMergedCellsBorders({...t,startRow:o.startRow,endRow:o.endRow},n,!0):e===l.Direction.RIGHT&&r.endColumn>=o.endColumn?_.alignToMergedCellsBorders({...t,startRow:o.startRow,endRow:o.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(t),r)}function al(o,t,e){const n=l.getReverseDirection(t),i=Zt(o,n,e),r=Zt(o,t,e),s=br(i,t,e);return _.alignToMergedCellsBorders(l.Rectangle.union(r,s),e,!1)}function Tr(o,t,e){const{left:n,right:i,up:r,down:s}=t,a=e.getMaxRows(),c=e.getMaxColumns();let d=!0;const u={...o};for(;d;){if(d=!1,r&&u.startRow!==0){const h=u.startRow-1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,f,S)=>{jt(S)&&(u.startRow=Math.min(g,u.startRow),u.startColumn=Math.min(f,u.startColumn),u.endColumn=Math.max(f,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;e.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((g,f,S)=>{jt(S)&&(u.endRow=Math.max(g+(S.rowSpan!==void 0?S.rowSpan-1:0),u.endRow),u.startColumn=Math.min(f,u.startColumn),u.endColumn=Math.max(f,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,f,S)=>{jt(S)&&(u.startColumn=Math.min(f,u.startColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}if(i&&u.endColumn!==c-1){const h=u.endColumn+1;e.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((g,f,S)=>{jt(S)&&(u.endColumn=Math.max(f+(S.colSpan!==void 0?S.colSpan-1:0),u.endColumn),u.startRow=Math.min(g,u.startRow),u.endRow=Math.max(g,u.endRow),d=!0)})}}return u}function Hi(o){return{startRow:0,startColumn:0,endRow:o.getRowCount()-1,endColumn:o.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function Zt(o,t,e){let n;switch(t){case l.Direction.UP:n={startRow:o.startRow,startColumn:o.startColumn,endRow:o.startRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:o.endRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:o.startRow,startColumn:o.endColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return _.alignToMergedCellsBorders(n,e,!1)}function Bt(o,t,e,n,i){let r=!1;const s=o.getMatrixWithMergedCells(t,e,n,i).forValue((a,c,d)=>{if(jt(d))return r=!0,!1});return{hasValue:r,matrix:s}}function yo(o,t,e){const n=l.Rectangle.clone(o);if(t==null)return n;switch(e){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function ll(o,t,e){const{primary:n,range:i}=o,r=l.Rectangle.clone(i);switch(t){case l.Direction.UP:case l.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=Zt(r,t,e);switch(t){case l.Direction.DOWN:return i.startRow<s.startRow;case l.Direction.UP:return i.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<i.endColumn;case l.Direction.RIGHT:return s.startColumn>i.startColumn}}function wr(o,t){let e=o[0].startRow,n=o[0].endRow;o.forEach(r=>{const{startRow:s,endRow:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const i=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)i[c-e]=!0}),o.every(r=>{const{startRow:s,endRow:a}=r;for(let c=s;c<=a;c++)if(!i[c-e])return!1;return!0})}function Er(o,t){let e=o[0].startColumn,n=o[0].endColumn;o.forEach(r=>{const{startColumn:s,endColumn:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const i=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)i[c-e]=!0}),o.every(r=>{const{startColumn:s,endColumn:a}=r;for(let c=s;c<=a;c++)if(!i[c-e])return!1;return!0})}function Qo(o,t){return t?o==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):o==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):o==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}function jt(o){return o.v!==void 0&&o.v!==null&&o.v!==""||o.p!==void 0}var cl=Object.defineProperty,dl=Object.getOwnPropertyDescriptor,ul=(o,t,e,n)=>{for(var i=n>1?void 0:n?dl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&cl(t,e,i),i},Li=(o,t)=>(e,n)=>t(e,n,o);let Kt=class{constructor(o,t){R(this,"_current",null);R(this,"_shortcutParam",[]);this._univerInstanceService=o,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(o){return this._getCurrentBySearch(o)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(o){const t=this._getCurrentBySearch({unitId:o.unitId,sheetId:o.sheetId,keycode:o.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(o),t}remove(o){if(o==null)return;const t=this._getCurrentBySearch(o);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(o){return o==null?void 0:this._shortcutParam.find(e=>e.unitId===o.unitId&&e.sheetId===o.sheetId&&e.keycode===o.keycode)}};Kt=ul([Li(0,l.IUniverInstanceService),Li(1,P.Inject(l.LocaleService))],Kt);var Fe=(o=>(o[o.moveStopeOne=0]="moveStopeOne",o[o.moveGap=1]="moveGap",o[o.moveStepPage=2]="moveStepPage",o[o.moveStepEnd=3]="moveStepEnd",o))(Fe||{});const we={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:i}=e,r=o.get(_.SelectionManagerService).getLast();if(!r)return!1;const{direction:s,jumpOver:a}=t,{range:c,primary:d}=r,u=yo(c,d,s),h=a===1?qo(u,s,i):et(u,s,i),m=_.getCellAtRowCol(h.startRow,h.startColumn,i);return l.Rectangle.equals(m,u)?!1:(o.get(Kt).remove({unitId:n.getUnitId(),sheetId:i.getSheetId(),keycode:v.KeyCode.TAB}),o.get(l.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:i.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(m),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:h.startRow,actualColumn:h.startColumn,isMerged:m.isMerged,isMergedMainCell:m.startRow===h.startRow&&m.startColumn===h.startColumn}}]}))}},gt={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:i}=e,r=o.get(_.SelectionManagerService).getLast();if(!r)return!1;const s=n.getUnitId(),a=i.getSheetId();if(!r)return!1;const{direction:c,keycode:d}=t,{range:u,primary:h}=r;let m=yo(u,h,c);const g=o.get(Kt),f=g.getCurrentBySearch({unitId:s,sheetId:a,keycode:v.KeyCode.TAB});let S;const{startRow:p,endRow:I,startColumn:M,endColumn:b}=u;if(l.Rectangle.equals(u,h)){if(d===v.KeyCode.TAB)f==null&&g.addOrUpdate({unitId:s,sheetId:a,keycode:v.KeyCode.TAB,selection:r});else{const E=f==null?void 0:f.selection;if(E!=null){const{range:O,primary:x}=E;m=yo(O,x,c)}g.remove({unitId:s,sheetId:a,keycode:v.KeyCode.TAB})}const T=et(m,c,i),w=_.getCellAtRowCol(T.startRow,T.startColumn,i);if(l.Rectangle.equals(w,m))return!1;S={range:l.Rectangle.clone(w),primary:{startRow:w.startRow,startColumn:w.startColumn,endRow:w.endRow,endColumn:w.endColumn,actualRow:T.startRow,actualColumn:T.startColumn,isMerged:w.isMerged,isMergedMainCell:w.startRow===T.startRow&&w.startColumn===T.startColumn}}}else{g.remove({unitId:s,sheetId:a,keycode:v.KeyCode.TAB});const T=l.Tools.deepClone(h),w=et({startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn},c,i,{startRow:p,endRow:I,startColumn:M,endColumn:b}),E=_.getCellAtRowCol(w.startRow,w.startColumn,i);S={range:l.Rectangle.clone(u),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:w.startRow,actualColumn:w.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===w.startRow&&E.startColumn===w.startColumn}}}return o.get(l.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:s,subUnitId:a,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[S]})}},Ae={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=_.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{worksheet:n,unitId:i,subUnitId:r}=e,s=o.get(_.SelectionManagerService).getLast();if(!s)return!1;const{range:a,primary:c}=s,{jumpOver:d,direction:u}=t,m=ll(s,u,n)?d===1?sl(a,{...l.Rectangle.clone(c),rangeType:l.RANGE_TYPE.NORMAL},u,n):al(a,u,n):d===1?il(a,u,n):rl(a,u,n);return l.Rectangle.equals(m,a)?!1:o.get(l.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:i,subUnitId:r,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:m,primary:c}]})}};let Le=[],lo="";const yr={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Le=[],lo=""},handler:async(o,t={expandToGapFirst:!0,loop:!1})=>{const e=o.get(_.SelectionManagerService).getLast(),n=_.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!n)return!1;const{worksheet:i,unitId:r,subUnitId:s}=n;if(!e||!i)return!1;const a=`${r}|${s}`;a!==lo&&(Le=[],lo=a);const c=i.getMaxRows(),d=i.getMaxColumns(),{expandToGapFirst:u,loop:h}=t,{range:m,primary:g}=e,f=m.endColumn===d-1&&m.endRow===c-1&&m.startRow===0&&m.startColumn===0;Le.some(p=>l.Rectangle.equals(p,m))||(Le=[],Le.push(m));let S;if(f)if(h){if(Le.findIndex(I=>l.Rectangle.equals(I,m))!==Le.length-1)return!1;S=Le[0]}else return!1;else u?(S=Tr(m,{left:!0,right:!0,up:!0,down:!0},i),l.Rectangle.equals(S,m)&&(S=Hi(i))):S=Hi(i);return Le.some(p=>l.Rectangle.equals(p,S))||Le.push(S),o.get(l.ICommandService).executeCommand(_.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:S,primary:g}]})}};var hl=Object.defineProperty,ml=Object.getOwnPropertyDescriptor,gl=(o,t,e,n)=>{for(var i=n>1?void 0:n?ml(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&hl(t,e,i),i},kt=(o,t)=>(e,n)=>t(e,n,o);const fl=l.createInterceptorKey("BEFORE_CELL_EDIT"),_l=l.createInterceptorKey("AFTER_CELL_EDIT"),Sl=l.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");exports.EditorBridgeService=class extends l.Disposable{constructor(e,n,i,r,s){super();R(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);R(this,"_isForceKeepVisible",!1);R(this,"_editorIsDirty",!1);R(this,"_visible",{visible:!1,eventType:y.DeviceInputEventType.Dblclick});R(this,"_currentEditCell",null);R(this,"_currentEditCellState",null);R(this,"_currentEditCellState$",new B.BehaviorSubject(null));R(this,"currentEditCellState$",this._currentEditCellState$.asObservable());R(this,"_visible$",new B.BehaviorSubject(this._visible));R(this,"visible$",this._visible$.asObservable());R(this,"_afterVisible$",new B.BehaviorSubject(this._visible));R(this,"afterVisible$",this._afterVisible$.asObservable());R(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:fl,AFTER_CELL_EDIT:_l,AFTER_CELL_EDIT_ASYNC:Sl}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=i,this._univerInstanceService=r,this._editorService=s,this.disposeWithMe(l.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:a=>a})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:a=>a})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:a=>a}))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var N,L;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:i}=n,{primary:r,unitId:s,sheetId:a,scene:c,engine:d}=e,{startRow:u,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const g=l.makeCellToSelection(m);if(g==null)return;const f=y.getCanvasOffsetByEngine(d);let{startX:S,startY:p,endX:I,endY:M}=g;const{scaleX:b,scaleY:T}=c.getAncestorScale(),w=c.getScrollXY(this._selectionRenderService.getViewPort());S=i.convertTransformToOffsetX(S,b,w),p=i.convertTransformToOffsetY(p,T,w),I=i.convertTransformToOffsetX(I,b,w),M=i.convertTransformToOffsetY(M,T,w);const E=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),O=E.getActiveSheet(),x={workbook:E,worksheet:O,unitId:E.getUnitId(),subUnitId:O.getSheetId(),row:u,col:h},A=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(u,h),x);let k=A&&i.getCellDocumentModelWithFormula(A);if(!k||k.documentModel==null){const V=i.getBlankCellDocumentModel(A);if(k!=null){const{verticalAlign:j,horizontalAlign:z,wrapStrategy:q,textRotation:K,fill:$}=k,{centerAngle:Q,vertexAngle:D}=y.convertTextRotation(K);V.documentModel.documentStyle.renderConfig={verticalAlign:j,horizontalAlign:z,wrapStrategy:q,background:{rgb:$},centerAngle:Q,vertexAngle:D}}k=V}if((N=k.documentModel)==null||N.setZoomRatio(Math.max(b,T)),(A==null?void 0:A.isInArrayFormulaRange)===!0){const V=(L=k.documentModel)==null?void 0:L.getBody();V&&(V.textRuns=[{st:0,ed:V.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(a),{position:{startX:S,startY:p,endX:I,endY:M},scaleX:b,scaleY:T,canvasOffset:f,row:u,column:h,unitId:s,sheetId:a,documentLayoutObject:k,editorUnitId:this._editorUnitId,isInArrayFormulaRange:A==null?void 0:A.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=gl([kt(0,P.Inject(exports.SheetSkeletonManagerService)),kt(1,Ne),kt(2,P.Inject(l.ThemeService)),kt(3,l.IUniverInstanceService),kt(4,v.IEditorService)],exports.EditorBridgeService);const Ee=P.createIdentifier("univer.sheet-editor-bridge.service"),Te={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(o,t)=>{const e=o.get(Ee);return t==null?!1:(e.changeVisible(t),!0)}},Jo={id:"sheet.operation.set-cell-edit-visible-f2",type:l.CommandType.OPERATION,handler:(o,t)=>(o.get(l.ICommandService).syncExecuteCommand(Te.id,t),!0)},qt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class ot{constructor(){R(this,"_scrollInfo",new Map);R(this,"_scrollInfo$",new B.BehaviorSubject(null));R(this,"scrollInfo$",this._scrollInfo$.asObservable());R(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:i,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(i,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),e===!0&&this._refresh({unitId:n,sheetId:i})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var i;if(t==null)return;const{unitId:e,sheetId:n}=t;return(i=this._scrollInfo.get(e))==null?void 0:i.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const nt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(o,t)=>{if(t==null)return!1;const e=o.get(ot),r=o.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-a,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Xt={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(o,t={offsetX:0,offsetY:0})=>{const e=o.get(l.ICommandService),n=o.get(ot),i=o.get(l.IUniverInstanceService),r=_.getSheetCommandTarget(i);if(!r)return!1;const{unitId:s,subUnitId:a,worksheet:c}=r,{xSplit:d,ySplit:u}=c.getConfig().freeze,h=n.getCurrentScroll(),{offsetX:m=0,offsetY:g=0}=t||{},{sheetViewStartRow:f=0,sheetViewStartColumn:S=0,offsetX:p=0,offsetY:I=0}=h||{};return e.executeCommand(nt.id,{unitId:s,sheetId:a,sheetViewStartRow:f+u,sheetViewStartColumn:S+d,offsetX:p+m,offsetY:I+g})}},dt={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:(o,t)=>{if(!t)return!1;const e=o.get(l.IUniverInstanceService),n=o.get(ot),i=_.getSheetCommandTarget(e);if(!i)return!1;const{workbook:r,worksheet:s}=i,a=n.getCurrentScroll();if(!s)return!1;const{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=t,{sheetViewStartColumn:m,sheetViewStartRow:g,offsetX:f,offsetY:S}=a||{},{xSplit:p,ySplit:I}=s.getConfig().freeze;return o.get(l.ICommandService).syncExecuteCommand(nt.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:c!=null?c:(g!=null?g:0)+I,sheetViewStartColumn:d!=null?d:(m!=null?m:0)+p,offsetX:u!=null?u:f,offsetY:h!=null?h:S})}},Or={id:"sheet.command.scroll-to-cell",type:l.CommandType.COMMAND,handler:(o,t)=>{const e=o.get(l.IUniverInstanceService);return o.get(y.IRenderManagerService).getRenderById(e.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(t.range)}},pl={id:"sheet.command.scroll-view-reset",type:l.CommandType.COMMAND,handler:async o=>{const t=o.get(l.IUniverInstanceService),e=_.getSheetCommandTarget(t);if(!e)return!1;const{subUnitId:n,unitId:i}=e;return o.get(l.ICommandService).executeCommand(nt.id,{unitId:i,sheetId:n,sheetViewStartRow:0,sheetViewStartColumn:0})}};function Cl(o){return typeof o.isMainScene>"u"}function it(o,t){const e=o instanceof l.Workbook?o:o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const n=e.getUnitId();let i,r,s,a;if(Cl(t)){const m=t.getRenderById(n);if(m==null)return null;i=m.components,i=m.components,r=m.mainComponent,s=m.scene,a=m.engine}else i=t.components,r=t.mainComponent,s=t.scene,a=t.engine;if(!i||!r)return null;const c=r,d=i.get(ie.ROW),u=i.get(ie.COLUMN),h=i.get(ie.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:d,spreadsheetColumnHeader:u,spreadsheetLeftTopPlaceholder:h,scene:s,engine:a}}function Oo(o,t,e,n){const{startX:i,startY:r,endX:s,endY:a}=n.getCellByIndex(o,t);return{startX:i,startY:r,endX:s,endY:a}}function Et(o,t,e,n,i,r){const s=e.getRelativeCoord(y.Vector2.FromArray([o,t])),{x:a,y:c}=s,d=e.getScrollXYByRelativeCoords(s,i),{scaleX:u,scaleY:h}=e.getAncestorScale(),m=n.getCellPositionByOffset(a,c,u,h,d,r),{row:g,column:f}=m,S=n.getNoMergeCellPositionByIndex(g,f),{startX:p,startY:I,endX:M,endY:b}=S;return{startX:p,startY:I,endX:M,endY:b,row:g,column:f}}function Rn(o,t,e,n){const i=e.getRelativeCoord(y.Vector2.FromArray([o,t])),r=e.getViewport(W.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(i,r),{scaleX:a,scaleY:c}=e.getAncestorScale(),{x:d,y:u}=s,h=o/a+d,m=t/c+u;return{x:h,y:m}}var vl=Object.defineProperty,Il=Object.getOwnPropertyDescriptor,Rl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Il(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&vl(t,e,i),i},_t=(o,t)=>(e,n)=>t(e,n,o);const Ml=[we.id,gt.id];exports.SheetsScrollRenderController=class extends l.Disposable{constructor(t,e,n,i,r,s,a){super(),this._context=t,this._sheetSkeletonManagerService=e,this._univerInstanceService=n,this._commandService=i,this._renderManagerService=r,this._selectionManagerService=s,this._scrollManagerService=a,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(Ml.includes(t.id))this._scrollToSelection();else if(t.id===_.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===Ae.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e.range,a=this._getViewportBounding();if(a==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=a;let m=0,g=0;n>c?m=r:r<u?m=n:m=c,i>d?g=s:s<h?g=i:g=d,t.direction===l.Direction.DOWN?m=r:t.direction===l.Direction.UP?m=n:t.direction===l.Direction.RIGHT?g=s:t.direction===l.Direction.LEFT&&(g=i),this._scrollToCell(m,g)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(W.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(i=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||i.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=i,{row:d,column:u,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(a,c);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:d,sheetViewStartColumn:u,offsetX:m,offsetY:h})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(i=>{var f;const r=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(r==null||i.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=i,d=this._getFreeze(),{row:u,column:h,rowOffset:m,columnOffset:g}=r.getDecomposedOffset(a,c);this._commandService.executeCommand(dt.id,{sheetViewStartRow:u+((d==null?void 0:d.ySplit)||0),sheetViewStartColumn:h+((d==null?void 0:d.xSplit)||0),offsetX:g,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var S;const e=(S=this._sheetSkeletonManagerService.getCurrent())==null?void 0:S.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const i=n.scene;n.scene.getAncestorScale();const r=i.getViewport(W.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:a,offsetX:c,offsetY:d}=t,{startX:u,startY:h}=e.getCellByIndexWithNoHeader(s,a),m=u+c,g=h+d,f=r.getBarScroll(m,g);r.scrollTo(f)})))}_initSkeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var d;if(t==null)return;const{skeleton:e,unitId:n}=t,i=(d=this._renderManagerService.getRenderById(n))==null?void 0:d.scene;if(e==null||i==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=e;i==null||i.transformByState({width:a+s,height:c+r})}_getSheetObject(){return it(this._context.unit,this._context)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e;let a=0,c=0;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=t;d>=n&&(a=h),h<=r&&(a=d),u>=i&&(c=m),m<=s&&(c=u),this._scrollToCell(a,c)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:i,actualRow:r,actualColumn:s}=e.primary,a=t?r:n,c=t?s:i;this._scrollToCell(a,c)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(W.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const i=e.getBounding();return n.getRowColumnSegment(i)}_scrollToCell(t,e){var E,O,x,A;const{rowHeightAccumulation:n,columnWidthAccumulation:i}=(O=(E=this._sheetSkeletonManagerService.getCurrent())==null?void 0:E.skeleton)!=null?O:{};if(n==null||i==null)return!1;const r=(x=this._getSheetObject())==null?void 0:x.scene;if(r==null)return!1;const s=r.getViewport(W.VIEW_MAIN);if(s==null||((A=this._sheetSkeletonManagerService.getCurrent())==null?void 0:A.skeleton)==null)return!1;const c=this._context.unit.getActiveSheet(),{startColumn:d,startRow:u,ySplit:h,xSplit:m}=c.getFreeze(),g=this._getViewportBounding();if(g==null)return!1;const{startRow:f,startColumn:S,endRow:p,endColumn:I}=g;let M,b;if(t>=u&&e>=d-m&&(t<=f&&(M=t),t>=p)){const k=n[t]-s.height;for(let N=f;N<=t;N++)if(n[N]>=k){M=N+1;break}}if(e>=d&&t>=u-h&&(e<=S&&(b=e),e>=I)){const k=i[e]-s.width;for(let N=S;N<=e;N++)if(i[N]>=k){b=N+1;break}}if(M===void 0&&b===void 0)return!1;const{offsetX:T,offsetY:w}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(dt.id,{sheetViewStartRow:M,sheetViewStartColumn:b,offsetX:b===void 0?T:0,offsetY:M===void 0?w:0})}};exports.SheetsScrollRenderController=Rl([_t(1,P.Inject(exports.SheetSkeletonManagerService)),_t(2,l.IUniverInstanceService),_t(3,l.ICommandService),_t(4,y.IRenderManagerService),_t(5,P.Inject(_.SelectionManagerService)),_t(6,P.Inject(ot))],exports.SheetsScrollRenderController);function bl(o){return o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(B.switchMap(t=>t?t.activeSheet$.pipe(B.map(e=>e?{workbook:t,worksheet:e}:null)):B.of(null)))}function _e(o,t,e){return bl(o).pipe(B.switchMap(n=>n?e(n):B.of(t)))}var Tl=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,El=(o,t,e,n)=>{for(var i=n>1?void 0:n?wl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Tl(t,e,i),i},Ft=(o,t)=>(e,n)=>t(e,n,o);exports.SheetRenderController=class extends l.RxDisposable{constructor(e,n,i,r,s){super();R(this,"_skeletonChangeMutations",new Set);this._sheetSkeletonManagerService=e,this._contextService=n,this._univerInstanceService=i,this._renderManagerService=r,this._commandService=s,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){if(this._skeletonChangeMutations.has(e))throw new Error(`[SheetRenderController]: the mutationId ${e} has already been registered!`);return this._skeletonChangeMutations.add(e),l.toDisposable(()=>this._skeletonChangeMutations.delete(e))}_init(){this._initialRenderRefresh(),this._initWorkbookListener(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:n,unitId:i,sheetId:r}=e,s=this._univerInstanceService.getUniverSheetInstance(i),a=s==null?void 0:s.getSheetBySheetId(r);if(s==null||a==null)return;const c=this._renderManagerService.getRenderById(i);if(c==null)return;const{mainComponent:d,components:u}=c,h=d,m=u.get(ie.ROW),g=u.get(ie.COLUMN),f=u.get(ie.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:p}=n;h==null||h.updateSkeleton(n),m==null||m.updateSkeleton(n),g==null||g.updateSkeleton(n),f==null||f.transformByState({width:S,height:p})}))}_initWorkbookListener(){this._univerInstanceService.getTypeOfUnitAdded$(l.UniverInstanceType.UNIVER_SHEET).pipe(B.takeUntil(this.dispose$)).subscribe(e=>this._createSheetRenderer(e)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(B.takeUntil(this.dispose$)).subscribe(e=>{const n=e.getUnitId();this._sheetSkeletonManagerService.removeSkeleton({unitId:n}),this._renderManagerService.removeRender(n)}),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createSheetRenderer(e))}_createSheetRenderer(e){const n=e.getUnitId();this._renderManagerService.createRender(n),this._renderManagerService.setCurrent(n);const i=e.getActiveSheet().getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:i,unitId:n})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,s;const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return;const i=n.getUnitId();if(_.COMMAND_LISTENER_SKELETON_CHANGE.includes(e.id)||this._skeletonChangeMutations.has(e.id)){const a=n.getActiveSheet(),c=a.getSheetId(),d=e.params,{unitId:u,subUnitId:h}=d;if(!(u===n.getUnitId()&&h===a.getSheetId()))return;e.id!==_.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:u,sheetId:c,commandId:e.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:u,sheetId:c,commandId:e.id})}else _.COMMAND_LISTENER_VALUE_CHANGE.includes(e.id)&&this._sheetSkeletonManagerService.reCalculate();e.type===l.CommandType.MUTATION&&((s=(r=this._renderManagerService.getRenderById(i))==null?void 0:r.mainComponent)==null||s.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(y.RENDER_RAW_FORMULA_KEY).pipe(B.distinctUntilChanged(),B.takeUntil(this.dispose$)).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof y.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})})}};exports.SheetRenderController=El([l.OnLifecycle(l.LifecycleStages.Ready,exports.SheetRenderController),Ft(0,P.Inject(exports.SheetSkeletonManagerService)),Ft(1,l.IContextService),Ft(2,l.IUniverInstanceService),Ft(3,y.IRenderManagerService),Ft(4,l.ICommandService)],exports.SheetRenderController);const Zn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=o.get(l.IUniverInstanceService),n=_.getSheetCommandTarget(e);if(!n)return!1;const{worksheet:i,subUnitId:r,unitId:s}=n,{delta:a,reset:c}=t;let d=c?100:Math.round((i.getConfig().zoomRatio+a)*100);d=Math.max(To[0],d),d=Math.min(To[1],d);const u=d/100;return o.get(l.ICommandService).executeCommand(ke.id,{unitId:s,subUnitId:r,zoomRatio:u})}},Kn={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:i}=t;return o.get(l.ICommandService).executeCommand(ke.id,{unitId:e,subUnitId:n,zoomRatio:i})}};var yl=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,xl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ol(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&yl(t,e,i),i},Ui=(o,t)=>(e,n)=>t(e,n,o);let Bn=class extends l.Disposable{constructor(o,t,e){super(),this._context=o,this._sheetSkeletonManagerService=t,this._commandService=e,this._skeletonListener(),this._zoomEventBinding()}updateZoom(o,t){const e=this._context.unit.getSheetBySheetId(o);return e?(e.getConfig().zoomRatio=t,e===this._context.unit.getActiveSheet()&&this._updateViewZoom(t),!0):!1}_zoomEventBinding(){var t;const o=(t=this._getSheetObject())==null?void 0:t.scene;o!=null&&this.disposeWithMe(o.onMouseWheelObserver.add(e=>{if(!e.ctrlKey)return;const n=Math.abs(e.deltaX);let i=n<40?.2:n<80?.4:.2;i*=e.deltaY>0?-1:1,o.scaleX<1&&(i/=2);const r=this._context.unit,s=r.getActiveSheet(),a=s.getZoomRatio();let c=+Number.parseFloat(`${a+i}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(Kn.id,{zoomRatio:Math.round(c*10)/10,unitId:r.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_skeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(o=>{if(o==null)return;const n=this._context.unit.getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)}))}_updateViewZoom(o){const t=this._getSheetObject();t==null||t.scene.scale(o,o),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return it(this._context.unit,this._context)}};Bn=xl([Ui(1,P.Inject(exports.SheetSkeletonManagerService)),Ui(2,l.ICommandService)],Bn);const ke={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(o,t)=>{const n=o.get(y.IRenderManagerService).getRenderById(t.unitId);return n?n.with(Bn).updateZoom(t.subUnitId,t.zoomRatio):!1}};var Nl=Object.defineProperty,Al=Object.getOwnPropertyDescriptor,Dl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Al(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Nl(t,e,i),i},Ke=(o,t)=>(e,n)=>t(e,n,o);exports.AutoFillController=class extends l.Disposable{constructor(e,n,i,r,s,a,c,d){super();R(this,"_beforeApplyData",[]);R(this,"_currentLocation",null);R(this,"_copyData",[]);R(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=i,this._autoFillService=r,this._editorBridgeService=s,this._sheetInterceptorService=a,this._selectionManagerService=c,this._injector=d,this._defaultHook={id:"default",type:vt.Default,priority:0,onBeforeFillData:(u,h)=>{this._presetAndCacheData(u,h)},onFillData:(u,h,m)=>this._fillData(u,h,m)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),this._initQuitListener()}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Te.id,In.id,ke.id,_.SetWorksheetActiveOperation.id,_.SetRangeValuesMutation.id,_.MoveRangeMutation.id,_.RemoveRowMutation.id,_.RemoveColMutation.id,_.InsertRowMutation.id,_.InsertColMutation.id,_.MoveRowsMutation.id,_.MoveColsMutation.id,_.SetWorksheetColWidthMutation.id,_.SetWorksheetRowHeightMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{var s,a;const r=i==null?void 0:i.fromCollab;e.includes(n.id)&&!r&&n.params.trigger!==Un.id&&this._quit(),n.id===_.RemoveSheetMutation.id&&n.params.unitId===((s=this._currentLocation)==null?void 0:s.unitId)&&n.params.subUnitId===((a=this._currentLocation)==null?void 0:a.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(n=>{var i;n.getUnitId()===((i=this._currentLocation)==null?void 0:i.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_onSelectionControlFillChanged(){const e=new l.DisposableCollection,n=i=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return;i.dispose(),this._selectionRenderService.getCurrentControls().forEach(a=>{i.add(l.toDisposable(a.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const d={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow},u={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._triggerAutoFill(d,u)}))),i.add(l.toDisposable(a.fillControl.onDblclickObserver.add(()=>{const c={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow};this._handleDbClickFill(c)}))),i.add(l.toDisposable(a.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===_.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var g;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(In.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(In.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const i={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=l.Direction.UP,i.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=l.Direction.DOWN,i.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=l.Direction.LEFT,i.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=l.Direction.RIGHT,i.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId(),c=s.getActiveSheet().getSheetId();this._autoFillService.direction=r;const d={get:this._injector.get.bind(this._injector)},u=Rt(e,d),h=Rt(i,d);if(!u||!h)return;this._autoFillService.autoFillLocation={source:u,target:h,unitId:a,subUnitId:c},this._autoFillService.getActiveHooks().forEach(f=>{var S;(S=f==null?void 0:f.onBeforeFillData)==null||S.call(f,{source:u,target:h,unitId:a,subUnitId:c},r)}),(g=this._autoFillService.menu.find(f=>f.value===oe.SERIES))!=null&&g.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,g,f,S,p,I;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=e,a=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet();if(!a)return e;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=i;if(r>0&&((g=c.getValue(n,r-1))==null?void 0:g.v)!=null){let M=n;for(;((f=c.getValue(M,r-1))==null?void 0:f.v)!=null&&M<d;)M+=1;h=M-1}else if(s<u&&((S=c.getValue(i,s+1))==null?void 0:S.v)!=null){let M=n;for(;((p=c.getValue(M,s+1))==null?void 0:p.v)!=null&&M<d;)M+=1;h=M-1}for(let M=i+1;M<=h;M++)for(let b=r;b<=s;b++)if(((I=c.getValue(M,b))==null?void 0:I.v)!=null){h=M-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var e,n;this._currentLocation&&this._commandService.executeCommand(Un.id,{unitId:(e=this._currentLocation)==null?void 0:e.unitId,subUnitId:(n=this._currentLocation)==null?void 0:n.subUnitId})}_getApplyData(e,n,i,r,s,a=!0){const c=[],d=Math.floor(i/n),u=i%n,h=this._autoFillService.getRules();if(!a&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(g=>{m[g.type]=[]}),h.forEach(g=>{const{type:f,applyFunctions:S={}}=g,p=e[f];p&&p.forEach(I=>{const M=Fs(I.index,u),b=I.index.length*d+M,T=this._applyFunctions(I,b,r,s,S,e),w=Ws(n,i,I.index);m[f].push({data:T,index:w})})});for(let g=0;g<i;g++)h.forEach(f=>{const{type:S}=f,p=m[S];for(let I=0;I<p.length;I++)g in p[I].index&&c.push(p[I].data[p[I].index[g]])});return c}_applyFunctions(e,n,i,r,s,a){const{data:c}=e,d=i===l.Direction.UP||i===l.Direction.LEFT;if(r===oe.COPY){const u=s==null?void 0:s[oe.COPY];return u?u(e,n,i,a):(d&&c.reverse(),ht(c,n))}if(r===oe.SERIES){const u=s==null?void 0:s[oe.SERIES];return u?u(e,n,i,a):(d&&c.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,i,a):ht(c,n))}if(r===oe.ONLY_FORMAT){const u=s==null?void 0:s[oe.ONLY_FORMAT];return u?u(e,n,i,a):js(c,n)}}_getCopyData(e,n){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),r=this._autoFillService.getRules(),s=[],a=n===l.Direction.DOWN||n===l.Direction.UP;let c,d;return a?(c=e.cols,d=e.rows):(c=e.rows,d=e.cols),c.forEach(u=>{const h=this._getEmptyCopyDataPiece(),m={type:void 0,cellData:void 0};d.forEach(g=>{let f;a?f=i.getValue(g,u):f=i.getValue(u,g);const{type:S,isContinue:p}=r.find(I=>I.match(f))||mr;if(p(m,f)){const I=h[S],M=I[I.length-1];M.data.push(f),M.index.push(g-d[0])}else{const I=h[S];I?I.push({data:[f],index:[g-d[0]]}):h[S]=[{data:[f],index:[g-d[0]]}]}m.type=S,m.cellData=f}),s.push(h)}),s}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,i,r){const s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),a=[];for(let c=e.startRow;c<=e.endRow;c++)for(let d=e.startColumn;d<=e.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:g,endColumn:f}=y.getCellInfoInMergeData(c,d,s);if(u){if(i===l.Direction.DOWN){let S=h+r,p=g+r;for(;p<=n.endRow;)a.push({startRow:S,startColumn:m,endRow:p,endColumn:f}),S+=r,p+=r}else if(i===l.Direction.UP){let S=h-r,p=g-r;for(;S>=n.startRow;)a.push({startRow:S,startColumn:m,endRow:p,endColumn:f}),S-=r,p-=r}else if(i===l.Direction.RIGHT){let S=m+r,p=f+r;for(;p<=n.endColumn;)a.push({startRow:h,startColumn:S,endRow:g,endColumn:p}),S+=r,p+=r}else if(i===l.Direction.LEFT){let S=m-r,p=f-r;for(;S>=n.startColumn;)a.push({startRow:h,startColumn:S,endRow:g,endColumn:p}),S-=r,p-=r}}}return a}_presetAndCacheData(e,n){const{source:i,target:r}=e,s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),a=[];r.rows.forEach(c=>{const d=[];r.cols.forEach(u=>{d.push(l.Tools.deepClone(s.getValue(c,u)))}),a.push(d)}),this._beforeApplyData=a,this._copyData=this._getCopyData(i,n),this._currentLocation=e,this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,i){var $,Q;const r=[],s=[];let a=!0;i===oe.NO_FORMAT&&(a=!1,i=oe.SERIES);const{source:c,target:d,unitId:u,subUnitId:h}=e;if(!c||!d||n==null)return{undos:r,redos:s};const m=mt(c),g=mt(d),{cols:f,rows:S}=d,{cols:p,rows:I}=c,M=this._copyData;let b;n===l.Direction.DOWN||n===l.Direction.UP?b=I.length:b=p.length;const T=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const D=S.length,H=[];f.forEach((F,Y)=>{const X=M[Y],J=this._getApplyData(X,b,D,n,i,a);H.push(J)});for(let F=0;F<H[0].length;F++){const Y=[];for(let X=0;X<H.length;X++)Y.push({s:null,...H[X][F]});T.push(Y)}}else{const D=f.length;S.forEach((H,F)=>{const Y=M[F],X=this._getApplyData(Y,b,D,n,i,a),J=[];for(let ee=0;ee<X.length;ee++)J.push({s:null,...X[ee]});T.push(J)})}let w=[];const E=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getStyles();a?(w=this._getMergeApplyData(m,g,n,b),T.forEach(D=>{D.forEach(H=>{H&&E&&E&&(H.s=E.getStyleByCell(H))})})):T.forEach((D,H)=>{D.forEach((F,Y)=>{F&&E&&(F.s=E.getStyleByCell(this._beforeApplyData[H][Y])||null)})}),i===oe.ONLY_FORMAT&&T.forEach((D,H)=>{D.forEach((F,Y)=>{if(F){const X=this._beforeApplyData[H][Y]||{};F.f=X.f,F.si=X.si,F.t=X.t,F.v=X.v}})});const O={get:this._injector.get.bind(this._injector)},x=[],A=(Q=($=this._univerInstanceService.getUniverSheetInstance(u))==null?void 0:$.getSheetBySheetId(h))==null?void 0:Q.getMergeData();A&&A.forEach(D=>{l.Rectangle.intersects(D,g)&&x.push(D)});const k={unitId:u,subUnitId:h,ranges:x},N=_.RemoveMergeUndoMutationFactory(O,k);s.push({id:_.RemoveWorksheetMergeMutation.id,params:k}),r.push({id:_.AddWorksheetMergeMutation.id,params:N});const L={subUnitId:h,unitId:u,cellValue:Ks([d])},V=_.SetRangeValuesUndoMutationFactory(O,L),j=this._sheetInterceptorService.onCommandExecute({id:_.ClearSelectionContentCommand.id});s.push({id:_.SetRangeValuesMutation.id,params:L},...j.redos),r.push(...j.undos,{id:_.SetRangeValuesMutation.id,params:V});const z=new l.ObjectMatrix;S.forEach((D,H)=>{f.forEach((F,Y)=>{T[H][Y]&&z.setValue(D,F,T[H][Y])})});const q={subUnitId:h,unitId:u,cellValue:z.getMatrix()},K=_.SetRangeValuesUndoMutationFactory(O,q);if(r.push({id:_.SetRangeValuesMutation.id,params:K}),s.push({id:_.SetRangeValuesMutation.id,params:q}),w!=null&&w.length){const D=_.getAddMergeMutationRangeByType(w),H={unitId:u,subUnitId:h,ranges:D},F=_.AddMergeUndoMutationFactory(O,H);r.push({id:_.RemoveWorksheetMergeMutation.id,params:F}),s.push({id:_.AddWorksheetMergeMutation.id,params:H})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ue.OTHER,ue.FORMULA].includes(r))}))}};exports.AutoFillController=Dl([l.OnLifecycle(l.LifecycleStages.Steady,exports.AutoFillController),Ke(0,l.IUniverInstanceService),Ke(1,Ne),Ke(2,l.ICommandService),Ke(3,yt),Ke(4,Ee),Ke(5,P.Inject(_.SheetInterceptorService)),Ke(6,P.Inject(_.SelectionManagerService)),Ke(7,P.Inject(P.Injector))],exports.AutoFillController);var Pl=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Ll=(o,t,e,n)=>{for(var i=n>1?void 0:n?Hl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Pl(t,e,i),i},co=(o,t)=>(e,n)=>t(e,n,o);exports.CellCustomRenderController=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=n,this._renderManagerService=i,this._univerInstanceService=r,this._initEventBinding()}_initEventBinding(){const e=new l.DisposableCollection,n=this._context.unit,i=r=>{if(e.dispose(),!r)return;const{unitId:s,skeleton:a}=r,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const d=c.mainComponent,u=g=>{const{offsetX:f,offsetY:S}=g,p=c.scene,I=n.getActiveSheet(),M=p.getActiveViewportByCoord(y.Vector2.FromArray([f,S]));if(!M)return;const{scaleX:b,scaleY:T}=p.getAncestorScale(),w={x:M.actualScrollX,y:M.actualScrollY},E=a.getCellPositionByOffset(f,S,b,T,w),O=a.mergeData.find($=>{const{startColumn:Q,startRow:D,endColumn:H,endRow:F}=$;return E.row>=D&&E.column>=Q&&E.row<=F&&E.column<=H}),x={actualRow:O?O.startRow:E.row,actualCol:O?O.startColumn:E.column,mergeCell:O,row:E.row,col:E.column};if(!x||!a)return;const A=I.getCell(x.actualRow,x.actualCol);if(!A)return;const k=A.customRender;if(!(k!=null&&k.length))return;const N=x.actualRow,L=x.actualCol,V=k.sort(l.sortRules),j=n.getActiveSheet().getSheetId(),z={data:A,style:a.getsStyles().getStyleByCell(A),primaryWithCoord:a.getCellByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:j,row:N,col:L},q={x:w.x+f/b,y:w.y+S/T},K=V.find($=>{var Q;return(Q=$.isHit)==null?void 0:Q.call($,q,z)});if(K)return[K,z]},h=d.onPointerDownObserver.add(g=>{var S;const f=u(g);if(f){const[p,I]=f;(S=p.onPointerDown)==null||S.call(p,I,g)}}),m=d.onPointerMoveObserver.add(g=>{var S,p,I,M;const f=u(g);if(f){const[b,T]=f;this._enterActiveRender?this._enterActiveRender.render!==b&&((p=(S=this._enterActiveRender.render).onPointerLeave)==null||p.call(S,this._enterActiveRender.cellContext,g),this._enterActiveRender={render:b,cellContext:T},(I=b.onPointerEnter)==null||I.call(b,T,g)):(this._enterActiveRender={render:b,cellContext:T},(M=b.onPointerEnter)==null||M.call(b,T,g))}});h&&e.add(h),m&&e.add(m)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i)),i(this._sheetSkeletonManagerService.getCurrent()),this.disposeWithMe(e)}};exports.CellCustomRenderController=Ll([l.OnLifecycle(l.LifecycleStages.Rendered,exports.CellCustomRenderController),co(1,P.Inject(exports.SheetSkeletonManagerService)),co(2,y.IRenderManagerService),co(3,l.IUniverInstanceService)],exports.CellCustomRenderController);const xr={id:"sheet.command.hide-row-confirm",type:l.CommandType.COMMAND,handler:async o=>{var c;const e=(c=o.get(_.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=o.get(l.ICommandService),i=o.get(l.IUniverInstanceService),r=_.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,a=s.getVisibleRows();if(wr(a,e)){const d=o.get(v.IConfirmService),u=o.get(l.LocaleService);return await d.confirm({id:"sheet.confirm.hide-row",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllRowsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetRowHiddenCommand.id),!0}},Nr={id:"sheet.command.hide-col-confirm",type:l.CommandType.COMMAND,handler:async o=>{var c;const e=(c=o.get(_.SelectionManagerService).getSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const n=o.get(l.ICommandService),i=o.get(l.IUniverInstanceService),r=_.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,a=s.getVisibleCols();if(Er(a,e)){const d=o.get(v.IConfirmService),u=o.get(l.LocaleService);return await d.confirm({id:"sheet.confirm.hide-col",title:{title:u.t("info.problem")},children:{title:u.t("rightClick.hideAllColumnsAlert")},cancelText:u.t("button.cancel"),confirmText:u.t("button.confirm")}),!1}return await n.executeCommand(_.SetColHiddenCommand.id),!0}},ei={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatBoldCommand.id):t.executeCommand(_.SetBoldCommand.id)}},ti={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatItalicCommand.id):t.executeCommand(_.SetItalicCommand.id)}},ni={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatUnderlineCommand.id):t.executeCommand(_.SetUnderlineCommand.id)}},oi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatStrikethroughCommand.id):t.executeCommand(_.SetStrikeThroughCommand.id)}},Ul={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSubscriptCommand.id):!1}},Vl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSuperscriptCommand.id):!1}},Ar={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(_.SetFontSizeCommand.id,t)}},Dr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(_.SetFontFamilyCommand.id,t)}},kn={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatTextColorCommand.id,t):e.executeCommand(_.SetTextColorCommand.id,t)}};function Pr(o,t){return t.some(e=>Bl(o,e))}function Bl(o,t){const{startRow:e,startColumn:n,endColumn:i,endRow:r}=t,s=o.getMatrixWithMergedCells(e,n,r,i);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==n)&&o.cellHasValue(u))return a=!0,!1}),a}function Hr(o,t,e,n){const i=[],r=[],s=e.getSheetId();return n.forEach(a=>{const c=kl(e,a),d={unitId:t,subUnitId:s,cellValue:c.getData()},u=_.SetRangeValuesUndoMutationFactory(o,d);i.push({id:_.SetRangeValuesMutation.id,params:u}),r.push({id:_.SetRangeValuesMutation.id,params:d})}),{undos:i,redos:r}}function kl(o,t){const{startRow:e,startColumn:n,endColumn:i,endRow:r}=t,s=o.getMatrixWithMergedCells(e,n,r,i),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==e||d!==n)&&a.setValue(c,d,null)}),a}function Fl(o,t,e,n){const i=e.getActiveViewportByCoord(y.Vector2.FromArray([o,t]));if(!i)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),a={x:i.actualScrollX,y:i.actualScrollY},c=n.getCellPositionByOffset(o,t,r,s,a),d=n.mergeData.find(h=>{const{startColumn:m,startRow:g,endColumn:f,endRow:S}=h;return c.row>=g&&c.column>=m&&c.row<=S&&c.column<=f});return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function Wl(o,t,e,n){const i=n.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||o>i.startRow&&t>i.startColumn)return e.getViewport(W.VIEW_MAIN);if(o<=i.startRow&&t<=i.startColumn)return e.getViewport(W.VIEW_MAIN_LEFT_TOP);if(o<=i.startRow&&t>i.startColumn)return e.getViewport(W.VIEW_MAIN_TOP);if(o>i.startRow&&t<=i.startColumn)return e.getViewport(W.VIEW_MAIN_LEFT)}function jl(o,t,e,n){const i=Vi(o.left,o.top,t,e,n),r=Vi(o.right,o.bottom,t,e,n);return{left:i.x,top:i.y,right:r.x,bottom:r.y}}function Vi(o,t,e,n,i){const{scaleX:r,scaleY:s}=e.getAncestorScale(),a=e.getViewport(W.VIEW_MAIN);if(!a)return{x:o,y:t};const c=i.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:m}=c,g=n.getNoMergeCellPositionByIndexWithNoHeader(u-m,d-h),f=n.getNoMergeCellPositionByIndexWithNoHeader(u,d),{rowHeaderWidth:S,columnHeaderHeight:p}=n,I=f.startX-g.startX,M=f.startY-g.startY,{top:b,left:T,actualScrollX:w,actualScrollY:E}=a;let O;o>T?O=(o-w)*r:O=(I+S-(T-o))*r;let x;return t>b?x=(t-E)*s:x=(M+p-(b-t))*r,{x:O,y:x}}var $l=Object.defineProperty,zl=Object.getOwnPropertyDescriptor,Yl=(o,t,e,n)=>{for(var i=n>1?void 0:n?zl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&$l(t,e,i),i},uo=(o,t)=>(e,n)=>t(e,n,o),xe=(o=>(o[o.OFF=0]="OFF",o[o.ONCE=1]="ONCE",o[o.INFINITE=2]="INFINITE",o))(xe||{});const ft=P.createIdentifier("univer.format-painter-service");let xo=class extends l.Disposable{constructor(t,e,n){super();R(this,"status$");R(this,"_selectionFormat");R(this,"_markId",null);R(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new B.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[_.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=e,a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;this._selectionFormat.merges=[];for(let g=n;g<=i;g++)for(let f=r;f<=s;f++){const S=d.getValue(g,f);m.setValue(g,f,h.getStyleByCell(S)||{});const{isMergedMainCell:p,...I}=y.getCellInfoInMergeData(g,f,u);p&&this._selectionFormat.merges.push({startRow:I.startRow,startColumn:I.startColumn,endRow:I.endRow,endColumn:I.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};xo=Yl([uo(0,P.Inject(_.SelectionManagerService)),uo(1,l.IUniverInstanceService),uo(2,tn)],xo);const ii={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(o,t)=>t?(o.get(ft).setStatus(t.status),!0):!1},Lr={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async o=>{const e=o.get(ft).getStatus();let n;return e!==xe.OFF?n=xe.OFF:n=xe.INFINITE,o.get(l.ICommandService).executeCommand(ii.id,{status:n})}},ri={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async o=>{const e=o.get(ft).getStatus();let n;return e!==xe.OFF?n=xe.OFF:n=xe.ONCE,o.get(l.ICommandService).executeCommand(ii.id,{status:n})}},Ur={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(o,t)=>{const e=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(_.SelectionManagerService),s=o.get(_.SheetInterceptorService),a=_.getSheetCommandTarget(i,t);if(!a)return!1;const{worksheet:c,unitId:d,subUnitId:u}=a,h=o.get(_.SheetPermissionService),{styleValues:m,styleRange:g,mergeRanges:f}=t;if(!h.getSheetEditable(d,u))return!1;const S=g?[g]:r.getSelectionRanges();if(!S||!S.length)return!1;const p=new l.ObjectMatrix;let I;if(l.Tools.isArray(m))for(let q=0;q<S.length;q++){const{startRow:K,startColumn:$,endRow:Q,endColumn:D}=S[q];for(let H=0;H<=Q-K;H++)for(let F=0;F<=D-$;F++)p.setValue(H+K,F+$,m[H][F])}else if(l.isICellData(m))for(let q=0;q<S.length;q++){const{startRow:K,startColumn:$}=S[q];p.setValue(K,$,m)}else I=m;const M={subUnitId:u,unitId:d,cellValue:I!=null?I:p.getMatrix()},b=_.SetRangeValuesUndoMutationFactory(o,M),T=e.syncExecuteCommand(_.SetRangeValuesMutation.id,M),{undos:w,redos:E}=s.onCommandExecute({id:_.SetRangeValuesCommand.id,params:{...M,range:S}}),O=_.getAddMergeMutationRangeByType(f),x=[],A=[],k=Pr(c,O),N={unitId:d,subUnitId:u,ranges:O},L={unitId:d,subUnitId:u,ranges:O};x.push({id:_.RemoveWorksheetMergeMutation.id,params:N}),x.push({id:_.AddWorksheetMergeMutation.id,params:L});const V=_.RemoveMergeUndoMutationFactory(o,N),j=_.AddMergeUndoMutationFactory(o,L);if(A.push({id:_.RemoveWorksheetMergeMutation.id,params:j}),A.push({id:_.AddWorksheetMergeMutation.id,params:V}),k){const q=Hr(o,d,c,O);x.unshift(...q.redos),A.push(...q.undos)}const z=await l.sequenceExecute([...E,...x],e);return T&&z.result?(n.pushUndoRedo({unitID:d,undoMutations:[{id:_.SetRangeValuesMutation.id,params:b},...w,...A],redoMutations:[{id:_.SetRangeValuesMutation.id,params:M},...E,...x]}),!0):!1}},qn={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(o,t)=>{const{type:e}=t||{},n=o.get(l.IUniverInstanceService),i=o.get(l.IUndoRedoService),r=_.getSheetCommandTarget(n);if(!r)return!1;const{unitId:s,subUnitId:a}=r,c=o.get(l.ICommandService),u=o.get(_.SelectionManagerService).getSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:m}=h,g=o.get(ot),{sheetViewStartRow:f=0,sheetViewStartColumn:S=0}=g.getCurrentScroll()||{};let p,I,M,b;const{startRow:T,startColumn:w,rangeType:E}=m;if(E===l.RANGE_TYPE.ROW||e===1)p=T,M=T-f,I=-1,b=0;else if(E===l.RANGE_TYPE.COLUMN||e===2)p=-1,M=0,I=w,b=w-S;else if(E===l.RANGE_TYPE.NORMAL)p=T,M=T-f,I=w,b=w-S;else return!1;const O={unitId:s,subUnitId:a,startRow:p,startColumn:I,xSplit:I>0?Math.max(1,b):b,ySplit:p>0?Math.max(1,M):M},x=_.SetFrozenMutationFactory(o,O);return c.syncExecuteCommand(_.SetFrozenMutation.id,O)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:_.SetFrozenMutation.id,params:x}],redoMutations:[{id:_.SetFrozenMutation.id,params:O}]}),!0}},Vr={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(qn.id,{type:1}),!0)},Br={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(qn.id,{type:2}),!0)},kr={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async o=>{const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(l.IUndoRedoService),i=_.getSheetCommandTarget(e);if(!i)return!1;const{unitId:r,subUnitId:s}=i,a={unitId:r,subUnitId:s,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},c=_.SetFrozenMutationFactory(o,a);return t.syncExecuteCommand(_.SetFrozenMutation.id,a)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:_.SetFrozenMutation.id,params:c}],redoMutations:[{id:_.SetFrozenMutation.id,params:a}]}),!0}},Nt="UI_PLUGIN_SHEETS",Qn=`${Nt}_COLOR_PICKER_COMPONENT`,Fr=`${Nt}_FONT_FAMILY_COMPONENT`,Wr=`${Nt}_FONT_FAMILY_ITEM_COMPONENT`,jr=`${Nt}_FONT_SIZE_COMPONENT`,si=`${Nt}_MENU_ITEM_INPUT_COMPONENT`;var $r={exports:{}},Jn={};/**
1
+ "use strict";var Ps=Object.defineProperty;var Hs=(o,t,e)=>t in o?Ps(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var R=(o,t,e)=>(Hs(o,typeof t!="symbol"?t+"":t,e),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("@univerjs/docs"),l=require("@univerjs/core"),S=require("@univerjs/sheets"),D=require("@wendellhu/redi"),U=require("rxjs"),I=require("@univerjs/ui"),Go=require("@univerjs/docs-ui"),E=require("@univerjs/engine-render"),G=require("@wendellhu/redi/react-bindings"),Ls=require("rxjs/operators"),re=require("@univerjs/design"),Rn=require("@univerjs/engine-numfmt"),Z=require("@univerjs/engine-formula"),V=require("react"),Oe=require("clsx"),Us="SheetUI";function Gn(o,t){if(o==null)return;const e=t.getRenderById(o);if(e==null)return;const{mainComponent:n,scene:i,engine:r,components:s}=e,a=n,c=s.get(te.DOCS_VIEW_KEY.BACKGROUND);return{document:a,docBackground:c,scene:i,engine:r}}const wo={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Un=["零","一","二","三","四","五","六","七","八","九"],Ri=["","万","亿","万亿","亿亿"],Vs=["","十","百","千"],gr={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Ge(o){if(!o)return 0;let t=0,e=0,n=0,i=!1;const r=o.split("");for(let s=0;s<r.length;s++){const a=wo[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(e+=n);else{const c=gr[r[s]],u=c.value;i=c.secUnit,i?(e=(e+n)*u,t+=e,e=0):e+=n*u,n=0}}return t+e}function Bs(o){let t="",e="",n=0,i=!0;for(;o>0;){const r=o%10;r===0?i||(i=!0,e=Un[r]+e):(i=!1,t=Un[r],t+=Vs[n],e=t+e),n++,o=Math.floor(o/10)}return e}function Fs(o){let t=0,e="",n="",i=!1;if(o===0)return Un[0];for(;o>0;){const r=o%1e4;i&&(n=Un[0]+n),e=Bs(r),e+=r!==0?Ri[t]:Ri[0],n=e+n,i=r<1e3&&r>0,o=Math.floor(o/1e4),t++}return n}function ks(o){if(!o)return!1;let t=!0;if(o)if(o.length===1)o==="日"||o in wo?t=!0:t=!1;else{const e=o.split("");for(let n=0;n<e.length;n++)if(!(e[n]in wo||e[n]in gr)){t=!1;break}}return t}function cn(o){if(!o)return{isExtendNumber:!1};const t=/0|([1-9]+[0-9]*)/g,e=t.test(o);if(e){const n=o.match(t);if(n&&n.length>0){const i=n[n.length-1],r=o.lastIndexOf(i),s=o.substr(0,r),a=o.substr(r+i.length);return{isExtendNumber:!0,matchTxt:Number(i),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:e}}function Ws(o){let t;return o.length===2&&(o==="周一"||o==="周二"||o==="周三"||o==="周四"||o==="周五"||o==="周六"||o==="周日")?t=!0:t=!1,t}function js(o){let t;return o.length===3&&(o==="星期一"||o==="星期二"||o==="星期三"||o==="星期四"||o==="星期五"||o==="星期六"||o==="星期日")?t=!0:t=!1,t}function $s(o,t){let e=0;for(let n=0;n<o.length&&o[n]<t;n++)e++;return e}function en(o){let t=!0;const e=o[1]-o[0];for(let n=1;n<o.length;n++)if(o[n]-o[n-1]!==e){t=!1;break}return t}function zs(o,t,e){const n=[],i=Math.floor(t/o),r=t%o;let s=0;if(i>0){for(let a=0;a<i;a++)for(let c=0;c<e.length;c++)n[e[c]+a*o]=s,s++;for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]+o*i]=s,s++}else for(let a=0;a<e.length&&e[a]<r;a++)n[e[a]]=s,s++;return n}function ht(o,t){const e=[];for(let n=1;n<=t;n++){const i=(n-1)%o.length,r=l.Tools.deepClone(o[i]);e.push({v:null,s:null,p:null,f:null,si:null,t:null,...r})}return e}function Ys(o,t){var n;const e=[];for(let i=1;i<=t;i++){const r=(i-1)%o.length,s={s:(n=o[r])==null?void 0:n.s};e.push(s)}return e}function Xs(o){let t=!0;const e=o[1]/o[0];for(let n=1;n<o.length;n++)if(o[n]/o[n-1]!==e){t=!1;break}return t}function Gs(o){const t=[];for(let e=1;e<=o;e++)t.push(e);return t}function Mi(o,t,e){var r,s,a,c;const n=[],i=[];for(let u=0;u<o.length;u++)i.push(Number((r=o[u])==null?void 0:r.v));if(o.length>2&&Xs(i))for(let u=1;u<=t;u++){const d=(u-1)%o.length,h=l.Tools.deepClone(o[d]),m=Number((s=o[o.length-1])==null?void 0:s.v)*(Number((a=o[1])==null?void 0:a.v)/Number((c=o[0])==null?void 0:c.v))**u;h&&(h.t!==l.CellValueType.BOOLEAN&&(h.v=m),n.push(h))}else{const u=Gs(o.length);for(let d=1;d<=t;d++){const h=(d-1)%o.length,m=l.Tools.deepClone(o[h]),g=e===l.Direction.DOWN||e===l.Direction.RIGHT,f=Zs(o.length+d,i,u,g);m&&(m.t!==l.CellValueType.BOOLEAN&&(m.v=f),n.push(m))}}return n}function Zs(o,t,e,n=!0){function i(h){let m=0;for(let g=0;g<h.length;g++)m+=h[g];return m/h.length}const r=i(e),s=i(t);let a=0,c=0;for(let h=0;h<e.length;h++)a+=(e[h]-r)*(t[h]-s),c+=(e[h]-r)*(e[h]-r);let u;c===0?u=n?1:-1:u=a/c;const d=s-u*r;return Math.round((d+u*o)*1e5)/1e5}function bi(o,t,e){var r;const n=[],i=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=t;s++){const a=(s-1)%o.length,c=l.Tools.deepClone(o[a]),u=`${(r=o[o.length-1])==null?void 0:r.v}`,d=u==null?void 0:u.match(i),h=d==null?void 0:d[d.length-1],m=Math.abs(Number(h)+e*s);if(!u||!h)continue;const g=u.lastIndexOf(h),f=u.substr(0,g)+m.toString()+u.substr(g+h.length);c&&(c.v=f,n.push(c))}return n}function Tt(o,t,e,n=0){var a,c;const i=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=i.length)return[];const r=i[n],s=[];for(let u=1;u<=t;u++){const d=(u-1)%o.length,h=l.Tools.deepClone(o[d]);let m=0;if(((a=o[o.length-1])==null?void 0:a.v)===r[0])m=7+e*u;else{const f=`${(c=o[o.length-1])==null?void 0:c.v}`;if(f){const _=f.substr(f.length-1,1);m=Ge(_)+e*u}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const g=m%7;h&&(h.v=r[g],s.push(h))}return s}function Ti(o,t,e){var i;const n=[];for(let r=1;r<=t;r++){const s=(r-1)%o.length,a=l.Tools.deepClone(o[s]),c=`${(i=o[o.length-1])==null?void 0:i.v}`,u=Ge(c)+e*r;let d;u<=0?d="零":d=Fs(u),a&&(a.v=d,n.push(a))}return n}const Yt={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function Ks(o){let t=!1;return Object.keys(Yt).forEach(e=>{Yt[e].includes(o)&&(t=!0)}),t}function ao(o){let t="";const e=[];return Object.keys(Yt).forEach(n=>{Yt[n].includes(o)&&(t=n,e.push(...Yt[n]))}),{name:t,series:e}}function wi(o,t,e,n){var s;const i=n.length,r=[];for(let a=1;a<=t;a++){const c=(a-1)%o.length,u=l.Tools.deepClone(o[c]),d=`${(s=o[o.length-1])==null?void 0:s.v}`;let h=n.indexOf(d)+e*a;h<0&&(h+=Math.abs(e)*i);const m=h%i;u&&(u.v=n[m],r.push(u))}return r}function qs(o,t){const e=[];let n;if(t.startRow<o.startRow)n=l.Direction.UP;else if(t.endRow>o.endRow)n=l.Direction.DOWN;else if(t.startColumn<o.startColumn)n=l.Direction.LEFT;else if(t.endColumn>o.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const i=o.endRow-o.startRow+1,r=t.endRow-t.startRow+1,s=Math.floor(r/i),a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.DOWN){for(let u=0;u<s;u++)e.push({repeatStartCell:{row:o.startRow+(u+1)*i,col:o.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow+(s+1)*i,col:o.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:o.endColumn-o.startColumn}})}else{for(let u=0;u<s;u++)e.push({repeatStartCell:{row:o.startRow-(u+1)*i,col:o.startColumn},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow-(s+1)*i,col:o.startColumn},relativeRange:{startRow:i-a,endRow:i-1,startColumn:0,endColumn:o.endColumn-o.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const i=o.endColumn-o.startColumn+1,r=t.endColumn-t.startColumn+1,s=Math.floor(r/i),a=r%i,c={startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:o.endColumn-o.startColumn};if(n===l.Direction.RIGHT){for(let u=0;u<s;u++)e.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(u+1)*i},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow,col:o.startColumn+(s+1)*i},relativeRange:{startRow:0,startColumn:0,endRow:o.endRow-o.startRow,endColumn:a-1}})}else{for(let u=0;u<s;u++)e.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(u+1)*i},relativeRange:c});a>0&&e.push({repeatStartCell:{row:o.startRow,col:o.startColumn-(s+1)*i},relativeRange:{startRow:0,startColumn:i-a,endRow:o.endRow-o.startRow,endColumn:i-1}})}}return e}function Qs(o){const t=new l.ObjectMatrix;return o.forEach(e=>{const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e;for(let a=n;a<=r;a++)for(let c=i;c<=s;c++)t.setValue(a,c,{v:null,p:null,f:null,si:null})}),t.getData()}function Rt(o,t,e,n){const i=t.get(l.IUniverInstanceService),r=e?i.getUnit(e,l.UniverInstanceType.UNIVER_SHEET):i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=n?r==null?void 0:r.getSheetBySheetId(n):r==null?void 0:r.getActiveSheet();if(!s)return null;const{startRow:a,endRow:c,startColumn:u,endColumn:d}=o,h=[],m=[];for(let g=a;g<=c;g++)s.getRowFiltered(g)||h.push(g);for(let g=u;g<=d;g++)m.push(g);return{rows:h,cols:m}}function mt(o){const{rows:t,cols:e}=o;return{startRow:t[0],endRow:t[t.length-1],startColumn:e[0],endColumn:e[e.length-1]}}function tn(o){let t=[],e=[];const n=[];return o.forEach(i=>{t.push(...i.rows),e.push(...i.cols)}),t=Array.from(new Set(t)).sort((i,r)=>i-r),e=Array.from(new Set(e)).sort((i,r)=>i-r),o.forEach(i=>{n.push({startRow:t.findIndex(r=>r===i.rows[0]),endRow:t.findIndex(r=>r===i.rows[i.rows.length-1]),startColumn:e.findIndex(r=>r===i.cols[0]),endColumn:e.findIndex(r=>r===i.cols[i.cols.length-1])})}),{ranges:n,mapFunc:(i,r)=>({row:t[i],col:e[r]})}}function Js(o){const t=new l.ObjectMatrix;return o.forEach(e=>{const{rows:n,cols:i}=e;n.forEach(r=>{i.forEach(s=>{t.setValue(r,s,{v:null,p:null,f:null,si:null})})})}),t.getData()}var vt=(o=>(o.Append="APPEND",o.Default="DEFAULT",o.Only="ONLY",o))(vt||{}),ue=(o=>(o.NUMBER="number",o.DATE="date",o.EXTEND_NUMBER="extendNumber",o.CHN_NUMBER="chnNumber",o.CHN_WEEK2="chnWeek2",o.CHN_WEEK3="chnWeek3",o.LOOP_SERIES="loopSeries",o.FORMULA="formula",o.OTHER="other",o))(ue||{}),oe=(o=>(o.COPY="0",o.SERIES="1",o.ONLY_FORMAT="2",o.NO_FORMAT="3",o))(oe||{});const ea={type:ue.NUMBER,priority:1e3,match:o=>typeof(o==null?void 0:o.v)=="number"||(o==null?void 0:o.t)===l.CellValueType.NUMBER,isContinue:(o,t)=>o.type===ue.NUMBER,applyFunctions:{[oe.SERIES]:(o,t,e)=>{const{data:n}=o;return e===l.Direction.LEFT||e===l.Direction.UP?(n.reverse(),Mi(n,t,e).reverse()):Mi(n,t,e)}}},fr={type:ue.OTHER,priority:0,match:()=>!0,isContinue:(o,t)=>o.type===ue.OTHER},ta={type:ue.EXTEND_NUMBER,priority:900,match:o=>cn(`${o==null?void 0:o.v}`||"").isExtendNumber,isContinue:(o,t)=>{var e;if(o.type===ue.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:i}=cn(`${(e=o.cellData)==null?void 0:e.v}`||""),{beforeTxt:r,afterTxt:s}=cn(`${t==null?void 0:t.v}`||"");if(n===r&&i===s)return!0}return!1},applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.UP||e===l.Direction.LEFT;let r;if(n.length===1)return r=i?-1:1,be(bi(n,t,r),i);const s=[];for(let c=0;c<n.length;c++){const u=`${(a=n[c])==null?void 0:a.v}`;u&&s.push(Number(cn(u).matchTxt))}return i&&(n.reverse(),s.reverse()),en(s)?(r=s[1]-s[0],be(bi(n,t,r),i)):ht(n,t)}}},na={type:ue.CHN_NUMBER,priority:830,match:o=>!!ks(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_NUMBER,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var c,u,d;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return i?m=-1:m=1,h&&(h==="日"||Ge(h)<7)?be(Tt(n,t,m),i):be(Ti(n,t,m),i)}let r=!1;for(let h=0;h<n.length;h++)if(((u=n[h])==null?void 0:u.v)==="日"){r=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(d=n[h])==null?void 0:d.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):r&&Ge(m)>0&&Ge(m)<7?s.push(Ge(m)+a*7):s.push(Ge(m))}if(i&&(n.reverse(),s.reverse()),en(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return be(Tt(n,t,m),i)}const h=s[1]-s[0];return be(Ti(n,t,h),i)}return ht(n,t)}}},oa={type:ue.CHN_WEEK2,priority:820,match:o=>!!Ws(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_WEEK2,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,be(Tt(n,t,c,1),i)}const r=[];let s=0;for(let c=0;c<n.length;c++){const u=`${(a=n[c])==null?void 0:a.v}`,d=u==null?void 0:u.substr(u.length-1,1);u==="周日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Ge(d)+s*7)}if(i&&(n.reverse(),r.reverse()),en(r)){const c=r[1]-r[0];return be(Tt(n,t,c,1),i)}return ht(n,t)}}},ia={type:ue.CHN_WEEK3,priority:810,match:o=>js(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>o.type===ue.CHN_WEEK3,applyFunctions:{[oe.SERIES]:(o,t,e)=>{var a;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP;if(n.length===1){let c;return i?c=-1:c=1,be(Tt(n,t,c,2),i)}const r=[];let s=0;for(let c=0;c<n.length;c++){const u=`${(a=n[c])==null?void 0:a.v}`;if(u){const d=u.substr(u.length-1,1);u==="星期日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Ge(d)+s*7)}}if(i&&(n.reverse(),r.reverse()),en(r)){const c=r[1]-r[0];return be(Tt(n,t,c,2),i)}return ht(n,t)}}},ra={type:ue.LOOP_SERIES,priority:800,match:o=>Ks(`${o==null?void 0:o.v}`||""),isContinue:(o,t)=>{var e;return o.type===ue.LOOP_SERIES?ao(`${(e=o.cellData)==null?void 0:e.v}`||"").name===ao(`${t==null?void 0:t.v}`||"").name:!1},applyFunctions:{[oe.SERIES]:(o,t,e)=>{var c,u;const{data:n}=o,i=e===l.Direction.LEFT||e===l.Direction.UP,{series:r}=ao(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let d;return i?d=-1:d=1,be(wi(n,t,d,r),i)}const s=[];let a=0;for(let d=0;d<n.length;d++){const h=`${(u=n[d])==null?void 0:u.v}`;h&&(h===r[0]?d===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(h)+a*7))}if(i&&(n.reverse(),s.reverse()),en(s)){const d=s[1]-s[0];return be(wi(n,t,d,r),i)}return ht(n,t)}}};function be(o,t){return t?o.reverse():o}var sa=Object.defineProperty,aa=Object.getOwnPropertyDescriptor,la=(o,t,e,n)=>{for(var i=n>1?void 0:n?aa(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&sa(t,e,i),i},dn=(o,t)=>(e,n)=>t(e,n,o);exports.AutoFillService=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_rules",[]);R(this,"_hooks",[]);R(this,"_applyType$",new U.BehaviorSubject(oe.SERIES));R(this,"_isFillingStyle",!0);R(this,"_autoFillLocation$",new U.BehaviorSubject(null));R(this,"autoFillLocation$",this._autoFillLocation$.asObservable());R(this,"_showMenu$",new U.BehaviorSubject(!1));R(this,"showMenu$",this._showMenu$.asObservable());R(this,"_direction",l.Direction.DOWN);R(this,"applyType$",this._applyType$.asObservable());R(this,"_menu$",new U.BehaviorSubject([{label:"autoFill.copy",value:oe.COPY,disable:!1},{label:"autoFill.series",value:oe.SERIES,disable:!1},{label:"autoFill.formatOnly",value:oe.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:oe.NO_FORMAT,disable:!1}]));R(this,"menu$",this._menu$.asObservable());this._univerInstanceService=e,this._selectionManagerService=n,this._commandService=i,this._undoRedoService=r,this._init()}_init(){this._rules=[ea,ta,na,oa,ia,ra,fr].sort((e,n)=>n.priority-e.priority),this._isFillingStyle=!0}getOneByPriority(e){return e.length<=0?[]:[e.reduce((i,r)=>(r.priority||0)>(i.priority||0)?r:i,e[0])]}addHook(e){if(this._hooks.find(n=>n.id===e.id))throw new Error(`Add hook failed, hook id '${e.id}' already exist!`);return e.priority===void 0&&(e.priority=0),e.type===void 0&&(e.type=vt.Append),this._hooks.push(e),l.toDisposable(()=>{const n=this._hooks.findIndex(i=>i===e);n>-1&&this._hooks.splice(n,1)})}registerRule(e){if(this._rules.find(i=>i.type===e.type))throw new Error(`Registry rule failed, type '${e.type}' already exist!`);const n=this._rules.findIndex(i=>i.priority<e.priority);this._rules.splice(n===-1?this._rules.length:n,0,e)}getRules(){return this._rules}getAllHooks(){return this._hooks}getActiveHooks(){const{source:e,target:n,unitId:i,subUnitId:r}=this.autoFillLocation||{};if(!e||!n||!i||!r)return[];const s=this._hooks.filter(d=>{var h;return!((h=d.disable)!=null&&h.call(d,{source:e,target:n,unitId:i,subUnitId:r},this._direction,this.applyType))}),a=s.filter(d=>d.type===vt.Only);if(a.length>0)return this.getOneByPriority(a);const c=this.getOneByPriority(s.filter(d=>d.type===vt.Default)),u=s.filter(d=>d.type===vt.Append)||[];return[...c,...u]}get applyType(){return this._applyType$.getValue()}set applyType(e){this._applyType$.next(e)}get menu(){return this._menu$.getValue()}get direction(){return this._direction}set direction(e){this._direction=e}isFillingStyle(){return this._isFillingStyle}setFillingStyle(e){this._isFillingStyle=e}get autoFillLocation(){return this._autoFillLocation$.getValue()}set autoFillLocation(e){this._autoFillLocation$.next(e)}setDisableApplyType(e,n){this._menu$.next(this._menu$.getValue().map(i=>i.value===e?{...i,disable:n}:i))}setShowMenu(e){this._showMenu$.next(e)}fillData(e,n){var _,p;const{source:i,target:r,unitId:s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),subUnitId:a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId()}=this.autoFillLocation||{},c=this.direction;if(!i||!r||s!==e||a!==n)return!1;const u=l.Rectangle.union(mt(i),mt(r)),d=this.applyType,h=this.getActiveHooks();this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,{selections:[{primary:{...(p=(_=this._selectionManagerService.getLast())==null?void 0:_.primary)!=null?p:u},range:{...u,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:s,subUnitId:a});const m=[],g=[];return h.forEach(v=>{var T;const{undos:M,redos:b}=((T=v.onFillData)==null?void 0:T.call(v,{source:i,target:r,unitId:s,subUnitId:a},c,d))||{};M&&m.push(...M),b&&g.push(...b)}),g.every(v=>this._commandService.syncExecuteCommand(v.id,v.params))&&this._undoRedoService.pushUndoRedo({unitID:s,undoMutations:m,redoMutations:g}),h.forEach(v=>{var M;(M=v.onAfterFillData)==null||M.call(v,{source:i,target:r,unitId:s,subUnitId:a},c,d)}),this.setShowMenu(!0),!0}};exports.AutoFillService=la([l.OnLifecycle(l.LifecycleStages.Rendered,exports.AutoFillService),dn(0,D.Inject(l.IUniverInstanceService)),dn(1,D.Inject(S.SelectionManagerService)),dn(2,l.ICommandService),dn(3,l.IUndoRedoService)],exports.AutoFillService);const yt=D.createIdentifier("univer.auto-fill-service"),Vn={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(o,t)=>o.get(yt).fillData(t.unitId,t.subUnitId)},Mn={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(l.IUniverInstanceService),n=o.get(l.ICommandService),i=o.get(l.IUndoRedoService),r=S.getSheetCommandTarget(e);if(!r)return!1;const{unitId:s,subUnitId:a}=r,{clearRange:c,selectionRange:u}=t,d={subUnitId:a,unitId:s,cellValue:Qs([c])},h=S.SetRangeValuesUndoMutationFactory(o,d),{startColumn:m,startRow:g}=u;return n.executeCommand(S.SetSelectionsOperation.id,{selections:[{primary:{startColumn:m,startRow:g,endColumn:m,endRow:g,actualRow:g,actualColumn:m,isMerge:!1,isMergedMainCell:!1},range:{...u}}],unitId:s,subUnitId:a}),n.syncExecuteCommand(S.SetRangeValuesMutation.id,d)?(i.pushUndoRedo({unitID:s,undoMutations:[{id:S.SetRangeValuesMutation.id,params:h}],redoMutations:[{id:S.SetRangeValuesMutation.id,params:d}]}),!0):!1}};function Zo(o){return o.getContextValue(l.FOCUSING_SHEET)}function ne(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(l.EDITOR_ACTIVATED)}function _r(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&!o.getContextValue(l.EDITOR_ACTIVATED)&&!o.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function ca(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)}function da(o){return o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)}function Sr(o){return o.getContextValue(l.FOCUSING_FORMULA_EDITOR)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function ua(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.EDITOR_ACTIVATED)&&o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)}function Zt(o){return o.getContextValue(l.FOCUSING_SHEET)&&o.getContextValue(l.FOCUSING_UNIVER_EDITOR)&&o.getContextValue(l.EDITOR_ACTIVATED)&&!o.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)&&!o.getContextValue(l.FOCUSING_EDITOR_STANDALONE)}var ie=(o=>(o.MAIN="__SpreadsheetRender__",o.ROW="__SpreadsheetRowHeader__",o.COLUMN="__SpreadsheetColumnHeader__",o.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",o))(ie||{}),W=(o=>(o.VIEW_MAIN="viewMain",o.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",o.VIEW_MAIN_TOP="viewMainTop",o.VIEW_MAIN_LEFT="viewMainLeft",o.VIEW_ROW_TOP="viewRowTop",o.VIEW_ROW_BOTTOM="viewRowBottom",o.VIEW_COLUMN_LEFT="viewColumnLeft",o.VIEW_COLUMN_RIGHT="viewColumnRight",o.VIEW_LEFT_TOP="viewLeftTop",o))(W||{});const Ei=0,nt=2,ha=3,Eo=[10,400],yi=1001;var ma=Object.defineProperty,ga=Object.getOwnPropertyDescriptor,fa=(o,t,e,n)=>{for(var i=n>1?void 0:n?ga(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&ma(t,e,i),i},Oi=(o,t)=>(e,n)=>t(e,n,o);exports.SheetSkeletonManagerService=class{constructor(t,e){R(this,"_currentSkeleton",{unitId:"",sheetId:""});R(this,"_sheetSkeletonParam",[]);R(this,"_currentSkeleton$",new U.BehaviorSubject(null));R(this,"currentSkeleton$",this._currentSkeleton$.asObservable());R(this,"_currentSkeletonBefore$",new U.BehaviorSubject(null));R(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._univerInstanceService=t,this._injector=e}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getSkeleton(this._currentSkeleton)}getUnitSkeleton(t,e){return this._getSkeleton({unitId:t,sheetId:e})}setCurrent(t){this._setCurrent(t)}removeSkeleton(t){const e=this._sheetSkeletonParam.findIndex(n=>n.unitId===t.unitId);e!==-1&&(this._sheetSkeletonParam[e].skeleton.dispose(),this._sheetSkeletonParam.splice(e,1),this._currentSkeletonBefore$.next(null),this._currentSkeleton$.next(null))}_compareSearch(t,e){return t==null||e==null?!1:t.commandId===e.commandId&&t.sheetId===e.sheetId&&t.unitId===e.unitId}_setCurrent(t){const e=this._getSkeleton(t);if(e!=null)this._reCalculate(e);else{const{unitId:i,sheetId:r}=t,s=this._univerInstanceService.getUniverSheetInstance(t.unitId),a=s==null?void 0:s.getSheetBySheetId(t.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:i,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=t;const n=this.getCurrent();this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n)}reCalculate(){const t=this.getCurrent();t!=null&&this._reCalculate(t)}_reCalculate(t){t.dirty&&(t.skeleton.makeDirty(!0),t.dirty=!1),t.skeleton.calculate()}makeDirtyCurrent(t=!0){this.makeDirty(this._currentSkeleton,t)}makeDirty(t,e=!0){const n=this._getSkeleton(t);n!=null&&(n.dirty=e)}getOrCreateSkeleton(t){const e=this._getSkeleton(t);if(e)return e.skeleton;const n=this._univerInstanceService.getUniverSheetInstance(t.unitId),i=n==null?void 0:n.getSheetBySheetId(t.sheetId);if(!i||!n)return;const r=this._buildSkeleton(i,n);return this._sheetSkeletonParam.push({unitId:t.unitId,sheetId:t.sheetId,skeleton:r,dirty:!1}),r}_getSkeleton(t){const e=this._sheetSkeletonParam.find(n=>n.unitId===t.unitId&&n.sheetId===t.sheetId);return e!=null&&(e.commandId=t.commandId),e}_buildSkeleton(t,e){const n=t.getConfig();return this._injector.createInstance(E.SpreadsheetSkeleton,t,n,t.getCellMatrix(),e.getStyles())}};exports.SheetSkeletonManagerService=fa([Oi(0,l.IUniverInstanceService),Oi(1,D.Inject(D.Injector))],exports.SheetSkeletonManagerService);class _a{constructor(){R(this,"_startColumn",-1);R(this,"_startRow",-1);R(this,"_endColumn",-1);R(this,"_endRow",-1);R(this,"_startX",0);R(this,"_startY",0);R(this,"_endX",0);R(this,"_endY",0);R(this,"_currentCell");R(this,"_rangeType",l.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(t){const{startColumn:e,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:u}=t;return e===s&&n===a&&i===c&&r===u}isInclude(t){const{startColumn:e,startRow:n,endColumn:i,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:u}=t;return!(c<e||s>i||a>r||u<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(t,e){const{startColumn:n,startRow:i,endColumn:r,endRow:s,startX:a,startY:c,endX:u,endY:d,rangeType:h}=t;this._startColumn=n,this._startRow=i,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=u,this._endY=d,h!=null&&(this._rangeType=h),this.setCurrentCell(e)}setCurrentCell(t){t&&(this._currentCell=t)}clearCurrentCell(){this._currentCell=null}}const xi=.3;class Bn extends l.Disposable{constructor(e,n,i=!0,r){super();R(this,"_leftControl");R(this,"_rightControl");R(this,"_topControl");R(this,"_bottomControl");R(this,"_backgroundControlTop");R(this,"_backgroundControlBottom");R(this,"_backgroundControlMiddleLeft");R(this,"_backgroundControlMiddleRight");R(this,"_fillControl");R(this,"_selectionShape");R(this,"_rowHeaderBackground");R(this,"_rowHeaderBorder");R(this,"_rowHeaderGroup");R(this,"_rowHeaderHighlight");R(this,"_columnHeaderBackground");R(this,"_columnHeaderBorder");R(this,"_columnHeaderGroup");R(this,"_columnHeaderHighlight");R(this,"_topLeftWidget");R(this,"_topCenterWidget");R(this,"_topRightWidget");R(this,"_middleLeftWidget");R(this,"_middleRightWidget");R(this,"_bottomLeftWidget");R(this,"_bottomCenterWidget");R(this,"_bottomRightWidget");R(this,"_dashRect");R(this,"_selectionModel");R(this,"_selectionStyle");R(this,"_rowHeaderWidth",0);R(this,"_columnHeaderHeight",0);R(this,"_widgetRects",[]);R(this,"_dispose$",new U.BehaviorSubject(this));R(this,"dispose$",this._dispose$.asObservable());R(this,"selectionMoving$",new U.Subject);R(this,"selectionMoved$",new U.Subject);R(this,"selectionScaling$",new U.Subject);R(this,"selectionScaled$",new U.Subject);R(this,"selectionFilling$",new U.Subject);R(this,"_selectionFilled$",new U.Subject);R(this,"selectionFilled$",this._selectionFilled$.asObservable());R(this,"_defaultStyle");R(this,"_currentStyle");R(this,"_isHelperSelection",!0);R(this,"_antLineOffset",0);R(this,"_antRequestNewFrame",-1);this._scene=e,this._zIndex=n,this._isHeaderHighlight=i,this._themeService=r,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}setEvent(e){this.leftControl.evented=e,this.rightControl.evented=e,this.topControl.evented=e,this.bottomControl.evented=e}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,n=0,i=0,r,s){this._selectionModel.setValue(e,s),r==null&&(r=this._selectionStyle),this._updateControl(r,n,i)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,n,i,r,s,a,c,u,d,h,m,g,f,_,p,v,M,b,T,w,y,O,x,A,F;(e=this._leftControl)==null||e.dispose(),(n=this._rightControl)==null||n.dispose(),(i=this._topControl)==null||i.dispose(),(r=this._bottomControl)==null||r.dispose(),(s=this._backgroundControlTop)==null||s.dispose(),(a=this._backgroundControlMiddleLeft)==null||a.dispose(),(c=this._backgroundControlMiddleRight)==null||c.dispose(),(u=this._backgroundControlBottom)==null||u.dispose(),(d=this._fillControl)==null||d.dispose(),(h=this._selectionShape)==null||h.dispose(),(m=this._rowHeaderBackground)==null||m.dispose(),(g=this._rowHeaderBorder)==null||g.dispose(),(f=this._rowHeaderGroup)==null||f.dispose(),(_=this._rowHeaderBackground)==null||_.dispose(),(p=this._columnHeaderBackground)==null||p.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(M=this._columnHeaderGroup)==null||M.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(T=this._topCenterWidget)==null||T.dispose(),(w=this._topRightWidget)==null||w.dispose(),(y=this._middleLeftWidget)==null||y.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(x=this._bottomLeftWidget)==null||x.dispose(),(A=this._bottomCenterWidget)==null||A.dispose(),(F=this._bottomRightWidget)==null||F.dispose(),super.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let n;if(e.isMerged){const i=e.mergeInfo;n={startRow:i.startRow,endRow:i.endRow,startColumn:i.startColumn,endColumn:i.endColumn,startX:i.startX,endX:i.endX,startY:i.startY,endY:i.endY}}else{const{actualRow:i,actualColumn:r,startX:s,endX:a,startY:c,endY:u}=e;n={startRow:i,endRow:i,startColumn:r,endColumn:r,startX:s,endX:a,startY:c,endY:u}}return n}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,n,i){const{startX:r,startY:s,endX:a,endY:c}=this._selectionModel,u=this._defaultStyle;e==null&&(e=u),this._currentStyle=e;const{stroke:d=u.stroke,widgets:h=u.widgets,hasAutoFill:m=u.hasAutoFill,AutofillStroke:g=u.AutofillStroke,strokeDash:f,isAnimationDash:_}=e;let{strokeWidth:p=u.strokeWidth,AutofillSize:v=u.AutofillSize,AutofillStrokeWidth:M=u.AutofillStrokeWidth}=e;const b=this._getScale(),T=(p+S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH)/2/b;p/=b,v/=b,M/=b<1?1:b;const w=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/b,y=E.FIX_ONE_PIXEL_BLUR_OFFSET/b;if(this.leftControl.transformByState({height:c-s,left:-T+y,width:p,strokeWidth:w,top:-w/2+y}),this.leftControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:c-s,left:a-r-T+y,width:p,strokeWidth:w,top:-w/2+y}),this.rightControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:a-r+p,top:-T+y,left:-T+y,height:p,strokeWidth:w}),this.topControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:a-r+p,top:c-s-T+y,height:p,left:-T+y,strokeWidth:w}),this.bottomControl.setProps({fill:d,stroke:S.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),f==null||c-s>1e6||a-r>1e5)this.dashRect.hide(),this._stopAntLineAnimation();else{const O=e.strokeWidth*2/b;this.dashRect.transformByState({height:c-s,width:a-r,strokeWidth:O,left:-O/2+y,top:-O/2+y}),this.dashRect.setProps({strokeDashArray:[0,f/b]}),this._stopAntLineAnimation(),_!==!1&&this._startAntLineAnimation(),this.dashRect.show()}m===!0&&!this._hasWidgets(h)?(this.fillControl.setProps({fill:d,stroke:g,strokeScaleEnabled:!1}),this.fillControl.transformByState({width:v-M,height:v-M,left:a-r-v/2+M/2-y,top:c-s-v/2+M/2-y,strokeWidth:M}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,n,i),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(r,s),this._selectionStyle=e,this._rowHeaderWidth=n||0,this._columnHeaderHeight=i||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=S.getNormalSelectionStyle(this._themeService),this._selectionModel=new _a;const e=this._zIndex;this._leftControl=new E.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new E.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new E.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new E.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new E.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new E.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new E.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new E.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new E.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new E.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const n=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new E.Group("__SpreadsheetSelectionShape__"+e,...n,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e;const i=this.getScene();i.addObject(this._selectionShape,ha),this.disposeWithMe(l.toDisposable(i.onTransformChangeObservable.add(r=>{r.type===E.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._updateControl(this._currentStyle,this._rowHeaderWidth,this._columnHeaderHeight)}))),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new E.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new E.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new E.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new E.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new E.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new E.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],E.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new E.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new E.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new E.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new E.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new E.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new E.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new E.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new E.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,n,i){const{startX:r,startY:s,endX:a,endY:c,rangeType:u}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const h=this._getScale(),{stroke:m,hasRowHeader:g,rowHeaderFill:f=d.rowHeaderFill,rowHeaderStroke:_=d.rowHeaderStroke,hasColumnHeader:p,columnHeaderFill:v=d.columnHeaderFill,columnHeaderStroke:M=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:T=d.columnHeaderStrokeWidth}=e;if(b/=h,T/=h,p===!0){let w=v;this._isHeaderHighlight&&u===l.RANGE_TYPE.COLUMN&&(w=new l.ColorKit(m).setAlpha(xi).toString()),this._columnHeaderBackground.setProps({fill:w}),this._columnHeaderBackground.resize(a-r,i),this._columnHeaderBorder.setProps({fill:M}),this._columnHeaderBorder.transformByState({width:a-r,height:T,top:i-T+1/h}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(r,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),g===!0){let w=f;this._isHeaderHighlight&&u===l.RANGE_TYPE.ROW&&(w=new l.ColorKit(m).setAlpha(xi).toString()),this._rowHeaderBackground.setProps({fill:w}),this._rowHeaderBackground.resize(n,c-s),this._rowHeaderBorder.setProps({fill:_}),this._rowHeaderBorder.transformByState({width:b,height:c-s,left:n-b+1/h}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,s)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:n,startY:i,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const c=this._getScale(),{fill:u=a.fill}=e;let{strokeWidth:d=a.strokeWidth}=e;d/=c;const h=this._selectionModel.highlightToSelection();if(!h){this._backgroundControlTop.resize(r-n,s-i),this._backgroundControlTop.setProps({fill:u}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:m,startY:g,endX:f,endY:_}=h,p=d/2,v={left:-p,top:-p,width:r-n+p*2,height:g-i+p};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const M={left:-p,top:g-i,width:m-n+p,height:_-g};M.width<0&&(M.width=0,M.height=0),this._backgroundControlMiddleLeft.transformByState(M);const b={left:f-n-p,top:g-i,width:r-f+p*2,height:_-g};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const T={left:-p,top:_-i,width:r-n+p*2,height:s-_+p};T.height<0&&(T.width=0,T.height=0),this._backgroundControlBottom.transformByState(T),this._backgroundControlTop.setProps({fill:u}),this._backgroundControlMiddleLeft.setProps({fill:u}),this._backgroundControlMiddleRight.setProps({fill:u}),this._backgroundControlBottom.setProps({fill:u})}_updateWidgets(e){const{startX:n,startY:i,endX:r,endY:s}=this._selectionModel,a=this._defaultStyle;e==null&&(e=a);const{stroke:c=a.stroke,widgets:u=a.widgets,widgetStroke:d=a.widgetStroke}=e,h=this._getScale();let{widgetSize:m=a.widgetSize,widgetStrokeWidth:g=a.widgetStrokeWidth}=e;m/=h,g/=h;const f={left:-m/2+g/2,center:(r-n)/2-m/2+g/2,right:r-n-m/2+g/2,top:-m/2,middle:(s-i)/2-m/2,bottom:s-i-m/2+g/2},_=m-g;this._widgetRects.forEach(p=>{p.setProps({fill:c,stroke:d})}),u.tl===!0?(this._topLeftWidget.transformByState({height:_,width:_,left:f.left,top:f.top,strokeWidth:g}),this._topLeftWidget.show()):this._topLeftWidget.hide(),u.tc===!0?(this._topCenterWidget.transformByState({height:_,width:_,left:f.center,top:f.top,strokeWidth:g}),this._topCenterWidget.show()):this._topCenterWidget.hide(),u.tr===!0?(this._topRightWidget.transformByState({height:_,width:_,left:f.right,top:f.top,strokeWidth:g}),this._topRightWidget.show()):this._topRightWidget.hide(),u.ml===!0?(this._middleLeftWidget.transformByState({height:_,width:_,left:f.left,top:f.middle,strokeWidth:g}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),u.mr===!0?(this._middleRightWidget.transformByState({height:_,width:_,left:f.right,top:f.middle,strokeWidth:g}),this._middleRightWidget.show()):this._middleRightWidget.hide(),u.bl===!0?(this._bottomLeftWidget.transformByState({height:_,width:_,left:f.left,top:f.bottom,strokeWidth:g}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),u.bc===!0?(this._bottomCenterWidget.transformByState({height:_,width:_,left:f.center,top:f.bottom,strokeWidth:g}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),u.br===!0?(this._bottomRightWidget.transformByState({height:_,width:_,left:f.right,top:f.bottom,strokeWidth:g}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const n=Object.keys(e);if(n.length===0)return!1;for(const i of n)if(e[i]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:n}=this._scene.getAncestorScale();return Math.max(e,n)}_stopAntLineAnimation(){this._antLineOffset=0,E.cancelRequestFrame(this._antRequestNewFrame)}_startAntLineAnimation(){const e=this._getScale();this._antLineOffset+=.6/e,this._antLineOffset>16/e&&(this._antLineOffset=0),this.dashRect.setProps({strokeDashOffset:-this._antLineOffset}),this._antRequestNewFrame=E.requestNewFrame(()=>{this._startAntLineAnimation()})}}const Ni="__SpreadsheetHelperSelectionTempRect",Sa=35;class Ai{constructor(t,e,n,i,r){R(this,"_startOffsetX",0);R(this,"_startOffsetY",0);R(this,"_relativeSelectionPositionRow",0);R(this,"_relativeSelectionPositionColumn",0);R(this,"_relativeSelectionRowLength",0);R(this,"_relativeSelectionColumnLength",0);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_helperSelection");R(this,"_scrollTimer");R(this,"_activeViewport");R(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});R(this,"_isInMergeState",!1);R(this,"_fillControlColors",[]);this._control=t,this._skeleton=e,this._scene=n,this._themeService=i,this._injector=r,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var t,e;(t=this._scrollTimer)==null||t.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(e=this._helperSelection)==null||e.dispose()}_getFreeze(){var e;return(e=this._injector.get(exports.SheetSkeletonManagerService).getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_isSelectionInViewport(t,e){const n=this._getFreeze()||{startRow:-1,startColumn:-1,xSplit:0,ySplit:0};switch(e.viewPortKey){case W.VIEW_MAIN:return t.endRow>=n.startRow&&t.endColumn>=n.startColumn;case W.VIEW_MAIN_TOP:case W.VIEW_COLUMN_RIGHT:return t.endColumn>=n.startColumn&&t.startRow<n.startRow;case W.VIEW_MAIN_LEFT:case W.VIEW_ROW_BOTTOM:return t.endRow>=n.startRow&&t.startColumn<n.startColumn;case W.VIEW_MAIN_LEFT_TOP:case W.VIEW_COLUMN_LEFT:case W.VIEW_ROW_TOP:case W.VIEW_LEFT_TOP:return t.startRow<n.startRow&&t.startColumn<n.startColumn}}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:t,rightControl:e,topControl:n,bottomControl:i}=this._control;[t,e,n,i].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(E.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(t,e){var y;const n=this._scene,i=n.getScrollXYByRelativeCoords(E.Vector2.FromArray([t,e])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,i),{row:c,column:u}=a,d=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let g=m+this._relativeSelectionRowLength;g>d&&(g=d,g-m<this._relativeSelectionRowLength&&(m=g-this._relativeSelectionRowLength));let f=u+this._relativeSelectionPositionColumn;f<0&&(f=0);let _=f+this._relativeSelectionColumnLength;_>h&&(_=h,_-f<this._relativeSelectionColumnLength&&(f=_-this._relativeSelectionColumnLength));const p=this._skeleton.getNoMergeCellPositionByIndex(m,f),v=this._skeleton.getNoMergeCellPositionByIndex(g,_),M=(p==null?void 0:p.startY)||0,b=(v==null?void 0:v.endY)||0,T=(p==null?void 0:p.startX)||0,w=(v==null?void 0:v.endX)||0;(y=this._helperSelection)==null||y.transformByState({left:T,top:M,width:w-T,height:b-M}),this._targetSelection={startY:M,endY:b,startX:T,endX:w,startRow:m,endRow:g,startColumn:f,endColumn:_},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(t){const{offsetX:e,offsetY:n}=t,i=this._scene,r=i.getRelativeCoord(E.Vector2.FromArray([e,n])),{x:s,y:a}=r,c=i.getScrollXYByRelativeCoords(r),{scaleX:u,scaleY:d}=i.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,u,d,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:g}=h,{startRow:f,startColumn:_,endRow:p,endColumn:v}=this._control.model;let M=0,b=0;m<f?M-=1:m>p&&(M+=1),g<_?b-=1:g>v&&(b+=1),this._relativeSelectionPositionRow=f-m+M,this._relativeSelectionPositionColumn=_-g+b,this._relativeSelectionRowLength=p-f,this._relativeSelectionColumnLength=v-_;const T=this._control.selectionStyle,w=this._getScale();this.isHelperSelection&&(this._helperSelection=new E.Rect(Ni,{stroke:T.stroke,strokeWidth:T.strokeWidth/w}),i.addObject(this._helperSelection));const y=i.getViewport(W.VIEW_MAIN),O=E.ScrollTimer.create(i);O.startScroll(s,a,y),this._scrollTimer=O,i.disableEvent(),this._moveObserver=i.onPointerMoveObserver.add(x=>{const{offsetX:A,offsetY:F}=x,{x:N,y:L}=i.getRelativeCoord(E.Vector2.FromArray([A,F]));this._controlMoving(N,L),i.setCursor(E.CURSOR_TYPE.MOVE),O.scrolling(N,L,()=>{this._controlMoving(N,L)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var A,F;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(F=this._scrollTimer)==null||F.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:t,topCenterWidget:e,topRightWidget:n,middleLeftWidget:i,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,u=[E.CURSOR_TYPE.NORTH_WEST_RESIZE,E.CURSOR_TYPE.NORTH_RESIZE,E.CURSOR_TYPE.NORTH_EAST_RESIZE,E.CURSOR_TYPE.WEST_RESIZE,E.CURSOR_TYPE.EAST_RESIZE,E.CURSOR_TYPE.SOUTH_WEST_RESIZE,E.CURSOR_TYPE.SOUTH_RESIZE,E.CURSOR_TYPE.SOUTH_EAST_RESIZE];[t,e,n,i,r,s,a,c].forEach((d,h)=>{d.onPointerEnterObserver.add(()=>{d.setCursor(u[h])}),d.onPointerLeaveObserver.add(()=>{d.resetCursor()}),d.onPointerDownObserver.add(m=>{this._widgetEvent(m,u[h])})})}_widgetMoving(t,e,n){const i=this._scene,r=i.getScrollXYByRelativeCoords(E.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=i.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(t,e,s,a,r),{row:u,column:d}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,_=u,p=d;n===E.CURSOR_TYPE.NORTH_WEST_RESIZE?(g=u,f=d,_=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn):n===E.CURSOR_TYPE.NORTH_RESIZE?(g=u,f=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===E.CURSOR_TYPE.NORTH_EAST_RESIZE?(g=u,f=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow,p=d):n===E.CURSOR_TYPE.WEST_RESIZE?(g=this._relativeSelectionPositionRow,f=d,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn):n===E.CURSOR_TYPE.EAST_RESIZE?_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===E.CURSOR_TYPE.SOUTH_WEST_RESIZE?(g=this._relativeSelectionPositionRow,f=d,_=u,p=this._relativeSelectionPositionColumn):n===E.CURSOR_TYPE.SOUTH_RESIZE&&(g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,_=u,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:v,startColumn:M,endRow:b,endColumn:T}=this._swapPositions(g,f,_,p),w=this._skeleton.getNoMergeCellPositionByIndex(v,M),y=this._skeleton.getNoMergeCellPositionByIndex(b,T),O=(w==null?void 0:w.startY)||0,x=(y==null?void 0:y.endY)||0,A=(w==null?void 0:w.startX)||0,F=(y==null?void 0:y.endX)||0;this._targetSelection={startY:O,endY:x,startX:A,endX:F,startRow:g,endRow:_,startColumn:f,endColumn:p},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(t,e){const{offsetX:n,offsetY:i}=t,r=this._scene,s=r.getRelativeCoord(E.Vector2.FromArray([n,i])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=i;const{startRow:u,startColumn:d,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=u,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=h-u,this._relativeSelectionColumnLength=m-d,e===E.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):e===E.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:e===E.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:e===E.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:e===E.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const g=E.ScrollTimer.create(r);g.startScroll(a,c),this._scrollTimer=g,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(f=>{const{offsetX:_,offsetY:p}=f,{x:v,y:M}=r.getRelativeCoord(E.Vector2.FromArray([_,p]));this._widgetMoving(v,M,e),r.setCursor(e),g.scrolling(v,M,()=>{this._widgetMoving(v,M,e)})}),this._upObserver=r.onPointerUpObserver.add(()=>{var _;const f=this._scene;f.resetCursor(),this._clearObserverEvent(),f.enableEvent(),(_=this._scrollTimer)==null||_.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:t}=this._control;t.onPointerEnterObserver.add(()=>{t.setCursor(E.CURSOR_TYPE.CROSSHAIR)}),t.onPointerLeaveObserver.add(()=>{t.resetCursor()}),t.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(t,e){var F,N,L;const n=this._scene,i=n.getScrollXY(this._activeViewport),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(t,e,r,s,i),{row:c,column:u}=a,d=n.getRelativeCoord(E.Vector2.FromArray([t,e])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let g=this._relativeSelectionPositionRow,f=this._relativeSelectionPositionColumn,_=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,p=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,v=!1,M=!0;if((u<f||u>p)&&c>=g&&c<=_){const B=this._fillRuler(u,f,p,this._relativeSelectionColumnLength,m);f=B.startRowOrColumn,p=B.endRowOrColumn,v=B.isLighten,M=!1}else if((c<g||c>_)&&u>=f&&u<=p){const B=this._fillRuler(c,g,_,this._relativeSelectionRowLength,h);g=B.startRowOrColumn,_=B.endRowOrColumn,v=B.isLighten}else if(Math.abs(this._startOffsetX-d.x-i.x)/2>Math.abs(this._startOffsetY-d.y-i.y)){const B=this._fillRuler(u,f,p,this._relativeSelectionColumnLength,m);f=B.startRowOrColumn,p=B.endRowOrColumn,v=B.isLighten,M=!1}else{const B=this._fillRuler(c,g,_,this._relativeSelectionRowLength,h);g=B.startRowOrColumn,_=B.endRowOrColumn,v=B.isLighten}const b=this._skeleton.getNoMergeCellPositionByIndex(g,f),T=this._skeleton.getNoMergeCellPositionByIndex(_,p),w=(b==null?void 0:b.startY)||0,y=(T==null?void 0:T.endY)||0,O=(b==null?void 0:b.startX)||0,x=(T==null?void 0:T.endX)||0;v?this._controlHandler((B,j)=>{const z=new l.ColorKit(this._fillControlColors[j]).lighten(Sa).toRgbString();B.setProps({fill:z})}):this._controlHandler((B,j)=>{B.setProps({fill:this._fillControlColors[j]})});const A=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();g===_&&M===!0||f===p&&M===!1?(F=this._helperSelection)==null||F.hide():((N=this._helperSelection)==null||N.transformByState({left:O-A/2,top:w-A/2,width:x-O,height:y-w}),(L=this._helperSelection)==null||L.show()),this._targetSelection={startY:w,endY:y,startX:O,endX:x,startRow:g,endRow:_,startColumn:f,endColumn:p},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(t){const{offsetX:e,offsetY:n}=t,i=this._scene,r=i.getRelativeCoord(E.Vector2.FromArray([e,n])),{x:s,y:a}=r;this._startOffsetX=s,this._startOffsetY=a;const{startRow:c,startColumn:u,endRow:d,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,u,d,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=d-c,this._relativeSelectionColumnLength=h-u;const m=this._control.selectionStyle;let g=m==null?void 0:m.stroke,f=m==null?void 0:m.strokeWidth;const _=S.getNormalSelectionStyle(this._themeService);g==null&&(g=_.stroke),f==null&&(f=_.strokeWidth);const p=this._getScale();f/=p;const v=S.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/p,M=new l.ColorKit(g).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new E.Rect(Ni,{stroke:M,strokeWidth:f+v/2}),i.addObject(this._helperSelection)),this._activeViewport=i.getActiveViewportByCoord(E.Vector2.FromArray([e,n]));const b=i.getViewport(W.VIEW_MAIN),T=E.ScrollTimer.create(i,this._activeViewport.viewPortKey===W.VIEW_MAIN?E.ScrollTimerType.ALL:E.ScrollTimerType.NONE);T.startScroll(s,a,b),this._scrollTimer=T,i.disableEvent(),this._controlHandler(w=>{this._fillControlColors.push(w.fill)}),this._moveObserver=i.onPointerMoveObserver.add(w=>{var L;const{offsetX:y,offsetY:O}=w,x=i.getActiveViewportByCoord(E.Vector2.FromArray([y,O])),{x:A,y:F}=i.getRelativeCoord(E.Vector2.FromArray([y,O]));this._fillMoving(A,F),i.setCursor(E.CURSOR_TYPE.CROSSHAIR);const N=this._targetSelection;if(b&&x&&((L=this._activeViewport)==null?void 0:L.viewPortKey)!==(x==null?void 0:x.viewPortKey)){let B;N.startRow!==c?(T.scrollTimerType=E.ScrollTimerType.Y,B={...N,endRow:N.startRow}):N.endRow!==d?(T.scrollTimerType=E.ScrollTimerType.Y,B={...N,startRow:N.endRow}):N.startColumn!==u?(T.scrollTimerType=E.ScrollTimerType.X,B={...N,endColumn:N.startColumn}):(T.scrollTimerType=E.ScrollTimerType.X,B={...N,startColumn:N.endColumn}),this._isSelectionInViewport(B,x)&&(b.scrollTo({x:T.scrollTimerType===E.ScrollTimerType.X?0:void 0,y:T.scrollTimerType===E.ScrollTimerType.Y?0:void 0}),this._activeViewport=x)}T.scrolling(A,F,()=>{this._fillMoving(A,F)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var y,O;(y=this._helperSelection)==null||y.dispose();const w=this._scene;w.resetCursor(),this._clearObserverEvent(),w.enableEvent(),(O=this._scrollTimer)==null||O.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(t,e,n,i){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:u,endColumn:d}=s,h={left:e,top:t,right:i,bottom:n},m={left:c,top:a,right:d,bottom:u};if(E.isRectIntersect(h,m))return!0}return!1}_swapPositions(t,e,n,i){const r=Math.min(t,n),s=Math.min(e,i),a=Math.max(t,n),c=Math.max(e,i);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(t){const{leftControl:e,rightControl:n,topControl:i,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:u,fillControl:d}=this._control,h=[e,n,i,r,s,a,c,u,d];for(let m=0,g=h.length;m<g;m++){const f=h[m];t(f,m)}}_fillRuler(t,e,n,i,r){let s=!1;if(t<e)if(this._isInMergeState&&t<e){const a=e-t,c=i+1,u=Math.ceil(a/c);let d=e-u*c;d<0&&(d=e-(u-1)*c),e=d}else e=t;else if(t>=e&&t<=n)s=!0,this._isInMergeState||(n=t);else if(this._isInMergeState&&t>n){const a=t-n,c=i+1,u=Math.ceil(a/c);let d=n+u*c;d>r&&(d=n+(u-1)*c),n=d}else n=t;return{rowOrColumn:t,startRowOrColumn:e,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:t,scaleY:e}=this._scene.getAncestorScale();return Math.max(t,e)}}var pa=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,va=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ca(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&pa(t,e,i),i},un=(o,t)=>(e,n)=>t(e,n,o);exports.SelectionRenderService=class{constructor(t,e,n,i){R(this,"hasSelection",!1);R(this,"_downObserver");R(this,"_moveObserver");R(this,"_upObserver");R(this,"_controlFillConfig$",new U.BehaviorSubject(null));R(this,"controlFillConfig$",this._controlFillConfig$.asObservable());R(this,"_selectionControls",[]);R(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});R(this,"_startOffsetX",0);R(this,"_startOffsetY",0);R(this,"_scrollTimer");R(this,"_cancelDownObserver");R(this,"_cancelUpObserver");R(this,"_skeleton");R(this,"_scene");R(this,"_isHeaderHighlight",!0);R(this,"_isDetectMergedCell",!0);R(this,"_selectionStyle");R(this,"_isSelectionEnabled",!0);R(this,"_isShowPreviousEnable",0);R(this,"_isRemainLastEnable",!0);R(this,"_isSkipRemainLastEnable",!1);R(this,"_isSingleSelection",!1);R(this,"_selectionMoveEnd$",new U.BehaviorSubject([]));R(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());R(this,"_selectionMoving$",new U.Subject);R(this,"selectionMoving$",this._selectionMoving$.asObservable());R(this,"_selectionMoveStart$",new U.Subject);R(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());R(this,"_activeViewport");R(this,"_usable$",new U.BehaviorSubject(!1));R(this,"usable$",this._usable$.asObservable());this._themeService=t,this._shortcutService=e,this._sheetSkeletonManagerService=n,this._injector=i,this._selectionStyle=S.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(t){this._selectionStyle=t}resetStyle(){this.setStyle(S.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}enableSingleSelection(){this._isSingleSelection=!0}disableSingleSelection(){this._isSingleSelection=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const{rangeWithCoord:n,primaryWithCoord:i}=t,r=this._skeleton;let s=t.style;s==null&&(s=S.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new Bn(a,e.length,this._isHeaderHighlight,this._themeService);new Ai(c,r,a,this._themeService,this._injector);const{rowHeaderWidth:u,columnHeaderHeight:d}=r;c.update(n,u,d,s,i),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),e.push(c)}updateControlForCurrentByRangeData(t){const e=this.getCurrentControls();if(!e)return;const n=this._skeleton;if(n==null)return;const{rowHeaderWidth:i,columnHeaderHeight:r}=n;for(let s=0,a=t.length;s<a;s++){const{rangeWithCoord:c,primaryWithCoord:u,style:d}=t[s];e[s].update(c,i,r,d,u)}}refreshSelectionMoveStart(){this._selectionMoveStart$.next(this.getSelectionDataWithStyle())}changeRuntime(t,e,n){this._skeleton=t,this._scene=e,this._activeViewport=n||(e==null?void 0:e.getViewports()[0]),this._usable$.next(!!(t&&e))}getSelectionDataWithStyle(){return this._selectionControls.map(e=>e.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const t=this.getCurrentControls();if(t.length>0){for(const e of t)e.dispose();t.length=0}}_getFreeze(){var e;return(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig().freeze}_getViewportByCell(t,e){if(!this._scene||t===void 0||e===void 0)return null;const n=this._getFreeze();if(!n||n.startRow<=0&&n.startColumn<=0)return this._scene.getViewport(W.VIEW_MAIN);if(t>n.startRow&&e>n.startColumn)return this._scene.getViewport(W.VIEW_MAIN);if(t<=n.startRow&&e<=n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_LEFT_TOP);if(t<=n.startRow&&e>n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_TOP);if(t>n.startRow&&e<=n.startColumn)return this._scene.getViewport(W.VIEW_MAIN_LEFT)}getActiveSelections(){const t=this.getCurrentControls();if(t&&t.length>0)return t==null?void 0:t.map(n=>{const i=n.model,r=i.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn},primary:s}})}getActiveRange(){const t=this.getCurrentControls(),e=t&&t[t.length-1].model;return e&&{startRow:e.startRow,startColumn:e.startColumn,endRow:e.endRow,endColumn:e.endColumn}}getActiveSelection(){const t=this.getCurrentControls();return t&&t[t.length-1]}endSelection(){this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}reset(){var t,e,n;this._clearSelectionControls(),(t=this._moveObserver)==null||t.dispose(),(e=this._upObserver)==null||e.dispose(),(n=this._downObserver)==null||n.dispose(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(t,e=0,n=l.RANGE_TYPE.NORMAL,i,r=E.ScrollTimerType.ALL){var X,J;if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=t,u=this._scene;if(u==null||s==null)return;i!=null&&(this._activeViewport=i);const d=u.getViewport(W.VIEW_MAIN),h=u.getRelativeCoord(E.Vector2.FromArray([a,c]));let{x:m,y:g}=h;this._startOffsetX=m,this._startOffsetY=g;const f=u.getScrollXYByRelativeCoords(h),{scaleX:_,scaleY:p}=u.getAncestorScale();n===l.RANGE_TYPE.ROW?m=0:n===l.RANGE_TYPE.COLUMN&&(g=0);const v=this._getSelectedRangeWithMerge(m,g,_,p,f);if(!v)return!1;const{rangeWithCoord:M,primaryWithCoord:b}=v,{startRow:T,startColumn:w,endColumn:y,endRow:O,startY:x,endY:A,startX:F,endX:N}=M,{rowHeaderWidth:L,columnHeaderHeight:B}=s,j={startColumn:w,startRow:T,endColumn:y,endRow:O,startY:x,endY:A,startX:F,endX:N,rangeType:n};this._startSelectionRange=j;let z=this.getActiveSelection();const q=this.getCurrentControls();if(!q)return!1;for(const ee of q){if(t.button===2&&ee.model.isInclude(j)){z=ee;return}if(ee.model.isEqual(j)){z=ee;break}t.shiftKey||ee.clearHighlight()}if(q.length>0&&!t.ctrlKey&&!t.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable||q.length>0&&this._isSingleSelection&&!t.shiftKey){for(const ee of q)ee.dispose();q.length=0}const K=z&&z.model.currentCell;if(z&&t.shiftKey&&K){const{actualRow:ee,actualColumn:ce,mergeInfo:Ce}=K,De=Math.min(ee,j.startRow,Ce.startRow),Pe=Math.max(ee,j.endRow,Ce.endRow),We=Math.min(ce,j.startColumn,Ce.startColumn),je=Math.max(ce,j.endColumn,Ce.endColumn),he=s.getMergeBounding(De,We,Pe,je),de=s.getNoMergeCellPositionByIndex(he.startRow,he.startColumn),se=s.getNoMergeCellPositionByIndex(he.endRow,he.endColumn),$e={startColumn:he.startColumn,startRow:he.startRow,endColumn:he.endColumn,endRow:he.endRow,startY:de.startY,endY:se.endY,startX:de.startX,endX:se.endX,rangeType:n},pe=s.getCellByIndex(ee,ce);this._startSelectionRange={startColumn:pe.mergeInfo.startColumn,startRow:pe.mergeInfo.startRow,endColumn:pe.mergeInfo.endColumn,endRow:pe.mergeInfo.endRow,startY:pe.mergeInfo.startY||0,endY:pe.mergeInfo.endY||0,startX:pe.mergeInfo.startX||0,endX:pe.mergeInfo.endX||0,rangeType:n},z.update($e,L,B,this._selectionStyle,K)}else this._isRemainLastEnable&&z&&!t.ctrlKey&&!t.shiftKey&&!this._isSkipRemainLastEnable&&!this._isSingleSelection?z.update(j,L,B,this._selectionStyle,b):(z=new Bn(u,q.length+e,this._isHeaderHighlight,this._themeService),new Ai(z,s,u,this._themeService,this._injector),z.update(j,L,B,this._selectionStyle,b),q.push(z));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),u.disableEvent();const $=u.getActiveViewportByCoord(E.Vector2.FromArray([m,g])),Q=E.ScrollTimer.create(this._scene,r);Q.startScroll((X=d==null?void 0:d.left)!=null?X:0,(J=d==null?void 0:d.top)!=null?J:0,d),this._scrollTimer=Q,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(m,g,z,n);let P=0,H=0,k=m,Y=g;this._moveObserver=u.onPointerMoveObserver.add(ee=>{var pe,Ht,Lt,fi,_i,Si,pi,Ci,vi,Ii;const{offsetX:ce,offsetY:Ce}=ee,{x:De,y:Pe}=u.getRelativeCoord(E.Vector2.FromArray([ce,Ce]));this._moving(De,Pe,z,n);let We=De,je=Pe;const he=this.getActiveSelection(),de=(pe=this._sheetSkeletonManagerService.getCurrent())==null?void 0:pe.skeleton.getWorksheetConfig().freeze,se=he==null?void 0:he.model,$e=(Ht=u.getActiveViewportByCoord(E.Vector2.FromArray([ce,Ce])))!=null?Ht:this._getViewportByCell(se==null?void 0:se.endRow,se==null?void 0:se.endColumn);if($&&$e&&d){const oo=k<d.left&&De>d.left||k>d.left&&De<d.left,io=Y<d.top&&Pe>d.top||Y>d.top&&Pe<d.top;oo&&(P+=1),io&&(H+=1);const He=$.viewPortKey,Ut=$e.viewPortKey;if(He===W.VIEW_ROW_TOP)Ce<d.top&&((Lt=se==null?void 0:se.endRow)!=null?Lt:0)<((fi=de==null?void 0:de.startRow)!=null?fi:0)?je=d.top:io&&H%2===1&&d.scrollTo({y:0});else if(He===W.VIEW_COLUMN_LEFT)ce<d.left&&((_i=se==null?void 0:se.endColumn)!=null?_i:0)<((Si=de==null?void 0:de.startColumn)!=null?Si:0)?We=d.left:oo&&P%2===1&&d.scrollTo({x:0});else if(He===Ut){let ze=!1,rt=!1;He===W.VIEW_MAIN_LEFT_TOP?(ze=!0,rt=!0):He===W.VIEW_MAIN_TOP?rt=!0:He===W.VIEW_MAIN_LEFT&&(ze=!0),((pi=se==null?void 0:se.endRow)!=null?pi:0)>((Ci=de==null?void 0:de.startRow)!=null?Ci:0)&&(rt=!1),((vi=se==null?void 0:se.endColumn)!=null?vi:0)>((Ii=de==null?void 0:de.startColumn)!=null?Ii:0)&&(ze=!1),ze&&(We=d.left),rt&&(je=d.top)}else{const ze={x:$.scrollX,y:$.scrollY},rt={x:$e.scrollX,y:$e.scrollY},ro=ze.x!==rt.x&&oo&&P%2===1,so=ze.y!==rt.y&&io&&H%2===1;(ro||so)&&(d.scrollTo({x:ro?ze.x:void 0,y:so?ze.y:void 0}),ro||(We=d.left),so||(je=d.top)),(He===W.VIEW_MAIN_LEFT_TOP&&Ut===W.VIEW_MAIN_LEFT||Ut===W.VIEW_MAIN_LEFT_TOP&&He===W.VIEW_MAIN_LEFT)&&(We=d.left),(He===W.VIEW_MAIN_LEFT_TOP&&Ut===W.VIEW_MAIN_TOP||Ut===W.VIEW_MAIN_LEFT_TOP&&He===W.VIEW_MAIN_TOP)&&(je=d.top)}k=De,Y=Pe}Q.scrolling(We,je,()=>{this._moving(De,Pe,z,n)})}),this._upObserver=u.onPointerUpObserver.add(ee=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionToCoord(t){const{range:e,primary:n,style:i}=t;let r=this.convertRangeDataToSelection(e);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:i}}convertRangeDataToSelection(t){const{startRow:e,startColumn:n,endRow:i,endColumn:r,rangeType:s}=t,a=this._scene,c=this._skeleton;if(a==null||c==null)return;a.getAncestorScale();const u=c.getNoMergeCellPositionByIndex(e,n),d=c.getNoMergeCellPositionByIndex(i,r);return{startRow:e,startColumn:n,endRow:i,endColumn:r,rangeType:s,startY:(u==null?void 0:u.startY)||0,endY:(d==null?void 0:d.endY)||0,startX:(u==null?void 0:u.startX)||0,endX:(d==null?void 0:d.endX)||0}}convertCellRangeToInfo(t){if(t==null)return;const e=this._scene,n=this._skeleton;if(e==null||n==null)return;const{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:u,endRow:d,endColumn:h}=t,m=n.getNoMergeCellPositionByIndex(i,r),g=n.getNoMergeCellPositionByIndex(c,u),f=n.getNoMergeCellPositionByIndex(d,h);return{actualRow:i,actualColumn:r,isMerged:s,isMergedMainCell:a,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY,mergeInfo:{startRow:c,startColumn:u,endRow:d,endColumn:h,startY:(g==null?void 0:g.startY)||0,endY:(f==null?void 0:f.endY)||0,startX:(g==null?void 0:g.startX)||0,endX:(f==null?void 0:f.endX)||0}}}_moving(t,e,n,i){var J;const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:u,endColumn:d}=this._startSelectionRange,{startRow:h,endRow:m,startColumn:g,endColumn:f}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1},_=s.getViewport(W.VIEW_MAIN),p=(J=this._getViewportByCell(m,f))!=null?J:_,v=s.getScrollXYByRelativeCoords(E.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),p),{scaleX:M,scaleY:b}=s.getAncestorScale(),{rowHeaderWidth:T,columnHeaderHeight:w}=r;i===l.RANGE_TYPE.ROW?t=Number.POSITIVE_INFINITY:i===l.RANGE_TYPE.COLUMN&&(e=Number.POSITIVE_INFINITY);const y=this._getSelectedRangeWithMerge(t,e,M,b,v);if(!y)return!1;const{rangeWithCoord:O,primaryWithCoord:x}=y,{startRow:A,startColumn:F,endColumn:N,endRow:L}=O,B=Math.min(A,a),j=Math.min(F,c),z=Math.max(L,u),q=Math.max(N,d);let K={startRow:B,startColumn:j,endRow:z,endColumn:q};if(this._isDetectMergedCell&&(K=r.getSelectionBounding(B,j,z,q)),!K)return!1;const{startRow:$,startColumn:Q,endRow:P,endColumn:H}=K,k=r.getNoMergeCellPositionByIndex($,Q),Y=r.getNoMergeCellPositionByIndex(P,H),X={startColumn:Q,startRow:$,endColumn:H,endRow:P,startY:(k==null?void 0:k.startY)||0,endY:(Y==null?void 0:Y.endY)||0,startX:(k==null?void 0:k.startX)||0,endX:(Y==null?void 0:Y.endX)||0};(g!==Q||h!==$||f!==H||m!==P)&&n!=null&&(n.update(X,T,w),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,i;const t=this._scene;if(t==null)return;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),t.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const e=(i=t.getEngine())==null?void 0:i.activeScene;e==null||e.onPointerDownObserver.remove(this._cancelDownObserver),e==null||e.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const t=this._scene;if(t==null)return;const e=(n=t.getEngine())==null?void 0:n.activeScene;e==null||e===t||(e.onPointerDownObserver.remove(this._cancelDownObserver),e.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=e.onPointerDownObserver.add(i=>{this._endSelection()}),this._cancelUpObserver=e.onPointerUpObserver.add(i=>{this._endSelection()}))}_getSelectedRangeWithMerge(t,e,n,i,r){var v;if(this._isDetectMergedCell){const M=(v=this._skeleton)==null?void 0:v.calculateCellIndexByPosition(t,e,n,i,r),b=l.makeCellToSelection(M);return b==null?void 0:{primaryWithCoord:M,rangeWithCoord:b}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(t,e,n,i,r),{row:c,column:u}=a,d=s.getNoMergeCellPositionByIndex(c,u),{startX:h,startY:m,endX:g,endY:f}=d,_={startY:m,endY:f,startX:h,endX:g,startRow:c,endRow:c,startColumn:u,endColumn:u};return{primaryWithCoord:{actualRow:c,actualColumn:u,isMerged:!1,isMergedMainCell:!1,startY:m,endY:f,startX:h,endX:g,mergeInfo:_},rangeWithCoord:_}}};exports.SelectionRenderService=va([un(0,D.Inject(l.ThemeService)),un(1,I.IShortcutService),un(2,D.Inject(exports.SheetSkeletonManagerService)),un(3,D.Inject(D.Injector))],exports.SelectionRenderService);const Ne=D.createIdentifier("deprecated.univer.sheet.selection-render-service");var Ia=Object.defineProperty,Ra=Object.getOwnPropertyDescriptor,Ma=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ra(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ia(t,e,i),i},Vt=(o,t)=>(e,n)=>t(e,n,o);const ba=1e4,nn=D.createIdentifier("univer.mark-selection-service");exports.MarkSelectionService=class extends l.Disposable{constructor(e,n,i,r,s){super();R(this,"_shapeMap",new Map);this._currentService=e,this._renderManagerService=n,this._selectionRenderService=i,this._sheetSkeletonManagerService=r,this._themeService=s}addShape(e,n=[],i=ba){const r=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet().getSheetId(),a=l.Tools.generateRandomId();return this._shapeMap.set(a,{selection:e,subUnitId:s,unitId:r.getUnitId(),zIndex:i,control:null,exits:n}),this.refreshShapes(),a}refreshShapes(){const e=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),n=this._currentService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getSheetId();this._shapeMap.forEach(i=>{var M;const{unitId:r,subUnitId:s,selection:a,control:c,zIndex:u}=i;if(c&&c.dispose(),r!==e||s!==n)return;const{style:d}=a,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:g}=this._selectionRenderService.convertSelectionToCoord(a),f=(M=this._sheetSkeletonManagerService.getCurrent())==null?void 0:M.skeleton;if(!h||!f)return;const{rowHeaderWidth:_,columnHeaderHeight:p}=f,v=new Bn(h,u,!1,this._themeService);v.update(m,_,p,d,g),i.control=v})}getShapeMap(){return this._shapeMap}removeShape(e){const n=this._shapeMap.get(e);if(!n)return;const{control:i}=n;i&&i.dispose(),this._shapeMap.delete(e)}removeAllShapes(){for(const e of this._shapeMap.values()){const{control:n}=e;n&&n.dispose()}this._shapeMap.clear()}};exports.MarkSelectionService=Ma([Vt(0,l.IUniverInstanceService),Vt(1,E.IRenderManagerService),Vt(2,Ne),Vt(3,D.Inject(exports.SheetSkeletonManagerService)),Vt(4,D.Inject(l.ThemeService))],exports.MarkSelectionService);const Ta=10,wa=6;function Ea(){return l.Tools.generateRandomId(wa)}function ya(o){const t=o.match(/data-copy-id="([^\s]+)"/);return t&&t[1]?t[1]:null}class Oa{constructor(){R(this,"_cache",new l.LRUMap(Ta))}set(t,e){this._cache.set(t,e)}get(t){return this._cache.get(t)}del(t){this._cache.delete(t)}clear(){this._cache.clear()}}function pr(o,t){const e=t!=null?t:o.style,n={},i=o.tagName.toLowerCase();switch(i){case"b":case"em":case"strong":{n.bl=l.BooleanNumber.TRUE;break}case"s":{n.st={s:l.BooleanNumber.TRUE};break}case"u":{n.ul={s:l.BooleanNumber.TRUE};break}case"i":{n.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{n.va=i==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}return xa(e,n),n}function xa(o,t){for(let e=0;e<o.length;e++){const n=o[e],i=o.getPropertyValue(n);switch(n){case"font-family":{t.ff=i;break}case"font-size":{const r=Number.parseInt(i);if(!Number.isNaN(r)){if(i.endsWith("pt"))t.fs=r;else if(i.endsWith("px")){const s=r*.75;t.fs=s}}break}case"font-style":{i==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{(Number(i)>400||i==="bold")&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(i)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(i)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(i)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const r=new l.ColorKit(i);r.isValid&&(t.cl={rgb:r.toRgbString()});break}case"background-color":{const r=new l.ColorKit(i),s=r.isValid?r.toRgbString():"";s!==I.DEFAULT_BACKGROUND_COLOR_RGB&&s!==I.DEFAULT_BACKGROUND_COLOR_RGBA&&(t.bg={rgb:r.toRgbString()});break}}}}function Na(o){const t=new DOMParser,e=`<x-univer id="univer-root">${o}</x-univer>`;return t.parseFromString(e,"text/html").querySelector("#univer-root")}function yo(o,t){const e=[];for(let n=0,i=o.length;n<i;n++)o[n]===l.DataStreamTreeTokenType.PARAGRAPH&&e.push({startIndex:n});if(t)for(const n of e)t.bullet&&(n.bullet=l.Tools.deepClone(t.bullet)),t.paragraphStyle&&(n.paragraphStyle=l.Tools.deepClone(t.paragraphStyle));return e}const Aa=["color_color","background_background","font-size_fontSize","text-align_textAlign","vertical-align_verticalAlign","font-weight_fontWeight","font-style_fontStyle","font-family_fontFamily","text-decoration_textDecoration","white-space_whiteSpace","word-wrap_wordWrap"],Da=["border-left_borderLeft","border-right_borderRight","border-top_borderTop","border-bottom_borderBottom"];function Di(o,t){const e=o.tagName.toLowerCase();return typeof t=="string"?e===t:Array.isArray(t)?t.some(n=>n===e):t(o)}function Pa(o){o.style.display="none",o.style.width="0",o.style.height="0",o.setAttribute("tabindex","-1"),o.setAttribute("aria-hidden","true"),o.setAttribute("title","hidden iframe")}const Xn=class Xn{constructor(t){R(this,"styleCache",new Map);R(this,"styleRules",[]);R(this,"afterProcessRules",[]);R(this,"htmlElement");R(this,"getCurrentSkeleton");this.getCurrentSkeleton=t.getCurrentSkeleton,this.htmlElement=document.createElement("iframe"),this.htmlElement.style.display="none",document.body.appendChild(this.htmlElement),Pa(this.htmlElement)}static use(t){if(this.pluginList.includes(t))throw new Error(`Univer paste plugin ${t.name} already added`);this.pluginList.push(t)}convert(t){this.htmlElement.contentDocument&&(this.htmlElement.contentDocument.open(),this.htmlElement.contentDocument.write(t),this.htmlElement.contentDocument.close()),t=t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style[\s\S]*?<\/style>/g,"");const e=Xn.pluginList.find(g=>g.checkPasteType(t));e&&(this.styleRules=[...e.stylesRules],this.afterProcessRules=[...e.afterProcessRules]);const n=new l.ObjectMatrix,i=Na(t),r={dataStream:"",textRuns:[]},s=[],a=[],c=t.match(/<table\b[^>]*>([\s\S]*?)<\/table>/gi),u=[];this.process(null,i==null?void 0:i.childNodes,r,u);const{paragraphs:d,dataStream:h,textRuns:m}=r;if(d){const g=d.map(f=>f.startIndex+1);g.unshift(0);for(let f=0;f<g.length;f++){let _;f===g.length-1?_=`${h.substring(g[f])}\r
2
+ `:_=`${h.substring(g[f],g[f+1]-1)}\r
3
+ `;const p=[];m==null||m.forEach(M=>{M.st>=g[f]&&M.ed<=g[f+1]&&p.push({st:M.st-g[f],ed:M.ed-g[f],ts:M.ts})});const v=this._generateDocumentDataModelSnapshot({body:{dataStream:_,textRuns:p,paragraphs:yo(_)}});n.setValue(n.getLength(),0,{v:_,p:v}),s.push({})}}else if(h){const g=`${h}\r
4
+ `,f={dataStream:g,textRuns:m,paragraphs:yo(g)},_=this._generateDocumentDataModelSnapshot({body:f});n.setValue(0,0,{v:h,p:_}),s.push({})}return c&&c.forEach(g=>{const f=n.getDataRange().endRow+1,{cellMatrix:_,rowProperties:p,colProperties:v}=this._parseTable(g);_&&_.forValue((M,b,T)=>{n.setValue(f+M,b,T)}),v&&a.push(...v),s.push(...p)}),{rowProperties:s,colProperties:a,cellMatrix:n}}_parseTable(t){var s,a;const e=new l.ObjectMatrix,n=(s=La(t))!=null?s:[],{rowProperties:i=[]}=Ha(t),r=Va(this.htmlElement,(a=this.getCurrentSkeleton())==null?void 0:a.skeleton);return r&&r.forValue((c,u,d)=>{var g,f,_,p,v,M,b,T,w,y,O,x,A,F,N,L,B,j,z,q,K,$,Q,P;let h=I.handleStringToStyle(void 0,d.style);if((p=(_=(f=(g=d==null?void 0:d.richTextParma)==null?void 0:g.p)==null?void 0:f.body)==null?void 0:_.textRuns)!=null&&p.length){const H=(M=(v=d==null?void 0:d.richTextParma)==null?void 0:v.v)==null?void 0:M.length;for(let k=0;k<((y=(w=(T=(b=d==null?void 0:d.richTextParma)==null?void 0:b.p)==null?void 0:T.body)==null?void 0:w.textRuns)==null?void 0:y.length);k++){const Y=(A=(x=(O=d==null?void 0:d.richTextParma)==null?void 0:O.p)==null?void 0:x.body)==null?void 0:A.textRuns[k];Y.st===0&&Y.ed===H&&(h={...Y.ts,...h},(L=(N=(F=d==null?void 0:d.richTextParma)==null?void 0:F.p)==null?void 0:N.body)==null||L.textRuns.splice(k,1),k--)}((q=(z=(j=(B=d==null?void 0:d.richTextParma)==null?void 0:B.p)==null?void 0:j.body)==null?void 0:z.textRuns)==null?void 0:q.length)===0&&(d.content=(K=d==null?void 0:d.richTextParma)==null?void 0:K.v,delete d.richTextParma)}const m=(P=(Q=($=d==null?void 0:d.richTextParma)==null?void 0:$.p)==null?void 0:Q.body)!=null&&P.textRuns?{v:d.richTextParma.v,p:d.richTextParma.p,s:h,rowSpan:d.rowSpan,colSpan:d.colSpan}:{v:d.content,s:h,rowSpan:d.rowSpan,colSpan:d.colSpan};e.setValue(c,u,m)}),{rowProperties:i,colProperties:n,cellMatrix:e}}_generateDocumentDataModelSnapshot(t){var a;const e=this.getCurrentSkeleton();if(e==null)return null;const{skeleton:n}=e,i=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...i==null?void 0:i.getSnapshot(),...t};return i==null||i.reset(s),i==null?void 0:i.getSnapshot()}process(t,e,n,i){var r,s;for(const a of e)if(a.nodeName.toLowerCase()==="table")i.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let u;t&&this.styleCache.has(t)&&(u=this.styleCache.get(t));const d={dataStream:"",textRuns:[]};n.dataStream+=c,d.dataStream+=c,u&&Object.getOwnPropertyNames(u).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:u}),d.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:u}))}else if(a.nodeType===Node.ELEMENT_NODE){if(a.nodeName==="STYLE")continue;const c=t?this.styleCache.get(t):{},u=this.styleRules.find(({filter:g})=>Di(a,g)),d=u?u.getStyle(a):pr(a);this.styleCache.set(a,{...c,...d});const{childNodes:h}=a;this.process(a,h,n,i);const m=this.afterProcessRules.find(({filter:g})=>Di(a,g));m&&m.handler(n,a)}}dispose(){document.body.removeChild(this.htmlElement)}};R(Xn,"pluginList",[]);let wt=Xn;function Ha(o){const t=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=o.matchAll(t);if(!e)return{rowProperties:[],rowCount:0};const i=Array.from(e).map(r=>Cr(r[1]));return{rowProperties:i,rowCount:i.length}}function Cr(o){if(!o)return{};const t={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let n;for(;(n=e.exec(o))!==null;){const[,i,,r,s]=n,a=r!==void 0?r:s;t[i]=a}return t}function La(o){const t=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=o.match(t),n=/<col([\s\S]*?)>/g;let i;return e!=null&&e[2]?i=e[2].matchAll(n):i=o.matchAll(n),i?Array.from(i).map(r=>Cr(r[1])):null}function Ua(o){const t={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&#39;":"'","&nbsp;":" "};return o.replace(/&lt;|&gt;|&amp;|&quot;|&#39;|&nbsp;|<br>/g,e=>t[e])}function ge(o,t){if(!o)return"";const e=/border(-top|-right|-bottom|-left)?\s*:\s*([^;]+);/g,n={},i=o.replace(e,(s,a,c)=>{const u=`border${a||""}`;return n[u]=c.trim(),""});let r=t.map(s=>s==="border"&&n[s]?`border: ${n[s]};`:n[s]?`${s}: ${n[s]};`:"").filter(s=>s).join(" ");return r+=` ${i.trim()}`,r.trim()}function Va(o,t){var r,s,a;const e=new l.ObjectMatrix,n=(r=o.contentDocument)==null?void 0:r.querySelector("table");if(!n)return e;const i=n==null?void 0:n.querySelectorAll("tr");for(let c=0;c<i.length;c++){const d=i[c].querySelectorAll("td, th");let h=0;for(let m=0;m<d.length;){const g=d[m];let f="";const _=Number(g.getAttribute("rowSpan"))||1,p=Number(g.getAttribute("colSpan"))||1;if(f=Ba(g),_>1&&p>1&&!f.includes("border-top")&&!f.includes("border-left")){const T=Pi((s=e.getValue(c-1,m))==null?void 0:s.style,"border-bottom"),w=Pi((a=e.getValue(c,m-1))==null?void 0:a.style,"border-right");T&&(f+=`border-top:${T};`),w&&(f+=`border-left:${w};`)}const{cellText:v,cellRichStyle:M}=Fa(g,t),b=_>1||p>1?{rowSpan:_,colSpan:p,content:v,style:f,richTextParma:{p:M,v}}:{content:v,style:f,richTextParma:{p:M,v}};if(e.getValue(c,h)){h+=1;continue}else _>1||p>1?ka(e,f,b,{colSpan:p,rowSpan:_,rowIndex:c,colIndex:m,colSetValueIndex:h}):e.setValue(c,h,b),h+=p,m++}}return e}function vr(o,t,e,n=new Map){var i;for(const r of t)if(r.nodeType===Node.TEXT_NODE){const s=(i=r.nodeValue)==null?void 0:i.replace(/[\r\n]/g,"");let a;o&&n.has(o)&&(a=n.get(o)),e.dataStream+=s,a&&Object.getOwnPropertyNames(a).length&&e.textRuns.push({st:e.dataStream.length-s.length,ed:e.dataStream.length,ts:a})}else{if(r.nodeType===Node.COMMENT_NODE||r.nodeName==="STYLE")continue;if(r.nodeType===Node.ELEMENT_NODE){const s=o?n.get(o):{},a=getComputedStyle(r),c=pr(r,a);n.set(r,{...s,...c});const{childNodes:u}=r;vr(r,u,e,n)}}}function Pi(o,t){if(!o||!t)return null;const e=new RegExp(`(${t}\\s*:\\s*[^;]+);`,"i"),n=o.match(e);return n?n[1]:null}function Ba(o){let t="";const e=o.getAttribute("class"),n=getComputedStyle(o);if(e)Aa.forEach(i=>{const[r,s]=i.split("_"),a=n.getPropertyValue(r)||n[s];a&&(t+=`${r}:${a};`)});else{const r=/<\w+\s+[^>]*?style="([^"]*)"/gi.exec(o.outerHTML);r!=null&&r[1]&&(t=r[1])}return Da.forEach(i=>{const[r,s]=i.split("_"),a=n.getPropertyValue(r)||n[s];a&&(t+=`${r}:${a};`)}),t}function Fa(o,t){var r;let e="",n;if(/<[^>]+>/.test(o.innerHTML)&&t){const s={dataStream:"",textRuns:[]};vr(null,o.childNodes,s);const a=(r=t.getBlankCellDocumentModel())==null?void 0:r.documentModel,c=a==null?void 0:a.getSnapshot(),u=`${s.dataStream}\r
5
+ `,d={...c,body:{dataStream:u,textRuns:s.textRuns,paragraphs:yo(u)}};a==null||a.reset(d),n=a==null?void 0:a.getSnapshot(),e=s.dataStream}else e=Ua(o.innerHTML.replace(/[\r\n]/g,""));return{cellText:e,cellRichStyle:n}}function ka(o,t,e,n){const{rowSpan:i,colSpan:r,rowIndex:s,colSetValueIndex:a}=n;if(i===1){for(let c=a;c<a+r;c++)o.setValue(s,c,{style:ge(t,["border-top","border-bottom"])});o.setValue(s,a+r-1,{style:ge(t,["border-top","border-bottom","border-right"])}),o.setValue(s,a,{...e,style:ge(t,["border-top","border-bottom","border-left"])})}else if(r===1){for(let c=s;c<s+i;c++)o.setValue(c,a,{style:ge(t,["border-left","border-right"])});o.setValue(s+i-1,a,{style:ge(t,["border-left","border-right","border-bottom"])}),o.setValue(s,a,{...e,style:ge(t,["border-left","border-right","border-top"])})}else{for(let c=a;c<a+r;c++)o.setValue(s,c,{style:ge(t,["border-top"])}),o.setValue(s+i-1,c,{style:ge(t,["border-bottom"])});for(let c=s;c<s+i;c++)o.setValue(c,a,{style:ge(t,["border-left"])}),o.setValue(c,a+r-1,{style:ge(t,["border-right"])});o.setValue(s+i-1,a,{style:ge(t,["border-left","border-bottom"])}),o.setValue(s,a+r-1,{style:ge(t,["border-right","border-top"])}),o.setValue(s+i-1,a+r-1,{style:ge(t,["border-right","border-bottom"])}),o.setValue(s,a,{...e,style:ge(t,["border-top","border-left"])});for(let c=s;c<s+i;c++)for(let u=a;u<a+r;u++)o.getValue(c,u)||o.setValue(c,u,{style:ge(t,[])})}}var et=(o=>(o.COPY="COPY",o.CUT="CUT",o))(et||{});function Wa(o,t,e,n,i){const r=e.map(u=>{var d;return(d=u.onCopyRow)==null?void 0:d.call(u,o)}).filter(u=>!!u),s=Ko(r),a=qo(s),c=t.map(u=>{if(!i.has(`${o}-${u}`)){const d=n.getValue(o,u);if(d!=null&&d.rowSpan&&(d!=null&&d.colSpan))for(let h=o;h<o+d.rowSpan;h++)for(let m=u;m<u+d.colSpan;m++)i.add(`${h}-${m}`);return ja(o,u,e,n)}return null}).filter(u=>!!u).join("");return`<tr${a}>${c}</tr>`}function ja(o,t,e,n){const i=n.getValue(o,t),r=e.map(u=>{var d;return(d=u.onCopyCellStyle)==null?void 0:d.call(u,o,t,i==null?void 0:i.rowSpan,i==null?void 0:i.colSpan)}).filter(u=>!!u),s=Ko(r),a=qo(s),c=e.reduce((u,d)=>{var h;return u||((h=d.onCopyCellContent)==null?void 0:h.call(d,o,t))||""},"");return`<td${a}>${c}</td>`}function $a(o,t){return`<colgroup>${o.map(n=>{const i=t.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),r=Ko(i);return`<col ${qo(r)}>`}).join("")}</colgroup>`}function Ko(o){return o.reduce((t,e)=>(Object.keys(e).forEach(i=>{t[i]?t[i]+=`;${e[i]}`:t[i]=e[i]}),t),{})}function qo(o){return Object.keys(o).reduce((t,e)=>(t+=` ${e}="${o[e]}"`,t),"")}function za(o,t){const e=[];for(let n=o;n<=t;n++)e.push(n);return e}class Ya{convert(t,e,n){const{startColumn:i,endColumn:r}=e,s=$a(za(i,r),n),a=[],c=new Set,{startRow:u,endRow:d,startColumn:h,endColumn:m}=t.getDataRange();for(let f=u;f<=d;f++){const _=Array.from({length:m-h+1},(p,v)=>h+v);a.push(Wa(f,_,n,t,c))}return`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
6
+ <tbody>${a.join("")}</tbody></table>`}}const Xa=(o,t,e=!1)=>{const n=h=>h.endRow-h.startRow+1,i=h=>h.endColumn-h.startColumn+1,r=n(t)%n(o),s=i(t)%i(o),a={startRow:0,endRow:n(o)-1,startColumn:0,endColumn:i(o)-1},c=Math.floor(n(t)/n(o)),u=Math.floor(i(t)/i(o)),d=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=u;m++){const g=n(o)*(h-1),f=i(o)*(m-1),_={startRow:g+t.startRow,endRow:g+t.startRow,startColumn:f+t.startColumn,endColumn:f+t.startColumn};d.push({repeatRelativeRange:a,startRange:_})}else if(!r&&s&&!e)for(let h=1;h<=c;h++){const m=n(o)*(h-1),g=0,f={startRow:m+t.startRow,endRow:m+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};d.push({repeatRelativeRange:a,startRange:f})}else if(r&&!s&&!e)for(let h=1;h<=u;h++){const g=i(o)*(h-1),f={startRow:0+t.startRow,endRow:0+t.startRow,startColumn:g+t.startColumn,endColumn:g+t.startColumn};d.push({repeatRelativeRange:a,startRange:f})}else{const h={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};d.push({startRange:h,repeatRelativeRange:a})}return d};async function Ga(o){return o?/<td[^>]*class=".*?xl.*?"[^>]*>.*?<\/td>/.test(o):!1}function Za(...o){if(o.length===1)return o[0];const t=new l.ObjectMatrix;return o.forEach(e=>{e&&new l.ObjectMatrix(e).forValue((i,r,s)=>{t.setValue(i,r,{...t.getValue(i,r),...s})})}),t.getMatrix()}function Ka(o,t){return o.id===t.id&&o.params.unitId===t.params.unitId&&o.params.subUnitId===t.params.subUnitId}function Oo(o){const t=[];for(let e=0;e<o.length;){let n=1;if(o[e].id===S.SetRangeValuesMutation.id){const i=o[e],r=[i];for(;e+n<o.length&&Ka(i,o[e+n]);)r.push(o[e+n]),n+=1;const s=Za(...r.map(a=>a.params.cellValue||{}));t.push({...i,params:{...i.params,cellValue:s}})}else t.push(o[e]);e+=n}return t}function lo(o,t){const{startRow:e,endRow:n,startColumn:i,endColumn:r}=o;for(let s=e;s<=n;s++)for(let a=i;a<=r;a++)if(t.rows.includes(s)&&t.cols.includes(a))return!0}function Hi(o,t){const{startRow:e,endRow:n,startColumn:i,endColumn:r}=t;for(let s=e;s<=n;s++)if(!o.rows.includes(s))return!1;for(let s=i;s<=r;s++)if(!o.cols.includes(s))return!1;return!0}var qa=Object.defineProperty,Qa=Object.getOwnPropertyDescriptor,Ja=(o,t,e,n)=>{for(var i=n>1?void 0:n?Qa(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&qa(t,e,i),i},ve=(o,t)=>(e,n)=>t(e,n,o);const fe={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};wt.use(Go.PastePluginWord);wt.use(Go.PastePluginLark);wt.use(Go.PastePluginUniver);const Ot=D.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends l.Disposable{constructor(e,n,i,r,s,a,c,u,d,h,m,g,f){super();R(this,"_clipboardHooks",[]);R(this,"_clipboardHooks$",new U.BehaviorSubject([]));R(this,"clipboardHooks$",this._clipboardHooks$.asObservable());R(this,"_htmlToUSM");R(this,"_usmToHtml");R(this,"_copyContentCache");R(this,"_copyMarkId",null);this._logService=e,this._univerInstanceService=n,this._selectionManagerService=i,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=u,this._notificationService=d,this._platformService=h,this._localeService=m,this._errorService=g,this._injector=f,this._htmlToUSM=new wt({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new Ya,this._copyContentCache=new Oa,this.disposeWithMe(this._htmlToUSM)}copyContentCache(){return this._copyContentCache}generateCopyContent(e,n,i){const r=this._clipboardHooks;r.forEach(a=>{var c;return(c=a.onBeforeCopy)==null?void 0:c.call(a,e,n,i)});const s=this._generateCopyContent(e,n,i,r);return r.forEach(a=>{var c;return(c=a.onAfterCopy)==null?void 0:c.call(a)}),s}async copy(e=et.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),r=i.getActiveSheet(),s=this.generateCopyContent(i.getUnitId(),r.getSheetId(),n.range);if(!s)return!1;const{html:a,plain:c,matrixFragment:u,copyId:d,discreteRange:h}=s;this._copyContentCache.set(d,{unitId:i.getUnitId(),subUnitId:r.getSheetId(),range:h,matrix:u,copyType:e}),await this._clipboardInterfaceService.write(c,a),this._markSelectionService.removeAllShapes();const m=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:m}),!0}async cut(){return this.copy(et.CUT)}async paste(e,n=fe.DEFAULT_PASTE){const i=e.types,r=i.indexOf(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=i.indexOf(I.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(I.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._platformService.isWindows&&await Ga(s)?(this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),!1):this._pasteHTML(s,n):r?this._pastePlainText(r,n):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}legacyPaste(e,n){return e?this._pasteHTML(e,fe.DEFAULT_PASTE):n?this._pastePlainText(n,fe.DEFAULT_PASTE):Promise.resolve(!1)}addClipboardHook(e){if(this._clipboardHooks.findIndex(i=>i.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(i=>{const r=i.priority||0;return(e.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),l.toDisposable(()=>{const i=this._clipboardHooks.indexOf(e);i>-1&&(this._clipboardHooks.splice(i,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,n,i,r){const s=this._univerInstanceService.getUniverSheetInstance(e),a=s==null?void 0:s.getSheetBySheetId(n);if(!s||!a)return null;const c=r.reduce((T,w)=>{var O;const y=(O=w.getFilteredOutRows)==null?void 0:O.call(w,i);return y==null||y.forEach(x=>T.add(x)),T},new Set),{startColumn:u,startRow:d,endColumn:h,endRow:m}=i,g=a.getMatrixWithMergedCells(d,u,m,h,!0),f=new l.ObjectMatrix;let _=d;const p={rows:[],cols:[]};for(let T=d;T<=m;T++)if(!c.has(T)){p.rows.push(T);for(let w=u;w<=h;w++){const y=g.getValue(T,w);y?f.setValue(_-d,w-u,{...Li(),...l.Tools.deepClone(y)}):f.setValue(_-d,w-u,Li())}_+=1}for(let T=u;T<=h;T++)p.cols.push(T);let v=this._usmToHtml.convert(g,i,r);const M=el(f),b=Ea();return v=v.replace(/(<[a-z]+)/,(T,w)=>`${w} data-copy-id="${b}"`),{copyId:b,plain:M,html:v,matrixFragment:f,discreteRange:p}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(e,n){const i=this._getPastingTarget();if(!i.selection)return!1;const r={get:this._injector.get.bind(this._injector)},s=Rt(i.selection.range,r,i.unitId,i.subUnitId);if(!s)return!1;const{unitId:a,subUnitId:c}=i,u=this._clipboardHooks,d=[];if(u.some(_=>{var p;return d.push(_)&&((p=_.onBeforePaste)==null?void 0:p.call(_,{unitId:a,subUnitId:c,range:s}))===!1}))return d.forEach(_=>{var p;return(p=_.onAfterPaste)==null?void 0:p.call(_,!1)}),!1;const m=[],g=[];d.forEach(_=>{var v;const p=(v=_.onPastePlainText)==null?void 0:v.call(_,{unitId:a,subUnitId:c,range:s},e,{pasteType:n});p&&(m.push(...p.redos),g.push(...p.undos))});const f=m.every(_=>this._commandService.executeCommand(_.id,_.params));return f&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:g,redoMutations:m}),f}async _pasteHTML(e,n){const i=ya(e);return i&&this._copyContentCache.get(i)?this._pasteInternal(i,n):this._pasteExternal(e,n)}async _pasteExternal(e,n){var d;const{rowProperties:i,colProperties:r,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const a=this._getPastedRange(s);if(!a)return!1;const c=(d=this._univerInstanceService.getUniverSheetInstance(a.unitId))==null?void 0:d.getSheetBySheetId(a.subUnitId);if(!c)return!1;const u=c==null?void 0:c.getMergeData();return u&&u.some(m=>lo(m,a.pastedRange)&&!Hi(a.pastedRange,m))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:i,colProperties:r,cellMatrix:s},a,n)}async _pasteInternal(e,n){var T,w;const i=l.Tools.deepClone(this._copyContentCache.get(e)),{range:r,matrix:s,unitId:a,subUnitId:c}=i||{};if(!s||!i||!r||!a||!c||!s||!i)return!1;const u=(T=this._univerInstanceService.getUniverSheetInstance(a))==null?void 0:T.getStyles();s.forValue((y,O,x)=>{if(typeof x.s=="string"){const A=l.Tools.deepClone(x);A.s=u==null?void 0:u.getStyleByCell(x),s.setValue(y,O,A)}});const d=this._getPastedRange(s);if(!d)return!1;const h=(w=this._univerInstanceService.getUniverSheetInstance(d.unitId))==null?void 0:w.getSheetBySheetId(d.subUnitId);if(!h)return!1;const m=h==null?void 0:h.getMergeData();if(m&&m.some(O=>lo(O,d.pastedRange)&&!Hi(d.pastedRange,O)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const g=h.getColumnManager(),f=h.getRowManager(),_=h.getConfig().defaultColumnWidth,p=h.getConfig().defaultRowHeight,v=[],M=[];if(r.cols.forEach(y=>{const O=g.getColumnOrCreate(y);v.push({width:`${O.w||_}`})}),r.rows.forEach(y=>{const O=f.getRowOrCreate(y);M.push({height:`${O.ah||O.h||p}`})}),i.copyType===et.CUT){const y=d.pastedRange.rows[0],O=r.rows[r.rows.length-1]-r.rows[0]+y;d.pastedRange.rows=Array.from(new Array(O+1).keys()).slice(y)}const b=this._pasteUSM({cellMatrix:s,colProperties:v,rowProperties:M},d,n,{range:r,unitId:i.unitId,subUnitId:i.subUnitId,copyType:i.copyType,copyId:e});return i.copyType===et.CUT&&(this._copyContentCache.set(e,{...i,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),b}_pasteUSM(e,n,i,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=e,{unitId:u,subUnitId:d,pastedRange:h}=n,m=h.cols.length,g=this._clipboardHooks,f=[];if(g.some(O=>{var x;return f.push(O)&&((x=O.onBeforePaste)==null?void 0:x.call(O,{unitId:u,subUnitId:d,range:h}))===!1}))return f.forEach(O=>{var x;return(x=O.onAfterPaste)==null?void 0:x.call(O,!1)}),!1;if(!c)return!1;const p=r?{unitId:r.unitId,subUnitId:r.subUnitId,range:r.range}:null,v={copyType:(r==null?void 0:r.copyType)||et.COPY,copyId:r==null?void 0:r.copyId,pasteType:i};let M=[],b=[];f.filter(O=>!O.specialPasteInfo&&O.id!==fe.DEFAULT_PASTE||i===O.id).forEach(O=>{var F,N,L;if(s){const B=(F=O.onPasteRows)==null?void 0:F.call(O,{range:h,unitId:u,subUnitId:d},s,{pasteType:i});B&&(M.push(...B.redos),b.push(...B.undos))}const x=(N=O.onPasteColumns)==null?void 0:N.call(O,{range:h,unitId:u,subUnitId:d},a||new Array(m).map(()=>({})),{pasteType:i});x&&(M.push(...x.redos),b.push(...x.undos));const A=(L=O.onPasteCells)==null?void 0:L.call(O,p,{range:h,unitId:u,subUnitId:d},c,v);A&&(M.push(...A.redos),b.push(...A.undos))});const w=this._getSetSelectionOperation(u,d,h,c);w&&M.push(w),M=Oo(M),b=Oo(b),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:b,redoMutationsInfo:M});const y=M.every(O=>this._commandService.executeCommand(O.id,O.params));return y&&this._undoRedoService.pushUndoRedo({unitID:u,undoMutations:b,redoMutations:M}),y}_getSetSelectionOperation(e,n,i,r){var b;const s=(b=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:b.getSheetBySheetId(n);if(!s)return null;const{rows:a,cols:c}=i,u=a[0],d=c[0],h=a[a.length-1],m=c[c.length-1],g={startRow:u,endRow:u,startColumn:d,endColumn:d},f=S.getPrimaryForRange(g,s),_=r.getValue(0,0),p=(_==null?void 0:_.rowSpan)||1,v=(_==null?void 0:_.colSpan)||1;if(p>1||v>1){const T={startRow:u,endRow:u+p-1,startColumn:d,endColumn:d+v-1};f.startRow=T.startRow,f.endRow=T.endRow,f.startColumn=T.startColumn,f.endColumn=T.endColumn,f.isMerged=!0,f.isMergedMainCell=!0}const M={unitId:e,subUnitId:n,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:u,endRow:h,startColumn:d,endColumn:m},primary:f,style:null}]};return{id:S.SetSelectionsOperation.id,params:M}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=e.getActiveSheet(),i=this._selectionManagerService.getLast();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),selection:i}}_transformPastedData(e,n,i){const r=this._getPastingTarget(),{selection:s,unitId:a,subUnitId:c}=r;if(!s)return null;const u={get:this._injector.get.bind(this._injector)},d=Rt(s.range,u,a,c);if(!d)return null;const{ranges:[h],mapFunc:m}=tn([d]),{startRow:g,startColumn:f,endRow:_,endColumn:p}=h,v=_-g+1,M=p-f+1,b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),T=b==null?void 0:b.getActiveSheet();if(!T)return null;const y=T.getMergeData().filter(L=>d.rows.includes(L.startRow)&&d.cols.includes(L.startColumn)),O=y[0];let x=0,A=0,F=0,N=0;if(O&&(x=O.startRow,A=O.startColumn,F=O.endRow,N=O.endColumn),v%e===0&&M%n===0)if(y.length>0&&(v!==e||M!==n))if(x===d.rows[0]&&A===d.cols[0]&&F===d.rows[v-1]&&N===d.cols[M-1])if(rl(i))for(let B=0;B<v;B++)for(let j=0;j<M;j++){const z=i.getValue(B%e,j%n);z&&i.setValue(B,j,z)}else i.forValue((B,j,z)=>{z.s=null,delete z.colSpan,delete z.rowSpan});else for(let L=0;L<v;L++)for(let B=0;B<M;B++){const j=i.getValue(L%e,B%n);j&&i.setValue(L,B,j)}else for(let L=0;L<v;L++)for(let B=0;B<M;B++){const j=i.getValue(L%e,B%n);j&&i.setValue(L,B,j)}else if(y.length>0){const{row:L,col:B}=m(g,f);if(this._topLeftCellsMatch(e,n,{topRow:L,leftCol:B})){const z=this._expandOrShrinkRowsCols(a,c,d,n,e);d.rows=z.rows,d.cols=z.cols}else{if(_>O.endRow||p>O.endColumn)return null;i.forValue((z,q,K)=>{K.s=null,delete K.colSpan,delete K.rowSpan})}}else{const L=this._expandOrShrinkRowsCols(a,c,d,n,e);d.rows=L.rows,d.cols=L.cols}return{pastedRange:d,unitId:a,subUnitId:c}}_getPastedRange(e){var T;const n=this._getPastingTarget(),{selection:i,unitId:r,subUnitId:s}=n;if(!i)return null;const a={get:this._injector.get.bind(this._injector)},c=Rt(i.range,a,r,s);if(!c)return null;const{startColumn:u,endColumn:d,startRow:h,endRow:m}=e.getDataRange(),g=m-h+1,f=d-u+1,_=c.rows.length,p=c.cols.length,v=(T=this._univerInstanceService.getUniverSheetInstance(r))==null?void 0:T.getSheetBySheetId(s);if(!v)return null;const M=v==null?void 0:v.getMergeData();if(_%g===0&&p%f===0&&!(M==null?void 0:M.some(y=>lo(y,c)))){for(let y=0;y<_;y++)for(let O=0;O<p;O++){const x=e.getValue(y%g,O%f);x&&e.setValue(y,O,x)}return{pastedRange:c,unitId:r,subUnitId:s}}const b=this._expandOrShrinkRowsCols(r,s,c,f,g);return c.rows=b.rows,c.cols=b.cols,{pastedRange:c,unitId:r,subUnitId:s}}_expandOrShrinkRowsCols(e,n,i,r,s){const{rows:a,cols:c}=i,u=this._univerInstanceService.getUniverSheetInstance(e),d=u==null?void 0:u.getSheetBySheetId(n);let h,m;if(a.length>=s)h=a.slice(0,s);else{h=a.slice(0);let g=a[a.length-1]+1;for(;h.length<s;)d.getRowFiltered(g)||h.push(g),g++}if(c.length>=r)m=c.slice(0,r);else{m=c.slice(0);let g=c[c.length-1]+1;for(;m.length<r;)m.push(g),g++}return{rows:h,cols:m}}_topLeftCellsMatch(e,n,i){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r==null?void 0:r.getActiveSheet();if(!s)return!1;const{topRow:a,leftCol:c}=i,u=ol(a+e-1,c,c+n-1,s),d=il(c+n-1,a,a+e-1,s);return!u&&!d}};exports.SheetClipboardService=Ja([ve(0,l.ILogService),ve(1,l.IUniverInstanceService),ve(2,D.Inject(S.SelectionManagerService)),ve(3,I.IClipboardInterfaceService),ve(4,l.IUndoRedoService),ve(5,l.ICommandService),ve(6,nn),ve(7,D.Inject(exports.SheetSkeletonManagerService)),ve(8,I.INotificationService),ve(9,I.IPlatformService),ve(10,D.Inject(l.LocaleService)),ve(11,D.Inject(l.ErrorService)),ve(12,D.Inject(D.Injector))],exports.SheetClipboardService);function el(o){let t="";const e=o.getLength();return o.forRow((n,i)=>{const r=[];i.forEach(s=>{const a=o.getValue(n,s);if(a){const c=tl(a);r.push(c)}}),t+=r.join(" "),n!==e-1&&(t+=`
7
+ `)}),t}function tl(o){const t=l.extractPureTextFromCell(o);return nl((t==null?void 0:t.toString())||"")}const nl=o=>o.replace(/&/g,"&amp;").replace(/\uFEFF/g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;");function ol(o,t,e,n){return n.getMergeData().some(i=>i.startRow<=o&&o<i.endRow&&t<=i.startColumn&&i.startColumn<=e)}function il(o,t,e,n){return n.getMergeData().some(i=>i.startColumn<=o&&o<i.endColumn&&t<=i.startRow&&i.startRow<=e)}function rl(o){let t=0;return o.forValue((e,n,i)=>{if(i&&t++,t>1)return!1}),t>1}function Li(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Qo=998,Ir={id:I.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:Qo,preconditions:Zo,handler:async o=>o.get(Ot).copy()},sl={id:I.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:Qo,preconditions:Zo,handler:async o=>o.get(Ot).cut()},xt={id:I.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Qo,preconditions:Zo,handler:async(o,t)=>{const n=await o.get(I.IClipboardInterfaceService).read(),i=o.get(Ot);return n.length!==0?i.paste(n[0],t==null?void 0:t.value):!1}},Rr={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_VALUE})},Mr={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_FORMAT})},br={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_COL_WIDTH})},Tr={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async o=>o.get(l.ICommandService).executeCommand(xt.id,{value:fe.SPECIAL_PASTE_BESIDES_BORDER})};var Zn=(o=>(o.MergeAll="mergeAll",o.MergeVertical="mergeVertical",o.MergeHorizontal="mergeHorizontal",o))(Zn||{});function tt(o,t,e,n,i=!0,r=1,s=!0){let a={...o};n==null&&(n={startRow:0,endRow:e.getRowCount()-1,startColumn:0,endColumn:e.getColumnCount()-1});let c;switch(t){case l.Direction.UP:for(c=o.startRow-r;c>-1&&!e.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,i&&(a=tt(a,l.Direction.LEFT,e,n,!1)));break;case l.Direction.DOWN:for(c=o.endRow+r;c<e.getRowCount()&&!e.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,i&&(a=tt(a,l.Direction.RIGHT,e,n,!1)));break;case l.Direction.LEFT:for(c=o.startColumn-r;c>-1&&!e.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,i&&(a=tt(a,l.Direction.UP,e,n,!1)));break;case l.Direction.RIGHT:for(c=o.endColumn+r;c<e.getColumnCount()&&!e.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,i&&(a=tt(a,l.Direction.DOWN,e,n,!1)));break}return a}function Jo(o,t,e){const n={...o},{startRow:i,startColumn:r,endRow:s,endColumn:a}=Kt(o,t,e);let c=Bt(e,i,r,s,a).hasValue,u=!0,d=!0;for(;d;){if(l.Direction.UP===t){let h=n.startRow-1;for(;h>-1&&!e.getRowVisible(h);)h-=1;if(h===-1){d=!1;break}const{hasValue:m,matrix:g}=Bt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!u){d=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue(_=>{f=Math.min(_,f)}),n.startRow=f}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){d=!1;break}c=m,u=!1}}if(l.Direction.DOWN===t){let h=n.endRow+1;for(;h<e.getRowCount()&&!e.getRowVisible(h);)h+=1;if(h===e.getRowCount()){d=!1;break}const{hasValue:m,matrix:g}=Bt(e,h,n.startColumn,h,n.endColumn);if(c&&!m&&!u){d=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((_,p,v)=>{f=Math.max(_+(v.rowSpan||1)-1,f)}),n.endRow=f}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){d=!1;break}c=m,u=!1}}if(l.Direction.LEFT===t){let h=n.startColumn-1;for(;h>-1&&!e.getColVisible(h);)h-=1;if(h===-1){d=!1;break}const{hasValue:m,matrix:g}=Bt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!u){d=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((_,p)=>{f=Math.min(p,f)}),n.startColumn=f}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){d=!1;break}c=m,u=!1}}if(l.Direction.RIGHT===t){let h=n.endColumn+1;for(;h<e.getColumnCount()&&!e.getColVisible(h);)h+=1;if(h===e.getColumnCount()){d=!1;break}const{hasValue:m,matrix:g}=Bt(e,n.startRow,h,n.endRow,h);if(c&&!m&&!u){d=!1;break}else{if(g.getLength()!==0){let f=h;g.forValue((_,p,v)=>{f=Math.max(p+(v.colSpan||1)-1,f)}),n.endColumn=f}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){d=!1;break}c=m,u=!1}}}return S.alignToMergedCellsBorders(n,e,!0)}function wr(o,t,e){return tt(o,t,e,void 0,!1,1,!1)}function al(o,t,e){const n=Jo(o,t,e);return S.alignToMergedCellsBorders(l.Rectangle.union(n,o),e,!0)}function ll(o,t,e){const n=wr(o,t,e),i={startRow:Math.min(o.startRow,n.startRow),startColumn:Math.min(o.startColumn,n.startColumn),endRow:Math.max(o.endRow,n.endRow),endColumn:Math.max(o.endColumn,n.endColumn)};return S.alignToMergedCellsBorders(l.Rectangle.union(o,i),e)}function cl(o,t,e,n){const i=l.getReverseDirection(e),r=Jo(Kt(o,i,n),e,n);return e===l.Direction.UP&&r.startRow<=o.startRow?S.alignToMergedCellsBorders({...t,startColumn:o.startColumn,endColumn:o.endColumn},n,!0):e===l.Direction.DOWN&&r.endRow>=o.endRow?S.alignToMergedCellsBorders({...t,startColumn:o.startColumn,endColumn:o.endColumn},n,!0):e===l.Direction.LEFT&&r.startColumn<=o.startColumn?S.alignToMergedCellsBorders({...t,startRow:o.startRow,endRow:o.endRow},n,!0):e===l.Direction.RIGHT&&r.endColumn>=o.endColumn?S.alignToMergedCellsBorders({...t,startRow:o.startRow,endRow:o.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(t),r)}function dl(o,t,e){const n=l.getReverseDirection(t),i=Kt(o,n,e),r=Kt(o,t,e),s=wr(i,t,e);return S.alignToMergedCellsBorders(l.Rectangle.union(r,s),e,!1)}function Er(o,t,e){const{left:n,right:i,up:r,down:s}=t,a=e.getMaxRows(),c=e.getMaxColumns();let u=!0;const d={...o};for(;u;){if(u=!1,r&&d.startRow!==0){const h=d.startRow-1;e.getMatrixWithMergedCells(h,d.startColumn,h,d.endColumn).forValue((g,f,_)=>{jt(_)&&(d.startRow=Math.min(g,d.startRow),d.startColumn=Math.min(f,d.startColumn),d.endColumn=Math.max(f,d.endColumn),u=!0)})}if(s&&d.endRow!==a-1){const h=d.endRow+1;e.getMatrixWithMergedCells(h,d.startColumn,h,d.endColumn).forValue((g,f,_)=>{jt(_)&&(d.endRow=Math.max(g+(_.rowSpan!==void 0?_.rowSpan-1:0),d.endRow),d.startColumn=Math.min(f,d.startColumn),d.endColumn=Math.max(f,d.endColumn),u=!0)})}if(n&&d.startColumn!==0){const h=d.startColumn-1;e.getMatrixWithMergedCells(d.startRow,h,d.endRow,h).forValue((g,f,_)=>{jt(_)&&(d.startColumn=Math.min(f,d.startColumn),d.startRow=Math.min(g,d.startRow),d.endRow=Math.max(g,d.endRow),u=!0)})}if(i&&d.endColumn!==c-1){const h=d.endColumn+1;e.getMatrixWithMergedCells(d.startRow,h,d.endRow,h).forValue((g,f,_)=>{jt(_)&&(d.endColumn=Math.max(f+(_.colSpan!==void 0?_.colSpan-1:0),d.endColumn),d.startRow=Math.min(g,d.startRow),d.endRow=Math.max(g,d.endRow),u=!0)})}}return d}function Ui(o){return{startRow:0,startColumn:0,endRow:o.getRowCount()-1,endColumn:o.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL}}function Kt(o,t,e){let n;switch(t){case l.Direction.UP:n={startRow:o.startRow,startColumn:o.startColumn,endRow:o.startRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:o.endRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:o.startRow,startColumn:o.endColumn,endRow:o.endRow,endColumn:o.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return S.alignToMergedCellsBorders(n,e,!1)}function Bt(o,t,e,n,i){let r=!1;const s=o.getMatrixWithMergedCells(t,e,n,i).forValue((a,c,u)=>{if(jt(u))return r=!0,!1});return{hasValue:r,matrix:s}}function xo(o,t,e){const n=l.Rectangle.clone(o);if(t==null)return n;switch(e){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=t.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=t.actualRow;break}return n}function ul(o,t,e){const{primary:n,range:i}=o,r=l.Rectangle.clone(i);switch(t){case l.Direction.UP:case l.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=Kt(r,t,e);switch(t){case l.Direction.DOWN:return i.startRow<s.startRow;case l.Direction.UP:return i.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<i.endColumn;case l.Direction.RIGHT:return s.startColumn>i.startColumn}}function yr(o,t){let e=o[0].startRow,n=o[0].endRow;o.forEach(r=>{const{startRow:s,endRow:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const i=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startRow:s,endRow:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)i[c-e]=!0}),o.every(r=>{const{startRow:s,endRow:a}=r;for(let c=s;c<=a;c++)if(!i[c-e])return!1;return!0})}function Or(o,t){let e=o[0].startColumn,n=o[0].endColumn;o.forEach(r=>{const{startColumn:s,endColumn:a}=r;e=Math.min(e,s),n=Math.max(n,a)});const i=new Array(n-e+1).fill(!1);return t.forEach(r=>{const{startColumn:s,endColumn:a}=r;for(let c=Math.max(s,e);c<=Math.min(a,n);c++)i[c-e]=!0}),o.every(r=>{const{startColumn:s,endColumn:a}=r;for(let c=s;c<=a;c++)if(!i[c-e])return!1;return!0})}function ei(o,t){return t?o==="mergeAll"?t.filter(e=>!(e.startRow===e.endRow&&e.startColumn===e.endColumn)):o==="mergeVertical"?t.filter(e=>e.startRow!==e.endRow):o==="mergeHorizontal"?t.filter(e=>e.startColumn!==e.endColumn):t:null}function jt(o){return o.v!==void 0&&o.v!==null&&o.v!==""||o.p!==void 0}var hl=Object.defineProperty,ml=Object.getOwnPropertyDescriptor,gl=(o,t,e,n)=>{for(var i=n>1?void 0:n?ml(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&hl(t,e,i),i},Vi=(o,t)=>(e,n)=>t(e,n,o);let qt=class{constructor(o,t){R(this,"_current",null);R(this,"_shortcutParam",[]);this._univerInstanceService=o,this._localeService=t}dispose(){this._shortcutParam=[]}getCurrentBySearch(o){return this._getCurrentBySearch(o)}getCurrent(){return this._getCurrentBySearch(this._current)}addOrUpdate(o){const t=this._getCurrentBySearch({unitId:o.unitId,sheetId:o.sheetId,keycode:o.keycode});if(t!=null){const e=this._shortcutParam.indexOf(t);this._shortcutParam.splice(e,1)}return this._shortcutParam.push(o),t}remove(o){if(o==null)return;const t=this._getCurrentBySearch(o);if(t==null)return;const e=this._shortcutParam.indexOf(t);return this._shortcutParam.splice(e,1)[0]}_getCurrentBySearch(o){return o==null?void 0:this._shortcutParam.find(e=>e.unitId===o.unitId&&e.sheetId===o.sheetId&&e.keycode===o.keycode)}};qt=gl([Vi(0,l.IUniverInstanceService),Vi(1,D.Inject(l.LocaleService))],qt);var ke=(o=>(o[o.moveStopeOne=0]="moveStopeOne",o[o.moveGap=1]="moveGap",o[o.moveStepPage=2]="moveStepPage",o[o.moveStepEnd=3]="moveStepEnd",o))(ke||{});const we={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=S.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:i}=e,r=o.get(S.SelectionManagerService).getLast();if(!r)return!1;const{direction:s,jumpOver:a}=t,{range:c,primary:u}=r,d=xo(c,u,s),h=a===1?Jo(d,s,i):tt(d,s,i),m=S.getCellAtRowCol(h.startRow,h.startColumn,i);return l.Rectangle.equals(m,d)?!1:(o.get(qt).remove({unitId:n.getUnitId(),sheetId:i.getSheetId(),keycode:I.KeyCode.TAB}),o.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:n.getUnitId(),subUnitId:i.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(m),primary:{startRow:m.startRow,startColumn:m.startColumn,endRow:m.endRow,endColumn:m.endColumn,actualRow:h.startRow,actualColumn:h.startColumn,isMerged:m.isMerged,isMergedMainCell:m.startRow===h.startRow&&m.startColumn===h.startColumn}}]}))}},gt={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=S.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{workbook:n,worksheet:i}=e,r=o.get(S.SelectionManagerService).getLast();if(!r)return!1;const s=n.getUnitId(),a=i.getSheetId();if(!r)return!1;const{direction:c,keycode:u}=t,{range:d,primary:h}=r;let m=xo(d,h,c);const g=o.get(qt),f=g.getCurrentBySearch({unitId:s,sheetId:a,keycode:I.KeyCode.TAB});let _;const{startRow:p,endRow:v,startColumn:M,endColumn:b}=d;if(l.Rectangle.equals(d,h)){if(u===I.KeyCode.TAB)f==null&&g.addOrUpdate({unitId:s,sheetId:a,keycode:I.KeyCode.TAB,selection:r});else{const y=f==null?void 0:f.selection;if(y!=null){const{range:O,primary:x}=y;m=xo(O,x,c)}g.remove({unitId:s,sheetId:a,keycode:I.KeyCode.TAB})}const T=tt(m,c,i),w=S.getCellAtRowCol(T.startRow,T.startColumn,i);if(l.Rectangle.equals(w,m))return!1;_={range:l.Rectangle.clone(w),primary:{startRow:w.startRow,startColumn:w.startColumn,endRow:w.endRow,endColumn:w.endColumn,actualRow:T.startRow,actualColumn:T.startColumn,isMerged:w.isMerged,isMergedMainCell:w.startRow===T.startRow&&w.startColumn===T.startColumn}}}else{g.remove({unitId:s,sheetId:a,keycode:I.KeyCode.TAB});const T=l.Tools.deepClone(h),w=tt({startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn},c,i,{startRow:p,endRow:v,startColumn:M,endColumn:b}),y=S.getCellAtRowCol(w.startRow,w.startColumn,i);_={range:l.Rectangle.clone(d),primary:{startRow:y.startRow,startColumn:y.startColumn,endRow:y.endRow,endColumn:y.endColumn,actualRow:w.startRow,actualColumn:w.startColumn,isMerged:y.isMerged,isMergedMainCell:y.startRow===w.startRow&&y.startColumn===w.startColumn}}}return o.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:s,subUnitId:a,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[_]})}},Ae={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=S.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!e)return!1;const{worksheet:n,unitId:i,subUnitId:r}=e,s=o.get(S.SelectionManagerService).getLast();if(!s)return!1;const{range:a,primary:c}=s,{jumpOver:u,direction:d}=t,m=ul(s,d,n)?u===1?cl(a,{...l.Rectangle.clone(c),rangeType:l.RANGE_TYPE.NORMAL},d,n):dl(a,d,n):u===1?al(a,d,n):ll(a,d,n);return l.Rectangle.equals(m,a)?!1:o.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:i,subUnitId:r,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:m,primary:c}]})}};let Le=[],co="";const xr={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Le=[],co=""},handler:async(o,t={expandToGapFirst:!0,loop:!1})=>{const e=o.get(S.SelectionManagerService).getLast(),n=S.getSheetCommandTarget(o.get(l.IUniverInstanceService));if(!n)return!1;const{worksheet:i,unitId:r,subUnitId:s}=n;if(!e||!i)return!1;const a=`${r}|${s}`;a!==co&&(Le=[],co=a);const c=i.getMaxRows(),u=i.getMaxColumns(),{expandToGapFirst:d,loop:h}=t,{range:m,primary:g}=e,f=m.endColumn===u-1&&m.endRow===c-1&&m.startRow===0&&m.startColumn===0;Le.some(p=>l.Rectangle.equals(p,m))||(Le=[],Le.push(m));let _;if(f)if(h){if(Le.findIndex(v=>l.Rectangle.equals(v,m))!==Le.length-1)return!1;_=Le[0]}else return!1;else d?(_=Er(m,{left:!0,right:!0,up:!0,down:!0},i),l.Rectangle.equals(_,m)&&(_=Ui(i))):_=Ui(i);return Le.some(p=>l.Rectangle.equals(p,_))||Le.push(_),o.get(l.ICommandService).executeCommand(S.SetSelectionsOperation.id,{unitId:r,subUnitId:s,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:_,primary:g}]})}};var fl=Object.defineProperty,_l=Object.getOwnPropertyDescriptor,Sl=(o,t,e,n)=>{for(var i=n>1?void 0:n?_l(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&fl(t,e,i),i},Ft=(o,t)=>(e,n)=>t(e,n,o);const pl=l.createInterceptorKey("BEFORE_CELL_EDIT"),Cl=l.createInterceptorKey("AFTER_CELL_EDIT"),vl=l.createInterceptorKey("AFTER_CELL_EDIT_ASYNC");exports.EditorBridgeService=class extends l.Disposable{constructor(e,n,i,r,s){super();R(this,"_editorUnitId",l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);R(this,"_isForceKeepVisible",!1);R(this,"_editorIsDirty",!1);R(this,"_visible",{visible:!1,eventType:E.DeviceInputEventType.Dblclick});R(this,"_currentEditCell",null);R(this,"_currentEditCellState",null);R(this,"_currentEditCellState$",new U.BehaviorSubject(null));R(this,"currentEditCellState$",this._currentEditCellState$.asObservable());R(this,"_visible$",new U.BehaviorSubject(this._visible));R(this,"visible$",this._visible$.asObservable());R(this,"_afterVisible$",new U.BehaviorSubject(this._visible));R(this,"afterVisible$",this._afterVisible$.asObservable());R(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:pl,AFTER_CELL_EDIT:Cl,AFTER_CELL_EDIT_ASYNC:vl}));this._sheetSkeletonManagerService=e,this._selectionRenderService=n,this._themeService=i,this._univerInstanceService=r,this._editorService=s,this.disposeWithMe(l.toDisposable(()=>{this._currentEditCellState$.complete(),this._currentEditCell=null})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:a=>a})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:a=>a})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC,{priority:-1,handler:a=>a}))}refreshEditCellState(){const e=this.getLatestEditCellState();this._currentEditCellState=e,this._currentEditCellState$.next(e)}setEditCell(e){this._currentEditCell=e;const n=this.getLatestEditCellState();this._currentEditCellState=n,this._currentEditCellState$.next(n)}getEditCellState(){return this._currentEditCellState}getLatestEditCellState(){var N,L;const e=this._currentEditCell;if(e==null)return;const n=this._sheetSkeletonManagerService.getCurrent();if(n==null)return;const{skeleton:i}=n,{primary:r,unitId:s,sheetId:a,scene:c,engine:u}=e,{startRow:d,startColumn:h}=r,m=this._selectionRenderService.convertCellRangeToInfo(r);if(m==null)return;const g=l.makeCellToSelection(m);if(g==null)return;const f=E.getCanvasOffsetByEngine(u);let{startX:_,startY:p,endX:v,endY:M}=g;const{scaleX:b,scaleY:T}=c.getAncestorScale(),w=c.getScrollXY(this._selectionRenderService.getViewPort());_=i.convertTransformToOffsetX(_,b,w),p=i.convertTransformToOffsetY(p,T,w),v=i.convertTransformToOffsetX(v,b,w),M=i.convertTransformToOffsetY(M,T,w);const y=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),O=y.getActiveSheet(),x={workbook:y,worksheet:O,unitId:y.getUnitId(),subUnitId:O.getSheetId(),row:d,col:h},A=this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(O.getCell(d,h),x);let F=A&&i.getCellDocumentModelWithFormula(A);if(!F||F.documentModel==null){const B=i.getBlankCellDocumentModel(A);if(F!=null){const{verticalAlign:j,horizontalAlign:z,wrapStrategy:q,textRotation:K,fill:$}=F,{centerAngle:Q,vertexAngle:P}=E.convertTextRotation(K);B.documentModel.documentStyle.renderConfig={verticalAlign:j,horizontalAlign:z,wrapStrategy:q,background:{rgb:$},centerAngle:Q,vertexAngle:P}}F=B}if((N=F.documentModel)==null||N.setZoomRatio(Math.max(b,T)),(A==null?void 0:A.isInArrayFormulaRange)===!0){const B=(L=F.documentModel)==null?void 0:L.getBody();B&&(B.textRuns=[{st:0,ed:B.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}return this._editorService.setOperationSheetUnitId(s),this._editorService.setOperationSheetSubUnitId(a),{position:{startX:_,startY:p,endX:v,endY:M},scaleX:b,scaleY:T,canvasOffset:f,row:d,column:h,unitId:s,sheetId:a,documentLayoutObject:F,editorUnitId:this._editorUnitId,isInArrayFormulaRange:A==null?void 0:A.isInArrayFormulaRange}}getCurrentEditorId(){return this._editorUnitId}changeVisible(e){this._visible=e,e.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(e){this._editorIsDirty=e}getEditorDirty(){return this._editorIsDirty}};exports.EditorBridgeService=Sl([Ft(0,D.Inject(exports.SheetSkeletonManagerService)),Ft(1,Ne),Ft(2,D.Inject(l.ThemeService)),Ft(3,l.IUniverInstanceService),Ft(4,I.IEditorService)],exports.EditorBridgeService);const Ee=D.createIdentifier("univer.sheet-editor-bridge.service"),Te={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(o,t)=>{const e=o.get(Ee);return t==null?!1:(e.changeVisible(t),!0)}},ti={id:"sheet.operation.set-cell-edit-visible-f2",type:l.CommandType.OPERATION,handler:(o,t)=>(o.get(l.ICommandService).syncExecuteCommand(Te.id,t),!0)},Qt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Ze{constructor(){R(this,"_scrollInfo",new Map);R(this,"_scrollInfo$",new U.BehaviorSubject(null));R(this,"scrollInfo$",this._scrollInfo$.asObservable());R(this,"_currentScroll",null)}dispose(){this._scrollInfo$.complete()}setCurrentScroll(t){this._currentScroll=t,this._refresh(t)}getScrollByParam(t){return this._getCurrentScroll(t)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t})}addOrReplaceNoRefresh(t){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...t},!1)}addOrReplaceByParam(t){this._addByParam(t)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(t,e=!0){const{unitId:n,sheetId:i,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=t;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(i,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),e===!0&&this._refresh({unitId:n,sheetId:i})}_clearByParam(t){this._addByParam({...t,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(t)}_getCurrentScroll(t){var i;if(t==null)return;const{unitId:e,sheetId:n}=t;return(i=this._scrollInfo.get(e))==null?void 0:i.get(n)}_refresh(t){this._scrollInfo$.next(this._getCurrentScroll(t))}}const ot={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(o,t)=>{if(t==null)return!1;const e=o.get(Ze),r=o.get(l.IUniverInstanceService).getUniverSheetInstance(t.unitId).getSheetBySheetId(t.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return e.addOrReplaceByParam({...t,sheetViewStartRow:t.sheetViewStartRow-a,sheetViewStartColumn:t.sheetViewStartColumn-s}),!0}},Xt={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(o,t={offsetX:0,offsetY:0})=>{const e=o.get(l.ICommandService),n=o.get(Ze),i=o.get(l.IUniverInstanceService),r=S.getSheetCommandTarget(i);if(!r)return!1;const{unitId:s,subUnitId:a,worksheet:c}=r,{xSplit:u,ySplit:d}=c.getConfig().freeze,h=n.getCurrentScroll(),{offsetX:m=0,offsetY:g=0}=t||{},{sheetViewStartRow:f=0,sheetViewStartColumn:_=0,offsetX:p=0,offsetY:v=0}=h||{};return e.executeCommand(ot.id,{unitId:s,sheetId:a,sheetViewStartRow:f+d,sheetViewStartColumn:_+u,offsetX:p+m,offsetY:v+g})}},dt={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:(o,t)=>{if(!t)return!1;const e=o.get(l.IUniverInstanceService),n=o.get(Ze),i=S.getSheetCommandTarget(e);if(!i)return!1;const{workbook:r,worksheet:s}=i,a=n.getCurrentScroll();if(!s)return!1;const{sheetViewStartRow:c,sheetViewStartColumn:u,offsetX:d,offsetY:h}=t,{sheetViewStartColumn:m,sheetViewStartRow:g,offsetX:f,offsetY:_}=a||{},{xSplit:p,ySplit:v}=s.getConfig().freeze;return o.get(l.ICommandService).syncExecuteCommand(ot.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:c!=null?c:(g!=null?g:0)+v,sheetViewStartColumn:u!=null?u:(m!=null?m:0)+p,offsetX:d!=null?d:f,offsetY:h!=null?h:_})}},Nr={id:"sheet.command.scroll-to-cell",type:l.CommandType.COMMAND,handler:(o,t)=>{const e=o.get(l.IUniverInstanceService);return o.get(E.IRenderManagerService).getRenderById(e.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId()).with(exports.SheetsScrollRenderController).scrollToRange(t.range)}},Il={id:"sheet.command.scroll-view-reset",type:l.CommandType.COMMAND,handler:async o=>{const t=o.get(l.IUniverInstanceService),e=S.getSheetCommandTarget(t);if(!e)return!1;const{subUnitId:n,unitId:i}=e;return o.get(l.ICommandService).executeCommand(ot.id,{unitId:i,sheetId:n,sheetViewStartRow:0,sheetViewStartColumn:0})}};function Rl(o){return typeof o.isMainScene>"u"}function it(o,t){const e=o instanceof l.Workbook?o:o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return null;const n=e.getUnitId();let i,r,s,a;if(Rl(t)){const m=t.getRenderById(n);if(m==null)return null;i=m.components,i=m.components,r=m.mainComponent,s=m.scene,a=m.engine}else i=t.components,r=t.mainComponent,s=t.scene,a=t.engine;if(!i||!r)return null;const c=r,u=i.get(ie.ROW),d=i.get(ie.COLUMN),h=i.get(ie.LEFT_TOP);return{spreadsheet:c,spreadsheetRowHeader:u,spreadsheetColumnHeader:d,spreadsheetLeftTopPlaceholder:h,scene:s,engine:a}}function No(o,t,e,n){const{startX:i,startY:r,endX:s,endY:a}=n.getCellByIndex(o,t);return{startX:i,startY:r,endX:s,endY:a}}function Et(o,t,e,n,i,r){const s=e.getRelativeCoord(E.Vector2.FromArray([o,t])),{x:a,y:c}=s,u=e.getScrollXYByRelativeCoords(s,i),{scaleX:d,scaleY:h}=e.getAncestorScale(),m=n.getCellPositionByOffset(a,c,d,h,u,r),{row:g,column:f}=m,_=n.getNoMergeCellPositionByIndex(g,f),{startX:p,startY:v,endX:M,endY:b}=_;return{startX:p,startY:v,endX:M,endY:b,row:g,column:f}}function bn(o,t,e,n){const i=e.getRelativeCoord(E.Vector2.FromArray([o,t])),r=e.getViewport(W.VIEW_MAIN),s=e.getScrollXYByRelativeCoords(i,r),{scaleX:a,scaleY:c}=e.getAncestorScale(),{x:u,y:d}=s,h=o/a+u,m=t/c+d;return{x:h,y:m}}var Ml=Object.defineProperty,bl=Object.getOwnPropertyDescriptor,Tl=(o,t,e,n)=>{for(var i=n>1?void 0:n?bl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ml(t,e,i),i},_t=(o,t)=>(e,n)=>t(e,n,o);const wl=[we.id,gt.id];exports.SheetsScrollRenderController=class extends l.Disposable{constructor(t,e,n,i,r,s,a){super(),this._context=t,this._sheetSkeletonManagerService=e,this._univerInstanceService=n,this._commandService=i,this._renderManagerService=r,this._selectionManagerService=s,this._scrollManagerService=a,this._init()}scrollToRange(t){const{startRow:e,startColumn:n}=t;return this._scrollToCell(e,n)}_init(){this._initCommandListener(),this._initScrollEventListener(),this._scrollSubscribeBinding(),this._initSkeletonListener()}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(wl.includes(t.id))this._scrollToSelection();else if(t.id===S.ScrollToCellOperation.id){const e=t.params;this._scrollToSelectionByDirection(e)}else if(t.id===Ae.id){const e=t.params;this._scrollToSelectionForExpand(e)}}))}_scrollToSelectionForExpand(t){setTimeout(()=>{const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e.range,a=this._getViewportBounding();if(a==null)return;const{startRow:c,startColumn:u,endRow:d,endColumn:h}=a;let m=0,g=0;n>c?m=r:r<d?m=n:m=c,i>u?g=s:s<h?g=i:g=u,t.direction===l.Direction.DOWN?m=r:t.direction===l.Direction.UP?m=n:t.direction===l.Direction.RIGHT?g=s:t.direction===l.Direction.LEFT&&(g=i),this._scrollToCell(m,g)},0)}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_initScrollEventListener(){var n;const t=(n=this._getSheetObject())==null?void 0:n.scene;if(t==null)return;const e=t.getViewport(W.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(i=>{var g;const r=(g=this._sheetSkeletonManagerService.getCurrent())==null?void 0:g.skeleton;if(r==null||i.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=i,{row:u,column:d,rowOffset:h,columnOffset:m}=r.getDecomposedOffset(a,c);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:u,sheetViewStartColumn:d,offsetX:m,offsetY:h})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(i=>{var f;const r=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(r==null||i.isTrigger===!1)return;const s=this._getSheetObject();if(r==null||s==null)return;const{actualScrollX:a=0,actualScrollY:c=0}=i,u=this._getFreeze(),{row:d,column:h,rowOffset:m,columnOffset:g}=r.getDecomposedOffset(a,c);this._commandService.executeCommand(dt.id,{sheetViewStartRow:d+((u==null?void 0:u.ySplit)||0),sheetViewStartColumn:h+((u==null?void 0:u.xSplit)||0),offsetX:g,offsetY:m})})))}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(t=>{var _;const e=(_=this._sheetSkeletonManagerService.getCurrent())==null?void 0:_.skeleton,n=this._getSheetObject();if(e==null||n==null)return;const i=n.scene;n.scene.getAncestorScale();const r=i.getViewport(W.VIEW_MAIN);if(r==null)return;if(t==null){r.scrollTo({x:0,y:0});return}const{sheetViewStartRow:s,sheetViewStartColumn:a,offsetX:c,offsetY:u}=t,{startX:d,startY:h}=e.getCellByIndexWithNoHeader(s,a),m=d+c,g=h+u,f=r.getBarScroll(m,g);r.scrollTo(f)})))}_initSkeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{if(t==null)return;const{unitId:e,sheetId:n}=t;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(t),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:n}))})))}_updateSceneSize(t){var u;if(t==null)return;const{skeleton:e,unitId:n}=t,i=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.scene;if(e==null||i==null)return;const{rowTotalHeight:r,columnTotalWidth:s,rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=e;i==null||i.transformByState({width:a+s,height:c+r})}_getSheetObject(){return it(this._context.unit,this._context)}_scrollToSelectionByDirection(t){const e=this._getViewportBounding();if(e==null)return!1;const{startRow:n,startColumn:i,endRow:r,endColumn:s}=e;let a=0,c=0;const{startRow:u,startColumn:d,endRow:h,endColumn:m}=t;u>=n&&(a=h),h<=r&&(a=u),d>=i&&(c=m),m<=s&&(c=d),this._scrollToCell(a,c)}_scrollToSelection(t=!0){const e=this._selectionManagerService.getLast();if(e==null)return;const{startRow:n,startColumn:i,actualRow:r,actualColumn:s}=e.primary,a=t?r:n,c=t?s:i;this._scrollToCell(a,c)}_getViewportBounding(){var r,s;const t=(r=this._getSheetObject())==null?void 0:r.scene;if(t==null)return;const e=t.getViewport(W.VIEW_MAIN);if(e==null)return;const n=(s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton;if(n==null)return;const i=e.getBounding();return n.getRowColumnSegment(i)}_scrollToCell(t,e){var y,O,x,A;const{rowHeightAccumulation:n,columnWidthAccumulation:i}=(O=(y=this._sheetSkeletonManagerService.getCurrent())==null?void 0:y.skeleton)!=null?O:{};if(n==null||i==null)return!1;const r=(x=this._getSheetObject())==null?void 0:x.scene;if(r==null)return!1;const s=r.getViewport(W.VIEW_MAIN);if(s==null||((A=this._sheetSkeletonManagerService.getCurrent())==null?void 0:A.skeleton)==null)return!1;const c=this._context.unit.getActiveSheet(),{startColumn:u,startRow:d,ySplit:h,xSplit:m}=c.getFreeze(),g=this._getViewportBounding();if(g==null)return!1;const{startRow:f,startColumn:_,endRow:p,endColumn:v}=g;let M,b;if(t>=d&&e>=u-m&&(t<=f&&(M=t),t>=p)){const F=n[t]-s.height;for(let N=f;N<=t;N++)if(n[N]>=F){M=N+1;break}}if(e>=u&&t>=d-h&&(e<=_&&(b=e),e>=v)){const F=i[e]-s.width;for(let N=_;N<=e;N++)if(i[N]>=F){b=N+1;break}}if(M===void 0&&b===void 0)return!1;const{offsetX:T,offsetY:w}=this._scrollManagerService.getCurrentScroll()||{};return this._commandService.syncExecuteCommand(dt.id,{sheetViewStartRow:M,sheetViewStartColumn:b,offsetX:b===void 0?T:0,offsetY:M===void 0?w:0})}};exports.SheetsScrollRenderController=Tl([_t(1,D.Inject(exports.SheetSkeletonManagerService)),_t(2,l.IUniverInstanceService),_t(3,l.ICommandService),_t(4,E.IRenderManagerService),_t(5,D.Inject(S.SelectionManagerService)),_t(6,D.Inject(Ze))],exports.SheetsScrollRenderController);function El(o){return o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.switchMap(t=>t?t.activeSheet$.pipe(U.map(e=>e?{workbook:t,worksheet:e}:null)):U.of(null)))}function _e(o,t,e){return El(o).pipe(U.switchMap(n=>n?e(n):U.of(t)))}var yl=Object.defineProperty,Ol=Object.getOwnPropertyDescriptor,xl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ol(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&yl(t,e,i),i},kt=(o,t)=>(e,n)=>t(e,n,o);exports.SheetRenderController=class extends l.RxDisposable{constructor(e,n,i,r,s){super();R(this,"_skeletonChangeMutations",new Set);this._sheetSkeletonManagerService=e,this._contextService=n,this._univerInstanceService=i,this._renderManagerService=r,this._commandService=s,Promise.resolve().then(()=>this._init())}registerSkeletonChangingMutations(e){if(this._skeletonChangeMutations.has(e))throw new Error(`[SheetRenderController]: the mutationId ${e} has already been registered!`);return this._skeletonChangeMutations.add(e),l.toDisposable(()=>this._skeletonChangeMutations.delete(e))}_init(){this._initialRenderRefresh(),this._initWorkbookListener(),this._initCommandListener(),this._initContextListener()}_initialRenderRefresh(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:n,unitId:i,sheetId:r}=e,s=this._univerInstanceService.getUniverSheetInstance(i),a=s==null?void 0:s.getSheetBySheetId(r);if(s==null||a==null)return;const c=this._renderManagerService.getRenderById(i);if(c==null)return;const{mainComponent:u,components:d}=c,h=u,m=d.get(ie.ROW),g=d.get(ie.COLUMN),f=d.get(ie.LEFT_TOP),{rowHeaderWidth:_,columnHeaderHeight:p}=n;h==null||h.updateSkeleton(n),m==null||m.updateSkeleton(n),g==null||g.updateSkeleton(n),f==null||f.transformByState({width:_,height:p})}))}_initWorkbookListener(){this._univerInstanceService.getTypeOfUnitAdded$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).subscribe(e=>this._createSheetRenderer(e)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(U.takeUntil(this.dispose$)).subscribe(e=>{const n=e.getUnitId();this._sheetSkeletonManagerService.removeSkeleton({unitId:n}),this._renderManagerService.removeRender(n)}),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(e=>this._createSheetRenderer(e))}_createSheetRenderer(e){const n=e.getUnitId();this._renderManagerService.createRender(n),this._renderManagerService.setCurrent(n);const i=e.getActiveSheet().getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:i,unitId:n})}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var r,s;const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return;const i=n.getUnitId();if(S.COMMAND_LISTENER_SKELETON_CHANGE.includes(e.id)||this._skeletonChangeMutations.has(e.id)){const a=n.getActiveSheet(),c=a.getSheetId(),u=e.params,{unitId:d,subUnitId:h}=u;if(!(d===n.getUnitId()&&h===a.getSheetId()))return;e.id!==S.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:d,sheetId:c,commandId:e.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:d,sheetId:c,commandId:e.id})}else S.COMMAND_LISTENER_VALUE_CHANGE.includes(e.id)&&this._sheetSkeletonManagerService.reCalculate();e.type===l.CommandType.MUTATION&&((s=(r=this._renderManagerService.getRenderById(i))==null?void 0:r.mainComponent)==null||s.makeDirty())}))}_initContextListener(){this._contextService.subscribeContextValue$(E.RENDER_RAW_FORMULA_KEY).pipe(U.distinctUntilChanged(),U.takeUntil(this.dispose$)).subscribe(()=>{this._renderManagerService.getRenderAll().forEach(e=>{e.mainComponent instanceof E.Spreadsheet&&e.mainComponent.makeForceDirty(!0)})})}};exports.SheetRenderController=xl([l.OnLifecycle(l.LifecycleStages.Ready,exports.SheetRenderController),kt(0,D.Inject(exports.SheetSkeletonManagerService)),kt(1,l.IContextService),kt(2,l.IUniverInstanceService),kt(3,E.IRenderManagerService),kt(4,l.ICommandService)],exports.SheetRenderController);const Kn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const e=o.get(l.IUniverInstanceService),n=S.getSheetCommandTarget(e);if(!n)return!1;const{worksheet:i,subUnitId:r,unitId:s}=n,{delta:a,reset:c}=t;let u=c?100:Math.round((i.getConfig().zoomRatio+a)*100);u=Math.max(Eo[0],u),u=Math.min(Eo[1],u);const d=u/100;return o.get(l.ICommandService).executeCommand(Fe.id,{unitId:s,subUnitId:r,zoomRatio:d})}},qn={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(o,t)=>{if(!t)return!1;const{unitId:e,subUnitId:n,zoomRatio:i}=t;return o.get(l.ICommandService).executeCommand(Fe.id,{unitId:e,subUnitId:n,zoomRatio:i})}};var Nl=Object.defineProperty,Al=Object.getOwnPropertyDescriptor,Dl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Al(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Nl(t,e,i),i},Bi=(o,t)=>(e,n)=>t(e,n,o);let Fn=class extends l.Disposable{constructor(o,t,e){super(),this._context=o,this._sheetSkeletonManagerService=t,this._commandService=e,this._skeletonListener(),this._zoomEventBinding()}updateZoom(o,t){const e=this._context.unit.getSheetBySheetId(o);return e?(e.getConfig().zoomRatio=t,e===this._context.unit.getActiveSheet()&&this._updateViewZoom(t),!0):!1}_zoomEventBinding(){var t;const o=(t=this._getSheetObject())==null?void 0:t.scene;o!=null&&this.disposeWithMe(o.onMouseWheelObserver.add(e=>{if(!e.ctrlKey)return;const n=Math.abs(e.deltaX);let i=n<40?.2:n<80?.4:.2;i*=e.deltaY>0?-1:1,o.scaleX<1&&(i/=2);const r=this._context.unit,s=r.getActiveSheet(),a=s.getZoomRatio();let c=+Number.parseFloat(`${a+i}`).toFixed(1);c=c>=4?4:c<=.1?.1:c,this._commandService.executeCommand(qn.id,{zoomRatio:Math.round(c*10)/10,unitId:r.getUnitId(),subUnitId:s.getSheetId()}),e.preventDefault()}))}_skeletonListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(o=>{if(o==null)return;const n=this._context.unit.getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)}))}_updateViewZoom(o){const t=this._getSheetObject();t==null||t.scene.scale(o,o),t==null||t.spreadsheet.makeForceDirty()}_getSheetObject(){return it(this._context.unit,this._context)}};Fn=Dl([Bi(1,D.Inject(exports.SheetSkeletonManagerService)),Bi(2,l.ICommandService)],Fn);const Fe={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(o,t)=>{const n=o.get(E.IRenderManagerService).getRenderById(t.unitId);return n?n.with(Fn).updateZoom(t.subUnitId,t.zoomRatio):!1}};var Pl=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Ll=(o,t,e,n)=>{for(var i=n>1?void 0:n?Hl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Pl(t,e,i),i},qe=(o,t)=>(e,n)=>t(e,n,o);exports.AutoFillController=class extends l.Disposable{constructor(e,n,i,r,s,a,c,u){super();R(this,"_beforeApplyData",[]);R(this,"_currentLocation",null);R(this,"_copyData",[]);R(this,"_defaultHook");this._univerInstanceService=e,this._selectionRenderService=n,this._commandService=i,this._autoFillService=r,this._editorBridgeService=s,this._sheetInterceptorService=a,this._selectionManagerService=c,this._injector=u,this._defaultHook={id:"default",type:vt.Default,priority:0,onBeforeFillData:(d,h)=>{this._presetAndCacheData(d,h)},onFillData:(d,h,m)=>this._fillData(d,h,m)},this._init()}_init(){this._initDefaultHook(),this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),this._initQuitListener()}_initDefaultHook(){this.disposeWithMe(this._autoFillService.addHook(this._defaultHook))}_initQuitListener(){const e=[Te.id,Mn.id,Fe.id,S.SetWorksheetActiveOperation.id,S.SetRangeValuesMutation.id,S.MoveRangeMutation.id,S.RemoveRowMutation.id,S.RemoveColMutation.id,S.InsertRowMutation.id,S.InsertColMutation.id,S.MoveRowsMutation.id,S.MoveColsMutation.id,S.SetWorksheetColWidthMutation.id,S.SetWorksheetRowHeightMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{var s,a;const r=i==null?void 0:i.fromCollab;e.includes(n.id)&&!r&&n.params.trigger!==Vn.id&&this._quit(),n.id===S.RemoveSheetMutation.id&&n.params.unitId===((s=this._currentLocation)==null?void 0:s.unitId)&&n.params.subUnitId===((a=this._currentLocation)==null?void 0:a.subUnitId)&&this._quit()})),this.disposeWithMe(this._univerInstanceService.unitDisposed$.subscribe(n=>{var i;n.getUnitId()===((i=this._currentLocation)==null?void 0:i.unitId)&&this._quit()}))}_quit(){this._currentLocation=null,this._beforeApplyData=[],this._copyData=[],this._autoFillService.setShowMenu(!1)}_onSelectionControlFillChanged(){const e=new l.DisposableCollection,n=i=>{const r=this._selectionManagerService.getCurrent();if((r==null?void 0:r.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME)return;i.dispose(),this._selectionRenderService.getCurrentControls().forEach(a=>{i.add(l.toDisposable(a.selectionFilled$.subscribe(c=>{if(c==null||c.startColumn===-1||c.startRow===-1||c.endColumn===-1||c.endRow===-1)return;const u={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow},d={startColumn:c.startColumn,endColumn:c.endColumn,startRow:c.startRow,endRow:c.endRow};this._triggerAutoFill(u,d)}))),i.add(l.toDisposable(a.fillControl.onDblclickObserver.add(()=>{const c={startColumn:a.model.startColumn,endColumn:a.model.endColumn,startRow:a.model.startRow,endRow:a.model.endRow};this._handleDbClickFill(c)}))),i.add(l.toDisposable(a.fillControl.onPointerDownObserver.add(()=>{this._editorBridgeService.isVisible().visible&&this._editorBridgeService.changeVisible({visible:!1,eventType:E.DeviceInputEventType.PointerDown})})))})};n(e),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===S.SetSelectionsOperation.id&&n(e)}))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(()=>{this._handleFillData()})))}_triggerAutoFill(e,n){var g;if(e.startColumn===n.startColumn&&e.startRow===n.startRow&&e.endColumn===n.endColumn&&e.endRow===n.endRow)return;if(n.endColumn<e.endColumn&&n.endColumn>e.startColumn){this._commandService.executeCommand(Mn.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:e.endColumn},selectionRange:n});return}if(n.endRow<e.endRow&&n.endRow>e.startRow){this._commandService.executeCommand(Mn.id,{clearRange:{startRow:n.endRow+1,endRow:e.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}const i={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<e.startRow)r=l.Direction.UP,i.endRow=e.startRow-1;else if(n.endRow>e.endRow)r=l.Direction.DOWN,i.startRow=e.endRow+1;else if(n.startColumn<e.startColumn)r=l.Direction.LEFT,i.endColumn=e.startColumn-1;else if(n.endColumn>e.endColumn)r=l.Direction.RIGHT,i.startColumn=e.endColumn+1;else return;const s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return;const a=s.getUnitId(),c=s.getActiveSheet().getSheetId();this._autoFillService.direction=r;const u={get:this._injector.get.bind(this._injector)},d=Rt(e,u),h=Rt(i,u);if(!d||!h)return;this._autoFillService.autoFillLocation={source:d,target:h,unitId:a,subUnitId:c},this._autoFillService.getActiveHooks().forEach(f=>{var _;(_=f==null?void 0:f.onBeforeFillData)==null||_.call(f,{source:d,target:h,unitId:a,subUnitId:c},r)}),(g=this._autoFillService.menu.find(f=>f.value===oe.SERIES))!=null&&g.disable?this._autoFillService.applyType=oe.COPY:this._autoFillService.applyType=oe.SERIES}_handleDbClickFill(e){const n=this._detectFillRange(e);n.endRow<=e.endRow||this._triggerAutoFill(e,n)}_detectFillRange(e){var m,g,f,_,p,v;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=e,a=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet();if(!a)return e;const c=a.getCellMatrix(),u=a.getMaxRows()-1,d=a.getMaxColumns()-1;let h=i;if(r>0&&((g=c.getValue(n,r-1))==null?void 0:g.v)!=null){let M=n;for(;((f=c.getValue(M,r-1))==null?void 0:f.v)!=null&&M<u;)M+=1;h=M-1}else if(s<d&&((_=c.getValue(i,s+1))==null?void 0:_.v)!=null){let M=n;for(;((p=c.getValue(M,s+1))==null?void 0:p.v)!=null&&M<u;)M+=1;h=M-1}for(let M=i+1;M<=h;M++)for(let b=r;b<=s;b++)if(((v=c.getValue(M,b))==null?void 0:v.v)!=null){h=M-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFillData(){var e,n;this._currentLocation&&this._commandService.executeCommand(Vn.id,{unitId:(e=this._currentLocation)==null?void 0:e.unitId,subUnitId:(n=this._currentLocation)==null?void 0:n.subUnitId})}_getApplyData(e,n,i,r,s,a=!0){const c=[],u=Math.floor(i/n),d=i%n,h=this._autoFillService.getRules();if(!a&&s===oe.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(g=>{m[g.type]=[]}),h.forEach(g=>{const{type:f,applyFunctions:_={}}=g,p=e[f];p&&p.forEach(v=>{const M=$s(v.index,d),b=v.index.length*u+M,T=this._applyFunctions(v,b,r,s,_,e),w=zs(n,i,v.index);m[f].push({data:T,index:w})})});for(let g=0;g<i;g++)h.forEach(f=>{const{type:_}=f,p=m[_];for(let v=0;v<p.length;v++)g in p[v].index&&c.push(p[v].data[p[v].index[g]])});return c}_applyFunctions(e,n,i,r,s,a){const{data:c}=e,u=i===l.Direction.UP||i===l.Direction.LEFT;if(r===oe.COPY){const d=s==null?void 0:s[oe.COPY];return d?d(e,n,i,a):(u&&c.reverse(),ht(c,n))}if(r===oe.SERIES){const d=s==null?void 0:s[oe.SERIES];return d?d(e,n,i,a):(u&&c.reverse(),s!=null&&s[oe.COPY]?s[oe.COPY](e,n,i,a):ht(c,n))}if(r===oe.ONLY_FORMAT){const d=s==null?void 0:s[oe.ONLY_FORMAT];return d?d(e,n,i,a):Ys(c,n)}}_getCopyData(e,n){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),r=this._autoFillService.getRules(),s=[],a=n===l.Direction.DOWN||n===l.Direction.UP;let c,u;return a?(c=e.cols,u=e.rows):(c=e.rows,u=e.cols),c.forEach(d=>{const h=this._getEmptyCopyDataPiece(),m={type:void 0,cellData:void 0};u.forEach(g=>{let f;a?f=i.getValue(g,d):f=i.getValue(d,g);const{type:_,isContinue:p}=r.find(v=>v.match(f))||fr;if(p(m,f)){const v=h[_],M=v[v.length-1];M.data.push(f),M.index.push(g-u[0])}else{const v=h[_];v?v.push({data:[f],index:[g-u[0]]}):h[_]=[{data:[f],index:[g-u[0]]}]}m.type=_,m.cellData=f}),s.push(h)}),s}_getEmptyCopyDataPiece(){const e={};return this._autoFillService.getRules().forEach(n=>{e[n.type]=[]}),e}_getMergeApplyData(e,n,i,r){const s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),a=[];for(let c=e.startRow;c<=e.endRow;c++)for(let u=e.startColumn;u<=e.endColumn;u++){const{isMergedMainCell:d,startRow:h,startColumn:m,endRow:g,endColumn:f}=E.getCellInfoInMergeData(c,u,s);if(d){if(i===l.Direction.DOWN){let _=h+r,p=g+r;for(;p<=n.endRow;)a.push({startRow:_,startColumn:m,endRow:p,endColumn:f}),_+=r,p+=r}else if(i===l.Direction.UP){let _=h-r,p=g-r;for(;_>=n.startRow;)a.push({startRow:_,startColumn:m,endRow:p,endColumn:f}),_-=r,p-=r}else if(i===l.Direction.RIGHT){let _=m+r,p=f+r;for(;p<=n.endColumn;)a.push({startRow:h,startColumn:_,endRow:g,endColumn:p}),_+=r,p+=r}else if(i===l.Direction.LEFT){let _=m-r,p=f-r;for(;_>=n.startColumn;)a.push({startRow:h,startColumn:_,endRow:g,endColumn:p}),_-=r,p-=r}}}return a}_presetAndCacheData(e,n){const{source:i,target:r}=e,s=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getCellMatrix(),a=[];r.rows.forEach(c=>{const u=[];r.cols.forEach(d=>{u.push(l.Tools.deepClone(s.getValue(c,d)))}),a.push(u)}),this._beforeApplyData=a,this._copyData=this._getCopyData(i,n),this._currentLocation=e,this._hasSeries(this._copyData)?this._autoFillService.setDisableApplyType(oe.SERIES,!1):this._autoFillService.setDisableApplyType(oe.SERIES,!0)}_fillData(e,n,i){var $,Q;const r=[],s=[];let a=!0;i===oe.NO_FORMAT&&(a=!1,i=oe.SERIES);const{source:c,target:u,unitId:d,subUnitId:h}=e;if(!c||!u||n==null)return{undos:r,redos:s};const m=mt(c),g=mt(u),{cols:f,rows:_}=u,{cols:p,rows:v}=c,M=this._copyData;let b;n===l.Direction.DOWN||n===l.Direction.UP?b=v.length:b=p.length;const T=[];if(n===l.Direction.DOWN||n===l.Direction.UP){const P=_.length,H=[];f.forEach((k,Y)=>{const X=M[Y],J=this._getApplyData(X,b,P,n,i,a);H.push(J)});for(let k=0;k<H[0].length;k++){const Y=[];for(let X=0;X<H.length;X++)Y.push({s:null,...H[X][k]});T.push(Y)}}else{const P=f.length;_.forEach((H,k)=>{const Y=M[k],X=this._getApplyData(Y,b,P,n,i,a),J=[];for(let ee=0;ee<X.length;ee++)J.push({s:null,...X[ee]});T.push(J)})}let w=[];const y=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getStyles();a?(w=this._getMergeApplyData(m,g,n,b),T.forEach(P=>{P.forEach(H=>{H&&y&&y&&(H.s=y.getStyleByCell(H))})})):T.forEach((P,H)=>{P.forEach((k,Y)=>{k&&y&&(k.s=y.getStyleByCell(this._beforeApplyData[H][Y])||null)})}),i===oe.ONLY_FORMAT&&T.forEach((P,H)=>{P.forEach((k,Y)=>{if(k){const X=this._beforeApplyData[H][Y]||{};k.f=X.f,k.si=X.si,k.t=X.t,k.v=X.v}})});const O={get:this._injector.get.bind(this._injector)},x=[],A=(Q=($=this._univerInstanceService.getUniverSheetInstance(d))==null?void 0:$.getSheetBySheetId(h))==null?void 0:Q.getMergeData();A&&A.forEach(P=>{l.Rectangle.intersects(P,g)&&x.push(P)});const F={unitId:d,subUnitId:h,ranges:x},N=S.RemoveMergeUndoMutationFactory(O,F);s.push({id:S.RemoveWorksheetMergeMutation.id,params:F}),r.push({id:S.AddWorksheetMergeMutation.id,params:N});const L={subUnitId:h,unitId:d,cellValue:Js([u])},B=S.SetRangeValuesUndoMutationFactory(O,L),j=this._sheetInterceptorService.onCommandExecute({id:S.ClearSelectionContentCommand.id});s.push({id:S.SetRangeValuesMutation.id,params:L},...j.redos),r.push(...j.undos,{id:S.SetRangeValuesMutation.id,params:B});const z=new l.ObjectMatrix;_.forEach((P,H)=>{f.forEach((k,Y)=>{T[H][Y]&&z.setValue(P,k,T[H][Y])})});const q={subUnitId:h,unitId:d,cellValue:z.getMatrix()},K=S.SetRangeValuesUndoMutationFactory(O,q);if(r.push({id:S.SetRangeValuesMutation.id,params:K}),s.push({id:S.SetRangeValuesMutation.id,params:q}),w!=null&&w.length){const P=S.getAddMergeMutationRangeByType(w),H={unitId:d,subUnitId:h,ranges:P},k=S.AddMergeUndoMutationFactory(O,H);r.push({id:S.RemoveWorksheetMergeMutation.id,params:k}),s.push({id:S.AddWorksheetMergeMutation.id,params:H})}return{undos:r,redos:s}}_hasSeries(e){return e.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ue.OTHER,ue.FORMULA].includes(r))}))}};exports.AutoFillController=Ll([l.OnLifecycle(l.LifecycleStages.Steady,exports.AutoFillController),qe(0,l.IUniverInstanceService),qe(1,Ne),qe(2,l.ICommandService),qe(3,yt),qe(4,Ee),qe(5,D.Inject(S.SheetInterceptorService)),qe(6,D.Inject(S.SelectionManagerService)),qe(7,D.Inject(D.Injector))],exports.AutoFillController);var Ul=Object.defineProperty,Vl=Object.getOwnPropertyDescriptor,Bl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Vl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ul(t,e,i),i},uo=(o,t)=>(e,n)=>t(e,n,o);exports.CellCustomRenderController=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_enterActiveRender");this._context=e,this._sheetSkeletonManagerService=n,this._renderManagerService=i,this._univerInstanceService=r,this._initEventBinding()}_initEventBinding(){const e=new l.DisposableCollection,n=this._context.unit,i=r=>{if(e.dispose(),!r)return;const{unitId:s,skeleton:a}=r,c=this._renderManagerService.getRenderById(s);if(c&&c.mainComponent){const u=c.mainComponent,d=g=>{const{offsetX:f,offsetY:_}=g,p=c.scene,v=n.getActiveSheet(),M=p.getActiveViewportByCoord(E.Vector2.FromArray([f,_]));if(!M)return;const{scaleX:b,scaleY:T}=p.getAncestorScale(),w={x:M.actualScrollX,y:M.actualScrollY},y=a.getCellPositionByOffset(f,_,b,T,w),O=a.mergeData.find($=>{const{startColumn:Q,startRow:P,endColumn:H,endRow:k}=$;return y.row>=P&&y.column>=Q&&y.row<=k&&y.column<=H}),x={actualRow:O?O.startRow:y.row,actualCol:O?O.startColumn:y.column,mergeCell:O,row:y.row,col:y.column};if(!x||!a)return;const A=v.getCell(x.actualRow,x.actualCol);if(!A)return;const F=A.customRender;if(!(F!=null&&F.length))return;const N=x.actualRow,L=x.actualCol,B=F.sort(l.sortRules),j=n.getActiveSheet().getSheetId(),z={data:A,style:a.getsStyles().getStyleByCell(A),primaryWithCoord:a.getCellByIndex(x.actualRow,x.actualCol),unitId:s,subUnitId:j,row:N,col:L},q={x:w.x+f/b,y:w.y+_/T},K=B.find($=>{var Q;return(Q=$.isHit)==null?void 0:Q.call($,q,z)});if(K)return[K,z]},h=u.onPointerDownObserver.add(g=>{var _;const f=d(g);if(f){const[p,v]=f;(_=p.onPointerDown)==null||_.call(p,v,g)}}),m=u.onPointerMoveObserver.add(g=>{var _,p,v,M;const f=d(g);if(f){const[b,T]=f;this._enterActiveRender?this._enterActiveRender.render!==b&&((p=(_=this._enterActiveRender.render).onPointerLeave)==null||p.call(_,this._enterActiveRender.cellContext,g),this._enterActiveRender={render:b,cellContext:T},(v=b.onPointerEnter)==null||v.call(b,T,g)):(this._enterActiveRender={render:b,cellContext:T},(M=b.onPointerEnter)==null||M.call(b,T,g))}});h&&e.add(h),m&&e.add(m)}};this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i)),i(this._sheetSkeletonManagerService.getCurrent()),this.disposeWithMe(e)}};exports.CellCustomRenderController=Bl([l.OnLifecycle(l.LifecycleStages.Rendered,exports.CellCustomRenderController),uo(1,D.Inject(exports.SheetSkeletonManagerService)),uo(2,E.IRenderManagerService),uo(3,l.IUniverInstanceService)],exports.CellCustomRenderController);const Ar={id:"sheet.command.hide-row-confirm",type:l.CommandType.COMMAND,handler:async o=>{var c;const e=(c=o.get(S.SelectionManagerService).getSelections())==null?void 0:c.map(u=>u.range);if(!(e!=null&&e.length))return!1;const n=o.get(l.ICommandService),i=o.get(l.IUniverInstanceService),r=S.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,a=s.getVisibleRows();if(yr(a,e)){const u=o.get(I.IConfirmService),d=o.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.hide-row",title:{title:d.t("info.problem")},children:{title:d.t("rightClick.hideAllRowsAlert")},cancelText:d.t("button.cancel"),confirmText:d.t("button.confirm")}),!1}return await n.executeCommand(S.SetRowHiddenCommand.id),!0}},Dr={id:"sheet.command.hide-col-confirm",type:l.CommandType.COMMAND,handler:async o=>{var c;const e=(c=o.get(S.SelectionManagerService).getSelections())==null?void 0:c.map(u=>u.range);if(!(e!=null&&e.length))return!1;const n=o.get(l.ICommandService),i=o.get(l.IUniverInstanceService),r=S.getSheetCommandTarget(i);if(!r)return!1;const{worksheet:s}=r,a=s.getVisibleCols();if(Or(a,e)){const u=o.get(I.IConfirmService),d=o.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.hide-col",title:{title:d.t("info.problem")},children:{title:d.t("rightClick.hideAllColumnsAlert")},cancelText:d.t("button.cancel"),confirmText:d.t("button.confirm")}),!1}return await n.executeCommand(S.SetColHiddenCommand.id),!0}},ni={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatBoldCommand.id):t.executeCommand(S.SetBoldCommand.id)}},oi={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatItalicCommand.id):t.executeCommand(S.SetItalicCommand.id)}},ii={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatUnderlineCommand.id):t.executeCommand(S.SetUnderlineCommand.id)}},ri={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatStrikethroughCommand.id):t.executeCommand(S.SetStrikeThroughCommand.id)}},Fl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSubscriptCommand.id):!1}},kl={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async o=>{const t=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?t.executeCommand(te.SetInlineFormatSuperscriptCommand.id):!1}},Pr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontSizeCommand.id,t):e.executeCommand(S.SetFontSizeCommand.id,t)}},Hr={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatFontFamilyCommand.id,t):e.executeCommand(S.SetFontFamilyCommand.id,t)}},kn={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(o,t)=>{const e=o.get(l.ICommandService);return o.get(l.IContextService).getContextValue(l.EDITOR_ACTIVATED)?e.executeCommand(te.SetInlineFormatTextColorCommand.id,t):e.executeCommand(S.SetTextColorCommand.id,t)}};function Lr(o,t){return t.some(e=>Wl(o,e))}function Wl(o,t){const{startRow:e,startColumn:n,endColumn:i,endRow:r}=t,s=o.getMatrixWithMergedCells(e,n,r,i);let a=!1;return s.forValue((c,u,d)=>{if(d&&(c!==e||u!==n)&&o.cellHasValue(d))return a=!0,!1}),a}function Ur(o,t,e,n){const i=[],r=[],s=e.getSheetId();return n.forEach(a=>{const c=jl(e,a),u={unitId:t,subUnitId:s,cellValue:c.getData()},d=S.SetRangeValuesUndoMutationFactory(o,u);i.push({id:S.SetRangeValuesMutation.id,params:d}),r.push({id:S.SetRangeValuesMutation.id,params:u})}),{undos:i,redos:r}}function jl(o,t){const{startRow:e,startColumn:n,endColumn:i,endRow:r}=t,s=o.getMatrixWithMergedCells(e,n,r,i),a=new l.ObjectMatrix;return s.forValue((c,u,d)=>{d&&(c!==e||u!==n)&&a.setValue(c,u,null)}),a}function $l(o,t,e,n){const i=e.getActiveViewportByCoord(E.Vector2.FromArray([o,t]));if(!i)return;const{scaleX:r,scaleY:s}=e.getAncestorScale(),a={x:i.actualScrollX,y:i.actualScrollY},c=n.getCellPositionByOffset(o,t,r,s,a),u=n.mergeData.find(h=>{const{startColumn:m,startRow:g,endColumn:f,endRow:_}=h;return c.row>=g&&c.column>=m&&c.row<=_&&c.column<=f});return{actualRow:u?u.startRow:c.row,actualCol:u?u.startColumn:c.column,mergeCell:u,row:c.row,col:c.column}}function zl(o,t,e,n){const i=n.getFreeze();if(!i||i.startRow<=0&&i.startColumn<=0||o>i.startRow&&t>i.startColumn)return e.getViewport(W.VIEW_MAIN);if(o<=i.startRow&&t<=i.startColumn)return e.getViewport(W.VIEW_MAIN_LEFT_TOP);if(o<=i.startRow&&t>i.startColumn)return e.getViewport(W.VIEW_MAIN_TOP);if(o>i.startRow&&t<=i.startColumn)return e.getViewport(W.VIEW_MAIN_LEFT)}function Yl(o,t,e,n){const i=Fi(o.left,o.top,t,e,n),r=Fi(o.right,o.bottom,t,e,n);return{left:i.x,top:i.y,right:r.x,bottom:r.y}}function Fi(o,t,e,n,i){const{scaleX:r,scaleY:s}=e.getAncestorScale(),a=e.getViewport(W.VIEW_MAIN);if(!a)return{x:o,y:t};const c=i.getFreeze(),{startColumn:u,startRow:d,xSplit:h,ySplit:m}=c,g=n.getNoMergeCellPositionByIndexWithNoHeader(d-m,u-h),f=n.getNoMergeCellPositionByIndexWithNoHeader(d,u),{rowHeaderWidth:_,columnHeaderHeight:p}=n,v=f.startX-g.startX,M=f.startY-g.startY,{top:b,left:T,actualScrollX:w,actualScrollY:y}=a;let O;o>T?O=(o-w)*r:O=(v+_-(T-o))*r;let x;return t>b?x=(t-y)*s:x=(M+p-(b-t))*r,{x:O,y:x}}function Vr(o,t,e,n,i,r){const{scene:s}=o,{skeleton:a,sheetId:c,unitId:u}=n,d=$l(i,r,s,a);if(!d)return null;const{row:h,col:m,mergeCell:g,actualCol:f,actualRow:_}=d,p={unitId:u,subUnitId:c,workbook:t,worksheet:e,row:_,col:f};let v;g?v=g:v={startRow:h,endRow:h,startColumn:m,endColumn:m};const M=s.getActiveViewportByCoord(E.Vector2.FromArray([i,r]));if(!M)return;const{scaleX:b,scaleY:T}=s.getAncestorScale(),w={x:M.actualScrollX,y:M.actualScrollY};return{position:{startX:(a.getOffsetByPositionX(v.startColumn-1)-w.x)*b,endX:(a.getOffsetByPositionX(v.endColumn)-w.x)*b,startY:(a.getOffsetByPositionY(v.startRow-1)-w.y)*T,endY:(a.getOffsetByPositionY(v.endRow)-w.y)*T},location:p}}var Xl=Object.defineProperty,Gl=Object.getOwnPropertyDescriptor,Zl=(o,t,e,n)=>{for(var i=n>1?void 0:n?Gl(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Xl(t,e,i),i},ho=(o,t)=>(e,n)=>t(e,n,o),xe=(o=>(o[o.OFF=0]="OFF",o[o.ONCE=1]="ONCE",o[o.INFINITE=2]="INFINITE",o))(xe||{});const ft=D.createIdentifier("univer.format-painter-service");let Ao=class extends l.Disposable{constructor(t,e,n){super();R(this,"status$");R(this,"_selectionFormat");R(this,"_markId",null);R(this,"_status$");this._selectionManagerService=t,this._univerInstanceService=e,this._markSelectionService=n,this._status$=new U.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(t){t!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(t),this._status$.next(t)}getStatus(){return this._status$.getValue()}_updateRangeMark(t){if(this._markSelectionService.removeAllShapes(),this._markId=null,t!==0){const e=this._selectionManagerService.getLast();if(e){const n=this._selectionManagerService.createCopyPasteSelection();t===2?this._markId=this._markSelectionService.addShape({...e,style:n}):this._markId=this._markSelectionService.addShape({...e,style:n},[S.SetRangeValuesMutation.id])}}}_getSelectionRangeFormat(){const t=this._selectionManagerService.getLast(),e=t==null?void 0:t.range;if(!e)return;const{startRow:n,endRow:i,startColumn:r,endColumn:s}=e,a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),u=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),d=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;this._selectionFormat.merges=[];for(let g=n;g<=i;g++)for(let f=r;f<=s;f++){const _=u.getValue(g,f);m.setValue(g,f,h.getStyleByCell(_)||{});const{isMergedMainCell:p,...v}=E.getCellInfoInMergeData(g,f,d);p&&this._selectionFormat.merges.push({startRow:v.startRow,startColumn:v.startColumn,endRow:v.endRow,endColumn:v.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};Ao=Zl([ho(0,D.Inject(S.SelectionManagerService)),ho(1,l.IUniverInstanceService),ho(2,nn)],Ao);const si={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(o,t)=>t?(o.get(ft).setStatus(t.status),!0):!1},Br={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async o=>{const e=o.get(ft).getStatus();let n;return e!==xe.OFF?n=xe.OFF:n=xe.INFINITE,o.get(l.ICommandService).executeCommand(si.id,{status:n})}},ai={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async o=>{const e=o.get(ft).getStatus();let n;return e!==xe.OFF?n=xe.OFF:n=xe.ONCE,o.get(l.ICommandService).executeCommand(si.id,{status:n})}},Fr={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(o,t)=>{const e=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(S.SelectionManagerService),s=o.get(S.SheetInterceptorService),a=S.getSheetCommandTarget(i,t);if(!a)return!1;const{worksheet:c,unitId:u,subUnitId:d}=a,h=o.get(S.SheetPermissionService),{styleValues:m,styleRange:g,mergeRanges:f}=t;if(!h.getSheetEditable(u,d))return!1;const _=g?[g]:r.getSelectionRanges();if(!_||!_.length)return!1;const p=new l.ObjectMatrix;let v;if(l.Tools.isArray(m))for(let q=0;q<_.length;q++){const{startRow:K,startColumn:$,endRow:Q,endColumn:P}=_[q];for(let H=0;H<=Q-K;H++)for(let k=0;k<=P-$;k++)p.setValue(H+K,k+$,m[H][k])}else if(l.isICellData(m))for(let q=0;q<_.length;q++){const{startRow:K,startColumn:$}=_[q];p.setValue(K,$,m)}else v=m;const M={subUnitId:d,unitId:u,cellValue:v!=null?v:p.getMatrix()},b=S.SetRangeValuesUndoMutationFactory(o,M),T=e.syncExecuteCommand(S.SetRangeValuesMutation.id,M),{undos:w,redos:y}=s.onCommandExecute({id:S.SetRangeValuesCommand.id,params:{...M,range:_}}),O=S.getAddMergeMutationRangeByType(f),x=[],A=[],F=Lr(c,O),N={unitId:u,subUnitId:d,ranges:O},L={unitId:u,subUnitId:d,ranges:O};x.push({id:S.RemoveWorksheetMergeMutation.id,params:N}),x.push({id:S.AddWorksheetMergeMutation.id,params:L});const B=S.RemoveMergeUndoMutationFactory(o,N),j=S.AddMergeUndoMutationFactory(o,L);if(A.push({id:S.RemoveWorksheetMergeMutation.id,params:j}),A.push({id:S.AddWorksheetMergeMutation.id,params:B}),F){const q=Ur(o,u,c,O);x.unshift(...q.redos),A.push(...q.undos)}const z=await l.sequenceExecute([...y,...x],e);return T&&z.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:S.SetRangeValuesMutation.id,params:b},...w,...A],redoMutations:[{id:S.SetRangeValuesMutation.id,params:M},...y,...x]}),!0):!1}},Qn={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(o,t)=>{const{type:e}=t||{},n=o.get(l.IUniverInstanceService),i=o.get(l.IUndoRedoService),r=S.getSheetCommandTarget(n);if(!r)return!1;const{unitId:s,subUnitId:a}=r,c=o.get(l.ICommandService),d=o.get(S.SelectionManagerService).getSelections();if(!d)return!1;const h=d[(d==null?void 0:d.length)-1],{range:m}=h,g=o.get(Ze),{sheetViewStartRow:f=0,sheetViewStartColumn:_=0}=g.getCurrentScroll()||{};let p,v,M,b;const{startRow:T,startColumn:w,rangeType:y}=m;if(y===l.RANGE_TYPE.ROW||e===1)p=T,M=T-f,v=-1,b=0;else if(y===l.RANGE_TYPE.COLUMN||e===2)p=-1,M=0,v=w,b=w-_;else if(y===l.RANGE_TYPE.NORMAL)p=T,M=T-f,v=w,b=w-_;else return!1;const O={unitId:s,subUnitId:a,startRow:p,startColumn:v,xSplit:v>0?Math.max(1,b):b,ySplit:p>0?Math.max(1,M):M},x=S.SetFrozenMutationFactory(o,O);return c.syncExecuteCommand(S.SetFrozenMutation.id,O)&&i.pushUndoRedo({unitID:s,undoMutations:[{id:S.SetFrozenMutation.id,params:x}],redoMutations:[{id:S.SetFrozenMutation.id,params:O}]}),!0}},kr={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(Qn.id,{type:1}),!0)},Wr={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async o=>(o.get(l.ICommandService).executeCommand(Qn.id,{type:2}),!0)},jr={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async o=>{const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(l.IUndoRedoService),i=S.getSheetCommandTarget(e);if(!i)return!1;const{unitId:r,subUnitId:s}=i,a={unitId:r,subUnitId:s,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},c=S.SetFrozenMutationFactory(o,a);return t.syncExecuteCommand(S.SetFrozenMutation.id,a)&&n.pushUndoRedo({unitID:r,undoMutations:[{id:S.SetFrozenMutation.id,params:c}],redoMutations:[{id:S.SetFrozenMutation.id,params:a}]}),!0}},Nt="UI_PLUGIN_SHEETS",Jn=`${Nt}_COLOR_PICKER_COMPONENT`,$r=`${Nt}_FONT_FAMILY_COMPONENT`,zr=`${Nt}_FONT_FAMILY_ITEM_COMPONENT`,Yr=`${Nt}_FONT_SIZE_COMPONENT`,li=`${Nt}_MENU_ITEM_INPUT_COMPONENT`;var Xr={exports:{}},eo={};/**
8
8
  * @license React
9
9
  * react-jsx-runtime.production.min.js
10
10
  *
@@ -12,10 +12,10 @@
12
12
  *
13
13
  * This source code is licensed under the MIT license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
- */var Xl=U,Gl=Symbol.for("react.element"),Zl=Symbol.for("react.fragment"),Kl=Object.prototype.hasOwnProperty,ql=Xl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ql={key:!0,ref:!0,__self:!0,__source:!0};function zr(o,t,e){var n,i={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Kl.call(t,n)&&!Ql.hasOwnProperty(n)&&(i[n]=t[n]);if(o&&o.defaultProps)for(n in t=o.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:Gl,type:o,key:r,ref:s,props:i,_owner:ql.current}}Jn.Fragment=Zl;Jn.jsx=zr;Jn.jsxs=zr;$r.exports=Jn;var C=$r.exports;const Jl="univer-sheets-ui-context-menu-input",ec="univer-sheets-ui-context-menu-input-container",tc="univer-sheets-ui-context-menu-input-number",ho={sheetsUiContextMenuInput:Jl,sheetsUiContextMenuInputContainer:ec,sheetsUiContextMenuInputNumber:tc},nc=o=>{const{prefix:t,suffix:e,value:n,onChange:i,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=o,a=G.useDependency(l.LocaleService),[c,d]=U.useState(),u=m=>{var g;d(m==null?void 0:m.toString()),i((g=m==null?void 0:m.toString())!=null?g:"")};U.useEffect(()=>{d(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return C.jsxs("div",{className:ho.sheetsUiContextMenuInput,children:[a.t(t),C.jsx("span",{className:ho.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:C.jsx(re.InputNumber,{className:ho.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:u,min:r,max:s})}),a.t(e)]})};var le=(o=>(o.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",o.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",o.SHEET_BAR="sheetBar",o))(le||{});function oc(o){const t=o.get(ft);return{id:ri.id,subId:Lr.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[v.MenuPosition.TOOLBAR_START],activated$:new B.Observable(e=>{let n=!1;const i=t.status$.subscribe(r=>{n=r!==xe.OFF,e.next(n)});return e.next(n),()=>{i.unsubscribe()}}),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}function ic(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(l.IContextService),i=o.get(_.SelectionManagerService);return{id:ei.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[v.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new B.Observable(s=>{var u;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(g=i.getLast())==null?void 0:g.primary;let p=l.FontWeight.NORMAL;if(S!=null){const I=r.getRange(S.startRow,S.startColumn);p=I==null?void 0:I.getFontWeight()}s.next(p===l.FontWeight.BOLD)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&n.getContextValue(l.EDITOR_ACTIVATED)&&n.getContextValue(l.FOCUSING_SHEET)){const S=on(o);if(S==null)return;const p=(f=S.ts)==null?void 0:f.bl;s.next(p===l.BooleanNumber.TRUE)}}),c=(u=i.getLast())==null?void 0:u.primary;if(!r){s.next(!1);return}let d=l.FontWeight.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===l.FontWeight.BOLD),a.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function rc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService),i=o.get(l.IContextService);return{id:ti.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[v.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new B.Observable(s=>{var u;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(g=n.getLast())==null?void 0:g.primary;let p=l.FontItalic.NORMAL;if(S!=null){const I=r.getRange(S.startRow,S.startColumn);p=I==null?void 0:I.getFontStyle()}s.next(p===l.FontItalic.ITALIC)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const S=on(o);if(S==null)return;const p=(f=S.ts)==null?void 0:f.it;s.next(p===l.BooleanNumber.TRUE)}}),c=(u=n.getLast())==null?void 0:u.primary;let d=l.FontItalic.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===l.FontItalic.ITALIC),a.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function sc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService),i=o.get(l.IContextService);return{id:ni.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[v.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new B.Observable(s=>{var u;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(g=n.getLast())==null?void 0:g.primary;let p;if(S!=null){const I=r.getRange(S.startRow,S.startColumn);p=I==null?void 0:I.getUnderline()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const S=on(o);if(S==null)return;const p=(f=S.ts)==null?void 0:f.ul;s.next((p==null?void 0:p.s)===l.BooleanNumber.TRUE)}}),c=(u=n.getLast())==null?void 0:u.primary;let d;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),a.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function ac(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService),i=o.get(l.IContextService);return{id:oi.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[v.MenuPosition.TOOLBAR_START],disabled$:_.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new B.Observable(s=>{var u;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===_.SetRangeValuesMutation.id||m===_.SetSelectionsOperation.id||m===_.SetWorksheetActiveOperation.id){const S=(g=n.getLast())==null?void 0:g.primary;let p;if(S!=null){const I=r.getRange(S.startRow,S.startColumn);p=I==null?void 0:I.getStrikeThrough()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const S=on(o);if(S==null)return;const p=(f=S.ts)==null?void 0:f.st;s.next((p==null?void 0:p.s)===l.BooleanNumber.TRUE)}}),c=(u=n.getLast())==null?void 0:u.primary;let d;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),a.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function lc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService),i=v.FONT_FAMILY_LIST[0].value;return{id:Dr.id,tooltip:"toolbar.font",group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.SELECTOR,label:Fr,positions:[v.MenuPosition.TOOLBAR_START],selections:v.FONT_FAMILY_LIST.map(r=>({label:{name:Wr,hoverable:!0},value:r.value})),disabled$:_.getCurrentSheetDisabled$(o),value$:_e(e,i,({worksheet:r})=>new B.Observable(s=>{var u;const a=t.onCommandExecuted(h=>{var S;const m=h.id;if(m!==_.SetRangeValuesMutation.id&&m!==_.SetSelectionsOperation.id&&m!==_.SetWorksheetActiveOperation.id)return;const g=(S=n.getLast())==null?void 0:S.primary;let f;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);f=p==null?void 0:p.getFontFamily()}s.next(f!=null?f:i)}),c=(u=n.getLast())==null?void 0:u.primary;let d;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontFamily()}return s.next(d!=null?d:i),a.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function cc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService),i=o.get(l.IContextService),r=_.getCurrentSheetDisabled$(o),s=11;return{id:Ar.id,group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:jr,props:{min:1,max:400,disabled$:r}},positions:[v.MenuPosition.TOOLBAR_START],selections:v.FONT_SIZE_LIST,disabled$:r,value$:_e(e,s,({worksheet:a})=>new B.Observable(c=>{var m;const d=t.onCommandExecuted(g=>{var S,p;const f=g.id;if(f===_.SetRangeValuesMutation.id||f===_.SetSelectionsOperation.id||f===_.SetWorksheetActiveOperation.id){const I=(S=n.getLast())==null?void 0:S.primary;let M;if(I!=null){const b=a.getRange(I.startRow,I.startColumn);M=b==null?void 0:b.getFontSize()}c.next(M!=null?M:s)}if((f===te.SetTextSelectionsOperation.id||f===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const I=on(o);if(I==null)return;const M=(p=I.ts)==null?void 0:p.fs;c.next(M!=null?M:s)}}),u=(m=n.getLast())==null?void 0:m.primary;let h;if(u!=null){const g=a.getRange(u.startRow,u.startColumn);h=g==null?void 0:g.getFontSize()}return c.next(h!=null?h:s),d.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function dc(o){return{id:_.ResetTextColorCommand.id,type:v.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:kn.id,disabled$:_.getCurrentSheetDisabled$(o)}}function uc(o){const t=o.get(l.ICommandService),e=o.get(l.ThemeService);return{id:kn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON_SELECTOR,positions:[v.MenuPosition.TOOLBAR_START],selections:[{label:{name:Qn,hoverable:!1}}],value$:new B.Observable(n=>{const i=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===kn.id){const a=s.params.value;n.next(a!=null?a:i)}});return n.next(i),r.dispose}),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}function hc(o){return{id:_.ResetBackgroundColorCommand.id,type:v.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:_.SetBackgroundColorCommand.id,disabled$:_.getCurrentSheetDisabled$(o)}}function mc(o){const t=o.get(l.ICommandService),e=o.get(l.ThemeService);return{id:_.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:v.MenuGroup.TOOLBAR_FORMAT,type:v.MenuItemType.BUTTON_SELECTOR,positions:[v.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Qn,hoverable:!1}}],value$:new B.Observable(n=>{const i=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===_.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a!=null?a:i)}});return n.next(i),r.dispose}),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}const Bi=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function gc(o){const t=o.get(l.IUniverInstanceService),e=o.get(_.SelectionManagerService);return{id:_.SetHorizontalTextAlignCommand.id,icon:Bi[0].icon,positions:[v.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:v.MenuGroup.TOOLBAR_LAYOUT,type:v.MenuItemType.SELECTOR,selections:Bi,value$:_e(t,l.HorizontalAlign.LEFT,({worksheet:n})=>new B.Observable(i=>{var c;const r=o.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==_.SetHorizontalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(g=e.getLast())==null?void 0:g.primary;let m;if(h!=null){const f=n.getRange(h.startRow,h.startColumn);m=f==null?void 0:f.getHorizontalAlignment()}i.next(m!=null?m:l.HorizontalAlign.LEFT)}),s=(c=e.getLast())==null?void 0:c.primary;let a;if(s!=null){const d=n.getRange(s.startRow,s.startColumn);a=d==null?void 0:d.getHorizontalAlignment()}return i.next(a!=null?a:l.HorizontalAlign.LEFT),r.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}const ki=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function fc(o){const t=o.get(l.IUniverInstanceService),e=o.get(_.SelectionManagerService);return{id:_.SetVerticalTextAlignCommand.id,icon:ki[2].icon,tooltip:"toolbar.verticalAlignMode.main",group:v.MenuGroup.TOOLBAR_LAYOUT,type:v.MenuItemType.SELECTOR,positions:[v.MenuPosition.TOOLBAR_START],selections:ki,value$:_e(t,l.VerticalAlign.BOTTOM,({worksheet:n})=>new B.Observable(i=>{var c;const r=o.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==_.SetVerticalTextAlignCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(g=e.getLast())==null?void 0:g.primary;let m;if(h!=null){const f=n.getRange(h.startRow,h.startColumn);m=f==null?void 0:f.getVerticalAlignment()}i.next(m!=null?m:l.VerticalAlign.BOTTOM)}),s=(c=e.getLast())==null?void 0:c.primary;let a;if(s!=null){const d=n.getRange(s.startRow,s.startColumn);a=d==null?void 0:d.getVerticalAlignment()}return i.next(a!=null?a:l.VerticalAlign.BOTTOM),r.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}const Fi=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function _c(o){const t=o.get(_.SelectionManagerService),e=o.get(l.IUniverInstanceService);return{id:_.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:Fi[0].icon,group:v.MenuGroup.TOOLBAR_LAYOUT,type:v.MenuItemType.SELECTOR,positions:[v.MenuPosition.TOOLBAR_START],selections:Fi,value$:_e(e,l.WrapStrategy.OVERFLOW,({worksheet:n})=>new B.Observable(i=>{var c;const r=o.get(l.ICommandService).onCommandExecuted(d=>{var g;const u=d.id;if(u!==_.SetTextWrapCommand.id&&u!==_.SetSelectionsOperation.id&&u!==_.SetWorksheetActiveOperation.id)return;const h=(g=t.getLast())==null?void 0:g.primary;let m;if(h!=null){const f=n.getRange(h.startRow,h.startColumn);m=f==null?void 0:f.getWrapStrategy()}i.next(m!=null?m:l.WrapStrategy.OVERFLOW)}),s=(c=t.getLast())==null?void 0:c.primary;let a;if(s!=null){const d=n.getRange(s.startRow,s.startColumn);a=d==null?void 0:d.getWrapStrategy()}return i.next(a!=null?a:l.WrapStrategy.OVERFLOW),r.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}const Wi=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function Sc(o){const t=o.get(_.SelectionManagerService),e=o.get(l.IUniverInstanceService);return{id:_.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Wi[0].icon,group:v.MenuGroup.TOOLBAR_LAYOUT,type:v.MenuItemType.SELECTOR,selections:Wi,positions:[v.MenuPosition.TOOLBAR_START],value$:_e(e,0,({worksheet:n})=>new B.Observable(i=>{var c,d;const r=o.get(l.ICommandService).onCommandExecuted(u=>{var f,S;const h=u.id;if(h!==_.SetTextRotationCommand.id&&h!==_.SetSelectionsOperation.id&&h!==_.SetWorksheetActiveOperation.id)return;const m=(f=t.getLast())==null?void 0:f.primary;let g;if(m!=null){const p=n.getRange(m.startRow,m.startColumn);g=p==null?void 0:p.getTextRotation()}(g==null?void 0:g.v)===l.BooleanNumber.TRUE?i.next("v"):i.next((S=g&&g.a)!=null?S:0)}),s=(c=t.getLast())==null?void 0:c.primary;let a;if(s!=null){const u=n.getRange(s.startRow,s.startColumn);a=u==null?void 0:u.getTextRotation()}return(a==null?void 0:a.v)===l.BooleanNumber.TRUE?i.next("v"):i.next((d=a&&a.a)!=null?d:0),r.dispose})),hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentSheetDisabled$(o)}}function At(o){return new B.Observable(t=>t.next(!o.get(v.IClipboardInterfaceService).supportClipboard))}function pc(){return{id:v.CopyCommand.id,group:v.MenuGroup.CONTEXT_MENU_FORMAT,type:v.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[v.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Cc(o){return{id:v.PasteCommand.id,group:v.MenuGroup.CONTEXT_MENU_FORMAT,type:v.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:At(o),positions:[v.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Dt="sheet.menu.paste-special";function vc(o){return{id:Dt,group:v.MenuGroup.CONTEXT_MENU_FORMAT,type:v.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:At(o),positions:[v.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Ic(o){return{id:vr.id,type:v.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Dt],disabled$:At(o)}}function Rc(o){return{id:Ir.id,type:v.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Dt],disabled$:At(o)}}function Mc(o){return{id:Rr.id,type:v.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Dt],disabled$:At(o)}}function bc(o){return{id:Mr.id,type:v.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Dt],disabled$:At(o)}}function Tc(){return{id:_.SetWorksheetRowIsAutoHeightCommand.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const nn="sheet.menu.sheet-frozen";function wc(){return{id:nn,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[v.MenuPosition.CONTEXT_MENU]}}const ai="sheet.header-menu.sheet-frozen";function Ec(){return{id:ai,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function yc(){return{id:qn.id,type:v.MenuItemType.BUTTON,positions:[nn,ai],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function Oc(){return{id:Vr.id,type:v.MenuItemType.BUTTON,positions:[nn],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function xc(){return{id:Br.id,type:v.MenuItemType.BUTTON,positions:[nn],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function Nc(){return{id:kr.id,type:v.MenuItemType.BUTTON,positions:[nn,ai],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Ac(){return{id:xr.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Dc(){return{id:Nr.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Pc(o){const t=o.get(l.IUniverInstanceService),e=o.get(_.SelectionManagerService),n=o.get(l.ICommandService),i=[_.SetSelectionsOperation,_.SetRowHiddenMutation,_.SetRowVisibleMutation].map(r=>r.id);return{id:_.SetSelectedRowsVisibleCommand.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:_e(t,!0,({worksheet:r})=>new B.Observable(s=>{function a(){var u;const d=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===l.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let m=h.startRow;m<=h.endRow;m++)if(!r.getRowRawVisible(m))return!0;return!1}))}const c=n.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!a())});return s.next(!a()),()=>c.dispose()}))}}function Hc(o){const t=o.get(l.IUniverInstanceService),e=o.get(_.SelectionManagerService),n=o.get(l.ICommandService),i=[_.SetSelectionsOperation,_.SetColHiddenMutation,_.SetColVisibleMutation].map(r=>r.id);return{id:_.SetSelectedColsVisibleCommand.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:_e(t,!0,({worksheet:r})=>new B.Observable(s=>{function a(){var u;const d=(u=e.getSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===l.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let m=h.startColumn;m<=h.endColumn;m++)if(!r.getColVisible(m))return!0;return!1})}const c=n.onCommandExecuted(d=>{i.findIndex(u=>u===d.id)!==-1&&s.next(!a())});return s.next(!a()),()=>c.dispose()}))}}function Lc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService);return{id:_.SetRowHeightCommand.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:si,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:i})=>new B.Observable(r=>{function s(){var u;const c=(u=n.getLast())==null?void 0:u.primary,d=c?i.getRowHeight(c.startRow):0;r.next(d)}const a=t.onCommandExecuted(c=>{const d=c.id;if(d===_.SetRangeValuesMutation.id||d===_.SetSelectionsOperation.id||d===_.SetWorksheetRowIsAutoHeightMutation.id)return s()});return s(),a.dispose}))}}function Uc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(_.SelectionManagerService);return{id:_.SetColWidthCommand.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:si,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:_e(e,0,({worksheet:i})=>new B.Observable(r=>{function s(){var u;const c=(u=n.getLast())==null?void 0:u.primary;let d=0;c!=null&&(d=i.getColumnWidth(c.startColumn)),r.next(d)}const a=t.onCommandExecuted(c=>{const d=c.id;if(d===_.SetRangeValuesMutation.id||d===_.SetSelectionsOperation.id||d===_.SetWorksheetColWidthMutation.id)return s()});return s(),a.dispose}))}}function on(o){var c;const t=o.get(l.IUniverInstanceService),e=o.get(te.TextSelectionManagerService),n=t.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveRange();if(n==null||i==null)return null;const r=(c=n.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=i;return r.find(({st:d,ed:u})=>s>=d&&s<=u)}function Vc(){const o=G.useDependency(l.IUniverInstanceService),t=v.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t!=null?t:null}function Bc(o){return v.useObservable(()=>{var e;return(e=o==null?void 0:o.activeSheet$)!=null?e:B.of(null)},void 0,void 0,[o])}const kc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormatting:"Conditional formatting",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging",waring:"Waring",dismantleMergeCellWaring:"This will cause some merged cells to be split. Do you want to continue?"}},filter:{confirm:{error:"There was a problem",notAllowedToInsertRange:"Not allowed to move cells here until filter is cleared"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor",deleteAllRowsAlert:"You can't delete all the rows on the sheet",deleteAllColumnsAlert:"You can't delete all the columns on the sheet",hideAllRowsAlert:"You can't hide all the rows on the sheet",hideAllColumnsAlert:"You can't hide all the columns on the sheet"},info:{tooltip:"Tooltip",error:"Error",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total}, ${totalPage} page, current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total}, ${totalPage} page, All data displayed",problem:"There was a problem",forceStringInfo:"Number stored as text"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells",overlappingMergedCells:"The paste area overlaps with merged cells"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},Fc=kc,Wc={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalFormatting:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并",waring:"警告",dismantleMergeCellWaring:"此操作会导致一些合并单元格被拆散,是否继续?"}},filter:{confirm:{error:"出现了一个问题",notAllowedToInsertRange:"要移动这些单元格,请清除该区域的筛选器"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
16
- [ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑",deleteAllRowsAlert:"您无法删除工作表上的所有行",deleteAllColumnsAlert:"您无法删除工作表上的所有列",hideAllRowsAlert:"您无法隐藏工作表上的所有行",hideAllColumnsAlert:"您无法隐藏工作表上的所有列"},info:{tooltip:"提示",error:"错误",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据",problem:"出现了一个问题",forceStringInfo:"以文本形式存储的数字"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数",overlappingMergedCells:"粘贴区域与合并单元格重叠"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}},Yr=Wc,jc={spreadsheetLabel:"Электронная таблица",spreadsheetRightLabel:"больше листов",toolbar:{undo:"Отменить",redo:"Повторить",formatPainter:"Копировать формат",currencyFormat:"Форматировать как валюту",percentageFormat:"Форматировать как процент",numberDecrease:"Уменьшить количество десятичных знаков",numberIncrease:"Увеличить количество десятичных знаков",moreFormats:"Больше форматов",font:"Шрифт",fontSize:"Размер шрифта",bold:"Жирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},resetColor:"Сбросить",customColor:"ПОЛЬЗ.",alternatingColors:"Чередующиеся цвета",confirmColor:"ОК",cancelColor:"Отмена",collapse:"Свернуть",fillColor:{main:"Цвет заливки",right:"Выбрать цвет"},border:{main:"Граница",right:"Стиль границы"},mergeCell:{main:"Объединить ячейки",right:"Выбрать тип объединения"},horizontalAlignMode:{main:"Горизонтальное выравнивание",right:"Выравнивание"},verticalAlignMode:{main:"Вертикальное выравнивание",right:"Выравнивание"},textWrapMode:{main:"Перенос текста",right:"Режим переноса текста"},textRotateMode:{main:"Поворот текста",right:"Режим поворота текста"},freezeTopRow:"Закрепить верхнюю строку",sortAndFilter:"Сортировка и фильтр",findAndReplace:"Найти и заменить",sum:"СУММ",autoSum:"Авто СУММ",moreFunction:"Больше функций",conditionalFormatting:"Условное форматирование",comment:"Комментарий",pivotTable:"Сводная таблица",chart:"Диаграмма",screenshot:"Снимок экрана",splitColumn:"Разделить текст",insertImage:"Вставить изображение",insertLink:"Вставить ссылку",dataValidation:"Проверка данных",protection:"Защита листа",clearText:"Очистить цвет",noColorSelectedText:"Цвет не выбран",toolMore:"Больше",toolLess:"Меньше",toolClose:"Закрыть",toolMoreTip:"Больше возможностей",moreOptions:"Больше опций",cellFormat:"Настройка формата ячейки",print:"Печать",borderMethod:{top:"Верхняя рамка",bottom:"Нижняя рамка",left:"Левая рамка",right:"Правая рамка"},more:"Больше"},defaultFmt:{Automatic:{text:"Автоматический",value:"Общий",example:""},Number:{text:"Число",value:"##0.00",example:"1000.12"},Percent:{text:"Процент",value:"#0.00%",example:"12.21%"},PlainText:{text:"Простой текст",value:"@",example:""},Scientific:{text:"Научный",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Бухгалтерский учет",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Десять тысяч",value:"w",example:"1億2000万2500"},Currency:{text:"Валюта",value:"¥0.00",example:"¥1200.09"},Digit:{text:"Десятичные 2 знака",value:"w0.00",example:"2万2500.55"},Date:{text:"Дата",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Время",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Время 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Дата и время",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Дата и время 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Пользовательские форматы",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"Больше форматов валюты",moreDateTime:"Больше форматов даты и времени",moreNumber:"Больше форматов чисел",titleCurrency:"Форматы валюты",decimalPlaces:"Десятичные знаки",titleDateTime:"Форматы даты и времени",titleNumber:"Числовые форматы"},print:{normalBtn:"Обычный",layoutBtn:"Макет страницы",pageBtn:"Предпросмотр разрыва страницы",menuItemPrint:"Печать (Ctrl+P)",menuItemAreas:"Области печати",menuItemRows:"Печатать строки заголовков",menuItemColumns:"Печатать столбцы заголовков"},align:{left:"лево",center:"центр",right:"право",top:"верх",middle:"середина",bottom:"низ"},button:{confirm:"ОК",cancel:"Отмена",close:"Закрыть",update:"Обновить",delete:"Удалить",insert:"Вставить",prevPage:"Предыдущая",nextPage:"Следующая",total:"всего:"},punctuation:{tab:"Табуляция",semicolon:"точка с запятой",comma:"запятая",space:"пробел"},colorPicker:{collapse:"Свернуть",customColor:"ПОЛЬЗ.",change:"Изменить",confirmColor:"ОК",cancelColor:"Отмена"},borderLine:{borderTop:"верхняя граница",borderBottom:"нижняя граница",borderLeft:"левая граница",borderRight:"правая граница",borderNone:"без границы",borderAll:"все границы",borderOutside:"внешняя граница",borderInside:"внутренняя граница",borderHorizontal:"горизонтальная граница",borderVertical:"вертикальная граница",borderColor:"цвет границы",borderSize:"размер границы",borderType:"тип границы"},merge:{all:"Объединить все",vertical:"Вертикальное объединение",horizontal:"Горизонтальное объединение",cancel:"Отменить объединение",overlappingError:"Невозможно объединить перекрывающиеся области",partiallyError:"Невозможно выполнить эту операцию на частично объединенных ячейках",confirm:{title:"Продолжение объединения сохранит только значение в верхней левой ячейке, остальные значения будут удалены. Вы уверены, что хотите продолжить?",cancel:"Отменить объединение",confirm:"Продолжить объединение",waring:"Предупреждение",dismantleMergeCellWaring:"Это приведет к разделению некоторых объединенных ячеек. Продолжить?"}},filter:{confirm:{error:"Произошла ошибка",notAllowedToInsertRange:"Нельзя перемещать ячейки сюда, пока фильтр не будет очищен"}},textWrap:{overflow:"Переполнение",wrap:"Перенос",clip:"Обрезать"},textRotate:{none:"Нет",angleUp:"Повернуть вверх",angleDown:"Повернуть вниз",vertical:"Вертикально",rotationUp:"Поворот вверх",rotationDown:"Поворот вниз"},sheetConfig:{delete:"Удалить",copy:"Копировать",rename:"Переименовать",changeColor:"Изменить цвет",hide:"Скрыть",unhide:"Показать",moveLeft:"Переместить влево",moveRight:"Переместить вправо",resetColor:"Сбросить цвет",cancelText:"Отмена",chooseText:"Подтвердить цвет",tipNameRepeat:"Имя вкладки не может повторяться! Пожалуйста, исправьте",noMoreSheet:"В книге должен содержаться хотя бы один видимый лист. Чтобы удалить выбранный лист, вставьте новый лист или покажите скрытый лист.",confirmDelete:"Вы уверены, что хотите удалить",redoDelete:"Можно отменить с помощью Ctrl+Z",noHide:"Нельзя скрыть, оставьте хотя бы одну вкладку листа",chartEditNoOpt:"Эта операция недоступна в режиме редактирования диаграммы!",sheetNameErrorTitle:"Произошла ошибка",sheetNameSpecCharError:`Имя не может содержать: [ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"Имя листа не может быть пустым.",sheetNameAlreadyExistsError:"Имя листа уже существует. Пожалуйста, введите другое имя.",deleteSheet:"Удалить лист",deleteSheetContent:"Подтвердите удаление этого листа. После удаления его нельзя будет восстановить. Вы уверены, что хотите удалить его?"},rightClick:{copy:"Копировать",copyAs:"Копировать как",cut:"Вырезать",paste:"Вставить",pasteSpecial:"Специальная вставка",pasteValue:"Вставить значение",pasteFormat:"Вставить формат",pasteColWidth:"Вставить ширину столбца",pasteBesidesBorder:"Вставить кроме стилей границы",insert:"Вставить",insertRow:"Вставить строку",insertRowBefore:"Вставить строку выше",insertColumn:"Вставить столбец",insertColumnBefore:"Вставить столбец слева",delete:"Удалить",deleteCell:"Удалить ячейку",insertCell:"Вставить ячейку",deleteSelected:"Удалить выбранное",hide:"Скрыть",hideSelected:"Скрыть выбранное",showHide:"Показать скрытые",toTopAdd:"Добавить сверху",toBottomAdd:"Добавить снизу",toLeftAdd:"Добавить слева",toRightAdd:"Добавить справа",deleteSelectedRow:"Удалить выбранную строку",deleteSelectedColumn:"Удалить выбранный столбец",hideSelectedRow:"Скрыть выбранную строку",showHideRow:"Показать скрытую строку",rowHeight:"Высота строки",hideSelectedColumn:"Скрыть выбранный столбец",showHideColumn:"Показать скрытый столбец",columnWidth:"Ширина столбца",to:"К",left:"Лево",right:"Право",top:"Верх",bottom:"Низ",moveLeft:"Переместить влево",moveUp:"Переместить вверх",moveRight:"Переместить вправо",moveDown:"Переместить вниз",add:"Добавить",row:"Строка",column:"Столбец",width:"Ширина",height:"Высота",number:"Номер",confirm:"Подтвердить",orderAZ:"Порядок А-Я",orderZA:"Порядок Я-А",clearSelection:"Очистить",clearContent:"Очистить содержимое",clearFormat:"Очистить формат",clearAll:"Очистить все",matrix:"Матричная операция",sortSelection:"Сортировать",filterSelection:"Фильтр",chartGeneration:"Создать диаграмму",firstLineTitle:"Заголовок первой строки",untitled:"Без названия",array1:"Одномерный массив",array2:"Двумерный массив",array3:"Многомерные массивы",diagonal:"Диагональ",antiDiagonal:"Антидиагональ",diagonalOffset:"Смещение диагонали",offset:"Смещение",boolean:"Булевый",flip:"Перевернуть",upAndDown:"Вверх и вниз",leftAndRight:"Влево и вправо",clockwise:"По часовой стрелке",counterclockwise:"Против часовой стрелки",transpose:"Транспонировать",matrixCalculation:"Матричное вычисление",plus:"Плюс",minus:"Минус",multiply:"Умножить",divided:"Делить",power:"Степень",root:"Корень",log:"Логарифм",delete0:"Удалить значения 0 с обоих концов",removeDuplicate:"Удалить дубликаты значений",byRow:"По строке",byCol:"По столбцу",generateNewMatrix:"Создать новую матрицу",fitContent:"Подогнать под данные",freeze:"Закрепить",freezeCol:"Закрепить до этого столбца",freezeRow:"Закрепить до этой строки",cancelFreeze:"Отменить закрепление",zenEditor:"Редактор на весь экран",deleteAllRowsAlert:"Нельзя удалить все строки на листе",deleteAllColumnsAlert:"Нельзя удалить все столбцы на листе",hideAllRowsAlert:"Нельзя скрыть все строки на листе",hideAllColumnsAlert:"Нельзя скрыть все столбцы на листе"},info:{tooltip:"Подсказка",error:"Ошибка",notChangeMerge:"Вы не можете частично изменить объединенные ячейки",detailUpdate:"Новый открытый",detailSave:"Восстановлено из локального кэша",row:"",column:"",loading:"Загрузка...",copy:"Копировать",return:"Выход",rename:"Переименовать",tips:"Переименовать",noName:"Электронная таблица без названия",wait:"ожидание обновления",add:"Добавить",addLast:"больше строк внизу",backTop:"Вернуться наверх",pageInfo:"Всего ${total}, ${totalPage} страниц, текущая ${currentPage}",nextPage:"Следующая",tipInputNumber:"Пожалуйста, введите число",tipInputNumberLimit:"Диапазон увеличения ограничен от 1 до 100",tipRowHeightLimit:"Высота строки должна быть в пределах от 0 до 545",tipColumnWidthLimit:"Ширина столбца должна быть в пределах от 0 до 2038",pageInfoFull:"Всего ${total}, ${totalPage} страниц, все данные отображены",problem:"Произошла проблема",forceStringInfo:"Число хранится как текст"},clipboard:{paste:{exceedMaxCells:"Количество вставляемых ячеек превышает максимальное количество ячеек",overlappingMergedCells:"Область вставки перекрывается с объединенными ячейками"},shortCutNotify:{title:"Используйте сочетания клавиш для вставки.",useShortCutInstead:"Обнаружено содержимое Excel. Используйте сочетание клавиш для вставки."}},statusbar:{sum:"Сумма",average:"Среднее",min:"Минимум",max:"Максимум",count:"Числовое количество",countA:"Количество",clickToCopy:"Нажмите, чтобы скопировать",copied:"Скопировано"},autoFill:{copy:"Копировать ячейку",series:"Заполнить серию",formatOnly:"Только формат",noFormat:"Без формата"},rangeSelector:{placeholder:"Выберите диапазон или введите значение",tooltip:"Выберите диапазон"},shortcut:{sheet:{"zoom-in":"Увеличить","zoom-out":"Уменьшить","reset-zoom":"Сбросить масштаб","select-below-cell":"Выбрать ячейку ниже","select-up-cell":"Выбрать ячейку выше","select-left-cell":"Выбрать ячейку слева","select-right-cell":"Выбрать ячейку справа","select-next-cell":"Выбрать следующую ячейку","select-previous-cell":"Выбрать предыдущую ячейку","select-up-value-cell":"Выбрать ячейку выше со значением","select-below-value-cell":"Выбрать ячейку ниже со значением","select-left-value-cell":"Выбрать ячейку слева со значением","select-right-value-cell":"Выбрать ячейку справа со значением","expand-selection-down":"Расширить выделение вниз","expand-selection-up":"Расширить выделение вверх","expand-selection-left":"Расширить выделение влево","expand-selection-right":"Расширить выделение вправо","expand-selection-to-left-gap":"Расширить выделение до левого пробела","expand-selection-to-below-gap":"Расширить выделение до нижнего пробела","expand-selection-to-right-gap":"Расширить выделение до правого пробела","expand-selection-to-up-gap":"Расширить выделение до верхнего пробела","select-all":"Выбрать все","toggle-editing":"Переключить редактирование","delete-and-start-editing":"Очистить и начать редактирование","abort-editing":"Прервать редактирование","break-line":"Разрыв строки","set-bold":"Переключить жирный","set-italic":"Переключить курсив","set-underline":"Переключить подчеркивание","set-strike-through":"Переключить зачеркивание"}},"sheet-view":"Просмотр листа","sheet-edit":"Редактирование листа",definedName:{managerTitle:"Управление именами",managerDescription:"Создайте определенное имя, выбрав ячейки или формулы и введя желаемое имя в текстовое поле.",addButton:"Добавить определенное имя",featureTitle:"Определенные имена",ratioRange:"Диапазон",ratioFormula:"Формула",confirm:"Подтвердить",cancel:"Отмена",scopeWorkbook:"Книга",inputNamePlaceholder:"Введите имя (без пробелов)",inputCommentPlaceholder:"Введите комментарий",inputRangePlaceholder:"Введите диапазон (без пробелов)",inputFormulaPlaceholder:"Введите формулу (без пробелов)",nameEmpty:"Имя не может быть пустым",nameDuplicate:"Имя уже существует",formulaOrRefStringEmpty:"Формула или строка ссылки не может быть пустой",formulaOrRefStringInvalid:"Неверная формула или строка ссылки",defaultName:"ОпределенноеИмя",updateButton:"Обновить",deleteButton:"Удалить",deleteConfirmText:"Вы уверены, что хотите удалить это определенное имя?",nameConflict:"Имя конфликтует с именем функции",nameInvalid:"Имя недействительно",nameSheetConflict:"Имя конфликтует с именем листа"}},$c=jc;class Xr{constructor(){R(this,"_state",null);R(this,"_rect",null);R(this,"_state$",new B.BehaviorSubject(null));R(this,"state$",this._state$.asObservable());R(this,"_rect$",new B.BehaviorSubject(null));R(this,"rect$",this._rect$.asObservable());R(this,"_focus",!1);R(this,"_focus$",new B.BehaviorSubject(this._focus));R(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const rn=P.createIdentifier("univer.sheet-cell-editor-manager.service");class zc{constructor(){R(this,"_position",null);R(this,"_position$",new B.BehaviorSubject(null));R(this,"position$",this._position$.asObservable());R(this,"_focus",!1);R(this,"_focus$",new B.BehaviorSubject(this._focus));R(this,"focus$",this._focus$.asObservable());R(this,"_fxBtnClick$",new B.Subject);R(this,"fxBtnClick$",this._fxBtnClick$.asObservable());R(this,"_foldBtnStatus$",new B.Subject);R(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const eo=P.createIdentifier("univer.sheet-formula-editor-manager.service");var Yc=Object.defineProperty,Xc=Object.getOwnPropertyDescriptor,Gc=(o,t,e,n)=>{for(var i=n>1?void 0:n?Xc(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Yc(t,e,i),i},ji=(o,t)=>(e,n)=>t(e,n,o);let Mn=class extends l.Disposable{constructor(t,e){super();R(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===_.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{if(n.id===_.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(i!=null&&i.fromCollab)){if(n.id===_.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===_.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i||i.getActiveSheet().getSheetId()!==n)return;const s=i.getActiveSheetIndex(),a=$i(i,s);this._switchToNextSheet(e,a)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i)return;const r=i.getSheetBySheetId(n);r&&(this._previousSheetIndex=i.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=$i(n,s);this._switchToNextSheet(e,a)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(_.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Mn=Gc([l.OnLifecycle(l.LifecycleStages.Ready,Mn),ji(0,l.ICommandService),ji(1,l.IUniverInstanceService)],Mn);function $i(o,t){const e=o.getSheetSize();for(let n=t;n>-1;n--){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}for(let n=t;n<e;n++){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Zc=Object.defineProperty,Kc=Object.getOwnPropertyDescriptor,qc=(o,t,e,n)=>{for(var i=n>1?void 0:n?Kc(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Zc(t,e,i),i},Wt=(o,t)=>(e,n)=>t(e,n,o);exports.AutoHeightController=class extends l.Disposable{constructor(t,e,n,i,r){super(),this._injector=t,this._sheetInterceptorService=e,this._selectionManagerService=n,this._univerInstanceService=i,this._sheetSkeletonManagerService=r,this._initialize()}getUndoRedoParamsOfAutoHeight(t){const{_univerInstanceService:e,_sheetSkeletonManagerService:n,_injector:i}=this,{skeleton:r}=n.getCurrent(),s=r.calculateAutoHeightInRange(t),a=e.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),c=a.getUnitId(),u={subUnitId:a.getActiveSheet().getSheetId(),unitId:c,rowsAutoHeightInfo:s},h=_.SetWorksheetRowAutoHeightMutationFactory(i,u);return{undos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:h}],redos:[{id:_.SetWorksheetRowAutoHeightMutation.id,params:u}]}}_initialize(){const{_sheetInterceptorService:t,_selectionManagerService:e}=this;this.disposeWithMe(t.interceptCommand({getMutations:n=>n.id!==_.SetRangeValuesCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(n.params.range)})),this.disposeWithMe(t.interceptCommand({getMutations:n=>n.id!==_.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(n.params.ranges)})),this.disposeWithMe(t.interceptCommand({getMutations:n=>{var s;if(n.id!==_.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((s=n.params)==null?void 0:s.style.type))return{redos:[],undos:[]};const r=e.getSelectionRanges();return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r):{redos:[],undos:[]}}}))}};exports.AutoHeightController=qc([l.OnLifecycle(l.LifecycleStages.Ready,exports.AutoHeightController),Wt(0,P.Inject(P.Injector)),Wt(1,P.Inject(_.SheetInterceptorService)),Wt(2,P.Inject(_.SelectionManagerService)),Wt(3,P.Inject(l.IUniverInstanceService)),Wt(4,P.Inject(exports.SheetSkeletonManagerService))],exports.AutoHeightController);function Qc(o,t,e,n,i){const r=[],s=[];if(n.copyType===Je.CUT){const{undos:a,redos:c}=Jc(o,t,i);r.push(...c),s.push(...a)}else{const{undos:a,redos:c}=Kr(t,e,i);r.push(...c),s.push(...a);const{undos:d,redos:u}=Gr(t,o,e,i);r.push(...u),s.push(...d);const{undos:h,redos:m}=Zr(t,e,i);r.push(...m),s.push(...h);const{undos:g,redos:f}=No(t,e,i);r.push(...f),s.push(...g)}return{undos:s,redos:r}}function Jc(o,t,e){let n=[],i=[];const{range:r,subUnitId:s,unitId:a}=o,{range:c,subUnitId:d}=t,u=c?mt(c):null,h=r?mt(r):null;if(h&&u){const m=e.get(l.IUniverInstanceService),g=e.get(_.SheetInterceptorService),f=m.getUniverSheetInstance(a),S=f==null?void 0:f.getSheetBySheetId(s),p=f==null?void 0:f.getSheetBySheetId(d);if(S&&p){const I=new l.ObjectMatrix,M=new l.ObjectMatrix,b=S.getCellMatrix(),T=p.getCellMatrix();l.Range.foreach(h,($,Q)=>{I.setValue($,Q,l.Tools.deepClone(b.getValue($,Q))),M.setValue($,Q,null)});const w=new l.ObjectMatrix;l.Range.foreach(u,($,Q)=>{w.setValue($,Q,l.Tools.deepClone(T.getValue($,Q)))});const E=new l.ObjectMatrix;l.Range.foreach(h,($,Q)=>{const D=l.cellToRange($,Q),H=l.Rectangle.getRelativeRange(D,h),F=l.Rectangle.getPositionRange(H,u);E.setValue(F.startRow,F.startColumn,b.getValue($,Q))});const O={from:{value:M.getMatrix(),subUnitId:s},to:{value:E.getMatrix(),subUnitId:d},unitId:a},x={from:{value:I.getMatrix(),subUnitId:s},to:{value:w.getMatrix(),subUnitId:d},unitId:a},A=g.onCommandExecute({id:_.MoveRangeCommand.id,params:{toRange:u,fromRange:h}}),k=S.getMergeData(),N=p.getMergeData(),L=k.filter($=>l.Rectangle.intersects($,h)),V=N.filter($=>l.Rectangle.intersects($,u)),j=L.map($=>l.Rectangle.getRelativeRange($,h)).map($=>l.Rectangle.getPositionRange($,u)),z=_.getAddMergeMutationRangeByType(j).filter($=>!N.some(Q=>l.Rectangle.equals($,Q))),q=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:L}},{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:V}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:z}}],K=[{id:_.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:z}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:d,ranges:V}},{id:_.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:L}}];n=[{id:_.MoveRangeMutation.id,params:O},...A.redos,...q,{id:_.SetSelectionsOperation.id,params:{unitId:a,subUnitId:d,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u}]}}],i=[{id:_.MoveRangeMutation.id,params:x},...A.undos,...K,{id:_.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:h}]}}]}}return{undos:i,redos:n}}function Gr(o,t,e,n){const{unitId:i,subUnitId:r,range:s}=o,a=[],c=[],{mapFunc:d}=en([s]),u=new l.ObjectMatrix;e.forValue((g,f,S)=>{var M;if(!S.p&&S.v&&!t){const b=String(S.v),T=vn.parseDate(b)||vn.parseTime(b)||vn.parseNumber(b);T!=null&&T.v&&typeof T.v=="number"&&(S.v=T.v)}const{row:p,col:I}=d(g,f);(M=S.p)!=null&&M.body?u.setValue(p,I,l.Tools.deepClone({p:S.p,v:S.v})):u.setValue(p,I,l.Tools.deepClone({v:S.v}))});const h={unitId:i,subUnitId:r,cellValue:l.Tools.deepClone(u.getMatrix())};a.push({id:_.SetRangeValuesMutation.id,params:h});const m=_.SetRangeValuesUndoMutationFactory(n,h);return c.push({id:_.SetRangeValuesMutation.id,params:m}),{undos:c,redos:a}}function Zr(o,t,e){const n=[],i=[],{unitId:r,subUnitId:s,range:a}=o,c=new l.ObjectMatrix,{mapFunc:d}=en([a]);t.forValue((m,g,f)=>{var M;const S={s:f.s};(M=f.p)!=null&&M.body&&(S.p=f.p);const{row:p,col:I}=d(m,g);c.setValue(p,I,S)});const u={unitId:r,subUnitId:s,cellValue:l.Tools.deepClone(c.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);return i.push({id:_.SetRangeValuesMutation.id,params:h}),{undos:i,redos:n}}function Kr(o,t,e){const n=[],i=[],r=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=o,{mapFunc:d}=en([c]);if(t.forValue((u,h,m)=>{if(m.s){const{row:g,col:f}=d(u,h);r.setValue(g,f,{s:null})}}),r.getLength()>0){const u={subUnitId:a,unitId:s,cellValue:l.Tools.deepClone(r.getMatrix())};n.push({id:_.SetRangeValuesMutation.id,params:u});const h=_.SetRangeValuesUndoMutationFactory(e,u);i.push({id:_.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:n}}function No(o,t,e){const n=[],i=[],{unitId:r,subUnitId:s,range:a}=o,{startColumn:c,startRow:d,endColumn:u,endRow:h}=mt(a),m=[];t.forValue((M,b,T)=>{if(T.rowSpan&&T.rowSpan>1){const w=T.colSpan||1,E={startRow:d+M,endRow:d+M+T.rowSpan-1,startColumn:c+b,endColumn:c+b+w-1};m.push(E)}else if(T.colSpan&&T.colSpan>1){const w=T.rowSpan||1,E={startRow:d+M,endRow:d+M+w-1,startColumn:c+b,endColumn:c+b+T.colSpan-1};m.push(E)}});const f=e.get(l.IUniverInstanceService).getUniverSheetInstance(r),S=f==null?void 0:f.getSheetBySheetId(s);if(f&&S){const b=S.getMergeData().filter(E=>l.Rectangle.intersects({startRow:d,startColumn:c,endRow:h,endColumn:u},E)),T={unitId:r,subUnitId:s,ranges:b};n.push({id:_.RemoveWorksheetMergeMutation.id,params:T});const w=_.RemoveMergeUndoMutationFactory(e,T);i.push({id:_.AddWorksheetMergeMutation.id,params:w})}const p={unitId:r,subUnitId:s,ranges:m};m.length>0&&n.push({id:_.AddWorksheetMergeMutation.id,params:p});const I=_.AddMergeUndoMutationFactory(e,p);return m.length>0&&i.push({id:_.RemoveWorksheetMergeMutation.id,params:I}),{undos:i,redos:n}}function ed(o){let t=o.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
15
+ */var Kl=V,ql=Symbol.for("react.element"),Ql=Symbol.for("react.fragment"),Jl=Object.prototype.hasOwnProperty,ec=Kl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,tc={key:!0,ref:!0,__self:!0,__source:!0};function Gr(o,t,e){var n,i={},r=null,s=null;e!==void 0&&(r=""+e),t.key!==void 0&&(r=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)Jl.call(t,n)&&!tc.hasOwnProperty(n)&&(i[n]=t[n]);if(o&&o.defaultProps)for(n in t=o.defaultProps,t)i[n]===void 0&&(i[n]=t[n]);return{$$typeof:ql,type:o,key:r,ref:s,props:i,_owner:ec.current}}eo.Fragment=Ql;eo.jsx=Gr;eo.jsxs=Gr;Xr.exports=eo;var C=Xr.exports;const nc="univer-sheets-ui-context-menu-input",oc="univer-sheets-ui-context-menu-input-container",ic="univer-sheets-ui-context-menu-input-number",mo={sheetsUiContextMenuInput:nc,sheetsUiContextMenuInputContainer:oc,sheetsUiContextMenuInputNumber:ic},rc=o=>{const{prefix:t,suffix:e,value:n,onChange:i,min:r=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=o,a=G.useDependency(l.LocaleService),[c,u]=V.useState(),d=m=>{var g;u(m==null?void 0:m.toString()),i((g=m==null?void 0:m.toString())!=null?g:"")};V.useEffect(()=>{u(n)},[n]);function h(m){m.key==="Backspace"&&m.stopPropagation()}return C.jsxs("div",{className:mo.sheetsUiContextMenuInput,children:[a.t(t),C.jsx("span",{className:mo.sheetsUiContextMenuInputContainer,onClick:m=>m.stopPropagation(),children:C.jsx(re.InputNumber,{className:mo.sheetsUiContextMenuInputNumber,value:Number(c),precision:0,onKeyDown:h,onChange:d,min:r,max:s})}),a.t(e)]})};var le=(o=>(o.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",o.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",o.SHEET_BAR="sheetBar",o))(le||{});function sc(o){const t=o.get(ft);return{id:ai.id,subId:Br.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[I.MenuPosition.TOOLBAR_START],activated$:new U.Observable(e=>{let n=!1;const i=t.status$.subscribe(r=>{n=r!==xe.OFF,e.next(n)});return e.next(n),()=>{i.unsubscribe()}}),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}function ac(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(l.IContextService),i=o.get(S.SelectionManagerService);return{id:ni.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new U.Observable(s=>{var d;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===S.SetRangeValuesMutation.id||m===S.SetSelectionsOperation.id||m===S.SetWorksheetActiveOperation.id){const _=(g=i.getLast())==null?void 0:g.primary;let p=l.FontWeight.NORMAL;if(_!=null){const v=r.getRange(_.startRow,_.startColumn);p=v==null?void 0:v.getFontWeight()}s.next(p===l.FontWeight.BOLD)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&n.getContextValue(l.EDITOR_ACTIVATED)&&n.getContextValue(l.FOCUSING_SHEET)){const _=rn(o);if(_==null)return;const p=(f=_.ts)==null?void 0:f.bl;s.next(p===l.BooleanNumber.TRUE)}}),c=(d=i.getLast())==null?void 0:d.primary;if(!r){s.next(!1);return}let u=l.FontWeight.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);u=h==null?void 0:h.getFontWeight()}return s.next(u===l.FontWeight.BOLD),a.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function lc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=o.get(l.IContextService);return{id:oi.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new U.Observable(s=>{var d;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===S.SetRangeValuesMutation.id||m===S.SetSelectionsOperation.id||m===S.SetWorksheetActiveOperation.id){const _=(g=n.getLast())==null?void 0:g.primary;let p=l.FontItalic.NORMAL;if(_!=null){const v=r.getRange(_.startRow,_.startColumn);p=v==null?void 0:v.getFontStyle()}s.next(p===l.FontItalic.ITALIC)}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const _=rn(o);if(_==null)return;const p=(f=_.ts)==null?void 0:f.it;s.next(p===l.BooleanNumber.TRUE)}}),c=(d=n.getLast())==null?void 0:d.primary;let u=l.FontItalic.NORMAL;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);u=h==null?void 0:h.getFontStyle()}return s.next(u===l.FontItalic.ITALIC),a.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function cc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=o.get(l.IContextService);return{id:ii.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new U.Observable(s=>{var d;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===S.SetRangeValuesMutation.id||m===S.SetSelectionsOperation.id||m===S.SetWorksheetActiveOperation.id){const _=(g=n.getLast())==null?void 0:g.primary;let p;if(_!=null){const v=r.getRange(_.startRow,_.startColumn);p=v==null?void 0:v.getUnderline()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const _=rn(o);if(_==null)return;const p=(f=_.ts)==null?void 0:f.ul;s.next((p==null?void 0:p.s)===l.BooleanNumber.TRUE)}}),c=(d=n.getLast())==null?void 0:d.primary;let u;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);u=h==null?void 0:h.getUnderline()}return s.next(!!(u&&u.s)),a.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function dc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=o.get(l.IContextService);return{id:ri.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[I.MenuPosition.TOOLBAR_START],disabled$:S.getCurrentSheetDisabled$(o),activated$:_e(e,!1,({worksheet:r})=>new U.Observable(s=>{var d;const a=t.onCommandExecuted(h=>{var g,f;const m=h.id;if(m===S.SetRangeValuesMutation.id||m===S.SetSelectionsOperation.id||m===S.SetWorksheetActiveOperation.id){const _=(g=n.getLast())==null?void 0:g.primary;let p;if(_!=null){const v=r.getRange(_.startRow,_.startColumn);p=v==null?void 0:v.getStrikeThrough()}s.next(!!(p&&p.s))}if((m===te.SetTextSelectionsOperation.id||m===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const _=rn(o);if(_==null)return;const p=(f=_.ts)==null?void 0:f.st;s.next((p==null?void 0:p.s)===l.BooleanNumber.TRUE)}}),c=(d=n.getLast())==null?void 0:d.primary;let u;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);u=h==null?void 0:h.getStrikeThrough()}return s.next(!!(u&&u.s)),a.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function uc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=l.DEFAULT_STYLES.ff;return{id:Hr.id,tooltip:"toolbar.font",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.SELECTOR,label:$r,positions:[I.MenuPosition.TOOLBAR_START],selections:I.FONT_FAMILY_LIST.map(r=>({label:{name:zr,hoverable:!0},value:r.value})),disabled$:S.getCurrentSheetDisabled$(o),value$:_e(e,i,({worksheet:r})=>new U.Observable(s=>{var d;const a=t.onCommandExecuted(h=>{var _;const m=h.id;if(m!==S.SetRangeValuesMutation.id&&m!==S.SetSelectionsOperation.id&&m!==S.SetWorksheetActiveOperation.id)return;const g=(_=n.getLast())==null?void 0:_.primary;let f;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);f=p==null?void 0:p.getFontFamily()}s.next(f!=null?f:i)}),c=(d=n.getLast())==null?void 0:d.primary;let u;if(c!=null){const h=r.getRange(c.startRow,c.startColumn);u=h==null?void 0:h.getFontFamily()}return s.next(u!=null?u:i),a.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function hc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=o.get(l.IContextService),r=S.getCurrentSheetDisabled$(o),s=l.DEFAULT_STYLES.fs;return{id:Pr.id,group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Yr,props:{min:1,max:400,disabled$:r}},positions:[I.MenuPosition.TOOLBAR_START],selections:I.FONT_SIZE_LIST,disabled$:r,value$:_e(e,s,({worksheet:a})=>new U.Observable(c=>{var m;const u=t.onCommandExecuted(g=>{var _,p;const f=g.id;if(f===S.SetRangeValuesMutation.id||f===S.SetSelectionsOperation.id||f===S.SetWorksheetActiveOperation.id){const v=(_=n.getLast())==null?void 0:_.primary;let M;if(v!=null){const b=a.getRange(v.startRow,v.startColumn);M=b==null?void 0:b.getFontSize()}c.next(M!=null?M:s)}if((f===te.SetTextSelectionsOperation.id||f===te.SetInlineFormatCommand.id)&&i.getContextValue(l.EDITOR_ACTIVATED)&&i.getContextValue(l.FOCUSING_SHEET)){const v=rn(o);if(v==null)return;const M=(p=v.ts)==null?void 0:p.fs;c.next(M!=null?M:s)}}),d=(m=n.getLast())==null?void 0:m.primary;let h;if(d!=null){const g=a.getRange(d.startRow,d.startColumn);h=g==null?void 0:g.getFontSize()}return c.next(h!=null?h:s),u.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET)}}function mc(o){return{id:S.ResetTextColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:kn.id,disabled$:S.getCurrentSheetDisabled$(o)}}function gc(o){const t=o.get(l.ICommandService),e=o.get(l.ThemeService);return{id:kn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON_SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:[{label:{name:Jn,hoverable:!1}}],value$:new U.Observable(n=>{const i=e.getCurrentTheme().textColor,r=t.onCommandExecuted(s=>{if(s.id===kn.id){const a=s.params.value;n.next(a!=null?a:i)}});return n.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}function fc(o){return{id:S.ResetBackgroundColorCommand.id,type:I.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:S.SetBackgroundColorCommand.id,disabled$:S.getCurrentSheetDisabled$(o)}}function _c(o){const t=o.get(l.ICommandService),e=o.get(l.ThemeService);return{id:S.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:I.MenuGroup.TOOLBAR_FORMAT,type:I.MenuItemType.BUTTON_SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Jn,hoverable:!1}}],value$:new U.Observable(n=>{const i=e.getCurrentTheme().primaryColor,r=t.onCommandExecuted(s=>{if(s.id===S.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a!=null?a:i)}});return n.next(i),r.dispose}),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}const ki=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function Sc(o){const t=o.get(l.IUniverInstanceService),e=o.get(S.SelectionManagerService),n=l.HorizontalAlign.LEFT;return{id:S.SetHorizontalTextAlignCommand.id,icon:ki[0].icon,positions:[I.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,selections:ki,value$:_e(t,n,({worksheet:i})=>new U.Observable(r=>{var u;const s=o.get(l.ICommandService).onCommandExecuted(d=>{var f;const h=d.id;if(h!==S.SetHorizontalTextAlignCommand.id&&h!==S.SetSelectionsOperation.id&&h!==S.SetWorksheetActiveOperation.id)return;const m=(f=e.getLast())==null?void 0:f.primary;let g;if(m!=null){const _=i.getRange(m.startRow,m.startColumn);g=_==null?void 0:_.getHorizontalAlignment()}r.next(g!=null?g:n)}),a=(u=e.getLast())==null?void 0:u.primary;let c;if(a!=null){const d=i.getRange(a.startRow,a.startColumn);c=d==null?void 0:d.getHorizontalAlignment()}return r.next(c!=null?c:n),s.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}const Wi=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function pc(o){const t=o.get(l.IUniverInstanceService),e=o.get(S.SelectionManagerService),n=l.VerticalAlign.BOTTOM;return{id:S.SetVerticalTextAlignCommand.id,icon:Wi[2].icon,tooltip:"toolbar.verticalAlignMode.main",group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:Wi,value$:_e(t,n,({worksheet:i})=>new U.Observable(r=>{var u;const s=o.get(l.ICommandService).onCommandExecuted(d=>{var f;const h=d.id;if(h!==S.SetVerticalTextAlignCommand.id&&h!==S.SetSelectionsOperation.id&&h!==S.SetWorksheetActiveOperation.id)return;const m=(f=e.getLast())==null?void 0:f.primary;let g;if(m!=null){const _=i.getRange(m.startRow,m.startColumn);g=_==null?void 0:_.getVerticalAlignment()}r.next(g!=null?g:n)}),a=(u=e.getLast())==null?void 0:u.primary;let c;if(a!=null){const d=i.getRange(a.startRow,a.startColumn);c=d==null?void 0:d.getVerticalAlignment()}return r.next(c!=null?c:n),s.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}const ji=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function Cc(o){const t=o.get(S.SelectionManagerService),e=o.get(l.IUniverInstanceService),n=l.WrapStrategy.OVERFLOW;return{id:S.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:ji[0].icon,group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,positions:[I.MenuPosition.TOOLBAR_START],selections:ji,value$:_e(e,n,({worksheet:i})=>new U.Observable(r=>{var u;const s=o.get(l.ICommandService).onCommandExecuted(d=>{var f;const h=d.id;if(h!==S.SetTextWrapCommand.id&&h!==S.SetSelectionsOperation.id&&h!==S.SetWorksheetActiveOperation.id)return;const m=(f=t.getLast())==null?void 0:f.primary;let g;if(m!=null){const _=i.getRange(m.startRow,m.startColumn);g=_==null?void 0:_.getWrapStrategy()}r.next(g!=null?g:n)}),a=(u=t.getLast())==null?void 0:u.primary;let c;if(a!=null){const d=i.getRange(a.startRow,a.startColumn);c=d==null?void 0:d.getWrapStrategy()}return r.next(c!=null?c:n),s.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}const $i=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function vc(o){const t=o.get(S.SelectionManagerService),e=o.get(l.IUniverInstanceService),n=0;return{id:S.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:$i[0].icon,group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SELECTOR,selections:$i,positions:[I.MenuPosition.TOOLBAR_START],value$:_e(e,n,({worksheet:i})=>new U.Observable(r=>{var u,d;const s=o.get(l.ICommandService).onCommandExecuted(h=>{var _,p;const m=h.id;if(m!==S.SetTextRotationCommand.id&&m!==S.SetSelectionsOperation.id&&m!==S.SetWorksheetActiveOperation.id)return;const g=(_=t.getLast())==null?void 0:_.primary;let f;if(g!=null){const v=i.getRange(g.startRow,g.startColumn);f=v==null?void 0:v.getTextRotation()}(f==null?void 0:f.v)===l.BooleanNumber.TRUE?r.next("v"):r.next((p=f&&f.a)!=null?p:n)}),a=(u=t.getLast())==null?void 0:u.primary;let c;if(a!=null){const h=i.getRange(a.startRow,a.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===l.BooleanNumber.TRUE?r.next("v"):r.next((d=c&&c.a)!=null?d:n),s.dispose})),hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:S.getCurrentSheetDisabled$(o)}}function At(o){return new U.Observable(t=>t.next(!o.get(I.IClipboardInterfaceService).supportClipboard))}function Ic(o){return{id:I.CopyCommand.id,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function Rc(o){return{id:I.PasteCommand.id,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:At(o),positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const Dt="sheet.menu.paste-special";function Mc(o){return{id:Dt,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",disabled$:At(o),positions:[I.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function bc(o){return{id:Rr.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[Dt],disabled$:At(o)}}function Tc(o){return{id:Mr.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[Dt],disabled$:At(o)}}function wc(o){return{id:br.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[Dt],disabled$:At(o)}}function Ec(o){return{id:Tr.id,type:I.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[Dt],disabled$:At(o)}}function yc(o){return{id:S.SetWorksheetRowIsAutoHeightCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const on="sheet.menu.sheet-frozen";function Oc(o){return{id:on,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[I.MenuPosition.CONTEXT_MENU]}}const ci="sheet.header-menu.sheet-frozen";function xc(o){return{id:ci,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function Nc(o){return{id:Qn.id,type:I.MenuItemType.BUTTON,positions:[on,ci],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function Ac(o){return{id:kr.id,type:I.MenuItemType.BUTTON,positions:[on],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function Dc(o){return{id:Wr.id,type:I.MenuItemType.BUTTON,positions:[on],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function Pc(o){return{id:jr.id,type:I.MenuItemType.BUTTON,positions:[on,ci],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function Hc(o){return{id:Ar.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function Lc(o){return{id:Dr.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function Uc(o){const t=o.get(l.IUniverInstanceService),e=o.get(S.SelectionManagerService),n=o.get(l.ICommandService),i=[S.SetSelectionsOperation,S.SetRowHiddenMutation,S.SetRowVisibleMutation].map(r=>r.id);return{id:S.SetSelectedRowsVisibleCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:_e(t,!0,({worksheet:r})=>new U.Observable(s=>{function a(){var d;const u=(d=e.getSelections())==null?void 0:d.map(h=>h.range).filter(h=>h.rangeType===l.RANGE_TYPE.ROW);return!!(u!=null&&u.some(h=>{for(let m=h.startRow;m<=h.endRow;m++)if(!r.getRowRawVisible(m))return!0;return!1}))}const c=n.onCommandExecuted(u=>{i.findIndex(d=>d===u.id)!==-1&&s.next(!a())});return s.next(!a()),()=>c.dispose()}))}}function Vc(o){const t=o.get(l.IUniverInstanceService),e=o.get(S.SelectionManagerService),n=o.get(l.ICommandService),i=[S.SetSelectionsOperation,S.SetColHiddenMutation,S.SetColVisibleMutation].map(r=>r.id);return{id:S.SetSelectedColsVisibleCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:_e(t,!0,({worksheet:r})=>new U.Observable(s=>{function a(){var d;const u=(d=e.getSelections())==null?void 0:d.map(h=>h.range).filter(h=>h.rangeType===l.RANGE_TYPE.COLUMN);return!u||u.length===0?!1:!!u.some(h=>{for(let m=h.startColumn;m<=h.endColumn;m++)if(!r.getColVisible(m))return!0;return!1})}const c=n.onCommandExecuted(u=>{i.findIndex(d=>d===u.id)!==-1&&s.next(!a())});return s.next(!a()),()=>c.dispose()}))}}function Bc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=0;return{id:S.SetRowHeightCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:li,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:_e(e,i,({worksheet:r})=>new U.Observable(s=>{function a(){var h;const u=(h=n.getLast())==null?void 0:h.primary,d=u?r.getRowHeight(u.startRow):i;s.next(d)}const c=t.onCommandExecuted(u=>{const d=u.id;if(d===S.SetRangeValuesMutation.id||d===S.SetSelectionsOperation.id||d===S.SetWorksheetRowIsAutoHeightMutation.id)return a()});return a(),c.dispose}))}}function Fc(o){const t=o.get(l.ICommandService),e=o.get(l.IUniverInstanceService),n=o.get(S.SelectionManagerService),i=0;return{id:S.SetColWidthCommand.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:li,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:_e(e,i,({worksheet:r})=>new U.Observable(s=>{function a(){var h;const u=(h=n.getLast())==null?void 0:h.primary;let d=i;u!=null&&(d=r.getColumnWidth(u.startColumn)),s.next(d)}const c=t.onCommandExecuted(u=>{const d=u.id;if(d===S.SetRangeValuesMutation.id||d===S.SetSelectionsOperation.id||d===S.SetWorksheetColWidthMutation.id)return a()});return a(),c.dispose}))}}function rn(o){var c;const t=o.get(l.IUniverInstanceService),e=o.get(te.TextSelectionManagerService),n=t.getUniverDocInstance(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),i=e.getActiveRange();if(n==null||i==null)return null;const r=(c=n.getBody())==null?void 0:c.textRuns;if(r==null)return;const{startOffset:s}=i;return r.find(({st:u,ed:d})=>s>=u&&s<=d)}function kc(){const o=G.useDependency(l.IUniverInstanceService),t=I.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]);return t!=null?t:null}function Wc(o){return I.useObservable(()=>{var e;return(e=o==null?void 0:o.activeSheet$)!=null?e:U.of(null)},void 0,void 0,[o])}const jc={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormatting:"Conditional formatting",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging",waring:"Waring",dismantleMergeCellWaring:"This will cause some merged cells to be split. Do you want to continue?"}},filter:{confirm:{error:"There was a problem",notAllowedToInsertRange:"Not allowed to move cells here until filter is cleared"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameErrorTitle:"There was a problem",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty.",sheetNameAlreadyExistsError:"The sheet name already exists. Please enter another name.",deleteSheet:"Delete worksheet",deleteSheetContent:"Confirm to delete this worksheet. It will not be retrieved after deletion. Are you sure you want to delete it?"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze",zenEditor:"Full Screen Editor",deleteAllRowsAlert:"You can't delete all the rows on the sheet",deleteAllColumnsAlert:"You can't delete all the columns on the sheet",hideAllRowsAlert:"You can't hide all the rows on the sheet",hideAllColumnsAlert:"You can't hide all the columns on the sheet"},info:{tooltip:"Tooltip",error:"Error",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total}, ${totalPage} page, current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total}, ${totalPage} page, All data displayed",problem:"There was a problem",forceStringInfo:"Number stored as text"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells",overlappingMergedCells:"The paste area overlaps with merged cells"},shortCutNotify:{title:"Kindly paste using keyboard shortcuts.",useShortCutInstead:"Detected Excel content. Use keyboard shortcut to paste."}},statusbar:{sum:"Sum",average:"Average",min:"Min",max:"Max",count:"Numerical Count",countA:"Count",clickToCopy:"Click to Copy",copied:"Copied"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","start-editing":"Start Editing (Selection into the Editor)","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit",definedName:{managerTitle:"Manager named",managerDescription:"Create a defined name by selecting cells or formulas, and entering the desired name into the text box.",addButton:"Add a defined name",featureTitle:"Defined names",ratioRange:"Range",ratioFormula:"Formula",confirm:"Confirm",cancel:"Cancel",scopeWorkbook:"Workbook",inputNamePlaceholder:"Please enter a name(No space allowed)",inputCommentPlaceholder:"Please enter a comment",inputRangePlaceholder:"Please input range(No space allowed)",inputFormulaPlaceholder:"Please input a formula(No space allowed)",nameEmpty:"Name cannot be empty",nameDuplicate:"Name already exists",formulaOrRefStringEmpty:"Formula or reference string cannot be empty",formulaOrRefStringInvalid:"Invalid formula or reference string",defaultName:"DefinedName",updateButton:"Update",deleteButton:"Delete",deleteConfirmText:"Are you sure you want to delete this defined name?",nameConflict:"The name conflicts with the function name",nameInvalid:"The name is invalid",nameSheetConflict:"The name conflicts with the sheet name"}},$c=jc,zc={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalFormatting:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并",waring:"警告",dismantleMergeCellWaring:"此操作会导致一些合并单元格被拆散,是否继续?"}},filter:{confirm:{error:"出现了一个问题",notAllowedToInsertRange:"要移动这些单元格,请清除该区域的筛选器"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameErrorTitle:"错误",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
16
+ [ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空。",sheetNameAlreadyExistsError:"工作表已存在,请输入其它名称。",deleteSheet:"删除工作表",deleteSheetContent:"确认删除此工作表,删除后将不可找回,确定要删除吗?"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结",zenEditor:"禅模式编辑",deleteAllRowsAlert:"您无法删除工作表上的所有行",deleteAllColumnsAlert:"您无法删除工作表上的所有列",hideAllRowsAlert:"您无法隐藏工作表上的所有行",hideAllColumnsAlert:"您无法隐藏工作表上的所有列"},info:{tooltip:"提示",error:"错误",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据",problem:"出现了一个问题",forceStringInfo:"以文本形式存储的数字"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数",overlappingMergedCells:"粘贴区域与合并单元格重叠"},shortCutNotify:{title:"请使用快捷键粘贴",useShortCutInstead:"检测到 Excel 内容,请使用快捷键粘贴"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"已复制"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线","start-editing":"开始编辑(选区切换到编辑器)"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格",definedName:{managerTitle:"名称管理器",managerDescription:"通过选择单元格或公式,并在文本框中输入您想要的名称来创建一个定义名称。",addButton:"新建名称",featureTitle:"定义名称",ratioRange:"范围",ratioFormula:"公式",confirm:"确认",cancel:"取消",scopeWorkbook:"工作簿",inputNamePlaceholder:"请输入名称(必填)",inputCommentPlaceholder:"请输入备注",inputRangePlaceholder:"请输入范围(必填)",inputFormulaPlaceholder:"请输入公式(必填)",nameEmpty:"名称不能为空",nameDuplicate:"名称重复",formulaOrRefStringEmpty:"公式或引用字符串不能为空",formulaOrRefStringInvalid:"公式或引用字符串无效",defaultName:"DefinedName",updateButton:"修改",deleteButton:"删除",deleteConfirmText:"确定删除定义名称?",nameConflict:"与函数名称冲突",nameInvalid:"名称不包含空格或不允许的字符",nameSheetConflict:"名称与工作表名称冲突"}},Zr=zc,Yc={spreadsheetLabel:"Электронная таблица",spreadsheetRightLabel:"больше листов",toolbar:{undo:"Отменить",redo:"Повторить",formatPainter:"Копировать формат",currencyFormat:"Форматировать как валюту",percentageFormat:"Форматировать как процент",numberDecrease:"Уменьшить количество десятичных знаков",numberIncrease:"Увеличить количество десятичных знаков",moreFormats:"Больше форматов",font:"Шрифт",fontSize:"Размер шрифта",bold:"Жирный",italic:"Курсив",strikethrough:"Зачеркнутый",subscript:"Нижний индекс",superscript:"Верхний индекс",underline:"Подчеркнутый",textColor:{main:"Цвет текста",right:"Выбрать цвет"},resetColor:"Сбросить",customColor:"ПОЛЬЗ.",alternatingColors:"Чередующиеся цвета",confirmColor:"ОК",cancelColor:"Отмена",collapse:"Свернуть",fillColor:{main:"Цвет заливки",right:"Выбрать цвет"},border:{main:"Граница",right:"Стиль границы"},mergeCell:{main:"Объединить ячейки",right:"Выбрать тип объединения"},horizontalAlignMode:{main:"Горизонтальное выравнивание",right:"Выравнивание"},verticalAlignMode:{main:"Вертикальное выравнивание",right:"Выравнивание"},textWrapMode:{main:"Перенос текста",right:"Режим переноса текста"},textRotateMode:{main:"Поворот текста",right:"Режим поворота текста"},freezeTopRow:"Закрепить верхнюю строку",sortAndFilter:"Сортировка и фильтр",findAndReplace:"Найти и заменить",sum:"СУММ",autoSum:"Авто СУММ",moreFunction:"Больше функций",conditionalFormatting:"Условное форматирование",comment:"Комментарий",pivotTable:"Сводная таблица",chart:"Диаграмма",screenshot:"Снимок экрана",splitColumn:"Разделить текст",insertImage:"Вставить изображение",insertLink:"Вставить ссылку",dataValidation:"Проверка данных",protection:"Защита листа",clearText:"Очистить цвет",noColorSelectedText:"Цвет не выбран",toolMore:"Больше",toolLess:"Меньше",toolClose:"Закрыть",toolMoreTip:"Больше возможностей",moreOptions:"Больше опций",cellFormat:"Настройка формата ячейки",print:"Печать",borderMethod:{top:"Верхняя рамка",bottom:"Нижняя рамка",left:"Левая рамка",right:"Правая рамка"},more:"Больше"},defaultFmt:{Automatic:{text:"Автоматический",value:"Общий",example:""},Number:{text:"Число",value:"##0.00",example:"1000.12"},Percent:{text:"Процент",value:"#0.00%",example:"12.21%"},PlainText:{text:"Простой текст",value:"@",example:""},Scientific:{text:"Научный",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Бухгалтерский учет",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Десять тысяч",value:"w",example:"1億2000万2500"},Currency:{text:"Валюта",value:"¥0.00",example:"¥1200.09"},Digit:{text:"Десятичные 2 знака",value:"w0.00",example:"2万2500.55"},Date:{text:"Дата",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Время",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Время 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Дата и время",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Дата и время 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Пользовательские форматы",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"Больше форматов валюты",moreDateTime:"Больше форматов даты и времени",moreNumber:"Больше форматов чисел",titleCurrency:"Форматы валюты",decimalPlaces:"Десятичные знаки",titleDateTime:"Форматы даты и времени",titleNumber:"Числовые форматы"},print:{normalBtn:"Обычный",layoutBtn:"Макет страницы",pageBtn:"Предпросмотр разрыва страницы",menuItemPrint:"Печать (Ctrl+P)",menuItemAreas:"Области печати",menuItemRows:"Печатать строки заголовков",menuItemColumns:"Печатать столбцы заголовков"},align:{left:"лево",center:"центр",right:"право",top:"верх",middle:"середина",bottom:"низ"},button:{confirm:"ОК",cancel:"Отмена",close:"Закрыть",update:"Обновить",delete:"Удалить",insert:"Вставить",prevPage:"Предыдущая",nextPage:"Следующая",total:"всего:"},punctuation:{tab:"Табуляция",semicolon:"точка с запятой",comma:"запятая",space:"пробел"},colorPicker:{collapse:"Свернуть",customColor:"ПОЛЬЗ.",change:"Изменить",confirmColor:"ОК",cancelColor:"Отмена"},borderLine:{borderTop:"верхняя граница",borderBottom:"нижняя граница",borderLeft:"левая граница",borderRight:"правая граница",borderNone:"без границы",borderAll:"все границы",borderOutside:"внешняя граница",borderInside:"внутренняя граница",borderHorizontal:"горизонтальная граница",borderVertical:"вертикальная граница",borderColor:"цвет границы",borderSize:"размер границы",borderType:"тип границы"},merge:{all:"Объединить все",vertical:"Вертикальное объединение",horizontal:"Горизонтальное объединение",cancel:"Отменить объединение",overlappingError:"Невозможно объединить перекрывающиеся области",partiallyError:"Невозможно выполнить эту операцию на частично объединенных ячейках",confirm:{title:"Продолжение объединения сохранит только значение в верхней левой ячейке, остальные значения будут удалены. Вы уверены, что хотите продолжить?",cancel:"Отменить объединение",confirm:"Продолжить объединение",waring:"Предупреждение",dismantleMergeCellWaring:"Это приведет к разделению некоторых объединенных ячеек. Продолжить?"}},filter:{confirm:{error:"Произошла ошибка",notAllowedToInsertRange:"Нельзя перемещать ячейки сюда, пока фильтр не будет очищен"}},textWrap:{overflow:"Переполнение",wrap:"Перенос",clip:"Обрезать"},textRotate:{none:"Нет",angleUp:"Повернуть вверх",angleDown:"Повернуть вниз",vertical:"Вертикально",rotationUp:"Поворот вверх",rotationDown:"Поворот вниз"},sheetConfig:{delete:"Удалить",copy:"Копировать",rename:"Переименовать",changeColor:"Изменить цвет",hide:"Скрыть",unhide:"Показать",moveLeft:"Переместить влево",moveRight:"Переместить вправо",resetColor:"Сбросить цвет",cancelText:"Отмена",chooseText:"Подтвердить цвет",tipNameRepeat:"Имя вкладки не может повторяться! Пожалуйста, исправьте",noMoreSheet:"В книге должен содержаться хотя бы один видимый лист. Чтобы удалить выбранный лист, вставьте новый лист или покажите скрытый лист.",confirmDelete:"Вы уверены, что хотите удалить",redoDelete:"Можно отменить с помощью Ctrl+Z",noHide:"Нельзя скрыть, оставьте хотя бы одну вкладку листа",chartEditNoOpt:"Эта операция недоступна в режиме редактирования диаграммы!",sheetNameErrorTitle:"Произошла ошибка",sheetNameSpecCharError:`Имя не может содержать: [ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"Имя листа не может быть пустым.",sheetNameAlreadyExistsError:"Имя листа уже существует. Пожалуйста, введите другое имя.",deleteSheet:"Удалить лист",deleteSheetContent:"Подтвердите удаление этого листа. После удаления его нельзя будет восстановить. Вы уверены, что хотите удалить его?"},rightClick:{copy:"Копировать",copyAs:"Копировать как",cut:"Вырезать",paste:"Вставить",pasteSpecial:"Специальная вставка",pasteValue:"Вставить значение",pasteFormat:"Вставить формат",pasteColWidth:"Вставить ширину столбца",pasteBesidesBorder:"Вставить кроме стилей границы",insert:"Вставить",insertRow:"Вставить строку",insertRowBefore:"Вставить строку выше",insertColumn:"Вставить столбец",insertColumnBefore:"Вставить столбец слева",delete:"Удалить",deleteCell:"Удалить ячейку",insertCell:"Вставить ячейку",deleteSelected:"Удалить выбранное",hide:"Скрыть",hideSelected:"Скрыть выбранное",showHide:"Показать скрытые",toTopAdd:"Добавить сверху",toBottomAdd:"Добавить снизу",toLeftAdd:"Добавить слева",toRightAdd:"Добавить справа",deleteSelectedRow:"Удалить выбранную строку",deleteSelectedColumn:"Удалить выбранный столбец",hideSelectedRow:"Скрыть выбранную строку",showHideRow:"Показать скрытую строку",rowHeight:"Высота строки",hideSelectedColumn:"Скрыть выбранный столбец",showHideColumn:"Показать скрытый столбец",columnWidth:"Ширина столбца",to:"К",left:"Лево",right:"Право",top:"Верх",bottom:"Низ",moveLeft:"Переместить влево",moveUp:"Переместить вверх",moveRight:"Переместить вправо",moveDown:"Переместить вниз",add:"Добавить",row:"Строка",column:"Столбец",width:"Ширина",height:"Высота",number:"Номер",confirm:"Подтвердить",orderAZ:"Порядок А-Я",orderZA:"Порядок Я-А",clearSelection:"Очистить",clearContent:"Очистить содержимое",clearFormat:"Очистить формат",clearAll:"Очистить все",matrix:"Матричная операция",sortSelection:"Сортировать",filterSelection:"Фильтр",chartGeneration:"Создать диаграмму",firstLineTitle:"Заголовок первой строки",untitled:"Без названия",array1:"Одномерный массив",array2:"Двумерный массив",array3:"Многомерные массивы",diagonal:"Диагональ",antiDiagonal:"Антидиагональ",diagonalOffset:"Смещение диагонали",offset:"Смещение",boolean:"Булевый",flip:"Перевернуть",upAndDown:"Вверх и вниз",leftAndRight:"Влево и вправо",clockwise:"По часовой стрелке",counterclockwise:"Против часовой стрелки",transpose:"Транспонировать",matrixCalculation:"Матричное вычисление",plus:"Плюс",minus:"Минус",multiply:"Умножить",divided:"Делить",power:"Степень",root:"Корень",log:"Логарифм",delete0:"Удалить значения 0 с обоих концов",removeDuplicate:"Удалить дубликаты значений",byRow:"По строке",byCol:"По столбцу",generateNewMatrix:"Создать новую матрицу",fitContent:"Подогнать под данные",freeze:"Закрепить",freezeCol:"Закрепить до этого столбца",freezeRow:"Закрепить до этой строки",cancelFreeze:"Отменить закрепление",zenEditor:"Редактор на весь экран",deleteAllRowsAlert:"Нельзя удалить все строки на листе",deleteAllColumnsAlert:"Нельзя удалить все столбцы на листе",hideAllRowsAlert:"Нельзя скрыть все строки на листе",hideAllColumnsAlert:"Нельзя скрыть все столбцы на листе"},info:{tooltip:"Подсказка",error:"Ошибка",notChangeMerge:"Вы не можете частично изменить объединенные ячейки",detailUpdate:"Новый открытый",detailSave:"Восстановлено из локального кэша",row:"",column:"",loading:"Загрузка...",copy:"Копировать",return:"Выход",rename:"Переименовать",tips:"Переименовать",noName:"Электронная таблица без названия",wait:"ожидание обновления",add:"Добавить",addLast:"больше строк внизу",backTop:"Вернуться наверх",pageInfo:"Всего ${total}, ${totalPage} страниц, текущая ${currentPage}",nextPage:"Следующая",tipInputNumber:"Пожалуйста, введите число",tipInputNumberLimit:"Диапазон увеличения ограничен от 1 до 100",tipRowHeightLimit:"Высота строки должна быть в пределах от 0 до 545",tipColumnWidthLimit:"Ширина столбца должна быть в пределах от 0 до 2038",pageInfoFull:"Всего ${total}, ${totalPage} страниц, все данные отображены",problem:"Произошла проблема",forceStringInfo:"Число хранится как текст"},clipboard:{paste:{exceedMaxCells:"Количество вставляемых ячеек превышает максимальное количество ячеек",overlappingMergedCells:"Область вставки перекрывается с объединенными ячейками"},shortCutNotify:{title:"Используйте сочетания клавиш для вставки.",useShortCutInstead:"Обнаружено содержимое Excel. Используйте сочетание клавиш для вставки."}},statusbar:{sum:"Сумма",average:"Среднее",min:"Минимум",max:"Максимум",count:"Числовое количество",countA:"Количество",clickToCopy:"Нажмите, чтобы скопировать",copied:"Скопировано"},autoFill:{copy:"Копировать ячейку",series:"Заполнить серию",formatOnly:"Только формат",noFormat:"Без формата"},rangeSelector:{placeholder:"Выберите диапазон или введите значение",tooltip:"Выберите диапазон"},shortcut:{sheet:{"zoom-in":"Увеличить","zoom-out":"Уменьшить","reset-zoom":"Сбросить масштаб","select-below-cell":"Выбрать ячейку ниже","select-up-cell":"Выбрать ячейку выше","select-left-cell":"Выбрать ячейку слева","select-right-cell":"Выбрать ячейку справа","select-next-cell":"Выбрать следующую ячейку","select-previous-cell":"Выбрать предыдущую ячейку","select-up-value-cell":"Выбрать ячейку выше со значением","select-below-value-cell":"Выбрать ячейку ниже со значением","select-left-value-cell":"Выбрать ячейку слева со значением","select-right-value-cell":"Выбрать ячейку справа со значением","expand-selection-down":"Расширить выделение вниз","expand-selection-up":"Расширить выделение вверх","expand-selection-left":"Расширить выделение влево","expand-selection-right":"Расширить выделение вправо","expand-selection-to-left-gap":"Расширить выделение до левого пробела","expand-selection-to-below-gap":"Расширить выделение до нижнего пробела","expand-selection-to-right-gap":"Расширить выделение до правого пробела","expand-selection-to-up-gap":"Расширить выделение до верхнего пробела","select-all":"Выбрать все","toggle-editing":"Переключить редактирование","delete-and-start-editing":"Очистить и начать редактирование","abort-editing":"Прервать редактирование","break-line":"Разрыв строки","set-bold":"Переключить жирный","set-italic":"Переключить курсив","set-underline":"Переключить подчеркивание","set-strike-through":"Переключить зачеркивание","start-editing":"Начать редактирование"}},"sheet-view":"Просмотр листа","sheet-edit":"Редактирование листа",definedName:{managerTitle:"Управление именами",managerDescription:"Создайте определенное имя, выбрав ячейки или формулы и введя желаемое имя в текстовое поле.",addButton:"Добавить определенное имя",featureTitle:"Определенные имена",ratioRange:"Диапазон",ratioFormula:"Формула",confirm:"Подтвердить",cancel:"Отмена",scopeWorkbook:"Книга",inputNamePlaceholder:"Введите имя (без пробелов)",inputCommentPlaceholder:"Введите комментарий",inputRangePlaceholder:"Введите диапазон (без пробелов)",inputFormulaPlaceholder:"Введите формулу (без пробелов)",nameEmpty:"Имя не может быть пустым",nameDuplicate:"Имя уже существует",formulaOrRefStringEmpty:"Формула или строка ссылки не может быть пустой",formulaOrRefStringInvalid:"Неверная формула или строка ссылки",defaultName:"ОпределенноеИмя",updateButton:"Обновить",deleteButton:"Удалить",deleteConfirmText:"Вы уверены, что хотите удалить это определенное имя?",nameConflict:"Имя конфликтует с именем функции",nameInvalid:"Имя недействительно",nameSheetConflict:"Имя конфликтует с именем листа"}},Xc=Yc;class Kr{constructor(){R(this,"_state",null);R(this,"_rect",null);R(this,"_state$",new U.BehaviorSubject(null));R(this,"state$",this._state$.asObservable());R(this,"_rect$",new U.BehaviorSubject(null));R(this,"rect$",this._rect$.asObservable());R(this,"_focus",!1);R(this,"_focus$",new U.BehaviorSubject(this._focus));R(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(t){this._state=t,this._refresh(t)}getRect(){return this._rect}setRect(t){this._rect=t,this._rect$.next(t)}getState(){return this._state}setFocus(t=!1){this._focus=t,this._focus$.next(t)}_refresh(t){this._state$.next(t)}}const sn=D.createIdentifier("univer.sheet-cell-editor-manager.service");class Gc{constructor(){R(this,"_position",null);R(this,"_position$",new U.BehaviorSubject(null));R(this,"position$",this._position$.asObservable());R(this,"_focus",!1);R(this,"_focus$",new U.BehaviorSubject(this._focus));R(this,"focus$",this._focus$.asObservable());R(this,"_fxBtnClick$",new U.Subject);R(this,"fxBtnClick$",this._fxBtnClick$.asObservable());R(this,"_foldBtnStatus$",new U.Subject);R(this,"foldBtnStatus$",this._foldBtnStatus$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(t){this._position=t,this._refresh(t)}getPosition(){return this._position}setFocus(t=!1){this._focus=t,this._focus$.next(t)}handleFxBtnClick(t){this._fxBtnClick$.next(t)}handleFoldBtnClick(t){this._foldBtnStatus$.next(t)}_refresh(t){this._position$.next(t)}}const to=D.createIdentifier("univer.sheet-formula-editor-manager.service");var Zc=Object.defineProperty,Kc=Object.getOwnPropertyDescriptor,qc=(o,t,e,n)=>{for(var i=n>1?void 0:n?Kc(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Zc(t,e,i),i},zi=(o,t)=>(e,n)=>t(e,n,o);let Tn=class extends l.Disposable{constructor(t,e){super();R(this,"_previousSheetIndex",-1);this._commandService=t,this._univerInstanceService=e,this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===S.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,i)=>{if(n.id===S.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===S.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(i!=null&&i.fromCollab)){if(n.id===S.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===S.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(t){const{unitId:e,subUnitId:n}=t.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i||i.getActiveSheet().getSheetId()!==n)return;const s=i.getActiveSheetIndex(),a=Yi(i,s);this._switchToNextSheet(e,a)}_beforeAdjustActiveSheetOnRemoveSheet(t){const{unitId:e,subUnitId:n}=t.params,i=this._univerInstanceService.getUniverSheetInstance(e);if(!i)return;const r=i.getSheetBySheetId(n);r&&(this._previousSheetIndex=i.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(t){if(this._previousSheetIndex===-1)return;const{unitId:e}=t.params,n=this._univerInstanceService.getUniverSheetInstance(e);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=Yi(n,s);this._switchToNextSheet(e,a)}_adjustActiveSheetOnInsertSheet(t){const{unitId:e,sheet:n}=t.params;this._switchToNextSheet(e,n.id)}_adjustActiveSheetOnShowSheet(t){const{unitId:e,subUnitId:n}=t.params;this._switchToNextSheet(e,n)}_switchToNextSheet(t,e){this._commandService.executeCommand(S.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:e})}};Tn=qc([l.OnLifecycle(l.LifecycleStages.Ready,Tn),zi(0,l.ICommandService),zi(1,l.IUniverInstanceService)],Tn);function Yi(o,t){const e=o.getSheetSize();for(let n=t;n>-1;n--){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}for(let n=t;n<e;n++){const i=o.getSheetByIndex(n);if(!i.getConfig().hidden)return i.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var Qc=Object.defineProperty,Jc=Object.getOwnPropertyDescriptor,ed=(o,t,e,n)=>{for(var i=n>1?void 0:n?Jc(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Qc(t,e,i),i},Wt=(o,t)=>(e,n)=>t(e,n,o);exports.AutoHeightController=class extends l.Disposable{constructor(t,e,n,i,r){super(),this._injector=t,this._sheetInterceptorService=e,this._selectionManagerService=n,this._univerInstanceService=i,this._sheetSkeletonManagerService=r,this._initialize()}getUndoRedoParamsOfAutoHeight(t){const{_univerInstanceService:e,_sheetSkeletonManagerService:n,_injector:i}=this,{skeleton:r}=n.getCurrent(),s=r.calculateAutoHeightInRange(t),a=e.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),c=a.getUnitId(),d={subUnitId:a.getActiveSheet().getSheetId(),unitId:c,rowsAutoHeightInfo:s},h=S.SetWorksheetRowAutoHeightMutationFactory(i,d);return{undos:[{id:S.SetWorksheetRowAutoHeightMutation.id,params:h}],redos:[{id:S.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:t,_selectionManagerService:e}=this;this.disposeWithMe(t.interceptCommand({getMutations:n=>n.id!==S.SetRangeValuesCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(n.params.range)})),this.disposeWithMe(t.interceptCommand({getMutations:n=>n.id!==S.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this.getUndoRedoParamsOfAutoHeight(n.params.ranges)})),this.disposeWithMe(t.interceptCommand({getMutations:n=>{var s;if(n.id!==S.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((s=n.params)==null?void 0:s.style.type))return{redos:[],undos:[]};const r=e.getSelectionRanges();return r!=null&&r.length?this.getUndoRedoParamsOfAutoHeight(r):{redos:[],undos:[]}}}))}};exports.AutoHeightController=ed([l.OnLifecycle(l.LifecycleStages.Ready,exports.AutoHeightController),Wt(0,D.Inject(D.Injector)),Wt(1,D.Inject(S.SheetInterceptorService)),Wt(2,D.Inject(S.SelectionManagerService)),Wt(3,D.Inject(l.IUniverInstanceService)),Wt(4,D.Inject(exports.SheetSkeletonManagerService))],exports.AutoHeightController);function td(o,t,e,n,i){const r=[],s=[];if(n.copyType===et.CUT){const{undos:a,redos:c}=nd(o,t,i);r.push(...c),s.push(...a)}else{const{undos:a,redos:c}=Jr(t,e,i);r.push(...c),s.push(...a);const{undos:u,redos:d}=qr(t,o,e,i);r.push(...d),s.push(...u);const{undos:h,redos:m}=Qr(t,e,i);r.push(...m),s.push(...h);const{undos:g,redos:f}=Do(t,e,i);r.push(...f),s.push(...g)}return{undos:s,redos:r}}function nd(o,t,e){let n=[],i=[];const{range:r,subUnitId:s,unitId:a}=o,{range:c,subUnitId:u}=t,d=c?mt(c):null,h=r?mt(r):null;if(h&&d){const m=e.get(l.IUniverInstanceService),g=e.get(S.SheetInterceptorService),f=m.getUniverSheetInstance(a),_=f==null?void 0:f.getSheetBySheetId(s),p=f==null?void 0:f.getSheetBySheetId(u);if(_&&p){const v=new l.ObjectMatrix,M=new l.ObjectMatrix,b=_.getCellMatrix(),T=p.getCellMatrix();l.Range.foreach(h,($,Q)=>{v.setValue($,Q,l.Tools.deepClone(b.getValue($,Q))),M.setValue($,Q,null)});const w=new l.ObjectMatrix;l.Range.foreach(d,($,Q)=>{w.setValue($,Q,l.Tools.deepClone(T.getValue($,Q)))});const y=new l.ObjectMatrix;l.Range.foreach(h,($,Q)=>{const P=l.cellToRange($,Q),H=l.Rectangle.getRelativeRange(P,h),k=l.Rectangle.getPositionRange(H,d);y.setValue(k.startRow,k.startColumn,b.getValue($,Q))});const O={from:{value:M.getMatrix(),subUnitId:s},to:{value:y.getMatrix(),subUnitId:u},unitId:a},x={from:{value:v.getMatrix(),subUnitId:s},to:{value:w.getMatrix(),subUnitId:u},unitId:a},A=g.onCommandExecute({id:S.MoveRangeCommand.id,params:{toRange:d,fromRange:h}}),F=_.getMergeData(),N=p.getMergeData(),L=F.filter($=>l.Rectangle.intersects($,h)),B=N.filter($=>l.Rectangle.intersects($,d)),j=L.map($=>l.Rectangle.getRelativeRange($,h)).map($=>l.Rectangle.getPositionRange($,d)),z=S.getAddMergeMutationRangeByType(j).filter($=>!N.some(Q=>l.Rectangle.equals($,Q))),q=[{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:L}},{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:B}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:u,ranges:z}}],K=[{id:S.RemoveWorksheetMergeMutation.id,params:{unitId:a,subUnitId:u,ranges:z}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:u,ranges:B}},{id:S.AddWorksheetMergeMutation.id,params:{unitId:a,subUnitId:s,ranges:L}}];n=[{id:S.MoveRangeMutation.id,params:O},...A.redos,...q,{id:S.SetSelectionsOperation.id,params:{unitId:a,subUnitId:u,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:d}]}}],i=[{id:S.MoveRangeMutation.id,params:x},...A.undos,...K,{id:S.SetSelectionsOperation.id,params:{unitId:a,sheetId:s,pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:h}]}}]}}return{undos:i,redos:n}}function qr(o,t,e,n){const{unitId:i,subUnitId:r,range:s}=o,a=[],c=[],{mapFunc:u}=tn([s]),d=new l.ObjectMatrix;e.forValue((g,f,_)=>{var M;if(!_.p&&_.v&&!t){const b=String(_.v),T=Rn.parseDate(b)||Rn.parseTime(b)||Rn.parseNumber(b);T!=null&&T.v&&typeof T.v=="number"&&(_.v=T.v)}const{row:p,col:v}=u(g,f);(M=_.p)!=null&&M.body?d.setValue(p,v,l.Tools.deepClone({p:_.p,v:_.v})):d.setValue(p,v,l.Tools.deepClone({v:_.v}))});const h={unitId:i,subUnitId:r,cellValue:l.Tools.deepClone(d.getMatrix())};a.push({id:S.SetRangeValuesMutation.id,params:h});const m=S.SetRangeValuesUndoMutationFactory(n,h);return c.push({id:S.SetRangeValuesMutation.id,params:m}),{undos:c,redos:a}}function Qr(o,t,e){const n=[],i=[],{unitId:r,subUnitId:s,range:a}=o,c=new l.ObjectMatrix,{mapFunc:u}=tn([a]);t.forValue((m,g,f)=>{var M;const _={s:f.s};(M=f.p)!=null&&M.body&&(_.p=f.p);const{row:p,col:v}=u(m,g);c.setValue(p,v,_)});const d={unitId:r,subUnitId:s,cellValue:l.Tools.deepClone(c.getMatrix())};n.push({id:S.SetRangeValuesMutation.id,params:d});const h=S.SetRangeValuesUndoMutationFactory(e,d);return i.push({id:S.SetRangeValuesMutation.id,params:h}),{undos:i,redos:n}}function Jr(o,t,e){const n=[],i=[],r=new l.ObjectMatrix,{unitId:s,subUnitId:a,range:c}=o,{mapFunc:u}=tn([c]);if(t.forValue((d,h,m)=>{if(m.s){const{row:g,col:f}=u(d,h);r.setValue(g,f,{s:null})}}),r.getLength()>0){const d={subUnitId:a,unitId:s,cellValue:l.Tools.deepClone(r.getMatrix())};n.push({id:S.SetRangeValuesMutation.id,params:d});const h=S.SetRangeValuesUndoMutationFactory(e,d);i.push({id:S.SetRangeValuesMutation.id,params:h})}return{undos:i,redos:n}}function Do(o,t,e){const n=[],i=[],{unitId:r,subUnitId:s,range:a}=o,{startColumn:c,startRow:u,endColumn:d,endRow:h}=mt(a),m=[];t.forValue((M,b,T)=>{if(T.rowSpan&&T.rowSpan>1){const w=T.colSpan||1,y={startRow:u+M,endRow:u+M+T.rowSpan-1,startColumn:c+b,endColumn:c+b+w-1};m.push(y)}else if(T.colSpan&&T.colSpan>1){const w=T.rowSpan||1,y={startRow:u+M,endRow:u+M+w-1,startColumn:c+b,endColumn:c+b+T.colSpan-1};m.push(y)}});const f=e.get(l.IUniverInstanceService).getUniverSheetInstance(r),_=f==null?void 0:f.getSheetBySheetId(s);if(f&&_){const b=_.getMergeData().filter(y=>l.Rectangle.intersects({startRow:u,startColumn:c,endRow:h,endColumn:d},y)),T={unitId:r,subUnitId:s,ranges:b};n.push({id:S.RemoveWorksheetMergeMutation.id,params:T});const w=S.RemoveMergeUndoMutationFactory(e,T);i.push({id:S.AddWorksheetMergeMutation.id,params:w})}const p={unitId:r,subUnitId:s,ranges:m};m.length>0&&n.push({id:S.AddWorksheetMergeMutation.id,params:p});const v=S.AddMergeUndoMutationFactory(e,p);return m.length>0&&i.push({id:S.RemoveWorksheetMergeMutation.id,params:v}),{undos:i,redos:n}}function od(o){let t=o.replace(/(\r\n|\n)/g,"\r");t.endsWith(`\r
17
17
  `)||(t+=`\r
18
18
  `);const e=[];for(let n=0;n<t.length;n++)t[n]==="\r"&&e.push({startIndex:n});return{dataStream:t,paragraphs:e,sectionBreaks:[{startIndex:t.indexOf(`
19
- `)}]}}var td=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,od=(o,t,e,n)=>{for(var i=n>1?void 0:n?nd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&td(t,e,i),i},Ue=(o,t)=>(e,n)=>t(e,n,o);let bn=class extends l.RxDisposable{constructor(o,t,e,n,i,r,s,a,c,d){var u;super(),this._injector=o,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=i,this._sheetClipboardService=r,this._messageService=s,this._sheetSkeletonManagerService=a,this._localService=c,this._textSelectionRenderManager=d,this._init(),(u=this._textSelectionRenderManager)==null||u.onPaste$.pipe(B.takeUntil(this.dispose$)).subscribe(h=>{var S,p;if(!ne(this._contextService))return;h.event.preventDefault();const m=h.event,g=(S=m.clipboardData)==null?void 0:S.getData("text/html"),f=(p=m.clipboardData)==null?void 0:p.getData("text/plain");this._sheetClipboardService.legacyPaste(g,f)})}_init(){[Cr,ol,xt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[vr,Ir,Rr,Mr].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const o=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>o.forEach(t=>t.dispose())})}_initCopyingHooks(){const o=this;let t=null;return{id:fe.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=o._getWorksheet(e,n)},onCopyCellContent(e,n){var s,a,c,d;const i=t.getCell(e,n);return(a=(s=i==null?void 0:i.p)==null?void 0:s.body)!=null&&a.paragraphs||(d=(c=i==null?void 0:i.p)==null?void 0:c.body)!=null&&d.textRuns?l.convertBodyToHtml(i.p.body):i?l.extractPureTextFromCell(i):""},onCopyCellStyle:(e,n,i,r)=>{const s={};(i||r)&&(s.rowspan=`${i||1}`,s.colspan=`${r||1}`);const a=t.getRange(e,n),c=t.getMergedCell(e,n),d=a.getTextStyle();let u="";if(d&&(u=l.handleStyleToString(d)),c){const h=c.endRow,m=c.endColumn,f=t.getRange(h,m).getTextStyle();if(f){const S=l.handleStyleToString(f);u?u+=S?`;${S}`:"":u=S}}return u&&(s.style=u),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null},getFilteredOutRows(e){var a;const{startRow:n,endRow:i}=e,r=(a=o._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getActiveSheet(),s=[];if(!r)return s;for(let c=n;c<=i;c++)r.getRowFiltered(c)&&s.push(c);return s}}}_initPastingHook(){const o=this;let t=null,e=null,n=null;return{id:fe.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:i,subUnitId:r,range:s}){n=o._getWorksheet(i,r),t=i,e=r;const a=o._configService.getConfig(_.MAX_CELL_PER_SHEET_KEY),c=s.rows[s.rows.length-1],d=s.cols[s.cols.length-1];return a&&c*d>a?(o._messageService.show({type:re.MessageType.Error,content:o._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(i,r){const{range:s}=i,a=[],c=[],d=n.getMaxRows(),u=s.rows[s.rows.length-1]-d,h=r.length-u,m=n.getRowManager();if(u>0){const p={};r.slice(h).forEach((M,b)=>{const{style:T,height:w}=M||{};if(T){const E=T.split(";");let O=l.DEFAULT_WORKSHEET_ROW_HEIGHT;E.find(x=>{x=x.toLowerCase();const A=v.textTrim(x.substr(0,x.indexOf(":"))),k=v.textTrim(x.substr(x.indexOf(":")+1));return A==="height"?(k.endsWith("pt")?O=y.ptToPx(Number.parseFloat(k)):O=Number.parseFloat(k),!0):!1}),p[b]={h:O,hd:l.BooleanNumber.FALSE}}else w&&(p[b]={h:Number.parseFloat(w),hd:l.BooleanNumber.FALSE})});const I={unitId:t,subUnitId:e,range:{startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1],endRow:s.rows[s.rows.length-1],startRow:d},rowInfo:p};a.push({id:_.InsertRowMutation.id,params:I})}const g={},f={};r.slice(0,h).forEach((p,I)=>{var T,w;const{style:M,height:b}=p;if(M){const E=M.split(";");let O=l.DEFAULT_WORKSHEET_ROW_HEIGHT;E.find(x=>{x=x.toLowerCase();const A=v.textTrim(x.substr(0,x.indexOf(":"))),k=v.textTrim(x.substr(x.indexOf(":")+1));return A==="height"?(k.endsWith("pt")?O=y.ptToPx(Number.parseFloat(k)):O=Number.parseFloat(k),!0):!1}),g[I+s.rows[0]]=O}else if(b){const E=m.getRow(s.rows[0]+I),O=Number.parseFloat(b);if(E){const{h:x=l.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:A=0}=E,k=Math.max(x,A);O>k&&(g[I+s.rows[0]]=O,f[I+s.rows[0]]=k)}else g[I+s.rows[0]]=O,f[I+s.rows[0]]=(w=(T=m.getRow(s.rows[0]+I))==null?void 0:T.h)!=null?w:l.DEFAULT_WORKSHEET_ROW_HEIGHT}});const S={unitId:t,subUnitId:e,ranges:[{startRow:s.rows[0],endRow:Math.min(s.rows[s.rows.length-1],d),startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1]}],rowHeight:g};return a.push({id:_.SetWorksheetRowHeightMutation.id,params:S}),c.push({id:_.SetWorksheetRowHeightMutation.id,params:{...S,rowHeight:20}}),{redos:a,undos:c}},onPasteColumns(i,r,s){var f;const{range:a}=i,c=[],d=n.getMaxColumns(),u=a.cols[a.cols.length-1]-d,h=r.length-u,m=(f=o._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?f:l.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(u>0){const S={unitId:t,subUnitId:e,range:{startRow:a.rows[0],endRow:a.rows[a.rows.length-1],endColumn:a.cols[a.cols.length-1],startColumn:d},colInfo:r.slice(h).map(p=>({w:p.width?+p.width:m,hd:l.BooleanNumber.FALSE}))};c.push({id:_.InsertColMutation.id,params:S})}const g={unitId:t,subUnitId:e,ranges:[{startRow:a.rows[0],endRow:a.rows[a.rows.length-1],startColumn:a.cols[0],endColumn:Math.min(a.cols[a.cols.length-1],d)}],colWidth:r.slice(0,h).map(S=>S.width?+S.width:m)};return c.push({id:_.SetWorksheetColWidthMutation.id,params:g}),{redos:c,undos:[]}},onPastePlainText(i,r,s){return o._onPastePlainText(i,r,s)},onPasteCells(i,r,s,a){return o._onPasteCells(i,r,s,a)},onAfterPaste(i){n=null}}}_generateDocumentDataModelSnapshot(o){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...o};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(o,t,e){const{range:n,unitId:i,subUnitId:r}=o;let s;if(/\r|\n/.test(t)){const c=ed(t),d=this._generateDocumentDataModelSnapshot({body:c});s={[n.rows[0]]:{[n.cols[0]]:{p:d}}}}else l.isFormulaString(t)?s={[n.rows[0]]:{[n.cols[0]]:{f:t}}}:s={[n.rows[0]]:{[n.cols[0]]:{v:t}}};const a={unitId:i,subUnitId:r,cellValue:s};return{redos:[{id:_.SetRangeValuesMutation.id,params:a}],undos:[{id:_.SetRangeValuesMutation.id,params:_.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(o,t,e,n){const i={get:this._injector.get.bind(this._injector)};return Qc(o,t,e,n,i)}_initSpecialPasteHooks(){const o={get:this._injector.get.bind(this._injector)},t=this,e={id:fe.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c)=>Gr(a,s,c,o)},n={id:fe.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c){const d=[],u=[],{undos:h,redos:m}=Kr(a,c,o);d.push(...m),u.push(...h);const{undos:g,redos:f}=No(a,c,o);d.push(...f),u.push(...g);const{undos:S,redos:p}=Zr(a,c,o);return d.push(...p),u.push(...S),{undos:u,redos:d}}},i={id:fe.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){var T;const d=t._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=t._getWorksheet(u,h),{range:f}=s,S=g.getMaxColumns(),p=f.cols[f.cols.length-1]-S,I=a.length-p,M=(T=t._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?T:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,b={unitId:u,subUnitId:h,ranges:[{startRow:f.rows[0],endRow:Math.min(f.cols[f.cols.length-1],S),startColumn:f.cols[0],endColumn:f.cols[f.cols.length-1]}],colWidth:a.slice(0,I).map(w=>w.width?+w.width:M)};return m.push({id:_.SetWorksheetColWidthMutation.id,params:b}),m.push({id:_.SetWorksheetColWidthMutation.id,params:b}),{redos:m,undos:[]}}},r={id:fe.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){t._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);const u=[],h=[],{range:m,unitId:g,subUnitId:f}=a,S=new l.ObjectMatrix;c.forValue((T,w,E)=>{const O=E.s;typeof O=="object"&&S.setValue(m.rows[T],m.cols[w],{s:{...O,bd:void 0},v:E.v})});const p={unitId:g,subUnitId:f,cellValue:S.getData()};u.push({id:_.SetRangeValuesMutation.id,params:p});const I=_.SetRangeValuesUndoMutationFactory(o,p);h.push({id:_.SetRangeValuesMutation.id,params:I});const{undos:M,redos:b}=No(a,c,o);return h.push(...M),u.push(...b),{redos:u,undos:h}}};return[e,n,i,r]}_getWorksheet(o,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(o))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${o} and subUnitId ${t}.`);return e}};bn=od([l.OnLifecycle(l.LifecycleStages.Steady,bn),Ue(0,P.Inject(P.Injector)),Ue(1,l.IUniverInstanceService),Ue(2,l.ICommandService),Ue(3,l.IContextService),Ue(4,l.IConfigService),Ue(5,Ot),Ue(6,v.IMessageService),Ue(7,P.Inject(exports.SheetSkeletonManagerService)),Ue(8,P.Inject(l.LocaleService)),Ue(9,P.Optional(y.ITextSelectionRenderManager))],bn);var id=Object.defineProperty,rd=Object.getOwnPropertyDescriptor,sd=(o,t,e,n)=>{for(var i=n>1?void 0:n?rd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&id(t,e,i),i},zi=(o,t)=>(e,n)=>t(e,n,o);let Tn=class extends l.RxDisposable{constructor(o,t){super(),this._univerInstanceService=o,this._undoRedoService=t,this._initialize()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_DOC).pipe(B.takeUntil(this.dispose$)).subscribe(o=>{if(o==null)return;o.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const o={};this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(t=>{const e=t.getConfig();o[t.getSheetId()]={cellData:new l.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}};Tn=sd([l.OnLifecycle(l.LifecycleStages.Rendered,Tn),zi(0,l.IUniverInstanceService),zi(1,P.Inject(l.IUndoRedoService))],Tn);const qr=[v.KeyCode.ARROW_DOWN,v.KeyCode.ARROW_UP,v.KeyCode.ARROW_LEFT,v.KeyCode.ARROW_RIGHT],ad=[v.KeyCode.ENTER,v.KeyCode.TAB,...qr];function ld(){const o=[];for(const t of qr)o.push({id:qt.id,binding:t,preconditions:e=>Gt(e),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),o.push({id:qt.id,binding:t|v.MetaKeys.SHIFT,preconditions:e=>Gt(e),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return o}const cd={id:Jo.id,binding:v.KeyCode.F2,description:"shortcut.sheet.start-editing",group:"4_sheet-edit",preconditions:ne,staticParameters:{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.F2}},dd={id:Te.id,binding:v.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:o=>Gt(o),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ENTER}},ud={id:Te.id,binding:v.KeyCode.TAB,preconditions:o=>Gt(o),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.TAB}},hd={id:Te.id,binding:v.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:o=>Gt(o),staticParameters:{visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC}},md={id:te.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:o=>sa(o),binding:v.KeyCode.ENTER|v.MetaKeys.ALT},gd={id:te.DeleteLeftCommand.id,preconditions:o=>aa(o)||fr(o),binding:v.KeyCode.BACKSPACE},fd={id:Te.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:o=>ne(o)&&!fr(o),binding:v.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.BACKSPACE}};function _d(o){return o.startsWith("'")}function Sd(o){return o.slice(1)}var pd=Object.defineProperty,Cd=Object.getOwnPropertyDescriptor,vd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Cd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&pd(t,e,i),i},Ve=(o,t)=>(e,n)=>t(e,n,o);function Id(o){const{textRuns:t=[],paragraphs:e=[]}=o;return t.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let wn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c,d,u){super();R(this,"_cursorChangeObservers");R(this,"_editorVisiblePrevious",!1);R(this,"_cursorChange",0);this._univerInstanceService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=i,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._selectionManagerService=d,this._editorService=u,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:i}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._cursorChange=i===y.DeviceInputEventType.PointerDown?2:1;return}this._cursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(t),n===v.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getEditCellState();if(u==null)return;const{unitId:h,sheetId:m,row:g,column:f,documentLayoutObject:S}=u;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const I=this._univerInstanceService.getUniverSheetInstance(h),M=I==null?void 0:I.getSheetBySheetId(m);if(M==null)return;const b=Rd(M.getCellRaw(g,f)||{},S,this._lexerTreeBuilder);if(b==null){this._moveCursor(n);return}const T={subUnitId:m,unitId:h,workbook:I,worksheet:M,row:g,col:f};a===h&&m!==c&&this._editorBridgeService.isForceKeepVisible()&&await this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const w=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(b,T),E=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(w),T);this._commandService.executeCommand(_.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:g,startColumn:f,endRow:g,endColumn:f},value:E}),this._moveCursor(n)}))}_exitInput(t){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!ad.includes(t))return;let e=l.Direction.LEFT;switch(t){case v.KeyCode.ENTER:e=l.Direction.DOWN;break;case v.KeyCode.TAB:e=l.Direction.RIGHT;break;case v.KeyCode.ARROW_DOWN:e=l.Direction.DOWN;break;case v.KeyCode.ARROW_UP:e=l.Direction.UP;break;case v.KeyCode.ARROW_LEFT:e=l.Direction.LEFT;break;case v.KeyCode.ARROW_RIGHT:e=l.Direction.RIGHT;break}t===v.KeyCode.ENTER||t===v.KeyCode.TAB?this._commandService.executeCommand(gt.id,{keycode:t,direction:e}):this._commandService.executeCommand(we.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(l.toDisposable(e.onPointerDownObserver.add(()=>{this._cursorChange===1&&(this._cursorChange=2)})))}_commandExecutedListener(){const t=[qt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:i,isShift:r}=n;if(i!=null&&(this._cursorChange===2||this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR))){this._moveInEditor(i,r);return}this._editorBridgeService.changeVisible(n)}e.id===Jo.id&&(this._cursorChange=2)}))}_moveInEditor(t,e){let n=l.Direction.LEFT;t===v.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:t===v.KeyCode.ARROW_UP?n=l.Direction.UP:t===v.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),e?this._commandService.executeCommand(te.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(te.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return Xn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};wn=vd([l.OnLifecycle(l.LifecycleStages.Rendered,wn),Ve(0,l.IUniverInstanceService),Ve(1,y.IRenderManagerService),Ve(2,l.ICommandService),Ve(3,Ee),Ve(4,l.IContextService),Ve(5,rn),Ve(6,P.Inject(Z.LexerTreeBuilder)),Ve(7,l.IUndoRedoService),Ve(8,P.Inject(_.SelectionManagerService)),Ve(9,v.IEditorService)],wn);function Rd(o,t,e){o=l.Tools.deepClone(o);const{documentModel:n}=t;if(n==null)return null;const i=n.getSnapshot(),{body:r}=i;if(r==null)return null;o.t=void 0;const s=r.dataStream;let c=s.substring(s.length-2,s.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(l.isFormulaString(c)){if(o.f===c)return null;const d=e.checkIfAddBracket(c);for(let u=0;u<d;u++)c+=Z.matchToken.CLOSE_BRACKET;o.f=c,o.v=null,o.p=null}else if(_d(c)){const d=Sd(c);o.v=d,o.f=null,o.si=null,o.p=null,o.t=l.CellValueType.FORCE_STRING}else if(Id(r))r.dataStream===`\r
20
- `?(o.v="",o.f=null,o.si=null,o.p=null):(o.p=i,o.v=null,o.f=null,o.si=null);else{if((c===o.v||c===""&&o.v==null)&&o.p==null)return null;o.v=c,o.f=null,o.si=null,o.p=null}return o}var Md=Object.defineProperty,bd=Object.getOwnPropertyDescriptor,Td=(o,t,e,n)=>{for(var i=n>1?void 0:n?bd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Md(t,e,i),i},Be=(o,t)=>(e,n)=>t(e,n,o);let En=class extends l.RxDisposable{constructor(t,e,n,i,r,s,a,c,d,u){super();R(this,"_loadedMap",new WeakSet);R(this,"_scheduledCallback",-1);this._univerInstanceService=t,this._renderManagerService=e,this._editorBridgeService=n,this._commandService=i,this._contextService=r,this._formulaEditorManagerService=s,this._undoRedoService=a,this._docSkeletonManagerService=c,this._docViewModelManagerService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(B.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._create(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._textSelectionManagerService.textSelection$.pipe(B.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{unitId:e}=t;e!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_create(t){if(t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&(this._loadedMap.has(n)||(this._initialMain(t),this._loadedMap.add(n)))}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(B.takeUntil(this.dispose$)).subscribe(()=>{var e;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.EDITOR_ACTIVATED)){this._univerInstanceService.setCurrentUnitForType(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.PointerDown});const r=(e=n==null?void 0:n.getBody())==null?void 0:e.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(te.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(B.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(t){const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:y.DeviceInputEventType.Dblclick})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(B.takeUntil(this.dispose$)).subscribe(t=>{if(!t)return this._clearScheduledCallback();const e=Xn(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||n==null)return this._clearScheduledCallback();const{width:i,height:r}=t;if(i===0||r===0)return this._clearScheduledCallback();const{engine:s}=e;n.updateDocumentDataPageSize(i),this._autoScroll(),this._scheduledCallback=requestIdleCallback(()=>s.resizeBySize(i,r))})}_clearScheduledCallback(){this._scheduledCallback!==-1&&cancelIdleCallback(this._scheduledCallback),this._scheduledCallback=-1}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(B.takeUntil(this.dispose$)).subscribe(t=>{t==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(t)}),this._editorBridgeService.visible$.pipe(B.takeUntil(this.dispose$)).subscribe(t=>{if(t==null||t.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const e=this._editorBridgeService.getLatestEditCellState();e!=null&&this._editorSyncHandler(e)})}_editorSyncHandler(t){var s;const e=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=e==null?void 0:e.dataStream,i=e==null?void 0:e.paragraphs,r=[];n==null||i==null||(t.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===y.DeviceInputEventType.Dblclick?(n=`\r
21
- `,i=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,i,r),this._autoScroll())}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,v.SetEditorResizeOperation.id],e=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var r,s;if(t.includes(i.id)){const a=i.params,{unitId:c}=a;if(e.includes(c)){const d=this._univerInstanceService.getUniverDocInstance(c),u=(r=d==null?void 0:d.getBody())==null?void 0:r.dataStream,h=(s=d==null?void 0:d.getBody())==null?void 0:s.paragraphs,m=c===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(u==null||h==null)return;this._syncContentAndRender(m,u,h),this._autoScroll()}}}));const n=[_.SetRangeValuesMutation.id,_.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var r,s,a,c,d;if(n.includes(i.id)){const u=this._editorBridgeService.getLatestEditCellState();if(u==null)return;let h=!1;const{row:m,column:g}=u;if(i.id===_.SetRangeValuesMutation.id&&i.params?(s=(r=i.params.cellValue)==null?void 0:r[m])!=null&&s[g]&&(h=!0):i.id===_.MoveRangeMutation.id&&i.params&&(c=(a=i.params.to.value)==null?void 0:a[m])!=null&&c[g]&&(h=!0),h){const f=(d=u.documentLayoutObject.documentModel)==null?void 0:d.getBody();if(f==null)return;const{dataStream:S,paragraphs:p=[]}=f;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,S,p),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,i=[]){var h;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),c=this._docViewModelManagerService.getViewModel(t);if(a==null||c==null||s==null)return;a.getBody().dataStream=e,a.getBody().paragraphs=this._clearParagraph(n),t===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),i.length>0&&(a.getBody().textRuns=i),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(t);u!=null&&(d.calculate(),r.includes(t)&&((h=u.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=l.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var f,S;const t=(f=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:f.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),i=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||i==null)return;const{marginTop:r=0,marginBottom:s=0}=i.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=t.getActualSize();d+=r+s;const{width:u,height:h}=e,m=a.getViewport(te.VIEWPORT_KEY.VIEW_MAIN);let g=m==null?void 0:m.getScrollBar();a.transformByState({width:u,height:d}),c==null||c.resize(u,d),d>h?g==null?m&&new y.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(g=null,m==null||m.scrollTo({x:0,y:0}),(S=m==null?void 0:m.getScrollBar())==null||S.dispose())}};En=Td([l.OnLifecycle(l.LifecycleStages.Steady,En),Be(0,l.IUniverInstanceService),Be(1,y.IRenderManagerService),Be(2,Ee),Be(3,l.ICommandService),Be(4,l.IContextService),Be(5,eo),Be(6,l.IUndoRedoService),Be(7,P.Inject(te.DocSkeletonManagerService)),Be(8,P.Inject(te.DocViewModelManagerService)),Be(9,P.Inject(te.TextSelectionManagerService))],En);const wd="36",Ed="univer-sheet-container",Qr={sheetFooterBarHeight:wd,sheetContainer:Ed};var yd=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,xd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Od(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&yd(t,e,i),i},Ie=(o,t)=>(e,n)=>t(e,n,o);const Yi=-1e3,Xi=5,Nd=2;let yn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c,d,u,h,m){super();R(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._univerInstanceService=i,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(l.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),i=this._editorBridgeService.getCurrentEditorId();if(n==null||i==null||!this._editorService.isSheetEditor(i))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(i))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,a,d,u)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.pipe(B.filter(t=>!!t)).subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:i,editorUnitId:r}=t;if(this._getEditorObject()==null||this._contextService.getContextValue(l.FOCUSING_EDITOR_STANDALONE)===!0||this._contextService.getContextValue(l.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)===!0)return;const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{vertexAngle:m}=y.convertTextRotation(d);h.updateDocumentId(r),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/i),this._univerInstanceService.changeDoc(r,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Yi,Yi)}))}_fitTextSize(t,e,n,i,r=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=t,h=i.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:g}=this._predictingSize(t,e,n,i,r,s),{verticalAlign:f,paddingData:S,fill:p}=i;let I=d-a,M=u-c;if(I<m&&(I=m),M<g)M=g,h.updateDocumentDataMargin(S);else{let b=0;f===l.VerticalAlign.MIDDLE?b=(M-g)/2/s:f===l.VerticalAlign.TOP?b=S.t||0:b=(M-g)/s-(S.b||0),b=b<(S.t||0)?S.t||0:b,h.updateDocumentDataMargin({t:b})}n.calculate(),this._editAreaProcessing(I,M,t,e,p,r,s)}_predictingSize(t,e,n,i,r=1,s=1){const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u}=i,h=i.documentModel,{vertexAngle:m}=y.convertTextRotation(d),g=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:p,actualHeight:I}=n.getActualSize();return{actualWidth:p*r,actualHeight:I*s}}h==null||h.updateDocumentDataPageSize((g-a-e.left)/r),n.calculate();const f=n.getActualSize();let S=c-a;return S<f.actualWidth*r+Xi*r&&(S=f.actualWidth*r+Xi*r),h==null||h.updateDocumentDataPageSize(S/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:S,actualHeight:f.actualHeight*s}}_editAreaProcessing(t,e,n,i,r,s=1,a=1){var w;const c=this._getEditorObject();if(c==null)return;let{startX:d,startY:u}=n;const{document:h,scene:m,engine:g}=c,f=m.getViewport(te.VIEWPORT_KEY.VIEW_MAIN),S=document.body.clientHeight-u-Number.parseFloat(Qr.sheetFooterBarHeight)-i.top-Nd*2,p=document.body.clientWidth-d-i.left;let I=e,M=f==null?void 0:f.getScrollBar();I>S?(I=S,M==null?f&&new y.ScrollBar(f,{enableHorizontal:!1,barSize:8}):f==null||f.resetSizeAndScrollBar()):(M=null,(w=f==null?void 0:f.getScrollBar())==null||w.dispose()),t+=(M==null?void 0:M.barSize)||0,t>p&&(t=p),d-=y.FIX_ONE_PIXEL_BLUR_OFFSET,u-=y.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/a,r);const{scaleX:b,scaleY:T}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/a,scaleX:s,scaleY:a}),h.resize(t/s,e/a),requestIdleCallback(()=>{g.resizeBySize(y.fixLineWidthByScale(t,b),y.fixLineWidthByScale(I,T))}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:t+d,endY:I+u,show:!0})}_addBackground(t,e,n,i){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&i==null||(s==null?t.addObjects([new y.Rect(r,{width:e,height:n,fill:i,evented:!1})],te.DOCS_COMPONENT_MAIN_LAYER_INDEX):i==null?s.dispose():(s.setProps({fill:i}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var w,E;const{visible:e,eventType:n,keycode:i}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,sheetId:g,isInArrayFormulaRange:f=!1}=r,S=this._getEditorObject();if(S==null)return;this._setOpenForCurrent(m,g);const{document:p,scene:I}=S;this._contextService.setContextValue(l.EDITOR_ACTIVATED,!0);const{documentModel:M}=a,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||M==null)return;const{skeleton:T}=b;if(this._fitTextSize(s,c,T,a,d,u),n===y.DeviceInputEventType.Keyboard||n===y.DeviceInputEventType.Dblclick&&f){const O=l.Tools.deepClone(M.snapshot),x=this._docViewModelManagerService.getViewModel(h);if(x==null)return;this._resetBodyStyle(O.body,!!f),M.reset(O),x.reset(M),p.makeDirty(),(i===v.KeyCode.BACKSPACE||n===y.DeviceInputEventType.Dblclick)&&(T.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===y.DeviceInputEventType.Dblclick){const O=M.getBody().dataStream.length-2||0;(w=I.getViewport(te.VIEWPORT_KEY.VIEW_MAIN))==null||w.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(E=this._renderManagerService.getRenderById(m))==null||E.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(l.FOCUSING_SHEET),i=this._univerInstanceService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(i)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(Te.id,{visible:!0,eventType:y.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,v.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const i=e.params,{unitId:r}=i;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const a=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(a==null)return;const c=this._editorBridgeService.getEditCellState();if(c==null)return;const{position:d,documentLayoutObject:u,canvasOffset:h,scaleX:m,scaleY:g}=c;this._fitTextSize(d,h,a,u,m,g)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[i,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return Xn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};yn=xd([l.OnLifecycle(l.LifecycleStages.Rendered,yn),Ie(0,P.Inject(te.DocSkeletonManagerService)),Ie(1,P.Inject(te.DocViewModelManagerService)),Ie(2,l.IContextService),Ie(3,l.IUniverInstanceService),Ie(4,y.IRenderManagerService),Ie(5,Ee),Ie(6,rn),Ie(7,y.ITextSelectionRenderManager),Ie(8,P.Inject(te.TextSelectionManagerService)),Ie(9,l.ICommandService),Ie(10,P.Inject(l.LocaleService)),Ie(11,v.IEditorService)],yn);var Ad=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Pd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Dd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ad(t,e,i),i},Hd=(o,t)=>(e,n)=>t(e,n,o);let Ao=class extends l.Disposable{constructor(o,t){super(),this._context=o,this._formatPainterService=t,this._initialize()}_initialize(){this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this.disposeWithMe(l.toDisposable(this._formatPainterService.status$.subscribe(o=>{const t=this._context.scene;t&&(o!==xe.OFF?t.setDefaultCursor(y.CURSOR_TYPE.CELL):t.setDefaultCursor(y.CURSOR_TYPE.DEFAULT))})))}};Ao=Pd([Hd(1,ft)],Ao);var Ld=Object.defineProperty,Ud=Object.getOwnPropertyDescriptor,Vd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ud(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ld(t,e,i),i},st=(o,t)=>(e,n)=>t(e,n,o);const Bd="__SpreadsheetFreezeRowMainName__",kd="__SpreadsheetFreezeRowHeaderName__",Fd="__SpreadsheetFreezeColumnMainName__",Wd="__SpreadsheetFreezeColumnHeaderName__",mo=4,jd=.01;let Fn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c){super();R(this,"_rowFreezeHeaderRect");R(this,"_rowFreezeMainRect");R(this,"_columnFreezeHeaderRect");R(this,"_columnFreezeMainRect");R(this,"_freezeDownObservers",[]);R(this,"_freezeMoveObservers",[]);R(this,"_freezeLeaveObservers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_changeToRow",-1);R(this,"_changeToColumn",-1);R(this,"_changeToOffsetX",0);R(this,"_changeToOffsetY",0);R(this,"_activeViewport",null);R(this,"_freezeNormalHeaderColor","");R(this,"_freezeNormalMainColor","");R(this,"_freezeActiveColor","");R(this,"_freezeHoverColor","");R(this,"_lastFreeze");this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionManagerService=i,this._scrollManagerService=r,this._themeService=s,this._sheetInterceptorService=a,this._injector=c,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return null;const i=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton,{startRow:r,startColumn:s}=n,a=this._getPositionByIndex(r,s);if(a==null)return null;const c=this._getSheetObject(),d=c.engine,u=(d==null?void 0:d.width)||0,h=(d==null?void 0:d.height)||0,m=c.scene,{startX:g,startY:f}=a,{rowTotalHeight:S,columnTotalWidth:p,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:M}=i,b=u>p+I?u:p+M,T=h>S+M?h:S+M;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=g,this._changeToOffsetY=f;const w=Math.max(m.scaleX,m.scaleY),E=mo/(w<1?1:w);if(t===0){const x=E;this._rowFreezeHeaderRect=new y.Rect(kd,{fill:this._freezeNormalHeaderColor,width:I,height:E,left:0,top:f-x,zIndex:3});let A=this._freezeNormalHeaderColor;(r===-1||r===0)&&(A=this._freezeNormalMainColor),this._rowFreezeMainRect=new y.Rect(Bd,{fill:A,width:b*2,height:E,left:I,top:f-x,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],tt)}else{const x=E;this._columnFreezeHeaderRect=new y.Rect(Wd,{fill:this._freezeNormalHeaderColor,width:E,height:M,left:g-x,top:0,zIndex:3});let A=this._freezeNormalHeaderColor;(s===-1||s===0)&&(A=this._freezeNormalMainColor),this._columnFreezeMainRect=new y.Rect(Fd,{fill:A,width:E,height:T*2,left:g-x,top:M,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],tt)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const i=this._getSheetObject();if(i==null)return;const{scene:r}=i;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(y.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,g,f;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,i=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/i,a=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,c=a===0?-((g=r==null?void 0:r.offsetY)!=null?g:0):e.rowHeightAccumulation[a-1]-((f=r==null?void 0:r.offsetY)!=null?f:0);let d=0,u=!1;for(let S=a,p=e.rowHeightAccumulation.length;S<p;S++)if(e.rowHeightAccumulation[S]-c>s){d=S,u=!0;break}return u||(d=e.rowHeightAccumulation.length-1),d}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(i=>i.isHit(new y.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,i=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(y.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?Number.POSITIVE_INFINITY:r.rowHeightAccumulation[c];this._activeViewport=null;const u=this._getFreeze();u&&(this._changeToColumn=u.startColumn,this._changeToRow=u.startRow),this._moveObserver=a.onPointerMoveObserver.add(m=>{var b,T,w,E;const g=this._getActiveViewport(m),{startX:f,startY:S,row:p,column:I}=Et(m.offsetX,m.offsetY,a,r,g||void 0,!0);a.setCursor(y.CURSOR_TYPE.GRABBING);const M=mo/Math.max(a.scaleX,a.scaleY);i===0?((b=e.transformByState({top:Math.min(S,d)-M/2}))==null||b.setProps({fill:this._freezeActiveColor}),(T=n.transformByState({top:Math.min(S,d)-M/2}))==null||T.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?p:Math.min(p,c),this._changeToOffsetY=Math.min(S,d),this._activeViewport=g):((w=e.transformByState({left:f-M/2}))==null||w.setProps({fill:this._freezeActiveColor}),(E=n.transformByState({left:f-M/2}))==null||E.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=I,this._changeToOffsetX=f,this._activeViewport=g)}),this._upObserver=a.onPointerUpObserver.add(()=>{var x,A;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:g}=r;i===0&&(this._changeToRow===0||this._changeToRow===-1)||i===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const f=mo/Math.max(a.scaleX,a.scaleY);i===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:g-f}),n.transformByState({top:g-f})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-f}),n.transformByState({left:m-f}));const S=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:p,sheetViewStartColumn:I}=S;if(I==null||p==null)return;const M=this._context.unit,b=M.getActiveSheet(),T=(x=b.getConfig())==null?void 0:x.freeze;let w=(T==null?void 0:T.xSplit)||0,E=(T==null?void 0:T.ySplit)||0;const O=(A=this._activeViewport)==null?void 0:A.viewPortKey;i===0&&(!O||O===W.VIEW_LEFT_TOP||O===W.VIEW_MAIN_LEFT_TOP||O===W.VIEW_MAIN_TOP||O===W.VIEW_ROW_TOP?E=this._changeToRow-(T.startRow-T.ySplit):E=this._changeToRow-p,E=E<0?0:E),i===1&&(!O||O===W.VIEW_LEFT_TOP||O===W.VIEW_MAIN_LEFT_TOP||O===W.VIEW_MAIN_LEFT||O===W.VIEW_COLUMN_LEFT?w=this._changeToColumn-(T.startColumn-T.xSplit):w=this._changeToColumn-I,w=w<0?0:w),this._commandService.executeCommand(_.SetFrozenCommand.id,{startRow:E===0?-1:this._changeToRow,startColumn:w===0?-1:this._changeToColumn,ySplit:E,xSplit:w,unitId:M.getUnitId(),subUnitId:b.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(W.VIEW_COLUMN_LEFT),i=e.getViewport(W.VIEW_COLUMN_RIGHT),r=e.getViewport(W.VIEW_ROW_TOP),s=e.getViewport(W.VIEW_ROW_BOTTOM),a=e.getViewport(W.VIEW_LEFT_TOP),c=e.getViewport(W.VIEW_MAIN),d=e.getViewport(W.VIEW_MAIN_LEFT_TOP),u=e.getViewport(W.VIEW_MAIN_LEFT),h=e.getViewport(W.VIEW_MAIN_TOP);if(!(n==null||i==null||r==null||s==null||a==null||c==null||d==null||u==null||h==null))return{viewMain:c,viewMainLeftTop:d,viewMainLeft:u,viewMainTop:h,viewColumnLeft:n,viewColumnRight:i,viewRowTop:r,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:i,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:d,actualScrollX:u,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:d,actualScrollY:h}),i.isActive&&i.updateScroll({scrollX:c,actualScrollX:u}),r.isActive&&r.updateScroll({scrollY:d,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:u})}))}_updateViewport(t=-1,e=-1,n=0,i=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=s,d=this._getViewports();if(!d)return;const{viewMain:u,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:g,viewColumnLeft:f,viewColumnRight:S,viewRowTop:p,viewRowBottom:I,viewLeftTop:M}=d;S.resize({left:a,top:0,height:c,right:0}),I.resize({left:0,top:c,bottom:0,width:a}),M.resize({left:0,top:0,width:a,height:c});let b=!0,T=!0;h.enable(),(t===-1||t===0)&&(b=!1),(e===-1||e===0)&&(T=!1);const w=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-i),E=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),g.disable(),m.disable(),p.disable(),f.disable(),h.resetPadding(),g.resetPadding(),m.resetPadding(),p.resetPadding(),f.resetPadding(),b===!1&&T===!1)u.resize({left:a,top:c,bottom:0,right:0}),u.resetPadding();else if(b===!0&&T===!1){const x=E.startY-w.startY;u.resize({left:a,top:c+x,bottom:0,right:0}),u.setPadding({startY:w.startY,endY:E.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(dt.id,{sheetViewStartRow:0,offsetY:0}),g.resize({left:a,top:c,height:x,right:0}),g.updateScroll({actualScrollY:w.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),p.resize({left:0,top:c,width:a,height:x}),p.updateScroll({actualScrollY:w.startY}),I.resize({left:0,top:c+x,bottom:0,width:a}),g.enable(),p.enable()}else if(b===!1&&T===!0){const x=E.startX-w.startX;u.resize({left:a+x,top:c,bottom:0,right:0}),u.setPadding({startX:w.startX,endX:E.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(dt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:x,bottom:0,right:0}),m.updateScroll({actualScrollX:w.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),f.resize({left:a,top:0,width:x,height:c}),f.updateScroll({actualScrollX:w.startX}),S.resize({left:a+x,top:0,height:c,right:0}),m.enable(),f.enable()}else{const x=E.startX-w.startX,A=E.startY-w.startY;u.resize({left:a+x,top:c+A,bottom:0,right:0}),u.setPadding({startY:w.startY,endY:E.startY,startX:w.startX,endX:E.startX}),r&&this._commandService.executeCommand(dt.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+A,width:x,bottom:0}),m.updateScroll({actualScrollX:w.startX,y:u.scrollY,actualScrollY:u.actualScrollY}),g.resize({left:a+x,top:c,height:A,right:0}),g.updateScroll({actualScrollY:w.startY,x:u.scrollX,actualScrollX:u.actualScrollX}),h.resize({left:a,top:c,width:x,height:A}),h.updateScroll({actualScrollX:w.startX,actualScrollY:w.startY}),p.resize({left:0,top:c,width:a,height:A}),p.updateScroll({actualScrollY:w.startY}),I.resize({left:0,top:c+A,bottom:0,width:a}),f.resize({left:a,top:0,width:x,height:c}),f.updateScroll({actualScrollX:w.startX}),S.resize({left:a+x,top:0,height:c,right:0}),h.enable(),g.enable(),m.enable(),p.enable(),f.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[_.SetWorksheetActiveOperation.id,_.InsertRangeMoveDownCommand.id,_.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._context.unit.getActiveSheet().getConfig().freeze,{startRow:i=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(i,r,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()}))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new l.ColorKit(t.grey400).setAlpha(jd).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const i=r=>{const s=this._context.unit,a=s.getUnitId(),d=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const u={...r,unitId:a,subUnitId:d,resetScroll:!1},h=_.SetFrozenMutationFactory(this._injector,u);return{undos:[{id:_.SetFrozenMutation.id,params:h}],redos:[{id:_.SetFrozenMutation.id,params:u}]}};if(t.id===_.InsertRowCommand.id){const s=t.params.range,a=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const c={...n,startRow:Math.max(1,n.startRow+a),ySplit:Math.max(1,n.ySplit+a)};return i(c)}}if(t.id===_.InsertColCommand.id){const s=t.params.range,a=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const c={...n,startColumn:Math.max(1,n.startColumn+a),xSplit:Math.max(1,n.xSplit+a)};return i(c)}}if(t.id===_.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=t.params,c=r==null?void 0:r.filter(p=>p.range.rangeType===l.RANGE_TYPE.COLUMN&&p.range.startColumn<=s&&s<=p.range.endColumn);if(!(c!=null&&c.length))return e;const d=c[0].range,u={...d,startColumn:a,endColumn:a+d.endColumn-d.startColumn};if(!n||n.startColumn<=0||d.startColumn>=n.startColumn&&u.startColumn>=n.startColumn||d.startColumn===u.startColumn||d.endColumn<n.startColumn&&u.startColumn<n.startColumn)return e;const h=d.endColumn-d.startColumn+1,m=Math.max(Math.min(n.startColumn,d.endColumn+1)-d.startColumn,0);let g,f;u.startColumn>=n.startColumn?(g=Math.max(n.startColumn-m,1),f=Math.max(n.xSplit-m,1)):(g=n.startColumn+h-m,f=n.xSplit+h-m);const S={...n,startColumn:g,xSplit:f};return i(S)}if(t.id===_.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=t.params,c=r==null?void 0:r.filter(p=>p.range.rangeType===l.RANGE_TYPE.ROW&&p.range.startRow<=s&&s<=p.range.endRow);if(!(c!=null&&c.length))return e;const d=c[0].range,u={...d,startRow:a,endRow:a+d.endRow-d.startRow};if(!n||n.startRow<=0||d.startRow>=n.startRow&&u.startRow>=n.startRow||d.startRow===u.startRow||d.endRow<n.startRow&&u.startRow<n.startRow)return e;const h=d.endRow-d.startRow+1,m=Math.max(Math.min(n.startRow,d.endRow+1)-d.startRow,0);let g,f;u.startRow>=n.startRow?(g=Math.max(n.startRow-m,1),f=Math.max(n.ySplit-m,1)):(g=n.startRow+h-m,f=n.ySplit+h-m);const S={...n,startRow:g,ySplit:f};return i(S)}if(t.id===_.RemoveColCommand.id||t.id===_.RemoveRowCommand.id){const r=t.params,s=r.range;if(s.rangeType===l.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const a=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,c={...n,startColumn:Math.max(1,n.startColumn-a),xSplit:Math.max(1,n.xSplit-a)};return i(c)}if(r.range.rangeType===l.RANGE_TYPE.ROW&&s.startRow<n.startRow){const a=Math.min(n.startRow,s.endRow+1)-s.startRow,c={...n,startRow:Math.max(1,n.startRow-a),ySplit:Math.max(1,n.ySplit-a)};return i(c)}}return e}}))}_commandExecutedListener(){const t=[_.SetFrozenMutation.id,ke.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,i=this._context.unit,r=i.getActiveSheet(),s=e.params,{unitId:a,subUnitId:c}=s;if(!(a===i.getUnitId()&&c===r.getSheetId()))return;const d=r.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:m=-1,ySplit:g=0,xSplit:f=0}=d;(!n||n.startRow!==h||n.ySplit!==g)&&(u|=2),(!n||n.startColumn!==m||n.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,m,g,f,u)}else if(e.id===_.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(i=>i.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(i=>i.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetWorksheetRowAutoHeightMutation.id){const n=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<i.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===_.SetColHiddenMutation.id||e.id===_.SetColVisibleMutation.id){const n=e.params,i=this._getFreeze(),r=n.ranges;i&&i.startColumn>-1&&r.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}else if(e.id===_.SetRowHiddenMutation.id||e.id===_.SetRowVisibleMutation.id){const n=e.params,i=this._getFreeze(),r=n.ranges;i&&i.startRow>-1&&r.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===y.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,i,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),e.onPointerMoveObserver.remove(a),e.onPointerLeaveObserver.remove(a)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var c;if(this._getSheetObject()==null)return;const i=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,r=i==null?void 0:i.getNoMergeCellPositionByIndex(t,e);if(i==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=i;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return it(this._context.unit,this._context)}_refreshFreeze(t,e,n,i,r){var a;const s={startRow:t,startColumn:e,ySplit:n,xSplit:i};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,i,r),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};Fn=Vd([st(1,P.Inject(exports.SheetSkeletonManagerService)),st(2,l.ICommandService),st(3,P.Inject(_.SelectionManagerService)),st(4,P.Inject(ot)),st(5,P.Inject(l.ThemeService)),st(6,P.Inject(_.SheetInterceptorService)),st(7,P.Inject(P.Injector))],Fn);var Do=(o=>(o[o.NORMAL=0]="NORMAL",o[o.HIGHLIGHT=1]="HIGHLIGHT",o))(Do||{});const $d="rgba(0, 0, 0, 0.15)",Xe="rgb(0, 0, 0)",un="rgb(255, 255, 255, 1)";class zd extends y.Shape{constructor(e,n){super(e,n);R(this,"_size",12);R(this,"_iconRatio",.4);R(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&y.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:$d});const n=this._size*.5*this._iconRatio,i=Math.PI/180*60,r=n*Math.sin(i),s=n*Math.cos(i);y.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Xe})}}var Yd=Object.defineProperty,Xd=Object.getOwnPropertyDescriptor,Gd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Xd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Yd(t,e,i),i},hn=(o,t)=>(e,n)=>t(e,n,o);const Zd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Kd="__SpreadsheetHeaderMenuMAINControllerShape__",qd="rgba(0, 0, 0, 0.1)";let Po=class extends l.Disposable{constructor(t,e,n,i,r){super();R(this,"_hoverRect");R(this,"_hoverMenu");R(this,"_currentColumn",Number.POSITIVE_INFINITY);R(this,"_observers",[]);this._context=t,this._sheetSkeletonManagerService=e,this._contextMenuService=n,this._commandService=i,this._selectionManagerService=r,this._initialize()}dispose(){var n,i;(n=this._hoverRect)==null||n.dispose(),(i=this._hoverMenu)==null||i.dispose();const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW);this._observers.forEach(r=>{e.onPointerEnterObserver.remove(r),e.onPointerMoveObserver.remove(r),e.onPointerLeaveObserver.remove(r),t.onPointerEnterObserver.remove(r),t.onPointerMoveObserver.remove(r),t.onPointerLeaveObserver.remove(r)})}_initialize(){const t=this._context.scene;this._hoverRect=new y.Rect(Zd,{fill:qd,evented:!1}),this._hoverMenu=new zd(Kd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],tt),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=t===0?n:e;this._observers.push(i==null?void 0:i.onPointerEnterObserver.add(()=>{var r;(r=this._hoverRect)==null||r.show()})),this._observers.push(i==null?void 0:i.onPointerMoveObserver.add(r=>{var f,S,p;const s=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(s==null)return;const{rowHeaderWidth:a,columnHeaderHeight:c}=s,{startX:d,startY:u,endX:h,endY:m,column:g}=Et(r.offsetX,r.offsetY,this._context.scene,s);if(t===0)(S=this._hoverRect)==null||S.transformByState({width:a,height:m-u,left:0,top:u});else{if(this._currentColumn=g,(p=this._hoverRect)==null||p.transformByState({width:h-d,height:c,left:d,top:0}),this._hoverMenu==null)return;if(h-d<c*2){this._hoverMenu.hide();return}const I=c*.8;this._hoverMenu.transformByState({left:h-c,top:c/2-I/2}),this._hoverMenu.setShapeProps({size:I}),this._hoverMenu.show()}})),this._observers.push(i==null?void 0:i.onPointerLeaveObserver.add(()=>{var r,s;(r=this._hoverRect)==null||r.hide(),(s=this._hoverMenu)==null||s.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{this._hoverMenu!=null&&(this._hoverMenu.setProps({mode:Do.HIGHLIGHT,visible:!0}),this._context.scene.setCursor(y.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{this._hoverMenu!=null&&(this._hoverMenu.setProps({mode:Do.NORMAL,visible:!1}),this._context.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{const e=this._currentColumn,n=this._selectionManagerService.getSelectionRanges();if(!!!(n!=null&&n.filter(r=>r.rangeType===l.RANGE_TYPE.COLUMN).find(r=>{const{startColumn:s,endColumn:a}=r;return e>=s&&e<=a}))){const r=this._getSelectionOnColumn(e);this._commandService.syncExecuteCommand(_.SetSelectionsOperation.id,r)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,le.COL_HEADER_CONTEXT_MENU)}))}_getSelectionOnColumn(t){const e=this._context.unit,n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:l.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};Po=Gd([hn(1,P.Inject(exports.SheetSkeletonManagerService)),hn(2,v.IContextMenuService),hn(3,l.ICommandService),hn(4,P.Inject(_.SelectionManagerService))],Po);var Qd=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,eu=(o,t,e,n)=>{for(var i=n>1?void 0:n?Jd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Qd(t,e,i),i},mn=(o,t)=>(e,n)=>t(e,n,o);const tu="__SpreadsheetHeaderMoveControllerBackground__",nu="__SpreadsheetHeaderMoveControllerShapeLine__",ou="rgba(0, 0, 0, 0.1)",iu="rgb(119, 119, 119)",ru=4;let Ho=class extends l.Disposable{constructor(t,e,n,i,r){super();R(this,"_startOffsetX",Number.NEGATIVE_INFINITY);R(this,"_startOffsetY",Number.NEGATIVE_INFINITY);R(this,"_moveHelperBackgroundShape");R(this,"_moveHelperLineShape");R(this,"_rowOrColumnDownObservers",[]);R(this,"_rowOrColumnMoveObservers",[]);R(this,"_rowOrColumnLeaveObservers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_scrollTimer");R(this,"_changeFromColumn",-1);R(this,"_changeFromRow",-1);R(this,"_changeToColumn",-1);R(this,"_changeToRow",-1);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionRenderService=i,this._selectionManagerService=r,this._initialize()}dispose(){var i,r,s;(i=this._moveHelperBackgroundShape)==null||i.dispose(),(r=this._moveHelperLineShape)==null||r.dispose();const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW),n=this._context.scene;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),t.onPointerDownObserver.remove(a)}),n.onPointerMoveObserver.remove(this._moveObserver),n.onPointerUpObserver.remove(this._upObserver),(s=this._scrollTimer)==null||s.dispose()}_initialize(){this._initialRowOrColumn(0),this._initialRowOrColumn(1)}_initialRowOrColumn(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=this._context.scene,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:d}=Et(s.offsetX,s.offsetY,i,a);if(this._checkInHeaderRange(t===0?c:d,t)===!1){i.resetCursor(),this._selectionRenderService.enableSelection();return}i.setCursor(y.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),i.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var w;const a=(w=this._sheetSkeletonManagerService.getCurrent())==null?void 0:w.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=i.getRelativeCoord(y.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:g,column:f}=Et(s.offsetX,s.offsetY,i,a);let S;t===0?(this._changeFromRow=g,S=y.ScrollTimerType.Y):(this._changeFromColumn=f,S=y.ScrollTimerType.X);const p=this._checkInHeaderRange(t===0?g:f,t);if(p===!1)return;const I=i.getScrollXYByRelativeCoords(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),i.setCursor(y.CURSOR_TYPE.GRABBING),i.disableEvent();let M=!1,b;const T=()=>{if(M)return;b=y.ScrollTimer.create(i,S);const E=i.getViewport(W.VIEW_MAIN);b.startScroll(h,m,E),this._scrollTimer=b,M=!0};this._moveObserver=i.onPointerMoveObserver.add(E=>{T();const{offsetX:O,offsetY:x}=E,{x:A,y:k}=i.getRelativeCoord(y.Vector2.FromArray([O,x]));this._rowColumnMoving(A,k,p,I,t),b.scrolling(A,k,()=>{this._rowColumnMoving(A,k,p,I,t)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var O,x,A;this._disposeBackgroundAndLine(),i.resetCursor(),i.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const E=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const N=(x=((E==null?void 0:E.filter(L=>L.range.rangeType===l.RANGE_TYPE.ROW&&L.range.startRow<=this._changeFromRow&&this._changeFromRow<=L.range.endRow))||[])[0])==null?void 0:x.range;N&&this._commandService.executeCommand(_.MoveRowsCommand.id,{fromRange:N,toRange:{...N,startRow:this._changeToRow,endRow:this._changeToRow+N.endRow-N.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const N=(A=((E==null?void 0:E.filter(L=>L.range.rangeType===l.RANGE_TYPE.COLUMN&&L.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=L.range.endColumn))||[])[0])==null?void 0:A.range;N&&this._commandService.executeCommand(_.MoveColsCommand.id,{fromRange:N,toRange:{...N,startColumn:this._changeToColumn,endColumn:this._changeToColumn+N.endColumn-N.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,i,r){var $,Q,D,H,F,Y,X;const s=this._context.scene,a=($=this._sheetSkeletonManagerService.getCurrent())==null?void 0:$.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:d,rowTotalHeight:u,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(W.VIEW_MAIN)),{scaleX:g,scaleY:f}=s.getAncestorScale(),S=a.getCellPositionByOffset(t,e,g,f,m),{row:p,column:I}=S,M=a.getNoMergeCellPositionByIndex(p,I),{startX:b,startY:T,endX:w,endY:E}=M,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const x=Math.max(g,g),{startX:A,endX:k,startY:N,endY:L,startRow:V,startColumn:j,endRow:z,endColumn:q}=O;r===0?(Q=this._moveHelperBackgroundShape)==null||Q.transformByState({height:L-N,width:h+c,left:0,top:N+(e-this._startOffsetY)/x+m.y-i.y}):(D=this._moveHelperBackgroundShape)==null||D.transformByState({height:u+d,width:k-A,left:A+(t-this._startOffsetX)/x+m.x-i.x,top:0}),(H=this._moveHelperBackgroundShape)==null||H.show();const K=ru/x;if(r===0){let J=0;if(p<=V)J=T-K/2,this._changeToRow=p;else if(p>z)J=E-K/2,this._changeToRow=p+1;else return;(F=this._moveHelperLineShape)==null||F.transformByState({height:K,width:h,left:c,top:J})}else{let J=0;if(I<=j)J=b-K/2,this._changeToColumn=I;else if(I>q)J=w-K/2,this._changeToColumn=I+1;else return;(Y=this._moveHelperLineShape)==null||Y.transformByState({height:u,width:K,left:J,top:d})}(X=this._moveHelperLineShape)==null||X.show()}_checkInHeaderRange(t,e=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(c=>{const d=c.range,{startRow:u,endRow:h,startColumn:m,endColumn:g,rangeType:f}=d;return e===1?t>=m&&t<=g&&l.RANGE_TYPE.COLUMN===f:t>=u&&t<=h&&l.RANGE_TYPE.ROW===f}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&e!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const t=this._context.scene;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const t=this._context.scene;this._moveHelperBackgroundShape=new y.Rect(tu,{fill:ou,evented:!1,zIndex:100}),this._moveHelperLineShape=new y.Rect(nu,{fill:iu,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],tt)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}};Ho=eu([mn(1,P.Inject(exports.SheetSkeletonManagerService)),mn(2,l.ICommandService),mn(3,Ne),mn(4,P.Inject(_.SelectionManagerService))],Ho);var Lo=(o=>(o[o.VERTICAL=0]="VERTICAL",o[o.HORIZONTAL=1]="HORIZONTAL",o))(Lo||{});const su="rgba(120, 120, 120, 0.01)",go="rgb(68, 71, 70)",$t=12,Uo=4;class Gi extends y.Shape{constructor(e,n){super(e,n);R(this,"_size",$t);R(this,"_color",go);R(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:i}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=$t/u,m=Uo/u;this.mode===0?(n=m,r=h-m):(i=m,s=h-m),y.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:su}),y.Rect.drawWith(e,{width:n,height:i,fill:go,radius:m}),e.save(),e.transform(1,0,0,1,r,s),y.Rect.drawWith(e,{width:n,height:i,fill:go,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:$t,height:this.size}):this.transformByState({width:this.size,height:$t}),this}}var au=Object.defineProperty,lu=Object.getOwnPropertyDescriptor,cu=(o,t,e,n)=>{for(var i=n>1?void 0:n?lu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&au(t,e,i),i},fo=(o,t)=>(e,n)=>t(e,n,o);const du="__SpreadsheetHeaderResizeControllerShapeRow__",uu="__SpreadsheetHeaderResizeControllerShapeColumn__",Zi="__SpreadsheetHeaderResizeControllerShapeHelper__",Ki="rgb(199, 199, 199)",hu=2;let Vo=class extends l.Disposable{constructor(t,e,n,i){super();R(this,"_currentRow",0);R(this,"_currentColumn",0);R(this,"_rowResizeRect");R(this,"_columnResizeRect");R(this,"_observers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_resizeHelperShape");R(this,"_startOffsetX",Number.POSITIVE_INFINITY);R(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._editorBridgeService=i,this._init()}dispose(){var n,i;(n=this._rowResizeRect)==null||n.dispose(),this._rowResizeRect=null,(i=this._columnResizeRect)==null||i.dispose(),this._columnResizeRect=null;const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW);this._observers.forEach(r=>{e.onPointerMoveObserver.remove(r),e.onPointerLeaveObserver.remove(r),t.onPointerMoveObserver.remove(r),t.onPointerLeaveObserver.remove(r)}),this._observers=[]}_init(){const t=this._context.scene;this._rowResizeRect=new Gi(du,{visible:!1,mode:Lo.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Gi(uu,{visible:!1,mode:Lo.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],tt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=this._context.scene,r=t===0?n:e;this._observers.push(r==null?void 0:r.onPointerMoveObserver.add((s,a)=>{var E;const c=(E=this._sheetSkeletonManagerService.getCurrent())==null?void 0:E.skeleton;if(c==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=c,{startX:h,startY:m,endX:g,endY:f,row:S,column:p}=Et(s.offsetX,s.offsetY,i,c),I=Rn(s.offsetX,s.offsetY,i),{scaleX:M,scaleY:b}=i.getAncestorScale(),T=Math.max(M,b),w=$t/T;if(t===0){let O=m-w/2;if(I.y<=m+w/2&&I.y>=m)this._currentRow=S-1;else if(I.y>=f-w/2&&I.y<=f)this._currentRow=S,O=f-w/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const x=d/3;this._rowResizeRect.transformByState({left:d/2-x/2,top:O}),this._rowResizeRect.setShapeProps({size:x}),this._rowResizeRect.show()}else{let O=h-w/2;if(I.x<=h+w/2&&I.x>=h)this._currentColumn=p-1;else if(I.x>=g-w/2&&I.x<=g)this._currentColumn=p,O=g-w/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const x=u*.7;this._columnResizeRect.transformByState({left:O,top:u/2-x/2}),this._columnResizeRect.setShapeProps({size:x}),this._columnResizeRect.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add((s,a)=>{var c,d;(c=this._rowResizeRect)==null||c.hide(),(d=this._columnResizeRect)==null||d.hide()}))}_initialHoverResize(t=0){const e=this._context.scene,n=t===0?this._rowResizeRect:this._columnResizeRect;n!=null&&(this.disposeWithMe(l.toDisposable(n.onPointerEnterObserver.add(()=>{n!=null&&(n.show(),e.setCursor(t===0?y.CURSOR_TYPE.ROW_RESIZE:y.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(n.onPointerLeaveObserver.add(()=>{n!=null&&(n.hide(),e.resetCursor())}))),this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add((i,r)=>{var K,$,Q,D,H,F,Y;const s=(K=this._sheetSkeletonManagerService.getCurrent())==null?void 0:K.skeleton;if(s==null)return;const a=this._context.scene,c=a.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=a.getViewport(W.VIEW_MAIN),m=(((Q=($=h==null?void 0:h.getScrollBar())==null?void 0:$.horizonBarRect)==null?void 0:Q.height)||0)+10,g=(((H=(D=h==null?void 0:h.getScrollBar())==null?void 0:D.verticalBarRect)==null?void 0:H.width)||0)+10,f=Rn(i.offsetX,i.offsetY,a),{scaleX:S,scaleY:p}=a.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const I=s.getOffsetByPositionX(this._currentColumn),M=s.getOffsetByPositionY(this._currentRow),b=s.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let T=!1,w=0,E=0;const{columnTotalWidth:O,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:k}=s,N=u>O+x?u:O+x,L=d>A+k?d:A+k,V=Math.max(S,p),j=Uo/V;t===0?this._resizeHelperShape=new y.Rect(Zi,{width:N,height:j,fill:Ki,left:0,top:M-j/2}):this._resizeHelperShape=new y.Rect(Zi,{width:j,height:L,fill:Ki,left:I-j/2,top:0});const z=((F=this._columnResizeRect)==null?void 0:F.left)||0,q=((Y=this._rowResizeRect)==null?void 0:Y.top)||0;a.addObject(this._resizeHelperShape,tt),a.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown}),this._moveObserver=a.onPointerMoveObserver.add(X=>{var de,se,$e,pe,Ht,Lt;const J=a.getRelativeCoord(y.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),ee=a.getScrollXYByRelativeCoords(J,h),ce=Rn(X.offsetX,X.offsetY,a),{x:Ce,y:De}=ce,{scaleX:Pe,scaleY:We}=a.getAncestorScale(),je=Math.max(Pe,We),he=Uo/je;w=Ce-this._startOffsetX-he/2,E=De-this._startOffsetY-he/2,Math.abs(t===0?E:w)>=hu&&(T=!0),t===0?(E>d-m+ee.y-b.startY&&(E=d-m+ee.y-b.startY),E<-(b.endY-b.startY)+2&&(E=-(b.endY-b.startY)+2),T&&((de=this._resizeHelperShape)==null||de.transformByState({top:M+E}),(se=this._rowResizeRect)==null||se.transformByState({top:q+E+he/2}),($e=this._rowResizeRect)==null||$e.show(),a.setCursor(y.CURSOR_TYPE.ROW_RESIZE))):(w>u-g+ee.x-b.startX&&(w=u-g+ee.x-b.startX),w<-(b.endX-b.startX)+2&&(w=-(b.endX-b.startX)+2),T&&((pe=this._resizeHelperShape)==null||pe.transformByState({left:I+w}),(Ht=this._columnResizeRect)==null||Ht.transformByState({left:z+w+he/2}),(Lt=this._columnResizeRect)==null||Lt.show(),a.setCursor(y.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=a.onPointerUpObserver.add(X=>{var ee,ce,Ce;const J=this._context.scene;this._clearObserverEvent(),(ee=this._resizeHelperShape)==null||ee.dispose(),this._resizeHelperShape=null,J.enableEvent(),T&&(J.resetCursor(),(ce=this._rowResizeRect)==null||ce.hide(),(Ce=this._columnResizeRect)==null||Ce.hide(),t===0?this._commandService.executeCommand(_.DeltaRowHeightCommand.id,{deltaY:E,anchorRow:this._currentRow}):this._commandService.executeCommand(_.DeltaColumnWidthCommand.id,{deltaX:w,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(n.onDblclickObserver.add(()=>{var i;t===0&&(this._context.scene.resetCursor(),this._commandService.executeCommand(_.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(i=this._rowResizeRect)==null||i.hide())}))))}_clearObserverEvent(){const t=this._context.scene;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}};Vo=cu([fo(1,P.Inject(exports.SheetSkeletonManagerService)),fo(2,l.ICommandService),fo(3,Ee)],Vo);var Bo=(o=>(o[o.ROW=0]="ROW",o[o.COLUMN=1]="COLUMN",o))(Bo||{});const zt=12,mu=.4;class qi extends y.Shape{constructor(e,n,i){super(e,n);R(this,"_size",zt);R(this,"_iconRatio",mu);R(this,"_hovered",!0);R(this,"_hasPrevious",!0);R(this,"_hasNext",!0);R(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>i==null?void 0:i())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Xe,fill:un}):y.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Xe,fill:un}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&y.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Xe}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:Xe})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?y.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Xe,fill:un}):y.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Xe,fill:un}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&y.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Xe}),this._hasNext){const a=this._hasPrevious?3:1;y.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:Xe})}}}var gu=Object.defineProperty,fu=Object.getOwnPropertyDescriptor,_u=(o,t,e,n)=>{for(var i=n>1?void 0:n?fu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&gu(t,e,i),i},Qi=(o,t)=>(e,n)=>t(e,n,o);const Ji="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Su=[_.InsertColMutation.id,_.InsertRowMutation.id,_.RemoveColMutation.id,_.RemoveRowMutation.id,_.SetWorksheetColWidthMutation.id,_.SetWorksheetRowIsAutoHeightMutation.id,_.SetRowHiddenMutation.id,_.SetRowVisibleMutation.id,_.SetColHiddenMutation.id,_.SetColVisibleMutation.id];let ko=class extends l.RxDisposable{constructor(t,e,n){super();R(this,"_shapes",{cols:[],rows:[]});this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._init()}get _workbook(){return this._context.unit}dispose(){super.dispose(),this._clearShapes()}_init(){let t="";this._context.unit.activeSheet$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{if(this._clearShapes(),!e){t="";return}t=e.getSheetId(),this._update(this._workbook,e)}),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!Su.includes(e.id)||!e.params||!e.params.unitId||e.params.subUnitId!==t)return;const n=this._workbook,i=n.getSheetBySheetId(e.params.subUnitId);i&&this._update(n,i)}))}_update(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getUnitSkeleton(t.getUnitId(),e.getSheetId()))==null?void 0:m.skeleton;if(!n)return;const i=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject(),{scene:a}=s,c=e.getRowCount(),d=i.map(g=>{const{startRow:f,endRow:S}=g,p=Oo(f,0,a,n),I=f!==0,M=S!==c-1;return new qi(Ji,{type:Bo.ROW,hovered:!1,hasPrevious:I,hasNext:M,top:p.startY-(I?zt:0),left:p.startX-zt},()=>this._commandService.executeCommand(_.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[g]}))}),u=e.getColumnCount(),h=r.map(g=>{const{startColumn:f,endColumn:S}=g,p=Oo(0,f,a,n),I=f!==0,M=S!==u-1;return new qi(Ji,{type:Bo.COLUMN,hovered:!1,hasPrevious:I,hasNext:M,top:20-zt,left:p.startX-(I?zt:0)},()=>this._commandService.executeCommand(_.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[g]}))});a.addObjects(h,wi),a.addObjects(d,wi),this._clearShapes(),this._shapes={cols:h,rows:d}}_clearShapes(){this._shapes.cols.forEach(t=>t.dispose()),this._shapes.rows.forEach(t=>t.dispose()),this._shapes={cols:[],rows:[]}}_getSheetObject(){return it(this._workbook,this._context)}};ko=_u([Qi(1,P.Inject(exports.SheetSkeletonManagerService)),Qi(2,l.ICommandService)],ko);var pu=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,vu=(o,t,e,n)=>{for(var i=n>1?void 0:n?Cu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&pu(t,e,i),i},_o=(o,t)=>(e,n)=>t(e,n,o);let Fo=class extends l.Disposable{constructor(o,t,e,n){super(),this._context=o,this._markSelectionService=t,this._commandService=e,this._sheetSkeletonManagerService=n,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const o=[Te.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{o.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,i)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(i)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{o&&this._markSelectionService.refreshShapes()}))}};Fo=vu([_o(1,P.Inject(tn)),_o(2,l.ICommandService),_o(3,P.Inject(exports.SheetSkeletonManagerService))],Fo);var Iu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Mu=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ru(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Iu(t,e,i),i},St=(o,t)=>(e,n)=>t(e,n,o);let Wo=class extends l.Disposable{constructor(o,t,e,n,i,r,s){super(),this._context=o,this._sheetSkeletonManagerService=t,this._commandService=e,this._selectionRenderService=n,this._selectionManagerService=i,this._themeService=r,this._definedNamesService=s,this._init()}dispose(){super.dispose(),this._selectionRenderService.changeRuntime(null,null),this._selectionRenderService.reset(),this._selectionManagerService.reset()}_init(){const o=this._context.unit,t=o.getActiveSheet(),e=this._getSheetObject();this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=o.getUnitId(),i=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:_.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:i})}_initDefinedNameListener(){this.disposeWithMe(this._definedNamesService.focusRange$.subscribe(async o=>{if(o==null)return;const{unitId:t}=o;let{formulaOrRefString:e}=o;const n=this._context.unit;if(t!==n.getUnitId()||(e.substring(0,1)===Z.operatorToken.EQUALS&&(e=e.substring(1)),!Z.isReferenceStrings(e)))return;const r=await this._getSelections(n,t,e);this._selectionManagerService.replace(r),this._commandService.executeCommand(_.ScrollToCellOperation.id,r[0].range)}))}async _getSelections(o,t,e){const n=e.split(",");let i=o.getActiveSheet();const r=[];for(let s=0;s<n.length;s++){const a=n[s].trim(),c=Z.deserializeRangeWithSheet(a.trim());if(s===0){const u=o.getSheetBySheetName(c.sheetName);u&&i.getSheetId()!==u.getSheetId()&&(i=u,await this._commandService.executeCommand(_.SetWorksheetActivateCommand.id,{subUnitId:i.getSheetId(),unitId:t}))}if(i.getName()!==c.sheetName)continue;let d=null;if(s===n.length-1){const u=c.range,{startRow:h,startColumn:m,endRow:g,endColumn:f}=u;d=_.getPrimaryForRange({startRow:h,startColumn:m,endRow:g,endColumn:f},i)}r.push({range:c.range,style:_.getNormalSelectionStyle(this._themeService),primary:d})}return r}_getActiveViewport(o){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(y.Vector2.FromArray([o.offsetX,o.offsetY]))}_initViewMainListener(o){const{spreadsheet:t}=o;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const o=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();o==null||(t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(o)})))}_refreshSelection(o){const t=o.map(e=>{const n=this._selectionRenderService.convertSelectionToCoord(e);return n.style=_.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(o){const{spreadsheetRowHeader:t,spreadsheet:e}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((n,i)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),y.ScrollTimerType.Y),n.button!==2&&i.stopPropagation()}))}_initColumnHeader(o){const{spreadsheetColumnHeader:t,spreadsheet:e}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((n,i)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),y.ScrollTimerType.X),n.button!==2&&i.stopPropagation()}))}_initLeftTop(o){const{spreadsheetLeftTopPlaceholder:t}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var a;const i=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(i==null)return;this._selectionRenderService.reset();const r=this._getAllRange(i),s=this._selectionRenderService.convertSelectionToCoord(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()}))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(o=>{if(this._selectionRenderService.reset(),o!=null){for(const t of o){if(t==null)continue;const e=this._selectionRenderService.convertSelectionToCoord(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(o)}}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(o=>{o!=null&&this._syncDefinedNameRange(o)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(o=>{o!=null&&this._syncDefinedNameRange(o)})))}_syncDefinedNameRange(o){if(o.length===0)return;const t=o[o.length-1],e=this._context.unit,n=e.getActiveSheet();this._definedNamesService.setCurrentRange({range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this.disposeWithMe(this._selectionRenderService.selectionMoveStart$.subscribe(o=>{this._move(o,_.SelectionMoveType.MOVE_START)})),this.disposeWithMe(this._selectionRenderService.selectionMoving$.subscribe(o=>{this._move(o,_.SelectionMoveType.MOVING)})),this.disposeWithMe(this._selectionRenderService.selectionMoveEnd$.subscribe(o=>{this._move(o,_.SelectionMoveType.MOVE_END)}))}_move(o,t){const e=this._context.unit;if(!e)return;const n=e.getUnitId(),i=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();o==null||o.length===0||this._commandService.executeCommand(_.SetSelectionsOperation.id,{unitId:n,subUnitId:i,type:t,pluginName:(r==null?void 0:r.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME,selections:o.map(s=>_.convertSelectionDataToRange(s))})}_getSheetObject(){return it(this._context.unit,this._context)}_initCommandListener(){const o=[ke.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(o.includes(t.id)){const e=this._context.unit,n=e.getActiveSheet(),i=t.params,{unitId:r,subUnitId:s}=i;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null){this._selectionRenderService.changeRuntime(null,null);return}const{unitId:t,sheetId:e,skeleton:n}=o,{scene:i}=this._context,r=i.getViewport(W.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,i,r);const s=this._selectionManagerService.getCurrent(),a=(s==null?void 0:s.pluginName)||_.NORMAL_SELECTION_PLUGIN_NAME;if((s==null?void 0:s.unitId)===t&&s.sheetId===e){const c=this._selectionManagerService.getSelections();c!=null&&this._refreshSelection(c)}else this._selectionManagerService.setCurrentSelection({pluginName:a,unitId:t,sheetId:e});a===_.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])}))}_getAllRange(o){return{range:{startRow:0,startColumn:0,endRow:o.getRowCount()-1,endColumn:o.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL},primary:this._getZeroRange(o).primary,style:null}}_getZeroRange(o){const t=o.mergeData;return _.transformCellDataToSelectionData(0,0,t)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};Wo=Mu([St(1,P.Inject(exports.SheetSkeletonManagerService)),St(2,l.ICommandService),St(3,Ne),St(4,P.Inject(_.SelectionManagerService)),St(5,P.Inject(l.ThemeService)),St(6,Z.IDefinedNamesService)],Wo);const Ze={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(o,t)=>{const e=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(v.IConfirmService),s=o.get(l.LocaleService),a=t.unitId,c=t.subUnitId,d=t.selections,u=_.getAddMergeMutationRangeByType(d,t.value),h=i.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],g=[],f=Pr(h,u);if(f&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const S={unitId:a,subUnitId:c,ranges:u},p={unitId:a,subUnitId:c,ranges:u},I=_.RemoveMergeUndoMutationFactory(o,S),M=_.AddMergeUndoMutationFactory(o,p);if(I.ranges.length>0&&m.push({id:_.RemoveWorksheetMergeMutation.id,params:I}),m.push({id:_.AddWorksheetMergeMutation.id,params:p}),g.push({id:_.RemoveWorksheetMergeMutation.id,params:M}),I.ranges.length>0&&g.push({id:_.AddWorksheetMergeMutation.id,params:I}),f){const E=Hr(o,a,h,u);m.unshift(...E.redos),g.push(...E.undos)}const b=_.AddMergeRedoSelectionsOperationFactory(o,t,u);b&&m.push(b);const T=_.AddMergeUndoSelectionsOperationFactory(o,t);return T&&g.push(T),l.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:a,undoMutations:g,redoMutations:m}),!0):!1}},Jr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(_.SelectionManagerService).getSelectionRanges(),i=Qo(Gn.MergeAll,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ze.id,{selections:i,unitId:c,subUnitId:d})}},es={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(_.SelectionManagerService).getSelectionRanges(),i=Qo(Gn.MergeVertical,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ze.id,{value:l.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:d})}},ts={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(_.SelectionManagerService).getSelectionRanges(),i=Qo(Gn.MergeHorizontal,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),d=a.getSheetId();return t.executeCommand(Ze.id,{value:l.Dimension.ROWS,selections:i,unitId:c,subUnitId:d})}},li={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async o=>{const t=o.get(v.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(_.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=_.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await t.confirm({id:li.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveLeftCommand.id):!0}},Wn={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async o=>{const t=o.get(v.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(_.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=_.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await t.confirm({id:Wn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await t.confirm({id:Wn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.DeleteRangeMoveUpCommand.id):!0}},jn={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async o=>{const t=o.get(v.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(_.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=_.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let g=d.startRow;g<=d.endRow;g++)if(c.getRowFiltered(g)&&await t.confirm({id:jn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const u=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await t.confirm({id:jn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveDownCommand.id):!0}},ci={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async o=>{const t=o.get(v.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(_.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=_.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,d);return f?u(g)>u(f):!1})||await t.confirm({id:ci.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(_.InsertRangeMoveRightCommand.id):!0}},ns={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(yt);return e.applyType=t.type,!0}},os={id:"sheet.command.remove-row-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{var d;const e=o.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const i=o.get(l.ICommandService),r=o.get(l.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:a}=s,c=a.getVisibleRows();if(wr(c,[n])){const u=o.get(v.IConfirmService),h=o.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(_.RemoveRowCommand.id,{range:n}),!0}},is={id:"sheet.command.remove-col-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{var d;const e=o.get(_.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(d=e.getLast())==null?void 0:d.range),!n)return!1;const i=o.get(l.ICommandService),r=o.get(l.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:a}=s,c=a.getVisibleCols();if(Er(c,[n])){const u=o.get(v.IConfirmService),h=o.get(l.LocaleService);return await u.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(_.RemoveColCommand.id,{range:n}),!0}},rs={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{const{subUnitId:e}=t,n=o.get(v.IConfirmService),i=o.get(l.ICommandService),r=o.get(l.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await i.executeCommand(_.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Pt=P.createIdentifier("univer.sheetbar-service");class bu extends l.Disposable{constructor(){super();R(this,"renameId$");R(this,"removeId$");R(this,"scroll$");R(this,"scrollX$");R(this,"addSheet$");R(this,"_renameId$");R(this,"_removeId$");R(this,"_scroll$");R(this,"_scrollX$");R(this,"_addSheet$");R(this,"_currentHandler",null);this._renameId$=new B.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new B.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new B.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new B.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new B.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,l.toDisposable(()=>{this._currentHandler=null})}}const ss={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async o=>(o.get(Pt).triggerSheetBarMenu(),!0)},as={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(o,t)=>(o.get(Ee).setEditCell(t),!0)},ls={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(o,t)=>{const e=o.get(Pt);return t&&e.setRenameId(t.subUnitId),!0}};var Me=function(){return Me=Object.assign||function(o){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(o[i]=t[i])}return o},Me.apply(this,arguments)},Tu=function(o,t){var e={};for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&t.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(o);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(o,n[i])&&(e[n[i]]=o[n[i]]);return e},Se=U.forwardRef(function(o,t){var e=o.icon,n=o.id,i=o.className,r=o.extend,s=Tu(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=U.useRef("_".concat(yu()));return cs(e,"".concat(n),{defIds:e.defIds,idSuffix:c.current},Me({ref:t,className:a},s),r)});function cs(o,t,e,n,i){return U.createElement(o.tag,Me(Me({key:t},wu(o,e,i)),n),(Eu(o,e).children||[]).map(function(r,s){return cs(r,"".concat(t,"-").concat(o.tag,"-").concat(s),e,void 0,i)}))}function wu(o,t,e){var n=Me({},o.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var i=t.defIds;return!i||i.length===0||(o.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function Eu(o,t){var e,n=t.defIds;return!n||n.length===0?o:o.tag==="defs"&&(!((e=o.children)===null||e===void 0)&&e.length)?Me(Me({},o),{children:o.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?Me(Me({},i),{attrs:Me(Me({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):o}function yu(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Ou={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},ds=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"autofill",ref:t,icon:Ou}))});ds.displayName="Autofill";const xu=ds;var Nu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.44 3.57291C14.698 3.83093 14.698 4.24927 14.44 4.50729L6.44342 12.5037C6.28721 12.6599 6.03395 12.6599 5.87774 12.5037L1.55992 8.18578C1.3019 7.92776 1.3019 7.50942 1.55993 7.2514C1.81795 6.99338 2.23629 6.99338 2.49431 7.25141L6.01916 10.7763C6.09727 10.8544 6.2239 10.8544 6.30201 10.7763L13.5056 3.57291C13.7636 3.31489 14.1819 3.31489 14.44 3.57291Z",fillRule:"evenodd",clipRule:"evenodd"}}]},us=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"check-mark-single",ref:t,icon:Nu}))});us.displayName="CheckMarkSingle";const Qt=us;var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.57061 3.65132C4.31677 3.39748 3.90521 3.39748 3.65137 3.65132C3.39753 3.90516 3.39753 4.31672 3.65137 4.57056L7.08079 7.99998L3.65123 11.4295C3.39739 11.6834 3.39739 12.0949 3.65123 12.3488C3.90507 12.6026 4.31662 12.6026 4.57047 12.3488L8.00003 8.91921L11.4295 12.3487C11.6834 12.6026 12.0949 12.6026 12.3488 12.3487C12.6026 12.0949 12.6026 11.6833 12.3488 11.4295L8.91927 7.99998L12.3486 4.57061C12.6025 4.31677 12.6025 3.90521 12.3486 3.65137C12.0948 3.39753 11.6832 3.39753 11.4294 3.65137L8.00003 7.08074L4.57061 3.65132Z"}}]},hs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"close-single",ref:t,icon:Au}))});hs.displayName="CloseSingle";const Du=hs;var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.22297.954345C1.3529.929358 1.51542.914795 1.7147.914795H6.85715C7.0561.914795 7.21986.929297 7.35152.959681 7.48737.991031 7.5967 1.04983 7.67995 1.13863 7.76349 1.22774 7.81571 1.34646 7.84615 1.48343L7.84671 1.48597C7.87164 1.62058 7.88612 1.79252 7.88612 2.00111V7.16269C7.88612 7.36211 7.87154 7.52439 7.84667 7.6587 7.82039 7.79533 7.76169 7.91004 7.67831 7.9934 7.59462 8.0771 7.48565 8.13006 7.35692 8.16096 7.22966 8.1915 7.06561 8.20599 6.87627 8.20599H1.7147C1.52177 8.20599 1.36349 8.19641 1.23252 8.17122 1.09967 8.14567.98914 8.09813.90398 8.0134.818184 7.93285.765734 7.8172.735395 7.68573.705177 7.55478.68573 7.38178.68573 7.16269V1.9581C.68573 1.7541.700286 1.58699.725186 1.45253.751461 1.31589.810166 1.20119.893537 1.11782.978617 1.03274 1.08895.98522 1.22033.954901L1.22297.954345zM2.02733 2.07424C1.95064 2.07854 1.91191 2.09755 1.89153 2.11849 1.86949 2.1517 1.85476 2.19738 1.85473 2.25901L1.86389 3.92571H3.72054V2.07424H2.02733zM4.8991 2.07901V3.92571H6.70756V2.20184C6.70756 2.15684 6.7041 2.12531 6.69899 2.10487 6.69675 2.09591 6.69467 2.09093 6.69349 2.08853 6.68344 2.08345 6.66389 2.07901 6.61819 2.07901H4.8991zM1.86466 5.08037L1.87384 6.90902C1.87384 6.95115 1.87723 6.98219 1.8825 7.00371 1.8864 7.01961 1.89067 7.02788 1.8933 7.03179 1.8933 7.03179 1.89686 7.03365 1.8996 7.03479 1.90589 7.03741 1.91476 7.04025 1.92666 7.04282 1.95062 7.04799 1.98341 7.05133 2.02535 7.05133H3.72532V5.08037H1.86466zM4.8991 5.08037V7.05133H6.55606C6.63148 7.05133 6.67174 7.04228 6.68909 7.03374 6.69039 7.03177 6.69349 7.02643 6.69691 7.01502 6.70311 6.99436 6.70756 6.96264 6.70756 6.91894V5.08037H4.8991zM8.65114 7.83368C8.78108 7.80869 8.94359 7.79413 9.14288 7.79413H14.2853C14.4843 7.79413 14.648 7.80863 14.7797 7.83902 14.9155 7.87037 15.0249 7.92916 15.1081 8.01797 15.1917 8.10707 15.2439 8.2258 15.2743 8.36277L15.2749 8.36531C15.2998 8.49991 15.3143 8.67185 15.3143 8.88045V14.042C15.3143 14.2414 15.2997 14.4037 15.2748 14.538 15.2486 14.6747 15.1899 14.7894 15.1065 14.8727 15.0228 14.9564 14.9138 15.0094 14.7851 15.0403 14.6578 15.0708 14.4938 15.0853 14.3044 15.0853H9.14288C8.94995 15.0853 8.79166 15.0757 8.6607 15.0506 8.52785 15.025 8.41732 14.9775 8.33216 14.8927 8.24636 14.8122 8.19391 14.6965 8.16358 14.5651 8.13336 14.4341 8.11391 14.2611 8.11391 14.042V8.83744C8.11391 8.63343 8.12847 8.46633 8.15337 8.33186 8.17964 8.19523 8.23835 8.08053 8.32172 7.99716 8.4068 7.91208 8.51713 7.86456 8.64851 7.83424L8.65114 7.83368zM9.45551 8.95357C9.37882 8.95788 9.34009 8.97689 9.3197 8.99782 9.29767 9.03103 9.28294 9.07672 9.28291 9.13834L9.29206 10.805H11.1487V8.95357H9.45551zM12.3273 8.95835V10.805H14.1357V9.08118C14.1357 9.03618 14.1323 9.00465 14.1272 8.98421 14.1249 8.97524 14.1228 8.97026 14.1217 8.96786 14.1116 8.96278 14.0921 8.95835 14.0464 8.95835H12.3273zM9.29283 11.9597L9.30202 13.7884C9.30202 13.8305 9.30541 13.8615 9.31068 13.883 9.31457 13.8989 9.31885 13.9072 9.32148 13.9111L9.32448 13.9127 9.32778 13.9141C9.33407 13.9167 9.34293 13.9196 9.35484 13.9222 9.3788 13.9273 9.41159 13.9307 9.45353 13.9307H11.1535V11.9597H9.29283zM12.3273 11.9597V13.9307H13.9842C14.0597 13.9307 14.0999 13.9216 14.1173 13.9131 14.1186 13.9111 14.1217 13.9058 14.1251 13.8944 14.1313 13.8737 14.1357 13.842 14.1357 13.7983V11.9597H12.3273z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.46247 2.15033C9.46247 1.74649 9.78985 1.41911 10.1937 1.41911H12.3873C13.5988 1.41911 14.581 2.40124 14.581 3.61276V5.80641C14.581 6.21025 14.2536 6.53762 13.8498 6.53762 13.4459 6.53762 13.1185 6.21025 13.1185 5.80641V3.61276C13.1185 3.20893 12.7912 2.88154 12.3873 2.88154H10.1937C9.78985 2.88154 9.46247 2.55417 9.46247 2.15033zM2.88154 10.1937C2.88154 9.78986 2.55416 9.46248 2.15032 9.46248 1.74648 9.46248 1.4191 9.78986 1.4191 10.1937V12.3873C1.4191 13.5988 2.40123 14.581 3.61275 14.581H5.8064C6.21024 14.581 6.53761 14.2536 6.53761 13.8498 6.53761 13.4459 6.21024 13.1186 5.8064 13.1186H3.61275C3.20892 13.1186 2.88154 12.7912 2.88154 12.3873V10.1937z"}}]}]},ms=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"convert-single",ref:t,icon:Pu}))});ms.displayName="ConvertSingle";const Hu=ms;var Lu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"delete-single",ref:t,icon:Lu}))});gs.displayName="DeleteSingle";const Uu=gs;var Vu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]}]},fs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"dropdown-single",ref:t,icon:Vu}))});fs.displayName="DropdownSingle";const er=fs;var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0 0H16V16H0z",opacity:.01}},{tag:"path",attrs:{fill:"currentColor",d:"M8.09973 1.50049C4.51022 1.50049 1.59973 4.41098 1.59973 8.00049C1.59973 11.59 4.51022 14.5005 8.09973 14.5005C11.6892 14.5005 14.5997 11.59 14.5997 8.00049C14.5997 4.41098 11.6892 1.50049 8.09973 1.50049ZM10.4995 10.4701L9.5419 10.4657L8.09971 8.74643L6.65897 10.4643L5.69993 10.4686C5.63609 10.4686 5.58386 10.4179 5.58386 10.3526C5.58386 10.325 5.59402 10.2989 5.61143 10.2771L7.49904 8.02824L5.61143 5.7808C5.59402 5.75904 5.58386 5.73292 5.58386 5.70536C5.58386 5.64152 5.63609 5.58929 5.69993 5.58929L6.65897 5.59364L8.09971 7.31295L9.54045 5.59509L10.498 5.59074C10.5619 5.59074 10.6141 5.64152 10.6141 5.70681C10.6141 5.73438 10.604 5.76049 10.5865 5.78225L8.70183 8.02969L10.588 10.2786C10.6054 10.3003 10.6156 10.3265 10.6156 10.354C10.6156 10.4179 10.5633 10.4701 10.4995 10.4701Z",fillRule:"evenodd",clipRule:"evenodd"}}]},_s=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"error-single",ref:t,icon:Bu}))});_s.displayName="ErrorSingle";const Ss=_s;var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.6905 4.78738C2.01709 4.61737 2.41966 4.7443 2.58967 5.07089C2.75217 5.38305 3.00913 5.69251 3.36183 5.98156C4.36103 6.80048 6.03866 7.37872 7.99833 7.37872C9.958 7.37872 11.6356 6.80049 12.6348 5.98157C12.9875 5.69251 13.2445 5.38304 13.407 5.0709C13.577 4.7443 13.9796 4.61737 14.3062 4.78737C14.6327 4.95738 14.7597 5.35995 14.5897 5.68654C14.329 6.18726 13.9448 6.63187 13.48 7.01281C13.4365 7.04842 13.3923 7.08356 13.3473 7.11821L14.8065 8.57746C15.0669 8.83781 15.0669 9.25992 14.8065 9.52027C14.5462 9.78062 14.124 9.78062 13.8637 9.52027L12.1741 7.83063C11.6495 8.08125 11.0697 8.28368 10.451 8.43104L10.9916 10.4486C11.0869 10.8042 10.8759 11.1698 10.5202 11.2651C10.1646 11.3604 9.79902 11.1493 9.70373 10.7937L9.13044 8.6541C8.7607 8.69234 8.38239 8.71205 7.99833 8.71205C7.61155 8.71205 7.2306 8.69206 6.85837 8.65329L6.28486 10.7937C6.18957 11.1494 5.82401 11.3604 5.46837 11.2651C5.11272 11.1698 4.90167 10.8043 4.99696 10.4486L5.53804 8.42923C4.92309 8.28224 4.34666 8.0808 3.82483 7.8317L2.13636 9.52018C1.87602 9.78053 1.45391 9.78053 1.19355 9.52018C0.933204 9.25983 0.933203 8.83772 1.19355 8.57737L2.65127 7.11965C2.60559 7.08453 2.56072 7.04892 2.51667 7.01281C2.05184 6.63186 1.66764 6.18725 1.40699 5.68655C1.23698 5.35996 1.36391 4.95739 1.6905 4.78738Z"}}]},ps=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"eyelash-single",ref:t,icon:ku}))});ps.displayName="EyelashSingle";const Fu=ps;var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.48334 4.89587C5.35517 4.89587 5.26008 4.777 5.28822 4.65196L5.37367 4.27223C5.47369 3.84311 5.65731 3.4768 5.93107 3.18085 6.23007 2.85761 6.67323 2.71538 7.21663 2.71538 7.41772 2.71538 7.63284 2.73908 7.86113 2.78378 7.88014 2.7875 7.89899 2.79139 7.91771 2.79543 8.12915 2.84113 8.35624 2.74611 8.43956 2.54647L8.66692 2.00173C8.75382 1.79351 8.65103 1.55537 8.43507 1.49007 8.40283 1.48032 8.36953 1.47045 8.33516 1.46047 8.0467 1.37763 7.70317 1.3335 7.29999 1.3335 6.2394 1.3335 5.44639 1.60069 4.89385 2.10573 4.32912 2.62202 3.92814 3.3605 3.70338 4.33753L2.25629 10.5523C2.18051 10.8899 2.08525 11.253 1.96769 11.6425 1.849 12.0347 1.70655 12.4208 1.54146 12.7986 1.37502 13.1773 1.18738 13.5375.978805 13.8784.912697 13.9865.8444 14.0896.773916 14.1876.684332 14.3122.753952 14.4944.905805 14.5167 1.5556 14.6123 2.23715 14.4376 2.60122 13.8909 2.74587 13.6737 2.88704 13.426 3.02434 13.1464 3.3856 12.411 3.72447 11.3716 4.03792 10.0188L4.88825 6.37667C4.90938 6.28616 4.99007 6.22214 5.08301 6.22214H7.04403C7.22895 6.22214 7.38976 6.09538 7.43296 5.91557L7.55939 5.3893C7.61982 5.13775 7.42917 4.89587 7.17046 4.89587H5.48334zM13.7403 5.0817L11.9317 7.33096 10.8281 5.13886C10.7615 4.99145 10.6146 4.89673 10.4529 4.89673H9.73214C9.4277 4.89673 9.22847 5.21561 9.36195 5.48923L10.8281 8.41635 8.21708 11.5106C7.98512 11.7771 8.17444 12.1929 8.5278 12.1929H9.10532C9.22597 12.1929 9.37975 12.1436 9.45801 12.0518L11.53 9.62616 12.5369 11.9223C12.5978 12.0844 12.7522 12.1929 12.9254 12.1929H13.7193C14.0023 12.1929 14.161 11.9788 14.0619 11.7137L12.592 8.64761C12.592 8.64761 14.8202 5.81675 15.0205 5.54025 15.2159 5.27062 15.0215 4.89673 14.6886 4.89673H14.0854C13.9467 4.89673 13.8525 4.9502 13.7403 5.0817z"}}]}]},Cs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"fx-single",ref:t,icon:Wu}))});Cs.displayName="FxSingle";const ju=Cs;var $u={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.74717 2.0944C8.74717 1.68671 8.41279 1.3562 8.00032 1.3562C7.58785 1.3562 7.25347 1.68671 7.25347 2.0944V7.26186H2.02541C1.61294 7.26186 1.27856 7.59237 1.27856 8.00007C1.27856 8.40777 1.61294 8.73827 2.02541 8.73827H7.25347V13.9057C7.25347 14.3134 7.58785 14.6439 8.00032 14.6439C8.41279 14.6439 8.74717 14.3134 8.74717 13.9057V8.73827H13.975C14.3874 8.73827 14.7218 8.40777 14.7218 8.00007C14.7218 7.59237 14.3874 7.26186 13.975 7.26186H8.74717V2.0944Z"}}]}]},vs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"increase-single",ref:t,icon:$u}))});vs.displayName="IncreaseSingle";const Is=vs;var zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M0.629584 3.99986C1.13729 3.4922 1.9604 3.49224 2.46806 3.99995L7.57569 9.10806C7.81 9.3424 8.18992 9.3424 8.42424 9.10808L13.5323 3.99998C14.04 3.4923 14.8631 3.4923 15.3708 3.99998C15.8785 4.50766 15.8785 5.33078 15.3708 5.83846L9.41415 11.7951C8.63307 12.5762 7.36669 12.5762 6.58565 11.7951L0.629497 5.83834C0.121839 5.33063 0.121879 4.50752 0.629584 3.99986Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},Rs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"more-down-single",ref:t,icon:zu}))});Rs.displayName="MoreDownSingle";const $n=Rs;var Yu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.45493 2.80093C5.74783 2.49409 6.2227 2.49409 6.5156 2.80093L11.0156 7.51523C11.3085 7.82207 11.3085 8.31956 11.0156 8.6264L6.44488 13.27C6.15199 13.5768 5.67711 13.5768 5.38422 13.27C5.09133 12.9631 5.09133 12.4656 5.38422 12.1588L9.28804 8.20898C9.36409 8.13203 9.36517 8.00855 9.29047 7.93029L5.45493 3.9121C5.16204 3.60526 5.16204 3.10777 5.45493 2.80093Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ms=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"more-single",ref:t,icon:Yu}))});Ms.displayName="MoreSingle";const tr=Ms;var Xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.69,y:12.25,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z"}}]}]},bs=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"paint-bucket",ref:t,icon:Xu}))});bs.displayName="PaintBucket";const Gu=bs;var Zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.40051 8.00049C1.40051 4.41098 4.311 1.50049 7.90051 1.50049C11.49 1.50049 14.4005 4.41098 14.4005 8.00049C14.4005 11.59 11.49 14.5005 7.90051 14.5005C4.311 14.5005 1.40051 11.59 1.40051 8.00049ZM7.31368 5.3379L7.56087 9.33424H8.24066L8.49816 5.3379L8.51876 4.12252H7.28278L7.31368 5.3379ZM7.07678 11.0646C7.07678 11.5693 7.44758 11.8783 7.90077 11.8783C8.35396 11.8783 8.72476 11.5693 8.72476 11.0646C8.72476 10.5805 8.35396 10.2612 7.90077 10.2612C7.44758 10.2612 7.07678 10.5805 7.07678 11.0646Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ts=U.forwardRef(function(o,t){return U.createElement(Se,Object.assign({},o,{id:"warning-single",ref:t,icon:Zu}))});Ts.displayName="WarningSingle";const nr=Ts,Ku=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),C.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),C.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),C.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),C.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),C.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),C.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),C.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),C.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),C.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),C.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),C.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),C.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),C.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),C.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),C.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),C.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),C.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),C.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),C.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),C.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),C.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),C.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),C.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),C.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),C.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),qu=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),C.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),C.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),C.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),C.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),C.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),C.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),C.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),C.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),C.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),C.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),C.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),C.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),C.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),C.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),C.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),C.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),C.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),C.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),C.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),C.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),C.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),C.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),C.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),Qu=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),C.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),C.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),C.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),C.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),C.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),C.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),C.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),C.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),C.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),C.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),C.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),C.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),C.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),C.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),C.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),C.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),C.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),C.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),C.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Ju=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),C.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),C.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),C.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),C.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),C.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),C.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),C.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),C.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),C.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),C.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),C.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),C.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),C.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),C.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),C.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),C.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),C.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),C.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),C.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),C.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),C.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),C.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),C.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),C.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),C.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),C.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),C.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),C.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),C.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),C.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),C.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),C.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),C.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),C.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),C.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),C.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),C.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),C.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),C.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),C.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),C.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),C.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),C.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),C.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),eh=()=>C.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),th=()=>C.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),C.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),C.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),C.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),C.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),C.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),C.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),C.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),C.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),C.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),C.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),C.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),C.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),C.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),C.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),C.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),C.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),C.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),nh=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),C.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),C.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),C.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),C.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),C.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),C.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),C.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),oh=()=>C.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),C.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),C.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),C.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),C.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),C.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),C.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),C.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),C.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),C.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),C.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),C.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),C.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),C.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),C.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),C.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),C.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),C.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),C.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),C.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),ih=()=>C.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),or=()=>C.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function ir(o){const{type:t=l.BorderStyleTypes.THIN}=o;switch(t){case l.BorderStyleTypes.DASH_DOT:return C.jsx(Ku,{});case l.BorderStyleTypes.DASH_DOT_DOT:return C.jsx(qu,{});case l.BorderStyleTypes.DASHED:return C.jsx(Qu,{});case l.BorderStyleTypes.HAIR:return C.jsx(Ju,{});case l.BorderStyleTypes.MEDIUM:return C.jsx(eh,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return C.jsx(th,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return C.jsx(nh,{});case l.BorderStyleTypes.MEDIUM_DASHED:return C.jsx(oh,{});case l.BorderStyleTypes.THICK:return C.jsx(ih,{});case l.BorderStyleTypes.THIN:return C.jsx(or,{});default:return C.jsx(or,{})}}const rh="univer-ui-plugin-sheets-border-panel",sh="univer-ui-plugin-sheets-border-panel-position",ah="univer-ui-plugin-sheets-border-panel-position-item",lh="univer-ui-plugin-sheets-border-panel-position-item-active",ch="univer-ui-plugin-sheets-border-panel-styles",dh="univer-ui-plugin-sheets-border-panel-board",uh="univer-ui-plugin-sheets-border-panel-button",hh="univer-ui-plugin-sheets-border-panel-more-icon",ye={uiPluginSheetsBorderPanel:rh,uiPluginSheetsBorderPanelPosition:sh,uiPluginSheetsBorderPanelPositionItem:ah,uiPluginSheetsBorderPanelPositionItemActive:lh,uiPluginSheetsBorderPanelStyles:ch,uiPluginSheetsBorderPanelBoard:dh,uiPluginSheetsBorderPanelButton:uh,uiPluginSheetsBorderPanelMoreIcon:hh},ws=`${Nt}_BORDER_PANEL_COMPONENT`,Es=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],mh=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function gh(o){var c;const t=G.useDependency(v.ComponentManager),e=G.useDependency(_.BorderStyleManagerService),{onChange:n,value:i}=o;function r(d,u){n==null||n({...i,[u]:d})}function s(d){const u=t.get(d);return u&&C.jsx(u,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function a(d){d.stopPropagation()}return C.jsxs("section",{className:ye.uiPluginSheetsBorderPanel,children:[C.jsx("div",{className:ye.uiPluginSheetsBorderPanelPosition,children:Es.map(d=>C.jsx("div",{className:e.getBorderInfo().type===d.value?`${ye.uiPluginSheetsBorderPanelPositionItemActive} ${ye.uiPluginSheetsBorderPanelPositionItem}`:ye.uiPluginSheetsBorderPanelPositionItem,onClick:u=>{u.stopPropagation(),r(d.value,"type")},children:s(d.icon)},d.value))}),C.jsxs("div",{className:ye.uiPluginSheetsBorderPanelStyles,children:[C.jsx("div",{children:C.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:C.jsx("section",{className:ye.uiPluginSheetsBorderPanelBoard,onClick:a,children:C.jsx(re.ColorPicker,{onChange:d=>r(d,"color")})}),children:C.jsxs("a",{className:ye.uiPluginSheetsBorderPanelButton,onClick:a,children:[C.jsx(Gu,{extend:{colorChannel1:(c=i.color)!=null?c:"rgb(var(--primary-color))"}}),C.jsx("span",{className:ye.uiPluginSheetsBorderPanelMoreIcon,children:C.jsx($n,{})})]})})}),C.jsx("div",{children:C.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:C.jsx("section",{onClick:a,children:C.jsx(re.Menu,{children:mh.map(d=>C.jsx(re.MenuItem,{eventKey:d.value.toString(),onClick:()=>r(d.value,"style"),children:C.jsx(ir,{type:d.value})},d.value))})}),children:C.jsxs("a",{className:ye.uiPluginSheetsBorderPanelButton,onClick:a,children:[C.jsx(ir,{type:l.BorderStyleTypes.THIN}),C.jsx("span",{className:ye.uiPluginSheetsBorderPanelMoreIcon,children:C.jsx($n,{})})]})})})]})]})}const fh="univer-count-bar",_h={countBar:fh},Sh=[50,80,100,130,150,170,200,400];function ph(){const o=G.useDependency(l.ICommandService),t=G.useDependency(l.IUniverInstanceService),e=U.useCallback(()=>{const s=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,i]=U.useState(()=>e());U.useEffect(()=>o.onCommandExecuted(a=>{if(a.id===ke.id||a.id===_.SetWorksheetActiveOperation.id){const c=e();i(c)}}).dispose,[o,e]);function r(s){i(s);const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),c=a==null?void 0:a.getActiveSheet();if(c==null)return;const d=s/100;o.executeCommand(Kn.id,{unitId:a.getUnitId(),subUnitId:c.getSheetId(),zoomRatio:d})}return C.jsx(re.Slider,{min:To[0],value:n,shortcuts:Sh,onChange:r})}function Ch(o){return C.jsx("section",{className:_h.countBar,children:C.jsx(ph,{})})}const vh="univer-editor-container",Ih="univer-editor-input",rr={editorContainer:vh,editorInput:Ih},zn=-1e3,sr={width:0,height:0,top:zn,left:zn},Rh=()=>{const[o,t]=U.useState({...sr}),e=G.useDependency(rn),n=G.useDependency(v.IEditorService),i=G.useDependency(l.IContextService),r=v.useObservable(()=>i.subscribeContextValue$(v.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[i,v.DISABLE_AUTO_FOCUS_KEY]),s={id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return U.useEffect(()=>{e.state$.subscribe(a=>{if(a==null)return;const{startX:c=zn,startY:d=zn,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)t({...sr});else{t({width:u-c-y.FIX_ONE_PIXEL_BLUR_OFFSET+2,height:h-d-y.FIX_ONE_PIXEL_BLUR_OFFSET+2,left:c+y.FIX_ONE_PIXEL_BLUR_OFFSET,top:d+y.FIX_ONE_PIXEL_BLUR_OFFSET});const g=n.getEditor(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(g==null)return;const{left:f,top:S,width:p,height:I}=g.getBoundingClientRect();e.setRect({left:f,top:S,width:p,height:I})}})},[]),U.useEffect(()=>{r||e.setFocus(!0)},[r,o]),C.jsx("div",{className:rr.editorContainer,style:{left:o.left,top:o.top,width:o.width,height:o.height},children:C.jsx(v.TextEditor,{id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:rr.editorInput,snapshot:s,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},Mh="univer-defined-name",bh="univer-defined-name-drop-down",Th="univer-defined-name-overlay",wh="univer-defined-name-overlay-container",Eh="univer-defined-name-overlay-item",yh="univer-defined-name-overlay-item-name",Oh="univer-defined-name-overlay-item-name-for-sheet",xh="univer-defined-name-overlay-item-formula",Nh="univer-defined-name-overlay-manager",Ah="univer-defined-name-overlay-manager-title",Dh="univer-defined-name-overlay-manager-content",Ph="univer-defined-name-container",Hh="univer-defined-name-container-scroll",Lh="univer-defined-name-container-addButton",Uh="univer-defined-name-container-addButton-text",Vh="univer-defined-name-container-item",Bh="univer-defined-name-container-item-name",kh="univer-defined-name-container-item-name-for-sheet",Fh="univer-defined-name-container-item-formula-or-refString",Wh="univer-defined-name-container-item-update",jh="univer-defined-name-container-item-delete",$h="univer-defined-name-container-item-show",zh="univer-defined-name-input",Yh="univer-defined-name-input-validation",ae={definedName:Mh,definedNameDropDown:bh,definedNameOverlay:Th,definedNameOverlayContainer:wh,definedNameOverlayItem:Eh,definedNameOverlayItemName:yh,definedNameOverlayItemNameForSheet:Oh,definedNameOverlayItemFormula:xh,definedNameOverlayManager:Nh,definedNameOverlayManagerTitle:Ah,definedNameOverlayManagerContent:Dh,definedNameContainer:Ph,definedNameContainerScroll:Hh,definedNameContainerAddButton:Lh,definedNameContainerAddButtonText:Uh,definedNameContainerItem:Vh,definedNameContainerItemName:Bh,definedNameContainerItemNameForSheet:kh,definedNameContainerItemFormulaOrRefString:Fh,definedNameContainerItemUpdate:Wh,definedNameContainerItemDelete:jh,definedNameContainerItemShow:$h,definedNameInput:zh,definedNameInputValidation:Yh},ys="DefinedNameContainer",jo="AllDefaultWorkbook",Os={id:"sidebar.operation.defined-name",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(v.ISidebarService),n=o.get(v.IEditorService),i=o.get(l.LocaleService),r=o.get(l.IUniverInstanceService),s=_.getSheetCommandTarget(r);if(!s)return!1;const{unitId:a}=s;switch(t.value){case"open":n.setOperationSheetUnitId(a),e.open({header:{title:i.t("definedName.featureTitle")},children:{label:ys},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function Xh(o){const t=G.useDependency(l.ICommandService),e=G.useDependency(l.LocaleService),n=G.useDependency(Z.IDefinedNamesService),s=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[c,d]=U.useState(a());U.useEffect(()=>{const m=n.update$.subscribe(()=>{d(a())});return()=>{m.unsubscribe()}},[]);const u=()=>{t.executeCommand(Os.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return C.jsxs("div",{className:ae.definedNameOverlay,children:[C.jsx("div",{className:ae.definedNameOverlayContainer,children:c.map((m,g)=>C.jsxs("div",{className:ae.definedNameOverlayItem,onClick:()=>{h(m)},children:[C.jsx("div",{className:ae.definedNameOverlayItemName,title:m.name,children:m.name}),C.jsx("div",{className:ae.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},g))}),C.jsxs("div",{className:ae.definedNameOverlayManager,onClick:u,children:[C.jsx("div",{className:ae.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),C.jsx("div",{className:ae.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function Gh(){const[o,t]=U.useState(""),e=G.useDependency(Z.IDefinedNamesService);return U.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),C.jsxs("div",{className:ae.definedName,children:[C.jsx(re.Input,{value:o,type:"text",size:"small",affixWrapperStyle:{border:"none",paddingLeft:"6px",paddingRight:"6px",height:"100%"}}),C.jsx(re.Dropdown,{overlay:C.jsx(Xh,{}),children:C.jsx("div",{className:ae.definedNameDropDown,children:C.jsx($n,{})})})]})}const Zh="univer-formula-box",Kh="univer-name-ranges",qh="univer-formula-bar",Qh="univer-formula-icon",Jh="univer-formula-icon-wrapper",em="univer-icon-container",tm="univer-icon-container-success",nm="univer-formula-active",om="univer-icon-container-error",im="univer-icon-container-fx",rm="univer-formula-input",sm="univer-formula-content",am="univer-arrow-container",me={formulaBox:Zh,nameRanges:Kh,formulaBar:qh,formulaIcon:Qh,formulaIconWrapper:Jh,iconContainer:em,iconContainerSuccess:tm,formulaActive:nm,iconContainerError:om,iconContainerFx:im,formulaInput:rm,formulaContent:sm,arrowContainer:am};function lm(){const[o,t]=U.useState(me.formulaGrey),[e,n]=U.useState(0),i=G.useDependency(eo),r=G.useDependency(Ee),s={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.TOP,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};U.useEffect(()=>{const m=r.visible$.subscribe(g=>{t(g.visible?me.formulaActive:me.formulaGrey)});return()=>m.unsubscribe()},[r.visible$]);function a(m){if(m==null)return;const g=m.getBoundingClientRect();i.setPosition(g)}function c(){n(e===0?1:0),setTimeout(()=>{i.handleFoldBtnClick(e===1)},150)}function d(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:y.DeviceInputEventType.Keyboard,keycode:v.KeyCode.ESC})}function u(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:y.DeviceInputEventType.PointerDown})}function h(){i.handleFxBtnClick(!0)}return C.jsxs("div",{className:me.formulaBox,style:{height:e===0?"28px":"82px"},children:[C.jsx("div",{className:me.nameRanges,children:C.jsx(Gh,{})}),C.jsxs("div",{className:me.formulaBar,children:[C.jsx("div",{className:me.formulaIcon,children:C.jsxs("div",{className:me.formulaIconWrapper,children:[C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerError,o),onClick:d,children:C.jsx(Du,{})}),C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerSuccess,o),onClick:u,children:C.jsx(Qt,{})}),C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerFx),onClick:h,children:C.jsx(ju,{})})]})}),C.jsxs("div",{className:me.formulaInput,children:[C.jsx(v.TextEditor,{id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:a,cancelDefaultResizeListener:!0,onContextMenu:m=>m.preventDefault(),className:me.formulaContent,snapshot:s,isSingle:!1}),C.jsx("div",{className:me.arrowContainer,onClick:c,children:e===0?C.jsx(er,{}):C.jsx(er,{style:{transform:"rotateZ(180deg)"}})})]})]}),C.jsx(v.ProgressBar,{})]})}const cm="univer-operate-container",dm="univer-auto-fill-popup-menu",um="univer-auto-fill-popup-menu-item",hm="univer-auto-fill-popup-menu-item-icon",mm="univer-auto-fill-popup-menu-item-title",gm="univer-auto-fill-popup-menu-item-hide",fm="univer-btn-container",_m="univer-btn-container-expand",ct={operateContainer:cm,autoFillPopupMenu:dm,autoFillPopupMenuItem:um,autoFillPopupMenuItemIcon:hm,autoFillPopupMenuItemTitle:mm,autoFillPopupMenuItemHide:gm,btnContainer:fm,btnContainerExpand:_m},Sm=()=>{const[,o]=U.useState({});return U.useCallback(()=>o(t=>!t),[])},pm=()=>{var Q;const o=G.useDependency(l.ICommandService),t=G.useDependency(exports.SheetSkeletonManagerService),e=G.useDependency(l.IUniverInstanceService),n=G.useDependency(y.IRenderManagerService),i=G.useDependency(Ne),r=G.useDependency(yt),s=G.useDependency(l.LocaleService),[a,c]=U.useState([]),[d,u]=U.useState(!1),[h,m]=U.useState({row:-1,col:-1}),[g,f]=U.useState(oe.SERIES),[S,p]=U.useState(!1),I=()=>{p(!0)},M=()=>{p(!1)},b=Sm();if(U.useEffect(()=>o.onCommandExecuted((H,F)=>{H.id===nt.id&&b()}).dispose,[b,o]),U.useEffect(()=>l.toDisposable(t.currentSkeleton$.subscribe(H=>{H&&b()})).dispose,[t,b]),U.useEffect(()=>l.toDisposable(r.menu$.subscribe(H=>{c(H.map(F=>({...F,index:H.indexOf(F)})))})).dispose,[r]),U.useEffect(()=>l.toDisposable(r.showMenu$.subscribe(H=>{const{source:F,target:Y}=r.autoFillLocation||{source:null,target:null};if(H&&F&&Y){const X=Math.max(F.rows[F.rows.length-1],Y.rows[Y.rows.length-1]),J=Math.max(F.cols[F.cols.length-1],Y.cols[Y.cols.length-1]);m({row:X,col:J})}else m({row:-1,col:-1})})).dispose,[r]),U.useEffect(()=>l.toDisposable(r.applyType$.subscribe(H=>{f(H)})).dispose,[r]),U.useEffect(()=>{function D(){u(!1)}return document.addEventListener("wheel",D),()=>{document.removeEventListener("wheel",D)}},[d]),h.col<0||h.row<0)return null;const T=it(e,n);if(!T)return null;const{scene:w}=T,E=(Q=t.getCurrent())==null?void 0:Q.skeleton,O=i.getViewPort(),x=w==null?void 0:w.scaleX,A=w==null?void 0:w.scaleY,k=w==null?void 0:w.getScrollXY(O);if(!x||!w||!x||!A||!k)return null;const N=(E==null?void 0:E.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,L=(E==null?void 0:E.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,V=E==null?void 0:E.convertTransformToOffsetX(N,x,k),j=E==null?void 0:E.convertTransformToOffsetY(L,A,k);if(V==null||j==null)return null;const z=D=>{u(D)},q=D=>{o.executeCommand(ns.id,{type:D.value})},K=d||S,$=a.filter(D=>!D.disable);return C.jsx("div",{onMouseEnter:I,onMouseLeave:M,style:{left:`${V+2}px`,top:`${j+2}px`,position:"absolute"},children:C.jsx(re.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:C.jsx("ul",{className:ct.autoFillPopupMenu,children:$.map(D=>C.jsxs("li",{onClick:()=>q(D),className:ct.autoFillPopupMenuItem,children:[C.jsx("span",{className:ct.autoFillPopupMenuItemIcon,children:D.value===g&&C.jsx(Qt,{style:{color:"rgb(var(--green-700, #409f11))"}})}),C.jsx("span",{className:ct.autoFillPopupMenuItemTitle,children:s.t(D.label)})]},D.index))}),visible:d,onVisibleChange:z,children:C.jsxs("div",{className:Oe(ct.btnContainer,{[ct.btnContainerExpand]:d}),children:[C.jsx(xu,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),K&&C.jsx($n,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Cm=()=>C.jsx("div",{className:ct.operateContainer,children:C.jsx(pm,{})}),vm="univer-sheet-bar",Im="univer-sheet-bar-options",Rm="univer-sheet-bar-options-divider",gn={sheetBar:vm,sheetBarOptions:Im,sheetBarOptionsDivider:Rm},Mm="univer-sheet-bar-btn",bm={sheetBarBtn:Mm};function On(o){const{children:t,className:e,style:n,disabled:i=!1,onClick:r,...s}=o,a=c=>{if(i){c.preventDefault();return}r&&r(c)};return C.jsx("button",{className:bm.sheetBarBtn,style:n,disabled:i,onClick:a,...s,children:t})}const Tm="univer-sheet-bar-menu",wm="univer-sheet-bar-menu-item",Em="univer-sheet-bar-menu-item-icon",ym="univer-sheet-bar-menu-item-hide",Om="univer-sheet-bar-menu-item-select",xm="univer-sheet-bar-menu-item-label",qe={sheetBarMenu:Tm,sheetBarMenuItem:wm,sheetBarMenuItemIcon:Em,sheetBarMenuItemHide:ym,sheetBarMenuItemSelect:Om,sheetBarMenuItemLabel:xm};function Nm(o){const{style:t}=o,[e,n]=U.useState([]),[i,r]=U.useState(!1),s=G.useDependency(l.IUniverInstanceService),a=G.useDependency(l.ICommandService),c=G.useDependency(Pt),d=v.useObservable(()=>s.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[]),u=S=>{const{sheetId:p}=S;!p||!d||(S.hidden?a.executeCommand(_.SetWorksheetShowCommand.id,{unitId:d.getUnitId(),subUnitId:p,value:p}):S.selected||a.executeCommand(_.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:p}),r(!1))},h=U.useCallback(()=>{if(!d)return;const S=d.getSheets(),p=d.getActiveSheet(),I=S.map((M,b)=>({label:M.getName(),index:`${b}`,sheetId:M.getSheetId(),hidden:M.isSheetHidden()===l.BooleanNumber.TRUE,selected:p===M}));n(I)},[d]),m=U.useCallback(()=>a.onCommandExecuted(S=>{switch(S.id){case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:h();break}}),[a,h]);function g(){r(!0)}const f=S=>{r(S)};return U.useEffect(()=>{h();const S=new l.DisposableCollection;return S.add(m()),S.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>S.dispose()},[m,c,h,d]),C.jsx(re.Dropdown,{placement:"topLeft",trigger:["click"],overlay:C.jsx("ul",{className:qe.sheetBarMenu,style:{...t},children:e.map(S=>C.jsxs("li",{onClick:()=>u(S),className:S.selected?`${qe.sheetBarMenuItem} ${qe.sheetBarMenuItemSelect}`:S.hidden?`${qe.sheetBarMenuItem} ${qe.sheetBarMenuItemHide}`:qe.sheetBarMenuItem,children:[C.jsx("span",{className:qe.sheetBarMenuItemIcon,children:S.selected?C.jsx(Qt,{}):S.hidden?C.jsx(Fu,{}):C.jsx(Qt,{})}),C.jsx("span",{className:qe.sheetBarMenuItemLabel,children:S.label})]},S.index))}),visible:i,onVisibleChange:f,children:C.jsx(On,{children:C.jsx(Hu,{})})})}const Am="univer-slide-tab-bar-container",Dm="univer-slide-tab-bar",Pm="univer-slide-tab-item",Hm="univer-slide-tab-active",Lm="univer-slide-tab-span",Um="univer-slide-tab-span-edit",Vm="univer-slide-tab-item-dropdown",Re={slideTabBarContainer:Am,slideTabBar:Dm,slideTabItem:Pm,slideTabActive:Hm,slideTabSpan:Lm,slideTabSpanEdit:Um,slideTabItemDropdown:Vm};function Bm(o){const{sheetId:t,label:e,color:n,selected:i}=o,[r,s]=U.useState(i),a=G.useDependency(l.ThemeService);U.useEffect(()=>{s(i)},[i]);const c=d=>{const u=a.getCurrentTheme(),h=u.textColor,m=u.colorWhite;return new l.ColorKit(d).isDark()?m:h};return C.jsx("div",{"data-id":t,className:r?`${Re.slideTabActive} ${Re.slideTabItem}`:Re.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?c(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:C.jsx("span",{className:Re.slideTabSpan,children:e})},t)}const km={easeOutStrong(o,t,e,n){return-e*((o=o/n-1)*o*o*o-1)+t},backOut(o,t,e,n,i){return typeof i>"u"&&(i=.7),e*((o=o/n-1)*o*((i+1)*o+i)+1)+t}},Fm={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(o){},success(o){},cancel(o){},complete(o){}};class Wm{constructor(t){R(this,"_config");R(this,"_status",0);R(this,"_start",0);R(this,"_handle",0);R(this,"_delayHandle",null);this._config={...Fm,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let i=0;i<t.length;i++){const r=t[i],s=r._config,a=s.success;s.loop||(s.success=d=>{e++,a&&a.call(r,d),e===t.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=km[this._config.type](t,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class ut{constructor(t,e){R(this,"_slideTabItem");R(this,"_animate");R(this,"_midline",0);R(this,"_translateX");R(this,"_scrollbar");R(this,"_slideTabBar");R(this,"_editMode");R(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(i=>n.push(new ut(i,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&Mt.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),i=d=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",i),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}t&&t(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{e=!1},a=d=>{e=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),Mt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",i),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Mt.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new Wm({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=ut.midline(this)}disableFixed(){if(this._placeholder){const t=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),i=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,i){const r=getComputedStyle(i).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=ut.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class jm{constructor(t){R(this,"_slideTabBar");R(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const It=class It{constructor(t){R(this,"_activeTabItemIndex",0);R(this,"_slideTabBar");R(this,"_slideTabItems",[]);R(this,"_config");R(this,"_downActionX",0);R(this,"_moveActionX",0);R(this,"_compareIndex",0);R(this,"_activeTabItem",null);R(this,"_moveAction");R(this,"_upAction");R(this,"_downAction");R(this,"_wheelAction");R(this,"_scrollIncremental",0);R(this,"_compareDirection",0);R(this,"_autoScrollTime",null);R(this,"_slideScrollbar");R(this,"_longPressTimer",null);R(this,"_leftBoundingLine",0);R(this,"_rightBoundingLine",0);R(this,"_leftMoveX",0);R(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new jm(this),this._config=t,this._initConfig();let n=0,i=0,r=0;this._downAction=a=>{var E,O,x,A,k,N;if((E=this._activeTabItem)!=null&&E.isEditMode())return;const c=(x=(O=a.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),d=this._slideTabItems.findIndex(L=>L.getId()===c);if(c==null||d===-1)return;if(this._activeTabItemIndex!==d){(A=this._activeTabItem)==null||A.removeEventListener("pointermove",this._moveAction),(k=this._activeTabItem)==null||k.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(a,c);return}if(this._compareIndex=d,this._downActionX=a.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[d],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const u=this._activeTabItem.getSlideTabItem();u==null||u.setPointerCapture(a.pointerId),(N=this._activeTabItem)==null||N.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:g,width:f}=this.getBoundingRect(),S=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-S),this._rightBoundingLine=h-S+m-this._downActionX,this._leftMoveX=h-g-S,this._rightMoveX=g+f-(h+m)+S,a.button===2||this._hasEditItem())return;const{pageX:p,pageY:I}=a,M=Date.now(),b=M-r<=It.DoubleClickDelay,T=Math.abs(p-n)<10,w=Math.abs(I-i)<10;b&&T&&w&&this._activeTabItem.setEditor(),n=p,i=I,r=M,this._longPressTimer=setTimeout(()=>{var L,V;(L=this._activeTabItem)==null||L.enableFixed(),this._startAutoScroll(),u&&(u.setPointerCapture(a.pointerId),u.style.cursor="move",(V=this._activeTabItem)==null||V.addEventListener("pointermove",this._moveAction))},It.LongPressDelay)},this._upAction=a=>{var d,u,h;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const c=(d=this._activeTabItem)==null?void 0:d.getSlideTabItem();c&&(c.style.cursor="",c.releasePointerCapture(a.pointerId),(u=this._activeTabItem)==null||u.removeEventListener("pointermove",this._moveAction),(h=this._activeTabItem)==null||h.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(a,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=a=>{this._activeTabItem&&(this._moveActionX=a.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(a),this._scrollRight(a))},this._wheelAction=a=>{this.setScroll(a.deltaY)},this.addListener()}static checkedSkipSlide(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(e=t?c-r.left-n:c+d-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(e=t?c+d-r.left-r.width+n:c-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];ut.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=0;r<n.length;r++){const s=n[r];ut.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=ut.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};R(It,"LongPressDelay",500),R(It,"DoubleClickDelay",300);let Mt=It;function $m(){const[o,t]=U.useState([]),[e,n]=U.useState(""),[i,r]=U.useState(""),[s,a]=U.useState(!1),[c,d]=U.useState([0,0]),u=U.useRef({slideTabBar:null}),h=U.useRef(null),m=G.useDependency(l.IUniverInstanceService),g=G.useDependency(l.ICommandService),f=G.useDependency(Pt),S=G.useDependency(l.LocaleService),p=G.useDependency(v.IConfirmService),I=G.useDependency(Ne),M=G.useDependency(Ee);G.useInjector();const b=m.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);U.useEffect(()=>{N();const D=T(),H=k(),F=[L(),V(),j(),z()];return()=>{H.dispose(),D.destroy(),F.forEach(Y=>Y.unsubscribe())}},[]),U.useEffect(()=>{o.length>0&&A()},[o]);const T=()=>{const D=new Mt({slideTabBarClassName:Re.slideTabBar,slideTabBarItemActiveClassName:Re.slideTabActive,slideTabBarItemClassName:Re.slideTabItem,slideTabBarSpanEditClassName:Re.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(H,F)=>{g.executeCommand(_.SetWorksheetNameCommand.id,{subUnitId:H,name:F})},onSlideEnd:(H,F)=>{g.executeCommand(_.SetWorksheetOrderCommand.id,{order:F})},onChangeTab:(H,F)=>{g.executeCommand(_.SetWorksheetActiveOperation.id,{subUnitId:F,unitId:b.getUnitId()}).then(()=>{H.button===2&&Q(!0)})},onScroll:H=>{f.setScroll(H)},onNameCheckAlert:H=>w(H)||E(H)});return u.current.slideTabBar=D,$(D),D},w=D=>{if(D.trim()===""){const H="sheetNameEmptyAlert";return p.open({id:H,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){O(),p.close(H)},onConfirm(){O(),p.close(H)}}),!0}return!1},E=D=>{const H=m.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(H.getActiveSheet().getName()===D)return!1;const X=H.checkSheetName(D);if(X){const J="sheetNameRepeatAlert";p.open({id:J,title:{title:S.t("sheetConfig.sheetNameErrorTitle")},children:{title:S.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:S.t("button.cancel"),confirmText:S.t("button.confirm"),onClose(){p.close(J),O()},onConfirm(){p.close(J),O()}})}return X},O=()=>{I.endSelection(),setTimeout(()=>{var H;const D=(H=u.current.slideTabBar)==null?void 0:H.getActiveItem();D&&(D.focus(),D.selectAll())},0)},x=()=>{var D,H;(H=(D=u.current.slideTabBar)==null?void 0:D.getActiveItem())==null||H.setEditor()},A=()=>{var H;const D=o.findIndex(F=>F.selected);(H=u.current.slideTabBar)==null||H.update(D)},k=()=>g.onCommandExecuted(D=>{switch(D.id){case _.SetTabColorMutation.id:case _.SetWorksheetHideMutation.id:case _.RemoveSheetMutation.id:case _.SetWorksheetNameMutation.id:case _.InsertSheetMutation.id:case _.SetWorksheetOrderMutation.id:case _.SetWorksheetActiveOperation.id:N();break}}),N=()=>{const D=b.getActiveSheet().getSheetId();n(D);const H=b.getSheets(),F=b.getActiveSheet(),Y=H.filter(X=>!X.isSheetHidden()).map((X,J)=>{var ee;return{sheetId:X.getSheetId(),label:X.getName(),index:J,selected:F===X,color:(ee=X.getTabColor())!=null?ee:void 0}});t(Y)},L=()=>f.scroll$.subscribe(D=>{q(D)}),V=()=>f.scrollX$.subscribe(D=>{var H;(H=u.current.slideTabBar)==null||H.flipPage(D)}),j=()=>f.renameId$.subscribe(()=>{x()}),z=()=>f.addSheet$.subscribe(()=>{var D;(D=u.current.slideTabBar)==null||D.getScrollbar().scrollRight()}),q=D=>{const{leftEnd:H,rightEnd:F}=D;let Y="";H&&F?Y="":H&&!F?Y="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&F?Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&!F&&(Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(Y)},K=D=>{f.setScroll({leftEnd:D.isLeftEnd(),rightEnd:D.isRightEnd()})},$=D=>{var Y;const H=(Y=h.current)==null?void 0:Y.querySelector(`.${Re.slideTabBar}`);if(!H)return;new ResizeObserver(()=>{K(D)}).observe(H)},Q=D=>{var H,F,Y,X,J;if(!M.isForceKeepVisible()){if(D){const{left:ee}=(F=(H=h.current)==null?void 0:H.getBoundingClientRect())!=null?F:{},{left:ce}=(J=(X=(Y=u.current.slideTabBar)==null?void 0:Y.getActiveItem())==null?void 0:X.getSlideTabItem().getBoundingClientRect())!=null?J:{};ee!==void 0&&ce!==void 0&&d([ce-ee,0])}a(D)}};return C.jsx(re.Dropdown,{className:Re.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:C.jsx(v.Menu,{menuType:le.SHEET_BAR,onOptionSelect:D=>{const{label:H,value:F}=D;g.executeCommand(H,{value:F,subUnitId:e}),a(!1)}}),onVisibleChange:Q,children:C.jsx("div",{className:Re.slideTabBarContainer,ref:h,children:C.jsx("div",{className:Re.slideTabBar,style:{boxShadow:i},children:o.map(D=>U.createElement(Bm,{...D,key:D.sheetId,selected:e===D.sheetId}))})})})}const ar=100,zm=()=>{const[o,t]=U.useState(!0),[e,n]=U.useState(!0),i=G.useDependency(l.ICommandService),r=G.useDependency(Pt);U.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;t(h),n(m)},a=()=>{i.executeCommand(_.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-ar)},d=()=>{r.setScrollX(ar)};return C.jsxs("div",{className:gn.sheetBar,children:[C.jsxs("div",{className:gn.sheetBarOptions,children:[C.jsx(On,{onClick:a,children:C.jsx(Is,{})}),C.jsx(Nm,{})]}),C.jsx($m,{}),(!o||!e)&&C.jsxs("div",{className:`${gn.sheetBarOptions} ${gn.sheetBarOptionsDivider}`,children:[C.jsx(On,{disabled:o,onClick:c,children:C.jsx(tr,{style:{transform:"rotateZ(180deg)"}})}),C.jsx(On,{disabled:e,onClick:d,children:C.jsx(tr,{})})]})]})};class Ym{constructor(){R(this,"_functions",[{func:Z.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(i=>i.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}}]);R(this,"_state$",new B.BehaviorSubject(null));R(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(i=>{const r=this._functions.find(s=>s.func===i.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(i)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const di=P.createIdentifier("univer.sheet-status-bar.service"),Xm="univer-status-bar",Gm="univer-single-mode",Zm="univer-status-bar-div",Km="univer-statistic-list",qm="univer-statistic-list-column",Qm="univer-statistic-item",Jm="univer-statistic-picker",eg="univer-statistic-picker-item",tg="univer-statistic-more",Ct={statusBar:Xm,singleMode:Gm,statusBarDiv:Zm,statisticList:Km,statisticListColumn:qm,statisticItem:Qm,statisticPicker:Jm,statisticPickerItem:eg,statisticMore:tg},ng=[Z.FUNCTION_NAMES_MATH.SUM,Z.FUNCTION_NAMES_STATISTICAL.AVERAGE,Z.FUNCTION_NAMES_STATISTICAL.MIN,Z.FUNCTION_NAMES_STATISTICAL.MAX],So={[Z.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[Z.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[Z.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[Z.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[Z.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[Z.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[Z.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},po=o=>{const t=G.useDependency(l.LocaleService),e=G.useDependency(v.IMessageService),n=G.useDependency(v.IClipboardInterfaceService),i=og(o),r=async()=>{await n.writeText(o.value.toString()),e.show({type:re.MessageType.Success,content:t.t("statusbar.copied")})};return C.jsx(re.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:C.jsx("div",{className:Ct.statisticItem,onClick:r,children:C.jsx("span",{children:`${t.t((So==null?void 0:So[o.name])||o.name)}: ${i}`})},o.name)})};function og(o){const{pattern:t,value:e}=o;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&ng.includes(o.name)?vn.format(t,e):e.toLocaleString()}const lr=800,ig=3,rg=()=>{const[o,t]=U.useState(window.innerWidth<lr),[e,n]=U.useState(!0),i=G.useDependency(di),r=i.getFunctions().map((m,g)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=U.useState(r),c=s.find(m=>m.show&&!m.disable),d=o&&c?[c]:s.filter(m=>m.show&&!m.disable);U.useEffect(()=>{const m=i.state$.subscribe(g=>{const f=g==null?void 0:g.values;if(!f||f.length===0)n(!1);else{n(!0);const S=s.map(p=>{var M;const I=f.find(b=>b.func===p.name);return I?(p.value=I.value,p.disable=!1):p.disable=!0,p.pattern=(M=g==null?void 0:g.pattern)!=null?M:null,p});a(S)}});return()=>{m.unsubscribe()}},[i]);const u=l.debounce(()=>{const m=window.innerWidth<lr;o!==m&&t(m)},100);U.useEffect(()=>(window.addEventListener("resize",u),()=>{window.removeEventListener("resize",u)}),[o]);let h=null;if(d.length>ig){const m=[];d.forEach((g,f)=>{f%2===0&&m.push(d.slice(f,f+2))}),h=C.jsxs(C.Fragment,{children:[" ",m.map((g,f)=>C.jsxs("div",{className:Ct.statisticListColumn,children:[(g==null?void 0:g[0])&&C.jsx(po,{...g==null?void 0:g[0]},g==null?void 0:g[0].name),(g==null?void 0:g[1])&&C.jsx(po,{...g==null?void 0:g[1]},g==null?void 0:g[1].name)]},`stat-col-${f}`))," "]})}else h=C.jsx(C.Fragment,{children:d.map(m=>C.jsx(po,{...m},m.name))});return e&&C.jsxs("div",{className:Oe(Ct.statusBar,{[Ct.singleMode]:o}),children:[C.jsx("div",{className:Oe(Ct.statisticList),children:h}),C.jsx("div",{className:Ct.statusBarDiv})]})};function sg(){const o=G.useDependency(l.IUniverInstanceService);return v.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsxs("section",{className:Qr.sheetContainer,"data-range-selector":!0,children:[C.jsx(zm,{}),C.jsx(rg,{}),C.jsx(Ch,{})]}):null}function ag(){const o=G.useDependency(l.IUniverInstanceService);return v.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsx(C.Fragment,{children:C.jsx(lm,{})}):null}function lg(){const o=G.useDependency(l.IUniverInstanceService);return v.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsxs(C.Fragment,{children:[C.jsx(Rh,{}),C.jsx(Cm,{})]}):null}const Co={width:"100%"},cr=o=>{const{inputId:t,state:e=!1,type:n="range",confirm:i,cancel:r,name:s,formulaOrRefString:a,comment:c="",localSheetId:d=jo,hidden:u=!1,id:h}=o,g=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),f=G.useDependency(l.LocaleService),S=G.useDependency(Z.IDefinedNamesService),p=G.useDependency(Z.IFunctionService),I=G.useDependency(Z.LexerTreeBuilder);if(g==null)return;const M=g.getUnitId();g.getActiveSheet().getSheetId();const[b,T]=U.useState(s),[w,E]=U.useState(a),[O,x]=U.useState(c),[A,k]=U.useState(d),[N,L]=U.useState(""),[V,j]=U.useState(n),[z,q]=U.useState(!0),K=[{label:f.t("definedName.scopeWorkbook"),value:jo}],$=X=>!Z.isReferenceStrings(X);U.useEffect(()=>{q(!0),T(s),x(c),k(d);let X=a;a.substring(0,1)===Z.operatorToken.EQUALS?j("formula"):$(a)?(j("formula"),X=Z.operatorToken.EQUALS+a):j("range"),E(X),L("")},[e]),g.getSheetOrders().forEach(X=>{const J=g.getSheetBySheetId(X);K.push({label:(J==null?void 0:J.getName())||"",value:X})});const Q=X=>X.map(ee=>{var ce;return Z.serializeRangeToRefString({...ee,sheetName:((ce=g.getSheetBySheetId(ee.sheetId))==null?void 0:ce.getName())||""})}).join(","),D=X=>{E(Q(X))},H=X=>{E(X||"")},F=()=>{if(b.length===0){L(f.t("definedName.nameEmpty"));return}if(S.getValueByName(M,b)!=null&&(h==null||h.length===0)){L(f.t("definedName.nameDuplicate"));return}if(!l.Tools.isValidParameter(b)||Z.isReferenceStringWithEffectiveColumn(b)||!l.Tools.isStartValidPosition(b)&&!y.hasCJKText(b.substring(0,1))){L(f.t("definedName.nameInvalid"));return}if(g.getSheetOrders().map(J=>{var ee;return((ee=g.getSheetBySheetId(J))==null?void 0:ee.getName())||""}).includes(b)){L(f.t("definedName.nameSheetConflict"));return}if(w.length===0){L(f.t("definedName.formulaOrRefStringEmpty"));return}if(!z){L(f.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(b.toUpperCase())){L(f.t("definedName.nameConflict"));return}i&&i({id:h||"",name:b,formulaOrRefString:I.convertRefersToAbsolute(w,l.AbsoluteRefType.ALL,l.AbsoluteRefType.ALL),comment:O,localSheetId:A})},Y=X=>{const J=X;J==="formula"&&w.substring(0,1)!==Z.operatorToken.EQUALS?(E(`${Z.operatorToken.EQUALS}`),E(`${Z.operatorToken.EQUALS}`)):w.substring(0,1)===Z.operatorToken.EQUALS&&(E(""),E("")),j(J)};return C.jsxs("div",{className:ae.definedNameInput,style:{display:e?"block":"none"},children:[C.jsx("div",{children:C.jsx(re.Input,{placeholder:f.t("definedName.inputNamePlaceholder"),value:b,allowClear:!0,onChange:T,affixWrapperStyle:Co})}),C.jsx("div",{children:C.jsxs(re.RadioGroup,{value:V,onChange:Y,children:[C.jsx(re.Radio,{value:"range",children:f.t("definedName.ratioRange")}),C.jsx(re.Radio,{value:"formula",children:f.t("definedName.ratioFormula")})]})}),C.jsx("div",{style:{display:V==="range"?"block":"none"},children:C.jsx(v.RangeSelector,{value:w,onValid:q,onChange:D,placeholder:f.t("definedName.inputRangePlaceholder"),id:l.createInternalEditorID(`${t}-rangeSelector`),width:"99%",openForSheetUnitId:M},`${t}-rangeSelector`)}),C.jsx("div",{style:{display:V==="range"?"none":"block"},children:C.jsx(v.TextEditor,{value:w,onValid:q,onChange:H,id:l.createInternalEditorID(`${t}-editor`),placeholder:f.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:M,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),C.jsx("div",{children:C.jsx(re.Select,{style:Co,value:A,options:K,onChange:k})}),C.jsx("div",{children:C.jsx(re.Input,{affixWrapperStyle:Co,placeholder:f.t("definedName.inputCommentPlaceholder"),value:O,onChange:x})}),C.jsxs("div",{style:{display:N.length===0?"none":"flex"},className:ae.definedNameInputValidation,children:[C.jsx("span",{children:N}),C.jsx(Ss,{})]}),C.jsxs("div",{children:[C.jsx(re.Button,{onClick:()=>{r&&r()},children:f.t("definedName.cancel")}),C.jsx(re.Button,{style:{marginLeft:15},type:"primary",onClick:F,children:f.t("definedName.confirm")})]})]})},cg=()=>{const o=G.useDependency(l.ICommandService),e=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=G.useDependency(l.LocaleService),i=G.useDependency(Z.IDefinedNamesService),r=G.useDependency(_.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),a=()=>{const N=i.getDefinedNameMap(s);return N?Array.from(Object.values(N)):[]},[c,d]=U.useState(!1),[u,h]=U.useState(a()),[m,g]=U.useState(null),[f,S]=U.useState();U.useEffect(()=>{const N=i.update$.subscribe(()=>{h(a())});return()=>{N.unsubscribe()}},[]);const p=N=>{const{name:L,formulaOrRefString:V,comment:j,localSheetId:z,hidden:q}=N;let K=N.id;if(K==null||K.length===0)K=l.Tools.generateRandomId(10),o.executeCommand(_.InsertDefinedNameCommand.id,{id:K,unitId:s,name:L,formulaOrRefString:V,comment:j,localSheetId:z,hidden:q});else{const $=i.getValueById(s,K),Q={id:K,unitId:s,name:L,formulaOrRefString:V,comment:j,localSheetId:z,hidden:q};o.executeCommand(_.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:{...$,unitId:s},newDefinedName:Q})}d(!1),g(null)},I=N=>{S(N)};function M(){S(null)}function b(N){const L=i.getValueById(s,N);o.executeCommand(_.RemoveDefinedNameCommand.id,{...L,unitId:s}),S(null)}const T=N=>{i.focusRange(s,N.id)},w=()=>{const N=u.length+1,L=n.t("definedName.defaultName")+N;if(i.getValueByName(s,L)==null)return L;let V=N+1;for(;;){const j=n.t("definedName.defaultName")+V;if(i.getValueByName(s,j)==null)return j;V++}},E=()=>{const N=e.getActiveSheet().getName(),L=r.getSelections();return L==null?"":L.map(j=>Z.serializeRangeWithSheet(N,j.range)).join(",")},O=()=>{d(!1),g(null)},x=()=>{d(!0),g(null)},A=N=>{d(!1),g(N)},k=N=>{const L=e.getSheetBySheetId(N);return L==null?"":L.getName()};return C.jsx("div",{className:ae.definedNameContainer,children:C.jsxs("div",{className:ae.definedNameContainerScroll,children:[C.jsxs("div",{children:[C.jsxs("div",{onClick:x,className:ae.definedNameContainerAddButton,style:{display:c?"none":"flex"},children:[C.jsx(Is,{}),C.jsx("span",{className:ae.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),C.jsx(cr,{confirm:p,cancel:O,state:c,inputId:"insertDefinedName",name:w(),formulaOrRefString:E()})]},"insertDefinedName"),u.map((N,L)=>C.jsxs("div",{children:[C.jsxs("div",{onClick:()=>{T(N)},className:ae.definedNameContainerItem,style:{display:N.id===m?"none":"flex"},children:[C.jsxs("div",{title:N.comment,children:[C.jsxs("div",{className:ae.definedNameContainerItemName,children:[N.name,C.jsx("span",{className:ae.definedNameContainerItemNameForSheet,children:N.localSheetId===jo||N.localSheetId==null?"":k(N.localSheetId)})]}),C.jsx("div",{className:ae.definedNameContainerItemFormulaOrRefString,children:N.formulaOrRefString})]}),C.jsx(re.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:C.jsx("div",{className:Oe(ae.definedNameContainerItemUpdate,ae.definedNameContainerItemShow),onClick:()=>{A(N.id)},children:C.jsx(Qt,{})})}),C.jsx(re.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:C.jsx("div",{className:Oe(ae.definedNameContainerItemDelete,ae.definedNameContainerItemShow),onClick:()=>{I(N.id)},children:C.jsx(Uu,{})})})]}),C.jsx(re.Confirm,{visible:f===N.id,onClose:M,onConfirm:()=>{b(N.id)},children:n.t("definedName.deleteConfirmText")}),C.jsx(cr,{confirm:p,cancel:O,state:N.id===m,id:N.id,inputId:N.id+L,name:N.name,formulaOrRefString:N.formulaOrRefString,comment:N.comment,localSheetId:N.localSheetId})]},L))]})})};function dg(o){const t=o.get(_.BorderStyleManagerService),e=_.getCurrentSheetDisabled$(o);return{id:_.SetBorderBasicCommand.id,icon:new B.Observable(n=>{const i="AllBorderSingle",r=o.get(_.BorderStyleManagerService),s=o.get(l.ICommandService).onCommandExecuted(a=>{var m;if(a.id!==_.SetBorderBasicCommand.id)return;const{type:d}=r.getBorderInfo(),u=Es.find(g=>g.value===d),h=(m=u==null?void 0:u.icon)!=null?m:i;n.next(h)});return n.next(i),s.dispose}),group:v.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[v.MenuPosition.TOOLBAR_START],type:v.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:ws,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const to="sheet.menu.clear-selection";function ug(){return{id:to,group:v.MenuGroup.CONTEXT_MENU_FORMAT,type:v.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[v.MenuPosition.CONTEXT_MENU,le.COL_HEADER_CONTEXT_MENU,le.ROW_HEADER_CONTEXT_MENU]}}function hg(){return{id:_.ClearSelectionContentCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[to]}}function mg(){return{id:_.ClearSelectionFormatCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[to]}}function gg(){return{id:_.ClearSelectionAllCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[to]}}const sn="sheet.menu.delete";function fg(){return{id:sn,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[v.MenuPosition.CONTEXT_MENU]}}function _g(){return{id:is.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[sn,le.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function Sg(){return{id:os.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,icon:"DeleteRow",positions:[sn,le.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function pg(){return{id:li.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[sn]}}function Cg(){return{id:Wn.id,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[sn]}}const ui="sheet.menu.col-insert";function vg(){return{id:ui,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.COL_HEADER_CONTEXT_MENU]}}const hi="sheet.menu.row-insert";function Ig(){return{id:hi,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.ROW_HEADER_CONTEXT_MENU]}}const an="sheet.menu.cell-insert";function Rg(){return{id:an,group:v.MenuGroup.CONTEXT_MENU_LAYOUT,type:v.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[v.MenuPosition.CONTEXT_MENU]}}function Mg(o){const t=o.get(_.SelectionManagerService);return{id:_.InsertRowBeforeCommand.id,type:v.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[hi,an],hidden$:new B.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function bg(o){const t=o.get(_.SelectionManagerService);return{id:_.InsertRowAfterCommand.id,type:v.MenuItemType.BUTTON,positions:[hi],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new B.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Tg(o){const t=o.get(_.SelectionManagerService);return{id:_.InsertColBeforeCommand.id,type:v.MenuItemType.BUTTON,positions:[ui,an],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new B.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function wg(o){const t=o.get(_.SelectionManagerService);return{id:_.InsertColAfterCommand.id,type:v.MenuItemType.BUTTON,positions:[ui],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new B.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Eg(){return{id:ci.id,type:v.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[an]}}function yg(){return{id:jn.id,type:v.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[an]}}function Og(o){return o.get(_.SelectionManagerService).selectionMoveEnd$.pipe(B.filter(e=>e!=null&&e.length>=2),B.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let i=n+1;i<e.length;i++)if(l.Rectangle.intersects(e[n].range,e[i].range))return!0;return!1}))}function xg(o){const t=_.getCurrentSheetDisabled$(o),e=Og(o);return{id:Ze.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[v.MenuPosition.TOOLBAR_START],group:v.MenuGroup.TOOLBAR_LAYOUT,type:v.MenuItemType.SUBITEMS,hidden$:v.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:t.pipe(B.combineLatestWith(e),B.map(([n,i])=>n||i))}}function Ng(o){return{id:Jr.id,type:v.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ze.id]}}function Ag(o){return{id:es.id,type:v.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ze.id]}}function Dg(o){return{id:ts.id,type:v.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ze.id]}}function Pg(o){return{id:_.RemoveWorksheetMergeCommand.id,type:v.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ze.id]}}function Hg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:rs.id,type:v.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.delete",disabled$:new B.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),i.dispose})}}function Lg(){return{id:_.CopySheetCommand.id,type:v.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.copy"}}function Ug(){return{id:ls.id,type:v.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.rename"}}function Vg(){return{id:_.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[le.SHEET_BAR],type:v.MenuItemType.SELECTOR,selections:[{label:{name:Qn,hoverable:!1}}]}}function Bg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:_.SetWorksheetHideCommand.id,type:v.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.hide",disabled$:new B.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values()).filter(d=>d.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),i.dispose})}}function kg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:ss.id,type:v.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new B.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===_.RemoveSheetMutation.id||s===_.InsertSheetMutation.id||s===_.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values());n.next(c.length===1)}});return n.next(!1),i.dispose})}}const Fg={id:_.SetRowHiddenCommand.id,preconditions:o=>ne(o),binding:v.KeyCode.Digit9|v.MetaKeys.CTRL_COMMAND},Wg={id:_.SetColHiddenCommand.id,preconditions:o=>ne(o),binding:v.KeyCode.Digit0|v.MetaKeys.CTRL_COMMAND|v.MetaKeys.SHIFT},jg={id:we.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_DOWN,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},$g={id:we.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_UP,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP}},zg={id:we.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_LEFT,priority:100,preconditions:gr,staticParameters:{direction:l.Direction.LEFT}},Yg={id:we.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_RIGHT,priority:100,preconditions:gr,staticParameters:{direction:l.Direction.RIGHT}},Xg={id:gt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:v.KeyCode.TAB,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,keycode:v.KeyCode.TAB}},Gg={id:gt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:v.KeyCode.TAB|v.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,keycode:v.KeyCode.TAB}},Zg={id:gt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:v.KeyCode.ENTER,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,keycode:v.KeyCode.ENTER}},Kg={id:gt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:v.KeyCode.ENTER|v.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP,keycode:v.KeyCode.ENTER}},qg={id:we.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_DOWN|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:Fe.moveGap}},Qg={id:we.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_UP|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:Fe.moveGap}},Jg={id:we.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_LEFT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:Fe.moveGap}},ef={id:we.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:v.KeyCode.ARROW_RIGHT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Fe.moveGap}},tf={id:Ae.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:v.KeyCode.ARROW_DOWN|v.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},nf={id:Ae.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:v.KeyCode.ARROW_UP|v.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.UP}},of={id:Ae.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:v.KeyCode.ARROW_LEFT|v.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.LEFT}},rf={id:Ae.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:v.KeyCode.ARROW_RIGHT|v.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT}},sf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:v.KeyCode.ARROW_DOWN|v.MetaKeys.SHIFT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:Fe.moveGap}},af={id:Ae.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:v.KeyCode.ARROW_UP|v.MetaKeys.SHIFT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:Fe.moveGap}},lf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:v.KeyCode.ARROW_LEFT|v.MetaKeys.SHIFT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:Fe.moveGap}},cf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:v.KeyCode.ARROW_RIGHT|v.MetaKeys.SHIFT|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Fe.moveGap}},df={id:yr.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:v.KeyCode.A|v.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{expandToGapFirst:!0,loop:!0}},uf={id:ei.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:o=>ne(o),binding:v.KeyCode.B|v.MetaKeys.CTRL_COMMAND},hf={id:ti.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:o=>ne(o),binding:v.KeyCode.I|v.MetaKeys.CTRL_COMMAND},mf={id:ni.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:o=>ne(o),binding:v.KeyCode.U|v.MetaKeys.CTRL_COMMAND},gf={id:oi.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:o=>ne(o),binding:v.KeyCode.X|v.MetaKeys.SHIFT|v.MetaKeys.CTRL_COMMAND},ff={id:_.ClearSelectionContentCommand.id,preconditions:o=>ne(o),binding:v.KeyCode.DELETE,mac:v.KeyCode.BACKSPACE},_f={id:Zn.id,description:"shortcut.sheet.zoom-in",binding:v.KeyCode.EQUAL|v.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:.2}},Sf={id:l.NilCommand.id,binding:v.KeyCode.EQUAL|v.MetaKeys.CTRL_COMMAND},pf={id:Zn.id,description:"shortcut.sheet.zoom-out",binding:v.KeyCode.MINUS|v.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:-.2}},Cf={id:l.NilCommand.id,binding:v.KeyCode.MINUS|v.MetaKeys.CTRL_COMMAND},vf={id:Zn.id,description:"shortcut.sheet.reset-zoom",binding:v.KeyCode.Digit0|v.MetaKeys.CTRL_COMMAND,preconditions:ne,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},If={id:l.NilCommand.id,binding:v.KeyCode.Digit0|v.MetaKeys.CTRL_COMMAND};var Rf=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,bf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Mf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Rf(t,e,i),i},at=(o,t)=>(e,n)=>t(e,n,o);let xn=class extends l.Disposable{constructor(o,t,e,n,i,r,s){super(),this._injector=o,this._componentManager=t,this._layoutService=e,this._commandService=n,this._shortcutService=i,this._menuService=r,this._uiController=s,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const o=this._componentManager;this.disposeWithMe(o.register(si,nc)),this.disposeWithMe(o.register(ws,gh)),this.disposeWithMe(o.register(Qn,re.ColorPicker)),this.disposeWithMe(o.register(Fr,v.FontFamily)),this.disposeWithMe(o.register(Wr,v.FontFamilyItem)),this.disposeWithMe(o.register(jr,v.FontSize)),this.disposeWithMe(o.register(ys,cg))}_initCommands(){[Jr,Ze,ts,es,Zn,Ae,we,gt,ls,rs,os,is,xr,Nr,dt,Or,yr,as,_.SetBoldCommand,qt,Te,Jo,ei,ti,ni,oi,Ul,Vl,Ar,Dr,kn,_.SetItalicCommand,_.SetStrikeThroughCommand,_.SetFontFamilyCommand,_.SetFontSizeCommand,ii,Lr,ri,Ur,nt,Xt,qn,Vr,Br,kr,_.SetUnderlineCommand,Kn,ke,ss,ns,jn,Wn,ci,li,Os,Un,In].forEach(o=>{this.disposeWithMe(this._commandService.registerCommand(o))})}_initMenus(){[pc,Cc,vc,Ic,Rc,Mc,bc,hg,mg,gg,ug,vg,Ig,Rg,Mg,bg,Tg,wg,Sg,Ac,Pc,Dc,Hc,_g,Lc,Tc,Uc,fg,pg,Cg,Eg,yg,yc,Oc,xc,Nc,wc,Ec,oc,ic,rc,sc,ac,lc,cc,dc,uc,hc,mc,dg,xg,Ng,Ag,Dg,Pg,gc,fc,_c,Sc,Hg,Lg,Ug,Vg,Bg,kg].forEach(o=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(o)))})}_initShortcuts(){[jg,$g,zg,Yg,Xg,Gg,Zg,Kg,qg,Qg,Jg,ef,tf,nf,of,rf,sf,af,lf,cf,df,_f,pf,vf,If,Sf,Cf,uf,hf,mf,gf,ff,...ld(),dd,cd,ud,md,gd,fd,hd,Fg,Wg].forEach(o=>{this.disposeWithMe(this._shortcutService.registerShortcut(o))})}_initWorkbenchParts(){const o=this._uiController,t=this._injector;this.disposeWithMe(o.registerComponent(v.DesktopUIPart.HEADER,()=>G.connectInjector(ag,t))),this.disposeWithMe(o.registerComponent(v.DesktopUIPart.FOOTER,()=>G.connectInjector(sg,t))),this.disposeWithMe(o.registerComponent(v.DesktopUIPart.CONTENT,()=>G.connectInjector(lg,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(l.UniverInstanceType.UNIVER_SHEET,o=>{this._injector.get(y.ITextSelectionRenderManager).focus()}))}};xn=bf([l.OnLifecycle(l.LifecycleStages.Ready,xn),at(0,P.Inject(P.Injector)),at(1,P.Inject(v.ComponentManager)),at(2,v.ILayoutService),at(3,l.ICommandService),at(4,v.IShortcutService),at(5,v.IMenuService),at(6,v.IUIController)],xn);var Tf=Object.defineProperty,wf=Object.getOwnPropertyDescriptor,Ef=(o,t,e,n)=>{for(var i=n>1?void 0:n?wf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Tf(t,e,i),i},lt=(o,t)=>(e,n)=>t(e,n,o);let Nn=class extends l.Disposable{constructor(t,e,n,i,r,s,a){super();R(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=i,this._commandService=r,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=l.debounce(e=>{var i;const n=(i=e[e.length-1])==null?void 0:i.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===_.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_clearResult(){this._statusBarService.setState(null)}_calculateSelection(t,e){var c;const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return this._clearResult();const i=n.getUnitId(),r=n.getActiveSheet().getSheetId(),s={},a=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(d=>{const u=d.getConfig();s[d.getSheetId()]={cellData:new l.ObjectMatrix(u.cellData),rowCount:u.rowCount,columnCount:u.columnCount,rowData:u.rowData,columnData:u.columnData}}),t!=null&&t.length){const d=t.map(p=>new Z.RangeReferenceObject(p,r,i));d.forEach(p=>{p.setUnitData({[i]:s}),a&&p.setArrayFormulaCellData(Z.convertUnitDataToRuntime(a))});const u=this._statusBarService.getFunctions(),h=d.map(p=>p.toArrayValueObject(!1)),m=u.map(p=>{const I=this._functionService.getExecutor(p.func);if(!I)return;const M=I==null?void 0:I.calculate(...h),b=M==null?void 0:M.getValue();if(b)return{func:p.func,value:b}});if(m.every(p=>p===void 0))return;let g=null;if(e){const{actualRow:p,actualColumn:I}=e;g=(c=this._numfmtService.getValue(i,r,p,I))==null?void 0:c.pattern}const S={values:m.filter(p=>p!==void 0),pattern:g};this._statusBarService.setState(S)}else this._clearResult()}};Nn=Ef([l.OnLifecycle(l.LifecycleStages.Ready,Nn),lt(0,l.IUniverInstanceService),lt(1,P.Inject(_.SelectionManagerService)),lt(2,Z.IFunctionService),lt(3,di),lt(4,l.ICommandService),lt(5,P.Inject(Z.FormulaDataModel)),lt(6,P.Inject(_.INumfmtService))],Nn);var yf=Object.defineProperty,Of=Object.getOwnPropertyDescriptor,xf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Of(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&yf(t,e,i),i},vo=(o,t)=>(e,n)=>t(e,n,o);exports.SheetCanvasView=class extends l.RxDisposable{constructor(e,n,i,r){super();R(this,"_fps$",new B.BehaviorSubject(""));R(this,"fps$",this._fps$.asObservable());this._context=e,this._commandService=n,this._renderManagerService=i,this._sheetSkeletonManagerService=r,this._addNewRender(this._context.unit)}dispose(){this._fps$.complete()}_addNewRender(e){const{scene:n,engine:i}=this._context;n.openTransformer(),n.addLayer(new y.Layer(n,[],0),new y.Layer(n,[],2)),this._addComponent(e),e.getShouldRenderLoopImmediately()&&i.runRenderLoop(()=>{n.render(),this._fps$.next(Math.round(i.getFps()).toString())})}_addComponent(e){const{scene:n,components:i}=this._context,r=e.getActiveSheet();e.getUnitId(),r.getSheetId(),this._addViewport(r);const s=new y.Spreadsheet(ie.MAIN),a=new y.SpreadsheetRowHeader(ie.ROW),c=new y.SpreadsheetColumnHeader(ie.COLUMN),d=new y.Rect(ie.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,i.set(ie.MAIN,s),i.set(ie.ROW,a),i.set(ie.COLUMN,c),i.set(ie.LEFT_TOP,d),n.addObjects([s],Ti),n.addObjects([a,c,d],tt),n.enableLayerCache(Ti,tt)}_addViewport(e){const n=this._context.scene,{rowHeader:i,columnHeader:r}=e.getConfig(),s=new y.Viewport(W.VIEW_MAIN,n,{left:i.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new y.Viewport(W.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(W.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:i.width,isWheelPreventDefaultX:!0}),new y.Viewport(W.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new y.Viewport(W.VIEW_COLUMN_RIGHT,n,{left:i.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new y.Viewport(W.VIEW_LEFT_TOP,n,{left:0,top:0,width:i.width,height:r.height,isWheelPreventDefaultX:!0}),new y.Viewport(W.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(W.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new y.Viewport(W.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(l.toDisposable(n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let d=0,u=0;const h=s.limitedScroll();if(a.inputIndex===y.PointerInput.MouseWheelX){const g=Math.abs(a.deltaX);a.deltaX>0?d=g:d=-g,this._commandService.executeCommand(Xt.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===y.PointerInput.MouseWheelY){let g=Math.abs(a.deltaY);a.shiftKey?(g*=3,a.deltaY>0?d=g:d=-g,this._commandService.executeCommand(Xt.id,{offsetX:d}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()):(a.deltaY>0?u=g:u=-g,this._commandService.executeCommand(Xt.id,{offsetY:u}),n.getParent().classType===y.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}this._context.scene.makeDirty(!0)}))),new y.ScrollBar(s),n.attachControl(),s}};exports.SheetCanvasView=xf([vo(1,l.ICommandService),vo(2,y.IRenderManagerService),vo(3,P.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Nf=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,Df=(o,t,e,n)=>{for(var i=n>1?void 0:n?Af(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Nf(t,e,i),i},fn=(o,t)=>(e,n)=>t(e,n,o);exports.HoverManagerService=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_currentCell$",new B.Subject);R(this,"currentCell$",this._currentCell$.asObservable().pipe(B.distinctUntilChanged((e,n)=>{var i,r,s,a,c,d,u,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((r=n==null?void 0:n.location)==null?void 0:r.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((a=n==null?void 0:n.location)==null?void 0:a.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((d=n==null?void 0:n.location)==null?void 0:d.row)&&((u=e==null?void 0:e.location)==null?void 0:u.col)===((h=n==null?void 0:n.location)==null?void 0:h.col)})));R(this,"_lastPosition",null);this._univerInstanceService=e,this._scrollManagerService=n,this._sheetSkeletonManagerService=i,this._renderManagerService=r,this._initCellDisposableListener()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)}))}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:e,offsetY:n}=this._lastPosition,i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!i){this._currentCell$.next(null);return}const r=i.getActiveSheet(),s=this._sheetSkeletonManagerService.getCurrent(),a=this._renderManagerService.getRenderById(i.getUnitId()),c=this._scrollManagerService.getCurrentScroll();if(!s||!c||!a)return;const{scene:d}=a,{skeleton:u,sheetId:h,unitId:m}=s,g=Fl(e,n,d,u);if(!g){this._currentCell$.next(null);return}const{row:f,col:S,mergeCell:p,actualCol:I,actualRow:M}=g,b={unitId:m,subUnitId:h,workbook:i,worksheet:r,row:M,col:I};let T;p?T=p:T={startRow:f,endRow:f,startColumn:S,endColumn:S};const w=d.getActiveViewportByCoord(y.Vector2.FromArray([e,n]));if(!w)return;const{scaleX:E,scaleY:O}=d.getAncestorScale(),x={x:w.actualScrollX,y:w.actualScrollY},A={startX:(u.getOffsetByPositionX(T.startColumn-1)-x.x)*E,endX:(u.getOffsetByPositionX(T.endColumn)-x.x)*E,startY:(u.getOffsetByPositionY(T.startRow-1)-x.y)*O,endY:(u.getOffsetByPositionY(T.endRow)-x.y)*O};this._currentCell$.next({location:b,position:A})}onMouseMove(e,n){this._lastPosition={offsetX:e,offsetY:n},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}};exports.HoverManagerService=Df([fn(0,l.IUniverInstanceService),fn(1,P.Inject(ot)),fn(2,P.Inject(exports.SheetSkeletonManagerService)),fn(3,y.IRenderManagerService)],exports.HoverManagerService);var Pf=Object.defineProperty,Hf=Object.getOwnPropertyDescriptor,Lf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Hf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Pf(t,e,i),i},Io=(o,t)=>(e,n)=>t(e,n,o);exports.HoverRenderController=class extends l.Disposable{constructor(t,e,n,i){super(),this._context=t,this._renderManagerService=e,this._hoverManagerService=n,this._sheetSkeletonManagerService=i,this._initPointerEvent()}_initPointerEvent(){const t=new l.DisposableCollection,e=n=>{if(t.dispose(),!n)return;const i=this._renderManagerService.getRenderById(n.unitId);if(!i)return;const{scene:r}=i,s=r.onPointerMoveObserver.add(a=>{this._hoverManagerService.onMouseMove(a.offsetX,a.offsetY)});t.add({dispose(){r.onPointerMoveObserver.remove(s)}})};e(this._sheetSkeletonManagerService.getCurrent()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{e(n)}))}};exports.HoverRenderController=Lf([l.OnLifecycle(l.LifecycleStages.Rendered,exports.HoverRenderController),Io(1,y.IRenderManagerService),Io(2,P.Inject(exports.HoverManagerService)),Io(3,P.Inject(exports.SheetSkeletonManagerService))],exports.HoverRenderController);const Uf="univer-cell-alert",Vf="univer-cell-alert-title",Bf="univer-cell-alert-icon",kf="univer-cell-alert-icon-error",Ff="univer-cell-alert-icon-info",Wf="univer-cell-alert-icon-warning",jf="univer-cell-alert-content",Ye={cellAlert:Uf,cellAlertTitle:Vf,cellAlertIcon:Bf,cellAlertIconError:kf,cellAlertIconInfo:Ff,cellAlertIconWarning:Wf,cellAlertContent:jf};function $f({popup:o}){var s;const t=(s=o.extraProps)==null?void 0:s.alert;if(!t)return null;const{type:e,title:n,message:i}=t,r={[bt.ERROR]:C.jsx(Ss,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconError)}),[bt.INFO]:C.jsx(nr,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconInfo)}),[bt.WARNING]:C.jsx(nr,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconWarning)})};return C.jsxs("div",{className:Ye.cellAlert,children:[C.jsxs("div",{className:Ye.cellAlertTitle,children:[e?r[e]:null,n]}),C.jsx("div",{className:Ye.cellAlertContent,children:i})]})}const xs="univer.sheet.cell-alert";var zf=Object.defineProperty,Yf=Object.getOwnPropertyDescriptor,Xf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Yf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&zf(t,e,i),i},pt=(o,t)=>(e,n)=>t(e,n,o);exports.SheetCanvasPopManagerService=class extends l.Disposable{constructor(t,e,n,i,r,s){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=i,this._refRangeService=r,this._commandService=s}_calcCellPosition(t,e,n,i,r){const{scene:s,engine:a}=n,c=i.getCellByIndex(t,e),d=c.isMergedMainCell?c.mergeInfo:c,{scaleX:u,scaleY:h}=s.getAncestorScale(),m={x:r.actualScrollX,y:r.actualScrollY},g=a.getCanvasElement().getBoundingClientRect();return{left:(d.startX-m.x)*u+g.left,right:(d.endX-m.x)*u+g.left,top:(d.startY-m.y)*h+g.top,bottom:(d.endY-m.y)*h+g.top}}_createCellPositionObserver(t,e,n,i,r){let s=t,a=e;const c=this._calcCellPosition(s,a,n,i,r),d=new B.BehaviorSubject(c),u=()=>d.next(this._calcCellPosition(s,a,n,i,r)),h=new l.DisposableCollection;return h.add(this._commandService.onCommandExecuted(g=>{if(g.id===_.SetWorksheetRowAutoHeightMutation.id&&g.params.rowsAutoHeightInfo.findIndex(S=>S.row===s)>-1){u();return}(_.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(g.id)>-1||g.id===nt.id||g.id===ke.id)&&u()})),{position$:d,disposable:h,position:c,updateRowCol:(g,f)=>{s=g,a=f,u()}}}_createObjectPositionObserver(t,e,n,i){const r=()=>{const{scene:d}=e,{left:u,top:h,width:m,height:g}=t,f={left:u,right:u+m,top:h,bottom:h+g},S=jl(f,d,n,i),p=e.engine.getCanvasElement().getBoundingClientRect();return{left:S.left,right:S.right,top:S.top+p.top,bottom:S.bottom+p.top}},s=r(),a=new B.BehaviorSubject(s),c=new l.DisposableCollection;return c.add(this._commandService.onCommandExecuted(d=>{(d.id===nt.id||d.id===ke.id)&&a.next(r())})),{position:s,position$:a,disposable:c}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),i=n.getActiveSheet(),r=n.getUnitId(),s=i.getSheetId(),a=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),c=this._renderManagerService.getRenderById(r);if(!c||!a)return{dispose:()=>{}};const{position:d,position$:u,disposable:h}=this._createObjectPositionObserver(t,c,a,i),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:d,anchorRect$:u});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),u.complete(),h.dispose()}}}attachPopupToCell(t,e,n,i){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),a=r.getUnitId(),c=s.getSheetId(),d=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:a,sheetId:c}),u=this._renderManagerService.getRenderById(a);if(!u||!d)return null;const h=i!=null?i:Wl(t,e,u.scene,s);if(!h)return null;const{position:m,position$:g,disposable:f,updateRowCol:S}=this._createCellPositionObserver(t,e,u,d,h),p=this._globalPopupManagerService.addPopup({...n,unitId:a,subUnitId:c,anchorRect:m,anchorRect$:g}),I=new l.DisposableCollection;I.add(f),I.add(l.toDisposable(()=>{this._globalPopupManagerService.removePopup(p),g.complete()}));const M={startRow:t,endRow:t,startColumn:e,endColumn:e};return I.add(this._refRangeService.watchRange(a,c,M,(b,T)=>{T?S(T.startRow,T.startColumn):I.dispose()})),I}};exports.SheetCanvasPopManagerService=Xf([pt(0,P.Inject(v.ICanvasPopupService)),pt(1,y.IRenderManagerService),pt(2,l.IUniverInstanceService),pt(3,P.Inject(exports.SheetSkeletonManagerService)),pt(4,P.Inject(_.RefRangeService)),pt(5,l.ICommandService)],exports.SheetCanvasPopManagerService);var Gf=Object.defineProperty,Zf=Object.getOwnPropertyDescriptor,Kf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Zf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Gf(t,e,i),i},dr=(o,t)=>(e,n)=>t(e,n,o),bt=(o=>(o[o.INFO=0]="INFO",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o))(bt||{});exports.CellAlertManagerService=class{constructor(t,e){R(this,"_currentAlert$",new B.Subject);R(this,"_currentAlert",new Map);R(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){let e=this._currentAlert.get(t.key);e&&e.dispose.dispose(),e?e.dispose.dispose():(e={alert:t,dispose:{dispose(){}}},this._currentAlert.set(t.key,e));const{location:n}=t,{row:i,col:r,unitId:s}=n;if(!this._renderManagerService.getRenderById(s))return;const c=this._canvasPopManagerService.attachPopupToCell(i,r,{componentKey:xs,direction:"horizontal",offset:[2,0],extraProps:{alert:t}});c&&(e.dispose=c),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(t){const e=this._currentAlert.get(t);e&&(this._currentAlert.delete(t),e==null||e.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(t=>{t.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}};exports.CellAlertManagerService=Kf([dr(0,y.IRenderManagerService),dr(1,P.Inject(exports.SheetCanvasPopManagerService))],exports.CellAlertManagerService);var qf=Object.defineProperty,Qf=Object.getOwnPropertyDescriptor,Jf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Qf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&qf(t,e,i),i},e_=(o,t)=>(e,n)=>t(e,n,o);let An=class extends l.Disposable{constructor(o,t){super(),this._context=o,this._componentManager=t,this._initComponent()}_initComponent(){this._componentManager.register(xs,$f)}};An=Jf([l.OnLifecycle(l.LifecycleStages.Starting,An),e_(1,P.Inject(v.ComponentManager))],An);var t_=Object.defineProperty,n_=Object.getOwnPropertyDescriptor,o_=(o,t,e,n)=>{for(var i=n>1?void 0:n?n_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&t_(t,e,i),i},ur=(o,t)=>(e,n)=>t(e,n,o);let Dn=class extends l.RxDisposable{constructor(o,t,e){super(),this._context=o,this._sheetSkeletonManagerService=t,this._sheetInterceptorService=e,this._init()}_init(){this._initViewModelIntercept()}_initViewModelIntercept(){const o={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(_.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,e,n)=>{var s;if(!((s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton))return n(t);const r=e.worksheet.getCellRaw(e.row,e.col);return!r||r.v===null||r.v===void 0?n(t):(t==null?void 0:t.t)===l.CellValueType.FORCE_STRING&&l.isRealNum(r.v)?n({...t,markers:{...t==null?void 0:t.markers,...o}}):n(t)}}))}};Dn=o_([l.OnLifecycle(l.LifecycleStages.Rendered,Dn),ur(1,P.Inject(exports.SheetSkeletonManagerService)),ur(2,P.Inject(_.SheetInterceptorService))],Dn);var i_=Object.defineProperty,r_=Object.getOwnPropertyDescriptor,s_=(o,t,e,n)=>{for(var i=n>1?void 0:n?r_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&i_(t,e,i),i},_n=(o,t)=>(e,n)=>t(e,n,o);const Ro="SHEET_FORCE_STRING_ALERT";let Pn=class extends l.Disposable{constructor(o,t,e,n,i){super(),this._context=o,this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=n,this._localeService=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(o=>{var t;if(o){const i=this._context.unit.getActiveSheet().getCell(o.location.row,o.location.col);if((i==null?void 0:i.t)===l.CellValueType.FORCE_STRING&&i.v&&l.isRealNum(i.v)){const r=this._cellAlertManagerService.currentAlert.get(Ro),s=(t=r==null?void 0:r.alert)==null?void 0:t.location;if(s&&s.row===o.location.row&&s.col===o.location.col&&s.subUnitId===o.location.subUnitId&&s.unitId===o.location.unitId)return;this._cellAlertManagerService.showAlert({type:bt.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:o.location,width:200,height:74,key:Ro});return}}this._cellAlertManagerService.removeAlert(Ro)}))}};Pn=s_([l.OnLifecycle(l.LifecycleStages.Rendered,Pn),_n(1,P.Inject(exports.HoverManagerService)),_n(2,P.Inject(exports.CellAlertManagerService)),_n(3,l.IUniverInstanceService),_n(4,P.Inject(l.LocaleService))],Pn);var a_=Object.defineProperty,l_=Object.getOwnPropertyDescriptor,c_=(o,t,e,n)=>{for(var i=n>1?void 0:n?l_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&a_(t,e,i),i},Mo=(o,t)=>(e,n)=>t(e,n,o);let $o=class extends l.Disposable{constructor(o,t,e,n){super(),this._context=o,this._contextMenuService=t,this._selectionManagerService=e,this._selectionRenderService=n,this._addListeners()}_addListeners(){var c,d;const o=(d=(c=this._context)==null?void 0:c.mainComponent)==null?void 0:d.onPointerDownObserver,t=o.add(u=>{if(u.button===2){const h=this._selectionManagerService.getSelections(),m=h==null?void 0:h[0];if(!m)return;const g=m.range.rangeType,f=this._selectionRenderService.convertSelectionToCoord(m).rangeWithCoord,S=()=>{if(!f)return!1;const I=u.offsetX,M=u.offsetY;switch(g){case l.RANGE_TYPE.ROW:return f.startY<=M&&f.endY>=M;case l.RANGE_TYPE.COLUMN:return f.startX<=I&&f.endX>=I;default:return f.startX<=I&&f.endX>=I&&f.startY<=M&&f.endY>=M}},p=I=>{this._contextMenuService.triggerContextMenu(u,I)};S()?g===l.RANGE_TYPE.COLUMN?p(le.COL_HEADER_CONTEXT_MENU):g===l.RANGE_TYPE.ROW?p(le.ROW_HEADER_CONTEXT_MENU):p(v.MenuPosition.CONTEXT_MENU):p(v.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>o.remove(t)));const e=this._context.components.get(ie.COLUMN),r=this._context.components.get(ie.ROW).onPointerDownObserver.add(u=>{u.button===2&&this._contextMenuService.triggerContextMenu(u,le.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>o.remove(r)));const a=e.onPointerDownObserver.add(u=>{u.button===2&&this._contextMenuService.triggerContextMenu(u,le.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>o.remove(a)))}};$o=c_([Mo(1,v.IContextMenuService),Mo(2,P.Inject(_.SelectionManagerService)),Mo(3,Ne)],$o);var d_=Object.defineProperty,u_=Object.getOwnPropertyDescriptor,h_=(o,t,e,n)=>{for(var i=n>1?void 0:n?u_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&d_(t,e,i),i},Qe=(o,t)=>(e,n)=>t(e,n,o);let zo=class extends l.RxDisposable{constructor(o,t,e,n,i,r,s,a,c){super(),this._context=o,this._injector=t,this._commandService=e,this._editorBridgeService=n,this._layoutService=i,this._editorService=r,this._contextService=s,this._selectionManagerService=a,this._rangeSelectorService=c,this._initialize(),this._commandExecutedListener()}_initialize(){this._initSelectionChangeListener(),this._initEventListener(),this._initialRangeSelector()}_initSelectionChangeListener(){B.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(B.takeUntil(this.dispose$)).subscribe(o=>this._handleSelectionChange(o))}_updateEditorPosition(o){const t=this._getSheetObject(),{scene:e,engine:n}=t,i=this._context.unitId,r=this._context.unit.getActiveSheet().getSheetId();this._commandService.executeCommand(as.id,{scene:e,engine:n,primary:o,unitId:i,sheetId:r})}_handleSelectionChange(o){var n;const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==_.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible)return;const e=(n=o==null?void 0:o[o.length-1])==null?void 0:n.primary;e&&this._updateEditorPosition(e)}_initEventListener(){const o=this._getSheetObject(),{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:i}=o;t.onDblclickObserver.add(r=>{if(r.button===2)return;const s=this._selectionManagerService.getCurrent();(s==null?void 0:s.pluginName)===_.NORMAL_SELECTION_PLUGIN_NAME&&this._commandService.executeCommand(Te.id,{visible:!0,eventType:y.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),i.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Te.id,{visible:!1,eventType:y.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const o=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),i=o==null?void 0:o.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));i&&this._rangeSelectorService.selectionChange(i)}))}_rangeSelector(o){if(!o)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),i=o.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(i)}_getCurrentUnitIdAndSheetId(){const o=this._context.unit,t=o.getActiveSheet();return{unitId:o.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return it(this._context.unit,this._context)}_commandExecutedListener(){const o=_.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===_.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():o.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===Kn.id&&this._editorBridgeService.refreshEditCellState()}))}};zo=h_([Qe(1,P.Inject(P.Injector)),Qe(2,l.ICommandService),Qe(3,Ee),Qe(4,v.ILayoutService),Qe(5,v.IEditorService),Qe(6,l.IContextService),Qe(7,P.Inject(_.SelectionManagerService)),Qe(8,v.IRangeSelectorService)],zo);var m_=Object.defineProperty,g_=Object.getOwnPropertyDescriptor,f_=(o,t,e,n)=>{for(var i=n>1?void 0:n?g_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&m_(t,e,i),i},Sn=(o,t)=>(e,n)=>t(e,n,o);let Hn=class extends l.Disposable{constructor(o,t,e,n){super(),this._commandService=o,this._formatPainterService=t,this._univerInstanceService=e,this._selectionRenderService=n,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(o=>{if(this._formatPainterService.getStatus()!==xe.OFF){const{rangeWithCoord:t}=o[o.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===xe.ONCE&&this._commandService.executeCommand(ri.id)}})))}async _applyFormatPainter(o){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),i=n.getUnitId(),r=n.getActiveSheet().getSheetId();if(!t)return;const{startRow:s,startColumn:a,endRow:c,endColumn:d}=t.getDataRange(),u=c-s+1,h=d-a+1,m=Array.from({length:o.endRow-o.startRow+1},()=>Array.from({length:o.endColumn-o.startColumn+1},()=>({}))),g=[];m.forEach((S,p)=>{S.forEach((I,M)=>{const b=p%u+s,T=M%h+a,w=t.getValue(b,T);w&&(m[p][M].s=w)})}),e.forEach(S=>{const p={startRow:S.startRow-s,startColumn:S.startColumn-a,endRow:S.endRow-s,endColumn:S.endColumn-a},I=Math.max(1,Math.floor((o.endRow-o.startRow+1)/u)),M=Math.max(1,Math.floor((o.endColumn-o.startColumn+1)/h));for(let b=0;b<I;b++)for(let T=0;T<M;T++)g.push({startRow:p.startRow+b*u+o.startRow,startColumn:p.startColumn+T*h+o.startColumn,endRow:p.endRow+b*u+o.startRow,endColumn:p.endColumn+T*h+o.startColumn})});const f={subUnitId:r,unitId:i,styleRange:o,styleValues:m,mergeRanges:g};await this._commandService.executeCommand(Ur.id,f)}};Hn=f_([l.OnLifecycle(l.LifecycleStages.Rendered,Hn),Sn(0,l.ICommandService),Sn(1,ft),Sn(2,l.IUniverInstanceService),Sn(3,Ne)],Hn);var __=Object.defineProperty,S_=Object.getOwnPropertyDescriptor,p_=(o,t,e,n)=>{for(var i=n>1?void 0:n?S_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&__(t,e,i),i},pn=(o,t)=>(e,n)=>t(e,n,o),Cn;exports.UniverSheetsUIPlugin=(Cn=class extends l.Plugin{constructor(t,e,n,i,r){super(),this._injector=e,this._localeService=n,this._renderManagerService=i,this._univerInstanceService=r,this._localeService.load({zhCN:Yr})}onStarting(t){[[Kt],[Ee,{useClass:exports.EditorBridgeService}],[Ot,{useClass:exports.SheetClipboardService}],[Pt,{useClass:bu}],[ft,{useClass:xo}],[rn,{useClass:Xr}],[eo,{useClass:zc}],[yt,{useClass:exports.AutoFillService}],[ot],[exports.SheetSkeletonManagerService],[Ne,{useClass:exports.SelectionRenderService}],[di,{useClass:Ym}],[tn,{useClass:exports.MarkSelectionService}],[exports.HoverManagerService],[exports.SheetCanvasPopManagerService],[exports.CellAlertManagerService],[Mn],[exports.AutoHeightController],[wn],[En],[Fn],[bn],[exports.SheetRenderController],[xn],[yn],[Nn],[Tn],[exports.AutoFillController],[Hn]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused(),this._registerRenderControllers()}_registerRenderControllers(){[exports.SheetCanvasView,Ho,Wo,Fn,ko,Vo,Bn,exports.SheetsScrollRenderController,Ao,Po,An,Pn,Fo,exports.HoverRenderController,Dn,exports.CellCustomRenderController,$o,zo].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderController(l.UniverInstanceType.UNIVER_SHEET,t))})}_markSheetAsFocused(){const t=this._univerInstanceService;t.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(Ds.filter(e=>!!e)).subscribe(e=>{t.focusUnit(e.getUnitId())})}},R(Cn,"pluginName","SHEET_UI_PLUGIN_NAME"),R(Cn,"type",l.UniverInstanceType.UNIVER_SHEET),Cn);exports.UniverSheetsUIPlugin=p_([pn(1,P.Inject(P.Injector)),pn(2,P.Inject(l.LocaleService)),pn(3,y.IRenderManagerService),pn(4,l.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=oe;exports.AutoFillCommand=Un;exports.COPY_TYPE=Je;exports.CellAlertType=bt;exports.CellEditorManagerService=Xr;exports.DATA_TYPE=ue;exports.ExpandSelectionCommand=Ae;exports.IAutoFillService=yt;exports.ICellEditorManagerService=rn;exports.IEditorBridgeService=Ee;exports.IFormulaEditorManagerService=eo;exports.IMarkSelectionService=tn;exports.ISelectionRenderService=Ne;exports.ISheetClipboardService=Ot;exports.JumpOver=Fe;exports.MoveSelectionCommand=we;exports.PASTE_SPECIAL_MENU_ID=Dt;exports.PREDEFINED_HOOK_NAME=fe;exports.ResetScrollCommand=pl;exports.SHEET_UI_PLUGIN_NAME=Ps;exports.SHEET_VIEW_KEY=ie;exports.ScrollCommand=dt;exports.ScrollToCellCommand=Or;exports.SelectionShape=Vn;exports.SetCellEditVisibleArrowOperation=qt;exports.SetCellEditVisibleOperation=Te;exports.SetScrollOperation=nt;exports.SetScrollRelativeCommand=Xt;exports.SetZoomRatioOperation=ke;exports.SheetCopyCommand=Cr;exports.SheetPasteCommand=xt;exports.VIEWPORT_KEY=W;exports.deriveStateFromActiveSheet$=_e;exports.enUS=Fc;exports.expandToContinuousRange=Tr;exports.getAutoFillRepeatRange=Gs;exports.getCoordByCell=Oo;exports.getCoordByOffset=Et;exports.getEditorObject=Xn;exports.getRepeatRange=$a;exports.getSheetObject=it;exports.getTransformCoord=Rn;exports.mergeSetRangeValues=Eo;exports.rangeToDiscreteRange=Rt;exports.ruRU=$c;exports.useActiveWorkbook=Vc;exports.useActiveWorksheet=Bc;exports.virtualizeDiscreteRanges=en;exports.whenFormulaEditorActivated=la;exports.whenSheetEditorFocused=ne;exports.zhCN=Yr;
19
+ `)}]}}var id=Object.defineProperty,rd=Object.getOwnPropertyDescriptor,sd=(o,t,e,n)=>{for(var i=n>1?void 0:n?rd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&id(t,e,i),i},Ue=(o,t)=>(e,n)=>t(e,n,o);let wn=class extends l.RxDisposable{constructor(o,t,e,n,i,r,s,a,c,u){var d;super(),this._injector=o,this._currentUniverSheet=t,this._commandService=e,this._contextService=n,this._configService=i,this._sheetClipboardService=r,this._messageService=s,this._sheetSkeletonManagerService=a,this._localService=c,this._textSelectionRenderManager=u,this._init(),(d=this._textSelectionRenderManager)==null||d.onPaste$.pipe(U.takeUntil(this.dispose$)).subscribe(h=>{var _,p;if(!ne(this._contextService))return;h.event.preventDefault();const m=h.event,g=(_=m.clipboardData)==null?void 0:_.getData("text/html"),f=(p=m.clipboardData)==null?void 0:p.getData("text/plain");this._sheetClipboardService.legacyPaste(g,f)})}_init(){[Ir,sl,xt].forEach(t=>this.disposeWithMe(this._commandService.registerMultipleCommand(t))),[Rr,Mr,br,Tr].forEach(t=>this.disposeWithMe(this._commandService.registerCommand(t))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const o=this._initSpecialPasteHooks().map(t=>this._sheetClipboardService.addClipboardHook(t));this.disposeWithMe({dispose:()=>o.forEach(t=>t.dispose())})}_initCopyingHooks(){const o=this;let t=null;return{id:fe.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(e,n){t=o._getWorksheet(e,n)},onCopyCellContent(e,n){var s,a,c,u;const i=t.getCell(e,n);return(a=(s=i==null?void 0:i.p)==null?void 0:s.body)!=null&&a.paragraphs||(u=(c=i==null?void 0:i.p)==null?void 0:c.body)!=null&&u.textRuns?l.convertBodyToHtml(i.p.body):i?l.extractPureTextFromCell(i):""},onCopyCellStyle:(e,n,i,r)=>{const s={};(i||r)&&(s.rowspan=`${i||1}`,s.colspan=`${r||1}`);const a=t.getRange(e,n),c=t.getMergedCell(e,n),u=a.getTextStyle();let d="";if(u&&(d=l.handleStyleToString(u)),c){const h=c.endRow,m=c.endColumn,f=t.getRange(h,m).getTextStyle();if(f){const _=l.handleStyleToString(f);d?d+=_?`;${_}`:"":d=_}}return d&&(s.style=d),s},onCopyColumn(e){return{width:`${t.getColumnWidth(e)}`}},onCopyRow(e){return{style:`height: ${t.getRowHeight(e)}px;`}},onAfterCopy(){t=null},getFilteredOutRows(e){var a;const{startRow:n,endRow:i}=e,r=(a=o._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getActiveSheet(),s=[];if(!r)return s;for(let c=n;c<=i;c++)r.getRowFiltered(c)&&s.push(c);return s}}}_initPastingHook(){const o=this;let t=null,e=null,n=null;return{id:fe.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste({unitId:i,subUnitId:r,range:s}){n=o._getWorksheet(i,r),t=i,e=r;const a=o._configService.getConfig(S.MAX_CELL_PER_SHEET_KEY),c=s.rows[s.rows.length-1],u=s.cols[s.cols.length-1];return a&&c*u>a?(o._messageService.show({type:re.MessageType.Error,content:o._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(i,r){const{range:s}=i,a=[],c=[],u=n.getMaxRows(),d=s.rows[s.rows.length-1]-u,h=r.length-d,m=n.getRowManager();if(d>0){const p={};r.slice(h).forEach((M,b)=>{const{style:T,height:w}=M||{};if(T){const y=T.split(";");let O=l.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const A=I.textTrim(x.substr(0,x.indexOf(":"))),F=I.textTrim(x.substr(x.indexOf(":")+1));return A==="height"?(F.endsWith("pt")?O=E.ptToPx(Number.parseFloat(F)):O=Number.parseFloat(F),!0):!1}),p[b]={h:O,hd:l.BooleanNumber.FALSE}}else w&&(p[b]={h:Number.parseFloat(w),hd:l.BooleanNumber.FALSE})});const v={unitId:t,subUnitId:e,range:{startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1],endRow:s.rows[s.rows.length-1],startRow:u},rowInfo:p};a.push({id:S.InsertRowMutation.id,params:v})}const g={},f={};r.slice(0,h).forEach((p,v)=>{var T,w;const{style:M,height:b}=p;if(M){const y=M.split(";");let O=l.DEFAULT_WORKSHEET_ROW_HEIGHT;y.find(x=>{x=x.toLowerCase();const A=I.textTrim(x.substr(0,x.indexOf(":"))),F=I.textTrim(x.substr(x.indexOf(":")+1));return A==="height"?(F.endsWith("pt")?O=E.ptToPx(Number.parseFloat(F)):O=Number.parseFloat(F),!0):!1}),g[v+s.rows[0]]=O}else if(b){const y=m.getRow(s.rows[0]+v),O=Number.parseFloat(b);if(y){const{h:x=l.DEFAULT_WORKSHEET_ROW_HEIGHT,ah:A=0}=y,F=Math.max(x,A);O>F&&(g[v+s.rows[0]]=O,f[v+s.rows[0]]=F)}else g[v+s.rows[0]]=O,f[v+s.rows[0]]=(w=(T=m.getRow(s.rows[0]+v))==null?void 0:T.h)!=null?w:l.DEFAULT_WORKSHEET_ROW_HEIGHT}});const _={unitId:t,subUnitId:e,ranges:[{startRow:s.rows[0],endRow:Math.min(s.rows[s.rows.length-1],u),startColumn:s.cols[0],endColumn:s.cols[s.cols.length-1]}],rowHeight:g};return a.push({id:S.SetWorksheetRowHeightMutation.id,params:_}),c.push({id:S.SetWorksheetRowHeightMutation.id,params:{..._,rowHeight:20}}),{redos:a,undos:c}},onPasteColumns(i,r,s){var f;const{range:a}=i,c=[],u=n.getMaxColumns(),d=a.cols[a.cols.length-1]-u,h=r.length-d,m=(f=o._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?f:l.DEFAULT_WORKSHEET_COLUMN_WIDTH;if(d>0){const _={unitId:t,subUnitId:e,range:{startRow:a.rows[0],endRow:a.rows[a.rows.length-1],endColumn:a.cols[a.cols.length-1],startColumn:u},colInfo:r.slice(h).map(p=>({w:p.width?+p.width:m,hd:l.BooleanNumber.FALSE}))};c.push({id:S.InsertColMutation.id,params:_})}const g={unitId:t,subUnitId:e,ranges:[{startRow:a.rows[0],endRow:a.rows[a.rows.length-1],startColumn:a.cols[0],endColumn:Math.min(a.cols[a.cols.length-1],u)}],colWidth:r.slice(0,h).map(_=>_.width?+_.width:m)};return c.push({id:S.SetWorksheetColWidthMutation.id,params:g}),{redos:c,undos:[]}},onPastePlainText(i,r,s){return o._onPastePlainText(i,r,s)},onPasteCells(i,r,s,a){return o._onPasteCells(i,r,s,a)},onAfterPaste(i){n=null}}}_generateDocumentDataModelSnapshot(o){var s;const t=this._sheetSkeletonManagerService.getCurrent();if(t==null)return null;const{skeleton:e}=t,n=(s=e.getBlankCellDocumentModel())==null?void 0:s.documentModel,r={...n==null?void 0:n.getSnapshot(),...o};return n==null||n.reset(r),n==null?void 0:n.getSnapshot()}_onPastePlainText(o,t,e){const{range:n,unitId:i,subUnitId:r}=o;let s;if(/\r|\n/.test(t)){const c=od(t),u=this._generateDocumentDataModelSnapshot({body:c});s={[n.rows[0]]:{[n.cols[0]]:{p:u}}}}else l.isFormulaString(t)?s={[n.rows[0]]:{[n.cols[0]]:{f:t}}}:s={[n.rows[0]]:{[n.cols[0]]:{v:t}}};const a={unitId:i,subUnitId:r,cellValue:s};return{redos:[{id:S.SetRangeValuesMutation.id,params:a}],undos:[{id:S.SetRangeValuesMutation.id,params:S.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}_onPasteCells(o,t,e,n){const i={get:this._injector.get.bind(this._injector)};return td(o,t,e,n,i)}_initSpecialPasteHooks(){const o={get:this._injector.get.bind(this._injector)},t=this,e={id:fe.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c)=>qr(a,s,c,o)},n={id:fe.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c){const u=[],d=[],{undos:h,redos:m}=Jr(a,c,o);u.push(...m),d.push(...h);const{undos:g,redos:f}=Do(a,c,o);u.push(...f),d.push(...g);const{undos:_,redos:p}=Qr(a,c,o);return u.push(...p),d.push(..._),{undos:d,redos:u}}},i={id:fe.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){var T;const u=t._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=u.getUnitId(),h=u.getActiveSheet().getSheetId(),m=[],g=t._getWorksheet(d,h),{range:f}=s,_=g.getMaxColumns(),p=f.cols[f.cols.length-1]-_,v=a.length-p,M=(T=t._configService.getConfig(l.DEFAULT_WORKSHEET_COLUMN_WIDTH_KEY))!=null?T:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,b={unitId:d,subUnitId:h,ranges:[{startRow:f.rows[0],endRow:Math.min(f.cols[f.cols.length-1],_),startColumn:f.cols[0],endColumn:f.cols[f.cols.length-1]}],colWidth:a.slice(0,v).map(w=>w.width?+w.width:M)};return m.push({id:S.SetWorksheetColWidthMutation.id,params:b}),m.push({id:S.SetWorksheetColWidthMutation.id,params:b}),{redos:m,undos:[]}}},r={id:fe.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,u){t._currentUniverSheet.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);const d=[],h=[],{range:m,unitId:g,subUnitId:f}=a,_=new l.ObjectMatrix;c.forValue((T,w,y)=>{const O=y.s;typeof O=="object"&&_.setValue(m.rows[T],m.cols[w],{s:{...O,bd:void 0},v:y.v})});const p={unitId:g,subUnitId:f,cellValue:_.getData()};d.push({id:S.SetRangeValuesMutation.id,params:p});const v=S.SetRangeValuesUndoMutationFactory(o,p);h.push({id:S.SetRangeValuesMutation.id,params:v});const{undos:M,redos:b}=Do(a,c,o);return h.push(...M),d.push(...b),{redos:d,undos:h}}};return[e,n,i,r]}_getWorksheet(o,t){var n;const e=(n=this._currentUniverSheet.getUniverSheetInstance(o))==null?void 0:n.getSheetBySheetId(t);if(!e)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${o} and subUnitId ${t}.`);return e}};wn=sd([l.OnLifecycle(l.LifecycleStages.Steady,wn),Ue(0,D.Inject(D.Injector)),Ue(1,l.IUniverInstanceService),Ue(2,l.ICommandService),Ue(3,l.IContextService),Ue(4,l.IConfigService),Ue(5,Ot),Ue(6,I.IMessageService),Ue(7,D.Inject(exports.SheetSkeletonManagerService)),Ue(8,D.Inject(l.LocaleService)),Ue(9,D.Optional(E.ITextSelectionRenderManager))],wn);var ad=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,cd=(o,t,e,n)=>{for(var i=n>1?void 0:n?ld(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&ad(t,e,i),i},Xi=(o,t)=>(e,n)=>t(e,n,o);let En=class extends l.RxDisposable{constructor(o,t){super(),this._univerInstanceService=o,this._undoRedoService=t,this._initialize()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_DOC).pipe(U.takeUntil(this.dispose$)).subscribe(o=>{if(o==null)return;o.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const o={};this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(t=>{const e=t.getConfig();o[t.getSheetId()]={cellData:new l.ObjectMatrix(e.cellData),rowCount:e.rowCount,columnCount:e.columnCount,rowData:e.rowData,columnData:e.columnData}})}};En=cd([l.OnLifecycle(l.LifecycleStages.Rendered,En),Xi(0,l.IUniverInstanceService),Xi(1,D.Inject(l.IUndoRedoService))],En);const es=[I.KeyCode.ARROW_DOWN,I.KeyCode.ARROW_UP,I.KeyCode.ARROW_LEFT,I.KeyCode.ARROW_RIGHT],dd=[I.KeyCode.ENTER,I.KeyCode.TAB,...es];function ud(){const o=[];for(const t of es)o.push({id:Qt.id,binding:t,preconditions:e=>Zt(e),staticParameters:{visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:t,isShift:!1}}),o.push({id:Qt.id,binding:t|I.MetaKeys.SHIFT,preconditions:e=>Zt(e),staticParameters:{visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:t,isShift:!0}});return o}const hd={id:ti.id,binding:I.KeyCode.F2,description:"shortcut.sheet.start-editing",group:"4_sheet-edit",preconditions:ne,staticParameters:{visible:!0,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.F2}},md={id:Te.id,binding:I.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:o=>Zt(o),staticParameters:{visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ENTER}},gd={id:Te.id,binding:I.KeyCode.TAB,preconditions:o=>Zt(o),staticParameters:{visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.TAB}},fd={id:Te.id,binding:I.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:o=>Zt(o),staticParameters:{visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ESC}},_d={id:te.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:o=>ca(o),binding:I.KeyCode.ENTER|I.MetaKeys.ALT},Sd={id:te.DeleteLeftCommand.id,preconditions:o=>da(o)||Sr(o),binding:I.KeyCode.BACKSPACE},pd={id:Te.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:o=>ne(o)&&!Sr(o),binding:I.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.BACKSPACE}};function Cd(o){return o.startsWith("'")}function vd(o){return o.slice(1)}var Id=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Md=(o,t,e,n)=>{for(var i=n>1?void 0:n?Rd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Id(t,e,i),i},Ve=(o,t)=>(e,n)=>t(e,n,o);function bd(o){const{textRuns:t=[],paragraphs:e=[]}=o;return t.some(n=>n.ts&&!l.Tools.isEmptyObject(n.ts))||e.some(n=>n.bullet)||e.length>=2}let yn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c,u,d){super();R(this,"_cursorChangeObservers");R(this,"_editorVisiblePrevious",!1);R(this,"_cursorChange",0);this._univerInstanceService=t,this._renderManagerService=e,this._commandService=n,this._editorBridgeService=i,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._selectionManagerService=u,this._editorService=d,this._initialize(),this._commandExecutedListener()}dispose(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;e.onPointerDownObserver.remove(this._cursorChangeObservers),super.dispose()}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(async t=>{const{visible:e,keycode:n,eventType:i}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!0){this._cursorChange=i===E.DeviceInputEventType.PointerDown?2:1;return}this._cursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:u}=s;if(this._exitInput(t),n===I.KeyCode.ESC){r&&this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:u,selections:r});return}const d=this._editorBridgeService.getEditCellState();if(d==null)return;const{unitId:h,sheetId:m,row:g,column:f,documentLayoutObject:_}=d;if(this._editorBridgeService.getEditorDirty()===!1){this._moveCursor(n);return}const v=this._univerInstanceService.getUniverSheetInstance(h),M=v==null?void 0:v.getSheetBySheetId(m);if(M==null)return;const b=Td(M.getCellRaw(g,f)||{},_,this._lexerTreeBuilder);if(b==null){this._moveCursor(n);return}const T={subUnitId:m,unitId:h,workbook:v,worksheet:M,row:g,col:f};a===h&&m!==c&&this._editorBridgeService.isForceKeepVisible()&&await this._commandService.executeCommand(S.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h}),this._selectionManagerService.refreshSelection();const w=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(b,T),y=await this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT_ASYNC)(Promise.resolve(w),T);this._commandService.executeCommand(S.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:g,startColumn:f,endRow:g,endColumn:f},value:y}),this._moveCursor(n)}))}_exitInput(t){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.EDITOR_ACTIVATED,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:t.visible});const e=this._editorBridgeService.getCurrentEditorId();e==null||!this._editorService.isSheetEditor(e)||(this._undoRedoService.clearUndoRedo(e),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(t){if(t==null||!dd.includes(t))return;let e=l.Direction.LEFT;switch(t){case I.KeyCode.ENTER:e=l.Direction.DOWN;break;case I.KeyCode.TAB:e=l.Direction.RIGHT;break;case I.KeyCode.ARROW_DOWN:e=l.Direction.DOWN;break;case I.KeyCode.ARROW_UP:e=l.Direction.UP;break;case I.KeyCode.ARROW_LEFT:e=l.Direction.LEFT;break;case I.KeyCode.ARROW_RIGHT:e=l.Direction.RIGHT;break}t===I.KeyCode.ENTER||t===I.KeyCode.TAB?this._commandService.executeCommand(gt.id,{keycode:t,direction:e}):this._commandService.executeCommand(we.id,{direction:e})}_cursorStateListener(){const t=this._getEditorObject();if(t==null)return;const{document:e}=t;this.disposeWithMe(l.toDisposable(e.onPointerDownObserver.add(()=>{this._cursorChange===1&&(this._cursorChange=2)})))}_commandExecutedListener(){const t=[Qt.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=e.params,{keycode:i,isShift:r}=n;if(i!=null&&(this._cursorChange===2||this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR))){this._moveInEditor(i,r);return}this._editorBridgeService.changeVisible(n)}e.id===ti.id&&(this._cursorChange=2)}))}_moveInEditor(t,e){let n=l.Direction.LEFT;t===I.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:t===I.KeyCode.ARROW_UP?n=l.Direction.UP:t===I.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),e?this._commandService.executeCommand(te.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(te.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return Gn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};yn=Md([l.OnLifecycle(l.LifecycleStages.Rendered,yn),Ve(0,l.IUniverInstanceService),Ve(1,E.IRenderManagerService),Ve(2,l.ICommandService),Ve(3,Ee),Ve(4,l.IContextService),Ve(5,sn),Ve(6,D.Inject(Z.LexerTreeBuilder)),Ve(7,l.IUndoRedoService),Ve(8,D.Inject(S.SelectionManagerService)),Ve(9,I.IEditorService)],yn);function Td(o,t,e){o=l.Tools.deepClone(o);const{documentModel:n}=t;if(n==null)return null;const i=n.getSnapshot(),{body:r}=i;if(r==null)return null;o.t=void 0;const s=r.dataStream;let c=s.substring(s.length-2,s.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?s.substring(0,s.length-2):s;if(l.isFormulaString(c)){if(o.f===c)return null;const u=e.checkIfAddBracket(c);for(let d=0;d<u;d++)c+=Z.matchToken.CLOSE_BRACKET;o.f=c,o.v=null,o.p=null}else if(Cd(c)){const u=vd(c);o.v=u,o.f=null,o.si=null,o.p=null,o.t=l.CellValueType.FORCE_STRING}else if(bd(r))r.dataStream===`\r
20
+ `?(o.v="",o.f=null,o.si=null,o.p=null):(o.p=i,o.v=null,o.f=null,o.si=null);else{if((c===o.v||c===""&&o.v==null)&&o.p==null)return null;o.v=c,o.f=null,o.si=null,o.p=null}return o}var wd=Object.defineProperty,Ed=Object.getOwnPropertyDescriptor,yd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ed(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&wd(t,e,i),i},Be=(o,t)=>(e,n)=>t(e,n,o);let On=class extends l.RxDisposable{constructor(t,e,n,i,r,s,a,c,u,d){super();R(this,"_loadedMap",new WeakSet);R(this,"_scheduledCallback",-1);this._univerInstanceService=t,this._renderManagerService=e,this._editorBridgeService=n,this._commandService=i,this._contextService=r,this._formulaEditorManagerService=s,this._undoRedoService=a,this._docSkeletonManagerService=c,this._docViewModelManagerService=u,this._textSelectionManagerService=d,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._listenFoldBtnClick(),this._renderManagerService.currentRender$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{this._create(t)}),this._create(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._textSelectionManagerService.textSelection$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{if(t==null)return;const{unitId:e}=t;e!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_create(t){if(t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&(this._loadedMap.has(n)||(this._initialMain(t),this._loadedMap.add(n)))}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(U.takeUntil(this.dispose$)).subscribe(()=>{var e;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.EDITOR_ACTIVATED)){this._univerInstanceService.setCurrentUnitForType(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:E.DeviceInputEventType.PointerDown});const r=(e=n==null?void 0:n.getBody())==null?void 0:e.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(te.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_listenFoldBtnClick(){this._formulaEditorManagerService.foldBtnStatus$.pipe(U.takeUntil(this.dispose$)).subscribe(()=>{this._textSelectionManagerService.refreshSelection()})}_initialMain(t){const e=this._renderManagerService.getRenderById(t);if(e==null)return;const{mainComponent:n}=e;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:E.DeviceInputEventType.Dblclick})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{if(!t)return this._clearScheduledCallback();const e=Gn(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||n==null)return this._clearScheduledCallback();const{width:i,height:r}=t;if(i===0||r===0)return this._clearScheduledCallback();const{engine:s}=e;n.updateDocumentDataPageSize(i),this._autoScroll(),this._scheduledCallback=requestIdleCallback(()=>s.resizeBySize(i,r))})}_clearScheduledCallback(){this._scheduledCallback!==-1&&cancelIdleCallback(this._scheduledCallback),this._scheduledCallback=-1}_syncFormulaEditorContent(){this._editorBridgeService.currentEditCellState$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{t==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(t)}),this._editorBridgeService.visible$.pipe(U.takeUntil(this.dispose$)).subscribe(t=>{if(t==null||t.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const e=this._editorBridgeService.getLatestEditCellState();e!=null&&this._editorSyncHandler(e)})}_editorSyncHandler(t){var s;const e=(s=t.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=e==null?void 0:e.dataStream,i=e==null?void 0:e.paragraphs,r=[];n==null||i==null||(t.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===E.DeviceInputEventType.Dblclick?(n=`\r
21
+ `,i=[{startIndex:0}]):t.isInArrayFormulaRange===!0&&(r=(e==null?void 0:e.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,i,r),this._autoScroll())}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,I.SetEditorResizeOperation.id],e=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var r,s;if(t.includes(i.id)){const a=i.params,{unitId:c}=a;if(e.includes(c)){const u=this._univerInstanceService.getUniverDocInstance(c),d=(r=u==null?void 0:u.getBody())==null?void 0:r.dataStream,h=(s=u==null?void 0:u.getBody())==null?void 0:s.paragraphs,m=c===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(d==null||h==null)return;this._syncContentAndRender(m,d,h),this._autoScroll()}}}));const n=[S.SetRangeValuesMutation.id,S.MoveRangeMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var r,s,a,c,u;if(n.includes(i.id)){const d=this._editorBridgeService.getLatestEditCellState();if(d==null)return;let h=!1;const{row:m,column:g}=d;if(i.id===S.SetRangeValuesMutation.id&&i.params?(s=(r=i.params.cellValue)==null?void 0:r[m])!=null&&s[g]&&(h=!0):i.id===S.MoveRangeMutation.id&&i.params&&(c=(a=i.params.to.value)==null?void 0:a[m])!=null&&c[g]&&(h=!0),h){const f=(u=d.documentLayoutObject.documentModel)==null?void 0:u.getBody();if(f==null)return;const{dataStream:_,paragraphs:p=[]}=f;this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,_,p),this._autoScroll()}}}))}_syncContentAndRender(t,e,n,i=[]){var h;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(t),a=this._univerInstanceService.getUniverDocInstance(t),c=this._docViewModelManagerService.getViewModel(t);if(a==null||c==null||s==null)return;a.getBody().dataStream=e,a.getBody().paragraphs=this._clearParagraph(n),t===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),i.length>0&&(a.getBody().textRuns=i),c.reset(a);const{skeleton:u}=s,d=this._renderManagerService.getRenderById(t);d!=null&&(u.calculate(),r.includes(t)&&((h=d.mainComponent)==null||h.makeDirty()))}_clearParagraph(t){const e=l.Tools.deepClone(t);for(const n of e)n.paragraphStyle&&(n.paragraphStyle.horizontalAlign=l.HorizontalAlign.UNSPECIFIED);return e}_autoScroll(){var f,_;const t=(f=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:f.skeleton,e=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),i=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||e==null||n==null||i==null)return;const{marginTop:r=0,marginBottom:s=0}=i.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:u}=t.getActualSize();u+=r+s;const{width:d,height:h}=e,m=a.getViewport(te.VIEWPORT_KEY.VIEW_MAIN);let g=m==null?void 0:m.getScrollBar();a.transformByState({width:d,height:u}),c==null||c.resize(d,u),u>h?g==null?m&&new E.ScrollBar(m,{enableHorizontal:!1,barSize:8}):m==null||m.resetSizeAndScrollBar():(g=null,m==null||m.scrollTo({x:0,y:0}),(_=m==null?void 0:m.getScrollBar())==null||_.dispose())}};On=yd([l.OnLifecycle(l.LifecycleStages.Steady,On),Be(0,l.IUniverInstanceService),Be(1,E.IRenderManagerService),Be(2,Ee),Be(3,l.ICommandService),Be(4,l.IContextService),Be(5,to),Be(6,l.IUndoRedoService),Be(7,D.Inject(te.DocSkeletonManagerService)),Be(8,D.Inject(te.DocViewModelManagerService)),Be(9,D.Inject(te.TextSelectionManagerService))],On);const Od="36",xd="univer-sheet-container",ts={sheetFooterBarHeight:Od,sheetContainer:xd};var Nd=Object.defineProperty,Ad=Object.getOwnPropertyDescriptor,Dd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ad(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Nd(t,e,i),i},Ie=(o,t)=>(e,n)=>t(e,n,o);const Gi=-1e3,Zi=5,Pd=2;let xn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c,u,d,h,m){super();R(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=t,this._docViewModelManagerService=e,this._contextService=n,this._univerInstanceService=i,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=u,this._commandService=d,this._localService=h,this._editorService=m,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const t=this._getEditorObject();t!=null&&this.disposeWithMe(l.toDisposable(t.document.onPointerDownObserver.add(()=>{var e;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getEditCellState(),i=this._editorBridgeService.getCurrentEditorId();if(n==null||i==null||!this._editorService.isSheetEditor(i))return;const r=(e=this._docSkeletonManagerService.getSkeletonByUnitId(i))==null?void 0:e.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:u,scaleY:d}=n;this._fitTextSize(s,c,r,a,u,d)}})))}_initialCursorSync(){this.disposeWithMe(this._cellEditorManagerService.focus$.pipe(U.filter(t=>!!t)).subscribe(()=>{this._textSelectionRenderManager.sync()}))}_initialEditFocusListener(){this.disposeWithMe(this._editorBridgeService.currentEditCellState$.subscribe(t=>{if(t==null||this._editorBridgeService.isForceKeepVisible())return;const{position:e,documentLayoutObject:n,scaleX:i,editorUnitId:r}=t;if(this._getEditorObject()==null||this._contextService.getContextValue(l.FOCUSING_EDITOR_STANDALONE)===!0||this._contextService.getContextValue(l.FOCUSING_UNIVER_EDITOR_STANDALONE_SINGLE_MODE)===!0)return;const{startX:a,endX:c}=e,{textRotation:u,wrapStrategy:d,documentModel:h}=n,{vertexAngle:m}=E.convertTextRotation(u);h.updateDocumentId(r),d===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/i),this._univerInstanceService.changeDoc(r,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Gi,Gi)}))}_fitTextSize(t,e,n,i,r=1,s=1){const{startX:a,startY:c,endX:u,endY:d}=t,h=i.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:g}=this._predictingSize(t,e,n,i,r,s),{verticalAlign:f,paddingData:_,fill:p}=i;let v=u-a,M=d-c;if(v<m&&(v=m),M<g)M=g,h.updateDocumentDataMargin(_);else{let b=0;f===l.VerticalAlign.MIDDLE?b=(M-g)/2/s:f===l.VerticalAlign.TOP?b=_.t||0:b=(M-g)/s-(_.b||0),b=b<(_.t||0)?_.t||0:b,h.updateDocumentDataMargin({t:b})}n.calculate(),this._editAreaProcessing(v,M,t,e,p,r,s)}_predictingSize(t,e,n,i,r=1,s=1){const{startX:a,endX:c}=t,{textRotation:u,wrapStrategy:d}=i,h=i.documentModel,{vertexAngle:m}=E.convertTextRotation(u),g=document.body.clientWidth;if(d===l.WrapStrategy.WRAP&&m===0){const{actualWidth:p,actualHeight:v}=n.getActualSize();return{actualWidth:p*r,actualHeight:v*s}}h==null||h.updateDocumentDataPageSize((g-a-e.left)/r),n.calculate();const f=n.getActualSize();let _=c-a;return _<f.actualWidth*r+Zi*r&&(_=f.actualWidth*r+Zi*r),h==null||h.updateDocumentDataPageSize(_/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED,cellValueType:void 0}),{actualWidth:_,actualHeight:f.actualHeight*s}}_editAreaProcessing(t,e,n,i,r,s=1,a=1){var w;const c=this._getEditorObject();if(c==null)return;let{startX:u,startY:d}=n;const{document:h,scene:m,engine:g}=c,f=m.getViewport(te.VIEWPORT_KEY.VIEW_MAIN),_=document.body.clientHeight-d-Number.parseFloat(ts.sheetFooterBarHeight)-i.top-Pd*2,p=document.body.clientWidth-u-i.left;let v=e,M=f==null?void 0:f.getScrollBar();v>_?(v=_,M==null?f&&new E.ScrollBar(f,{enableHorizontal:!1,barSize:8}):f==null||f.resetSizeAndScrollBar()):(M=null,(w=f==null?void 0:f.getScrollBar())==null||w.dispose()),t+=(M==null?void 0:M.barSize)||0,t>p&&(t=p),u-=E.FIX_ONE_PIXEL_BLUR_OFFSET,d-=E.FIX_ONE_PIXEL_BLUR_OFFSET,this._addBackground(m,t/s,e/a,r);const{scaleX:b,scaleY:T}=m.getPrecisionScale();m.transformByState({width:t/s,height:e/a,scaleX:s,scaleY:a}),h.resize(t/s,e/a),requestIdleCallback(()=>{g.resizeBySize(E.fixLineWidthByScale(t,b),E.fixLineWidthByScale(v,T))}),this._cellEditorManagerService.setState({startX:u,startY:d,endX:t+u,endY:v+d,show:!0})}_addBackground(t,e,n,i){const r="_backgroundRectHelperColor_",s=t.getObject(r);s==null&&i==null||(s==null?t.addObjects([new E.Rect(r,{width:e,height:n,fill:i,evented:!1})],te.DOCS_COMPONENT_MAIN_LAYER_INDEX):i==null?s.dispose():(s.setProps({fill:i}),s.transformByState({width:e,height:n})))}_initialStartEdit(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(t=>{var w,y;const{visible:e,eventType:n,keycode:i}=t;if(e===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=e,e===!1){this._setOpenForCurrent(null,null);return}const r=this._editorBridgeService.getEditCellState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:u,scaleY:d,editorUnitId:h,unitId:m,sheetId:g,isInArrayFormulaRange:f=!1}=r,_=this._getEditorObject();if(_==null)return;this._setOpenForCurrent(m,g);const{document:p,scene:v}=_;this._contextService.setContextValue(l.EDITOR_ACTIVATED,!0);const{documentModel:M}=a,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||M==null)return;const{skeleton:T}=b;if(this._fitTextSize(s,c,T,a,u,d),n===E.DeviceInputEventType.Keyboard||n===E.DeviceInputEventType.Dblclick&&f){const O=l.Tools.deepClone(M.snapshot),x=this._docViewModelManagerService.getViewModel(h);if(x==null)return;this._resetBodyStyle(O.body,!!f),M.reset(O),x.reset(M),p.makeDirty(),(i===I.KeyCode.BACKSPACE||n===E.DeviceInputEventType.Dblclick)&&(T.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===E.DeviceInputEventType.Dblclick){const O=M.getBody().dataStream.length-2||0;(w=v.getViewport(te.VIEWPORT_KEY.VIEW_MAIN))==null||w.scrollTo({y:Number.POSITIVE_INFINITY}),this._textSelectionManagerService.replaceTextRanges([{startOffset:O,endOffset:O}])}(y=this._renderManagerService.getRenderById(m))==null||y.scene.resetCursor()}))}_resetBodyStyle(t,e=!1){t.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,t.textRuns!=null&&(t.textRuns.length===1&&!e?(t.textRuns[0].st=0,t.textRuns[0].ed=1):t.textRuns=void 0),t.paragraphs!=null&&(t.paragraphs.length===1?t.paragraphs[0].startIndex=0:t.paragraphs=[{startIndex:0}]),t.sectionBreaks!=null&&(t.sectionBreaks=void 0),t.tables!=null&&(t.tables=void 0),t.customRanges!=null&&(t.customRanges=void 0),t.customBlocks!=null&&(t.customBlocks=void 0)}_initialKeyboardListener(){this.disposeWithMe(this._textSelectionRenderManager.onInputBefore$.subscribe(t=>{const e=this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR),n=this._contextService.getContextValue(l.FOCUSING_SHEET),i=this._univerInstanceService.getCurrentUniverDocInstance().getUnitId();n&&!e&&this._editorService.isSheetEditor(i)&&this._showEditorByKeyboard(t)}))}_showEditorByKeyboard(t){if(t==null)return;const e=t.event;this._commandService.executeCommand(Te.id,{visible:!0,eventType:E.DeviceInputEventType.Keyboard,keycode:e.which})}_commandExecutedListener(){const t=[te.RichTextEditingMutation.id,I.SetEditorResizeOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var n;if(t.includes(e.id)){const i=e.params,{unitId:r}=i;if(!this._editorService.isSheetEditor(r))return;const s=this._editorBridgeService.getCurrentEditorId();if(s==null)return;this._editorBridgeService.changeEditorDirty(!0);const a=(n=this._docSkeletonManagerService.getSkeletonByUnitId(s))==null?void 0:n.skeleton;if(a==null)return;const c=this._editorBridgeService.getEditCellState();if(c==null)return;const{position:u,documentLayoutObject:d,canvasOffset:h,scaleX:m,scaleY:g}=c;this._fitTextSize(u,h,a,d,m,g)}}))}_setOpenForCurrent(t,e){const n=this._editorService.getAllEditor();for(const[i,r]of n)r.isSheetEditor()&&(r.setOpenForSheetUnitId(t),r.setOpenForSheetSubUnitId(e))}_getEditorObject(){return Gn(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};xn=Dd([l.OnLifecycle(l.LifecycleStages.Rendered,xn),Ie(0,D.Inject(te.DocSkeletonManagerService)),Ie(1,D.Inject(te.DocViewModelManagerService)),Ie(2,l.IContextService),Ie(3,l.IUniverInstanceService),Ie(4,E.IRenderManagerService),Ie(5,Ee),Ie(6,sn),Ie(7,E.ITextSelectionRenderManager),Ie(8,D.Inject(te.TextSelectionManagerService)),Ie(9,l.ICommandService),Ie(10,D.Inject(l.LocaleService)),Ie(11,I.IEditorService)],xn);var Hd=Object.defineProperty,Ld=Object.getOwnPropertyDescriptor,Ud=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ld(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Hd(t,e,i),i},Vd=(o,t)=>(e,n)=>t(e,n,o);let Po=class extends l.Disposable{constructor(o,t){super(),this._context=o,this._formatPainterService=t,this._initialize()}_initialize(){this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this.disposeWithMe(l.toDisposable(this._formatPainterService.status$.subscribe(o=>{const t=this._context.scene;t&&(o!==xe.OFF?t.setDefaultCursor(E.CURSOR_TYPE.CELL):t.setDefaultCursor(E.CURSOR_TYPE.DEFAULT))})))}};Po=Ud([Vd(1,ft)],Po);var Bd=Object.defineProperty,Fd=Object.getOwnPropertyDescriptor,kd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Fd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Bd(t,e,i),i},st=(o,t)=>(e,n)=>t(e,n,o);const Wd="__SpreadsheetFreezeRowMainName__",jd="__SpreadsheetFreezeRowHeaderName__",$d="__SpreadsheetFreezeColumnMainName__",zd="__SpreadsheetFreezeColumnHeaderName__",go=4,Yd=.01;let Wn=class extends l.Disposable{constructor(t,e,n,i,r,s,a,c){super();R(this,"_rowFreezeHeaderRect");R(this,"_rowFreezeMainRect");R(this,"_columnFreezeHeaderRect");R(this,"_columnFreezeMainRect");R(this,"_freezeDownObservers",[]);R(this,"_freezeMoveObservers",[]);R(this,"_freezeLeaveObservers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_changeToRow",-1);R(this,"_changeToColumn",-1);R(this,"_changeToOffsetX",0);R(this,"_changeToOffsetY",0);R(this,"_activeViewport",null);R(this,"_freezeNormalHeaderColor","");R(this,"_freezeNormalMainColor","");R(this,"_freezeActiveColor","");R(this,"_freezeHoverColor","");R(this,"_lastFreeze");this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionManagerService=i,this._scrollManagerService=r,this._themeService=s,this._sheetInterceptorService=a,this._injector=c,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(t=0,e){var O;const n=e!=null?e:this._getFreeze();if(n==null)return null;const i=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton,{startRow:r,startColumn:s}=n,a=this._getPositionByIndex(r,s);if(a==null)return null;const c=this._getSheetObject(),u=c.engine,d=(u==null?void 0:u.width)||0,h=(u==null?void 0:u.height)||0,m=c.scene,{startX:g,startY:f}=a,{rowTotalHeight:_,columnTotalWidth:p,rowHeaderWidthAndMarginLeft:v,columnHeaderHeightAndMarginTop:M}=i,b=d>p+v?d:p+M,T=h>_+M?h:_+M;this._changeToRow=r,this._changeToColumn=s,this._changeToOffsetX=g,this._changeToOffsetY=f;const w=Math.max(m.scaleX,m.scaleY),y=go/(w<1?1:w);if(t===0){const x=y;this._rowFreezeHeaderRect=new E.Rect(jd,{fill:this._freezeNormalHeaderColor,width:v,height:y,left:0,top:f-x,zIndex:3});let A=this._freezeNormalHeaderColor;(r===-1||r===0)&&(A=this._freezeNormalMainColor),this._rowFreezeMainRect=new E.Rect(Wd,{fill:A,width:b*2,height:y,left:v,top:f-x,zIndex:3}),m.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],nt)}else{const x=y;this._columnFreezeHeaderRect=new E.Rect(zd,{fill:this._freezeNormalHeaderColor,width:y,height:M,left:g-x,top:0,zIndex:3});let A=this._freezeNormalHeaderColor;(s===-1||s===0)&&(A=this._freezeNormalMainColor),this._columnFreezeMainRect=new E.Rect($d,{fill:A,width:y,height:T*2,left:g-x,top:M,zIndex:3}),m.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],nt)}this._eventBinding(t)}_eventBinding(t=0){let e=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;t===1&&(e=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const i=this._getSheetObject();if(i==null)return;const{scene:r}=i;this._freezeMoveObservers.push(e==null?void 0:e.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(E.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{e==null||e.setProps({fill:this._freezeHoverColor,zIndex:4}),r.setCursor(E.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(e==null?void 0:e.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{e==null||e.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(e==null?void 0:e.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._freezeDown(s,e,n,t)}))}_getCurrentLastVisibleRow(){var h,m,g,f;const t=this._getSheetObject();if(t==null)return;const e=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(e==null)return;const n=t.scene,i=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(t.engine.height-e.columnHeaderHeight)/i,a=(m=r==null?void 0:r.sheetViewStartRow)!=null?m:0,c=a===0?-((g=r==null?void 0:r.offsetY)!=null?g:0):e.rowHeightAccumulation[a-1]-((f=r==null?void 0:r.offsetY)!=null?f:0);let u=0,d=!1;for(let _=a,p=e.rowHeightAccumulation.length;_<p;_++)if(e.rowHeightAccumulation[_]-c>s){u=_,d=!0;break}return d||(u=e.rowHeightAccumulation.length-1),u}_getActiveViewport(t){var n;const e=(n=this._getSheetObject())==null?void 0:n.scene.getViewports();return e&&e.find(i=>i.isHit(new E.Vector2(t.offsetX,t.offsetY)))||null}_freezeDown(t,e,n,i=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(E.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),u=c===void 0?Number.POSITIVE_INFINITY:r.rowHeightAccumulation[c];this._activeViewport=null;const d=this._getFreeze();d&&(this._changeToColumn=d.startColumn,this._changeToRow=d.startRow),this._moveObserver=a.onPointerMoveObserver.add(m=>{var b,T,w,y;const g=this._getActiveViewport(m),{startX:f,startY:_,row:p,column:v}=Et(m.offsetX,m.offsetY,a,r,g||void 0,!0);a.setCursor(E.CURSOR_TYPE.GRABBING);const M=go/Math.max(a.scaleX,a.scaleY);i===0?((b=e.transformByState({top:Math.min(_,u)-M/2}))==null||b.setProps({fill:this._freezeActiveColor}),(T=n.transformByState({top:Math.min(_,u)-M/2}))==null||T.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=c===void 0?p:Math.min(p,c),this._changeToOffsetY=Math.min(_,u),this._activeViewport=g):((w=e.transformByState({left:f-M/2}))==null||w.setProps({fill:this._freezeActiveColor}),(y=n.transformByState({left:f-M/2}))==null||y.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=v,this._changeToOffsetX=f,this._activeViewport=g)}),this._upObserver=a.onPointerUpObserver.add(()=>{var x,A;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:g}=r;i===0&&(this._changeToRow===0||this._changeToRow===-1)||i===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(e.setProps({fill:this._freezeNormalHeaderColor}),n.setProps({fill:this._freezeNormalMainColor})):(e==null||e.setProps({fill:this._freezeNormalHeaderColor}),n==null||n.setProps({fill:this._freezeNormalHeaderColor}));const f=go/Math.max(a.scaleX,a.scaleY);i===0?(this._changeToRow===0||this._changeToRow===-1)&&(e.transformByState({top:g-f}),n.transformByState({top:g-f})):(this._changeToColumn===0||this._changeToColumn===-1)&&(e.transformByState({left:m-f}),n.transformByState({left:m-f}));const _=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:p,sheetViewStartColumn:v}=_;if(v==null||p==null)return;const M=this._context.unit,b=M.getActiveSheet(),T=(x=b.getConfig())==null?void 0:x.freeze;let w=(T==null?void 0:T.xSplit)||0,y=(T==null?void 0:T.ySplit)||0;const O=(A=this._activeViewport)==null?void 0:A.viewPortKey;i===0&&(!O||O===W.VIEW_LEFT_TOP||O===W.VIEW_MAIN_LEFT_TOP||O===W.VIEW_MAIN_TOP||O===W.VIEW_ROW_TOP?y=this._changeToRow-(T.startRow-T.ySplit):y=this._changeToRow-p,y=y<0?0:y),i===1&&(!O||O===W.VIEW_LEFT_TOP||O===W.VIEW_MAIN_LEFT_TOP||O===W.VIEW_MAIN_LEFT||O===W.VIEW_COLUMN_LEFT?w=this._changeToColumn-(T.startColumn-T.xSplit):w=this._changeToColumn-v,w=w<0?0:w),this._commandService.executeCommand(S.SetFrozenCommand.id,{startRow:y===0?-1:this._changeToRow,startColumn:w===0?-1:this._changeToColumn,ySplit:y,xSplit:w,unitId:M.getUnitId(),subUnitId:b.getSheetId()})})}_getViewports(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t,n=e.getViewport(W.VIEW_COLUMN_LEFT),i=e.getViewport(W.VIEW_COLUMN_RIGHT),r=e.getViewport(W.VIEW_ROW_TOP),s=e.getViewport(W.VIEW_ROW_BOTTOM),a=e.getViewport(W.VIEW_LEFT_TOP),c=e.getViewport(W.VIEW_MAIN),u=e.getViewport(W.VIEW_MAIN_LEFT_TOP),d=e.getViewport(W.VIEW_MAIN_LEFT),h=e.getViewport(W.VIEW_MAIN_TOP);if(!(n==null||i==null||r==null||s==null||a==null||c==null||u==null||d==null||h==null))return{viewMain:c,viewMainLeftTop:u,viewMainLeft:d,viewMainTop:h,viewColumnLeft:n,viewColumnRight:i,viewRowTop:r,viewRowBottom:s,viewLeftTop:a}}_bindViewportScroll(){const t=this._getViewports();if(!t)return;const{viewMain:e,viewRowBottom:n,viewColumnRight:i,viewMainLeft:r,viewMainTop:s}=t;this.disposeWithMe(e.onScrollAfterObserver.add(a=>{const{scrollX:c,scrollY:u,actualScrollX:d,actualScrollY:h}=a;n.isActive&&n.updateScroll({scrollY:u,actualScrollY:h}),i.isActive&&i.updateScroll({scrollX:c,actualScrollX:d}),r.isActive&&r.updateScroll({scrollY:u,actualScrollY:h}),s.isActive&&s.updateScroll({scrollX:c,actualScrollX:d})}))}_updateViewport(t=-1,e=-1,n=0,i=0,r=3){var O;const s=(O=this._sheetSkeletonManagerService.getCurrent())==null?void 0:O.skeleton;if(s==null)return;const{rowHeaderWidthAndMarginLeft:a,columnHeaderHeightAndMarginTop:c}=s,u=this._getViewports();if(!u)return;const{viewMain:d,viewMainLeftTop:h,viewMainLeft:m,viewMainTop:g,viewColumnLeft:f,viewColumnRight:_,viewRowTop:p,viewRowBottom:v,viewLeftTop:M}=u;_.resize({left:a,top:0,height:c,right:0}),v.resize({left:0,top:c,bottom:0,width:a}),M.resize({left:0,top:0,width:a,height:c});let b=!0,T=!0;h.enable(),(t===-1||t===0)&&(b=!1),(e===-1||e===0)&&(T=!1);const w=s.getNoMergeCellPositionByIndexWithNoHeader(t-n,e-i),y=s.getNoMergeCellPositionByIndexWithNoHeader(t,e);if(h.disable(),g.disable(),m.disable(),p.disable(),f.disable(),h.resetPadding(),g.resetPadding(),m.resetPadding(),p.resetPadding(),f.resetPadding(),b===!1&&T===!1)d.resize({left:a,top:c,bottom:0,right:0}),d.resetPadding();else if(b===!0&&T===!1){const x=y.startY-w.startY;d.resize({left:a,top:c+x,bottom:0,right:0}),d.setPadding({startY:w.startY,endY:y.startY,startX:0,endX:0}),r&2&&this._commandService.executeCommand(dt.id,{sheetViewStartRow:0,offsetY:0}),g.resize({left:a,top:c,height:x,right:0}),g.updateScroll({actualScrollY:w.startY,x:d.scrollX,actualScrollX:d.actualScrollX}),p.resize({left:0,top:c,width:a,height:x}),p.updateScroll({actualScrollY:w.startY}),v.resize({left:0,top:c+x,bottom:0,width:a}),g.enable(),p.enable()}else if(b===!1&&T===!0){const x=y.startX-w.startX;d.resize({left:a+x,top:c,bottom:0,right:0}),d.setPadding({startX:w.startX,endX:y.startX,startY:0,endY:0}),r&1&&this._commandService.executeCommand(dt.id,{sheetViewStartColumn:0,offsetX:0}),m.resize({left:a,top:c,width:x,bottom:0,right:0}),m.updateScroll({actualScrollX:w.startX,y:d.scrollY,actualScrollY:d.actualScrollY}),f.resize({left:a,top:0,width:x,height:c}),f.updateScroll({actualScrollX:w.startX}),_.resize({left:a+x,top:0,height:c,right:0}),m.enable(),f.enable()}else{const x=y.startX-w.startX,A=y.startY-w.startY;d.resize({left:a+x,top:c+A,bottom:0,right:0}),d.setPadding({startY:w.startY,endY:y.startY,startX:w.startX,endX:y.startX}),r&&this._commandService.executeCommand(dt.id,{...r&1?{sheetViewStartColumn:0,offsetX:0}:null,...r&2?{sheetViewStartRow:0,offsetY:0}:null}),m.resize({left:a,top:c+A,width:x,bottom:0}),m.updateScroll({actualScrollX:w.startX,y:d.scrollY,actualScrollY:d.actualScrollY}),g.resize({left:a+x,top:c,height:A,right:0}),g.updateScroll({actualScrollY:w.startY,x:d.scrollX,actualScrollX:d.actualScrollX}),h.resize({left:a,top:c,width:x,height:A}),h.updateScroll({actualScrollX:w.startX,actualScrollY:w.startY}),p.resize({left:0,top:c,width:a,height:A}),p.updateScroll({actualScrollY:w.startY}),v.resize({left:0,top:c+A,bottom:0,width:a}),f.resize({left:a,top:0,width:x,height:c}),f.updateScroll({actualScrollX:w.startX}),_.resize({left:a+x,top:0,height:c,right:0}),h.enable(),g.enable(),m.enable(),p.enable(),f.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(t=>{[S.SetWorksheetActiveOperation.id,S.InsertRangeMoveDownCommand.id,S.InsertRangeMoveRightCommand.id].includes((t==null?void 0:t.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._context.unit.getActiveSheet().getConfig().freeze,{startRow:i=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(i,r,s,a,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(t=>{this._clearFreeze(),this._themeChange(t),this._refreshCurrent()}))}_themeChange(t){this._freezeNormalHeaderColor=t.grey400,this._freezeNormalMainColor=new l.ColorKit(t.grey400).setAlpha(Yd).toRgbString(),this._freezeActiveColor=t.primaryColor,this._freezeHoverColor=t.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{const e={redos:[],undos:[]},n=this._getFreeze();if(!n)return e;const i=r=>{const s=this._context.unit,a=s.getUnitId(),u=s.getActiveSheet().getSheetId();this._refreshFreeze(r.startRow,r.startColumn,r.ySplit,r.xSplit,0);const d={...r,unitId:a,subUnitId:u,resetScroll:!1},h=S.SetFrozenMutationFactory(this._injector,d);return{undos:[{id:S.SetFrozenMutation.id,params:h}],redos:[{id:S.SetFrozenMutation.id,params:d}]}};if(t.id===S.InsertRowCommand.id){const s=t.params.range,a=s.endRow-s.startRow+1;if(s.startRow<=n.startRow){const c={...n,startRow:Math.max(1,n.startRow+a),ySplit:Math.max(1,n.ySplit+a)};return i(c)}}if(t.id===S.InsertColCommand.id){const s=t.params.range,a=s.endColumn-s.startColumn+1;if(s.startColumn<=n.startColumn){const c={...n,startColumn:Math.max(1,n.startColumn+a),xSplit:Math.max(1,n.xSplit+a)};return i(c)}}if(t.id===S.MoveColsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startColumn:s},toRange:{startColumn:a}}=t.params,c=r==null?void 0:r.filter(p=>p.range.rangeType===l.RANGE_TYPE.COLUMN&&p.range.startColumn<=s&&s<=p.range.endColumn);if(!(c!=null&&c.length))return e;const u=c[0].range,d={...u,startColumn:a,endColumn:a+u.endColumn-u.startColumn};if(!n||n.startColumn<=0||u.startColumn>=n.startColumn&&d.startColumn>=n.startColumn||u.startColumn===d.startColumn||u.endColumn<n.startColumn&&d.startColumn<n.startColumn)return e;const h=u.endColumn-u.startColumn+1,m=Math.max(Math.min(n.startColumn,u.endColumn+1)-u.startColumn,0);let g,f;d.startColumn>=n.startColumn?(g=Math.max(n.startColumn-m,1),f=Math.max(n.xSplit-m,1)):(g=n.startColumn+h-m,f=n.xSplit+h-m);const _={...n,startColumn:g,xSplit:f};return i(_)}if(t.id===S.MoveRowsCommand.id){const r=this._selectionManagerService.getSelections(),{fromRange:{startRow:s},toRange:{startRow:a}}=t.params,c=r==null?void 0:r.filter(p=>p.range.rangeType===l.RANGE_TYPE.ROW&&p.range.startRow<=s&&s<=p.range.endRow);if(!(c!=null&&c.length))return e;const u=c[0].range,d={...u,startRow:a,endRow:a+u.endRow-u.startRow};if(!n||n.startRow<=0||u.startRow>=n.startRow&&d.startRow>=n.startRow||u.startRow===d.startRow||u.endRow<n.startRow&&d.startRow<n.startRow)return e;const h=u.endRow-u.startRow+1,m=Math.max(Math.min(n.startRow,u.endRow+1)-u.startRow,0);let g,f;d.startRow>=n.startRow?(g=Math.max(n.startRow-m,1),f=Math.max(n.ySplit-m,1)):(g=n.startRow+h-m,f=n.ySplit+h-m);const _={...n,startRow:g,ySplit:f};return i(_)}if(t.id===S.RemoveColCommand.id||t.id===S.RemoveRowCommand.id){const r=t.params,s=r.range;if(s.rangeType===l.RANGE_TYPE.COLUMN&&s.startColumn<n.startColumn){const a=Math.min(n.startColumn,s.endColumn+1)-s.startColumn,c={...n,startColumn:Math.max(1,n.startColumn-a),xSplit:Math.max(1,n.xSplit-a)};return i(c)}if(r.range.rangeType===l.RANGE_TYPE.ROW&&s.startRow<n.startRow){const a=Math.min(n.startRow,s.endRow+1)-s.startRow,c={...n,startRow:Math.max(1,n.startRow-a),ySplit:Math.max(1,n.ySplit-a)};return i(c)}}return e}}))}_commandExecutedListener(){const t=[S.SetFrozenMutation.id,Fe.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(t.includes(e.id)){const n=this._lastFreeze,i=this._context.unit,r=i.getActiveSheet(),s=e.params,{unitId:a,subUnitId:c}=s;if(!(a===i.getUnitId()&&c===r.getSheetId()))return;const u=r.getConfig().freeze;if(this._lastFreeze=u,u==null)return;let d=0;const{startRow:h=-1,startColumn:m=-1,ySplit:g=0,xSplit:f=0}=u;(!n||n.startRow!==h||n.ySplit!==g)&&(d|=2),(!n||n.startColumn!==m||n.xSplit!==f)&&(d|=1),s.resetScroll===!1&&(d=0),this._refreshFreeze(h,m,g,f,d)}else if(e.id===S.SetWorksheetRowHeightMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(i=>i.startRow<n.startRow)&&this._refreshCurrent()}else if(e.id===S.SetWorksheetColWidthMutation.id){const n=this._getFreeze();e.params&&n&&e.params.ranges.some(i=>i.startColumn<n.startColumn)&&this._refreshCurrent()}else if(e.id===S.SetWorksheetRowAutoHeightMutation.id){const n=e.params,i=this._getFreeze();if(i&&i.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<i.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}else if(e.id===S.SetColHiddenMutation.id||e.id===S.SetColVisibleMutation.id){const n=e.params,i=this._getFreeze(),r=n.ranges;i&&i.startColumn>-1&&r.some(s=>s.startColumn<i.startColumn)&&this._refreshCurrent()}else if(e.id===S.SetRowHiddenMutation.id||e.id===S.SetRowVisibleMutation.id){const n=e.params,i=this._getFreeze(),r=n.ranges;i&&i.startRow>-1&&r.some(s=>s.startRow<i.startRow)&&this._refreshCurrent()}}))}_zoomRefresh(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onTransformChangeObservable.add(n=>{n.type===E.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale&&this._refreshCurrent()})}_clearObserverEvent(){const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,i,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(i=this._rowFreezeMainRect)==null||i.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const t=this._getSheetObject();if(t==null)return;const{scene:e}=t;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),e.onPointerMoveObserver.remove(a),e.onPointerLeaveObserver.remove(a)}),e.onPointerEnterObserver.remove(this._moveObserver),e.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(t,e){var c;if(this._getSheetObject()==null)return;const i=(c=this._sheetSkeletonManagerService.getCurrent())==null?void 0:c.skeleton,r=i==null?void 0:i.getNoMergeCellPositionByIndex(t,e);if(i==null)return;if(r!=null&&(!isNaN(r.endX)||!isNaN(r.endY)))return r;const{rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=i;return{startX:s,endX:s,startY:a,endY:a}}_getFreeze(){var e;const t=(e=this._sheetSkeletonManagerService.getCurrent())==null?void 0:e.skeleton.getWorksheetConfig();if(t!=null)return t.freeze}_getSheetObject(){return it(this._context.unit,this._context)}_refreshFreeze(t,e,n,i,r){var a;const s={startRow:t,startColumn:e,ySplit:n,xSplit:i};this._clearFreeze(),this._createFreeze(0,s),this._createFreeze(1,s),this._updateViewport(t,e,n,i,r),(a=this._getSheetObject())==null||a.spreadsheet.makeForceDirty()}};Wn=kd([st(1,D.Inject(exports.SheetSkeletonManagerService)),st(2,l.ICommandService),st(3,D.Inject(S.SelectionManagerService)),st(4,D.Inject(Ze)),st(5,D.Inject(l.ThemeService)),st(6,D.Inject(S.SheetInterceptorService)),st(7,D.Inject(D.Injector))],Wn);var Ho=(o=>(o[o.NORMAL=0]="NORMAL",o[o.HIGHLIGHT=1]="HIGHLIGHT",o))(Ho||{});const Xd="rgba(0, 0, 0, 0.15)",Xe="rgb(0, 0, 0)",hn="rgb(255, 255, 255, 1)";class Gd extends E.Shape{constructor(e,n){super(e,n);R(this,"_size",12);R(this,"_iconRatio",.4);R(this,"_mode",0);this.setShapeProps(n)}setShapeProps(e){e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),this.transformByState({width:this._size,height:this._size})}_draw(e){this._mode===1&&E.Rect.drawWith(e,{width:this._size,height:this._size,radius:this._size,fill:Xd});const n=this._size*.5*this._iconRatio,i=Math.PI/180*60,r=n*Math.sin(i),s=n*Math.cos(i);E.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:Xe})}}var Zd=Object.defineProperty,Kd=Object.getOwnPropertyDescriptor,qd=(o,t,e,n)=>{for(var i=n>1?void 0:n?Kd(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Zd(t,e,i),i},mn=(o,t)=>(e,n)=>t(e,n,o);const Qd="__SpreadsheetHeaderMenuSHAPEControllerShape__",Jd="__SpreadsheetHeaderMenuMAINControllerShape__",eu="rgba(0, 0, 0, 0.1)";let Lo=class extends l.Disposable{constructor(t,e,n,i,r){super();R(this,"_hoverRect");R(this,"_hoverMenu");R(this,"_currentColumn",Number.POSITIVE_INFINITY);R(this,"_observers",[]);this._context=t,this._sheetSkeletonManagerService=e,this._contextMenuService=n,this._commandService=i,this._selectionManagerService=r,this._initialize()}dispose(){var n,i;(n=this._hoverRect)==null||n.dispose(),(i=this._hoverMenu)==null||i.dispose();const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW);this._observers.forEach(r=>{e.onPointerEnterObserver.remove(r),e.onPointerMoveObserver.remove(r),e.onPointerLeaveObserver.remove(r),t.onPointerEnterObserver.remove(r),t.onPointerMoveObserver.remove(r),t.onPointerLeaveObserver.remove(r)})}_initialize(){const t=this._context.scene;this._hoverRect=new E.Rect(Qd,{fill:eu,evented:!1}),this._hoverMenu=new Gd(Jd,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],nt),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=t===0?n:e;this._observers.push(i==null?void 0:i.onPointerEnterObserver.add(()=>{var r;(r=this._hoverRect)==null||r.show()})),this._observers.push(i==null?void 0:i.onPointerMoveObserver.add(r=>{var f,_,p;const s=(f=this._sheetSkeletonManagerService.getCurrent())==null?void 0:f.skeleton;if(s==null)return;const{rowHeaderWidth:a,columnHeaderHeight:c}=s,{startX:u,startY:d,endX:h,endY:m,column:g}=Et(r.offsetX,r.offsetY,this._context.scene,s);if(t===0)(_=this._hoverRect)==null||_.transformByState({width:a,height:m-d,left:0,top:d});else{if(this._currentColumn=g,(p=this._hoverRect)==null||p.transformByState({width:h-u,height:c,left:u,top:0}),this._hoverMenu==null)return;if(h-u<c*2){this._hoverMenu.hide();return}const v=c*.8;this._hoverMenu.transformByState({left:h-c,top:c/2-v/2}),this._hoverMenu.setShapeProps({size:v}),this._hoverMenu.show()}})),this._observers.push(i==null?void 0:i.onPointerLeaveObserver.add(()=>{var r,s;(r=this._hoverRect)==null||r.hide(),(s=this._hoverMenu)==null||s.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{this._hoverMenu!=null&&(this._hoverMenu.setProps({mode:Ho.HIGHLIGHT,visible:!0}),this._context.scene.setCursor(E.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{this._hoverMenu!=null&&(this._hoverMenu.setProps({mode:Ho.NORMAL,visible:!1}),this._context.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(t=>{const e=this._currentColumn,n=this._selectionManagerService.getSelectionRanges();if(!!!(n!=null&&n.filter(r=>r.rangeType===l.RANGE_TYPE.COLUMN).find(r=>{const{startColumn:s,endColumn:a}=r;return e>=s&&e<=a}))){const r=this._getSelectionOnColumn(e);this._commandService.syncExecuteCommand(S.SetSelectionsOperation.id,r)}t.stopPropagation(),t.preventDefault(),this._contextMenuService.triggerContextMenu(t,le.COL_HEADER_CONTEXT_MENU)}))}_getSelectionOnColumn(t){const e=this._context.unit,n=e.getActiveSheet();return{unitId:e.getUnitId(),subUnitId:n.getSheetId(),pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:{startRow:0,startColumn:t,endRow:n.getRowCount()-1,endColumn:t,rangeType:l.RANGE_TYPE.COLUMN},primary:{startRow:0,startColumn:t,endRow:0,endColumn:t,actualRow:0,actualColumn:t,isMerged:!1,isMergedMainCell:!1},style:null}]}}};Lo=qd([mn(1,D.Inject(exports.SheetSkeletonManagerService)),mn(2,I.IContextMenuService),mn(3,l.ICommandService),mn(4,D.Inject(S.SelectionManagerService))],Lo);var tu=Object.defineProperty,nu=Object.getOwnPropertyDescriptor,ou=(o,t,e,n)=>{for(var i=n>1?void 0:n?nu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&tu(t,e,i),i},gn=(o,t)=>(e,n)=>t(e,n,o);const iu="__SpreadsheetHeaderMoveControllerBackground__",ru="__SpreadsheetHeaderMoveControllerShapeLine__",su="rgba(0, 0, 0, 0.1)",au="rgb(119, 119, 119)",lu=4;let Uo=class extends l.Disposable{constructor(t,e,n,i,r){super();R(this,"_startOffsetX",Number.NEGATIVE_INFINITY);R(this,"_startOffsetY",Number.NEGATIVE_INFINITY);R(this,"_moveHelperBackgroundShape");R(this,"_moveHelperLineShape");R(this,"_rowOrColumnDownObservers",[]);R(this,"_rowOrColumnMoveObservers",[]);R(this,"_rowOrColumnLeaveObservers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_scrollTimer");R(this,"_changeFromColumn",-1);R(this,"_changeFromRow",-1);R(this,"_changeToColumn",-1);R(this,"_changeToRow",-1);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._selectionRenderService=i,this._selectionManagerService=r,this._initialize()}dispose(){var i,r,s;(i=this._moveHelperBackgroundShape)==null||i.dispose(),(r=this._moveHelperLineShape)==null||r.dispose();const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW),n=this._context.scene;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{e.onPointerDownObserver.remove(a),t.onPointerDownObserver.remove(a)}),n.onPointerMoveObserver.remove(this._moveObserver),n.onPointerUpObserver.remove(this._upObserver),(s=this._scrollTimer)==null||s.dispose()}_initialize(){this._initialRowOrColumn(0),this._initialRowOrColumn(1)}_initialRowOrColumn(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=this._context.scene,r=t===0?n:e;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:u}=Et(s.offsetX,s.offsetY,i,a);if(this._checkInHeaderRange(t===0?c:u,t)===!1){i.resetCursor(),this._selectionRenderService.enableSelection();return}i.setCursor(E.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),i.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var w;const a=(w=this._sheetSkeletonManagerService.getCurrent())==null?void 0:w.skeleton;if(a==null)return;const{offsetX:c,offsetY:u}=s,d=i.getRelativeCoord(E.Vector2.FromArray([c,u])),{x:h,y:m}=d;this._startOffsetX=h,this._startOffsetY=m;const{row:g,column:f}=Et(s.offsetX,s.offsetY,i,a);let _;t===0?(this._changeFromRow=g,_=E.ScrollTimerType.Y):(this._changeFromColumn=f,_=E.ScrollTimerType.X);const p=this._checkInHeaderRange(t===0?g:f,t);if(p===!1)return;const v=i.getScrollXYByRelativeCoords(E.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),i.setCursor(E.CURSOR_TYPE.GRABBING),i.disableEvent();let M=!1,b;const T=()=>{if(M)return;b=E.ScrollTimer.create(i,_);const y=i.getViewport(W.VIEW_MAIN);b.startScroll(h,m,y),this._scrollTimer=b,M=!0};this._moveObserver=i.onPointerMoveObserver.add(y=>{T();const{offsetX:O,offsetY:x}=y,{x:A,y:F}=i.getRelativeCoord(E.Vector2.FromArray([O,x]));this._rowColumnMoving(A,F,p,v,t),b.scrolling(A,F,()=>{this._rowColumnMoving(A,F,p,v,t)})}),this._upObserver=i.onPointerUpObserver.add(()=>{var O,x,A;this._disposeBackgroundAndLine(),i.resetCursor(),i.enableEvent(),this._clearObserverEvent(),(O=this._scrollTimer)==null||O.dispose();const y=this._selectionManagerService.getSelections();if(t===0){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const N=(x=((y==null?void 0:y.filter(L=>L.range.rangeType===l.RANGE_TYPE.ROW&&L.range.startRow<=this._changeFromRow&&this._changeFromRow<=L.range.endRow))||[])[0])==null?void 0:x.range;N&&this._commandService.executeCommand(S.MoveRowsCommand.id,{fromRange:N,toRange:{...N,startRow:this._changeToRow,endRow:this._changeToRow+N.endRow-N.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const N=(A=((y==null?void 0:y.filter(L=>L.range.rangeType===l.RANGE_TYPE.COLUMN&&L.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=L.range.endColumn))||[])[0])==null?void 0:A.range;N&&this._commandService.executeCommand(S.MoveColsCommand.id,{fromRange:N,toRange:{...N,startColumn:this._changeToColumn,endColumn:this._changeToColumn+N.endColumn-N.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})}))}_rowColumnMoving(t,e,n,i,r){var $,Q,P,H,k,Y,X;const s=this._context.scene,a=($=this._sheetSkeletonManagerService.getCurrent())==null?void 0:$.skeleton;if(a==null)return;const{rowHeaderWidth:c,columnHeaderHeight:u,rowTotalHeight:d,columnTotalWidth:h}=a,m=s.getScrollXY(s.getViewport(W.VIEW_MAIN)),{scaleX:g,scaleY:f}=s.getAncestorScale(),_=a.getCellPositionByOffset(t,e,g,f,m),{row:p,column:v}=_,M=a.getNoMergeCellPositionByIndex(p,v),{startX:b,startY:T,endX:w,endY:y}=M,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const x=Math.max(g,g),{startX:A,endX:F,startY:N,endY:L,startRow:B,startColumn:j,endRow:z,endColumn:q}=O;r===0?(Q=this._moveHelperBackgroundShape)==null||Q.transformByState({height:L-N,width:h+c,left:0,top:N+(e-this._startOffsetY)/x+m.y-i.y}):(P=this._moveHelperBackgroundShape)==null||P.transformByState({height:d+u,width:F-A,left:A+(t-this._startOffsetX)/x+m.x-i.x,top:0}),(H=this._moveHelperBackgroundShape)==null||H.show();const K=lu/x;if(r===0){let J=0;if(p<=B)J=T-K/2,this._changeToRow=p;else if(p>z)J=y-K/2,this._changeToRow=p+1;else return;(k=this._moveHelperLineShape)==null||k.transformByState({height:K,width:h,left:c,top:J})}else{let J=0;if(v<=j)J=b-K/2,this._changeToColumn=v;else if(v>q)J=w-K/2,this._changeToColumn=v+1;else return;(Y=this._moveHelperLineShape)==null||Y.transformByState({height:d,width:K,left:J,top:u})}(X=this._moveHelperLineShape)==null||X.show()}_checkInHeaderRange(t,e=0){var a;const n=this._selectionManagerService.getSelections();if(((a=this._selectionManagerService.getCurrent())==null?void 0:a.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME)return!1;const r=n==null?void 0:n.find(c=>{const u=c.range,{startRow:d,endRow:h,startColumn:m,endColumn:g,rangeType:f}=u;return e===1?t>=m&&t<=g&&l.RANGE_TYPE.COLUMN===f:t>=d&&t<=h&&l.RANGE_TYPE.ROW===f}),s=r==null?void 0:r.range;return r==null||s==null||s.rangeType===l.RANGE_TYPE.ALL||s.rangeType===l.RANGE_TYPE.NORMAL||s.rangeType===l.RANGE_TYPE.ROW&&e!==0||s.rangeType===l.RANGE_TYPE.COLUMN&&e!==1?!1:r}_clearObserverEvent(){const t=this._context.scene;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const t=this._context.scene;this._moveHelperBackgroundShape=new E.Rect(iu,{fill:su,evented:!1,zIndex:100}),this._moveHelperLineShape=new E.Rect(ru,{fill:au,evented:!1,zIndex:100}),t.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],nt)}_disposeBackgroundAndLine(){var t,e;(t=this._moveHelperBackgroundShape)==null||t.dispose(),(e=this._moveHelperLineShape)==null||e.dispose()}};Uo=ou([gn(1,D.Inject(exports.SheetSkeletonManagerService)),gn(2,l.ICommandService),gn(3,Ne),gn(4,D.Inject(S.SelectionManagerService))],Uo);var Vo=(o=>(o[o.VERTICAL=0]="VERTICAL",o[o.HORIZONTAL=1]="HORIZONTAL",o))(Vo||{});const cu="rgba(120, 120, 120, 0.01)",fo="rgb(68, 71, 70)",$t=12,Bo=4;class Ki extends E.Shape{constructor(e,n){super(e,n);R(this,"_size",$t);R(this,"_color",fo);R(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){let{width:n,height:i}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:u}=a.getAncestorScale(),d=Math.max(c,u),h=$t/d,m=Bo/d;this.mode===0?(n=m,r=h-m):(i=m,s=h-m),E.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:cu}),E.Rect.drawWith(e,{width:n,height:i,fill:fo,radius:m}),e.save(),e.transform(1,0,0,1,r,s),E.Rect.drawWith(e,{width:n,height:i,fill:fo,radius:m}),e.restore()}setShapeProps(e){return e!=null&&e.size&&(this._size=e.size),e!=null&&e.mode&&(this._mode=e.mode),e!=null&&e.color&&(this._color=e.color),this.mode===0?this.transformByState({width:$t,height:this.size}):this.transformByState({width:this.size,height:$t}),this}}var du=Object.defineProperty,uu=Object.getOwnPropertyDescriptor,hu=(o,t,e,n)=>{for(var i=n>1?void 0:n?uu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&du(t,e,i),i},_o=(o,t)=>(e,n)=>t(e,n,o);const mu="__SpreadsheetHeaderResizeControllerShapeRow__",gu="__SpreadsheetHeaderResizeControllerShapeColumn__",qi="__SpreadsheetHeaderResizeControllerShapeHelper__",Qi="rgb(199, 199, 199)",fu=2;let Fo=class extends l.Disposable{constructor(t,e,n,i){super();R(this,"_currentRow",0);R(this,"_currentColumn",0);R(this,"_rowResizeRect");R(this,"_columnResizeRect");R(this,"_observers",[]);R(this,"_moveObserver");R(this,"_upObserver");R(this,"_resizeHelperShape");R(this,"_startOffsetX",Number.POSITIVE_INFINITY);R(this,"_startOffsetY",Number.POSITIVE_INFINITY);this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._editorBridgeService=i,this._init()}dispose(){var n,i;(n=this._rowResizeRect)==null||n.dispose(),this._rowResizeRect=null,(i=this._columnResizeRect)==null||i.dispose(),this._columnResizeRect=null;const t=this._context.components.get(ie.COLUMN),e=this._context.components.get(ie.ROW);this._observers.forEach(r=>{e.onPointerMoveObserver.remove(r),e.onPointerLeaveObserver.remove(r),t.onPointerMoveObserver.remove(r),t.onPointerLeaveObserver.remove(r)}),this._observers=[]}_init(){const t=this._context.scene;this._rowResizeRect=new Ki(mu,{visible:!1,mode:Vo.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Ki(gu,{visible:!1,mode:Vo.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],nt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(t=0){const e=this._context.components.get(ie.COLUMN),n=this._context.components.get(ie.ROW),i=this._context.scene,r=t===0?n:e;this._observers.push(r==null?void 0:r.onPointerMoveObserver.add((s,a)=>{var y;const c=(y=this._sheetSkeletonManagerService.getCurrent())==null?void 0:y.skeleton;if(c==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:d}=c,{startX:h,startY:m,endX:g,endY:f,row:_,column:p}=Et(s.offsetX,s.offsetY,i,c),v=bn(s.offsetX,s.offsetY,i),{scaleX:M,scaleY:b}=i.getAncestorScale(),T=Math.max(M,b),w=$t/T;if(t===0){let O=m-w/2;if(v.y<=m+w/2&&v.y>=m)this._currentRow=_-1;else if(v.y>=f-w/2&&v.y<=f)this._currentRow=_,O=f-w/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const x=u/3;this._rowResizeRect.transformByState({left:u/2-x/2,top:O}),this._rowResizeRect.setShapeProps({size:x}),this._rowResizeRect.show()}else{let O=h-w/2;if(v.x<=h+w/2&&v.x>=h)this._currentColumn=p-1;else if(v.x>=g-w/2&&v.x<=g)this._currentColumn=p,O=g-w/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const x=d*.7;this._columnResizeRect.transformByState({left:O,top:d/2-x/2}),this._columnResizeRect.setShapeProps({size:x}),this._columnResizeRect.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add((s,a)=>{var c,u;(c=this._rowResizeRect)==null||c.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(t=0){const e=this._context.scene,n=t===0?this._rowResizeRect:this._columnResizeRect;n!=null&&(this.disposeWithMe(l.toDisposable(n.onPointerEnterObserver.add(()=>{n!=null&&(n.show(),e.setCursor(t===0?E.CURSOR_TYPE.ROW_RESIZE:E.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(n.onPointerLeaveObserver.add(()=>{n!=null&&(n.hide(),e.resetCursor())}))),this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add((i,r)=>{var K,$,Q,P,H,k,Y;const s=(K=this._sheetSkeletonManagerService.getCurrent())==null?void 0:K.skeleton;if(s==null)return;const a=this._context.scene,c=a.getEngine(),u=(c==null?void 0:c.height)||0,d=(c==null?void 0:c.width)||0,h=a.getViewport(W.VIEW_MAIN),m=(((Q=($=h==null?void 0:h.getScrollBar())==null?void 0:$.horizonBarRect)==null?void 0:Q.height)||0)+10,g=(((H=(P=h==null?void 0:h.getScrollBar())==null?void 0:P.verticalBarRect)==null?void 0:H.width)||0)+10,f=bn(i.offsetX,i.offsetY,a),{scaleX:_,scaleY:p}=a.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const v=s.getOffsetByPositionX(this._currentColumn),M=s.getOffsetByPositionY(this._currentRow),b=s.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn);let T=!1,w=0,y=0;const{columnTotalWidth:O,rowHeaderWidth:x,rowTotalHeight:A,columnHeaderHeight:F}=s,N=d>O+x?d:O+x,L=u>A+F?u:A+F,B=Math.max(_,p),j=Bo/B;t===0?this._resizeHelperShape=new E.Rect(qi,{width:N,height:j,fill:Qi,left:0,top:M-j/2}):this._resizeHelperShape=new E.Rect(qi,{width:j,height:L,fill:Qi,left:v-j/2,top:0});const z=((k=this._columnResizeRect)==null?void 0:k.left)||0,q=((Y=this._rowResizeRect)==null?void 0:Y.top)||0;a.addObject(this._resizeHelperShape,nt),a.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:E.DeviceInputEventType.PointerDown}),this._moveObserver=a.onPointerMoveObserver.add(X=>{var de,se,$e,pe,Ht,Lt;const J=a.getRelativeCoord(E.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),ee=a.getScrollXYByRelativeCoords(J,h),ce=bn(X.offsetX,X.offsetY,a),{x:Ce,y:De}=ce,{scaleX:Pe,scaleY:We}=a.getAncestorScale(),je=Math.max(Pe,We),he=Bo/je;w=Ce-this._startOffsetX-he/2,y=De-this._startOffsetY-he/2,Math.abs(t===0?y:w)>=fu&&(T=!0),t===0?(y>u-m+ee.y-b.startY&&(y=u-m+ee.y-b.startY),y<-(b.endY-b.startY)+2&&(y=-(b.endY-b.startY)+2),T&&((de=this._resizeHelperShape)==null||de.transformByState({top:M+y}),(se=this._rowResizeRect)==null||se.transformByState({top:q+y+he/2}),($e=this._rowResizeRect)==null||$e.show(),a.setCursor(E.CURSOR_TYPE.ROW_RESIZE))):(w>d-g+ee.x-b.startX&&(w=d-g+ee.x-b.startX),w<-(b.endX-b.startX)+2&&(w=-(b.endX-b.startX)+2),T&&((pe=this._resizeHelperShape)==null||pe.transformByState({left:v+w}),(Ht=this._columnResizeRect)==null||Ht.transformByState({left:z+w+he/2}),(Lt=this._columnResizeRect)==null||Lt.show(),a.setCursor(E.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=a.onPointerUpObserver.add(X=>{var ee,ce,Ce;const J=this._context.scene;this._clearObserverEvent(),(ee=this._resizeHelperShape)==null||ee.dispose(),this._resizeHelperShape=null,J.enableEvent(),T&&(J.resetCursor(),(ce=this._rowResizeRect)==null||ce.hide(),(Ce=this._columnResizeRect)==null||Ce.hide(),t===0?this._commandService.executeCommand(S.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(S.DeltaColumnWidthCommand.id,{deltaX:w,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(n.onDblclickObserver.add(()=>{var i;t===0&&(this._context.scene.resetCursor(),this._commandService.executeCommand(S.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(i=this._rowResizeRect)==null||i.hide())}))))}_clearObserverEvent(){const t=this._context.scene;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}};Fo=hu([_o(1,D.Inject(exports.SheetSkeletonManagerService)),_o(2,l.ICommandService),_o(3,Ee)],Fo);var ko=(o=>(o[o.ROW=0]="ROW",o[o.COLUMN=1]="COLUMN",o))(ko||{});const zt=12,_u=.4;class Ji extends E.Shape{constructor(e,n,i){super(e,n);R(this,"_size",zt);R(this,"_iconRatio",_u);R(this,"_hovered",!0);R(this,"_hasPrevious",!0);R(this,"_hasNext",!0);R(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>i==null?void 0:i())}setShapeProps(e){e.type!==void 0&&(this._unhideType=e.type),e.hovered!==void 0&&(this._hovered=e.hovered),e.hasPrevious!==void 0&&(this._hasPrevious=e.hasPrevious),e.hasNext!==void 0&&(this._hasNext=e.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(e){this._unhideType===0?this._drawOnRow(e):this._drawOnCol(e)}_drawOnRow(e){this._hovered&&(!this._hasNext||!this._hasPrevious?E.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Xe,fill:hn}):E.Rect.drawWith(e,{width:this._size,height:2*this._size,stroke:Xe,fill:hn}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&E.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:Xe}),this._hasNext){const a=this._hasPrevious?3:1;E.RegularPolygon.drawWith(e,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:Xe})}}_drawOnCol(e){this._hovered&&(!this._hasNext||!this._hasPrevious?E.Rect.drawWith(e,{width:this._size,height:this._size,stroke:Xe,fill:hn}):E.Rect.drawWith(e,{width:2*this._size,height:this._size,stroke:Xe,fill:hn}));const n=this._size*.5*this._iconRatio,i=Math.PI/3,r=n*Math.cos(i),s=n*Math.sin(i);if(this._hasPrevious&&E.RegularPolygon.drawWith(e,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:Xe}),this._hasNext){const a=this._hasPrevious?3:1;E.RegularPolygon.drawWith(e,{pointsGroup:[[{x:r+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:Xe})}}}var Su=Object.defineProperty,pu=Object.getOwnPropertyDescriptor,Cu=(o,t,e,n)=>{for(var i=n>1?void 0:n?pu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Su(t,e,i),i},er=(o,t)=>(e,n)=>t(e,n,o);const tr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",vu=[S.InsertColMutation.id,S.InsertRowMutation.id,S.RemoveColMutation.id,S.RemoveRowMutation.id,S.SetWorksheetColWidthMutation.id,S.SetWorksheetRowIsAutoHeightMutation.id,S.SetRowHiddenMutation.id,S.SetRowVisibleMutation.id,S.SetColHiddenMutation.id,S.SetColVisibleMutation.id];let Wo=class extends l.RxDisposable{constructor(t,e,n){super();R(this,"_shapes",{cols:[],rows:[]});this._context=t,this._sheetSkeletonManagerService=e,this._commandService=n,this._init()}get _workbook(){return this._context.unit}dispose(){super.dispose(),this._clearShapes()}_init(){let t="";this._context.unit.activeSheet$.pipe(U.takeUntil(this.dispose$)).subscribe(e=>{if(this._clearShapes(),!e){t="";return}t=e.getSheetId(),this._update(this._workbook,e)}),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(!vu.includes(e.id)||!e.params||!e.params.unitId||e.params.subUnitId!==t)return;const n=this._workbook,i=n.getSheetBySheetId(e.params.subUnitId);i&&this._update(n,i)}))}_update(t,e){var m;const n=(m=this._sheetSkeletonManagerService.getUnitSkeleton(t.getUnitId(),e.getSheetId()))==null?void 0:m.skeleton;if(!n)return;const i=e.getHiddenRows(),r=e.getHiddenCols(),s=this._getSheetObject(),{scene:a}=s,c=e.getRowCount(),u=i.map(g=>{const{startRow:f,endRow:_}=g,p=No(f,0,a,n),v=f!==0,M=_!==c-1;return new Ji(tr,{type:ko.ROW,hovered:!1,hasPrevious:v,hasNext:M,top:p.startY-(v?zt:0),left:p.startX-zt},()=>this._commandService.executeCommand(S.SetSpecificRowsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[g]}))}),d=e.getColumnCount(),h=r.map(g=>{const{startColumn:f,endColumn:_}=g,p=No(0,f,a,n),v=f!==0,M=_!==d-1;return new Ji(tr,{type:ko.COLUMN,hovered:!1,hasPrevious:v,hasNext:M,top:20-zt,left:p.startX-(v?zt:0)},()=>this._commandService.executeCommand(S.SetSpecificColsVisibleCommand.id,{unitId:t.getUnitId(),subUnitId:e.getSheetId(),ranges:[g]}))});a.addObjects(h,yi),a.addObjects(u,yi),this._clearShapes(),this._shapes={cols:h,rows:u}}_clearShapes(){this._shapes.cols.forEach(t=>t.dispose()),this._shapes.rows.forEach(t=>t.dispose()),this._shapes={cols:[],rows:[]}}_getSheetObject(){return it(this._workbook,this._context)}};Wo=Cu([er(1,D.Inject(exports.SheetSkeletonManagerService)),er(2,l.ICommandService)],Wo);var Iu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Mu=(o,t,e,n)=>{for(var i=n>1?void 0:n?Ru(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Iu(t,e,i),i},So=(o,t)=>(e,n)=>t(e,n,o);let jo=class extends l.Disposable{constructor(o,t,e,n){super(),this._context=o,this._markSelectionService=t,this._commandService=e,this._sheetSkeletonManagerService=n,this._initListeners()}_initListeners(){this._addRemoveListener(),this._addRefreshListener()}_addRemoveListener(){const o=[Te.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{o.includes(t.id)?this._markSelectionService.removeAllShapes():this._markSelectionService.getShapeMap().forEach((n,i)=>{n.exits.includes(t.id)&&this._markSelectionService.removeShape(i)})}))}_addRefreshListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{o&&this._markSelectionService.refreshShapes()}))}};jo=Mu([So(1,D.Inject(nn)),So(2,l.ICommandService),So(3,D.Inject(exports.SheetSkeletonManagerService))],jo);var bu=Object.defineProperty,Tu=Object.getOwnPropertyDescriptor,wu=(o,t,e,n)=>{for(var i=n>1?void 0:n?Tu(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&bu(t,e,i),i},St=(o,t)=>(e,n)=>t(e,n,o);let $o=class extends l.Disposable{constructor(o,t,e,n,i,r,s){super(),this._context=o,this._sheetSkeletonManagerService=t,this._commandService=e,this._selectionRenderService=n,this._selectionManagerService=i,this._themeService=r,this._definedNamesService=s,this._init()}dispose(){super.dispose(),this._selectionRenderService.changeRuntime(null,null),this._selectionRenderService.reset(),this._selectionManagerService.reset()}_init(){const o=this._context.unit,t=o.getActiveSheet(),e=this._getSheetObject();this._initViewMainListener(e),this._initRowHeader(e),this._initColumnHeader(e),this._initLeftTop(e),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener(),this._initDefinedNameListener();const n=o.getUnitId(),i=t.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:S.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:i})}_initDefinedNameListener(){this.disposeWithMe(this._definedNamesService.focusRange$.subscribe(async o=>{if(o==null)return;const{unitId:t}=o;let{formulaOrRefString:e}=o;const n=this._context.unit;if(t!==n.getUnitId()||(e.substring(0,1)===Z.operatorToken.EQUALS&&(e=e.substring(1)),!Z.isReferenceStrings(e)))return;const r=await this._getSelections(n,t,e);this._selectionManagerService.replace(r),this._commandService.executeCommand(S.ScrollToCellOperation.id,r[0].range)}))}async _getSelections(o,t,e){const n=e.split(",");let i=o.getActiveSheet();const r=[];for(let s=0;s<n.length;s++){const a=n[s].trim(),c=Z.deserializeRangeWithSheet(a.trim());if(s===0){const d=o.getSheetBySheetName(c.sheetName);d&&i.getSheetId()!==d.getSheetId()&&(i=d,await this._commandService.executeCommand(S.SetWorksheetActivateCommand.id,{subUnitId:i.getSheetId(),unitId:t}))}if(i.getName()!==c.sheetName)continue;let u=null;if(s===n.length-1){const d=c.range,{startRow:h,startColumn:m,endRow:g,endColumn:f}=d;u=S.getPrimaryForRange({startRow:h,startColumn:m,endRow:g,endColumn:f},i)}r.push({range:c.range,style:S.getNormalSelectionStyle(this._themeService),primary:u})}return r}_getActiveViewport(o){const t=this._getSheetObject();return t==null?void 0:t.scene.getActiveViewportByCoord(E.Vector2.FromArray([o.offsetX,o.offsetY]))}_initViewMainListener(o){const{spreadsheet:t}=o;this.disposeWithMe(l.toDisposable(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(e,t.zIndex+1,l.RANGE_TYPE.NORMAL,this._getActiveViewport(e)),e.button!==2&&n.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const o=this._selectionManagerService.getSelections(),t=this._selectionManagerService.getCurrent();o==null||(t==null?void 0:t.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME||this._refreshSelection(o)})))}_refreshSelection(o){const t=o.map(e=>{const n=this._selectionRenderService.convertSelectionToCoord(e);return n.style=S.getNormalSelectionStyle(this._themeService),n});this._selectionRenderService.updateControlForCurrentByRangeData(t)}_initRowHeader(o){const{spreadsheetRowHeader:t,spreadsheet:e}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((n,i)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.ROW,this._getActiveViewport(n),E.ScrollTimerType.Y),n.button!==2&&i.stopPropagation()}))}_initColumnHeader(o){const{spreadsheetColumnHeader:t,spreadsheet:e}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((n,i)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(n,((e==null?void 0:e.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,this._getActiveViewport(n),E.ScrollTimerType.X),n.button!==2&&i.stopPropagation()}))}_initLeftTop(o){const{spreadsheetLeftTopPlaceholder:t}=o;this.disposeWithMe(t==null?void 0:t.onPointerDownObserver.add((e,n)=>{var a;const i=(a=this._sheetSkeletonManagerService.getCurrent())==null?void 0:a.skeleton;if(i==null)return;this._selectionRenderService.reset();const r=this._getAllRange(i),s=this._selectionRenderService.convertSelectionToCoord(r);this._selectionRenderService.addControlToCurrentByRangeData(s),this._selectionRenderService.refreshSelectionMoveStart(),e.button!==2&&n.stopPropagation()}))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(o=>{if(this._selectionRenderService.reset(),o!=null){for(const t of o){if(t==null)continue;const e=this._selectionRenderService.convertSelectionToCoord(t);this._selectionRenderService.addControlToCurrentByRangeData(e)}this._syncDefinedNameRange(o)}}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(o=>{o!=null&&this._syncDefinedNameRange(o)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveStart$.subscribe(o=>{o!=null&&this._syncDefinedNameRange(o)})))}_syncDefinedNameRange(o){if(o.length===0)return;const t=o[o.length-1],e=this._context.unit,n=e.getActiveSheet();this._definedNamesService.setCurrentRange({range:t.range,unitId:e.getUnitId(),sheetId:n.getSheetId()})}_initUserActionSyncListener(){this.disposeWithMe(this._selectionRenderService.selectionMoveStart$.subscribe(o=>{this._move(o,S.SelectionMoveType.MOVE_START)})),this.disposeWithMe(this._selectionRenderService.selectionMoving$.subscribe(o=>{this._move(o,S.SelectionMoveType.MOVING)})),this.disposeWithMe(this._selectionRenderService.selectionMoveEnd$.subscribe(o=>{this._move(o,S.SelectionMoveType.MOVE_END)}))}_move(o,t){const e=this._context.unit;if(!e)return;const n=e.getUnitId(),i=e.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();o==null||o.length===0||this._commandService.executeCommand(S.SetSelectionsOperation.id,{unitId:n,subUnitId:i,type:t,pluginName:(r==null?void 0:r.pluginName)||S.NORMAL_SELECTION_PLUGIN_NAME,selections:o.map(s=>S.convertSelectionDataToRange(s))})}_getSheetObject(){return it(this._context.unit,this._context)}_initCommandListener(){const o=[Fe.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(o.includes(t.id)){const e=this._context.unit,n=e.getActiveSheet(),i=t.params,{unitId:r,subUnitId:s}=i;if(!(r===e.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(o=>{if(o==null){this._selectionRenderService.changeRuntime(null,null);return}const{unitId:t,sheetId:e,skeleton:n}=o,{scene:i}=this._context,r=i.getViewport(W.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,i,r);const s=this._selectionManagerService.getCurrent(),a=(s==null?void 0:s.pluginName)||S.NORMAL_SELECTION_PLUGIN_NAME;if((s==null?void 0:s.unitId)===t&&s.sheetId===e){const c=this._selectionManagerService.getSelections();c!=null&&this._refreshSelection(c)}else this._selectionManagerService.setCurrentSelection({pluginName:a,unitId:t,sheetId:e});a===S.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])}))}_getAllRange(o){return{range:{startRow:0,startColumn:0,endRow:o.getRowCount()-1,endColumn:o.getColumnCount()-1,rangeType:l.RANGE_TYPE.ALL},primary:this._getZeroRange(o).primary,style:null}}_getZeroRange(o){const t=o.mergeData;return S.transformCellDataToSelectionData(0,0,t)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};$o=wu([St(1,D.Inject(exports.SheetSkeletonManagerService)),St(2,l.ICommandService),St(3,Ne),St(4,D.Inject(S.SelectionManagerService)),St(5,D.Inject(l.ThemeService)),St(6,Z.IDefinedNamesService)],$o);const Ke={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(o,t)=>{const e=o.get(l.ICommandService),n=o.get(l.IUndoRedoService),i=o.get(l.IUniverInstanceService),r=o.get(I.IConfirmService),s=o.get(l.LocaleService),a=t.unitId,c=t.subUnitId,u=t.selections,d=S.getAddMergeMutationRangeByType(u,t.value),h=i.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],g=[],f=Lr(h,d);if(f&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const _={unitId:a,subUnitId:c,ranges:d},p={unitId:a,subUnitId:c,ranges:d},v=S.RemoveMergeUndoMutationFactory(o,_),M=S.AddMergeUndoMutationFactory(o,p);if(v.ranges.length>0&&m.push({id:S.RemoveWorksheetMergeMutation.id,params:v}),m.push({id:S.AddWorksheetMergeMutation.id,params:p}),g.push({id:S.RemoveWorksheetMergeMutation.id,params:M}),v.ranges.length>0&&g.push({id:S.AddWorksheetMergeMutation.id,params:v}),f){const y=Ur(o,a,h,d);m.unshift(...y.redos),g.push(...y.undos)}const b=S.AddMergeRedoSelectionsOperationFactory(o,t,d);b&&m.push(b);const T=S.AddMergeUndoSelectionsOperationFactory(o,t);return T&&g.push(T),l.sequenceExecute(m,e).result?(n.pushUndoRedo({unitID:a,undoMutations:g,redoMutations:m}),!0):!1}},ns={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(S.SelectionManagerService).getSelectionRanges(),i=ei(Zn.MergeAll,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),u=a.getSheetId();return t.executeCommand(Ke.id,{selections:i,unitId:c,subUnitId:u})}},os={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(S.SelectionManagerService).getSelectionRanges(),i=ei(Zn.MergeVertical,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),u=a.getSheetId();return t.executeCommand(Ke.id,{value:l.Dimension.COLUMNS,selections:i,unitId:c,subUnitId:u})}},is={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async o=>{const t=o.get(l.ICommandService),n=o.get(S.SelectionManagerService).getSelectionRanges(),i=ei(Zn.MergeHorizontal,n);if(!(i!=null&&i.length))return!1;const s=o.get(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const a=s.getActiveSheet();if(!a)return!1;const c=s.getUnitId(),u=a.getSheetId();return t.executeCommand(Ke.id,{value:l.Dimension.ROWS,selections:i,unitId:c,subUnitId:u})}},di={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async o=>{const t=o.get(I.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(S.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=S.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let u=s[0].range;if(!u)return!1;u={...u,endColumn:c.getColumnCount()-1};const d=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,u);return f?d(g)>d(f):!1})||await t.confirm({id:di.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(S.DeleteRangeMoveLeftCommand.id):!0}},jn={type:l.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async o=>{const t=o.get(I.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(S.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=S.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let u=s[0].range;if(!u)return!1;u={...u,endRow:c.getRowCount()-1};for(let g=u.startRow;g<=u.endRow;g++)if(c.getRowFiltered(g)&&await t.confirm({id:jn.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const d=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,u);return f?d(g)>d(f):!1})||await t.confirm({id:jn.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(S.DeleteRangeMoveUpCommand.id):!0}},$n={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async o=>{const t=o.get(I.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(S.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=S.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let u=s[0].range;if(!u)return!1;u={...u,endRow:c.getRowCount()-1};for(let g=u.startRow;g<=u.endRow;g++)if(c.getRowFiltered(g)&&await t.confirm({id:$n.id,title:{title:n.t("filter.confirm.error")},children:{title:n.t("filter.confirm.notAllowedToInsertRange")},confirmText:n.t("button.confirm")}))return!1;const d=g=>g.endColumn-g.startColumn;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,u);return f?d(g)>d(f):!1})||await t.confirm({id:$n.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(S.InsertRangeMoveDownCommand.id):!0}},ui={type:l.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async o=>{const t=o.get(I.IConfirmService),e=o.get(l.ICommandService),n=o.get(l.LocaleService),i=o.get(S.SelectionManagerService),r=o.get(l.IUniverInstanceService),s=i.getSelections();if(!s)return!1;const a=S.getSheetCommandTarget(r);if(!a)return!1;const{worksheet:c}=a;let u=s[0].range;if(!u)return!1;u={...u,endColumn:c.getColumnCount()-1};const d=g=>g.endRow-g.startRow;return!c.getMergeData().find(g=>{const f=l.Rectangle.getIntersects(g,u);return f?d(g)>d(f):!1})||await t.confirm({id:ui.id,title:{title:n.t("merge.confirm.waring")},children:{title:n.t("merge.confirm.dismantleMergeCellWaring")},cancelText:n.t("button.cancel"),confirmText:n.t("button.confirm")})?e.executeCommand(S.InsertRangeMoveRightCommand.id):!0}},rs={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(yt);return e.applyType=t.type,!0}},ss={id:"sheet.command.remove-row-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{var u;const e=o.get(S.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(u=e.getLast())==null?void 0:u.range),!n)return!1;const i=o.get(l.ICommandService),r=o.get(l.IUniverInstanceService),s=S.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:a}=s,c=a.getVisibleRows();if(yr(c,[n])){const d=o.get(I.IConfirmService),h=o.get(l.LocaleService);return await d.confirm({id:"sheet.confirm.remove-row",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllRowsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(S.RemoveRowCommand.id,{range:n}),!0}},as={id:"sheet.command.remove-col-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{var u;const e=o.get(S.SelectionManagerService);let n=t==null?void 0:t.range;if(n||(n=(u=e.getLast())==null?void 0:u.range),!n)return!1;const i=o.get(l.ICommandService),r=o.get(l.IUniverInstanceService),s=S.getSheetCommandTarget(r);if(!s)return!1;const{worksheet:a}=s,c=a.getVisibleCols();if(Or(c,[n])){const d=o.get(I.IConfirmService),h=o.get(l.LocaleService);return await d.confirm({id:"sheet.confirm.remove-col",title:{title:h.t("info.problem")},children:{title:h.t("rightClick.deleteAllColumnsAlert")},cancelText:h.t("button.cancel"),confirmText:h.t("button.confirm")}),!1}return await i.executeCommand(S.RemoveColCommand.id,{range:n}),!0}},ls={id:"sheet.command.remove-sheet-confirm",type:l.CommandType.COMMAND,handler:async(o,t)=>{const{subUnitId:e}=t,n=o.get(I.IConfirmService),i=o.get(l.ICommandService),r=o.get(l.LocaleService);return await n.confirm({id:"sheet.confirm.remove-sheet",title:{title:r.t("sheetConfig.deleteSheet")},children:{title:r.t("sheetConfig.deleteSheetContent")},cancelText:r.t("button.cancel"),confirmText:r.t("button.confirm")})?(await i.executeCommand(S.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},Pt=D.createIdentifier("univer.sheetbar-service");class Eu extends l.Disposable{constructor(){super();R(this,"renameId$");R(this,"removeId$");R(this,"scroll$");R(this,"scrollX$");R(this,"addSheet$");R(this,"_renameId$");R(this,"_removeId$");R(this,"_scroll$");R(this,"_scrollX$");R(this,"_addSheet$");R(this,"_currentHandler",null);this._renameId$=new U.Subject,this.renameId$=this._renameId$.asObservable(),this._removeId$=new U.Subject,this.removeId$=this._removeId$.asObservable(),this._scroll$=new U.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new U.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new U.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(e){this._renameId$.next(e)}setRemoveId(e){this._removeId$.next(e)}setScroll(e){this._scroll$.next(e)}setScrollX(e){this._scrollX$.next(e)}setAddSheet(e){this._addSheet$.next(e)}triggerSheetBarMenu(){var e;(e=this._currentHandler)==null||e.handleSheetBarMenu()}registerSheetBarMenuHandler(e){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=e,l.toDisposable(()=>{this._currentHandler=null})}}const cs={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async o=>(o.get(Pt).triggerSheetBarMenu(),!0)},ds={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(o,t)=>(o.get(Ee).setEditCell(t),!0)},us={id:"sheet.operation.rename-sheet",type:l.CommandType.OPERATION,handler:async(o,t)=>{const e=o.get(Pt);return t&&e.setRenameId(t.subUnitId),!0}};var Me=function(){return Me=Object.assign||function(o){for(var t,e=1,n=arguments.length;e<n;e++){t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(o[i]=t[i])}return o},Me.apply(this,arguments)},yu=function(o,t){var e={};for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&t.indexOf(n)<0&&(e[n]=o[n]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(o);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(o,n[i])&&(e[n[i]]=o[n[i]]);return e},Se=V.forwardRef(function(o,t){var e=o.icon,n=o.id,i=o.className,r=o.extend,s=yu(o,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(i||"").trim(),c=V.useRef("_".concat(Nu()));return hs(e,"".concat(n),{defIds:e.defIds,idSuffix:c.current},Me({ref:t,className:a},s),r)});function hs(o,t,e,n,i){return V.createElement(o.tag,Me(Me({key:t},Ou(o,e,i)),n),(xu(o,e).children||[]).map(function(r,s){return hs(r,"".concat(t,"-").concat(o.tag,"-").concat(s),e,void 0,i)}))}function Ou(o,t,e){var n=Me({},o.attrs);e!=null&&e.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=e.colorChannel1);var i=t.defIds;return!i||i.length===0||(o.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function xu(o,t){var e,n=t.defIds;return!n||n.length===0?o:o.tag==="defs"&&(!((e=o.children)===null||e===void 0)&&e.length)?Me(Me({},o),{children:o.children.map(function(i){return typeof i.attrs.id=="string"&&n&&n.indexOf(i.attrs.id)>-1?Me(Me({},i),{attrs:Me(Me({},i.attrs),{id:i.attrs.id+t.idSuffix})}):i})}):o}function Nu(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";var Au={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z",fillRule:"evenodd",clipRule:"evenodd"}}]},ms=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"autofill",ref:t,icon:Au}))});ms.displayName="Autofill";const Du=ms;var Pu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gs=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"check-mark-single",ref:t,icon:Pu}))});gs.displayName="CheckMarkSingle";const Jt=gs;var Hu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z"}}]},fs=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"close-single",ref:t,icon:Hu}))});fs.displayName="CloseSingle";const Lu=fs;var Uu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"g",attrs:{fill:"currentColor",clipPath:"url(#convert-single_clip0_911_593)"},children:[{tag:"path",attrs:{d:"M2.44766.848145C1.564.848145.847656 1.56449.847656 2.44814V6.44814C.847656 7.3318 1.564 8.04814 2.44766 8.04814H6.44766C7.33131 8.04814 8.04766 7.3318 8.04766 6.44814V2.44814C8.04766 1.56449 7.33131.848145 6.44766.848145H2.44766zM2.04766 6.44814V5.04824H3.84775V6.84814H2.44766C2.22674 6.84814 2.04766 6.66906 2.04766 6.44814zM2.04766 3.84824H3.84775V2.04814H2.44766C2.22674 2.04814 2.04766 2.22723 2.04766 2.44814V3.84824zM5.04775 6.84814V5.04824H6.84766V6.44814C6.84766 6.66906 6.66857 6.84814 6.44766 6.84814H5.04775zM5.04775 3.84824H6.84766V2.44814C6.84766 2.22723 6.66857 2.04814 6.44766 2.04814H5.04775V3.84824zM9.55215 7.95166C8.66849 7.95166 7.95215 8.668 7.95215 9.55166V13.5517C7.95215 14.4353 8.66849 15.1517 9.55215 15.1517L11.5522 15.1517 13.5521 15.1517C14.4358 15.1517 15.1521 14.4353 15.1521 13.5517L15.1521 11.5518 15.1521 9.55166C15.1521 8.668 14.4358 7.95166 13.5521 7.95166H9.55215zM13.9521 10.9518V9.55166C13.9521 9.33075 13.7731 9.15166 13.5521 9.15166H12.1522V10.9518H13.9521zM10.9522 10.9518V9.15166H9.55215C9.33123 9.15166 9.15215 9.33075 9.15215 9.55166V10.9518H10.9522zM9.15215 12.1518H10.9522V13.9517H9.55215C9.33123 13.9517 9.15215 13.7726 9.15215 13.5517V12.1518zM12.1522 12.1518H13.9521V13.5517C13.9521 13.7726 13.7731 13.9517 13.5521 13.9517H12.1522V12.1518z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M9.62158 2.44912C9.62158 2.11775 9.89021 1.84912 10.2216 1.84912H12.7516C13.6352 1.84912 14.3516 2.56547 14.3516 3.44912V5.9791C14.3516 6.31047 14.0829 6.5791 13.7516 6.5791 13.4202 6.5791 13.1516 6.31047 13.1516 5.9791V3.44912C13.1516 3.22821 12.9725 3.04912 12.7516 3.04912H10.2216C9.89021 3.04912 9.62158 2.78049 9.62158 2.44912zM5.77871 14.1507C6.11008 14.1507 6.37871 13.8821 6.37871 13.5507 6.37871 13.2193 6.11008 12.9507 5.77871 12.9507L3.24873 12.9507C3.02782 12.9507 2.84873 12.7716 2.84873 12.5507L2.84873 10.0207C2.84873 9.68933 2.5801 9.4207 2.24873 9.4207 1.91736 9.4207 1.64873 9.68933 1.64873 10.0207L1.64873 12.5507C1.64873 13.4343 2.36507 14.1507 3.24873 14.1507H5.77871z"}}]},{tag:"defs",attrs:{},children:[{tag:"clipPath",attrs:{id:"convert-single_clip0_911_593"},children:[{tag:"path",attrs:{fill:"#fff",d:"M0 0H16V16H0z"}}]}]}],defIds:["convert-single_clip0_911_593"]},_s=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"convert-single",ref:t,icon:Uu}))});_s.displayName="ConvertSingle";const Vu=_s;var Bu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.78662 6.17993C7.12169 6.17993 7.39331 6.45156 7.39331 6.78662V10.7301C7.39331 11.0652 7.12169 11.3368 6.78662 11.3368 6.45156 11.3368 6.17993 11.0652 6.17993 10.7301V6.78662C6.17993 6.45156 6.45156 6.17993 6.78662 6.17993zM9.82007 6.78662C9.82007 6.45156 9.54844 6.17993 9.21338 6.17993 8.87831 6.17993 8.60669 6.45156 8.60669 6.78662V10.7301C8.60669 11.0652 8.87831 11.3368 9.21338 11.3368 9.54844 11.3368 9.82007 11.0652 9.82007 10.7301V6.78662z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.57094 1.32642C6.34938 1.32642 6.14544 1.44719 6.03894 1.64148L5.21395 3.14648H1.93311C1.59804 3.14648 1.32642 3.41811 1.32642 3.75317C1.32642 4.08824 1.59804 4.35986 1.93311 4.35986H2.84314V14.0669C2.84314 14.402 3.11476 14.6736 3.44983 14.6736H12.5502C12.8852 14.6736 13.1569 14.402 13.1569 14.0669V4.35986H14.0669C14.402 4.35986 14.6736 4.08824 14.6736 3.75317C14.6736 3.41811 14.402 3.14648 14.0669 3.14648H10.7895L9.98357 1.64602C9.87785 1.4492 9.67252 1.32642 9.44911 1.32642H6.57094ZM9.4122 3.14648L9.08632 2.53979H6.93024L6.59767 3.14648H9.4122ZM4.05652 4.35986V13.4602H11.9435V4.35986H4.05652Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ss=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"delete-single",ref:t,icon:Bu}))});Ss.displayName="DeleteSingle";const Fu=Ss;var ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.85869 12.9216C8.38445 13.4708 7.61555 13.4708 7.14131 12.9216L0.358114 5.06726C-0.406895 4.18144 0.134916 2.66683 1.2168 2.66683L14.7832 2.66683C15.8651 2.66683 16.4069 4.18144 15.6419 5.06726L8.85869 12.9216Z"}}]}]},ps=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"dropdown-single",ref:t,icon:ku}))});ps.displayName="DropdownSingle";const nr=ps;var Wu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM10.3097 5.69014C10.544 5.92445 10.544 6.30435 10.3097 6.53867L8.84843 7.9999L10.3099 9.46137C10.5442 9.69569 10.5442 10.0756 10.3099 10.3099C10.0756 10.5442 9.69569 10.5442 9.46137 10.3099L7.9999 8.84843L6.53842 10.3099C6.30411 10.5442 5.92421 10.5442 5.6899 10.3099C5.45558 10.0756 5.45558 9.69569 5.6899 9.46137L7.15137 7.9999L5.69014 6.53867C5.45583 6.30435 5.45583 5.92445 5.69014 5.69014C5.92445 5.45583 6.30435 5.45583 6.53867 5.69014L7.9999 7.15137L9.46113 5.69014C9.69544 5.45583 10.0753 5.45583 10.3097 5.69014Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Cs=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"error-single",ref:t,icon:Wu}))});Cs.displayName="ErrorSingle";const vs=Cs;var ju={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.28096 4.6541C1.57489 4.50109 1.93721 4.61533 2.09022 4.90926C2.27315 5.26067 2.55999 5.60455 2.94829 5.92278C4.04628 6.82266 5.87505 7.44865 7.99828 7.44865C10.1215 7.44865 11.9503 6.82267 13.0482 5.92279C13.4366 5.60455 13.7234 5.26067 13.9063 4.90927C14.0594 4.61533 14.4217 4.50109 14.7156 4.65409C15.0095 4.8071 15.1238 5.16941 14.9708 5.46334C14.6995 5.98445 14.2981 6.44997 13.8089 6.8509C13.7298 6.91575 13.6481 6.97914 13.564 7.041L15.2245 8.70153C15.4588 8.93585 15.4588 9.31575 15.2245 9.55006C14.9902 9.78438 14.6103 9.78438 14.376 9.55006L12.5041 7.67822C11.8977 7.97568 11.2181 8.21208 10.4884 8.37706L11.0996 10.6581C11.1853 10.9782 10.9954 11.3072 10.6753 11.393C10.3552 11.4787 10.0262 11.2888 9.94045 10.9687L9.29949 8.57652C8.8758 8.62404 8.44081 8.64865 7.99828 8.64865C7.55276 8.64865 7.11487 8.62371 6.68846 8.57555L6.04723 10.9687C5.96147 11.2888 5.63247 11.4788 5.31239 11.393C4.99231 11.3073 4.80236 10.9783 4.88812 10.6582L5.49983 8.37516C4.7743 8.2105 4.09843 7.9752 3.49498 7.67947L1.62436 9.55009C1.39005 9.78441 1.01015 9.78441 0.775835 9.5501C0.54152 9.31578 0.541518 8.93588 0.775832 8.70157L2.43478 7.04261C2.34987 6.98024 2.26746 6.91632 2.18764 6.8509C1.69842 6.44997 1.29706 5.98445 1.0258 5.46335C0.872791 5.16942 0.987031 4.80711 1.28096 4.6541Z"}}]},Is=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"eyelash-single",ref:t,icon:ju}))});Is.displayName="EyelashSingle";const $u=Is;var zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6.06409 5.53454C5.93592 5.53454 5.84083 5.41567 5.86897 5.29063L5.95442 4.9109C6.05444 4.48178 6.23806 4.11547 6.51182 3.81952 6.81082 3.49628 7.25398 3.35405 7.79738 3.35405 7.99847 3.35405 8.21359 3.37775 8.44188 3.42245 8.46089 3.42617 8.47974 3.43006 8.49846 3.4341 8.7099 3.4798 8.93698 3.38478 9.02031 3.18514L9.24767 2.6404C9.33457 2.43219 9.23178 2.19404 9.01582 2.12874 8.98358 2.11899 8.95028 2.10912 8.91591 2.09914 8.62745 2.01631 8.28392 1.97217 7.88074 1.97217 6.82015 1.97217 6.02714 2.23936 5.4746 2.7444 4.90987 3.26069 4.50889 3.99917 4.28413 4.9762L2.83703 11.1909C2.76126 11.5286 2.666 11.8917 2.54844 12.2812 2.42975 12.6734 2.2873 13.0595 2.12221 13.4373 1.95577 13.8159 1.76813 14.1762 1.55955 14.5171 1.49345 14.6251 1.42515 14.7282 1.35467 14.8263 1.26508 14.9509 1.3347 15.133 1.48655 15.1554 2.13635 15.2509 2.8179 15.0763 3.18197 14.5296 3.32661 14.3124 3.46779 14.0646 3.60509 13.7851 3.96635 13.0497 4.30522 12.0103 4.61867 10.6574L5.469 7.01534C5.49013 6.92483 5.57082 6.86081 5.66376 6.86081H7.62478C7.8097 6.86081 7.97051 6.73405 8.01371 6.55425L8.14014 6.02798C8.20057 5.77642 8.00992 5.53454 7.75121 5.53454H6.06409zM14.3211 5.72037L12.5124 7.96963 11.4089 5.77754C11.3422 5.63012 11.1954 5.5354 11.0336 5.5354H10.3129C10.0085 5.5354 9.80921 5.85428 9.9427 6.1279L11.4089 9.05502 8.79783 12.1493C8.56587 12.4158 8.75519 12.8315 9.10855 12.8315H9.68607C9.80672 12.8315 9.9605 12.7822 10.0388 12.6904L12.1108 10.2648 13.1176 12.561C13.1786 12.7231 13.333 12.8315 13.5061 12.8315H14.3C14.5831 12.8315 14.7417 12.6175 14.6426 12.3524L13.1728 9.28628C13.1728 9.28628 15.4009 6.45542 15.6013 6.17892 15.7966 5.90929 15.6023 5.5354 15.2693 5.5354H14.6661C14.5275 5.5354 14.4333 5.58887 14.3211 5.72037z"}}]},Rs=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"fx-single",ref:t,icon:zu}))});Rs.displayName="FxSingle";const Yu=Rs;var Xu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},Ms=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"increase-single",ref:t,icon:Xu}))});Ms.displayName="IncreaseSingle";const bs=Ms;var Gu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ts=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"more-down-single",ref:t,icon:Gu}))});Ts.displayName="MoreDownSingle";const zn=Ts;var Zu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.90913 3.57564C6.14345 3.34132 6.52335 3.34132 6.75766 3.57564L10.7577 7.57564C10.992 7.80995 10.992 8.18985 10.7577 8.42417L6.75766 12.4242C6.52335 12.6585 6.14345 12.6585 5.90913 12.4242C5.67482 12.1899 5.67482 11.81 5.90913 11.5756L9.48487 7.9999L5.90913 4.42417C5.67482 4.18985 5.67482 3.80995 5.90913 3.57564Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ws=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"more-single",ref:t,icon:Zu}))});ws.displayName="MoreSingle";const or=ws;var Ku={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.69,y:12.25,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.74646 2.1642C7.34284 1.65121 6.85947 1.28205 6.38447 1.09593C5.86863 0.893787 5.15166 0.852126 4.70047 1.42917C4.29842 1.94344 4.33082 2.70249 4.57691 3.50395C4.68808 3.8661 4.86846 4.22254 5.12522 4.56617C5.13695 4.58185 5.14927 4.5968 5.16211 4.61102C5.17152 4.6214 5.18122 4.63139 5.19115 4.64096C5.20459 4.65393 5.21855 4.66618 5.23296 4.6777L3.5064 6.40422C3.26756 6.64306 3.26756 7.03033 3.5064 7.26919L7.23756 11.0004C7.47648 11.2392 7.86375 11.2392 8.1026 11.0004L12.8329 6.27001C13.0717 6.03117 13.0717 5.6439 12.8329 5.40505L9.10172 1.67387C8.86288 1.43503 8.47561 1.43503 8.23676 1.67387L7.74646 2.1642ZM7.46162 4.50638C7.47252 4.57574 7.48163 4.64652 7.4888 4.71868C7.52232 5.05481 7.82194 5.30013 8.15807 5.26661C8.4942 5.23311 8.73954 4.93345 8.70601 4.59732C8.65786 4.11463 8.54251 3.6666 8.37892 3.26169L8.66928 2.97135L11.5354 5.83753L10.6106 6.76237H4.87824L7.40802 4.2326C7.42885 4.32128 7.44684 4.41255 7.46162 4.50638ZM6.87284 3.03784C6.57441 2.62008 6.22261 2.34634 5.93815 2.23487C5.80233 2.18165 5.71528 2.17827 5.67638 2.18335C5.6725 2.18387 5.66929 2.18443 5.6666 2.18497L5.6619 2.18607C5.64166 2.21954 5.53594 2.45979 5.74626 3.1449C5.81241 3.36036 5.92262 3.58602 6.09307 3.81761L6.87284 3.03784Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.1932 11.5463C12.6454 11.5463 13.012 11.1797 13.012 10.7275C13.012 10.4475 12.6981 9.92821 12.459 9.5733C12.3299 9.38173 12.0564 9.38174 11.9274 9.57331C11.6883 9.92822 11.3744 10.4475 11.3744 10.7275C11.3744 11.1797 11.741 11.5463 12.1932 11.5463Z"}}]}]},Es=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"paint-bucket",ref:t,icon:Ku}))});Es.displayName="PaintBucket";const qu=Es;var Qu={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.00008 12.3671C8.46031 12.3671 8.83342 11.994 8.83342 11.5338C8.83342 11.0735 8.46031 10.7004 8.00008 10.7004C7.53985 10.7004 7.16675 11.0735 7.16675 11.5338C7.16675 11.994 7.53985 12.3671 8.00008 12.3671ZM8.5999 4.4335C8.5999 4.10213 8.33127 3.8335 7.9999 3.8335C7.66853 3.8335 7.3999 4.10213 7.3999 4.4335V9.36683C7.3999 9.6982 7.66853 9.96683 7.9999 9.96683C8.33127 9.96683 8.5999 9.6982 8.5999 9.36683V4.4335Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ys=V.forwardRef(function(o,t){return V.createElement(Se,Object.assign({},o,{id:"warning-single",ref:t,icon:Qu}))});ys.displayName="WarningSingle";const ir=ys,Ju=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),C.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),C.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),C.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),C.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),C.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),C.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),C.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),C.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),C.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),C.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),C.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),C.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),C.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),C.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),C.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),C.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),C.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),C.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),C.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),C.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),C.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),C.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),C.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),C.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),C.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),eh=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),C.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),C.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),C.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),C.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),C.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),C.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),C.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),C.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),C.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),C.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),C.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),C.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),C.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),C.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),C.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),C.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),C.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),C.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),C.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),C.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),C.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),C.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),C.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),C.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),th=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),C.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),C.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),C.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),C.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),C.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),C.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),C.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),C.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),C.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),C.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),C.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),C.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),C.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),C.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),C.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),C.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),C.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),C.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),C.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),nh=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),C.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),C.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),C.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),C.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),C.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),C.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),C.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),C.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),C.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),C.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),C.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),C.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),C.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),C.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),C.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),C.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),C.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),C.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),C.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),C.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),C.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),C.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),C.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),C.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),C.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),C.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),C.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),C.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),C.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),C.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),C.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),C.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),C.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),C.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),C.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),C.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),C.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),C.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),C.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),C.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),C.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),C.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),C.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),C.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),C.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),C.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),oh=()=>C.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),ih=()=>C.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),C.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),C.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),C.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),C.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),C.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),C.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),C.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),C.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),C.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),C.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),C.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),C.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),C.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),C.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),C.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),C.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),C.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),rh=()=>C.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),C.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),C.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),C.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),C.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),C.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),C.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),C.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),C.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),C.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),C.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),C.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),sh=()=>C.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[C.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),C.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),C.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),C.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),C.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),C.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),C.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),C.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),C.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),C.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),C.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),C.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),C.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),C.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),C.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),C.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),C.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),C.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),C.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),C.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),ah=()=>C.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),rr=()=>C.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function sr(o){const{type:t=l.BorderStyleTypes.THIN}=o;switch(t){case l.BorderStyleTypes.DASH_DOT:return C.jsx(Ju,{});case l.BorderStyleTypes.DASH_DOT_DOT:return C.jsx(eh,{});case l.BorderStyleTypes.DASHED:return C.jsx(th,{});case l.BorderStyleTypes.HAIR:return C.jsx(nh,{});case l.BorderStyleTypes.MEDIUM:return C.jsx(oh,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return C.jsx(ih,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return C.jsx(rh,{});case l.BorderStyleTypes.MEDIUM_DASHED:return C.jsx(sh,{});case l.BorderStyleTypes.THICK:return C.jsx(ah,{});case l.BorderStyleTypes.THIN:return C.jsx(rr,{});default:return C.jsx(rr,{})}}const lh="univer-ui-plugin-sheets-border-panel",ch="univer-ui-plugin-sheets-border-panel-position",dh="univer-ui-plugin-sheets-border-panel-position-item",uh="univer-ui-plugin-sheets-border-panel-position-item-active",hh="univer-ui-plugin-sheets-border-panel-styles",mh="univer-ui-plugin-sheets-border-panel-board",gh="univer-ui-plugin-sheets-border-panel-button",fh="univer-ui-plugin-sheets-border-panel-more-icon",ye={uiPluginSheetsBorderPanel:lh,uiPluginSheetsBorderPanelPosition:ch,uiPluginSheetsBorderPanelPositionItem:dh,uiPluginSheetsBorderPanelPositionItemActive:uh,uiPluginSheetsBorderPanelStyles:hh,uiPluginSheetsBorderPanelBoard:mh,uiPluginSheetsBorderPanelButton:gh,uiPluginSheetsBorderPanelMoreIcon:fh},Os=`${Nt}_BORDER_PANEL_COMPONENT`,xs=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"HorizontalBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"VerticalBorder",value:"vertical"},{label:"borderLine.borderTlbr",icon:"BackSlashSingle",value:"tlbr"},{label:"borderLine.borderTlbcTlmr",icon:"LeftDoubleDiagonalSingle",value:"tlbc_tlmr"},{label:"borderLine.borderTlbrTlbcTlmr",icon:"LeftTridiagonalSingle",value:"tlbr_tlbc_tlmr"},{label:"borderLine.borderBlTr",icon:"SlashSingle",value:"bltr"},{label:"borderLine.borderMltrBctr",icon:"RightDoubleDiagonalSingle",value:"mltr_bctr"}],_h=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function Sh(o){var c;const t=G.useDependency(I.ComponentManager),e=G.useDependency(S.BorderStyleManagerService),{onChange:n,value:i}=o;function r(u,d){n==null||n({...i,[d]:u})}function s(u){const d=t.get(u);return d&&C.jsx(d,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function a(u){u.stopPropagation()}return C.jsxs("section",{className:ye.uiPluginSheetsBorderPanel,children:[C.jsx("div",{className:ye.uiPluginSheetsBorderPanelPosition,children:xs.map(u=>C.jsx("div",{className:e.getBorderInfo().type===u.value?`${ye.uiPluginSheetsBorderPanelPositionItemActive} ${ye.uiPluginSheetsBorderPanelPositionItem}`:ye.uiPluginSheetsBorderPanelPositionItem,onClick:d=>{d.stopPropagation(),r(u.value,"type")},children:s(u.icon)},u.value))}),C.jsxs("div",{className:ye.uiPluginSheetsBorderPanelStyles,children:[C.jsx("div",{children:C.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:C.jsx("section",{className:ye.uiPluginSheetsBorderPanelBoard,onClick:a,children:C.jsx(re.ColorPicker,{onChange:u=>r(u,"color")})}),children:C.jsxs("a",{className:ye.uiPluginSheetsBorderPanelButton,onClick:a,children:[C.jsx(qu,{extend:{colorChannel1:(c=i.color)!=null?c:"rgb(var(--primary-color))"}}),C.jsx("span",{className:ye.uiPluginSheetsBorderPanelMoreIcon,children:C.jsx(zn,{})})]})})}),C.jsx("div",{children:C.jsx(re.Dropdown,{align:{offset:[0,18]},overlay:C.jsx("section",{onClick:a,children:C.jsx(re.Menu,{children:_h.map(u=>C.jsx(re.MenuItem,{eventKey:u.value.toString(),onClick:()=>r(u.value,"style"),children:C.jsx(sr,{type:u.value})},u.value))})}),children:C.jsxs("a",{className:ye.uiPluginSheetsBorderPanelButton,onClick:a,children:[C.jsx(sr,{type:l.BorderStyleTypes.THIN}),C.jsx("span",{className:ye.uiPluginSheetsBorderPanelMoreIcon,children:C.jsx(zn,{})})]})})})]})]})}const ph="univer-count-bar",Ch={countBar:ph},vh=[50,80,100,130,150,170,200,400];function Ih(){const o=G.useDependency(l.ICommandService),t=G.useDependency(l.IUniverInstanceService),e=V.useCallback(()=>{const s=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet().getZoomRatio()*100||100;return Math.round(s)},[t]),[n,i]=V.useState(()=>e());V.useEffect(()=>o.onCommandExecuted(a=>{if(a.id===Fe.id||a.id===S.SetWorksheetActiveOperation.id){const c=e();i(c)}}).dispose,[o,e]);function r(s){i(s);const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),c=a==null?void 0:a.getActiveSheet();if(c==null)return;const u=s/100;o.executeCommand(qn.id,{unitId:a.getUnitId(),subUnitId:c.getSheetId(),zoomRatio:u})}return C.jsx(re.Slider,{min:Eo[0],value:n,shortcuts:vh,onChange:r})}function Rh(o){return C.jsx("section",{className:Ch.countBar,children:C.jsx(Ih,{})})}const Mh="univer-editor-container",bh="univer-editor-input",ar={editorContainer:Mh,editorInput:bh},Yn=-1e3,lr={width:0,height:0,top:Yn,left:Yn},Th=()=>{const[o,t]=V.useState({...lr}),e=G.useDependency(sn),n=G.useDependency(I.IEditorService),i=G.useDependency(l.IContextService),r=I.useObservable(()=>i.subscribeContextValue$(I.DISABLE_AUTO_FOCUS_KEY),!1,void 0,[i,I.DISABLE_AUTO_FOCUS_KEY]),s={id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}};return V.useEffect(()=>{e.state$.subscribe(a=>{if(a==null)return;const{startX:c=Yn,startY:u=Yn,endX:d=0,endY:h=0,show:m=!1}=a;if(!m)t({...lr});else{t({width:d-c-E.FIX_ONE_PIXEL_BLUR_OFFSET+2,height:h-u-E.FIX_ONE_PIXEL_BLUR_OFFSET+2,left:c+E.FIX_ONE_PIXEL_BLUR_OFFSET,top:u+E.FIX_ONE_PIXEL_BLUR_OFFSET});const g=n.getEditor(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(g==null)return;const{left:f,top:_,width:p,height:v}=g.getBoundingClientRect();e.setRect({left:f,top:_,width:p,height:v})}})},[]),V.useEffect(()=>{r||e.setFocus(!0)},[r,o]),C.jsx("div",{className:ar.editorContainer,style:{left:o.left,top:o.top,width:o.width,height:o.height},children:C.jsx(I.TextEditor,{id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,className:ar.editorInput,snapshot:s,cancelDefaultResizeListener:!0,isSheetEditor:!0,isSingle:!1})})},wh="univer-defined-name",Eh="univer-defined-name-drop-down",yh="univer-defined-name-overlay",Oh="univer-defined-name-overlay-container",xh="univer-defined-name-overlay-item",Nh="univer-defined-name-overlay-item-name",Ah="univer-defined-name-overlay-item-name-for-sheet",Dh="univer-defined-name-overlay-item-formula",Ph="univer-defined-name-overlay-manager",Hh="univer-defined-name-overlay-manager-title",Lh="univer-defined-name-overlay-manager-content",Uh="univer-defined-name-container",Vh="univer-defined-name-container-scroll",Bh="univer-defined-name-container-addButton",Fh="univer-defined-name-container-addButton-text",kh="univer-defined-name-container-item",Wh="univer-defined-name-container-item-name",jh="univer-defined-name-container-item-name-for-sheet",$h="univer-defined-name-container-item-formula-or-refString",zh="univer-defined-name-container-item-update",Yh="univer-defined-name-container-item-delete",Xh="univer-defined-name-container-item-show",Gh="univer-defined-name-input",Zh="univer-defined-name-input-validation",ae={definedName:wh,definedNameDropDown:Eh,definedNameOverlay:yh,definedNameOverlayContainer:Oh,definedNameOverlayItem:xh,definedNameOverlayItemName:Nh,definedNameOverlayItemNameForSheet:Ah,definedNameOverlayItemFormula:Dh,definedNameOverlayManager:Ph,definedNameOverlayManagerTitle:Hh,definedNameOverlayManagerContent:Lh,definedNameContainer:Uh,definedNameContainerScroll:Vh,definedNameContainerAddButton:Bh,definedNameContainerAddButtonText:Fh,definedNameContainerItem:kh,definedNameContainerItemName:Wh,definedNameContainerItemNameForSheet:jh,definedNameContainerItemFormulaOrRefString:$h,definedNameContainerItemUpdate:zh,definedNameContainerItemDelete:Yh,definedNameContainerItemShow:Xh,definedNameInput:Gh,definedNameInputValidation:Zh},Ns="DefinedNameContainer",zo="AllDefaultWorkbook",As={id:"sidebar.operation.defined-name",type:l.CommandType.COMMAND,handler:async(o,t)=>{const e=o.get(I.ISidebarService),n=o.get(I.IEditorService),i=o.get(l.LocaleService),r=o.get(l.IUniverInstanceService),s=S.getSheetCommandTarget(r);if(!s)return!1;const{unitId:a}=s;switch(t.value){case"open":n.setOperationSheetUnitId(a),e.open({header:{title:i.t("definedName.featureTitle")},children:{label:Ns},onClose:()=>{n.closeRangePrompt()},width:333});break;case"close":default:e.close();break}return!0}};function Kh(o){const t=G.useDependency(l.ICommandService),e=G.useDependency(l.LocaleService),n=G.useDependency(Z.IDefinedNamesService),s=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=()=>{const m=n.getDefinedNameMap(s);return m?Array.from(Object.values(m)):[]},[c,u]=V.useState(a());V.useEffect(()=>{const m=n.update$.subscribe(()=>{u(a())});return()=>{m.unsubscribe()}},[]);const d=()=>{t.executeCommand(As.id,{value:"open"})},h=m=>{n.focusRange(s,m.id)};return C.jsxs("div",{className:ae.definedNameOverlay,children:[C.jsx("div",{className:ae.definedNameOverlayContainer,children:c.map((m,g)=>C.jsxs("div",{className:ae.definedNameOverlayItem,onClick:()=>{h(m)},children:[C.jsx("div",{className:ae.definedNameOverlayItemName,title:m.name,children:m.name}),C.jsx("div",{className:ae.definedNameOverlayItemFormula,title:m.formulaOrRefString,children:m.formulaOrRefString})]},g))}),C.jsxs("div",{className:ae.definedNameOverlayManager,onClick:d,children:[C.jsx("div",{className:ae.definedNameOverlayManagerTitle,children:e.t("definedName.managerTitle")}),C.jsx("div",{className:ae.definedNameOverlayManagerContent,children:e.t("definedName.managerDescription")})]})]})}function qh(){const[o,t]=V.useState(""),e=G.useDependency(Z.IDefinedNamesService);return V.useEffect(()=>{const n=e.currentRange$.subscribe(()=>{t(e.getCurrentRangeForString())});return()=>{n.unsubscribe()}},[]),C.jsxs("div",{className:ae.definedName,children:[C.jsx(re.Input,{value:o,type:"text",size:"small",affixWrapperStyle:{border:"none",paddingLeft:"6px",paddingRight:"6px",height:"100%"}}),C.jsx(re.Dropdown,{overlay:C.jsx(Kh,{}),children:C.jsx("div",{className:ae.definedNameDropDown,children:C.jsx(zn,{})})})]})}const Qh="univer-formula-box",Jh="univer-name-ranges",em="univer-formula-bar",tm="univer-formula-icon",nm="univer-formula-icon-wrapper",om="univer-icon-container",im="univer-icon-container-success",rm="univer-formula-active",sm="univer-icon-container-error",am="univer-icon-container-fx",lm="univer-formula-input",cm="univer-formula-content",dm="univer-arrow-container",me={formulaBox:Qh,nameRanges:Jh,formulaBar:em,formulaIcon:tm,formulaIconWrapper:nm,iconContainer:om,iconContainerSuccess:im,formulaActive:rm,iconContainerError:sm,iconContainerFx:am,formulaInput:lm,formulaContent:cm,arrowContainer:dm};function um(){const[o,t]=V.useState(me.formulaGrey),[e,n]=V.useState(0),i=G.useDependency(to),r=G.useDependency(Ee),a=G.useDependency(l.ThemeService).getCurrentTheme().primaryColor,c={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.TOP,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};V.useEffect(()=>{const f=r.visible$.subscribe(_=>{t(_.visible?me.formulaActive:me.formulaGrey)});return()=>f.unsubscribe()},[r.visible$]);function u(f){if(f==null)return;const _=f.getBoundingClientRect();i.setPosition(_)}function d(){n(e===0?1:0),setTimeout(()=>{i.handleFoldBtnClick(e===1)},150)}function h(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:E.DeviceInputEventType.Keyboard,keycode:I.KeyCode.ESC})}function m(){r.isVisible().visible&&r.changeVisible({visible:!1,eventType:E.DeviceInputEventType.PointerDown})}function g(){i.handleFxBtnClick(!0)}return C.jsxs("div",{className:me.formulaBox,style:{height:e===0?"28px":"82px"},children:[C.jsx("div",{className:me.nameRanges,children:C.jsx(qh,{})}),C.jsxs("div",{className:me.formulaBar,children:[C.jsx("div",{className:me.formulaIcon,children:C.jsxs("div",{className:me.formulaIconWrapper,children:[C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerError,o),onClick:h,children:C.jsx(Lu,{})}),C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerSuccess,o),onClick:m,children:C.jsx(Jt,{})}),C.jsx("span",{className:Oe(me.iconContainer,me.iconContainerFx),onClick:g,children:C.jsx(Yu,{})})]})}),C.jsxs("div",{className:me.formulaInput,children:[C.jsx(I.TextEditor,{id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,isSheetEditor:!0,resizeCallBack:u,cancelDefaultResizeListener:!0,onContextMenu:f=>f.preventDefault(),className:me.formulaContent,snapshot:c,isSingle:!1}),C.jsx("div",{className:me.arrowContainer,onClick:d,children:e===0?C.jsx(nr,{}):C.jsx(nr,{style:{transform:"rotateZ(180deg)"}})})]})]}),C.jsx(I.ProgressBar,{barColor:a})]})}const hm="univer-operate-container",mm="univer-auto-fill-popup-menu",gm="univer-auto-fill-popup-menu-item",fm="univer-auto-fill-popup-menu-item-icon",_m="univer-auto-fill-popup-menu-item-title",Sm="univer-auto-fill-popup-menu-item-hide",pm="univer-btn-container",Cm="univer-btn-container-expand",ct={operateContainer:hm,autoFillPopupMenu:mm,autoFillPopupMenuItem:gm,autoFillPopupMenuItemIcon:fm,autoFillPopupMenuItemTitle:_m,autoFillPopupMenuItemHide:Sm,btnContainer:pm,btnContainerExpand:Cm},vm=()=>{const[,o]=V.useState({});return V.useCallback(()=>o(t=>!t),[])},Im=()=>{var Q;const o=G.useDependency(l.ICommandService),t=G.useDependency(exports.SheetSkeletonManagerService),e=G.useDependency(l.IUniverInstanceService),n=G.useDependency(E.IRenderManagerService),i=G.useDependency(Ne),r=G.useDependency(yt),s=G.useDependency(l.LocaleService),[a,c]=V.useState([]),[u,d]=V.useState(!1),[h,m]=V.useState({row:-1,col:-1}),[g,f]=V.useState(oe.SERIES),[_,p]=V.useState(!1),v=()=>{p(!0)},M=()=>{p(!1)},b=vm();if(V.useEffect(()=>o.onCommandExecuted((H,k)=>{H.id===ot.id&&b()}).dispose,[b,o]),V.useEffect(()=>l.toDisposable(t.currentSkeleton$.subscribe(H=>{H&&b()})).dispose,[t,b]),V.useEffect(()=>l.toDisposable(r.menu$.subscribe(H=>{c(H.map(k=>({...k,index:H.indexOf(k)})))})).dispose,[r]),V.useEffect(()=>l.toDisposable(r.showMenu$.subscribe(H=>{const{source:k,target:Y}=r.autoFillLocation||{source:null,target:null};if(H&&k&&Y){const X=Math.max(k.rows[k.rows.length-1],Y.rows[Y.rows.length-1]),J=Math.max(k.cols[k.cols.length-1],Y.cols[Y.cols.length-1]);m({row:X,col:J})}else m({row:-1,col:-1})})).dispose,[r]),V.useEffect(()=>l.toDisposable(r.applyType$.subscribe(H=>{f(H)})).dispose,[r]),V.useEffect(()=>{function P(){d(!1)}return document.addEventListener("wheel",P),()=>{document.removeEventListener("wheel",P)}},[u]),h.col<0||h.row<0)return null;const T=it(e,n);if(!T)return null;const{scene:w}=T,y=(Q=t.getCurrent())==null?void 0:Q.skeleton,O=i.getViewPort(),x=w==null?void 0:w.scaleX,A=w==null?void 0:w.scaleY,F=w==null?void 0:w.getScrollXY(O);if(!x||!w||!x||!A||!F)return null;const N=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endX)||0,L=(y==null?void 0:y.getNoMergeCellPositionByIndex(h.row,h.col).endY)||0,B=y==null?void 0:y.convertTransformToOffsetX(N,x,F),j=y==null?void 0:y.convertTransformToOffsetY(L,A,F);if(B==null||j==null)return null;const z=P=>{d(P)},q=P=>{o.executeCommand(rs.id,{type:P.value})},K=u||_,$=a.filter(P=>!P.disable);return C.jsx("div",{onMouseEnter:v,onMouseLeave:M,style:{left:`${B+2}px`,top:`${j+2}px`,position:"absolute"},children:C.jsx(re.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:C.jsx("ul",{className:ct.autoFillPopupMenu,children:$.map(P=>C.jsxs("li",{onClick:()=>q(P),className:ct.autoFillPopupMenuItem,children:[C.jsx("span",{className:ct.autoFillPopupMenuItemIcon,children:P.value===g&&C.jsx(Jt,{style:{color:"rgb(var(--green-700, #409f11))"}})}),C.jsx("span",{className:ct.autoFillPopupMenuItemTitle,children:s.t(P.label)})]},P.index))}),visible:u,onVisibleChange:z,children:C.jsxs("div",{className:Oe(ct.btnContainer,{[ct.btnContainerExpand]:u}),children:[C.jsx(Du,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),K&&C.jsx(zn,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Rm=()=>C.jsx("div",{className:ct.operateContainer,children:C.jsx(Im,{})}),Mm="univer-sheet-bar",bm="univer-sheet-bar-options",Tm="univer-sheet-bar-options-divider",fn={sheetBar:Mm,sheetBarOptions:bm,sheetBarOptionsDivider:Tm},wm="univer-sheet-bar-btn",Em={sheetBarBtn:wm};function Nn(o){const{children:t,className:e,style:n,disabled:i=!1,onClick:r,...s}=o,a=c=>{if(i){c.preventDefault();return}r&&r(c)};return C.jsx("button",{className:Em.sheetBarBtn,style:n,disabled:i,onClick:a,...s,children:t})}const ym="univer-sheet-bar-menu",Om="univer-sheet-bar-menu-item",xm="univer-sheet-bar-menu-item-icon",Nm="univer-sheet-bar-menu-item-hide",Am="univer-sheet-bar-menu-item-select",Dm="univer-sheet-bar-menu-item-label",Qe={sheetBarMenu:ym,sheetBarMenuItem:Om,sheetBarMenuItemIcon:xm,sheetBarMenuItemHide:Nm,sheetBarMenuItemSelect:Am,sheetBarMenuItemLabel:Dm};function Pm(o){const{style:t}=o,[e,n]=V.useState([]),[i,r]=V.useState(!1),s=G.useDependency(l.IUniverInstanceService),a=G.useDependency(l.ICommandService),c=G.useDependency(Pt),u=I.useObservable(()=>s.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[]),d=_=>{const{sheetId:p}=_;!p||!u||(_.hidden?a.executeCommand(S.SetWorksheetShowCommand.id,{unitId:u.getUnitId(),subUnitId:p,value:p}):_.selected||a.executeCommand(S.SetWorksheetActivateCommand.id,{unitId:u.getUnitId(),subUnitId:p}),r(!1))},h=V.useCallback(()=>{if(!u)return;const _=u.getSheets(),p=u.getActiveSheet(),v=_.map((M,b)=>({label:M.getName(),index:`${b}`,sheetId:M.getSheetId(),hidden:M.isSheetHidden()===l.BooleanNumber.TRUE,selected:p===M}));n(v)},[u]),m=V.useCallback(()=>a.onCommandExecuted(_=>{switch(_.id){case S.SetWorksheetHideMutation.id:case S.RemoveSheetMutation.id:case S.SetWorksheetNameMutation.id:case S.InsertSheetMutation.id:case S.SetWorksheetOrderMutation.id:case S.SetWorksheetActiveOperation.id:h();break}}),[a,h]);function g(){r(!0)}const f=_=>{r(_)};return V.useEffect(()=>{h();const _=new l.DisposableCollection;return _.add(m()),_.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:g})),()=>_.dispose()},[m,c,h,u]),C.jsx(re.Dropdown,{placement:"topLeft",trigger:["click"],overlay:C.jsx("ul",{className:Qe.sheetBarMenu,style:{...t},children:e.map(_=>C.jsxs("li",{onClick:()=>d(_),className:_.selected?`${Qe.sheetBarMenuItem} ${Qe.sheetBarMenuItemSelect}`:_.hidden?`${Qe.sheetBarMenuItem} ${Qe.sheetBarMenuItemHide}`:Qe.sheetBarMenuItem,children:[C.jsx("span",{className:Qe.sheetBarMenuItemIcon,children:_.selected?C.jsx(Jt,{}):_.hidden?C.jsx($u,{}):C.jsx(Jt,{})}),C.jsx("span",{className:Qe.sheetBarMenuItemLabel,children:_.label})]},_.index))}),visible:i,onVisibleChange:f,children:C.jsx(Nn,{children:C.jsx(Vu,{})})})}const Hm="univer-slide-tab-bar-container",Lm="univer-slide-tab-bar",Um="univer-slide-tab-item",Vm="univer-slide-tab-active",Bm="univer-slide-tab-span",Fm="univer-slide-tab-span-edit",km="univer-slide-tab-item-dropdown",Re={slideTabBarContainer:Hm,slideTabBar:Lm,slideTabItem:Um,slideTabActive:Vm,slideTabSpan:Bm,slideTabSpanEdit:Fm,slideTabItemDropdown:km};function Wm(o){const{sheetId:t,label:e,color:n,selected:i}=o,[r,s]=V.useState(i),a=G.useDependency(l.ThemeService);V.useEffect(()=>{s(i)},[i]);const c=u=>{const d=a.getCurrentTheme(),h=d.textColor,m=d.colorWhite;return new l.ColorKit(u).isDark()?m:h};return C.jsx("div",{"data-id":t,className:r?`${Re.slideTabActive} ${Re.slideTabItem}`:Re.slideTabItem,style:{backgroundColor:!r&&n?n:"",color:!r&&n?c(n):"",boxShadow:r&&n?`0px 0px 8px rgba(0, 0, 0, 0.08), inset 0px -2px 0px 0px ${n}`:""},children:C.jsx("span",{className:Re.slideTabSpan,children:e})},t)}const jm={easeOutStrong(o,t,e,n){return-e*((o=o/n-1)*o*o*o-1)+t},backOut(o,t,e,n,i){return typeof i>"u"&&(i=.7),e*((o=o/n-1)*o*((i+1)*o+i)+1)+t}},$m={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(o){},success(o){},cancel(o){},complete(o){}};class zm{constructor(t){R(this,"_config");R(this,"_status",0);R(this,"_start",0);R(this,"_handle",0);R(this,"_delayHandle",null);this._config={...$m,...t},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...t){let e=0;return new Promise(n=>{for(let i=0;i<t.length;i++){const r=t[i],s=r._config,a=s.success;s.loop||(s.success=u=>{e++,a&&a.call(r,u),e===t.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let t=Date.now()-this._start;t=t>=this._config.duration?this._config.duration:t;const n=jm[this._config.type](t,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(t===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class ut{constructor(t,e){R(this,"_slideTabItem");R(this,"_animate");R(this,"_midline",0);R(this,"_translateX");R(this,"_scrollbar");R(this,"_slideTabBar");R(this,"_editMode");R(this,"_placeholder");this._slideTabItem=t,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=e,this._placeholder=null,this._scrollbar=e.getScrollbar(),this.update()}static midline(t){return t.getBoundingRect().x+t.getBoundingRect().width/2}static leftLine(t){return t.getBoundingRect().x}static rightLine(t){return t.getBoundingRect().x+t.getBoundingRect().width}static make(t,e){const n=[];return t.forEach(i=>n.push(new ut(i,e))),n}getSlideTabItem(){return this._slideTabItem}getEditor(){return this._slideTabItem.querySelector("span")}focus(){var t;(t=this.getEditor())==null||t.focus()}selectAll(){const t=this.getEditor();t&&Mt.keepSelectAll(t)}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}translateX(t){return this._translateX=t,this._slideTabItem.style.transform=`translateX(${t}px)`,this.getTranslateXDirection()}setEditor(t){let e=!0;if(this._editMode===!1){const n=this._slideTabItem.querySelector("span"),i=u=>{if(!this.nameCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",i),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const d=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,d)}t&&t(u)}};let r=u=>{n&&(u.stopPropagation(),u.key==="Enter"&&n.blur())};const s=u=>{e=!1},a=u=>{e=!0},c=u=>{if(!n)return;const d=50;setTimeout(()=>{if(e){const h=n.innerText;h.length>d&&(n.innerText=h.substring(0,d),Mt.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",i),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Mt.keepSelectAll(n))}}nameCheck(){const t=this._slideTabItem.querySelector("span");if(!t)return!1;const e=t.innerText;return this._slideTabBar.getConfig().onNameCheckAlert(e)}animate(){return{translateX:t=>{this._translateX!==t&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new zm({begin:this._translateX,end:t,receive:e=>{this._slideTabItem.style.transform=`translateX(${e}px)`}}),this._translateX=t,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(t){this._slideTabItem.after(t._slideTabItem||t)}update(){this._midline=ut.midline(this)}disableFixed(){if(this._placeholder){const t=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("box-sizing"),this._slideTabItem.style.removeProperty("font-size"),this._slideTabItem.style.removeProperty("font-family"),this._slideTabItem.style.removeProperty("font-weight"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("border-radius"),this._placeholder.after(this._slideTabItem),t.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const t=document.createElement("div"),e=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),i=this._slideTabItem.querySelector("span");if(this._placeholder=t,this._placeholder.style.width=`${e.width}px`,this._placeholder.style.height=`${e.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,i){const r=getComputedStyle(i).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.fontFamily=n.fontFamily,this._slideTabItem.style.fontWeight=n.fontWeight,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${e.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${e.y}px`,this._slideTabItem.style.width=`${e.width}px`,this._slideTabItem.style.height=`${e.height}px`,this._slideTabItem.style.position="fixed",this._slideTabItem.after(t),document.body.appendChild(this._slideTabItem)}addEventListener(t,e,n){this._slideTabItem.addEventListener(t,e,n)}removeEventListener(t,e,n){this._slideTabItem.removeEventListener(t,e,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const t=this._slideTabItem.getBoundingClientRect();return t.x+=this._scrollbar.getScrollX(),t}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const t=ut.midline(this);return t>this._midline?1:t<this._midline?-1:0}equals(t){return t&&t._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class Ym{constructor(t){R(this,"_slideTabBar");R(this,"_scrollX");const e=t.primeval();this._scrollX=e.scrollLeft,this._slideTabBar=t}scrollX(t){const e=this._slideTabBar.primeval();e.scrollLeft=t,this._scrollX=e.scrollLeft}scrollRight(){const t=this._slideTabBar.primeval();t.scrollLeft=t.scrollWidth,this._scrollX=t.scrollLeft}getScrollX(){return this._scrollX}}const It=class It{constructor(t){R(this,"_activeTabItemIndex",0);R(this,"_slideTabBar");R(this,"_slideTabItems",[]);R(this,"_config");R(this,"_downActionX",0);R(this,"_moveActionX",0);R(this,"_compareIndex",0);R(this,"_activeTabItem",null);R(this,"_moveAction");R(this,"_upAction");R(this,"_downAction");R(this,"_wheelAction");R(this,"_scrollIncremental",0);R(this,"_compareDirection",0);R(this,"_autoScrollTime",null);R(this,"_slideScrollbar");R(this,"_longPressTimer",null);R(this,"_leftBoundingLine",0);R(this,"_rightBoundingLine",0);R(this,"_leftMoveX",0);R(this,"_rightMoveX",0);var s;if(t.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const e=t.slideTabBarContainer.querySelector(`.${(s=t.slideTabBarClassName)!=null?s:"slide-tab-bar"}`);if(e==null)throw new Error("not found slide-tab-bar");this._slideTabBar=e,this._slideScrollbar=new Ym(this),this._config=t,this._initConfig();let n=0,i=0,r=0;this._downAction=a=>{var y,O,x,A,F,N;if((y=this._activeTabItem)!=null&&y.isEditMode())return;const c=(x=(O=a.target)==null?void 0:O.closest(`.${t.slideTabBarItemClassName}`))==null?void 0:x.getAttribute("data-id"),u=this._slideTabItems.findIndex(L=>L.getId()===c);if(c==null||u===-1)return;if(this._activeTabItemIndex!==u){(A=this._activeTabItem)==null||A.removeEventListener("pointermove",this._moveAction),(F=this._activeTabItem)==null||F.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(a,c);return}if(this._compareIndex=u,this._downActionX=a.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[u],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(a.pointerId),(N=this._activeTabItem)==null||N.addEventListener("pointerup",this._upAction);const{x:h,width:m}=this._activeTabItem.getBoundingRect(),{x:g,width:f}=this.getBoundingRect(),_=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(h-_),this._rightBoundingLine=h-_+m-this._downActionX,this._leftMoveX=h-g-_,this._rightMoveX=g+f-(h+m)+_,a.button===2||this._hasEditItem())return;const{pageX:p,pageY:v}=a,M=Date.now(),b=M-r<=It.DoubleClickDelay,T=Math.abs(p-n)<10,w=Math.abs(v-i)<10;b&&T&&w&&this._activeTabItem.setEditor(),n=p,i=v,r=M,this._longPressTimer=setTimeout(()=>{var L,B;(L=this._activeTabItem)==null||L.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(a.pointerId),d.style.cursor="move",(B=this._activeTabItem)==null||B.addEventListener("pointermove",this._moveAction))},It.LongPressDelay)},this._upAction=a=>{var u,d,h;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const c=(u=this._activeTabItem)==null?void 0:u.getSlideTabItem();c&&(c.style.cursor="",c.releasePointerCapture(a.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(h=this._activeTabItem)==null||h.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(a,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=a=>{this._activeTabItem&&(this._moveActionX=a.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(a),this._scrollRight(a))},this._wheelAction=a=>{this.setScroll(a.deltaY)},this.addListener()}static checkedSkipSlide(t){let e=t.target;for(;e!=null&&e!==document.body;){if(e.getAttribute("data-slide-skip"))return!0;e=e.parentElement}return!1}static keepLastIndex(t){setTimeout(()=>{const e=window.getSelection();e&&(e.selectAllChildren(t),e.collapseToEnd())})}static keepSelectAll(t){setTimeout(()=>{const e=window.getSelection();if(!e)return;const n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)})}update(t){this._config.currentIndex=t,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let t=0;t<this._slideTabItems.length;t++)this._slideTabItems[t].animate().cancel(),this._slideTabItems[t].translateX(0),this._slideTabItems[t].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const t=this._slideTabBar.parentElement;return t?this._slideTabBar.scrollWidth-t.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(t=>{t.removeEventListener("pointerdown",this._downAction)})}setScroll(t){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t),t>0){const e=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(t){if(t>0){const e=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}else if(t<0){const e=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(t){let e=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,u=a.width;return c<s&&c+u+n*2>s?(e=t?c-r.left-n:c+u-s+n,!0):!1}),e}calculateRightScrollX(t){let e=0;const n=4;return this._slideTabItems.some(i=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=i.getSlideTabItem().getBoundingClientRect(),c=a.left,u=a.width;return c-n*2<s&&c+u>s?(e=t?c+u-r.left-r.width+n:c-s-n,!0):!1}),e}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let t=0;t<this._slideTabItems.length;t++)if(this._slideTabItems[t].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(t){const e=this.getBoundingRect(),n=t.pageX-e.x;n>e.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(e.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let t=0;t<this._slideTabItems.length;t++){const e=this._slideTabItems[t],n=this._slideTabItems[t+1];n&&e.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=0;r<t&&!(r>=t);r++)n.push(this._slideTabItems[r]);for(let r=t+1;r<e;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];ut.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const t=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),e=this._slideTabItems.length,n=[];for(let r=t+1;r<e;r++)n.push(this._slideTabItems[r]);for(let r=0;r<t;r++)this._slideTabItems[r].animate().translateX(0);let i=!0;for(let r=0;r<n.length;r++){const s=n[r];ut.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=t+r+1,i=!1):(s.animate().translateX(0),i&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){var e;const t=this._slideTabBar.querySelectorAll(`.${(e=this._config.slideTabBarItemClassName)!=null?e:"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=ut.make(t,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};R(It,"LongPressDelay",500),R(It,"DoubleClickDelay",300);let Mt=It;function Xm(){const[o,t]=V.useState([]),[e,n]=V.useState(""),[i,r]=V.useState(""),[s,a]=V.useState(!1),[c,u]=V.useState([0,0]),d=V.useRef({slideTabBar:null}),h=V.useRef(null),m=G.useDependency(l.IUniverInstanceService),g=G.useDependency(l.ICommandService),f=G.useDependency(Pt),_=G.useDependency(l.LocaleService),p=G.useDependency(I.IConfirmService),v=G.useDependency(Ne),M=G.useDependency(Ee),b=m.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);V.useEffect(()=>{N();const P=T(),H=F(),k=[L(),B(),j(),z()];return()=>{H.dispose(),P.destroy(),k.forEach(Y=>Y.unsubscribe())}},[]),V.useEffect(()=>{o.length>0&&A()},[o]);const T=()=>{const P=new Mt({slideTabBarClassName:Re.slideTabBar,slideTabBarItemActiveClassName:Re.slideTabActive,slideTabBarItemClassName:Re.slideTabItem,slideTabBarSpanEditClassName:Re.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:h.current,currentIndex:0,onChangeName:(H,k)=>{g.executeCommand(S.SetWorksheetNameCommand.id,{subUnitId:H,name:k})},onSlideEnd:(H,k)=>{g.executeCommand(S.SetWorksheetOrderCommand.id,{order:k})},onChangeTab:(H,k)=>{g.executeCommand(S.SetWorksheetActiveOperation.id,{subUnitId:k,unitId:b.getUnitId()}).then(()=>{H.button===2&&Q(!0)})},onScroll:H=>{f.setScroll(H)},onNameCheckAlert:H=>w(H)||y(H)});return d.current.slideTabBar=P,$(P),P},w=P=>{if(P.trim()===""){const H="sheetNameEmptyAlert";return p.open({id:H,title:{title:_.t("sheetConfig.sheetNameErrorTitle")},children:{title:_.t("sheetConfig.sheetNameCannotIsEmptyError")},cancelText:_.t("button.cancel"),confirmText:_.t("button.confirm"),onClose(){O(),p.close(H)},onConfirm(){O(),p.close(H)}}),!0}return!1},y=P=>{const H=m.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(H.getActiveSheet().getName()===P)return!1;const X=H.checkSheetName(P);if(X){const J="sheetNameRepeatAlert";p.open({id:J,title:{title:_.t("sheetConfig.sheetNameErrorTitle")},children:{title:_.t("sheetConfig.sheetNameAlreadyExistsError")},cancelText:_.t("button.cancel"),confirmText:_.t("button.confirm"),onClose(){p.close(J),O()},onConfirm(){p.close(J),O()}})}return X},O=()=>{v.endSelection(),setTimeout(()=>{var H;const P=(H=d.current.slideTabBar)==null?void 0:H.getActiveItem();P&&(P.focus(),P.selectAll())},0)},x=()=>{var P,H;(H=(P=d.current.slideTabBar)==null?void 0:P.getActiveItem())==null||H.setEditor()},A=()=>{var H;const P=o.findIndex(k=>k.selected);(H=d.current.slideTabBar)==null||H.update(P)},F=()=>g.onCommandExecuted(P=>{switch(P.id){case S.SetTabColorMutation.id:case S.SetWorksheetHideMutation.id:case S.RemoveSheetMutation.id:case S.SetWorksheetNameMutation.id:case S.InsertSheetMutation.id:case S.SetWorksheetOrderMutation.id:case S.SetWorksheetActiveOperation.id:N();break}}),N=()=>{const P=b.getActiveSheet().getSheetId();n(P);const H=b.getSheets(),k=b.getActiveSheet(),Y=H.filter(X=>!X.isSheetHidden()).map((X,J)=>{var ee;return{sheetId:X.getSheetId(),label:X.getName(),index:J,selected:k===X,color:(ee=X.getTabColor())!=null?ee:void 0}});t(Y)},L=()=>f.scroll$.subscribe(P=>{q(P)}),B=()=>f.scrollX$.subscribe(P=>{var H;(H=d.current.slideTabBar)==null||H.flipPage(P)}),j=()=>f.renameId$.subscribe(()=>{x()}),z=()=>f.addSheet$.subscribe(()=>{var P;(P=d.current.slideTabBar)==null||P.getScrollbar().scrollRight()}),q=P=>{const{leftEnd:H,rightEnd:k}=P;let Y="";H&&k?Y="":H&&!k?Y="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&k?Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&!k&&(Y="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(Y)},K=P=>{f.setScroll({leftEnd:P.isLeftEnd(),rightEnd:P.isRightEnd()})},$=P=>{var Y;const H=(Y=h.current)==null?void 0:Y.querySelector(`.${Re.slideTabBar}`);if(!H)return;new ResizeObserver(()=>{K(P)}).observe(H)},Q=P=>{var H,k,Y,X,J;if(!M.isForceKeepVisible()){if(P){const{left:ee}=(k=(H=h.current)==null?void 0:H.getBoundingClientRect())!=null?k:{},{left:ce}=(J=(X=(Y=d.current.slideTabBar)==null?void 0:Y.getActiveItem())==null?void 0:X.getSlideTabItem().getBoundingClientRect())!=null?J:{};ee!==void 0&&ce!==void 0&&u([ce-ee,0])}a(P)}};return C.jsx(re.Dropdown,{className:Re.slideTabItemDropdown,visible:s,align:{offset:c},trigger:["contextMenu"],overlay:C.jsx(I.Menu,{menuType:le.SHEET_BAR,onOptionSelect:P=>{const{label:H,value:k}=P;g.executeCommand(H,{value:k,subUnitId:e}),a(!1)}}),onVisibleChange:Q,children:C.jsx("div",{className:Re.slideTabBarContainer,ref:h,children:C.jsx("div",{className:Re.slideTabBar,style:{boxShadow:i},children:o.map(P=>V.createElement(Wm,{...P,key:P.sheetId,selected:e===P.sheetId}))})})})}const cr=100,Gm=()=>{const[o,t]=V.useState(!0),[e,n]=V.useState(!0),i=G.useDependency(l.ICommandService),r=G.useDependency(Pt);V.useEffect(()=>{const d=r.scroll$.subscribe(h=>{s(h)});return()=>{d.unsubscribe()}},[]);const s=d=>{const{leftEnd:h,rightEnd:m}=d;t(h),n(m)},a=()=>{i.executeCommand(S.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-cr)},u=()=>{r.setScrollX(cr)};return C.jsxs("div",{className:fn.sheetBar,children:[C.jsxs("div",{className:fn.sheetBarOptions,children:[C.jsx(Nn,{onClick:a,children:C.jsx(bs,{})}),C.jsx(Pm,{})]}),C.jsx(Xm,{}),(!o||!e)&&C.jsxs("div",{className:`${fn.sheetBarOptions} ${fn.sheetBarOptionsDivider}`,children:[C.jsx(Nn,{disabled:o,onClick:c,children:C.jsx(or,{style:{transform:"rotateZ(180deg)"}})}),C.jsx(Nn,{disabled:e,onClick:u,children:C.jsx(or,{})})]})]})};class Zm{constructor(){R(this,"_functions",[{func:Z.FUNCTION_NAMES_STATISTICAL.MAX,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.MIN,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_MATH.SUM,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:t=>{var e,n;return((n=(e=t.values.find(i=>i.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNT,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:t=>{var e,n,i,r;return((n=(e=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:e.value)!=null?n:0)>1&&((r=(i=t.values.find(s=>s.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:i.value)!=null?r:0)>0}}]);R(this,"_state$",new U.BehaviorSubject(null));R(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(t){var n;const e={values:[],pattern:null};t==null||t.values.forEach(i=>{const r=this._functions.find(s=>s.func===i.func);r&&(r.filter===void 0||r.filter(t))&&e.values.push(i)}),e.pattern=(n=t==null?void 0:t.pattern)!=null?n:null,this._state$.next(e)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(t){this._functions.push(...t)}}const hi=D.createIdentifier("univer.sheet-status-bar.service"),Km="univer-status-bar",qm="univer-single-mode",Qm="univer-status-bar-div",Jm="univer-statistic-list",eg="univer-statistic-list-column",tg="univer-statistic-item",ng="univer-statistic-picker",og="univer-statistic-picker-item",ig="univer-statistic-more",Ct={statusBar:Km,singleMode:qm,statusBarDiv:Qm,statisticList:Jm,statisticListColumn:eg,statisticItem:tg,statisticPicker:ng,statisticPickerItem:og,statisticMore:ig},rg=[Z.FUNCTION_NAMES_MATH.SUM,Z.FUNCTION_NAMES_STATISTICAL.AVERAGE,Z.FUNCTION_NAMES_STATISTICAL.MIN,Z.FUNCTION_NAMES_STATISTICAL.MAX],po={[Z.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[Z.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[Z.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[Z.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[Z.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[Z.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[Z.FUNCTION_NAMES_TEXT.CONCATENATE]:"concatenate"},Co=o=>{const t=G.useDependency(l.LocaleService),e=G.useDependency(I.IMessageService),n=G.useDependency(I.IClipboardInterfaceService),i=sg(o),r=async()=>{await n.writeText(o.value.toString()),e.show({type:re.MessageType.Success,content:t.t("statusbar.copied")})};return C.jsx(re.Tooltip,{title:t.t("statusbar.clickToCopy"),placement:"top",children:C.jsx("div",{className:Ct.statisticItem,onClick:r,children:C.jsx("span",{children:`${t.t((po==null?void 0:po[o.name])||o.name)}: ${i}`})},o.name)})};function sg(o){const{pattern:t,value:e}=o;return typeof e!="number"?"Invalid input":e>=1e8?e.toExponential(2):t&&rg.includes(o.name)?Rn.format(t,e):e.toLocaleString()}const dr=800,ag=3,lg=()=>{const[o,t]=V.useState(window.innerWidth<dr),[e,n]=V.useState(!0),i=G.useDependency(hi),r=i.getFunctions().map((m,g)=>({name:m.func,value:0,show:!0,disable:!1,pattern:null})),[s,a]=V.useState(r),c=s.find(m=>m.show&&!m.disable),u=o&&c?[c]:s.filter(m=>m.show&&!m.disable);V.useEffect(()=>{const m=i.state$.subscribe(g=>{const f=g==null?void 0:g.values;if(!f||f.length===0)n(!1);else{n(!0);const _=s.map(p=>{var M;const v=f.find(b=>b.func===p.name);return v?(p.value=v.value,p.disable=!1):p.disable=!0,p.pattern=(M=g==null?void 0:g.pattern)!=null?M:null,p});a(_)}});return()=>{m.unsubscribe()}},[i]);const d=l.debounce(()=>{const m=window.innerWidth<dr;o!==m&&t(m)},100);V.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[o]);let h=null;if(u.length>ag){const m=[];u.forEach((g,f)=>{f%2===0&&m.push(u.slice(f,f+2))}),h=C.jsxs(C.Fragment,{children:[" ",m.map((g,f)=>C.jsxs("div",{className:Ct.statisticListColumn,children:[(g==null?void 0:g[0])&&C.jsx(Co,{...g==null?void 0:g[0]},g==null?void 0:g[0].name),(g==null?void 0:g[1])&&C.jsx(Co,{...g==null?void 0:g[1]},g==null?void 0:g[1].name)]},`stat-col-${f}`))," "]})}else h=C.jsx(C.Fragment,{children:u.map(m=>C.jsx(Co,{...m},m.name))});return e&&C.jsxs("div",{className:Oe(Ct.statusBar,{[Ct.singleMode]:o}),children:[C.jsx("div",{className:Oe(Ct.statisticList),children:h}),C.jsx("div",{className:Ct.statusBarDiv})]})};function cg(){const o=G.useDependency(l.IUniverInstanceService);return I.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsxs("section",{className:ts.sheetContainer,"data-range-selector":!0,children:[C.jsx(Gm,{}),C.jsx(lg,{}),C.jsx(Rh,{})]}):null}function dg(){const o=G.useDependency(l.IUniverInstanceService);return I.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsx(um,{}):null}function ug(){const o=G.useDependency(l.IUniverInstanceService);return I.useObservable(()=>o.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),null,!1,[])?C.jsxs(C.Fragment,{children:[C.jsx(Th,{}),C.jsx(Rm,{})]}):null}const vo={width:"100%"},ur=o=>{const{inputId:t,state:e=!1,type:n="range",confirm:i,cancel:r,name:s,formulaOrRefString:a,comment:c="",localSheetId:u=zo,hidden:d=!1,id:h}=o,g=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),f=G.useDependency(l.LocaleService),_=G.useDependency(Z.IDefinedNamesService),p=G.useDependency(Z.IFunctionService),v=G.useDependency(Z.LexerTreeBuilder);if(g==null)return;const M=g.getUnitId();g.getActiveSheet().getSheetId();const[b,T]=V.useState(s),[w,y]=V.useState(a),[O,x]=V.useState(c),[A,F]=V.useState(u),[N,L]=V.useState(""),[B,j]=V.useState(n),[z,q]=V.useState(!0),K=[{label:f.t("definedName.scopeWorkbook"),value:zo}],$=X=>!Z.isReferenceStrings(X);V.useEffect(()=>{q(!0),T(s),x(c),F(u);let X=a;a.substring(0,1)===Z.operatorToken.EQUALS?j("formula"):$(a)?(j("formula"),X=Z.operatorToken.EQUALS+a):j("range"),y(X),L("")},[e]),g.getSheetOrders().forEach(X=>{const J=g.getSheetBySheetId(X);K.push({label:(J==null?void 0:J.getName())||"",value:X})});const Q=X=>X.map(ee=>{var ce;return Z.serializeRangeToRefString({...ee,sheetName:((ce=g.getSheetBySheetId(ee.sheetId))==null?void 0:ce.getName())||""})}).join(","),P=X=>{y(Q(X))},H=X=>{y(X||"")},k=()=>{if(b.length===0){L(f.t("definedName.nameEmpty"));return}if(_.getValueByName(M,b)!=null&&(h==null||h.length===0)){L(f.t("definedName.nameDuplicate"));return}if(!l.Tools.isValidParameter(b)||Z.isReferenceStringWithEffectiveColumn(b)||!l.Tools.isStartValidPosition(b)&&!E.hasCJKText(b.substring(0,1))){L(f.t("definedName.nameInvalid"));return}if(g.getSheetOrders().map(J=>{var ee;return((ee=g.getSheetBySheetId(J))==null?void 0:ee.getName())||""}).includes(b)){L(f.t("definedName.nameSheetConflict"));return}if(w.length===0){L(f.t("definedName.formulaOrRefStringEmpty"));return}if(!z){L(f.t("definedName.formulaOrRefStringInvalid"));return}if(p.hasExecutor(b.toUpperCase())){L(f.t("definedName.nameConflict"));return}i&&i({id:h||"",name:b,formulaOrRefString:v.convertRefersToAbsolute(w,l.AbsoluteRefType.ALL,l.AbsoluteRefType.ALL),comment:O,localSheetId:A})},Y=X=>{const J=X;J==="formula"&&w.substring(0,1)!==Z.operatorToken.EQUALS?(y(`${Z.operatorToken.EQUALS}`),y(`${Z.operatorToken.EQUALS}`)):w.substring(0,1)===Z.operatorToken.EQUALS&&(y(""),y("")),j(J)};return C.jsxs("div",{className:ae.definedNameInput,style:{display:e?"block":"none"},children:[C.jsx("div",{children:C.jsx(re.Input,{placeholder:f.t("definedName.inputNamePlaceholder"),value:b,allowClear:!0,onChange:T,affixWrapperStyle:vo})}),C.jsx("div",{children:C.jsxs(re.RadioGroup,{value:B,onChange:Y,children:[C.jsx(re.Radio,{value:"range",children:f.t("definedName.ratioRange")}),C.jsx(re.Radio,{value:"formula",children:f.t("definedName.ratioFormula")})]})}),C.jsx("div",{style:{display:B==="range"?"block":"none"},children:C.jsx(I.RangeSelector,{value:w,onValid:q,onChange:P,placeholder:f.t("definedName.inputRangePlaceholder"),id:l.createInternalEditorID(`${t}-rangeSelector`),width:"99%",openForSheetUnitId:M},`${t}-rangeSelector`)}),C.jsx("div",{style:{display:B==="range"?"none":"block"},children:C.jsx(I.TextEditor,{value:w,onValid:q,onChange:H,id:l.createInternalEditorID(`${t}-editor`),placeholder:f.t("definedName.inputFormulaPlaceholder"),openForSheetUnitId:M,onlyInputFormula:!0,style:{width:"99%"},canvasStyle:{fontSize:10}},`${t}-editor`)}),C.jsx("div",{children:C.jsx(re.Select,{style:vo,value:A,options:K,onChange:F})}),C.jsx("div",{children:C.jsx(re.Input,{affixWrapperStyle:vo,placeholder:f.t("definedName.inputCommentPlaceholder"),value:O,onChange:x})}),C.jsxs("div",{style:{display:N.length===0?"none":"flex"},className:ae.definedNameInputValidation,children:[C.jsx("span",{children:N}),C.jsx(vs,{})]}),C.jsxs("div",{children:[C.jsx(re.Button,{onClick:()=>{r&&r()},children:f.t("definedName.cancel")}),C.jsx(re.Button,{style:{marginLeft:15},type:"primary",onClick:k,children:f.t("definedName.confirm")})]})]})},hg=()=>{const o=G.useDependency(l.ICommandService),e=G.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=G.useDependency(l.LocaleService),i=G.useDependency(Z.IDefinedNamesService),r=G.useDependency(S.SelectionManagerService);if(e==null)return;const s=e.getUnitId(),a=()=>{const N=i.getDefinedNameMap(s);return N?Array.from(Object.values(N)):[]},[c,u]=V.useState(!1),[d,h]=V.useState(a()),[m,g]=V.useState(null),[f,_]=V.useState();V.useEffect(()=>{const N=i.update$.subscribe(()=>{h(a())});return()=>{N.unsubscribe()}},[]);const p=N=>{const{name:L,formulaOrRefString:B,comment:j,localSheetId:z,hidden:q}=N;let K=N.id;if(K==null||K.length===0)K=l.Tools.generateRandomId(10),o.executeCommand(S.InsertDefinedNameCommand.id,{id:K,unitId:s,name:L,formulaOrRefString:B,comment:j,localSheetId:z,hidden:q});else{const $=i.getValueById(s,K),Q={id:K,unitId:s,name:L,formulaOrRefString:B,comment:j,localSheetId:z,hidden:q};o.executeCommand(S.SetDefinedNameCommand.id,{unitId:s,oldDefinedName:{...$,unitId:s},newDefinedName:Q})}u(!1),g(null)},v=N=>{_(N)};function M(){_(null)}function b(N){const L=i.getValueById(s,N);o.executeCommand(S.RemoveDefinedNameCommand.id,{...L,unitId:s}),_(null)}const T=N=>{i.focusRange(s,N.id)},w=()=>{const N=d.length+1,L=n.t("definedName.defaultName")+N;if(i.getValueByName(s,L)==null)return L;let B=N+1;for(;;){const j=n.t("definedName.defaultName")+B;if(i.getValueByName(s,j)==null)return j;B++}},y=()=>{const N=e.getActiveSheet().getName(),L=r.getSelections();return L==null?"":L.map(j=>Z.serializeRangeWithSheet(N,j.range)).join(",")},O=()=>{u(!1),g(null)},x=()=>{u(!0),g(null)},A=N=>{u(!1),g(N)},F=N=>{const L=e.getSheetBySheetId(N);return L==null?"":L.getName()};return C.jsx("div",{className:ae.definedNameContainer,children:C.jsxs("div",{className:ae.definedNameContainerScroll,children:[C.jsxs("div",{children:[C.jsxs("div",{onClick:x,className:ae.definedNameContainerAddButton,style:{display:c?"none":"flex"},children:[C.jsx(bs,{}),C.jsx("span",{className:ae.definedNameContainerAddButtonText,children:n.t("definedName.addButton")})]}),C.jsx(ur,{confirm:p,cancel:O,state:c,inputId:"insertDefinedName",name:w(),formulaOrRefString:y()})]},"insertDefinedName"),d.map((N,L)=>C.jsxs("div",{children:[C.jsxs("div",{onClick:()=>{T(N)},className:ae.definedNameContainerItem,style:{display:N.id===m?"none":"flex"},children:[C.jsxs("div",{title:N.comment,children:[C.jsxs("div",{className:ae.definedNameContainerItemName,children:[N.name,C.jsx("span",{className:ae.definedNameContainerItemNameForSheet,children:N.localSheetId===zo||N.localSheetId==null?"":F(N.localSheetId)})]}),C.jsx("div",{className:ae.definedNameContainerItemFormulaOrRefString,children:N.formulaOrRefString})]}),C.jsx(re.Tooltip,{title:n.t("definedName.updateButton"),placement:"top",style:{pointerEvents:"none"},children:C.jsx("div",{className:Oe(ae.definedNameContainerItemUpdate,ae.definedNameContainerItemShow),onClick:()=>{A(N.id)},children:C.jsx(Jt,{})})}),C.jsx(re.Tooltip,{title:n.t("definedName.deleteButton"),placement:"top",style:{pointerEvents:"none"},children:C.jsx("div",{className:Oe(ae.definedNameContainerItemDelete,ae.definedNameContainerItemShow),onClick:()=>{v(N.id)},children:C.jsx(Fu,{})})})]}),C.jsx(re.Confirm,{visible:f===N.id,onClose:M,onConfirm:()=>{b(N.id)},children:n.t("definedName.deleteConfirmText")}),C.jsx(ur,{confirm:p,cancel:O,state:N.id===m,id:N.id,inputId:N.id+L,name:N.name,formulaOrRefString:N.formulaOrRefString,comment:N.comment,localSheetId:N.localSheetId})]},L))]})})};function mg(o){const t=o.get(S.BorderStyleManagerService),e=S.getCurrentSheetDisabled$(o);return{id:S.SetBorderBasicCommand.id,icon:new U.Observable(n=>{const i="AllBorderSingle",r=o.get(S.BorderStyleManagerService),s=o.get(l.ICommandService).onCommandExecuted(a=>{var m;if(a.id!==S.SetBorderBasicCommand.id)return;const{type:u}=r.getBorderInfo(),d=xs.find(g=>g.value===u),h=(m=d==null?void 0:d.icon)!=null?m:i;n.next(h)});return n.next(i),s.dispose}),group:I.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[I.MenuPosition.TOOLBAR_START],type:I.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:Os,hoverable:!1},value$:t.borderInfo$}],value$:t.borderInfo$,hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:e}}const no="sheet.menu.clear-selection";function gg(o){return{id:no,group:I.MenuGroup.CONTEXT_MENU_FORMAT,type:I.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[I.MenuPosition.CONTEXT_MENU,le.COL_HEADER_CONTEXT_MENU,le.ROW_HEADER_CONTEXT_MENU]}}function fg(o){return{id:S.ClearSelectionContentCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[no]}}function _g(o){return{id:S.ClearSelectionFormatCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[no]}}function Sg(o){return{id:S.ClearSelectionAllCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[no]}}const an="sheet.menu.delete";function pg(o){return{id:an,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[I.MenuPosition.CONTEXT_MENU]}}function Cg(o){return{id:as.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[an,le.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function vg(o){return{id:ss.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,icon:"DeleteRow",positions:[an,le.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function Ig(o){return{id:di.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[an]}}function Rg(o){return{id:jn.id,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[an]}}const mi="sheet.menu.col-insert";function Mg(o){return{id:mi,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.COL_HEADER_CONTEXT_MENU]}}const gi="sheet.menu.row-insert";function bg(o){return{id:gi,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[le.ROW_HEADER_CONTEXT_MENU]}}const ln="sheet.menu.cell-insert";function Tg(o){return{id:ln,group:I.MenuGroup.CONTEXT_MENU_LAYOUT,type:I.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[I.MenuPosition.CONTEXT_MENU]}}function wg(o){const t=o.get(S.SelectionManagerService);return{id:S.InsertRowBeforeCommand.id,type:I.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[gi,ln],hidden$:new U.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Eg(o){const t=o.get(S.SelectionManagerService);return{id:S.InsertRowAfterCommand.id,type:I.MenuItemType.BUTTON,positions:[gi],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new U.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function yg(o){const t=o.get(S.SelectionManagerService);return{id:S.InsertColBeforeCommand.id,type:I.MenuItemType.BUTTON,positions:[mi,ln],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new U.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function Og(o){const t=o.get(S.SelectionManagerService);return{id:S.InsertColAfterCommand.id,type:I.MenuItemType.BUTTON,positions:[mi],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new U.Observable(e=>{const n=t.getSelections();e.next((n==null?void 0:n.length)!==1)})}}function xg(o){return{id:ui.id,type:I.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[ln]}}function Ng(o){return{id:$n.id,type:I.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[ln]}}function Ag(o){return o.get(S.SelectionManagerService).selectionMoveEnd$.pipe(U.filter(e=>e!=null&&e.length>=2),U.map(e=>{if(!e)return!1;for(let n=0;n<e.length;n++)for(let i=n+1;i<e.length;i++)if(l.Rectangle.intersects(e[n].range,e[i].range))return!0;return!1}))}function Dg(o){const t=S.getCurrentSheetDisabled$(o),e=Ag(o);return{id:Ke.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[I.MenuPosition.TOOLBAR_START],group:I.MenuGroup.TOOLBAR_LAYOUT,type:I.MenuItemType.SUBITEMS,hidden$:I.getMenuHiddenObservable(o,l.UniverInstanceType.UNIVER_SHEET),disabled$:t.pipe(U.combineLatestWith(e),U.map(([n,i])=>n||i))}}function Pg(o){return{id:ns.id,type:I.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[Ke.id]}}function Hg(o){return{id:os.id,type:I.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[Ke.id]}}function Lg(o){return{id:is.id,type:I.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[Ke.id]}}function Ug(o){return{id:S.RemoveWorksheetMergeCommand.id,type:I.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[Ke.id]}}function Vg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:ls.id,type:I.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.delete",disabled$:new U.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values()).filter(u=>u.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),i.dispose})}}function Bg(o){return{id:S.CopySheetCommand.id,type:I.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.copy"}}function Fg(o){return{id:us.id,type:I.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.rename"}}function kg(o){return{id:S.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[le.SHEET_BAR],type:I.MenuItemType.SELECTOR,selections:[{label:{name:Jn,hoverable:!1}}]}}function Wg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:S.SetWorksheetHideCommand.id,type:I.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.hide",disabled$:new U.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values()).filter(u=>u.getConfig().hidden===l.BooleanNumber.FALSE);n.next(c.length===1)}});return n.next(!1),i.dispose})}}function jg(o){const t=o.get(l.IUniverInstanceService),e=o.get(l.ICommandService);return{id:cs.id,type:I.MenuItemType.BUTTON,positions:[le.SHEET_BAR],title:"sheetConfig.unhide",disabled$:new U.Observable(n=>{const i=e.onCommandExecuted(r=>{const s=r.id;if(s===S.RemoveSheetMutation.id||s===S.InsertSheetMutation.id||s===S.SetWorksheetHideMutation.id){const a=t.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getWorksheets(),c=Array.from(a.values());n.next(c.length===1)}});return n.next(!1),i.dispose})}}const $g={id:S.SetRowHiddenCommand.id,preconditions:o=>ne(o),binding:I.KeyCode.Digit9|I.MetaKeys.CTRL_COMMAND},zg={id:S.SetColHiddenCommand.id,preconditions:o=>ne(o),binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND|I.MetaKeys.SHIFT},Yg={id:we.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},Xg={id:we.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP}},Gg={id:we.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT,priority:100,preconditions:_r,staticParameters:{direction:l.Direction.LEFT}},Zg={id:we.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT,priority:100,preconditions:_r,staticParameters:{direction:l.Direction.RIGHT}},Kg={id:gt.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:I.KeyCode.TAB,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,keycode:I.KeyCode.TAB}},qg={id:gt.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:I.KeyCode.TAB|I.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,keycode:I.KeyCode.TAB}},Qg={id:gt.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:I.KeyCode.ENTER,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,keycode:I.KeyCode.ENTER}},Jg={id:gt.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:I.KeyCode.ENTER|I.MetaKeys.SHIFT,priority:100,preconditions:ne,staticParameters:{direction:l.Direction.UP,keycode:I.KeyCode.ENTER}},ef={id:we.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},tf={id:we.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},nf={id:we.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},of={id:we.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},rf={id:Ae.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.DOWN}},sf={id:Ae.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.UP}},af={id:Ae.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.LEFT}},lf={id:Ae.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.SHIFT,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT}},cf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_DOWN|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.DOWN,jumpOver:ke.moveGap}},df={id:Ae.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_UP|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.UP,jumpOver:ke.moveGap}},uf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_LEFT|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.LEFT,jumpOver:ke.moveGap}},hf={id:Ae.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:I.KeyCode.ARROW_RIGHT|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{direction:l.Direction.RIGHT,jumpOver:ke.moveGap}},mf={id:xr.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:I.KeyCode.A|I.MetaKeys.CTRL_COMMAND,preconditions:ne,staticParameters:{expandToGapFirst:!0,loop:!0}},gf={id:ni.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:o=>ne(o),binding:I.KeyCode.B|I.MetaKeys.CTRL_COMMAND},ff={id:oi.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:o=>ne(o),binding:I.KeyCode.I|I.MetaKeys.CTRL_COMMAND},_f={id:ii.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:o=>ne(o),binding:I.KeyCode.U|I.MetaKeys.CTRL_COMMAND},Sf={id:ri.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:o=>ne(o),binding:I.KeyCode.X|I.MetaKeys.SHIFT|I.MetaKeys.CTRL_COMMAND},pf={id:S.ClearSelectionContentCommand.id,preconditions:o=>ne(o),binding:I.KeyCode.DELETE,mac:I.KeyCode.BACKSPACE},Cf={id:Kn.id,description:"shortcut.sheet.zoom-in",binding:I.KeyCode.EQUAL|I.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:.2}},vf={id:l.NilCommand.id,binding:I.KeyCode.EQUAL|I.MetaKeys.CTRL_COMMAND},If={id:Kn.id,description:"shortcut.sheet.zoom-out",binding:I.KeyCode.MINUS|I.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",preconditions:ne,priority:1,staticParameters:{delta:-.2}},Rf={id:l.NilCommand.id,binding:I.KeyCode.MINUS|I.MetaKeys.CTRL_COMMAND},Mf={id:Kn.id,description:"shortcut.sheet.reset-zoom",binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND,preconditions:ne,group:"3_sheet-view",priority:1,staticParameters:{reset:!0}},bf={id:l.NilCommand.id,binding:I.KeyCode.Digit0|I.MetaKeys.CTRL_COMMAND};var Tf=Object.defineProperty,wf=Object.getOwnPropertyDescriptor,Ef=(o,t,e,n)=>{for(var i=n>1?void 0:n?wf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Tf(t,e,i),i},at=(o,t)=>(e,n)=>t(e,n,o);const yf={};let Gt=class extends l.Disposable{constructor(o,t,e,n,i,r,s,a){super(),this._config=o,this._injector=t,this._componentManager=e,this._layoutService=n,this._commandService=i,this._shortcutService=r,this._menuService=s,this._uiPartsService=a,this._init()}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts(),this._initFocusHandler()}_initCustomComponents(){const o=this._componentManager;this.disposeWithMe(o.register(li,rc)),this.disposeWithMe(o.register(Os,Sh)),this.disposeWithMe(o.register(Jn,re.ColorPicker)),this.disposeWithMe(o.register($r,I.FontFamily)),this.disposeWithMe(o.register(zr,I.FontFamilyItem)),this.disposeWithMe(o.register(Yr,I.FontSize)),this.disposeWithMe(o.register(Ns,hg))}_initCommands(){[ns,Ke,is,os,Kn,Ae,we,gt,us,ls,ss,as,Ar,Dr,dt,Nr,xr,ds,S.SetBoldCommand,Qt,Te,ti,ni,oi,ii,ri,Fl,kl,Pr,Hr,kn,S.SetItalicCommand,S.SetStrikeThroughCommand,S.SetFontFamilyCommand,S.SetFontSizeCommand,si,Br,ai,Fr,ot,Xt,Qn,kr,Wr,jr,S.SetUnderlineCommand,qn,Fe,cs,rs,$n,jn,ui,di,As,Vn,Mn].forEach(o=>{this.disposeWithMe(this._commandService.registerCommand(o))})}_initMenus(){const{menu:o={}}=this._config;[Ic,Rc,Mc,bc,Tc,wc,Ec,fg,_g,Sg,gg,Mg,bg,Tg,wg,Eg,yg,Og,vg,Hc,Uc,Lc,Vc,Cg,Bc,yc,Fc,pg,Ig,Rg,xg,Ng,Nc,Ac,Dc,Pc,Oc,xc,sc,ac,lc,cc,dc,uc,hc,mc,gc,fc,_c,mg,Dg,Pg,Hg,Lg,Ug,Sc,pc,Cc,vc,Vg,Bg,Fg,kg,Wg,jg].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t),o))})}_initShortcuts(){[Yg,Xg,Gg,Zg,Kg,qg,Qg,Jg,ef,tf,nf,of,rf,sf,af,lf,cf,df,uf,hf,mf,Cf,If,Mf,bf,vf,Rf,gf,ff,_f,Sf,pf,...ud(),md,hd,gd,_d,Sd,pd,fd,$g,zg].forEach(o=>{this.disposeWithMe(this._shortcutService.registerShortcut(o))})}_initWorkbenchParts(){const o=this._uiPartsService,t=this._injector;this.disposeWithMe(o.registerComponent(I.BuiltInUIPart.HEADER,()=>G.connectInjector(dg,t))),this.disposeWithMe(o.registerComponent(I.BuiltInUIPart.FOOTER,()=>G.connectInjector(cg,t))),this.disposeWithMe(o.registerComponent(I.BuiltInUIPart.CONTENT,()=>G.connectInjector(ug,t)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(l.UniverInstanceType.UNIVER_SHEET,o=>{this._injector.get(E.ITextSelectionRenderManager).focus()}))}};Gt=Ef([l.OnLifecycle(l.LifecycleStages.Ready,Gt),at(1,D.Inject(D.Injector)),at(2,D.Inject(I.ComponentManager)),at(3,I.ILayoutService),at(4,l.ICommandService),at(5,I.IShortcutService),at(6,I.IMenuService),at(7,I.IUIPartsService)],Gt);var Of=Object.defineProperty,xf=Object.getOwnPropertyDescriptor,Nf=(o,t,e,n)=>{for(var i=n>1?void 0:n?xf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Of(t,e,i),i},lt=(o,t)=>(e,n)=>t(e,n,o);let An=class extends l.Disposable{constructor(t,e,n,i,r,s,a){super();R(this,"_calculateTimeout",-1);this._univerInstanceService=t,this._selectionManagerService=e,this._functionService=n,this._statusBarService=i,this._commandService=r,this._formulaDataModel=s,this._numfmtService=a,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){const t=l.debounce(e=>{var i;const n=(i=e[e.length-1])==null?void 0:i.primary;this._calculateSelection(e.map(r=>r.range),n)},100);this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===S.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(e=>{var n;((n=this._selectionManagerService.getCurrent())==null?void 0:n.pluginName)===S.NORMAL_SELECTION_PLUGIN_NAME&&e&&t(e)}))),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===S.SetRangeValuesMutation.id){const n=this._selectionManagerService.getSelections();n&&t(n)}}))}_clearResult(){this._statusBarService.setState(null)}_calculateSelection(t,e){var c;const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return this._clearResult();const i=n.getUnitId(),r=n.getActiveSheet().getSheetId(),s={},a=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getSheets().forEach(u=>{const d=u.getConfig();s[u.getSheetId()]={cellData:new l.ObjectMatrix(d.cellData),rowCount:d.rowCount,columnCount:d.columnCount,rowData:d.rowData,columnData:d.columnData}}),t!=null&&t.length){const u=t.map(p=>new Z.RangeReferenceObject(p,r,i));u.forEach(p=>{p.setUnitData({[i]:s}),a&&p.setArrayFormulaCellData(Z.convertUnitDataToRuntime(a))});const d=this._statusBarService.getFunctions(),h=u.map(p=>p.toArrayValueObject(!1)),m=d.map(p=>{const v=this._functionService.getExecutor(p.func);if(!v)return;const M=v==null?void 0:v.calculate(...h),b=M==null?void 0:M.getValue();if(b)return{func:p.func,value:b}});if(m.every(p=>p===void 0))return;let g=null;if(e){const{actualRow:p,actualColumn:v}=e;g=(c=this._numfmtService.getValue(i,r,p,v))==null?void 0:c.pattern}const _={values:m.filter(p=>p!==void 0),pattern:g};this._statusBarService.setState(_)}else this._clearResult()}};An=Nf([l.OnLifecycle(l.LifecycleStages.Ready,An),lt(0,l.IUniverInstanceService),lt(1,D.Inject(S.SelectionManagerService)),lt(2,Z.IFunctionService),lt(3,hi),lt(4,l.ICommandService),lt(5,D.Inject(Z.FormulaDataModel)),lt(6,D.Inject(S.INumfmtService))],An);var Af=Object.defineProperty,Df=Object.getOwnPropertyDescriptor,Pf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Df(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Af(t,e,i),i},Io=(o,t)=>(e,n)=>t(e,n,o);exports.SheetCanvasView=class extends l.RxDisposable{constructor(e,n,i,r){super();R(this,"_fps$",new U.BehaviorSubject(""));R(this,"fps$",this._fps$.asObservable());this._context=e,this._commandService=n,this._renderManagerService=i,this._sheetSkeletonManagerService=r,this._addNewRender(this._context.unit)}dispose(){this._fps$.complete()}_addNewRender(e){const{scene:n,engine:i}=this._context;n.openTransformer(),n.addLayer(new E.Layer(n,[],0),new E.Layer(n,[],2)),this._addComponent(e),e.getShouldRenderLoopImmediately()&&i.runRenderLoop(()=>{n.render(),this._fps$.next(Math.round(i.getFps()).toString())})}_addComponent(e){const{scene:n,components:i}=this._context,r=e.getActiveSheet();e.getUnitId(),r.getSheetId(),this._addViewport(r);const s=new E.Spreadsheet(ie.MAIN),a=new E.SpreadsheetRowHeader(ie.ROW),c=new E.SpreadsheetColumnHeader(ie.COLUMN),u=new E.Rect(ie.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,i.set(ie.MAIN,s),i.set(ie.ROW,a),i.set(ie.COLUMN,c),i.set(ie.LEFT_TOP,u),n.addObjects([s],Ei),n.addObjects([a,c,u],nt),n.enableLayerCache(Ei,nt)}_addViewport(e){const n=this._context.scene,{rowHeader:i,columnHeader:r}=e.getConfig(),s=new E.Viewport(W.VIEW_MAIN,n,{left:i.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0});return new E.Viewport(W.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),new E.Viewport(W.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:i.width,isWheelPreventDefaultX:!0}),new E.Viewport(W.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),new E.Viewport(W.VIEW_COLUMN_RIGHT,n,{left:i.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),new E.Viewport(W.VIEW_LEFT_TOP,n,{left:0,top:0,width:i.width,height:r.height,isWheelPreventDefaultX:!0}),new E.Viewport(W.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),new E.Viewport(W.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),new E.Viewport(W.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),this.disposeWithMe(l.toDisposable(n.onMouseWheelObserver.add((a,c)=>{if(a.ctrlKey)return;let u=0,d=0;const h=s.limitedScroll();if(a.inputIndex===E.PointerInput.MouseWheelX){const g=Math.abs(a.deltaX);a.deltaX>0?u=g:u=-g,this._commandService.executeCommand(Xt.id,{offsetX:u}),n.getParent().classType===E.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()}if(a.inputIndex===E.PointerInput.MouseWheelY){let g=Math.abs(a.deltaY);a.shiftKey?(g*=3,a.deltaY>0?u=g:u=-g,this._commandService.executeCommand(Xt.id,{offsetX:u}),n.getParent().classType===E.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedX||c.stopPropagation():s.isWheelPreventDefaultX?a.preventDefault():h!=null&&h.isLimitedX||a.preventDefault()):(a.deltaY>0?d=g:d=-g,this._commandService.executeCommand(Xt.id,{offsetY:d}),n.getParent().classType===E.RENDER_CLASS_TYPE.SCENE_VIEWER?h!=null&&h.isLimitedY||c.stopPropagation():s.isWheelPreventDefaultY?a.preventDefault():h!=null&&h.isLimitedY||a.preventDefault())}this._context.scene.makeDirty(!0)}))),new E.ScrollBar(s),n.attachControl(),s}};exports.SheetCanvasView=Pf([Io(1,l.ICommandService),Io(2,E.IRenderManagerService),Io(3,D.Inject(exports.SheetSkeletonManagerService))],exports.SheetCanvasView);var Hf=Object.defineProperty,Lf=Object.getOwnPropertyDescriptor,Uf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Lf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Hf(t,e,i),i},_n=(o,t)=>(e,n)=>t(e,n,o);exports.HoverManagerService=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_currentCell$",new U.Subject);R(this,"currentCell$",this._currentCell$.asObservable().pipe(U.distinctUntilChanged((e,n)=>{var i,r,s,a,c,u,d,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((r=n==null?void 0:n.location)==null?void 0:r.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((a=n==null?void 0:n.location)==null?void 0:a.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((u=n==null?void 0:n.location)==null?void 0:u.row)&&((d=e==null?void 0:e.location)==null?void 0:d.col)===((h=n==null?void 0:n.location)==null?void 0:h.col)})));R(this,"currentPosition$",this._currentCell$.asObservable());R(this,"_lastPosition",null);this._univerInstanceService=e,this._scrollManagerService=n,this._sheetSkeletonManagerService=i,this._renderManagerService=r,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||this._currentCell$.next(null)}))}_calcActiveCell(){if(!this._lastPosition)return;const{offsetX:e,offsetY:n}=this._lastPosition,i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!i){this._currentCell$.next(null);return}const r=i.getActiveSheet(),s=this._sheetSkeletonManagerService.getCurrent(),a=this._renderManagerService.getRenderById(i.getUnitId()),c=this._scrollManagerService.getCurrentScroll();if(!s||!c||!a)return;const u=Vr(a,i,r,s,e,n);if(!u){this._currentCell$.next(null);return}const{location:d,position:h}=u;this._currentCell$.next({location:d,position:h})}onMouseMove(e,n){this._lastPosition={offsetX:e,offsetY:n},this._calcActiveCell()}onScrollStart(){this._currentCell$.next(null)}onScrollEnd(){this._calcActiveCell()}};exports.HoverManagerService=Uf([_n(0,l.IUniverInstanceService),_n(1,D.Inject(Ze)),_n(2,D.Inject(exports.SheetSkeletonManagerService)),_n(3,E.IRenderManagerService)],exports.HoverManagerService);var Vf=Object.defineProperty,Bf=Object.getOwnPropertyDescriptor,Ff=(o,t,e,n)=>{for(var i=n>1?void 0:n?Bf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Vf(t,e,i),i},Ro=(o,t)=>(e,n)=>t(e,n,o);exports.HoverRenderController=class extends l.Disposable{constructor(t,e,n,i){super(),this._context=t,this._renderManagerService=e,this._hoverManagerService=n,this._sheetSkeletonManagerService=i,this._initPointerEvent()}_initPointerEvent(){const t=new l.DisposableCollection,e=n=>{if(t.dispose(),!n)return;const i=this._renderManagerService.getRenderById(n.unitId);if(!i)return;const{scene:r}=i,s=r.onPointerMoveObserver.add(a=>{this._hoverManagerService.onMouseMove(a.offsetX,a.offsetY)});t.add({dispose(){r.onPointerMoveObserver.remove(s)}})};e(this._sheetSkeletonManagerService.getCurrent()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{e(n)}))}};exports.HoverRenderController=Ff([l.OnLifecycle(l.LifecycleStages.Rendered,exports.HoverRenderController),Ro(1,E.IRenderManagerService),Ro(2,D.Inject(exports.HoverManagerService)),Ro(3,D.Inject(exports.SheetSkeletonManagerService))],exports.HoverRenderController);const kf="univer-cell-alert",Wf="univer-cell-alert-title",jf="univer-cell-alert-icon",$f="univer-cell-alert-icon-error",zf="univer-cell-alert-icon-info",Yf="univer-cell-alert-icon-warning",Xf="univer-cell-alert-content",Ye={cellAlert:kf,cellAlertTitle:Wf,cellAlertIcon:jf,cellAlertIconError:$f,cellAlertIconInfo:zf,cellAlertIconWarning:Yf,cellAlertContent:Xf};function Gf({popup:o}){var s;const t=(s=o.extraProps)==null?void 0:s.alert;if(!t)return null;const{type:e,title:n,message:i}=t,r={[bt.ERROR]:C.jsx(vs,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconError)}),[bt.INFO]:C.jsx(ir,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconInfo)}),[bt.WARNING]:C.jsx(ir,{className:Oe(Ye.cellAlertIcon,Ye.cellAlertIconWarning)})};return C.jsxs("div",{className:Ye.cellAlert,children:[C.jsxs("div",{className:Ye.cellAlertTitle,children:[e?r[e]:null,n]}),C.jsx("div",{className:Ye.cellAlertContent,children:i})]})}const Ds="univer.sheet.cell-alert";var Zf=Object.defineProperty,Kf=Object.getOwnPropertyDescriptor,qf=(o,t,e,n)=>{for(var i=n>1?void 0:n?Kf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Zf(t,e,i),i},pt=(o,t)=>(e,n)=>t(e,n,o);exports.SheetCanvasPopManagerService=class extends l.Disposable{constructor(t,e,n,i,r,s){super(),this._globalPopupManagerService=t,this._renderManagerService=e,this._univerInstanceService=n,this._sheetSkeletonManagerService=i,this._refRangeService=r,this._commandService=s}_createObjectPositionObserver(t,e,n,i){const r=()=>{const{scene:u}=e,{left:d,top:h,width:m,height:g}=t,f={left:d,right:d+m,top:h,bottom:h+g},_=Yl(f,u,n,i);return{left:_.left,right:_.right,top:_.top,bottom:_.bottom}},s=r(),a=new U.BehaviorSubject(s),c=new l.DisposableCollection;return c.add(this._commandService.onCommandExecuted(u=>{(u.id===ot.id||u.id===Fe.id)&&a.next(r())})),{position:s,position$:a,disposable:c}}attachPopupToObject(t,e){const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),i=n.getActiveSheet(),r=n.getUnitId(),s=i.getSheetId(),a=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:r,sheetId:s}),c=this._renderManagerService.getRenderById(r);if(!c||!a)return{dispose:()=>{}};const{position:u,position$:d,disposable:h}=this._createObjectPositionObserver(t,c,a,i),m=this._globalPopupManagerService.addPopup({...e,unitId:r,subUnitId:s,anchorRect:u,anchorRect$:d});return{dispose:()=>{this._globalPopupManagerService.removePopup(m),d.complete(),h.dispose()}}}attachPopupToCell(t,e,n,i){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),a=r.getUnitId(),c=s.getSheetId(),u=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:a,sheetId:c}),d=this._renderManagerService.getRenderById(a);if(!d||!u)return null;const h=i!=null?i:zl(t,e,d.scene,s);if(!h)return null;const{position:m,position$:g,disposable:f,updateRowCol:_}=this._createCellPositionObserver(t,e,d,u,h),p=this._globalPopupManagerService.addPopup({...n,unitId:a,subUnitId:c,anchorRect:m,anchorRect$:g}),v=new l.DisposableCollection;v.add(f),v.add(l.toDisposable(()=>{this._globalPopupManagerService.removePopup(p),g.complete()}));const M={startRow:t,endRow:t,startColumn:e,endColumn:e};return v.add(this._refRangeService.watchRange(a,c,M,(b,T)=>{T?_(T.startRow,T.startColumn):v.dispose()})),v}_createCellPositionObserver(t,e,n,i,r){let s=t,a=e;const c=this._calcCellPositionByCell(s,a,n,i,r),u=new U.BehaviorSubject(c),d=()=>u.next(this._calcCellPositionByCell(s,a,n,i,r)),h=new l.DisposableCollection;return h.add(this._commandService.onCommandExecuted(g=>{if(g.id===S.SetWorksheetRowAutoHeightMutation.id&&g.params.rowsAutoHeightInfo.findIndex(_=>_.row===s)>-1){d();return}(S.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(g.id)>-1||g.id===ot.id||g.id===Fe.id)&&d()})),{position$:u,disposable:h,position:c,updateRowCol:(g,f)=>{s=g,a=f,d()}}}_calcCellPositionByCell(t,e,n,i,r){const{scene:s}=n,a=i.getCellByIndex(t,e),c=a.isMergedMainCell?a.mergeInfo:a,{scaleX:u,scaleY:d}=s.getAncestorScale(),h={x:r.actualScrollX,y:r.actualScrollY};return{left:(c.startX-h.x)*u,right:(c.endX-h.x)*u,top:(c.startY-h.y)*d,bottom:(c.endY-h.y)*d}}};exports.SheetCanvasPopManagerService=qf([pt(0,D.Inject(I.ICanvasPopupService)),pt(1,E.IRenderManagerService),pt(2,l.IUniverInstanceService),pt(3,D.Inject(exports.SheetSkeletonManagerService)),pt(4,D.Inject(S.RefRangeService)),pt(5,l.ICommandService)],exports.SheetCanvasPopManagerService);var Qf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,e_=(o,t,e,n)=>{for(var i=n>1?void 0:n?Jf(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Qf(t,e,i),i},hr=(o,t)=>(e,n)=>t(e,n,o),bt=(o=>(o[o.INFO=0]="INFO",o[o.WARNING=1]="WARNING",o[o.ERROR=2]="ERROR",o))(bt||{});exports.CellAlertManagerService=class{constructor(t,e){R(this,"_currentAlert$",new U.Subject);R(this,"_currentAlert",new Map);R(this,"currentAlert$",this._currentAlert$.asObservable());this._renderManagerService=t,this._canvasPopManagerService=e}get currentAlert(){return this._currentAlert}showAlert(t){let e=this._currentAlert.get(t.key);e&&e.dispose.dispose(),e?e.dispose.dispose():(e={alert:t,dispose:{dispose(){}}},this._currentAlert.set(t.key,e));const{location:n}=t,{row:i,col:r,unitId:s}=n;if(!this._renderManagerService.getRenderById(s))return;const c=this._canvasPopManagerService.attachPopupToCell(i,r,{componentKey:Ds,direction:"horizontal",offset:[2,0],extraProps:{alert:t}});c&&(e.dispose=c),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}removeAlert(t){const e=this._currentAlert.get(t);e&&(this._currentAlert.delete(t),e==null||e.dispose.dispose(),this._currentAlert$.next(Array.from(this._currentAlert.entries())))}clearAlert(){this._currentAlert.forEach(t=>{t.dispose.dispose()}),this._currentAlert.clear(),this._currentAlert$.next(Array.from(this._currentAlert.entries()))}};exports.CellAlertManagerService=e_([hr(0,E.IRenderManagerService),hr(1,D.Inject(exports.SheetCanvasPopManagerService))],exports.CellAlertManagerService);var t_=Object.defineProperty,n_=Object.getOwnPropertyDescriptor,o_=(o,t,e,n)=>{for(var i=n>1?void 0:n?n_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&t_(t,e,i),i},i_=(o,t)=>(e,n)=>t(e,n,o);let Dn=class extends l.Disposable{constructor(o,t){super(),this._context=o,this._componentManager=t,this._initComponent()}_initComponent(){this._componentManager.register(Ds,Gf)}};Dn=o_([l.OnLifecycle(l.LifecycleStages.Starting,Dn),i_(1,D.Inject(I.ComponentManager))],Dn);var r_=Object.defineProperty,s_=Object.getOwnPropertyDescriptor,a_=(o,t,e,n)=>{for(var i=n>1?void 0:n?s_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&r_(t,e,i),i},mr=(o,t)=>(e,n)=>t(e,n,o);let Pn=class extends l.RxDisposable{constructor(o,t,e){super(),this._context=o,this._sheetSkeletonManagerService=t,this._sheetInterceptorService=e,this._init()}_init(){this._initViewModelIntercept()}_initViewModelIntercept(){const o={tl:{size:6,color:"#409f11"}};this.disposeWithMe(this._sheetInterceptorService.intercept(S.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,e,n)=>{var s;if(!((s=this._sheetSkeletonManagerService.getCurrent())==null?void 0:s.skeleton))return n(t);const r=e.worksheet.getCellRaw(e.row,e.col);return!r||r.v===null||r.v===void 0?n(t):(t==null?void 0:t.t)===l.CellValueType.FORCE_STRING&&l.isRealNum(r.v)?n({...t,markers:{...t==null?void 0:t.markers,...o}}):n(t)}}))}};Pn=a_([l.OnLifecycle(l.LifecycleStages.Rendered,Pn),mr(1,D.Inject(exports.SheetSkeletonManagerService)),mr(2,D.Inject(S.SheetInterceptorService))],Pn);var l_=Object.defineProperty,c_=Object.getOwnPropertyDescriptor,d_=(o,t,e,n)=>{for(var i=n>1?void 0:n?c_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&l_(t,e,i),i},Sn=(o,t)=>(e,n)=>t(e,n,o);const Mo="SHEET_FORCE_STRING_ALERT";let Hn=class extends l.Disposable{constructor(o,t,e,n,i){super(),this._context=o,this._hoverManagerService=t,this._cellAlertManagerService=e,this._univerInstanceService=n,this._localeService=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.subscribe(o=>{var t;if(o){const i=this._context.unit.getActiveSheet().getCell(o.location.row,o.location.col);if((i==null?void 0:i.t)===l.CellValueType.FORCE_STRING&&i.v&&l.isRealNum(i.v)){const r=this._cellAlertManagerService.currentAlert.get(Mo),s=(t=r==null?void 0:r.alert)==null?void 0:t.location;if(s&&s.row===o.location.row&&s.col===o.location.col&&s.subUnitId===o.location.subUnitId&&s.unitId===o.location.unitId)return;this._cellAlertManagerService.showAlert({type:bt.ERROR,title:this._localeService.t("info.error"),message:this._localeService.t("info.forceStringInfo"),location:o.location,width:200,height:74,key:Mo});return}}this._cellAlertManagerService.removeAlert(Mo)}))}};Hn=d_([l.OnLifecycle(l.LifecycleStages.Rendered,Hn),Sn(1,D.Inject(exports.HoverManagerService)),Sn(2,D.Inject(exports.CellAlertManagerService)),Sn(3,l.IUniverInstanceService),Sn(4,D.Inject(l.LocaleService))],Hn);var u_=Object.defineProperty,h_=Object.getOwnPropertyDescriptor,m_=(o,t,e,n)=>{for(var i=n>1?void 0:n?h_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&u_(t,e,i),i},bo=(o,t)=>(e,n)=>t(e,n,o);let Yo=class extends l.Disposable{constructor(o,t,e,n){super(),this._context=o,this._contextMenuService=t,this._selectionManagerService=e,this._selectionRenderService=n,this._addListeners()}_addListeners(){var c,u;const o=(u=(c=this._context)==null?void 0:c.mainComponent)==null?void 0:u.onPointerDownObserver,t=o.add(d=>{if(d.button===2){const h=this._selectionManagerService.getSelections(),m=h==null?void 0:h[0];if(!m)return;const g=m.range.rangeType,f=this._selectionRenderService.convertSelectionToCoord(m).rangeWithCoord,_=()=>{if(!f)return!1;const v=d.offsetX,M=d.offsetY;switch(g){case l.RANGE_TYPE.ROW:return f.startY<=M&&f.endY>=M;case l.RANGE_TYPE.COLUMN:return f.startX<=v&&f.endX>=v;default:return f.startX<=v&&f.endX>=v&&f.startY<=M&&f.endY>=M}},p=v=>{this._contextMenuService.triggerContextMenu(d,v)};_()?g===l.RANGE_TYPE.COLUMN?p(le.COL_HEADER_CONTEXT_MENU):g===l.RANGE_TYPE.ROW?p(le.ROW_HEADER_CONTEXT_MENU):p(I.MenuPosition.CONTEXT_MENU):p(I.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>o.remove(t)));const e=this._context.components.get(ie.COLUMN),r=this._context.components.get(ie.ROW).onPointerDownObserver.add(d=>{d.button===2&&this._contextMenuService.triggerContextMenu(d,le.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>o.remove(r)));const a=e.onPointerDownObserver.add(d=>{d.button===2&&this._contextMenuService.triggerContextMenu(d,le.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>o.remove(a)))}};Yo=m_([bo(1,I.IContextMenuService),bo(2,D.Inject(S.SelectionManagerService)),bo(3,Ne)],Yo);var g_=Object.defineProperty,f_=Object.getOwnPropertyDescriptor,__=(o,t,e,n)=>{for(var i=n>1?void 0:n?f_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&g_(t,e,i),i},Je=(o,t)=>(e,n)=>t(e,n,o);let Xo=class extends l.RxDisposable{constructor(o,t,e,n,i,r,s,a,c){super(),this._context=o,this._injector=t,this._commandService=e,this._editorBridgeService=n,this._layoutService=i,this._editorService=r,this._contextService=s,this._selectionManagerService=a,this._rangeSelectorService=c,this._initialize(),this._commandExecutedListener()}_initialize(){this._initSelectionChangeListener(),this._initEventListener(),this._initialRangeSelector()}_initSelectionChangeListener(){U.merge(this._selectionManagerService.selectionMoveEnd$,this._selectionManagerService.selectionMoveStart$).pipe(U.takeUntil(this.dispose$)).subscribe(o=>this._handleSelectionChange(o))}_updateEditorPosition(o){const t=this._getSheetObject(),{scene:e,engine:n}=t,i=this._context.unitId,r=this._context.unit.getActiveSheet().getSheetId();this._commandService.executeCommand(ds.id,{scene:e,engine:n,primary:o,unitId:i,sheetId:r})}_handleSelectionChange(o){var n;const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==S.NORMAL_SELECTION_PLUGIN_NAME||this._editorBridgeService.isVisible().visible)return;const e=(n=o==null?void 0:o[o.length-1])==null?void 0:n.primary;e&&this._updateEditorPosition(e)}_initEventListener(){const o=this._getSheetObject(),{spreadsheet:t,spreadsheetColumnHeader:e,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:i}=o;t.onDblclickObserver.add(r=>{if(r.button===2)return;const s=this._selectionManagerService.getCurrent();(s==null?void 0:s.pluginName)===S.NORMAL_SELECTION_PLUGIN_NAME&&this._commandService.executeCommand(Te.id,{visible:!0,eventType:E.DeviceInputEventType.Dblclick})}),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),i.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Te.id,{visible:!1,eventType:E.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_initialRangeSelector(){this.disposeWithMe(this._selectionManagerService.selectionMoving$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._selectionManagerService.selectionMoveStart$.subscribe(this._rangeSelector.bind(this))),this.disposeWithMe(this._rangeSelectorService.openSelector$.subscribe(()=>{const o=this._selectionManagerService.getSelections(),{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),i=o==null?void 0:o.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));i&&this._rangeSelectorService.selectionChange(i)}))}_rangeSelector(o){if(!o)return;const{unitId:t,sheetId:e,sheetName:n}=this._getCurrentUnitIdAndSheetId(),i=o.map(r=>({range:r.range,unitId:t,sheetId:e,sheetName:n}));this._rangeSelectorService.selectionChange(i)}_getCurrentUnitIdAndSheetId(){const o=this._context.unit,t=o.getActiveSheet();return{unitId:o.getUnitId(),sheetId:t.getSheetId(),sheetName:t.getName()}}_getSheetObject(){return it(this._context.unit,this._context)}_commandExecutedListener(){const o=S.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((t,e)=>{e!=null&&e.fromCollab||(t.id===S.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():o.includes(t.id)&&this._hideEditor())})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{t.id===qn.id&&this._editorBridgeService.refreshEditCellState()}))}};Xo=__([Je(1,D.Inject(D.Injector)),Je(2,l.ICommandService),Je(3,Ee),Je(4,I.ILayoutService),Je(5,I.IEditorService),Je(6,l.IContextService),Je(7,D.Inject(S.SelectionManagerService)),Je(8,I.IRangeSelectorService)],Xo);var S_=Object.defineProperty,p_=Object.getOwnPropertyDescriptor,C_=(o,t,e,n)=>{for(var i=n>1?void 0:n?p_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&S_(t,e,i),i},pn=(o,t)=>(e,n)=>t(e,n,o);let Ln=class extends l.Disposable{constructor(o,t,e,n){super(),this._commandService=o,this._formatPainterService=t,this._univerInstanceService=e,this._selectionRenderService=n,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(l.toDisposable(this._selectionRenderService.selectionMoveEnd$.subscribe(o=>{if(this._formatPainterService.getStatus()!==xe.OFF){const{rangeWithCoord:t}=o[o.length-1];this._applyFormatPainter({startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}),this._formatPainterService.getStatus()===xe.ONCE&&this._commandService.executeCommand(ai.id)}})))}async _applyFormatPainter(o){const{styles:t,merges:e}=this._formatPainterService.getSelectionFormat(),n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),i=n.getUnitId(),r=n.getActiveSheet().getSheetId();if(!t)return;const{startRow:s,startColumn:a,endRow:c,endColumn:u}=t.getDataRange(),d=c-s+1,h=u-a+1,m=Array.from({length:o.endRow-o.startRow+1},()=>Array.from({length:o.endColumn-o.startColumn+1},()=>({}))),g=[];m.forEach((_,p)=>{_.forEach((v,M)=>{const b=p%d+s,T=M%h+a,w=t.getValue(b,T);w&&(m[p][M].s=w)})}),e.forEach(_=>{const p={startRow:_.startRow-s,startColumn:_.startColumn-a,endRow:_.endRow-s,endColumn:_.endColumn-a},v=Math.max(1,Math.floor((o.endRow-o.startRow+1)/d)),M=Math.max(1,Math.floor((o.endColumn-o.startColumn+1)/h));for(let b=0;b<v;b++)for(let T=0;T<M;T++)g.push({startRow:p.startRow+b*d+o.startRow,startColumn:p.startColumn+T*h+o.startColumn,endRow:p.endRow+b*d+o.startRow,endColumn:p.endColumn+T*h+o.startColumn})});const f={subUnitId:r,unitId:i,styleRange:o,styleValues:m,mergeRanges:g};await this._commandService.executeCommand(Fr.id,f)}};Ln=C_([l.OnLifecycle(l.LifecycleStages.Rendered,Ln),pn(0,l.ICommandService),pn(1,ft),pn(2,l.IUniverInstanceService),pn(3,Ne)],Ln);var v_=Object.defineProperty,I_=Object.getOwnPropertyDescriptor,R_=(o,t,e,n)=>{for(var i=n>1?void 0:n?I_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&v_(t,e,i),i},Cn=(o,t)=>(e,n)=>t(e,n,o);exports.DragManagerService=class extends l.Disposable{constructor(e,n,i,r){super();R(this,"_currentCell$",new U.Subject);R(this,"currentCell$",this._currentCell$.asObservable().pipe(U.distinctUntilChanged((e,n)=>{var i,r,s,a,c,u,d,h;return((i=e==null?void 0:e.location)==null?void 0:i.unitId)===((r=n==null?void 0:n.location)==null?void 0:r.unitId)&&((s=e==null?void 0:e.location)==null?void 0:s.subUnitId)===((a=n==null?void 0:n.location)==null?void 0:a.subUnitId)&&((c=e==null?void 0:e.location)==null?void 0:c.row)===((u=n==null?void 0:n.location)==null?void 0:u.row)&&((d=e==null?void 0:e.location)==null?void 0:d.col)===((h=n==null?void 0:n.location)==null?void 0:h.col)})));R(this,"_endCell$",new U.Subject);R(this,"endCell$",this._endCell$.asObservable());this._univerInstanceService=e,this._scrollManagerService=n,this._sheetSkeletonManagerService=i,this._renderManagerService=r,this._initCellDisposableListener()}dispose(){super.dispose(),this._currentCell$.complete(),this._endCell$.complete()}_initCellDisposableListener(){this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e||(this._currentCell$.next(null),this._endCell$.next(null))}))}_calcActiveCell(e,n){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!i)return null;const r=i.getActiveSheet(),s=this._sheetSkeletonManagerService.getCurrent(),a=this._renderManagerService.getRenderById(i.getUnitId()),c=this._scrollManagerService.getCurrentScroll();if(!(!s||!c||!a))return Vr(a,i,r,s,e,n)}onDragOver(e){const{offsetX:n,offsetY:i,dataTransfer:r}=e,s=this._calcActiveCell(n,i);if(!s){this._currentCell$.next(null);return}const{location:a,position:c}=s;this._currentCell$.next({location:a,position:c,dataTransfer:r})}onDrop(e){const{offsetX:n,offsetY:i,dataTransfer:r}=e,s=this._calcActiveCell(n,i);if(!s){this._endCell$.next(null);return}const{location:a,position:c}=s;this._endCell$.next({location:a,position:c,dataTransfer:r})}};exports.DragManagerService=R_([Cn(0,l.IUniverInstanceService),Cn(1,D.Inject(Ze)),Cn(2,D.Inject(exports.SheetSkeletonManagerService)),Cn(3,E.IRenderManagerService)],exports.DragManagerService);var M_=Object.defineProperty,b_=Object.getOwnPropertyDescriptor,T_=(o,t,e,n)=>{for(var i=n>1?void 0:n?b_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&M_(t,e,i),i},To=(o,t)=>(e,n)=>t(e,n,o);exports.DragRenderController=class extends l.Disposable{constructor(t,e,n,i){super(),this._context=t,this._renderManagerService=e,this._dragManagerService=n,this._sheetSkeletonManagerService=i,this._initDragEvent()}_initDragEvent(){const t=new l.DisposableCollection,e=n=>{if(t.dispose(),!n)return;const i=this._renderManagerService.getRenderById(n.unitId);if(!i)return;const{scene:r}=i,s=r.onDragOverObserver.add(c=>{this._dragManagerService.onDragOver(c)}),a=r.onDropObserver.add(c=>{this._dragManagerService.onDrop(c)});t.add({dispose(){r.onDragOverObserver.remove(s),r.onDropObserver.remove(a)}})};e(this._sheetSkeletonManagerService.getCurrent()),this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(n=>{e(n)}))}};exports.DragRenderController=T_([l.OnLifecycle(l.LifecycleStages.Rendered,exports.DragRenderController),To(1,E.IRenderManagerService),To(2,D.Inject(exports.DragManagerService)),To(3,D.Inject(exports.SheetSkeletonManagerService))],exports.DragRenderController);var w_=Object.defineProperty,E_=Object.getOwnPropertyDescriptor,y_=(o,t,e,n)=>{for(var i=n>1?void 0:n?E_(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&w_(t,e,i),i},vn=(o,t)=>(e,n)=>t(e,n,o),In;exports.UniverSheetsUIPlugin=(In=class extends l.Plugin{constructor(t={},e,n,i,r){super(),this._config=t,this._injector=e,this._localeService=n,this._renderManagerService=i,this._univerInstanceService=r,this._localeService.load({zhCN:Zr}),this._config=l.Tools.deepMerge({},yf,this._config)}onStarting(t){[[qt],[Ee,{useClass:exports.EditorBridgeService}],[Ot,{useClass:exports.SheetClipboardService}],[Pt,{useClass:Eu}],[ft,{useClass:Ao}],[sn,{useClass:Kr}],[to,{useClass:Gc}],[yt,{useClass:exports.AutoFillService}],[Ze],[exports.SheetSkeletonManagerService],[Ne,{useClass:exports.SelectionRenderService}],[hi,{useClass:Zm}],[nn,{useClass:exports.MarkSelectionService}],[exports.HoverManagerService],[exports.DragManagerService],[exports.SheetCanvasPopManagerService],[exports.CellAlertManagerService],[Tn],[exports.AutoHeightController],[yn],[On],[Wn],[wn],[exports.SheetRenderController],[Gt,{useFactory:()=>this._injector.createInstance(Gt,this._config)}],[xn],[An],[En],[exports.AutoFillController],[Ln]].forEach(e=>t.add(e))}onReady(){this._markSheetAsFocused(),this._registerRenderControllers()}_registerRenderControllers(){[exports.SheetCanvasView,Uo,$o,Wn,Wo,Fo,Fn,exports.SheetsScrollRenderController,Po,Lo,Dn,Hn,jo,exports.HoverRenderController,exports.DragRenderController,Pn,exports.CellCustomRenderController,Yo,Xo].forEach(t=>{this.disposeWithMe(this._renderManagerService.registerRenderController(l.UniverInstanceType.UNIVER_SHEET,t))})}_markSheetAsFocused(){const t=this._univerInstanceService;t.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(Ls.filter(e=>!!e)).subscribe(e=>{t.focusUnit(e.getUnitId())})}},R(In,"pluginName","SHEET_UI_PLUGIN"),R(In,"type",l.UniverInstanceType.UNIVER_SHEET),In);exports.UniverSheetsUIPlugin=y_([vn(1,D.Inject(D.Injector)),vn(2,D.Inject(l.LocaleService)),vn(3,E.IRenderManagerService),vn(4,l.IUniverInstanceService)],exports.UniverSheetsUIPlugin);exports.APPLY_TYPE=oe;exports.AutoFillCommand=Vn;exports.COPY_TYPE=et;exports.CellAlertType=bt;exports.CellEditorManagerService=Kr;exports.DATA_TYPE=ue;exports.ExpandSelectionCommand=Ae;exports.IAutoFillService=yt;exports.ICellEditorManagerService=sn;exports.IEditorBridgeService=Ee;exports.IFormulaEditorManagerService=to;exports.IMarkSelectionService=nn;exports.ISelectionRenderService=Ne;exports.ISheetClipboardService=Ot;exports.JumpOver=ke;exports.MoveSelectionCommand=we;exports.PASTE_SPECIAL_MENU_ID=Dt;exports.PREDEFINED_HOOK_NAME=fe;exports.ResetScrollCommand=Il;exports.SHEET_UI_PLUGIN_NAME=Us;exports.SHEET_VIEW_KEY=ie;exports.ScrollCommand=dt;exports.ScrollToCellCommand=Nr;exports.SelectionShape=Bn;exports.SetCellEditVisibleArrowOperation=Qt;exports.SetCellEditVisibleOperation=Te;exports.SetScrollOperation=ot;exports.SetScrollRelativeCommand=Xt;exports.SetZoomRatioOperation=Fe;exports.SheetCopyCommand=Ir;exports.SheetMenuPosition=le;exports.SheetPasteCommand=xt;exports.VIEWPORT_KEY=W;exports.deriveStateFromActiveSheet$=_e;exports.enUS=$c;exports.expandToContinuousRange=Er;exports.getAutoFillRepeatRange=qs;exports.getCoordByCell=No;exports.getCoordByOffset=Et;exports.getEditorObject=Gn;exports.getRepeatRange=Xa;exports.getSheetObject=it;exports.getTransformCoord=bn;exports.mergeSetRangeValues=Oo;exports.rangeToDiscreteRange=Rt;exports.ruRU=Xc;exports.useActiveWorkbook=kc;exports.useActiveWorksheet=Wc;exports.virtualizeDiscreteRanges=tn;exports.whenFormulaEditorActivated=ua;exports.whenSheetEditorFocused=ne;exports.zhCN=Zr;