@univerjs/sheets-ui 0.6.7-nightly.202503311607 → 0.6.7-nightly.202504011606
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 +1 -1
- package/lib/es/index.js +1375 -1375
- package/lib/index.js +1375 -1375
- package/lib/umd/index.js +27 -27
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
`,g={...u,body:{dataStream:h,textRuns:c.textRuns,paragraphs:Zi(h)}};d==null||d.reset(g),o=d==null?void 0:d.getSnapshot(),r=c.dataStream}else r=Fm(i.innerHTML.replace(/[\r\n]/g,""));return{cellText:r,cellRichStyle:o}}_generateDocumentDataModelSnapshot(i){var l;const e=this._getCurrentSkeleton();if(e==null)return null;const{skeleton:t}=e,r=(l=t.getBlankCellDocumentModel())==null?void 0:l.documentModel,s={...r==null?void 0:r.getSnapshot(),...i};return r==null||r.reset(s),r==null?void 0:r.getSnapshot()}process(i,e,t,r){var o,s,l;for(const c of e)if(c.nodeName.toLowerCase()==="table")r.push({index:((o=t==null?void 0:t.paragraphs)==null?void 0:o.length)||0});else if(c.nodeType===Node.TEXT_NODE){if(((s=c.nodeValue)==null?void 0:s.trim())==="")continue;const d=(l=c.nodeValue)==null?void 0:l.replace(/[\r\n]/g,"");let u;i&&this._styleCache.has(i)&&(u=this._styleCache.get(i));const h={dataStream:"",textRuns:[]};t.dataStream+=d,h.dataStream+=d,u&&Object.getOwnPropertyNames(u).length&&(t.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}),h.textRuns.push({st:t.dataStream.length-d.length,ed:t.dataStream.length,ts:u}))}else{if(a.skipParseTagNames.includes(c.nodeName.toLowerCase()))continue;if(c.nodeName.toLowerCase()==="br")t.paragraphs||(t.paragraphs=[]),t.paragraphs.push({startIndex:t.dataStream.length}),t.dataStream+="\r";else if(c.nodeType===Node.ELEMENT_NODE){if(c.nodeName==="STYLE")continue;const d=c,u=this._processBeforeLink(d,{body:t}),h=i?this._styleCache.get(i):{},g=this._styleRules.find(({filter:v})=>ha(c,v)),S=g?g.getStyle(c):oi(c);this._styleCache.set(c,{...h,...S});const{childNodes:f}=c;this.process(c,f,t,r);const p=this._afterProcessRules.find(({filter:v})=>ha(c,v));p&&p.handler(t,c),this._processAfterLink(d,{body:t},u)}}}_processBeforeLink(i,e){return e.body.dataStream.length}_processAfterLink(i,e,t){var s,l;const r=e.body,o=i;o.tagName.toUpperCase()==="A"&&(r.customRanges=(s=r.customRanges)!=null?s:[],r.customRanges.push({startIndex:t,endIndex:r.dataStream.length-1,rangeId:(l=o.dataset.rangeid)!=null?l:a.generateRandomId(),rangeType:a.CustomRangeType.HYPERLINK,properties:{url:o.href}}))}dispose(){this._dom=null,this._styleCache.clear(),this._styleMap.clear()}};E(Mi,"_pluginList",[]);let wn=Mi;function Lm(n){const i=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,e=n.matchAll(i);if(!e)return{rowProperties:[],rowCount:0};const r=Array.from(e).map(o=>kl(o[1])).map(o=>{if(!o.height){const s=o.style,l=s&&s.match(/height\s*:\s*(\d+(\.\d+)?)px/);o.height=`${l?Number.parseInt(l[1],10):a.DEFAULT_WORKSHEET_ROW_HEIGHT}`}return o});return{rowProperties:r,rowCount:r.length}}function ma(n){const i={};return n.split(";").forEach(t=>{const[r,o]=t.split(":");i[r]=o}),i}function kl(n){if(!n)return{};const i={},e=/([\w-]+)\s*=\s*(?:(['"])([^'"]*)\2|(\S+))/g;let t;for(;(t=e.exec(n))!==null;){const[,r,,o,s]=t,l=o!==void 0?o:s;i[r]=l}return i}function Bm(n){const i=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,e=n.match(i),t=/<col([\s\S]*?)>/g;let r;if(e!=null&&e[2]?r=e[2].matchAll(t):r=n.matchAll(t),!r)return null;const o=Array.from(r).map(l=>kl(l[1])),s=[];return o.forEach(l=>{const c=Number(l.span);if(c)for(let d=0;d<c;d++){const u={...l};delete u.span,s.push(u)}else s.push(l)}),s}function Fm(n){const i={"<":"<",">":">","&":"&",""":'"',"'":"'"," ":" "};return n.replace(/<|>|&|"|'| |<br>/g,e=>i[e])}function ga(n,i){if(!n||!i)return null;const e=new RegExp(`(${i}\\s*:\\s*[^;]+);`,"i"),t=n.match(e);return t?t[1]:null}function jm(n,i,e,t){const{rowSpan:r,colSpan:o,rowIndex:s,colSetValueIndex:l}=t;for(let c=s;c<s+r;c++)for(let d=l;d<l+o;d++)c===s&&d===l?n.setValue(c,d,{...e,style:i}):n.setValue(c,d,{style:i})}const zm={name:"univer-doc-paste-plugin-lark",checkPasteType(n){return/lark-record-clipboard/i.test(n)},stylesRules:[{filter:["s"],getStyle(n){const i=oi(n);return{st:{s:a.BooleanNumber.TRUE},...i}}}],afterProcessRules:[{filter(n){return n.tagName==="DIV"&&/ace-line/i.test(n.className)},handler(n){n.paragraphs==null&&(n.paragraphs=[]),n.paragraphs.push({startIndex:n.dataStream.length}),n.dataStream+="\r"}}]},Xm={name:"univer-doc-paste-plugin-univer",checkPasteType(n){return/UniverNormal/i.test(n)},stylesRules:[],afterProcessRules:[{filter(n){return n.tagName==="P"&&/UniverNormal/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Al(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]},Ym={name:"univer-doc-paste-plugin-word",checkPasteType(n){return/word|mso/i.test(n)},stylesRules:[{filter:["b"],getStyle(n){const i=oi(n);return{bl:a.BooleanNumber.TRUE,...i}}}],afterProcessRules:[{filter(n){return n.tagName==="P"&&/mso/i.test(n.className)},handler(n,i){n.paragraphs==null&&(n.paragraphs=[]);const e={startIndex:n.dataStream.length},t=Al(i);t&&(e.paragraphStyle=t),n.paragraphs.push(e),n.dataStream+="\r"}}]};var dt=(n=>(n.COPY="COPY",n.CUT="CUT",n))(dt||{});function Gm(n,i,e,t,r){const o=e.map(d=>{var u;return(u=d.onCopyRow)==null?void 0:u.call(d,n)}).filter(d=>!!d),s=Ts(o),l=ys(s),c=i.map(d=>{if(!r.has(`${n}-${d}`)){const u=t.getValue(n,d);if(u!=null&&u.rowSpan&&(u!=null&&u.colSpan))for(let h=n;h<n+u.rowSpan;h++)for(let g=d;g<d+u.colSpan;g++)r.add(`${h}-${g}`);return Zm(n,d,e,t)}return null}).filter(d=>!!d).join("");return`<tr${l}>${c}</tr>`}function Zm(n,i,e,t){const r=t.getValue(n,i),o=e.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,n,i,r==null?void 0:r.rowSpan,r==null?void 0:r.colSpan)}).filter(d=>!!d),s=Ts(o),l=ys(s),c=e.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,n,i))||""},"");return`<td${l}>${c}</td>`}function Km(n,i){return`<colgroup>${n.map(t=>{const r=i.map(l=>{var c;return(c=l.onCopyColumn)==null?void 0:c.call(l,t)}).filter(l=>!!l),o=Ts(r);return`<col ${ys(o)} />`}).join("")}</colgroup>`}function Ts(n){return n.reduce((i,e)=>(Object.keys(e).forEach(r=>{i[r]?i[r]+=`;${e[r]}`:i[r]=e[r]}),i),{})}function ys(n){return Object.keys(n).reduce((i,e)=>`${i} ${e}="${n[e]}"`,"")}class qm{convert(i,e,t){const{cols:r,rows:o}=e;if(!r.length)return"";const s=Km(r,t),l=[],c=new Set;return o.forEach(u=>{l.push(Gm(u,r,t,i,c))}),`<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}
|
|
56
56
|
<tbody>${l.join("")}</tbody></table>`}}const Qm=(n,i,e=!1)=>{const t=h=>h.endRow-h.startRow+1,r=h=>h.endColumn-h.startColumn+1,o=t(i)%t(n),s=r(i)%r(n),l={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:r(n)-1},c=Math.floor(t(i)/t(n)),d=Math.floor(r(i)/r(n)),u=[];if(!o&&!s)for(let h=1;h<=c;h++)for(let g=1;g<=d;g++){const S=t(n)*(h-1),f=r(n)*(g-1),p={startRow:S+i.startRow,endRow:S+i.startRow,startColumn:f+i.startColumn,endColumn:f+i.startColumn};u.push({repeatRelativeRange:l,startRange:p})}else if(!o&&s&&!e)for(let h=1;h<=c;h++){const g=t(n)*(h-1),S=0,f={startRow:g+i.startRow,endRow:g+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else if(o&&!s&&!e)for(let h=1;h<=d;h++){const S=r(n)*(h-1),f={startRow:0+i.startRow,endRow:0+i.startRow,startColumn:S+i.startColumn,endColumn:S+i.startColumn};u.push({repeatRelativeRange:l,startRange:f})}else{const h={startRow:i.startRow,endRow:i.startRow,startColumn:i.startColumn,endColumn:i.startColumn};u.push({startRange:h,repeatRelativeRange:l})}return u};function Sa(n){return n?[/<td[^>]*class=".*?xl.*?"[^>]*>/i,/xmlns:x="urn:schemas-microsoft-com:office:excel"/i,/ProgId="Excel.Sheet"/i,/xmlns:o="urn:schemas-microsoft-com:office:office"/i,/@mso-|mso-excel/i,/<x:ExcelWorkbook>/i].some(e=>e.test(n)):!1}function Jm(n){if(!n)return!1;const i=/<img[^>]*src\s*=\s*["']data:image\/[^;]+;base64,[^"']*["'][^>]*>/i;return(n.match(i)||[]).length>0}function $m(...n){if(n.length===1)return n[0];const i=new a.ObjectMatrix;return n.forEach(e=>{e&&new a.ObjectMatrix(e).forValue((r,o,s)=>{i.setValue(r,o,{...i.getValue(r,o),...s})})}),i.getMatrix()}function eg(n,i){return n.id===i.id&&n.params.unitId===i.params.unitId&&n.params.subUnitId===i.params.subUnitId}function Yo(n){const i=[];for(let e=0;e<n.length;){let t=1;if(n[e].id===m.SetRangeValuesMutation.id){const r=n[e],o=[r];for(;e+t<n.length&&eg(r,n[e+t]);)o.push(n[e+t]),t+=1;const s=$m(...o.map(l=>l.params.cellValue||{}));i.push({...r,params:{...r.params,cellValue:s}})}else i.push(n[e]);e+=t}return i}function Ki(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=n;for(let s=e;s<=t;s++)for(let l=r;l<=o;l++)if(i.rows.includes(s)&&i.cols.includes(l))return!0}function fa(n,i){const{startRow:e,endRow:t,startColumn:r,endColumn:o}=i;for(let s=e;s<=t;s++)if(!n.rows.includes(s))return!1;for(let s=r;s<=o;s++)if(!n.cols.includes(s))return!1;return!0}function tg(n){const i=n.trim().split(`
|
|
57
57
|
`);let e="<table>";return i.forEach(t=>{const r=t.split(" ");e+="<tr>",r.forEach(o=>{e+=`<td>${o}</td>`}),e+="</tr>"}),e+="</table>",e}var ng=Object.getOwnPropertyDescriptor,rg=(n,i,e,t)=>{for(var r=t>1?void 0:t?ng(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},Oe=(n,i)=>(e,t)=>i(e,t,n);const ge={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",SPECIAL_PASTE_FORMULA:"special-paste-formula"},ig={[_.FILE_PNG_CLIPBOARD_MIME_TYPE]:"png",[_.FILE__JPEG_CLIPBOARD_MIME_TYPE]:"jpg",[_.FILE__WEBP_CLIPBOARD_MIME_TYPE]:"webp",[_.FILE__BMP_CLIPBOARD_MIME_TYPE]:"bmp"};wn.use(Ym);wn.use(zm);wn.use(Xm);const Be=a.createIdentifier("sheet.clipboard-service");exports.SheetClipboardService=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d,u,h,g,S,f,p){super();E(this,"_clipboardHooks",[]);E(this,"_clipboardHooks$",new x.BehaviorSubject([]));E(this,"clipboardHooks$",this._clipboardHooks$.asObservable());E(this,"_htmlToUSM");E(this,"_usmToHtml");E(this,"_copyContentCache");E(this,"_copyMarkId",null);E(this,"_pasteOptionsCache$",new x.BehaviorSubject(null));E(this,"pasteOptionsCache$",this._pasteOptionsCache$.asObservable());E(this,"_showMenu$",new x.BehaviorSubject(!1));E(this,"showMenu$",this._showMenu$.asObservable());this._logService=e,this._univerInstanceService=t,this._selectionManagerService=r,this._clipboardInterfaceService=o,this._undoRedoService=s,this._commandService=l,this._markSelectionService=c,this._notificationService=d,this._platformService=u,this._renderManagerService=h,this._themeService=g,this._localeService=S,this._errorService=f,this._injector=p,this._htmlToUSM=new wn({getCurrentSkeleton:()=>{var v;return(v=T.withCurrentTypeOfRenderer(a.UniverInstanceType.UNIVER_SHEET,exports.SheetSkeletonManagerService,this._univerInstanceService,this._renderManagerService))==null?void 0:v.getCurrentParam()}}),this._usmToHtml=new qm,this._copyContentCache=new Vm,this.disposeWithMe(this._htmlToUSM),this._initUnitDisposed()}setShowMenu(e){this._showMenu$.next(e)}getPasteMenuVisible(){return this._showMenu$.getValue()}getPasteOptionsCache(){return this._pasteOptionsCache$.getValue()}copyContentCache(){return this._copyContentCache}generateCopyContent(e,t,r,o=dt.COPY){const s=this._clipboardHooks;s.forEach(c=>{var d;return(d=c.onBeforeCopy)==null?void 0:d.call(c,e,t,r,o)});const l=this._generateCopyContent(e,t,r,this._clipboardHooks);return s.forEach(c=>{var d;return(d=c.onAfterCopy)==null?void 0:d.call(c)}),l}async copy(e=dt.COPY){const t=this._selectionManagerService.getCurrentLastSelection();if(!t)return!1;const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet();if(!o)return!1;const s=r.getUnitId(),l=o.getSheetId(),c=this.generateCopyContent(s,l,t.range);if(!c)return!1;const{html:d,plain:u,matrixFragment:h,copyId:g,discreteRange:S}=c;this._copyContentCache.set(g,{unitId:r.getUnitId(),subUnitId:o.getSheetId(),range:S,matrix:h,copyType:e}),await this._clipboardInterfaceService.write(u,d),this._markSelectionService.removeAllShapes();const f=xl(this._themeService);return this._copyMarkId=this._markSelectionService.addShape({...t,style:f}),!0}async cut(){return this.copy(dt.CUT)}async paste(e,t=ge.DEFAULT_PASTE){const r=e.types,o=r.indexOf(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",s=r.indexOf(_.HTML_CLIPBOARD_MIME_TYPE)!==-1?await e.getType(_.HTML_CLIPBOARD_MIME_TYPE).then(d=>d&&d.text()):"",l=r.findIndex(d=>_.imageMimeTypeSet.has(d)),c=l===-1||!Jm(s);if(s&&c)return this._platformService.isWindows&&Sa(s)&&this._notificationService.show({type:"warning",title:this._localeService.t("clipboard.shortCutNotify.title"),content:this._localeService.t("clipboard.shortCutNotify.useShortCutInstead")}),this._pasteHTML(s,t);if(l!==-1){const d=r[l],u=await e.getType(d);if(u){const h=ig[d],g=new File([u],`clipboard-image.${h}`,{type:d});return this._pasteFiles([g],t)}}return o?this._pastePlainText(o,t):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}async legacyPaste(e,t,r){const o=Sa(e!=null?e:"");return r&&!o?this._pasteFiles(r,ge.DEFAULT_PASTE):e?this._pasteHTML(e,ge.DEFAULT_PASTE):t?/[\n\t]/.test(t)?this._pasteHTML(tg(t),ge.DEFAULT_PASTE):this._pastePlainText(t,ge.DEFAULT_PASTE):this._pasteUnrecognized()}rePasteWithPasteType(e){const t=this._pasteOptionsCache$.getValue();if(!t)return!1;const r=this._injector.get(a.IUndoRedoService),o=r.pitchTopUndoElement();o&&a.sequenceExecute(o.undoMutations,this._commandService)&&r.popUndoToRedo();const{cellMatrix:s,rowProperties:l=[],colProperties:c=[],source:d,target:u}=t;return this._pasteUSM({cellMatrix:s,colProperties:c,rowProperties:l},u,ge[e],d),!0}updatePasteOptionsCache(e){this._pasteOptionsCache$.next(e)}addClipboardHook(e){if(this._clipboardHooks.findIndex(r=>r.id===e.id)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",e.id),{dispose:()=>{}};const t=this._clipboardHooks.findIndex(r=>{const o=r.priority||0;return(e.priority||0)<o});return this._clipboardHooks.splice(t!==-1?t:this._clipboardHooks.length,0,e),this._notifyClipboardHook(),a.toDisposable(()=>{const r=this._clipboardHooks.indexOf(e);r>-1&&(this._clipboardHooks.splice(r,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_generateCopyContent(e,t,r,o){const s=this._univerInstanceService.getUniverSheetInstance(e),l=s==null?void 0:s.getSheetBySheetId(t);if(!s||!l)return null;const c=o.reduce((M,y)=>{var O;const P=(O=y.getFilteredOutRows)==null?void 0:O.call(y,r);return P==null||P.forEach(k=>M.add(k)),M},new Set),{startColumn:d,startRow:u,endColumn:h,endRow:g}=r,S=l.getMatrixWithMergedCells(u,d,g,h,a.CellModeEnum.Both),f=new a.ObjectMatrix;let p=u;const v=new a.ObjectMatrix,C={rows:[],cols:[]};for(let M=u;M<=g;M++)if(!c.has(M)){C.rows.push(M);for(let y=d;y<=h;y++){const P=S.getValue(M,y);if(P){const O=a.Tools.deepClone(P);v.setValue(p-u,y-d,{...Bn(),...O}),delete O.displayV,f.setValue(p-u,y-d,{...Bn(),...O})}else v.setValue(p-u,y-d,Bn()),f.setValue(p-u,y-d,Bn()),S.setValue(M,y,Bn())}p+=1}for(let M=d;M<=h;M++)C.cols.push(M);let I=this._usmToHtml.convert(S,C,o);const R=Nl(v),w=Dm();return I=I.replace(/(<[a-z]+)/,(M,y)=>`${y} data-copy-id="${w}"`),{copyId:w,plain:R,html:I,matrixFragment:f,discreteRange:C}}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _executePaste(e){const t=this._getPastingTarget();if(!t.subUnitId||!t.selection)return!1;const r=this._injector.invoke(S=>m.rangeToDiscreteRange(t.selection.range,S,t.unitId,t.subUnitId));if(!r)return!1;const{unitId:o,subUnitId:s}=t,l=this._clipboardHooks,c=[];if(l.some(S=>{var f;return c.push(S)&&((f=S.onBeforePaste)==null?void 0:f.call(S,{unitId:o,subUnitId:s,range:r}))===!1}))return c.forEach(S=>{var f;return(f=S.onAfterPaste)==null?void 0:f.call(S,!1)}),!1;const u=[],h=[];c.forEach(S=>{const f=e(S,{unitId:o,subUnitId:s,range:r});f&&(u.push(...f.redos),h.push(...f.undos))});const g=u.every(S=>this._commandService.executeCommand(S.id,S.params));return g&&this._undoRedoService.pushUndoRedo({unitID:this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),undoMutations:h,redoMutations:u}),g}async _pasteFiles(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPasteFiles)==null?void 0:s.call(r,o,e,{pasteType:t})})}async _pastePlainText(e,t){return this._executePaste((r,o)=>{var s;return(s=r.onPastePlainText)==null?void 0:s.call(r,o,e,{pasteType:t})})}_pasteUnrecognized(){return this._executePaste((e,t)=>{var r;return(r=e.onPasteUnrecognized)==null?void 0:r.call(e,t)})}async _pasteHTML(e,t){const r=Hm(e);return r&&this._copyContentCache.get(r)?this._pasteInternal(r,t):this._pasteExternal(e,t)}async _pasteExternal(e,t){var h;const{rowProperties:r,colProperties:o,cellMatrix:s}=this._htmlToUSM.convert(e);if(!s)return!1;const l=this._getPastedRange(s);if(!l)return!1;const c=(h=this._univerInstanceService.getUniverSheetInstance(l.unitId))==null?void 0:h.getSheetBySheetId(l.subUnitId);if(!c)return!1;const d=c==null?void 0:c.getMergeData();return d.length&&d.some(S=>Ki(S,l.pastedRange)&&!fa(l.pastedRange,S))?(this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1):this._pasteUSM({rowProperties:r,colProperties:o,cellMatrix:s},l,t)}async _pasteInternal(e,t){var y,P;const r=a.Tools.deepClone(this._copyContentCache.get(e)),{range:o,matrix:s,unitId:l,subUnitId:c}=r||{};if(!s||!r||!o||!l||!c||!s||!r)return!1;const d=(y=this._univerInstanceService.getUniverSheetInstance(l))==null?void 0:y.getStyles();s.forValue((O,k,A)=>{if(typeof A.s=="string"){const N=a.Tools.deepClone(A);N.s=d==null?void 0:d.getStyleByCell(A),s.setValue(O,k,N)}if(A.colSpan||A.rowSpan)for(let N=0;N<A.rowSpan;N++)for(let H=0;H<A.colSpan;H++){if(N===0&&H===0)continue;const W=O+N,D=k+H;s.setValue(W,D,{s:d==null?void 0:d.getStyleByCell(A)})}});const u=this._getPastedRange(s);if(!u)return!1;const h=(P=this._univerInstanceService.getUniverSheetInstance(u.unitId))==null?void 0:P.getSheetBySheetId(u.subUnitId);if(!h)return!1;const g=h==null?void 0:h.getMergeData();if(g&&g.some(k=>Ki(k,u.pastedRange)&&!fa(u.pastedRange,k)))return this._errorService.emit(this._localeService.t("clipboard.paste.overlappingMergedCells")),!1;const S=this._univerInstanceService.getUnit(l);if(!S)return!1;const f=S.getSheetBySheetId(c);if(!f)return!1;const p=f.getColumnManager(),v=f.getRowManager(),C=f.getConfig().defaultColumnWidth,I=f.getConfig().defaultRowHeight,R=[],w=[];if(o.cols.forEach(O=>{const k=p.getColumnOrCreate(O);R.push({width:`${k.w||C}`})}),o.rows.forEach(O=>{const k=v.getRowOrCreate(O),{ah:A=I,h:N=I}=k,H=Math.max(A,N);w.push({height:`${H}`})}),r.copyType===dt.CUT){const O=u.pastedRange.rows[0],k=o.rows[o.rows.length-1]-o.rows[0]+O;u.pastedRange.rows=Array.from(new Array(k+1).keys()).slice(O)}const M=this._pasteUSM({cellMatrix:s,colProperties:R,rowProperties:w},u,t,{range:o,unitId:r.unitId,subUnitId:r.subUnitId,copyType:r.copyType,copyId:e});return r.copyType===dt.CUT&&(this._copyContentCache.set(e,{...r,matrix:null}),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),M}_pasteUSM(e,t,r,o){const{rowProperties:s,colProperties:l,cellMatrix:c}=e,{unitId:d,subUnitId:u,pastedRange:h}=t,g=h.cols.length,S=this._clipboardHooks,f=[];if(S.some(P=>{var O;return f.push(P)&&((O=P.onBeforePaste)==null?void 0:O.call(P,{unitId:d,subUnitId:u,range:h}))===!1}))return f.forEach(P=>{var O;return(O=P.onAfterPaste)==null?void 0:O.call(P,!1)}),!1;if(!c)return!1;const v=o?{unitId:o.unitId,subUnitId:o.subUnitId,range:o.range}:null,C={copyType:(o==null?void 0:o.copyType)||dt.COPY,copyId:o==null?void 0:o.copyId,pasteType:r};let I=[],R=[];const w=f.filter(P=>!P.specialPasteInfo&&P.id!==ge.DEFAULT_PASTE||r===P.id);w.forEach(P=>{var A,N,H;if(s){const W=(A=P.onPasteRows)==null?void 0:A.call(P,{range:h,unitId:d,subUnitId:u},s,{pasteType:r});W&&(I.push(...W.redos),R.push(...W.undos))}const O=(N=P.onPasteColumns)==null?void 0:N.call(P,{range:h,unitId:d,subUnitId:u},l||new Array(g).map(()=>({})),{pasteType:r});O&&(I.push(...O.redos),R.push(...O.undos));const k=(H=P.onPasteCells)==null?void 0:H.call(P,v,{range:h,unitId:d,subUnitId:u},c,C);k&&(I.push(...k.redos),R.push(...k.undos))});const M=this._getSetSelectionOperation(d,u,h,c,r);M&&I.push(M),I=Yo(I),R=Yo(R),R.push({id:m.SetWorksheetActiveOperation.id,params:{unitId:t.unitId,subUnitId:t.subUnitId}}),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:R,redoMutationsInfo:I});const y=I.every(P=>this._commandService.syncExecuteCommand(P.id,P.params));return y&&(this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:R,redoMutations:I}),this.updatePasteOptionsCache({target:{pastedRange:h,unitId:d,subUnitId:u},cellMatrix:c,rowProperties:s,colProperties:l,pasteType:r,source:o}),this.setShowMenu(!0)),w.forEach(P=>{var O;return(O=P.onAfterPaste)==null?void 0:O.call(P,y)}),y}_getSetSelectionOperation(e,t,r,o,s){var M;const l=(M=this._univerInstanceService.getUniverSheetInstance(e))==null?void 0:M.getSheetBySheetId(t);if(!l)return null;const{rows:c,cols:d}=r,u=c[0],h=d[0],g=c[c.length-1],S=d[d.length-1],f={startRow:u,endRow:u,startColumn:h,endColumn:h},p=m.getPrimaryForRange(f,l),v=o.getValue(0,0),C=(v==null?void 0:v.rowSpan)||1,I=(v==null?void 0:v.colSpan)||1;if((s===ge.DEFAULT_PASTE||s===ge.SPECIAL_PASTE_BESIDES_BORDER||s===ge.SPECIAL_PASTE_FORMAT)&&(C>1||I>1)){const y={startRow:u,endRow:u+C-1,startColumn:h,endColumn:h+I-1};p.startRow=y.startRow,p.endRow=y.endRow,p.startColumn=y.startColumn,p.endColumn=y.endColumn,p.isMerged=!0,p.isMergedMainCell=!0}const w={unitId:e,subUnitId:t,selections:[{range:{startRow:u,endRow:g,startColumn:h,endColumn:S},primary:p,style:null}]};return{id:m.SetSelectionsOperation.id,params:w}}_getPastingTarget(){const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),t=e.getActiveSheet(),r=this._selectionManagerService.getCurrentLastSelection();return{unitId:e.getUnitId(),subUnitId:t==null?void 0:t.getSheetId(),selection:r}}_transformPastedData(e,t,r){const o=this._getPastingTarget(),{selection:s,unitId:l,subUnitId:c}=o;if(!c||!s)return null;const d=this._injector.invoke(N=>m.rangeToDiscreteRange(s.range,N,l,c));if(!d)return null;const{ranges:[u],mapFunc:h}=Gt([d]),{startRow:g,startColumn:S,endRow:f,endColumn:p}=u,v=f-g+1,C=p-S+1,I=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),R=I==null?void 0:I.getActiveSheet();if(!R)return null;const M=R.getMergeData().filter(N=>d.rows.includes(N.startRow)&&d.cols.includes(N.startColumn)),y=M[0];let P=0,O=0,k=0,A=0;if(y&&(P=y.startRow,O=y.startColumn,k=y.endRow,A=y.endColumn),v%e===0&&C%t===0)if(M.length>0&&(v!==e||C!==t))if(P===d.rows[0]&&O===d.cols[0]&&k===d.rows[v-1]&&A===d.cols[C-1])if(lg(r))for(let H=0;H<v;H++)for(let W=0;W<C;W++){const D=r.getValue(H%e,W%t);D&&r.setValue(H,W,D)}else r.forValue((H,W,D)=>{D.s=null,delete D.colSpan,delete D.rowSpan});else for(let N=0;N<v;N++)for(let H=0;H<C;H++){const W=r.getValue(N%e,H%t);W&&r.setValue(N,H,W)}else for(let N=0;N<v;N++)for(let H=0;H<C;H++){const W=r.getValue(N%e,H%t);W&&r.setValue(N,H,W)}else if(M.length>0){const{row:N,col:H}=h(g,S);if(this._topLeftCellsMatch(e,t,{topRow:N,leftCol:H})){const D=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=D.rows,d.cols=D.cols}else{if(f>y.endRow||p>y.endColumn)return null;r.forValue((D,U,L)=>{L.s=null,delete L.colSpan,delete L.rowSpan})}}else{const N=this._expandOrShrinkRowsCols(l,c,d,t,e);d.rows=N.rows,d.cols=N.cols}return{pastedRange:d,unitId:l,subUnitId:c}}_getPastedRange(e){var R;const t=this._getPastingTarget(),{selection:r,unitId:o,subUnitId:s}=t;if(!s||!r)return null;const l=this._injector.invoke(w=>m.rangeToDiscreteRange(r.range,w,o,s));if(!l)return null;const{startColumn:c,endColumn:d,startRow:u,endRow:h}=e.getDataRange(),g=h-u+1,S=d-c+1;if(g<=0||S<=0)return null;const f=l.rows.length,p=l.cols.length,v=(R=this._univerInstanceService.getUniverSheetInstance(o))==null?void 0:R.getSheetBySheetId(s);if(!v)return null;const C=v==null?void 0:v.getMergeData();if(f%g===0&&p%S===0&&!(C==null?void 0:C.some(M=>Ki(M,l)))){for(let M=0;M<f;M++)for(let y=0;y<p;y++){const P=e.getValue(M%g,y%S);P&&e.setValue(M,y,P)}return{pastedRange:l,unitId:o,subUnitId:s}}const I=this._expandOrShrinkRowsCols(o,s,l,S,g);return l.rows=I.rows,l.cols=I.cols,{pastedRange:l,unitId:o,subUnitId:s}}_expandOrShrinkRowsCols(e,t,r,o,s){const{rows:l,cols:c}=r,d=this._univerInstanceService.getUniverSheetInstance(e),u=d==null?void 0:d.getSheetBySheetId(t);let h,g;if(l.length>=s)h=l.slice(0,s);else{h=l.slice(0);let S=l[l.length-1]+1;for(;h.length<s;)u.getRowFiltered(S)||h.push(S),S++}if(c.length>=o)g=c.slice(0,o);else{g=c.slice(0);let S=c[c.length-1]+1;for(;g.length<o;)g.push(S),S++}return{rows:h,cols:g}}_topLeftCellsMatch(e,t,r){const o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o==null?void 0:o.getActiveSheet();if(!s)return!1;const{topRow:l,leftCol:c}=r,d=sg(l+e-1,c,c+t-1,s),u=ag(c+t-1,l,l+e-1,s);return!d&&!u}removeMarkSelection(){this._copyMarkId&&(this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null)}_initUnitDisposed(){this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(a.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&this.copyContentCache().clearWithUnitId(e.getUnitId())}))}disposePasteOptionsCache(){this.setShowMenu(!1),this.updatePasteOptionsCache(null)}};exports.SheetClipboardService=rg([Oe(0,a.ILogService),Oe(1,a.IUniverInstanceService),Oe(2,a.Inject(m.SheetsSelectionsService)),Oe(3,_.IClipboardInterfaceService),Oe(4,a.IUndoRedoService),Oe(5,a.ICommandService),Oe(6,qt),Oe(7,_.INotificationService),Oe(8,_.IPlatformService),Oe(9,T.IRenderManagerService),Oe(10,a.Inject(a.ThemeService)),Oe(11,a.Inject(a.LocaleService)),Oe(12,a.Inject(a.ErrorService)),Oe(13,a.Inject(a.Injector))],exports.SheetClipboardService);function Nl(n){let i="";const e=n.getLength();return n.forRow((t,r)=>{const o=[];r.forEach(s=>{const l=n.getValue(t,s);if(l){const c=og(l);o.push(c)}}),i+=o.join(" "),t!==e-1&&(i+=`
|
|
58
|
-
`)}),i}function og(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function ag(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function lg(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ms=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ms,preconditions:ws,handler:async n=>n.get(Be).copy()},Ps={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ms,preconditions:ws,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ms,preconditions:ws,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},si={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Dl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},pr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.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 t.executeCommand(m.SetRowHiddenCommand.id),!0}},vr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(Qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.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 t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatSubscriptCommand.id):!1}},xs={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatSuperscriptCommand.id):!1}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},_r={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},As={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand(J.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var cg=Object.getOwnPropertyDescriptor,dg=(n,i,e,t)=>{for(var r=t>1?void 0:t?cg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const tt=a.createIdentifier("univer.format-painter-service");let ai=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new x.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=xl(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};ai=dg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],ai);const Ir={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(tt).setStatus(i.status),!0):!1},Wi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(tt).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(Ir.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(tt).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(Ir.id,{status:t})}},br={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(tt).applyFormatPainter(i.unitId,i.subUnitId,i.range)},mt={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,I,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,I=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,I=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,I=y,w=y-v;else return!1;const O={unitId:s,subUnitId:l,startRow:C,startColumn:I,xSplit:I>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},k=m.SetFrozenMutationFactory(n,O);return c.syncExecuteCommand(m.SetFrozenMutation.id,O)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:k}],redoMutations:[{id:m.SetFrozenMutation.id,params:O}]}),!0}},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(mt.id,{type:1}),!0)},Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(mt.id,{type:2}),!0)};var ug=Object.getOwnPropertyDescriptor,hg=(n,i,e,t)=>{for(var r=t>1?void 0:t?ug(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},pa=(n,i)=>(e,t)=>i(e,t,n);const mg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=mg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=hg([pa(0,T.IRenderManagerService),pa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const wr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Nn="UI_PLUGIN_SHEETS",Tr=`${Nn}_COLOR_PICKER_COMPONENT`,Ui=`${Nn}_FONT_FAMILY_COMPONENT`,Li=`${Nn}_FONT_FAMILY_ITEM_COMPONENT`,Bi=`${Nn}_FONT_SIZE_COMPONENT`,nt=`${Nn}_MENU_ITEM_INPUT_COMPONENT`,gg="univer-sheets-ui-context-menu-input",Sg="univer-sheets-ui-context-menu-input-container",fg="univer-sheets-ui-context-menu-input-number",qi={sheetsUiContextMenuInput:gg,sheetsUiContextMenuInputContainer:Sg,sheetsUiContextMenuInputNumber:fg},Hl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return b.jsxs("div",{className:qi.sheetsUiContextMenuInput,children:[l.t(i),b.jsx("span",{className:qi.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:b.jsx(Y.InputNumber,{className:qi.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function pg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):x.of(null)))}function be(n,i,e){return pg(n).pipe(me.switchMap(t=>t?e(t):x.of(i)))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?x.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return x.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return x.of(u.length>0)}else return x.of(d.length>0)})):x.of(!1)))}function tn(n,i,e){return x.combineLatest([i,Vl(n,e)]).pipe(me.map(([t,r])=>t||r))}function $(n,i={},e=!1){const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new x.BehaviorSubject(!1),d=s==null?void 0:s.visible$,u=new x.BehaviorSubject(null),h=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(f=>{c.next(f)}),g=d==null?void 0:d.subscribe(f=>{u.next(f)});return x.combineLatest([o.currentUser$,r,u,c]).pipe(me.finalize(()=>{h.unsubscribe(),g==null||g.unsubscribe(),c.complete()}),me.switchMap(([f,p,v,C])=>!p||v!=null&&v.visible&&v.unitId===p.getUnitId()&&!e||C&&!e?x.of(!0):p.activeSheet$.pipe(me.switchMap(I=>{if(!I)return x.of(!0);const R=n.get(m.SheetsSelectionsService),w=n.get(m.RangeProtectionRuleModel),M=n.get(m.WorksheetProtectionRuleModel),P=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return x.combineLatest([R.selectionMoveEnd$,P]).pipe(me.switchMap(([O,k])=>{if(k)return x.of(!0);const A=p.getUnitId(),N=I.getSheetId(),H=n.get(a.IPermissionService),{workbookTypes:W=[m.WorkbookEditablePermission],worksheetTypes:D,rangeTypes:U}=i,L=[];if(W==null||W.forEach(j=>{L.push(new j(A).id)}),D==null||D.forEach(j=>{L.push(new j(A,N).id)}),M.getRule(A,N))return H.composePermission$(L).pipe(me.map(j=>j.some(G=>G.value===!1)));const B=O==null?void 0:O.map(j=>j.range),z=w.getSubunitRuleList(A,N).filter(j=>B==null?void 0:B.some(G=>j.ranges.some(ee=>a.Rectangle.intersects(G,ee))));return U==null||U.forEach(j=>{z.forEach(G=>{L.push(new j(A,N,G.permissionId).id)})}),H.composePermission$(L).pipe(me.map(j=>j.some(G=>G.value===!1)))}))}))))}function Dn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return x.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Ul(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Fi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return x.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return x.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):x.of(!0)))}var Ll=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ll||{});function vg(n){const i=n.get(tt);return{id:kn.id,subId:Wi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new x.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==Ne.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:_r.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Ui,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Li},value:o.value})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{const l=()=>{var h;let d=r;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const g=o.getCellStyle(u.startRow,u.startColumn),S=o.getDefaultCellStyleInternal(),f=o.getRowStyle(u.startRow),p=o.getColumnStyle(u.startColumn),v=a.composeStyles(S,f,p,g);v.ff&&(d=v.ff)}s.next(d)},c=i.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:Cr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Bi,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new x.Observable(c=>{const d=()=>{var f;let g=o;const S=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(S!=null){const p=l.getCellStyle(S.startRow,S.startColumn),v=l.getDefaultCellStyleInternal(),C=l.getRowStyle(S.startRow),I=l.getColumnStyle(S.startColumn),R=a.composeStyles(v,C,I,p);R.fs&&(g=R.fs)}c.next(g)},u=()=>{var S,f;const g=Mr(n);if(g!=null){const p=(f=(S=g.ts)==null?void 0:S.fs)!=null?f:o;c.next(p)}},h=i.onCommandExecuted(g=>{const S=g.id;(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id)&&d(),(S===Ee.SetTextSelectionsOperation.id||S===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){return{id:As.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Tg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:Tr,hoverable:!1,selectable:!1}}],value$:new x.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function yg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Mg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:Tr,hoverable:!1,selectable:!1}}],value$:new x.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:va[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Og(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:Ca[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(i,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ia=[{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 Ag(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Ia[0].icon,type:_.MenuItemType.SELECTOR,selections:Ia,value$:be(e,t,({worksheet:r})=>new x.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){return new x.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:$(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const $n="sheet.menu.paste-special";function Ji(n){return{id:$n,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function $i(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function to(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e))}}function no(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ng(n){return{id:wr.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Bl="sheet.menu.sheet-frozen";function Dg(n){return{id:Bl,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Go="sheet.header-menu.sheet-frozen";function ba(n){return{id:Go,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:mt.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function io(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){return{id:vr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new x.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new x.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:nt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function jg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:nt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Mr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Ee.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var zg=Object.getOwnPropertyDescriptor,Xg=(n,i,e,t)=>{for(var r=t>1?void 0:t?zg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Yg="__SpreadsheetFreezeRowMainName__",Gg="__SpreadsheetFreezeRowHeaderName__",Zg="__SpreadsheetFreezeColumnMainName__",Kg="__SpreadsheetFreezeColumnHeaderName__",oo=2,qg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var O;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(O=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:O.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:R}=o,w=h>C+I?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=oo/Math.max(1,y);if(e===0){(s===-1||s===0)&&(P=P*2);const k=P;this._rowFreezeHeaderRect=new T.Rect(Gg,{fill:this._freezeNormalHeaderColor,width:I,height:P,left:0,top:p-k,zIndex:3});let A=this._freezeNormalHeaderColor;(s===-1||s===0)&&(A=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Yg,{fill:A,width:w*2/y,height:P,left:I,top:p-k,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],Rt)}else{(l===-1||l===0)&&(P=P*2);const k=P;this._columnFreezeHeaderRect=new T.Rect(Kg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-k,top:0,zIndex:3});let A=this._freezeNormalHeaderColor;(l===-1||l===0)&&(A=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Zg,{fill:A,width:P,height:M*2/y,left:f-k,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],Rt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new x.Subscription,this._freezePointerLeaveSubs=new x.Subscription,this._freezeDownSubs=new x.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,I,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(I=s==null?void 0:s.sheetViewStartRow)!=null?I:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let O=d,k=t.rowHeightAccumulation.length;O<k;O++)if(t.rowHeightAccumulation[O]-u>l){h=O,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let O=S,k=t.columnWidthAccumulation.length;O<k;O++)if(t.columnWidthAccumulation[O]-f>c){p=O,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,O,k,A;const v=this._getActiveViewport(p),{startX:C,startY:I,row:R,column:w}=Qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=oo/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(I,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(O=r.transformByState({top:Math.min(I,h)-y/2}))==null||O.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(I,h),this._activeViewport=v):((k=t.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeActiveColor}),(A=r.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var N,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=oo/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const I=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=I;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(N=y.getConfig())==null?void 0:N.freeze;let O=(P==null?void 0:P.xSplit)||0,k=(P==null?void 0:P.ySplit)||0;const A=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!A||A===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?k=this._changeToRow-(P.startRow-P.ySplit):k=this._changeToRow-R,k=k<0?0:k),o===1&&(!A||A===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||A===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?O=this._changeToColumn-(P.startColumn-P.xSplit):O=this._changeToColumn-w,O=O<0?0:O),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:k===0?-1:this._changeToRow,startColumn:O===0?-1:this._changeToColumn,ySplit:k,xSplit:O,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var O;const l=(O=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:O.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:I,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),I.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),R.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(w===!0&&M===!1){const k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),f.enable(),C.enable()}else if(w===!1&&M===!0){const k=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+k,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:k,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),S.enable(),p.enable()}else{const k=P.startX-y.startX,A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+k,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+A,width:k,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+k,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:k,height:A}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(qg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case xi.id:case Ai.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=Xg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function Qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return x.combineLatest([i.selectionMoveEnd$,o.pipe(x.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(x.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:x.of(null)}))]).pipe(x.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Fl(n,i){return!!or(n,i,a.RANGE_TYPE.ROW)}function jl(n,i){return!!or(n,i,a.RANGE_TYPE.COLUMN)}function or(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Jg=Object.getOwnPropertyDescriptor,$g=(n,i,e,t)=>{for(var r=t>1?void 0:t?Jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},so=(n,i)=>(e,t)=>i(e,t,n);const eS="__SpreadsheetHeaderMoveControllerBackground__",tS="__SpreadsheetHeaderMoveControllerShapeLine__",nS="rgba(0, 0, 0, 0.1)",rS="rgb(119, 119, 119)",iS=4,ao=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:ao}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var I,R;const h=(I=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:I.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(ao)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=Qe(u.offsetX,u.offsetY,o,h);if(!or(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,D;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(D=this._workbookSelections.getCurrentLastSelection())==null?void 0:D.range;if(!S||!this.interceptor.fetchThroughInterceptors(ao)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:I,y:R}=C;this._startOffsetX=I,this._startOffsetY=R;const{row:w,column:M}=Qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),O=or(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!O)return;const k=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let A=!1,N;const H=()=>{if(A)return;N=T.ScrollTimer.create(o,y),this._scrollTimer=N;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);N.startScroll(I,R,U),A=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:z}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,z,O,k,e),N.scrolling(B,z,()=>{this._rowColumnMoving(B,z,O,k,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const j=(F=((U==null?void 0:U.filter(G=>G.range.rangeType===a.RANGE_TYPE.ROW&&G.range.startRow<=this._changeFromRow&&this._changeFromRow<=G.range.endRow))||[])[0])==null?void 0:F.range;j&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:j,toRange:{...j,startRow:this._changeToRow,endRow:this._changeToRow+j.endRow-j.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const j=(B=((U==null?void 0:U.filter(G=>G.range.rangeType===a.RANGE_TYPE.COLUMN&&G.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=G.range.endColumn))||[])[0])==null?void 0:B.range;j&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:j,toRange:{...j,startColumn:this._changeToColumn,endColumn:this._changeToColumn+j.endColumn-j.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new x.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new x.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new x.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var z,j,G,ee,q,se,ce;const l=this._context.scene,c=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:I}=v,R=c.getNoMergeCellWithCoordByIndex(C,I),{startX:w,startY:M,endX:y,endY:P}=R,O=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(O==null)return;const k=Math.max(f,f),{startX:A,endX:N,startY:H,endY:W,startRow:D,startColumn:U,endRow:L,endColumn:F}=O;s===a.RANGE_TYPE.ROW?(j=this._moveHelperBackgroundShape)==null||j.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/k+S.y-o.y}):(G=this._moveHelperBackgroundShape)==null||G.transformByState({height:h+u,width:N-A,left:A+(e-this._startOffsetX)/k+S.x-o.x,top:0}),(ee=this._moveHelperBackgroundShape)==null||ee.show();const B=iS/k;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=D)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(q=this._moveHelperLineShape)==null||q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(I<=U)X=w-B/2,this._changeToColumn=I;else if(I>F)X=y-B/2,this._changeToColumn=I+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(tS,{fill:rS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],Rt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=$g([so(1,a.Inject(m.SheetsSelectionsService)),so(2,a.Inject(exports.SheetSkeletonManagerService)),so(3,a.ICommandService)],exports.HeaderMoveRenderController);var Zo=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Zo||{});const oS="rgba(120, 120, 120, 0.01)",lo="rgb(68, 71, 70)",Kn=12,sS=44,Ko=4;class Ra extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Kn);E(this,"_color",lo);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Kn/s,c=Ko/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:oS}),T.Rect.drawWith(e,{width:d,height:u,fill:lo,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:lo,radius:c}),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:Kn,height:this.size}):this.transformByState({width:this.size,height:Kn}),this}}var aS=Object.getOwnPropertyDescriptor,lS=(n,i,e,t)=>{for(var r=t>1?void 0:t?aS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},co=(n,i)=>(e,t)=>i(e,t,n);const cS="__SpreadsheetHeaderResizeControllerShapeRow__",dS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ea="__SpreadsheetHeaderResizeControllerShapeHelper__",wa="rgb(199, 199, 199)",uS=2,uo=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:uo}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new Ra(cS,{visible:!1,mode:Zo.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Ra(dS,{visible:!1,mode:Zo.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],Rt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var k;const h=(k=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:k.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:I,column:R}=Qe(d.offsetX,d.offsetY,o,h),w=Jn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),O=Kn/P;if(e===0){let A=p-O/2;if(w.y<=p+O/2&&w.y>=p)this._currentRow=I-1;else if(w.y>=C-O/2&&w.y<=C)this._currentRow=I,A=C-O/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(uo)(null,{row:this._currentRow}))return!1;const H=Math.min(sS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:A}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let A=f-O/2;if(w.x<=f+O/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-O/2&&w.x<=v)this._currentColumn=R,A=v-O/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(uo)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:A,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new x.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,z,j,G,ee,q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((z=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:z.height)||0)+10,S=(((G=(j=h==null?void 0:h.getScrollBar())==null?void 0:j.verticalScrollTrack)==null?void 0:G.width)||0)+10,f=Jn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),I=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:O,rowTotalHeight:k,columnHeaderHeight:A}=s,N=u>P+O?u:P+O,H=d>k+A?d:k+A,W=Math.max(p,v),D=Ko/W;e===0?this._resizeHelperShape=new T.Rect(Ea,{width:N,height:D,fill:wa,left:0,top:I-D/2}):this._resizeHelperShape=new T.Rect(Ea,{width:D,height:H,fill:wa,left:C-D/2,top:0});const U=((ee=this._columnResizeRect)==null?void 0:ee.left)||0,L=((q=this._rowResizeRect)==null?void 0:q.top)||0;l.addObject(this._resizeHelperShape,Rt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,Re,Fe,St,ft;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),Z=Jn(se.offsetX,se.offsetY,l),{x:Q,y:re}=Z,{scaleX:ie,scaleY:ae}=l.getAncestorScale(),oe=Math.max(ie,ae),ne=Ko/oe;M=Q-this._startOffsetX-ne/2,y=re-this._startOffsetY-ne/2,Math.abs(e===0?y:M)>=uS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:I+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+ne/2}),(Re=this._rowResizeRect)==null||Re.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+ne/2}),(ft=this._columnResizeRect)==null||ft.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,Z,Q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(Z=this._rowResizeRect)==null||Z.hide(),(Q=this._columnResizeRect)==null||Q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(wr.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=lS([co(1,a.Inject(exports.SheetSkeletonManagerService)),co(2,a.Inject(m.SheetsSelectionsService)),co(3,a.ICommandService)],exports.HeaderResizeRenderController);var hS=Object.getOwnPropertyDescriptor,mS=(n,i,e,t)=>{for(var r=t>1?void 0:t?hS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},jn=(n,i)=>(e,t)=>i(e,t,n);const gS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s,l){super();E(this,"_renderMetric$",new x.Subject);E(this,"renderMetric$",this._renderMetric$.asObservable());E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new x.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=r,this._sheetRenderService=o,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(x.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>gS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const r=S=>{let f=0;const v=Object.entries(S).filter(([I,R])=>Array.isArray(R)).map(([I])=>I).reduce((I,R)=>{const w=S[R].reduce((M,y)=>M+y,0);return I[R]=w,I},{});return Object.keys(S).filter(I=>I.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(I=>{f+=v[I]}),{...v,extensionTotal:f}},o=e.map(S=>({...S,...r(S)})),l=(S=>Object.entries(S[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const I=S.map(y=>y[C]),R=Math.max(...I),w=Math.min(...I),M=I.reduce((y,P)=>y+P,0)/I.length;return v[C]={max:Math.round(R*100)/100,min:Math.round(w*100)/100,avg:Math.round(M*100)/100},v},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Fs),t.addObjects([l,c,d],Rt),t.enableLayerCache(Fs,Rt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height+1,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o),l=this._configService.getConfig(qe),c=l==null?void 0:l.scrollConfig;return new T.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===K.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=mS([jn(1,a.Inject(a.IConfigService)),jn(2,a.Inject(exports.SheetSkeletonManagerService)),jn(3,a.Inject(exports.SheetsRenderService)),jn(4,a.ICommandService),jn(5,a.Optional(gd.ITelemetryService))],exports.SheetRenderController);function SS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function zl(n,i){return i.some(e=>fS(n,e))}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function Xl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=pS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function pS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Raw),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function vS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function Ta(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function CS(n,i,e,t){const r=ya(n.left,n.top,i,e,t),o=ya(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function ya(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,I=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let O;return i>R?O=(i-y)*s:O=(I+v-(R-i))*o,{x:P,y:O}}function Yl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Gl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=vS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,O)=>{O.startRow<=g&&O.endRow>=g&&O.startColumn<=h&&O.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Yl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:I,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*I,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*I,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const yt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=zl(h,u);if(f&&!i.defaultMerge&&!await o.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 p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),I=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:I}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const O=Xl(n,l,h,u);g.unshift(...O.redos),S.push(...O.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:yt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{selections:r,unitId:c,subUnitId:d})}},Ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ds={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Zl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Zl||{}),te=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(te||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),ut=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ut||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const sr="UNIVER_SHEET_PERMISSION_PANEL",li="UNIVER_SHEET_PERMISSION_USER_PART",Hs="UNIVER_SHEET_PERMISSION_BACKGROUND",Kl="UNIVER_SHEET_PERMISSION_USER_DIALOG",ql="UNIVER_SHEET_PERMISSION_DIALOG",ci="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",di="UNIVER_SHEET_PERMISSION_DIALOG_ID",Fr={[te.Copy]:"Copy",[te.SetCellStyle]:"SetCellStyle",[te.SetCellValue]:"SetCellValue",[te.SetRowStyle]:"SetRowStyle",[te.SetColumnStyle]:"SetColumnStyle",[te.InsertRow]:"InsertRow",[te.InsertColumn]:"InsertColumn",[te.InsertHyperlink]:"InsertHyperlink",[te.DeleteRow]:"DeleteRow",[te.DeleteColumn]:"DeleteColumn",[te.Sort]:"Sort",[te.Filter]:"Filter",[te.PivotTable]:"PivotTable",[te.EditExtraObject]:"EditExtraObject"},_S=[te.Copy,te.SetCellStyle,te.SetCellValue,te.SetRowStyle,te.SetColumnStyle,te.InsertRow,te.InsertColumn,te.InsertHyperlink,te.DeleteRow,te.DeleteColumn,te.Sort,te.Filter,te.PivotTable,te.EditExtraObject,te.View],Ql="sheet-permission-menu-icon",IS="sheet-permission-delete-icon",bS="sheet-permission-edit-icon",RS="sheet-permission-check-icon",Jl="sheet-permission-lock-icon",ES={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",ES);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class Mt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new x.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new x.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Je={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(Mt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:sr,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!1}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{fromSheetBar:!0,showDetail:!0}),!0}},xr={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Je.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Je.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.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 r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(Qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.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 r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Ar={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},kr={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},Nr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Zl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},ji={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Hr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Vs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:di,title:{title:"permission.dialog.allowedPermissionType"},children:{label:ql},width:393,destroyOnClose:!0,onClose:()=>e.close(di)}),!0}},wS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),b.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),b.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),b.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),b.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),b.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),b.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),b.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),b.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),b.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),b.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),b.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),b.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),b.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),b.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),b.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),b.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),b.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),TS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),b.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),b.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),b.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),b.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),b.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),b.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),b.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),b.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),b.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),b.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),b.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),yS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),b.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),b.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),b.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),b.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),b.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),b.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),b.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),b.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),b.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),b.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),b.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),b.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),b.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),b.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),b.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),b.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),b.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),b.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),b.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),MS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),b.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),b.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),b.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),b.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),b.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),b.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),b.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),b.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),b.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),b.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),b.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),b.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),b.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),b.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),b.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),b.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),b.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),b.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),b.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),b.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),b.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),b.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),b.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),b.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),b.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),b.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),b.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),b.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),b.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),b.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),b.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),b.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),b.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),b.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),b.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),b.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),b.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),b.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),b.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),b.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),b.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),b.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),PS=()=>b.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),OS=()=>b.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),b.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),b.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),b.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),b.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),b.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),xS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),b.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),b.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),b.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),AS=()=>b.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),b.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),b.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),b.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),b.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),b.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),b.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),b.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),b.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),b.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),b.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),b.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),b.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),b.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),b.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),b.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),b.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),b.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),b.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),b.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),kS=()=>b.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),Ma=()=>b.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Pa(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return b.jsx(wS,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(TS,{});case a.BorderStyleTypes.DASHED:return b.jsx(yS,{});case a.BorderStyleTypes.HAIR:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(xS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(AS,{});case a.BorderStyleTypes.THICK:return b.jsx(kS,{});case a.BorderStyleTypes.THIN:return b.jsx(Ma,{});default:return b.jsx(Ma,{})}}const Ws=`${Nn}_BORDER_PANEL_COMPONENT`,$l=[{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"}],NS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function ec(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&b.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return b.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[b.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:$l.map(c=>b.jsx("a",{className:Y.clsx(`
|
|
58
|
+
`)}),i}function og(n){return a.isNotNullOrUndefined(n.displayV)?n.displayV:a.extractPureTextFromCell(n)}function sg(n,i,e,t){return t.getMergeData().some(r=>r.startRow<=n&&n<r.endRow&&i<=r.startColumn&&r.startColumn<=e)}function ag(n,i,e,t){return t.getMergeData().some(r=>r.startColumn<=n&&n<r.endColumn&&i<=r.startRow&&r.startRow<=e)}function lg(n){let i=0;return n.forValue((e,t,r)=>{if(r&&i++,i>1)return!1}),i>1}function Bn(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Ms=998,Xe={id:_.CopyCommand.id,name:"sheet.command.copy",type:a.CommandType.COMMAND,multi:!0,priority:Ms,preconditions:ws,handler:async n=>n.get(Be).copy()},Ps={id:_.CutCommand.id,name:"sheet.command.cut",type:a.CommandType.COMMAND,multi:!0,priority:Ms,preconditions:ws,handler:async n=>n.get(Be).cut()},Ye={id:_.PasteCommand.id,type:a.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:Ms,preconditions:ws,handler:async(n,i)=>{const t=await n.get(_.IClipboardInterfaceService).read(),r=n.get(Be);return t.length!==0?r.paste(t[0],i==null?void 0:i.value):!1}},si={id:_.SheetPasteShortKeyCommandName,type:a.CommandType.COMMAND,handler:async(n,i)=>{const e=n.get(Be),{htmlContent:t,textContent:r,files:o}=i;return e.legacyPaste(t,r,o),!0}},gn={id:"sheet.command.paste-value",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_VALUE})},Sn={id:"sheet.command.paste-format",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_FORMAT})},Vt={id:"sheet.command.paste-col-width",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_COL_WIDTH})},fn={id:"sheet.command.paste-besides-border",type:a.CommandType.COMMAND,handler:async n=>n.get(a.ICommandService).executeCommand(Ye.id,{value:ge.SPECIAL_PASTE_BESIDES_BORDER})},Dl={id:"sheet.command.optional-paste",type:a.CommandType.COMMAND,handler:async(n,{type:i})=>n.get(Be).rePasteWithPasteType(i)},pr={id:"sheet.command.hide-row-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleRows();if(qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.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 t.executeCommand(m.SetRowHiddenCommand.id),!0}},vr={id:"sheet.command.hide-col-confirm",type:a.CommandType.COMMAND,handler:async n=>{var c;const e=(c=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:c.map(d=>d.range);if(!(e!=null&&e.length))return!1;const t=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),o=m.getSheetCommandTarget(r);if(!o)return!1;const{worksheet:s}=o,l=s.getVisibleCols();if(Qa(l,e)){const d=n.get(_.IConfirmService),u=n.get(a.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 t.executeCommand(m.SetColHiddenCommand.id),!0}},Qt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatBoldCommand.id):i.executeCommand(m.SetBoldCommand.id)}},Jt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatItalicCommand.id):i.executeCommand(m.SetItalicCommand.id)}},$t={type:a.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatUnderlineCommand.id):i.executeCommand(m.SetUnderlineCommand.id)}},en={type:a.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatStrikethroughCommand.id):i.executeCommand(m.SetStrikeThroughCommand.id)}},Os={type:a.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatSubscriptCommand.id):!1}},xs={type:a.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async n=>{const i=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?i.executeCommand(J.SetInlineFormatSuperscriptCommand.id):!1}},Cr={type:a.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatFontSizeCommand.id,i):e.executeCommand(m.SetFontSizeCommand.id,i)}},_r={type:a.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatFontFamilyCommand.id,i):e.executeCommand(m.SetFontFamilyCommand.id,i)}},Tn={type:a.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(n,i)=>{const e=n.get(a.ICommandService);return n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED)?e.executeCommand(J.SetInlineFormatTextColorCommand.id,i):e.executeCommand(m.SetTextColorCommand.id,i)}},As={type:a.CommandType.COMMAND,id:"sheet.command.reset-range-text-color",handler:async n=>{const i=n.get(a.ICommandService),t=n.get(a.IContextService).getContextValue(a.EDITOR_ACTIVATED),r=n.get(a.ThemeService);return t?i.executeCommand(J.SetInlineFormatTextColorCommand.id,{value:null}):i.executeCommand(m.SetTextColorCommand.id,{value:r.getCurrentTheme().textColor})}};var cg=Object.getOwnPropertyDescriptor,dg=(n,i,e,t)=>{for(var r=t>1?void 0:t?cg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},ln=(n,i)=>(e,t)=>i(e,t,n),Ne=(n=>(n[n.OFF=0]="OFF",n[n.ONCE=1]="ONCE",n[n.INFINITE=2]="INFINITE",n))(Ne||{});const tt=a.createIdentifier("univer.format-painter-service");let ai=class extends a.Disposable{constructor(i,e,t,r,o,s){super();E(this,"status$");E(this,"_selectionFormat");E(this,"_markId",null);E(this,"_status$");E(this,"_defaultHook",null);E(this,"_extendHooks",[]);this._selectionManagerService=i,this._themeService=e,this._markSelectionService=t,this._logService=r,this._commandService=o,this._undoRedoService=s,this._status$=new x.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new a.ObjectMatrix,merges:[]}}addHook(i){var e,t,r;i.isDefaultHook&&((e=i.priority)!=null?e:0)>((r=(t=this._defaultHook)==null?void 0:t.priority)!=null?r:-1)?this._defaultHook=i:(this._extendHooks.push(i),this._extendHooks.sort((o,s)=>(o.priority||0)-(s.priority||0)))}getHooks(){return this._defaultHook?[this._defaultHook,...this._extendHooks]:this._extendHooks}setStatus(i){this._updateRangeMark(i),this._status$.next(i),this.getHooks().forEach(t=>{t.onStatusChange!==void 0&&t.onStatusChange(i)})}getStatus(){return this._status$.getValue()}setSelectionFormat(i){this._selectionFormat=i}getSelectionFormat(){return this._selectionFormat}applyFormatPainter(i,e,t){const r=this.getHooks(),o=[],s=[];r.forEach(c=>{if(c.onApply!==void 0){const d=c.onApply(i,e,t,this._selectionFormat);d&&(o.push(...d.redos),s.push(...d.undos))}});for(const c of r)if(c.onBeforeApply!==void 0&&!c.onBeforeApply({unitId:i,subUnitId:e,range:t,redoMutationsInfo:o,format:this._selectionFormat,undoMutationsInfo:s}))return!1;this._logService.log("[FormatPainterService]","apply mutations",{undoMutationsInfo:s,redoMutationsInfo:o});const l=o.every(c=>this._commandService.executeCommand(c.id,c.params));return l&&this._undoRedoService.pushUndoRedo({unitID:i,undoMutations:s,redoMutations:o}),l}_updateRangeMark(i){if(this._markSelectionService.removeAllShapes(),i!==0){const e=this._selectionManagerService.getCurrentLastSelection();if(e){const t=xl(this._themeService);i===2?this._markId=this._markSelectionService.addShape({...e,style:t}):this._markId=this._markSelectionService.addShape({...e,style:t},[m.SetRangeValuesMutation.id])}}}};ai=dg([ln(0,a.Inject(m.SheetsSelectionsService)),ln(1,a.Inject(a.ThemeService)),ln(2,qt),ln(3,a.ILogService),ln(4,a.ICommandService),ln(5,a.IUndoRedoService)],ai);const Ir={id:"sheet.operation.set-format-painter",type:a.CommandType.OPERATION,handler:(n,i)=>i?(n.get(tt).setStatus(i.status),!0):!1},Wi={type:a.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async n=>{const e=n.get(tt).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.INFINITE,n.get(a.ICommandService).executeCommand(Ir.id,{status:t})}},kn={type:a.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async n=>{const e=n.get(tt).getStatus();let t;return e!==Ne.OFF?t=Ne.OFF:t=Ne.ONCE,n.get(a.ICommandService).executeCommand(Ir.id,{status:t})}},br={type:a.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(n,i)=>n.get(tt).applyFormatPainter(i.unitId,i.subUnitId,i.range)},mt={type:a.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(n,i)=>{const{type:e}=i||{},t=n.get(a.IUniverInstanceService),r=n.get(a.IUndoRedoService),o=m.getSheetCommandTarget(t);if(!o)return!1;const{unitId:s,subUnitId:l}=o,c=n.get(a.ICommandService),u=n.get(m.SheetsSelectionsService).getCurrentSelections();if(!u)return!1;const h=u[(u==null?void 0:u.length)-1],{range:g}=h,f=n.get(T.IRenderManagerService).getRenderById(s).with(exports.SheetScrollManagerService),{sheetViewStartRow:p=0,sheetViewStartColumn:v=0}=f.getCurrentScrollState()||{};let C,I,R,w;const{startRow:M,startColumn:y,rangeType:P}=g;if(P===a.RANGE_TYPE.ROW||e===1)C=M,R=M-p,I=-1,w=0;else if(P===a.RANGE_TYPE.COLUMN||e===2)C=-1,R=0,I=y,w=y-v;else if(P===a.RANGE_TYPE.NORMAL)C=M,R=M-p,I=y,w=y-v;else return!1;const O={unitId:s,subUnitId:l,startRow:C,startColumn:I,xSplit:I>0?Math.max(1,w):w,ySplit:C>0?Math.max(1,R):R},k=m.SetFrozenMutationFactory(n,O);return c.syncExecuteCommand(m.SetFrozenMutation.id,O)&&r.pushUndoRedo({unitID:s,undoMutations:[{id:m.SetFrozenMutation.id,params:k}],redoMutations:[{id:m.SetFrozenMutation.id,params:O}]}),!0}},Rr={type:a.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(mt.id,{type:1}),!0)},Er={type:a.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async n=>(n.get(a.ICommandService).executeCommand(mt.id,{type:2}),!0)};var ug=Object.getOwnPropertyDescriptor,hg=(n,i,e,t)=>{for(var r=t>1?void 0:t?ug(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},pa=(n,i)=>(e,t)=>i(e,t,n);const mg=(n,i)=>{const{unitId:e,subUnitId:t,ranges:r}=n,o={},s=i.getColumnManager();for(let l=0;l<r.length;l++){const c=r[l];for(let d=c.startColumn;d<c.endColumn+1;d++){const u=s.getColumnOrCreate(d);o[d]=u.w}}return{unitId:e,subUnitId:t,ranges:r,colWidth:o}};exports.AutoWidthController=class extends a.Disposable{constructor(i,e){super(),this._renderManagerService=i,this._univerInstanceService=e}getUndoRedoParamsOfColWidth(i){const e={redos:[],undos:[]},{_univerInstanceService:t}=this,r=m.getSheetCommandTarget(t);if(!r)return e;const{unitId:o,subUnitId:s,worksheet:l}=r,c=this._renderManagerService.getRenderById(o).with(exports.SheetSkeletonManagerService);if(!c.getCurrentParam())return e;const{skeleton:d}=c.getCurrentParam(),u=d.calculateAutoWidthInRange(i.ranges),h={};for(const{col:f,width:p}of u)h[f]=p;const g={subUnitId:s,unitId:o,ranges:i.ranges,colWidth:h},S=mg(g,l);return{undos:[{id:m.SetWorksheetColWidthMutation.id,params:S}],redos:[{id:m.SetWorksheetColWidthMutation.id,params:g}]}}};exports.AutoWidthController=hg([pa(0,T.IRenderManagerService),pa(1,a.Inject(a.IUniverInstanceService))],exports.AutoWidthController);const wr={type:a.CommandType.COMMAND,id:"sheet.command.set-col-auto-width",handler:(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o,i);if(!s)return!1;const{unitId:l,subUnitId:c}=s;let d=[];if(i!=null&&i.ranges)d=[...i.ranges];else{const f=r.getCurrentSelections();for(let p=0;p<f.length;p++)d.push(f[p].range)}if(!(d!=null&&d.length))return!1;const u={unitId:l,subUnitId:c,ranges:d},{redos:h,undos:g}=n.get(exports.AutoWidthController).getUndoRedoParamsOfColWidth(u);return a.sequenceExecute([...h],e).result?(t.pushUndoRedo({unitID:l,undoMutations:[...g],redoMutations:[...h]}),!0):!1}},Nn="UI_PLUGIN_SHEETS",Tr=`${Nn}_COLOR_PICKER_COMPONENT`,Ui=`${Nn}_FONT_FAMILY_COMPONENT`,Li=`${Nn}_FONT_FAMILY_ITEM_COMPONENT`,Bi=`${Nn}_FONT_SIZE_COMPONENT`,nt=`${Nn}_MENU_ITEM_INPUT_COMPONENT`,gg="univer-sheets-ui-context-menu-input",Sg="univer-sheets-ui-context-menu-input-container",fg="univer-sheets-ui-context-menu-input-number",qi={sheetsUiContextMenuInput:gg,sheetsUiContextMenuInputContainer:Sg,sheetsUiContextMenuInputNumber:fg},Hl=n=>{const{prefix:i,suffix:e,value:t,onChange:r,min:o=Number.MIN_SAFE_INTEGER,max:s=Number.MAX_SAFE_INTEGER}=n,l=_.useDependency(a.LocaleService),c=_.useDependency(_.IContextMenuService),[d,u]=V.useState(),h=S=>{var f;u(S==null?void 0:S.toString()),r((f=S==null?void 0:S.toString())!=null?f:"")};V.useEffect(()=>{c.visible||u(t)},[c.visible]),V.useEffect(()=>{u(t)},[t]);function g(S){S.key==="Backspace"&&S.stopPropagation()}return b.jsxs("div",{className:qi.sheetsUiContextMenuInput,children:[l.t(i),b.jsx("span",{className:qi.sheetsUiContextMenuInputContainer,onClick:S=>S.stopPropagation(),children:b.jsx(Y.InputNumber,{className:qi.sheetsUiContextMenuInputNumber,value:Number(d),precision:0,onKeyDown:g,onChange:h,min:o,max:s})}),l.t(e)]})};function pg(n){return n.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(i=>i?i.activeSheet$.pipe(me.map(e=>e?{workbook:i,worksheet:e}:null)):x.of(null)))}function be(n,i,e){return pg(n).pipe(me.switchMap(t=>t?e(t):x.of(i)))}function Vl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.IExclusiveRangeService),r=n.get(m.SheetsSelectionsService);return e.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).pipe(me.switchMap(s=>s?x.combineLatest([r.selectionMoveEnd$,s.activeSheet$]).pipe(me.switchMap(([l,c])=>{if(!c||l.length===0)return x.of(!1);const d=t.getInterestGroupId(l);if(i){const u=d.filter(h=>i.has(h));return x.of(u.length>0)}else return x.of(d.length>0)})):x.of(!1)))}function tn(n,i,e){return x.combineLatest([i,Vl(n,e)]).pipe(me.map(([t,r])=>t||r))}function $(n,i={},e=!1){const r=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),o=n.get(a.UserManagerService),s=n.has(Se)?n.get(Se):null,l=n.get(a.IContextService),c=new x.BehaviorSubject(!1),d=s==null?void 0:s.visible$,u=new x.BehaviorSubject(null),h=l.subscribeContextValue$(a.FOCUSING_FX_BAR_EDITOR).subscribe(f=>{c.next(f)}),g=d==null?void 0:d.subscribe(f=>{u.next(f)});return x.combineLatest([o.currentUser$,r,u,c]).pipe(me.finalize(()=>{h.unsubscribe(),g==null||g.unsubscribe(),c.complete()}),me.switchMap(([f,p,v,C])=>!p||v!=null&&v.visible&&v.unitId===p.getUnitId()&&!e||C&&!e?x.of(!0):p.activeSheet$.pipe(me.switchMap(I=>{if(!I)return x.of(!0);const R=n.get(m.SheetsSelectionsService),w=n.get(m.RangeProtectionRuleModel),M=n.get(m.WorksheetProtectionRuleModel),P=n.get(a.IContextService).subscribeContextValue$(a.FOCUSING_COMMON_DRAWINGS).pipe(me.startWith(!1));return x.combineLatest([R.selectionMoveEnd$,P]).pipe(me.switchMap(([O,k])=>{if(k)return x.of(!0);const A=p.getUnitId(),N=I.getSheetId(),H=n.get(a.IPermissionService),{workbookTypes:W=[m.WorkbookEditablePermission],worksheetTypes:D,rangeTypes:U}=i,L=[];if(W==null||W.forEach(j=>{L.push(new j(A).id)}),D==null||D.forEach(j=>{L.push(new j(A,N).id)}),M.getRule(A,N))return H.composePermission$(L).pipe(me.map(j=>j.some(G=>G.value===!1)));const B=O==null?void 0:O.map(j=>j.range),z=w.getSubunitRuleList(A,N).filter(j=>B==null?void 0:B.some(G=>j.ranges.some(ee=>a.Rectangle.intersects(G,ee))));return U==null||U.forEach(j=>{z.forEach(G=>{L.push(new j(A,N,G.permissionId).id)})}),H.composePermission$(L).pipe(me.map(j=>j.some(G=>G.value===!1)))}))}))))}function Dn(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(m.RangeProtectionRuleModel),r=n.get(a.IPermissionService);return x.merge(e.selectionMoveEnd$,r.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var h;const o=(h=e.getCurrentLastSelection())==null?void 0:h.range;if(!o)return!0;const s=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet();if(!s||!l)return!0;const c=s.getUnitId(),d=l.getSheetId(),u=[new m.WorkbookEditablePermission(c).id,new m.WorksheetEditPermission(c,d).id];return t.getSubunitRuleList(c,d).filter(g=>g.ranges.some(S=>a.Rectangle.intersects(o,S))).forEach(g=>{u.push(new m.RangeProtectionPermissionEditPoint(c,d,g.permissionId).id)}),r.composePermission(u).some(g=>g.value===!1)}))}function Wl(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var g;const s=(g=t.getCurrentLastSelection())==null?void 0:g.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id];return r.getSubunitRuleList(d,u).filter(S=>i==="row"?S.ranges.some(f=>s.startRow>f.startRow&&s.startRow<=f.endRow):S.ranges.some(f=>s.startColumn>f.startColumn&&s.startColumn<=f.endColumn)).forEach(S=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,S.permissionId).id)}),o.composePermission(h).some(S=>S.value===!1)}))}function Ul(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?(g.startColumn=0,g.endColumn=c.getColumnCount()-1):(g.startRow=0,g.endRow=c.getRowCount()-1),r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Fi(n,i){const e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.RangeProtectionRuleModel),o=n.get(a.IPermissionService);return x.merge(t.selectionMoveEnd$,o.permissionPointUpdate$.pipe(me.debounceTime(100))).pipe(me.map(()=>{var S;const s=(S=t.getCurrentLastSelection())==null?void 0:S.range;if(!s)return!0;const l=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=l==null?void 0:l.getActiveSheet();if(!l||!c)return!0;const d=l.getUnitId(),u=c.getSheetId(),h=[new m.WorkbookEditablePermission(d).id,new m.WorksheetEditPermission(d,u).id],g=a.Tools.deepClone(s);return i==="row"?g.endRow=c.getRowCount()-1:g.endColumn=c.getColumnCount()-1,r.getSubunitRuleList(d,u).filter(f=>f.ranges.some(p=>a.Rectangle.intersects(g,p))).forEach(f=>{h.push(new m.RangeProtectionPermissionEditPoint(d,u,f.permissionId).id)}),o.composePermission(h).some(f=>f.value===!1)}))}function Hn(n,i){const t=n.get(a.IUniverInstanceService).getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),r=n.get(m.WorksheetProtectionRuleModel),o=n.get(m.RangeProtectionRuleModel),s=n.get(a.IPermissionService),l=n.get(a.UserManagerService);return x.combineLatest([l.currentUser$,t]).pipe(me.switchMap(([c,d])=>d?d.activeSheet$.pipe(me.switchMap(u=>{if(!u)return x.of(!0);const h=d.getUnitId(),g=[];return i.forEach(f=>g.push(new f(h).id)),s.composePermission$(g).pipe(me.map(f=>f.every(p=>p.value===!0))).pipe(me.map(f=>{if(!f)return!0;const p=u.getSheetId(),v=r.getRule(h,p),C=o.getSubunitRuleList(h,p);return!!(v||C.length)}))})):x.of(!0)))}var Ll=(n=>(n.ROW_HEADER_CONTEXT_MENU="ROW_HEADER_CONTEXT_MENU",n.COL_HEADER_CONTEXT_MENU="COL_HEADER_CONTEXT_MENU",n.SHEET_BAR="SHEET_BAR",n.SHEET_FOOTER="SHEET_FOOTER",n))(Ll||{});function vg(n){const i=n.get(tt);return{id:kn.id,subId:Wi.id,type:_.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",activated$:new x.Observable(e=>{let t=!1;const r=i.status$.subscribe(o=>{t=o!==Ne.OFF,e.next(t)});return e.next(t),()=>{r.unsubscribe()}}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetCopyPermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function Cg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IContextService),r=n.get(m.SheetsSelectionsService);return{id:Qt.id,type:_.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=r.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontWeight.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontWeight()}s.next(v===a.FontWeight.BOLD)}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&t.getContextValue(a.EDITOR_ACTIVATED)&&t.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.bl;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=r.getCurrentLastSelection())==null?void 0:u.primary;if(!o){s.next(!1);return}let d=a.FontWeight.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontWeight()}return s.next(d===a.FontWeight.BOLD),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function _g(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:Jt.id,type:_.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v=a.FontItalic.NORMAL;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getFontStyle()}s.next(v===a.FontItalic.ITALIC)}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.it;s.next(v===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d=a.FontItalic.NORMAL;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getFontStyle()}return s.next(d===a.FontItalic.ITALIC),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ig(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:$t.id,type:_.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getUnderline()}s.next(!!(v&&v.s))}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.ul;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getUnderline()}return s.next(!!(d&&d.s)),l.dispose})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function bg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService);return{id:en.id,type:_.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),activated$:be(e,!1,({worksheet:o})=>new x.Observable(s=>{var u;const l=i.onCommandExecuted(h=>{var S,f;const g=h.id;if(g===m.SetRangeValuesMutation.id||g===m.SetSelectionsOperation.id||g===m.SetWorksheetActiveOperation.id){const p=(S=t.getCurrentLastSelection())==null?void 0:S.primary;let v;if(p!=null){const C=o.getRange(p.startRow,p.startColumn);v=C==null?void 0:C.getStrikeThrough()}s.next(!!(v&&v.s))}if((g===Ee.SetTextSelectionsOperation.id||g===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)){const p=Mr(n);if(p==null)return;const v=(f=p.ts)==null?void 0:f.st;s.next((v==null?void 0:v.s)===a.BooleanNumber.TRUE)}}),c=(u=t.getCurrentLastSelection())==null?void 0:u.primary;let d;if(c!=null){const h=o.getRange(c.startRow,c.startColumn);d=h==null?void 0:h.getStrikeThrough()}return s.next(!!(d&&d.s)),l.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Rg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=a.DEFAULT_STYLES.ff;return{id:_r.id,tooltip:"toolbar.font",type:_.MenuItemType.SELECTOR,label:Ui,selections:_.FONT_FAMILY_LIST.map(o=>({label:{name:Li},value:o.value})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{const l=()=>{var h;let d=r;const u=(h=t.getCurrentLastSelection())==null?void 0:h.primary;if(u!=null){const g=o.getCellStyle(u.startRow,u.startColumn),S=o.getDefaultCellStyleInternal(),f=o.getRowStyle(u.startRow),p=o.getColumnStyle(u.startColumn),v=a.composeStyles(S,f,p,g);v.ff&&(d=v.ff)}s.next(d)},c=i.onCommandExecuted(d=>{const u=d.id;(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetActiveOperation.id)&&l()});return l(),c.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Eg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(a.IContextService),o=a.DEFAULT_STYLES.fs,s=$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0);return{id:Cr.id,type:_.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Bi,props:{min:1,max:400,disabled$:s}},selections:_.FONT_SIZE_LIST,disabled$:s,value$:be(e,o,({worksheet:l})=>new x.Observable(c=>{const d=()=>{var f;let g=o;const S=(f=t.getCurrentLastSelection())==null?void 0:f.primary;if(S!=null){const p=l.getComposedCellStyle(S.startRow,S.startColumn);p.fs&&(g=p.fs)}c.next(g)},u=()=>{var S,f;const g=Mr(n);if(g!=null){const p=(f=(S=g.ts)==null?void 0:S.fs)!=null?f:o;c.next(p)}},h=i.onCommandExecuted(g=>{const S=g.id;(S===m.SetRangeValuesMutation.id||S===m.SetSelectionsOperation.id||S===m.SetWorksheetActiveOperation.id)&&d(),(S===Ee.SetTextSelectionsOperation.id||S===J.SetInlineFormatCommand.id)&&r.getContextValue(a.EDITOR_ACTIVATED)&&r.getContextValue(a.FOCUSING_SHEET)&&u()});return d(),h.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function wg(n){return{id:As.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Tg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:Tn.id,icon:"FontColor",tooltip:"toolbar.textColor.main",type:_.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:Tr,hoverable:!1,selectable:!1}}],value$:new x.Observable(t=>{const r=e.getCurrentTheme().textColor,o=i.onCommandExecuted(s=>{if(s.id===Tn.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]},!0)}}function yg(n){return{id:m.ResetBackgroundColorCommand.id,type:_.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Mg(n){const i=n.get(a.ICommandService),e=n.get(a.ThemeService);return{id:m.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",type:_.MenuItemType.BUTTON_SELECTOR,icon:"PaintBucket",selections:[{label:{name:Tr,hoverable:!1,selectable:!1}}],value$:new x.Observable(t=>{const r=e.getCurrentTheme().primaryColor,o=i.onCommandExecuted(s=>{if(s.id===m.SetBackgroundColorCommand.id){const l=s.params.value;t.next(l!=null?l:r)}});return t.next(r),o.dispose}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const va=[{label:"align.left",icon:"LeftJustifyingSingle",value:a.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:a.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:a.HorizontalAlign.RIGHT}];function Pg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.HorizontalAlign.LEFT;return{id:m.SetHorizontalTextAlignCommand.id,icon:va[0].icon,tooltip:"toolbar.horizontalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:va,value$:be(i,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetHorizontalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getHorizontalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getHorizontalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ca=[{label:"align.top",icon:"AlignTopSingle",value:a.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:a.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:a.VerticalAlign.BOTTOM}];function Og(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=a.VerticalAlign.BOTTOM;return{id:m.SetVerticalTextAlignCommand.id,icon:Ca[2].icon,tooltip:"toolbar.verticalAlignMode.main",type:_.MenuItemType.SELECTOR,selections:Ca,value$:be(i,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetVerticalTextAlignCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=e.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getVerticalAlignment()}o.next(S!=null?S:t)}),l=(d=e.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getVerticalAlignment()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const _a=[{label:"textWrap.overflow",icon:"OverflowSingle",value:a.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:a.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:a.WrapStrategy.CLIP}];function xg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=a.WrapStrategy.OVERFLOW;return{id:m.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:_a[0].icon,type:_.MenuItemType.SELECTOR,selections:_a,value$:be(e,t,({worksheet:r})=>new x.Observable(o=>{var d;const s=n.get(a.ICommandService).onCommandExecuted(u=>{var f;const h=u.id;if(h!==m.SetTextWrapCommand.id&&h!==m.SetSelectionsOperation.id&&h!==m.SetWorksheetActiveOperation.id)return;const g=(f=i.getCurrentLastSelection())==null?void 0:f.primary;let S;if(g!=null){const p=r.getRange(g.startRow,g.startColumn);S=p==null?void 0:p.getWrapStrategy()}o.next(S!=null?S:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const u=r.getRange(l.startRow,l.startColumn);c=u==null?void 0:u.getWrapStrategy()}return o.next(c!=null?c:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}const Ia=[{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 Ag(n){const i=n.get(m.SheetsSelectionsService),e=n.get(a.IUniverInstanceService),t=0;return{id:m.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Ia[0].icon,type:_.MenuItemType.SELECTOR,selections:Ia,value$:be(e,t,({worksheet:r})=>new x.Observable(o=>{var d,u;const s=n.get(a.ICommandService).onCommandExecuted(h=>{var p,v;const g=h.id;if(g!==m.SetTextRotationCommand.id&&g!==m.SetSelectionsOperation.id&&g!==m.SetWorksheetActiveOperation.id)return;const S=(p=i.getCurrentLastSelection())==null?void 0:p.primary;let f;if(S!=null){const C=r.getRange(S.startRow,S.startColumn);f=C==null?void 0:C.getTextRotation()}(f==null?void 0:f.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((v=f&&f.a)!=null?v:t)}),l=(d=i.getCurrentLastSelection())==null?void 0:d.primary;let c;if(l!=null){const h=r.getRange(l.startRow,l.startColumn);c=h==null?void 0:h.getTextRotation()}return(c==null?void 0:c.v)===a.BooleanNumber.TRUE?o.next("v"):o.next((u=c&&c.a)!=null?u:t),s.dispose})),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function yr(n){return new x.Observable(e=>e.next(!n.get(_.IClipboardInterfaceService).supportClipboard))}function pn(n){return{id:Xe.name,commandId:Xe.id,type:_.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",disabled$:$(n,{workbookTypes:[m.WorkbookCopyPermission],worksheetTypes:[m.WorksheetCopyPermission],rangeTypes:[m.RangeProtectionPermissionViewPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Qi(n){return{id:Ye.name,commandId:Ye.id,type:_.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const $n="sheet.menu.paste-special";function Ji(n){return{id:$n,type:_.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",hidden$:tn(n,_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET))}}function $i(n){return{id:gn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteValue",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellValuePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function eo(n){return{id:Sn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteFormat",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetCellStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function to(n){return{id:Vt.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e))}}function no(n){return{id:fn.id,type:_.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",disabled$:yr(n).pipe(x.combineLatestWith($(n,{rangeTypes:[m.RangeProtectionPermissionEditPoint],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetCellStylePermission,m.WorksheetSetCellValuePermission,m.WorksheetSetRowStylePermission,m.WorksheetSetColumnStylePermission],workbookTypes:[m.WorkbookEditablePermission]})),x.map(([i,e])=>i||e)),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function kg(n){return{id:m.SetWorksheetRowIsAutoHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AutoHeight",title:"rightClick.fitContent",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ng(n){return{id:wr.id,type:_.MenuItemType.BUTTON,icon:"AutoWidth",title:"rightClick.fitContent",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Bl="sheet.menu.sheet-frozen";function Dg(n){return{id:Bl,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}const Go="sheet.header-menu.sheet-frozen";function ba(n){return{id:Go,type:_.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function ro(n){return{id:mt.id,type:_.MenuItemType.BUTTON,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Hg(n){return{id:Rr.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeRow",icon:"FreezeRowSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Vg(n){return{id:Er.id,type:_.MenuItemType.BUTTON,title:"rightClick.freezeCol",icon:"FreezeColumnSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function io(n){return{id:m.CancelFrozenCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle",hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Wg(n){return{id:pr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedRow",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetRowStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Ug(n){return{id:vr.id,type:_.MenuItemType.BUTTON,icon:"Hide",title:"rightClick.hideSelectedColumn",disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]}),hidden$:_.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET)}}function Lg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetRowHiddenMutation,m.SetRowVisibleMutation].map(o=>o.id);return{id:m.SetSelectedRowsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideRow",hidden$:be(i,!0,({worksheet:o})=>new x.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.ROW);return!!(d!=null&&d.some(h=>{for(let g=h.startRow;g<=h.endRow;g++)if(!o.getRowRawVisible(g))return!0;return!1}))}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Bg(n){const i=n.get(a.IUniverInstanceService),e=n.get(m.SheetsSelectionsService),t=n.get(a.ICommandService),r=[m.SetSelectionsOperation,m.SetColHiddenMutation,m.SetColVisibleMutation].map(o=>o.id);return{id:m.SetSelectedColsVisibleCommand.id,type:_.MenuItemType.BUTTON,title:"rightClick.showHideColumn",hidden$:be(i,!0,({worksheet:o})=>new x.Observable(s=>{function l(){var u;const d=(u=e.getCurrentSelections())==null?void 0:u.map(h=>h.range).filter(h=>h.rangeType===a.RANGE_TYPE.COLUMN);return!d||d.length===0?!1:!!d.some(h=>{for(let g=h.startColumn;g<=h.endColumn;g++)if(!o.getColVisible(g))return!0;return!1})}const c=t.onCommandExecuted(d=>{r.findIndex(u=>u===d.id)!==-1&&s.next(!l())});return s.next(!l()),()=>c.dispose()})),disabled$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetSetColumnStylePermission,m.WorksheetEditPermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Fg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetRowHeightCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustHeight",label:{name:nt,props:{prefix:"rightClick.rowHeight",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary,u=d?o.getRowHeight(d.startRow):r;s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetRowIsAutoHeightMutation.id)return l()});return l(),c.dispose})),hidden$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetRowStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function jg(n){const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=0;return{id:m.SetColWidthCommand.id,type:_.MenuItemType.BUTTON,icon:"AdjustWidth",label:{name:nt,props:{prefix:"rightClick.columnWidth",suffix:"px",min:2,max:1e3}},value$:be(e,r,({worksheet:o})=>new x.Observable(s=>{function l(){var h;const d=(h=t.getCurrentLastSelection())==null?void 0:h.primary;let u=r;d!=null&&(u=o.getColumnWidth(d.startColumn)),s.next(u)}const c=i.onCommandExecuted(d=>{const u=d.id;if(u===m.SetRangeValuesMutation.id||u===m.SetSelectionsOperation.id||u===m.SetWorksheetColWidthMutation.id)return l()});return l(),c.dispose})),hidden$:$(n,{workbookTypes:[m.WorkbookEditablePermission],worksheetTypes:[m.WorksheetEditPermission,m.WorksheetSetColumnStylePermission],rangeTypes:[m.RangeProtectionPermissionEditPoint]})}}function Mr(n){var c;const i=n.get(a.IUniverInstanceService),e=n.get(Ee.DocSelectionManagerService),t=i.getUniverDocInstance(a.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),r=e.getActiveTextRange();if(t==null||r==null)return null;const o=(c=t.getBody())==null?void 0:c.textRuns;if(o==null)return;const{startOffset:s}=r;return o.find(({st:d,ed:u})=>s>=d&&s<=u)}var zg=Object.getOwnPropertyDescriptor,Xg=(n,i,e,t)=>{for(var r=t>1?void 0:t?zg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},xt=(n,i)=>(e,t)=>i(e,t,n);const Yg="__SpreadsheetFreezeRowMainName__",Gg="__SpreadsheetFreezeRowHeaderName__",Zg="__SpreadsheetFreezeColumnMainName__",Kg="__SpreadsheetFreezeColumnHeaderName__",oo=2,qg=.01,Fn=a.createInterceptorKey("freezePermissionCheck");exports.HeaderFreezeRenderController=class extends a.Disposable{constructor(e,t,r,o,s,l,c,d){super();E(this,"_rowFreezeHeaderRect");E(this,"_rowFreezeMainRect");E(this,"_columnFreezeHeaderRect");E(this,"_columnFreezeMainRect");E(this,"_freezeDownSubs");E(this,"_freezePointerEnterSubs");E(this,"_freezePointerLeaveSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_changeToRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToOffsetX",0);E(this,"_changeToOffsetY",0);E(this,"_activeViewport",null);E(this,"_freezeNormalHeaderColor","");E(this,"_freezeNormalMainColor","");E(this,"_freezeActiveColor","");E(this,"_freezeHoverColor","");E(this,"_lastFreeze");E(this,"interceptor",new a.InterceptorManager({FREEZE_PERMISSION_CHECK:Fn}));this._context=e,this._sheetSkeletonManagerService=t,this._commandService=r,this._selectionManagerService=o,this._scrollManagerService=s,this._themeService=l,this._sheetInterceptorService=c,this._injector=d,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener(),this._interceptorCommands(),this._bindViewportScroll(),this._zoomRefresh()}_createFreeze(e=0,t){var O;const r=t!=null?t:this._getFreeze();if(r==null)return null;const o=(O=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:O.skeleton,{startRow:s,startColumn:l}=r,c=this._getPositionByIndex(s,l);if(c==null||o==null)return null;const d=this._getSheetObject(),u=d.engine,h=(u==null?void 0:u.width)||0,g=(u==null?void 0:u.height)||0,S=d.scene,{startX:f,startY:p}=c,{rowTotalHeight:v,columnTotalWidth:C,rowHeaderWidthAndMarginLeft:I,columnHeaderHeightAndMarginTop:R}=o,w=h>C+I?h:C+R,M=g>v+R?g:v+R;this._changeToRow=s,this._changeToColumn=l,this._changeToOffsetX=f,this._changeToOffsetY=p;const y=Math.max(S.scaleX,S.scaleY);let P=oo/Math.max(1,y);if(e===0){(s===-1||s===0)&&(P=P*2);const k=P;this._rowFreezeHeaderRect=new T.Rect(Gg,{fill:this._freezeNormalHeaderColor,width:I,height:P,left:0,top:p-k,zIndex:3});let A=this._freezeNormalHeaderColor;(s===-1||s===0)&&(A=this._freezeNormalMainColor),this._rowFreezeMainRect=new T.Rect(Yg,{fill:A,width:w*2/y,height:P,left:I,top:p-k,zIndex:3}),S.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],Rt)}else{(l===-1||l===0)&&(P=P*2);const k=P;this._columnFreezeHeaderRect=new T.Rect(Kg,{fill:this._freezeNormalHeaderColor,width:P,height:R,left:f-k,top:0,zIndex:3});let A=this._freezeNormalHeaderColor;(l===-1||l===0)&&(A=this._freezeNormalMainColor),this._columnFreezeMainRect=new T.Rect(Zg,{fill:A,width:P,height:M*2/y,left:f-k,top:R,zIndex:3}),S.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],Rt)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,r=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,r=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:s}=o;if(this._freezePointerEnterSubs=new x.Subscription,this._freezePointerLeaveSubs=new x.Subscription,this._freezeDownSubs=new x.Subscription,r){const d=r.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=r.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}if(t){const d=t.onPointerEnter$.subscribeEvent(()=>{if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;t==null||t.setProps({fill:this._freezeHoverColor,zIndex:4}),s.setCursor(T.CURSOR_TYPE.GRAB)});this._freezePointerEnterSubs.add(d);const u=t.onPointerLeave$.subscribeEvent(()=>{t==null||t.setProps({fill:this._freezeNormalHeaderColor,zIndex:3}),s.resetCursor()});this._freezePointerLeaveSubs.add(u)}const l=t==null?void 0:t.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});l&&this._freezeDownSubs.add(l);const c=r==null?void 0:r.onPointerDown$.subscribeEvent(d=>{this._freezeDown(d,t,r,e)});c&&this._freezeDownSubs.add(c)}_getCurrentLastVisible(){var C,I,R,w,M,y,P;const e=this._getSheetObject();if(e==null)return;const t=(C=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:C.skeleton;if(t==null)return;const r=e.scene,o=Math.max(r.scaleX,r.scaleY),s=this._scrollManagerService.getCurrentScrollState(),l=(e.engine.height-t.columnHeaderHeight)/o,c=(e.engine.width-t.rowHeaderWidth)/o,d=(I=s==null?void 0:s.sheetViewStartRow)!=null?I:0,u=d===0?-((R=s==null?void 0:s.offsetY)!=null?R:0):t.rowHeightAccumulation[d-1]-((w=s==null?void 0:s.offsetY)!=null?w:0);let h=0,g=!1;for(let O=d,k=t.rowHeightAccumulation.length;O<k;O++)if(t.rowHeightAccumulation[O]-u>l){h=O,g=!0;break}g||(h=t.rowHeightAccumulation.length-1);const S=(M=s==null?void 0:s.sheetViewStartColumn)!=null?M:0,f=S===0?-((y=s==null?void 0:s.offsetX)!=null?y:0):t.columnWidthAccumulation[S-1]-((P=s==null?void 0:s.offsetX)!=null?P:0);let p=0,v=!1;for(let O=S,k=t.columnWidthAccumulation.length;O<k;O++)if(t.columnWidthAccumulation[O]-f>c){p=O,v=!0;break}return v||(p=t.columnWidthAccumulation.length-1),{lastRow:h,lastColumn:p}}_getActiveViewport(e){var r;const t=(r=this._getSheetObject())==null?void 0:r.scene.getViewports();return t&&t.find(o=>o.isHit(new T.Vector2(e.offsetX,e.offsetY)))||null}_freezeDown(e,t,r,o=0){var f;const s=(f=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:f.skeleton;if(s==null)return;const l=this._getSheetObject();if(l==null)return;if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;const{scene:d}=l;d.setCursor(T.CURSOR_TYPE.GRABBING),d.disableObjectsEvent();const u=this._getCurrentLastVisible(),h=u===void 0?Number.POSITIVE_INFINITY:s.rowHeightAccumulation[u.lastRow],g=u===void 0?Number.POSITIVE_INFINITY:s.columnWidthAccumulation[u.lastColumn-1]+s.rowHeaderWidth;this._activeViewport=null;const S=this._getFreeze();S&&(this._changeToColumn=S.startColumn,this._changeToRow=S.startRow),this._scenePointerMoveSub=d.onPointerMove$.subscribeEvent(p=>{var P,O,k,A;const v=this._getActiveViewport(p),{startX:C,startY:I,row:R,column:w}=Qe(p.offsetX,p.offsetY,d,s,v||void 0,!0);if(!this.interceptor.fetchThroughInterceptors(Fn)(!0,null))return!1;d.setCursor(T.CURSOR_TYPE.GRABBING);const y=oo/Math.max(d.scaleX,d.scaleY);o===0?((P=t.transformByState({top:Math.min(I,h)-y/2}))==null||P.setProps({fill:this._freezeActiveColor}),(O=r.transformByState({top:Math.min(I,h)-y/2}))==null||O.setProps({fill:this._freezeNormalHeaderColor}),this._changeToRow=u===void 0?R:Math.min(R,u.lastRow),this._changeToOffsetY=Math.min(I,h),this._activeViewport=v):((k=t.transformByState({left:Math.min(C,g)-y/2}))==null||k.setProps({fill:this._freezeActiveColor}),(A=r.transformByState({left:Math.min(C,g)-y/2}))==null||A.setProps({fill:this._freezeNormalHeaderColor}),this._changeToColumn=u===void 0?w:Math.min(w,u.lastColumn),this._changeToOffsetX=C,this._activeViewport=v)}),this._scenePointerUpSub=d.onPointerUp$.subscribeEvent(()=>{var N,H;d.resetCursor(),d.enableObjectsEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:p,columnHeaderHeightAndMarginTop:v}=s;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freezeNormalHeaderColor}),r.setProps({fill:this._freezeNormalMainColor})):(t==null||t.setProps({fill:this._freezeNormalHeaderColor}),r==null||r.setProps({fill:this._freezeNormalHeaderColor}));const C=oo/Math.max(d.scaleX,d.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:v-C}),r.transformByState({top:v-C})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:p-C}),r.transformByState({left:p-C}));const I=this._scrollManagerService.getCurrentScrollState()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:R,sheetViewStartColumn:w}=I;if(w==null||R==null)return;const M=this._context.unit,y=M.getActiveSheet();if(!y)return;const P=(N=y.getConfig())==null?void 0:N.freeze;let O=(P==null?void 0:P.xSplit)||0,k=(P==null?void 0:P.ySplit)||0;const A=(H=this._activeViewport)==null?void 0:H.viewportKey;o===0&&(!A||A===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP?k=this._changeToRow-(P.startRow-P.ySplit):k=this._changeToRow-R,k=k<0?0:k),o===1&&(!A||A===T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP||A===T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT||A===T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT?O=this._changeToColumn-(P.startColumn-P.xSplit):O=this._changeToColumn-w,O=O<0?0:O),this._commandService.executeCommand(m.SetFrozenCommand.id,{startRow:k===0?-1:this._changeToRow,startColumn:O===0?-1:this._changeToColumn,ySplit:k,xSplit:O,unitId:M.getUnitId(),subUnitId:y.getSheetId()})})}_getViewports(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e,r=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT),o=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT),s=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP),l=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM),c=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP),d=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),u=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP),h=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT),g=t.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(!(r==null||o==null||s==null||l==null||c==null||d==null||u==null||h==null||g==null))return{viewMain:d,viewMainLeftTop:u,viewMainLeft:h,viewMainTop:g,viewColumnLeft:r,viewColumnRight:o,viewRowTop:s,viewRowBottom:l,viewLeftTop:c}}_bindViewportScroll(){const e=this._getViewports();if(!e)return;const{viewRowBottom:t,viewColumnRight:r,viewMainLeft:o,viewMainTop:s}=e;this.disposeWithMe(this._scrollManagerService.validViewportScrollInfo$.subscribe(l=>{if(!l)return;const{scrollX:c,scrollY:d,viewportScrollX:u,viewportScrollY:h}=l;t.isActive&&t.updateScrollVal({scrollY:d,viewportScrollY:h}),r.isActive&&r.updateScrollVal({scrollX:c,viewportScrollX:u}),o.isActive&&o.updateScrollVal({scrollY:d,viewportScrollY:h}),s.isActive&&s.updateScrollVal({scrollX:c,viewportScrollX:u})}))}_updateViewport(e=-1,t=-1,r=0,o=0,s=3){var O;const l=(O=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:O.skeleton;if(l==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=l,u=this._getViewports();if(!u)return;const{viewMain:h,viewMainLeftTop:g,viewMainLeft:S,viewMainTop:f,viewColumnLeft:p,viewColumnRight:v,viewRowTop:C,viewRowBottom:I,viewLeftTop:R}=u;v.resizeWhenFreezeChange({left:c,top:0,height:d+1,right:0}),I.resizeWhenFreezeChange({left:0,top:d,bottom:0,width:c+1}),R.resizeWhenFreezeChange({left:0,top:0,width:c+1,height:d});let w=!0,M=!0;g.enable(),(e===-1||e===0)&&(w=!1),(t===-1||t===0)&&(M=!1);const y=l.getNoMergeCellWithCoordByIndex(e-r,t-o,!1),P=l.getNoMergeCellWithCoordByIndex(e,t,!1);if(g.disable(),f.disable(),S.disable(),C.disable(),p.disable(),g.resetPadding(),f.resetPadding(),S.resetPadding(),C.resetPadding(),p.resetPadding(),w===!1&&M===!1)h.resizeWhenFreezeChange({left:c,top:d,bottom:0,right:0}),h.resetPadding(),S.resizeWhenFreezeChange({left:c,top:d,bottom:0,width:0}),f.resizeWhenFreezeChange({left:c,top:d,height:0,right:0}),g.resizeWhenFreezeChange({left:c,top:d,width:0,height:0}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:0}),p.resizeWhenFreezeChange({left:0,top:0,height:d+1,width:0});else if(w===!0&&M===!1){const k=P.startY-y.startY;h.resizeWhenFreezeChange({left:c,top:d+k,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:0,endX:0}),s&2&&this._commandService.executeCommand(ze.id,{sheetViewStartRow:0,offsetY:0}),f.resizeWhenFreezeChange({left:c,top:d,height:k,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:k}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+k,bottom:0,width:c+1}),f.enable(),C.enable()}else if(w===!1&&M===!0){const k=P.startX-y.startX;h.resizeWhenFreezeChange({left:c+k,top:d,bottom:0,right:0}),h.setPadding({startX:y.startX,endX:P.startX,startY:0,endY:0}),s&1&&this._commandService.executeCommand(ze.id,{sheetViewStartColumn:0,offsetX:0}),S.resizeWhenFreezeChange({left:c,top:d,width:k,bottom:0,right:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),p.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),S.enable(),p.enable()}else{const k=P.startX-y.startX,A=P.startY-y.startY;h.resizeWhenFreezeChange({left:c+k,top:d+A,bottom:0,right:0}),h.setPadding({startY:y.startY,endY:P.startY,startX:y.startX,endX:P.startX}),s&&this._commandService.executeCommand(ze.id,{...s&1?{sheetViewStartColumn:0,offsetX:0}:null,...s&2?{sheetViewStartRow:0,offsetY:0}:null}),S.resizeWhenFreezeChange({left:c,top:d+A,width:k,bottom:0}),S.updateScrollVal({viewportScrollX:y.startX,rawScrollY:h.scrollY,viewportScrollY:h.viewportScrollY}),f.resizeWhenFreezeChange({left:c+k,top:d,height:A,right:0}),f.updateScrollVal({viewportScrollY:y.startY,rawScrollX:h.scrollX,viewportScrollX:h.viewportScrollX}),g.resizeWhenFreezeChange({left:c,top:d,width:k,height:A}),g.updateScrollVal({viewportScrollX:y.startX,viewportScrollY:y.startY}),C.resizeWhenFreezeChange({left:0,top:d,width:c+1,height:A}),C.updateScrollVal({viewportScrollY:y.startY}),I.resizeWhenFreezeChange({left:0,top:d+A,bottom:0,width:c+1}),p.resizeWhenFreezeChange({left:c,top:0,width:k,height:d+1}),p.updateScrollVal({viewportScrollX:y.startX}),v.resizeWhenFreezeChange({left:c+k,top:0,height:d+1,right:0}),g.enable(),f.enable(),S.enable(),C.enable(),p.enable()}}_skeletonListener(){this.disposeWithMe(a.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[m.SetWorksheetActiveOperation.id,m.InsertRangeMoveDownCommand.id,m.InsertRangeMoveRightCommand.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const t=this._context.unit.getActiveSheet();if(!t)return;const r=t.getConfig().freeze,{startRow:o=-1,startColumn:s=-1,ySplit:l=0,xSplit:c=0}=r;this._refreshFreeze(o,s,l,c,0)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()}))}_themeChange(e){this._freezeNormalHeaderColor=e.grey400,this._freezeNormalMainColor=new a.ColorKit(e.grey400).setAlpha(qg).toRgbString(),this._freezeActiveColor=e.primaryColor,this._freezeHoverColor=e.grey500}_interceptorCommands(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{const t={redos:[],undos:[]},r=this._getFreeze();if(!r)return t;const o=s=>{const l=this._context.unit,c=l.getUnitId(),d=l.getActiveSheet();if(!d)return t;const u=d.getSheetId();this._refreshFreeze(s.startRow,s.startColumn,s.ySplit,s.xSplit,0);const h={...s,unitId:c,subUnitId:u,resetScroll:!1},g=m.SetFrozenMutationFactory(this._injector,h);return{undos:[{id:m.SetFrozenMutation.id,params:g}],redos:[{id:m.SetFrozenMutation.id,params:h}]}};if(e.id===m.InsertRowCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endRow-l.startRow+1;if(l.startRow+1<r.startRow||l.startRow+1===r.startRow&&c===a.Direction.UP){const u={...r,startRow:Math.max(1,r.startRow+d),ySplit:Math.max(1,r.ySplit+d)};return o(u)}}if(e.id===m.InsertColCommand.id){const s=e.params,{range:l,direction:c}=s,d=l.endColumn-l.startColumn+1;if(l.startColumn+1<r.startColumn||l.startColumn+1===r.startColumn&&c===a.Direction.LEFT){const u={...r,startColumn:Math.max(1,r.startColumn+d),xSplit:Math.max(1,r.xSplit+d)};return o(u)}}if(e.id===m.MoveColsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startColumn:l},toRange:{startColumn:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.COLUMN&&C.range.startColumn<=l&&l<=C.range.endColumn);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startColumn:c,endColumn:c+u.endColumn-u.startColumn};if(!r||r.startColumn<=0||u.startColumn>=r.startColumn&&h.startColumn>=r.startColumn||u.startColumn===h.startColumn||u.endColumn<r.startColumn&&h.startColumn<r.startColumn)return t;const g=u.endColumn-u.startColumn+1,S=Math.max(Math.min(r.startColumn,u.endColumn+1)-u.startColumn,0);let f,p;h.startColumn>=r.startColumn?(f=Math.max(r.startColumn-S,1),p=Math.max(r.xSplit-S,1)):(f=r.startColumn+g-S,p=r.xSplit+g-S);const v={...r,startColumn:f,xSplit:p};return o(v)}if(e.id===m.MoveRowsCommand.id){const s=this._selectionManagerService.getCurrentSelections(),{fromRange:{startRow:l},toRange:{startRow:c}}=e.params,d=s==null?void 0:s.filter(C=>C.range.rangeType===a.RANGE_TYPE.ROW&&C.range.startRow<=l&&l<=C.range.endRow);if(!(d!=null&&d.length))return t;const u=d[0].range,h={...u,startRow:c,endRow:c+u.endRow-u.startRow};if(!r||r.startRow<=0||u.startRow>=r.startRow&&h.startRow>=r.startRow||u.startRow===h.startRow||u.endRow<r.startRow&&h.startRow<r.startRow)return t;const g=u.endRow-u.startRow+1,S=Math.max(Math.min(r.startRow,u.endRow+1)-u.startRow,0);let f,p;h.startRow>=r.startRow?(f=Math.max(r.startRow-S,1),p=Math.max(r.ySplit-S,1)):(f=r.startRow+g-S,p=r.ySplit+g-S);const v={...r,startRow:f,ySplit:p};return o(v)}if(e.id===m.RemoveColCommand.id||e.id===m.RemoveRowCommand.id){const s=e.params,l=s.range;if(l.rangeType===a.RANGE_TYPE.COLUMN&&l.startColumn<r.startColumn){const c=Math.min(r.startColumn,l.endColumn+1)-l.startColumn,d={...r,startColumn:Math.max(1,r.startColumn-c),xSplit:Math.max(1,r.xSplit-c)};return o(d)}if(s.range.rangeType===a.RANGE_TYPE.ROW&&l.startRow<r.startRow){const c=Math.min(r.startRow,l.endRow+1)-l.startRow,d={...r,startRow:Math.max(1,r.startRow-c),ySplit:Math.max(1,r.ySplit-c)};return o(d)}}return t}}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{switch(e.id){case m.SetFrozenMutation.id:case Le.id:{const t=this._lastFreeze,r=this._context.unit,o=r.getActiveSheet(),s=e.params,{unitId:l,subUnitId:c}=s;if(!(l===r.getUnitId()&&c===(o==null?void 0:o.getSheetId())))return;const d=o.getConfig().freeze;if(this._lastFreeze=d,d==null)return;let u=0;const{startRow:h=-1,startColumn:g=-1,ySplit:S=0,xSplit:f=0}=d;(!t||t.startRow!==h||t.ySplit!==S)&&(u|=2),(!t||t.startColumn!==g||t.xSplit!==f)&&(u|=1),s.resetScroll===!1&&(u=0),this._refreshFreeze(h,g,S,f,u)}break;case m.SetWorksheetRowHeightMutation.id:{const t=this._getFreeze(),r=t&&e.params.ranges.some(o=>o.startRow<t.startRow);e.params&&r&&this._refreshCurrent()}break;case m.SetWorksheetColWidthMutation.id:{const t=this._getFreeze();e.params&&t&&e.params.ranges.some(r=>r.startColumn<t.startColumn)&&this._refreshCurrent()}break;case m.SetWorksheetRowAutoHeightMutation.id:{const t=e.params,r=this._getFreeze();if(r&&r.startRow>-1&&t.rowsAutoHeightInfo.some(o=>o.row<r.startRow)){const o=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{o.unsubscribe()})})}}break;case m.SetColHiddenMutation.id:case m.SetColVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startColumn>-1&&o.some(s=>s.startColumn<r.startColumn)&&this._refreshCurrent()}break;case m.SetRowHiddenMutation.id:case m.SetRowVisibleMutation.id:{const t=e.params,r=this._getFreeze(),o=t.ranges;r&&r.startRow>-1&&o.some(s=>s.startRow<r.startRow)&&this._refreshCurrent()}break;case xi.id:case Ai.id:this._refreshCurrent()}}))}_zoomRefresh(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this.disposeWithMe(t.onTransformChange$.subscribeEvent(r=>{[T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale,T.TRANSFORM_CHANGE_OBSERVABLE_TYPE.all].includes(r.type)&&this._refreshCurrent()}))}_clearObserverEvent(){var t,r;this._getSheetObject()!=null&&((t=this._scenePointerMoveSub)==null||t.unsubscribe(),(r=this._scenePointerUpSub)==null||r.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_clearFreeze(){var t,r,o,s,l,c;(t=this._rowFreezeHeaderRect)==null||t.dispose(),(r=this._rowFreezeMainRect)==null||r.dispose(),(o=this._columnFreezeHeaderRect)==null||o.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose(),this._getSheetObject()!=null&&([this._freezeDownSubs,this._freezePointerEnterSubs,this._freezePointerLeaveSubs].forEach(d=>{d==null||d.unsubscribe()}),this._freezeDownSubs=null,this._freezePointerEnterSubs=null,this._freezePointerLeaveSubs=null,(l=this._scenePointerMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null)}_getPositionByIndex(e,t){var d;if(this._getSheetObject()==null)return;const o=(d=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:d.skeleton,s=o==null?void 0:o.getNoMergeCellWithCoordByIndex(e,t);if(o==null)return;if(s!=null&&(!isNaN(s.endX)||!isNaN(s.endY)))return s;const{rowHeaderWidthAndMarginLeft:l,columnHeaderHeightAndMarginTop:c}=o;return{startX:l,endX:l,startY:c,endY:c}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return Ge(this._context.unit,this._context)}_refreshFreeze(e,t,r,o,s){var c;const l={startRow:e,startColumn:t,ySplit:r,xSplit:o};this._clearFreeze(),this._createFreeze(0,l),this._createFreeze(1,l),this._updateViewport(e,t,r,o,s),(c=this._getSheetObject())==null||c.spreadsheet.makeForceDirty()}};exports.HeaderFreezeRenderController=Xg([xt(1,a.Inject(exports.SheetSkeletonManagerService)),xt(2,a.ICommandService),xt(3,a.Inject(m.SheetsSelectionsService)),xt(4,a.Inject(exports.SheetScrollManagerService)),xt(5,a.Inject(a.ThemeService)),xt(6,a.Inject(m.SheetInterceptorService)),xt(7,a.Inject(a.Injector))],exports.HeaderFreezeRenderController);function Qg(n){const i=n.get(m.SheetsSelectionsService),e=n.get(m.RangeProtectionRuleModel),t=n.get(a.IUniverInstanceService),r=n.get(m.MergeCellController),o=t.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET);return x.combineLatest([i.selectionMoveEnd$,o.pipe(x.map(s=>{var l;return(l=s==null?void 0:s.getUnitId())!=null?l:""})),o.pipe(x.switchMap(s=>{var l;return(l=s==null?void 0:s.activeSheet$)!=null?l:x.of(null)}))]).pipe(x.map(([s,l,c])=>{if(!c||!s||s.length===0)return!1;const d=c.getSheetId(),u=s.map(S=>S.range);if(r.interceptor.fetchThroughInterceptors(m.MERGE_CELL_INTERCEPTOR_CHECK)(!1,u))return!0;const g=e.getSubunitRuleList(l,d).map(S=>S.ranges).flat();if(s.length<2){const S=s[0].range;return g.some(p=>a.Rectangle.intersects(p,S)&&!a.Rectangle.contains(p,S))}for(let S=0;S<s.length;S++)for(let f=S+1;f<s.length;f++)if(a.Rectangle.intersects(s[S].range,s[f].range))return!0;return!1}))}function Fl(n,i){return!!or(n,i,a.RANGE_TYPE.ROW)}function jl(n,i){return!!or(n,i,a.RANGE_TYPE.COLUMN)}function or(n,i,e){return n.find(r=>{const o=r.range,{startRow:s,endRow:l,startColumn:c,endColumn:d,rangeType:u}=o;return u===a.RANGE_TYPE.ALL||u===a.RANGE_TYPE.NORMAL?!1:u===e&&(e===a.RANGE_TYPE.COLUMN&&c<=i&&i<=d||e===a.RANGE_TYPE.ROW&&s<=i&&i<=l)})}var Jg=Object.getOwnPropertyDescriptor,$g=(n,i,e,t)=>{for(var r=t>1?void 0:t?Jg(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},so=(n,i)=>(e,t)=>i(e,t,n);const eS="__SpreadsheetHeaderMoveControllerBackground__",tS="__SpreadsheetHeaderMoveControllerShapeLine__",nS="rgba(0, 0, 0, 0.1)",rS="rgb(119, 119, 119)",iS=4,ao=a.createInterceptorKey("headerMovePermissionCheck");exports.HeaderMoveRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_startOffsetX",Number.NEGATIVE_INFINITY);E(this,"_startOffsetY",Number.NEGATIVE_INFINITY);E(this,"_moveHelperBackgroundShape");E(this,"_moveHelperLineShape");E(this,"_headerPointerDownSubs");E(this,"_headerPointerMoveSubs");E(this,"_headerPointerLeaveSubs");E(this,"_dragHeaderMoveSub");E(this,"_scenePointerUpSub");E(this,"_scrollTimer");E(this,"_changeFromColumn",-1);E(this,"_changeFromRow",-1);E(this,"_changeToColumn",-1);E(this,"_changeToRow",-1);E(this,"interceptor",new a.InterceptorManager({HEADER_MOVE_PERMISSION_CHECK:ao}));E(this,"_workbookSelections");this._context=e,this._sheetSkeletonManagerService=r,this._commandService=o,this._workbookSelections=t.getWorkbookSelections(this._context.unitId),this._init()}dispose(){var e,t,r,o,s,l,c,d;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose(),(r=this._headerPointerMoveSubs)==null||r.unsubscribe(),(o=this._headerPointerLeaveSubs)==null||o.unsubscribe(),(s=this._headerPointerDownSubs)==null||s.unsubscribe(),this._headerPointerMoveSubs=null,this._headerPointerLeaveSubs=null,this._headerPointerDownSubs=null,(l=this._dragHeaderMoveSub)==null||l.unsubscribe(),(c=this._scenePointerUpSub)==null||c.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null,(d=this._scrollTimer)==null||d.dispose()}_init(){this._initialRowOrColumn(a.RANGE_TYPE.ROW),this._initialRowOrColumn(a.RANGE_TYPE.COLUMN)}_initialRowOrColumn(e=a.RANGE_TYPE.ROW){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===a.RANGE_TYPE.ROW?r:t,l=u=>{var I,R;const h=(I=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:I.skeleton;if(h==null)return;const g=(R=this._workbookSelections.getCurrentLastSelection())==null?void 0:R.range;if(!g||!this.interceptor.fetchThroughInterceptors(ao)(!1,g))return;const f=this._workbookSelections.getCurrentSelections(),{row:p,column:v}=Qe(u.offsetX,u.offsetY,o,h);if(!or(f,e===a.RANGE_TYPE.ROW?p:v,e)){o.resetCursor();return}o.setCursor(T.CURSOR_TYPE.GRAB)},c=()=>{var u,h;(u=this._moveHelperBackgroundShape)==null||u.hide(),(h=this._moveHelperLineShape)==null||h.hide(),o.resetCursor()},d=(u,h)=>{var W,D;if(h.isStopPropagation)return;const g=(W=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:W.skeleton;if(g==null)return;const S=(D=this._workbookSelections.getCurrentLastSelection())==null?void 0:D.range;if(!S||!this.interceptor.fetchThroughInterceptors(ao)(!1,S))return;const{offsetX:p,offsetY:v}=u,C=o.getCoordRelativeToViewport(T.Vector2.FromArray([p,v])),{x:I,y:R}=C;this._startOffsetX=I,this._startOffsetY=R;const{row:w,column:M}=Qe(u.offsetX,u.offsetY,o,g);let y;e===a.RANGE_TYPE.ROW?(this._changeFromRow=w,y=T.ScrollTimerType.Y):(this._changeFromColumn=M,y=T.ScrollTimerType.X);const P=this._workbookSelections.getCurrentSelections(),O=or(P,e===a.RANGE_TYPE.ROW?w:M,e);if(!O)return;const k=o.getScrollXYInfoByViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY]));this._newBackgroundAndLine(),o.setCursor(T.CURSOR_TYPE.GRABBING),o.disableObjectsEvent();let A=!1,N;const H=()=>{if(A)return;N=T.ScrollTimer.create(o,y),this._scrollTimer=N;const U=o.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);N.startScroll(I,R,U),A=!0};this._dragHeaderMoveSub=o.onPointerMove$.subscribeEvent(U=>{H();const{offsetX:L,offsetY:F}=U,{x:B,y:z}=o.getCoordRelativeToViewport(T.Vector2.FromArray([L,F]));this._rowColumnMoving(B,z,O,k,e),N.scrolling(B,z,()=>{this._rowColumnMoving(B,z,O,k,e)})}),this._scenePointerUpSub=o.onPointerUp$.subscribeEvent(()=>{var L,F,B;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableObjectsEvent(),this._clearObserverEvent(),(L=this._scrollTimer)==null||L.dispose();const U=this._workbookSelections.getCurrentSelections();if(e===a.RANGE_TYPE.ROW){if(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1){const j=(F=((U==null?void 0:U.filter(G=>G.range.rangeType===a.RANGE_TYPE.ROW&&G.range.startRow<=this._changeFromRow&&this._changeFromRow<=G.range.endRow))||[])[0])==null?void 0:F.range;j&&this._commandService.executeCommand(m.MoveRowsCommand.id,{fromRange:j,toRange:{...j,startRow:this._changeToRow,endRow:this._changeToRow+j.endRow-j.startRow}})}this._changeToRow=this._changeFromRow=-1}else{if(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1){const j=(B=((U==null?void 0:U.filter(G=>G.range.rangeType===a.RANGE_TYPE.COLUMN&&G.range.startColumn<=this._changeFromColumn&&this._changeFromColumn<=G.range.endColumn))||[])[0])==null?void 0:B.range;j&&this._commandService.executeCommand(m.MoveColsCommand.id,{fromRange:j,toRange:{...j,startColumn:this._changeToColumn,endColumn:this._changeToColumn+j.endColumn-j.startColumn}})}this._changeToColumn=this._changeFromColumn=-1}})};this._headerPointerMoveSubs=new x.Subscription,this._headerPointerMoveSubs.add(s.onPointerMove$.subscribeEvent(l)),this._headerPointerLeaveSubs=new x.Subscription,this._headerPointerLeaveSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(c)),this._headerPointerDownSubs=new x.Subscription,this._headerPointerDownSubs.add(s==null?void 0:s.onPointerDown$.subscribeEvent(d))}_rowColumnMoving(e,t,r,o,s){var z,j,G,ee,q,se,ce;const l=this._context.scene,c=(z=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:z.skeleton;if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u,rowTotalHeight:h,columnTotalWidth:g}=c,S=l.getViewportScrollXY(l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN)),{scaleX:f,scaleY:p}=l.getAncestorScale(),v=c.getCellIndexByOffset(e,t,f,p,S),{row:C,column:I}=v,R=c.getNoMergeCellWithCoordByIndex(C,I),{startX:w,startY:M,endX:y,endY:P}=R,O=this._sheetSkeletonManagerService.attachRangeWithCoord(r.range);if(O==null)return;const k=Math.max(f,f),{startX:A,endX:N,startY:H,endY:W,startRow:D,startColumn:U,endRow:L,endColumn:F}=O;s===a.RANGE_TYPE.ROW?(j=this._moveHelperBackgroundShape)==null||j.transformByState({height:W-H,width:g+d,left:0,top:H+(t-this._startOffsetY)/k+S.y-o.y}):(G=this._moveHelperBackgroundShape)==null||G.transformByState({height:h+u,width:N-A,left:A+(e-this._startOffsetX)/k+S.x-o.x,top:0}),(ee=this._moveHelperBackgroundShape)==null||ee.show();const B=iS/k;if(s===a.RANGE_TYPE.ROW){let X=0;if(C<=D)X=M-B/2,this._changeToRow=C;else if(C>L)X=P-B/2,this._changeToRow=C+1;else return;(q=this._moveHelperLineShape)==null||q.transformByState({height:B,width:g,left:d,top:X})}else{let X=0;if(I<=U)X=w-B/2,this._changeToColumn=I;else if(I>F)X=y-B/2,this._changeToColumn=I+1;else return;(se=this._moveHelperLineShape)==null||se.transformByState({height:h,width:B,left:X,top:u})}(ce=this._moveHelperLineShape)==null||ce.show()}_clearObserverEvent(){var e,t;(e=this._dragHeaderMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._dragHeaderMoveSub=null,this._scenePointerUpSub=null}_newBackgroundAndLine(){const e=this._context.scene;this._moveHelperBackgroundShape=new T.Rect(eS,{fill:nS,evented:!1,zIndex:100}),this._moveHelperLineShape=new T.Rect(tS,{fill:rS,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],Rt)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}};exports.HeaderMoveRenderController=$g([so(1,a.Inject(m.SheetsSelectionsService)),so(2,a.Inject(exports.SheetSkeletonManagerService)),so(3,a.ICommandService)],exports.HeaderMoveRenderController);var Zo=(n=>(n[n.VERTICAL=0]="VERTICAL",n[n.HORIZONTAL=1]="HORIZONTAL",n))(Zo||{});const oS="rgba(120, 120, 120, 0.01)",lo="rgb(68, 71, 70)",Kn=12,sS=44,Ko=4;class Ra extends T.Shape{constructor(e,t){super(e,t);E(this,"_size",Kn);E(this,"_color",lo);E(this,"_mode",0);this.setShapeProps(t)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(e){const t=this.getScene();if(!t)return;const{scaleX:r,scaleY:o}=t.getAncestorScale(),s=Math.max(r,o),l=Kn/s,c=Ko/s;let{width:d,height:u}=this,h=0,g=0;this.mode===0?(d=c,h=l-c):(u=c,g=l-c),T.Rect.drawWith(e,{width:this.width,height:this.height,left:0,top:0,fill:oS}),T.Rect.drawWith(e,{width:d,height:u,fill:lo,radius:c}),e.save(),e.transform(1,0,0,1,h,g),T.Rect.drawWith(e,{width:d,height:u,fill:lo,radius:c}),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:Kn,height:this.size}):this.transformByState({width:this.size,height:Kn}),this}}var aS=Object.getOwnPropertyDescriptor,lS=(n,i,e,t)=>{for(var r=t>1?void 0:t?aS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},co=(n,i)=>(e,t)=>i(e,t,n);const cS="__SpreadsheetHeaderResizeControllerShapeRow__",dS="__SpreadsheetHeaderResizeControllerShapeColumn__",Ea="__SpreadsheetHeaderResizeControllerShapeHelper__",wa="rgb(199, 199, 199)",uS=2,uo=a.createInterceptorKey("headerResizePermissionCheck");exports.HeaderResizeRenderController=class extends a.Disposable{constructor(e,t,r,o){super();E(this,"_currentRow",0);E(this,"_currentColumn",0);E(this,"_rowResizeRect");E(this,"_columnResizeRect");E(this,"_headerPointerSubs");E(this,"_scenePointerMoveSub");E(this,"_scenePointerUpSub");E(this,"_resizeHelperShape");E(this,"_startOffsetX",Number.POSITIVE_INFINITY);E(this,"_startOffsetY",Number.POSITIVE_INFINITY);E(this,"interceptor",new a.InterceptorManager({HEADER_RESIZE_PERMISSION_CHECK:uo}));this._context=e,this._sheetSkeletonManagerService=t,this._selectionManagerService=r,this._commandService=o,this._init()}dispose(){var e,t,r;(e=this._rowResizeRect)==null||e.dispose(),this._rowResizeRect=null,(t=this._columnResizeRect)==null||t.dispose(),this._columnResizeRect=null,(r=this._headerPointerSubs)==null||r.unsubscribe(),this._headerPointerSubs=null}_init(){const e=this._context.scene;this._rowResizeRect=new Ra(cS,{visible:!1,mode:Zo.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Ra(dS,{visible:!1,mode:Zo.VERTICAL,zIndex:100}),e.addObjects([this._rowResizeRect,this._columnResizeRect],Rt),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._context.components.get(he.COLUMN),r=this._context.components.get(he.ROW),o=this._context.scene,s=e===0?r:t,l=(d,u)=>{var h,g;(h=this._rowResizeRect)==null||h.hide(),(g=this._columnResizeRect)==null||g.hide()},c=(d,u)=>{var k;const h=(k=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:k.skeleton;if(h==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:g,columnHeaderHeight:S}=h,{startX:f,startY:p,endX:v,endY:C,row:I,column:R}=Qe(d.offsetX,d.offsetY,o,h),w=Jn(d.offsetX,d.offsetY,o),{scaleX:M,scaleY:y}=o.getAncestorScale(),P=Math.max(M,y),O=Kn/P;if(e===0){let A=p-O/2;if(w.y<=p+O/2&&w.y>=p)this._currentRow=I-1;else if(w.y>=C-O/2&&w.y<=C)this._currentRow=I,A=C-O/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;if(!this.interceptor.fetchThroughInterceptors(uo)(null,{row:this._currentRow}))return!1;const H=Math.min(sS,g/3);this._rowResizeRect.transformByState({left:g/2-H/2,top:A}),this._rowResizeRect.setShapeProps({size:H}),this._rowResizeRect.show()}else{let A=f-O/2;if(w.x<=f+O/2&&w.x>=f)this._currentColumn=R-1;else if(w.x>=v-O/2&&w.x<=v)this._currentColumn=R,A=v-O/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;if(!this.interceptor.fetchThroughInterceptors(uo)(null,{col:this._currentColumn}))return!1;const H=S*.7;this._columnResizeRect.transformByState({left:A,top:S/2-H/2}),this._columnResizeRect.setShapeProps({size:H}),this._columnResizeRect.show()}};this._headerPointerSubs=new x.Subscription,this._headerPointerSubs.add(s==null?void 0:s.onPointerMove$.subscribeEvent(c)),this._headerPointerSubs.add(s==null?void 0:s.onPointerLeave$.subscribeEvent(l))}_initialHoverResize(e=0){const t=this._context.scene,r=e===0?this._rowResizeRect:this._columnResizeRect;r!=null&&(this.disposeWithMe(r.onPointerEnter$.subscribeEvent(()=>{r!=null&&(r.show(),t.setCursor(e===0?T.CURSOR_TYPE.ROW_RESIZE:T.CURSOR_TYPE.COLUMN_RESIZE))})),this.disposeWithMe(r.onPointerLeave$.subscribeEvent(()=>{r!=null&&(r.hide(),t.resetCursor())})),this.disposeWithMe(r.onPointerDown$.subscribeEvent(o=>{var F,B,z,j,G,ee,q;const s=(F=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:F.skeleton;if(s==null)return;const l=this._context.scene,c=l.getEngine(),d=(c==null?void 0:c.height)||0,u=(c==null?void 0:c.width)||0,h=l.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=(((z=(B=h==null?void 0:h.getScrollBar())==null?void 0:B.horizonScrollTrack)==null?void 0:z.height)||0)+10,S=(((G=(j=h==null?void 0:h.getScrollBar())==null?void 0:j.verticalScrollTrack)==null?void 0:G.width)||0)+10,f=Jn(o.offsetX,o.offsetY,l),{scaleX:p,scaleY:v}=l.getAncestorScale();this._startOffsetX=f.x,this._startOffsetY=f.y;const C=s.getOffsetByColumn(this._currentColumn),I=s.getOffsetByRow(this._currentRow),R=s.getNoMergeCellWithCoordByIndex(this._currentRow,this._currentColumn);let w=!1,M=0,y=0;const{columnTotalWidth:P,rowHeaderWidth:O,rowTotalHeight:k,columnHeaderHeight:A}=s,N=u>P+O?u:P+O,H=d>k+A?d:k+A,W=Math.max(p,v),D=Ko/W;e===0?this._resizeHelperShape=new T.Rect(Ea,{width:N,height:D,fill:wa,left:0,top:I-D/2}):this._resizeHelperShape=new T.Rect(Ea,{width:D,height:H,fill:wa,left:C-D/2,top:0});const U=((ee=this._columnResizeRect)==null?void 0:ee.left)||0,L=((q=this._rowResizeRect)==null?void 0:q.top)||0;l.addObject(this._resizeHelperShape,Rt),l.disableObjectsEvent(),this._scenePointerMoveSub=l.onPointerMove$.subscribeEvent(se=>{var fe,Te,Re,Fe,St,ft;const ce=l.getCoordRelativeToViewport(T.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),X=l.getScrollXYInfoByViewport(ce,h),Z=Jn(se.offsetX,se.offsetY,l),{x:Q,y:re}=Z,{scaleX:ie,scaleY:ae}=l.getAncestorScale(),oe=Math.max(ie,ae),ne=Ko/oe;M=Q-this._startOffsetX-ne/2,y=re-this._startOffsetY-ne/2,Math.abs(e===0?y:M)>=uS&&(w=!0),e===0?(y>d-g+X.y-R.startY&&(y=d-g+X.y-R.startY),y<-(R.endY-R.startY)+2&&(y=-(R.endY-R.startY)+2),w&&((fe=this._resizeHelperShape)==null||fe.transformByState({top:I+y}),(Te=this._rowResizeRect)==null||Te.transformByState({top:L+y+ne/2}),(Re=this._rowResizeRect)==null||Re.show(),l.setCursor(T.CURSOR_TYPE.ROW_RESIZE))):(M>u-S+X.x-R.startX&&(M=u-S+X.x-R.startX),M<-(R.endX-R.startX)+2&&(M=-(R.endX-R.startX)+2),w&&((Fe=this._resizeHelperShape)==null||Fe.transformByState({left:C+M}),(St=this._columnResizeRect)==null||St.transformByState({left:U+M+ne/2}),(ft=this._columnResizeRect)==null||ft.show(),l.setCursor(T.CURSOR_TYPE.COLUMN_RESIZE)))}),this._scenePointerUpSub=l.onPointerUp$.subscribeEvent(se=>{var X,Z,Q;const ce=this._context.scene;this._clearObserverEvent(),(X=this._resizeHelperShape)==null||X.dispose(),this._resizeHelperShape=null,ce.enableObjectsEvent(),w&&(ce.resetCursor(),(Z=this._rowResizeRect)==null||Z.hide(),(Q=this._columnResizeRect)==null||Q.hide(),e===0?this._commandService.executeCommand(m.DeltaRowHeightCommand.id,{deltaY:y,anchorRow:this._currentRow}):this._commandService.executeCommand(m.DeltaColumnWidthCommand.id,{deltaX:M,anchorCol:this._currentColumn}))})})),this.disposeWithMe(r.onDblclick$.subscribeEvent(()=>{var h,g,S;this._context.scene.resetCursor();const s=(h=this._sheetSkeletonManagerService.getCurrentParam())==null?void 0:h.skeleton;if(!s)return;const l=0,c=0,d=s.worksheet.getRowCount()-1||0,u=s.worksheet.getColumnCount()-1||0;switch(e){case 1:{const f=this._selectionManagerService.getCurrentSelections(),p=[];for(let v=0;v<f.length;v++){const C=f[v];C.range.rangeType===a.RANGE_TYPE.COLUMN&&this._currentColumn<=C.range.endColumn&&this._currentColumn>=C.range.startColumn&&p.push({startColumn:C.range.startColumn,endColumn:C.range.endColumn,startRow:l,endRow:d})}p.length===0&&p.push({startColumn:this._currentColumn,endColumn:this._currentColumn,startRow:l,endRow:d}),this._commandService.executeCommand(wr.id,{ranges:p}),(g=this._columnResizeRect)==null||g.hide();break}case 0:this._commandService.executeCommand(m.SetWorksheetRowIsAutoHeightCommand.id,{ranges:[{startRow:this._currentRow,endRow:this._currentRow,startColumn:c,endColumn:u}]}),(S=this._rowResizeRect)==null||S.hide();break}})))}_clearObserverEvent(){var e,t;(e=this._scenePointerMoveSub)==null||e.unsubscribe(),(t=this._scenePointerUpSub)==null||t.unsubscribe(),this._scenePointerMoveSub=null,this._scenePointerUpSub=null}};exports.HeaderResizeRenderController=lS([co(1,a.Inject(exports.SheetSkeletonManagerService)),co(2,a.Inject(m.SheetsSelectionsService)),co(3,a.ICommandService)],exports.HeaderResizeRenderController);var hS=Object.getOwnPropertyDescriptor,mS=(n,i,e,t)=>{for(var r=t>1?void 0:t?hS(i,e):i,o=n.length-1,s;o>=0;o--)(s=n[o])&&(r=s(r)||r);return r},jn=(n,i)=>(e,t)=>i(e,t,n);const gS=60;exports.SheetRenderController=class extends a.RxDisposable{constructor(e,t,r,o,s,l){super();E(this,"_renderMetric$",new x.Subject);E(this,"renderMetric$",this._renderMetric$.asObservable());E(this,"_renderFrameTimeMetric",null);E(this,"_renderFrameTags",{});E(this,"_afterRenderMetric$",new x.Subject);this._context=e,this._configService=t,this._sheetSkeletonManagerService=r,this._sheetRenderService=o,this._commandService=s,this._telemetryService=l,this._addNewRender(),this._initRenderMetricSubscriber()}_addNewRender(){const{scene:e,engine:t,unit:r}=this._context;this._addComponent(r),this._initRerenderScheduler(),this._initCommandListener();const o=this._context.unit.getActiveSheet();if(!o)throw new Error("No active sheet found");const s=o.getSheetId();this._sheetSkeletonManagerService.setCurrent({sheetId:s});const l=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(c=>{c?t.runRenderLoop(l):t.stopRenderLoop(l)}))}_initRenderMetricSubscriber(){const{engine:e}=this._context;e.beginFrame$.subscribe(()=>{this._renderFrameTimeMetric=null,this._renderFrameTags={}}),e.endFrame$.subscribe(()=>{this._renderFrameTimeMetric&&Object.keys(this._renderFrameTimeMetric).filter(o=>o.startsWith(T.SHEET_EXTENSION_PREFIX)).length>0&&this._afterRenderMetric$.next({frameTimeMetric:this._renderFrameTimeMetric,tags:this._renderFrameTags})}),e.renderFrameTimeMetric$.subscribe(([r,o])=>{this._renderFrameTimeMetric||(this._renderFrameTimeMetric={}),this._renderFrameTimeMetric[r]||(this._renderFrameTimeMetric[r]=[]),this._renderFrameTimeMetric[r].push(Math.round(o*100)/100)}),e.renderFrameTags$.subscribe(([r,o])=>{this._renderFrameTags[r]=o});const t=[];this._afterRenderMetric$.pipe(x.withLatestFrom(e.endFrame$)).subscribe(([r,o])=>{t.push({FPS:o.FPS,elapsedTime:o.elapsedTime,frameTime:Math.round(o.frameTime*100)/100,...r.frameTimeMetric,...r.tags}),t.length>gS&&(this._captureRenderMetric(t),t.length=0)})}_captureRenderMetric(e){var g;const t=e;if(t.length===0)return;const r=S=>{let f=0;const v=Object.entries(S).filter(([I,R])=>Array.isArray(R)).map(([I])=>I).reduce((I,R)=>{const w=S[R].reduce((M,y)=>M+y,0);return I[R]=w,I},{});return Object.keys(S).filter(I=>I.startsWith(T.SHEET_EXTENSION_PREFIX)).forEach(I=>{f+=v[I]}),{...v,extensionTotal:f}},o=e.map(S=>({...S,...r(S)})),l=(S=>Object.entries(S[0]).filter(([v,C])=>!["elapsedTime"].includes(v)).filter(([v,C])=>typeof C=="number").map(([v])=>v).reduce((v,C)=>{const I=S.map(y=>y[C]),R=Math.max(...I),w=Math.min(...I),M=I.reduce((y,P)=>y+P,0)/I.length;return v[C]={max:Math.round(R*100)/100,min:Math.round(w*100)/100,avg:Math.round(M*100)/100},v},{}))(o),c=t[t.length-1].elapsedTime,d=this._context.unit.getActiveSheet().getSheetId(),u=this._context.unit.getUnitId(),h={sheetId:d,unitId:u,elapsedTimeToStart:c,...l};this._renderMetric$.next(h),(g=this._telemetryService)==null||g.capture("sheet_render_cost",h)}_addComponent(e){const{scene:t,components:r}=this._context,o=e.getActiveSheet(),s=new T.Spreadsheet(he.MAIN);this._addViewport(o);const l=new T.SpreadsheetRowHeader(he.ROW),c=new T.SpreadsheetColumnHeader(he.COLUMN),d=new T.Rect(he.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});this._context.mainComponent=s,r.set(he.MAIN,s),r.set(he.ROW,l),r.set(he.COLUMN,c),r.set(he.LEFT_TOP,d),t.addObjects([s],Fs),t.addObjects([l,c,d],Rt),t.enableLayerCache(Fs,Rt)}_initViewports(e,t,r){const l=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN,e,{left:t.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0,allowCache:!0,bufferEdgeX:100,bufferEdgeY:100}),c=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:0}),d=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:0,bufferEdgeY:100}),u=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP,e,{isWheelPreventDefaultX:!0,active:!1,allowCache:!0,bufferEdgeX:100,bufferEdgeY:0}),h=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_TOP,e,{active:!1,isWheelPreventDefaultX:!0}),g=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_ROW_BOTTOM,e,{left:0,top:r.height,bottom:0,width:t.width+1,isWheelPreventDefaultX:!0}),S=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_LEFT,e,{active:!1,isWheelPreventDefaultX:!0}),f=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_COLUMN_RIGHT,e,{left:t.width,top:0,height:r.height+1,right:0,isWheelPreventDefaultX:!0}),p=new T.Viewport(T.SHEET_VIEWPORT_KEY.VIEW_LEFT_TOP,e,{left:0,top:0,width:t.width,height:r.height,isWheelPreventDefaultX:!0});return{viewMain:l,viewLeftTop:p,viewMainLeftTop:c,viewMainLeft:d,viewMainTop:u,viewColumnLeft:S,viewRowTop:h,viewRowBottom:g,viewColumnRight:f}}_addViewport(e){const t=this._context.scene,{rowHeader:r,columnHeader:o}=e.getConfig(),{viewMain:s}=this._initViewports(t,r,o),l=this._configService.getConfig(qe),c=l==null?void 0:l.scrollConfig;return new T.ScrollBar(s,c),t.attachControl(),s}_initRerenderScheduler(){this.disposeWithMe(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e)return null;const{skeleton:t,sheetId:r}=e,o=this._context.unit,s=o==null?void 0:o.getSheetBySheetId(r);if(o==null||s==null)return;const{mainComponent:l,components:c}=this._context,d=l,u=c.get(he.ROW),h=c.get(he.COLUMN),g=c.get(he.LEFT_TOP),{rowHeaderWidth:S,columnHeaderHeight:f}=t;d==null||d.updateSkeleton(t),u==null||u.updateSkeleton(t),h==null||h.updateSkeleton(t),g==null||g.transformByState({width:S,height:f})}))}_initCommandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{const{unit:t}=this._context,{id:r}=e;if(m.COMMAND_LISTENER_SKELETON_CHANGE.includes(r)||this._sheetRenderService.checkMutationShouldTriggerRerender(r)){const o=e.params,{unitId:s,subUnitId:l}=o,c=t.getActiveSheet();if(!c)return;const d=this._context.unitId,u=c.getSheetId();if(s!==d||l!==u)return;this._sheetSkeletonManagerService.makeDirty({sheetId:u,commandId:r},!0),this._sheetSkeletonManagerService.setCurrent({sheetId:u,commandId:r})}else m.COMMAND_LISTENER_VALUE_CHANGE.includes(r)&&this._sheetSkeletonManagerService.reCalculate();e.type===a.CommandType.MUTATION&&this._markUnitDirty(e)}))}_markUnitDirty(e){const{mainComponent:t,scene:r}=this._context;if(e.id===K.SetFormulaCalculationNotificationMutation.id&&e.params.stageInfo!=null||(t&&t.makeDirty(),r.makeDirty(),!e.params))return;const o=e.params,s=this._spreadsheetViewports(r);if(e.id===m.SetRangeValuesMutation.id&&o.cellValue){const l=this._cellValueToRange(o.cellValue),c=this._rangeToBounds([l]);this._markViewportDirty(s,c),t.setDirtyArea(c)}if(e.id===m.MoveRangeMutation.id&&o.from&&o.to){const l=o.fromRange||this._cellValueToRange(o.from.value),c=o.toRange||this._cellValueToRange(o.to.value),d=this._rangeToBounds([l,c]);this._markViewportDirty(s,d),t.setDirtyArea(d)}}_cellValueToRange(e){let t=0,r=0,o=0,s=0;for(const[h,g]of Object.entries(e)){for(const S in g)t>Number(S)&&(t=Number(S)),r<Number(S)&&(r=Number(S));o>Number(h)&&(o=Number(h)),s<Number(h)&&(s=Number(h))}return{startRow:o,endRow:s,startColumn:t,endColumn:r}}_rangeToBounds(e){const t=this._sheetSkeletonManagerService.getCurrentParam().skeleton,{rowHeightAccumulation:r,columnWidthAccumulation:o,rowHeaderWidth:s,columnHeaderHeight:l}=t,c=[];for(const d of e){const{startRow:u,endRow:h,startColumn:g,endColumn:S}=d,f=u===0?0:r[u-1]+l,p=r[h]+l,v=g===0?0:o[g-1]+s,C=o[S]+s;c.push({top:f,left:v,bottom:p,right:C,width:C-v,height:p-f})}return c}_markViewportDirty(e,t){const r=e.filter(o=>o.isActive&&o.cacheBound);for(const o of r)for(const s of t)a.Rectangle.hasIntersectionBetweenTwoRect(o.cacheBound,s)&&o.markDirty(!0)}_spreadsheetViewports(e){return e.getViewports().filter(t=>["viewMain","viewMainLeftTop","viewMainTop","viewMainLeft"].includes(t.viewportKey))}};exports.SheetRenderController=mS([jn(1,a.Inject(a.IConfigService)),jn(2,a.Inject(exports.SheetSkeletonManagerService)),jn(3,a.Inject(exports.SheetsRenderService)),jn(4,a.ICommandService),jn(5,a.Optional(gd.ITelemetryService))],exports.SheetRenderController);function SS(n,i){if(n.length!==i.length)return!1;const e=n.sort((r,o)=>r.id.localeCompare(o.id)),t=i.sort((r,o)=>r.id.localeCompare(o.id));return e.every((r,o)=>{var s,l;return((s=r.subject)==null?void 0:s.userID)===((l=t[o].subject)==null?void 0:l.userID)&&r.role===t[o].role})}function zl(n,i){return i.some(e=>fS(n,e))}function fS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r);let l=!1;return s.forValue((c,d,u)=>{if(u&&(c!==e||d!==t)&&n.cellHasValue(u))return l=!0,!1}),l}function Xl(n,i,e,t){const r=[],o=[],s=e.getSheetId();return t.forEach(l=>{const c=pS(e,l),d={unitId:i,subUnitId:s,cellValue:c.getData()},u=m.SetRangeValuesUndoMutationFactory(n,d);r.push({id:m.SetRangeValuesMutation.id,params:u}),o.push({id:m.SetRangeValuesMutation.id,params:d})}),{undos:r,redos:o}}function pS(n,i){const{startRow:e,startColumn:t,endColumn:r,endRow:o}=i,s=n.getMatrixWithMergedCells(e,t,o,r,a.CellModeEnum.Raw),l=new a.ObjectMatrix;let c=null;return s.forValue((d,u,h)=>{var g,S,f,p;h&&d>=e&&u>=t&&(!c&&n.cellHasValue(h)&&(h.v!==""||((p=(f=(S=(g=h.p)==null?void 0:g.body)==null?void 0:S.dataStream)==null?void 0:f.length)!=null?p:0)>2)&&(c=h),l.setValue(d,u,null))}),l.setValue(e,t,c),l}function vS(n,i,e,t){const r=e.getActiveViewportByCoord(T.Vector2.FromArray([n,i]));if(!r)return;const{scaleX:o,scaleY:s}=e.getAncestorScale(),l={x:r.viewportScrollX,y:r.viewportScrollY},c=t.getCellIndexByOffset(n,i,o,s,l),d=t.worksheet.getMergedCell(c.row,c.column);return{actualRow:d?d.startRow:c.row,actualCol:d?d.startColumn:c.column,mergeCell:d,row:c.row,col:c.column}}function Ta(n,i,e,t){const r=t.getFreeze();if(!r||r.startRow<=0&&r.startColumn<=0||n>=r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(n<r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT_TOP);if(n<r.startRow&&i>=r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_TOP);if(n>=r.startRow&&i<r.startColumn)return e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN_LEFT)}function CS(n,i,e,t){const r=ya(n.left,n.top,i,e,t),o=ya(n.right,n.bottom,i,e,t);return{left:r.x,top:r.y,right:o.x,bottom:o.y}}function ya(n,i,e,t,r){const{scaleX:o,scaleY:s}=e.getAncestorScale(),l=e.getViewport(T.SHEET_VIEWPORT_KEY.VIEW_MAIN);if(!l)return{x:n,y:i};const c=r.getFreeze(),{startColumn:d,startRow:u,xSplit:h,ySplit:g}=c,S=t.getNoMergeCellWithCoordByIndex(u-g,d-h,!1),f=t.getNoMergeCellWithCoordByIndex(u,d,!1),{rowHeaderWidth:p,columnHeaderHeight:v}=t,C=f.startX-S.startX,I=f.startY-S.startY,{top:R,left:w,viewportScrollX:M,viewportScrollY:y}=l;let P;n>w?P=(n-M)*o:P=(C+p-(w-n))*o;let O;return i>R?O=(i-y)*s:O=(I+v-(R-i))*o,{x:P,y:O}}function Yl(n,i,e,t,r){let o=t,s=r;e.overflowCache.forValue((d,u,h)=>{h.startRow<=o&&h.endRow>=o&&h.startColumn<=s&&h.endColumn>=s&&(s=u,o=d)});const l=e.getCellWithCoordByIndex(o,s);return{unitId:n.getUnitId(),subUnitId:i.getSheetId(),workbook:n,worksheet:i,row:l.actualRow,col:l.actualColumn}}function Gl(n,i,e,t,r,o){const{scene:s}=n,l=i.getUnitId(),{skeleton:c,sheetId:d}=t,u=vS(r,o,s,c);if(!u)return null;let{actualCol:h,actualRow:g}=u;const S={unitId:l,subUnitId:d,workbook:i,worksheet:e,row:g,col:h};c.overflowCache.forValue((y,P,O)=>{O.startRow<=g&&O.endRow>=g&&O.startColumn<=h&&O.endColumn>=h&&(h=P,g=y)});const f=c.getCellWithCoordByIndex(g,h),p=Yl(i,e,c,g,h);let v;f.mergeInfo?v=f.mergeInfo:v={startRow:p.row,endRow:p.row,startColumn:p.col,endColumn:p.col};const C=s.getActiveViewportByCoord(T.Vector2.FromArray([r,o]));if(!C)return;const{scaleX:I,scaleY:R}=s.getAncestorScale(),w={x:C.viewportScrollX,y:C.viewportScrollY};return{position:{startX:(c.getOffsetByColumn(v.startColumn-1)-w.x)*I,endX:(c.getOffsetByColumn(v.endColumn)-w.x)*I,startY:(c.getOffsetByRow(v.startRow-1)-w.y)*R,endY:(c.getOffsetByRow(v.endRow)-w.y)*R},location:S,overflowLocation:p}}const yt={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(n,i)=>{const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(a.IUniverInstanceService),o=n.get(_.IConfirmService),s=n.get(a.LocaleService),l=i.unitId,c=i.subUnitId,d=i.selections,u=m.getAddMergeMutationRangeByType(d,i.value),h=r.getUniverSheetInstance(l).getSheetBySheetId(c),g=[],S=[],f=zl(h,u);if(f&&!i.defaultMerge&&!await o.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 p={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},v={unitId:l,subUnitId:c,ranges:a.Tools.deepClone(u)},C=m.RemoveMergeUndoMutationFactory(n,p),I=m.AddMergeUndoMutationFactory(n,v);if(C.ranges.length>0&&g.push({id:m.RemoveWorksheetMergeMutation.id,params:C}),g.push({id:m.AddWorksheetMergeMutation.id,params:v}),S.push({id:m.RemoveWorksheetMergeMutation.id,params:I}),C.ranges.length>0&&S.push({id:m.AddWorksheetMergeMutation.id,params:C}),f){const O=Xl(n,l,h,u);g.unshift(...O.redos),S.push(...O.undos)}const R=m.AddMergeRedoSelectionsOperationFactory(n,i,u);R&&g.push(R);const w=m.AddMergeUndoSelectionsOperationFactory(n,i);w&&S.push(w);const y=n.get(m.SheetInterceptorService).onCommandExecute({id:yt.id,params:{unitId:l,subUnitId:c,ranges:u}});return g.push(...y.redos),S.push(...y.undos),a.sequenceExecute(g,e).result?(t.pushUndoRedo({unitID:l,undoMutations:S,redoMutations:g}),!0):!1}},ks={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeAll,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{selections:r,unitId:c,subUnitId:d})}},Ns={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeVertical,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{value:a.Dimension.COLUMNS,selections:r,unitId:c,subUnitId:d})}},Ds={type:a.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async n=>{var u;const i=n.get(a.ICommandService),t=(u=n.get(m.SheetsSelectionsService).getCurrentSelections())==null?void 0:u.map(h=>h.range),r=ps(Ni.MergeHorizontal,t);if(!(r!=null&&r.length))return!1;const s=n.get(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!s)return!1;const l=s.getActiveSheet();if(!l)return!1;const c=s.getUnitId(),d=l.getSheetId();return i.executeCommand(yt.id,{value:a.Dimension.ROWS,selections:r,unitId:c,subUnitId:d})}},Vn={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-left-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Vn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveLeftCommand.id):!0}},Xt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-move-up-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Xt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Xt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.DeleteRangeMoveUpCommand.id):!0}},Yt={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-down-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endRow:c.getRowCount()-1};for(let S=d.startRow;S<=d.endRow;S++)if(c.getRowFiltered(S)&&await i.confirm({id:Yt.id,title:{title:t.t("filter.confirm.error")},children:{title:t.t("filter.confirm.notAllowedToInsertRange")},confirmText:t.t("button.confirm")}))return!1;const u=S=>S.endColumn-S.startColumn;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Yt.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveDownCommand.id):!0}},Wn={type:a.CommandType.COMMAND,id:"sheet.command.insert-range-move-right-confirm",handler:async n=>{const i=n.get(_.IConfirmService),e=n.get(a.ICommandService),t=n.get(a.LocaleService),r=n.get(m.SheetsSelectionsService),o=n.get(a.IUniverInstanceService),s=r.getCurrentSelections();if(!s)return!1;const l=m.getSheetCommandTarget(o);if(!l)return!1;const{worksheet:c}=l;let d=s[0].range;if(!d)return!1;d={...d,endColumn:c.getColumnCount()-1};const u=S=>S.endRow-S.startRow;return!c.getMergeData().find(S=>{const f=a.Rectangle.getIntersects(S,d);return f?u(S)>u(f):!1})||await i.confirm({id:Wn.id,title:{title:t.t("merge.confirm.waring")},children:{title:t.t("merge.confirm.dismantleMergeCellWaring")},cancelText:t.t("button.cancel"),confirmText:t.t("button.confirm")})?e.executeCommand(m.InsertRangeMoveRightCommand.id):!0}};var Zl=(n=>(n[n.UNIVER_UNKNOWN=0]="UNIVER_UNKNOWN",n[n.UNIVER_DOC=1]="UNIVER_DOC",n[n.UNIVER_SHEET=2]="UNIVER_SHEET",n[n.UNIVER_SLIDE=3]="UNIVER_SLIDE",n[n.UNIVER_PROJECT=4]="UNIVER_PROJECT",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Zl||{}),te=(n=>(n[n.View=0]="View",n[n.Edit=1]="Edit",n[n.ManageCollaborator=2]="ManageCollaborator",n[n.Print=3]="Print",n[n.Duplicate=4]="Duplicate",n[n.Comment=5]="Comment",n[n.Copy=6]="Copy",n[n.Share=7]="Share",n[n.Export=8]="Export",n[n.MoveWorksheet=9]="MoveWorksheet",n[n.DeleteWorksheet=10]="DeleteWorksheet",n[n.HideWorksheet=11]="HideWorksheet",n[n.RenameWorksheet=12]="RenameWorksheet",n[n.CreateWorksheet=13]="CreateWorksheet",n[n.SetWorksheetStyle=14]="SetWorksheetStyle",n[n.EditWorksheetCell=15]="EditWorksheetCell",n[n.InsertHyperlink=16]="InsertHyperlink",n[n.Sort=17]="Sort",n[n.Filter=18]="Filter",n[n.PivotTable=19]="PivotTable",n[n.FloatImg=20]="FloatImg",n[n.History=21]="History",n[n.RwHgtClWdt=22]="RwHgtClWdt",n[n.ViemRwHgtClWdt=23]="ViemRwHgtClWdt",n[n.ViewFilter=24]="ViewFilter",n[n.MoveSheet=25]="MoveSheet",n[n.DeleteSheet=26]="DeleteSheet",n[n.HideSheet=27]="HideSheet",n[n.CopySheet=28]="CopySheet",n[n.RenameSheet=29]="RenameSheet",n[n.CreateSheet=30]="CreateSheet",n[n.SelectProtectedCells=31]="SelectProtectedCells",n[n.SelectUnProtectedCells=32]="SelectUnProtectedCells",n[n.SetCellStyle=33]="SetCellStyle",n[n.SetCellValue=34]="SetCellValue",n[n.SetRowStyle=35]="SetRowStyle",n[n.SetColumnStyle=36]="SetColumnStyle",n[n.InsertRow=37]="InsertRow",n[n.InsertColumn=38]="InsertColumn",n[n.DeleteRow=39]="DeleteRow",n[n.DeleteColumn=40]="DeleteColumn",n[n.EditExtraObject=41]="EditExtraObject",n[n.Delete=42]="Delete",n[n.RecoverHistory=43]="RecoverHistory",n[n.ViewHistory=44]="ViewHistory",n[n.CreatePermissionObject=45]="CreatePermissionObject",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(te||{}),ke=(n=>(n[n.Reader=0]="Reader",n[n.Editor=1]="Editor",n[n.Owner=2]="Owner",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ke||{}),ut=(n=>(n[n.Unkonwn=0]="Unkonwn",n[n.Workbook=1]="Workbook",n[n.Worksheet=2]="Worksheet",n[n.SelectRange=3]="SelectRange",n[n.Document=4]="Document",n[n.Slide=5]="Slide",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(ut||{}),Ke=(n=>(n[n.SomeCollaborator=0]="SomeCollaborator",n[n.AllCollaborator=1]="AllCollaborator",n[n.OneSelf=2]="OneSelf",n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n))(Ke||{});const sr="UNIVER_SHEET_PERMISSION_PANEL",li="UNIVER_SHEET_PERMISSION_USER_PART",Hs="UNIVER_SHEET_PERMISSION_BACKGROUND",Kl="UNIVER_SHEET_PERMISSION_USER_DIALOG",ql="UNIVER_SHEET_PERMISSION_DIALOG",ci="UNIVER_SHEET_PERMISSION_USER_DIALOG_ID",di="UNIVER_SHEET_PERMISSION_DIALOG_ID",Fr={[te.Copy]:"Copy",[te.SetCellStyle]:"SetCellStyle",[te.SetCellValue]:"SetCellValue",[te.SetRowStyle]:"SetRowStyle",[te.SetColumnStyle]:"SetColumnStyle",[te.InsertRow]:"InsertRow",[te.InsertColumn]:"InsertColumn",[te.InsertHyperlink]:"InsertHyperlink",[te.DeleteRow]:"DeleteRow",[te.DeleteColumn]:"DeleteColumn",[te.Sort]:"Sort",[te.Filter]:"Filter",[te.PivotTable]:"PivotTable",[te.EditExtraObject]:"EditExtraObject"},_S=[te.Copy,te.SetCellStyle,te.SetCellValue,te.SetRowStyle,te.SetColumnStyle,te.InsertRow,te.InsertColumn,te.InsertHyperlink,te.DeleteRow,te.DeleteColumn,te.Sort,te.Filter,te.PivotTable,te.EditExtraObject,te.View],Ql="sheet-permission-menu-icon",IS="sheet-permission-delete-icon",bS="sheet-permission-edit-icon",RS="sheet-permission-check-icon",Jl="sheet-permission-lock-icon",ES={unitId:"",subUnitId:"",permissionId:"",unitType:m.UnitObject.SelectRange,id:"",ranges:[],viewState:m.ViewStateEnum.OthersCanView,editState:m.EditStateEnum.OnlyMe};class yn{constructor(){E(this,"_rule",ES);E(this,"_visible",!1)}setVisible(i){this._visible=i}getVisible(){return this._visible}reset(){this.setVisible(!1)}}class Mt{constructor(){E(this,"_userList",[]);E(this,"_userList$",new x.BehaviorSubject(this._userList));E(this,"userList$",this._userList$.asObservable());E(this,"_oldCollaboratorList",[]);E(this,"_selectUserList",[]);E(this,"_selectUserList$",new x.BehaviorSubject(this._selectUserList));E(this,"selectUserList$",this._selectUserList$.asObservable())}get userList(){return this._userList}setCanEditUserList(i){this._userList=i,this._userList$.next(i)}reset(){this._userList=[],this._oldCollaboratorList=[],this._selectUserList=[],this._selectUserList$.next([])}get oldCollaboratorList(){return this._oldCollaboratorList}setOldCollaboratorList(i){this._oldCollaboratorList=i}get selectUserList(){return this._selectUserList}setSelectUserList(i){this._selectUserList=i,this._selectUserList$.next(i)}}const Je={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openPanel",async handler(n,i={}){const e=n.get(_.ISidebarService),t=n.get(yn),r=n.get(Mt),{showDetail:o=!0,fromSheetBar:s=!1,rule:l,oldRule:c}=i,d={header:{title:"permission.panel.title"},children:{label:sr,showDetail:o,fromSheetBar:s,rule:l,oldRule:c},width:330,onClose:()=>{t.reset(),r.reset()}};return t.setVisible(!0),e.open(d),!0}},Pr={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-toolbar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!0}),!0}},Wt={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!0}),!0}},Ut={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-context-menu",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!1}),!0}},Or={type:a.CommandType.COMMAND,id:"sheet.command.add-range-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{fromSheetBar:!0,showDetail:!0}),!0}},xr={type:a.CommandType.COMMAND,id:"sheet.command.view-sheet-permission-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand(Je.id,{showDetail:!1}),!0}},Lt={type:a.CommandType.COMMAND,id:"sheet.command.delete-range-protection-from-context-menu",async handler(n){var h;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(a.IUndoRedoService),r=n.get(m.SheetsSelectionsService),o=n.get(m.WorksheetProtectionRuleModel),s=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),c=s.getUnitId(),d=l.getSheetId(),u=o.getRule(c,d);if(u!=null&&u.permissionId)return i.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d,rule:u});{const g=(h=r.getCurrentLastSelection())==null?void 0:h.range;if(!g)return!1;const p=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(c,d).find(v=>v.ranges.some(C=>a.Rectangle.intersects(C,g)));if(p){const v={unitId:c,subUnitId:d,ruleIds:[p.id]};return await i.executeCommand(m.DeleteRangeProtectionMutation.id,v)&&t.pushUndoRedo({unitID:c,redoMutations:[{id:m.DeleteRangeProtectionMutation.id,params:v}],undoMutations:[{id:m.AddRangeProtectionMutation.id,params:{unitId:c,subUnitId:d,rules:[p]}}]}),!0}else return!1}}},Bt={type:a.CommandType.COMMAND,id:"sheet.command.set-range-protection-from-context-menu",async handler(n){var u;const i=n.get(a.ICommandService),e=n.get(a.IUniverInstanceService),t=n.get(m.SheetsSelectionsService),r=n.get(m.WorksheetProtectionRuleModel),o=e.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=o.getActiveSheet(),l=o.getUnitId(),c=s.getSheetId(),d=r.getRule(l,c);if(d!=null&&d.permissionId){const h={...d,unitId:l,subUnitId:c,ranges:[]};return await i.executeCommand(Je.id,{showDetail:!0,rule:a.Tools.deepClone(h),oldRule:a.Tools.deepClone(h)}),!0}else{const h=(u=t.getCurrentLastSelection())==null?void 0:u.range;if(!h)return!1;const f=n.get(m.RangeProtectionRuleModel).getSubunitRuleList(l,c).find(p=>{var v;return(v=p==null?void 0:p.ranges)==null?void 0:v.some(C=>a.Rectangle.intersects(C,h))});if(f){const p={...f,unitId:l,subUnitId:c};return await i.executeCommand(Je.id,{showDetail:!0,rule:a.Tools.deepClone(p),oldRule:a.Tools.deepClone(p)}),!0}else return!1}}},Mn={id:"sheet.command.remove-row-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleRows();if(qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.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 r.executeCommand(m.RemoveRowCommand.id,{range:t}),!0}},Pn={id:"sheet.command.remove-col-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{var d;const e=n.get(m.SheetsSelectionsService);let t=i==null?void 0:i.range;if(t||(t=(d=e.getCurrentLastSelection())==null?void 0:d.range),!t)return!1;const r=n.get(a.ICommandService),o=n.get(a.IUniverInstanceService),s=m.getSheetCommandTarget(o);if(!s)return!1;const{worksheet:l}=s,c=l.getVisibleCols();if(Qa(c,[t])){const u=n.get(_.IConfirmService),h=n.get(a.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 r.executeCommand(m.RemoveColCommand.id,{range:t}),!0}},Ar={id:"sheet.command.remove-sheet-confirm",type:a.CommandType.COMMAND,handler:async(n,i)=>{const{subUnitId:e}=i,t=n.get(_.IConfirmService),r=n.get(a.ICommandService),o=n.get(a.LocaleService);return await t.confirm({id:"sheet.confirm.remove-sheet",title:{title:o.t("sheetConfig.deleteSheet")},children:{title:o.t("sheetConfig.deleteSheetContent")},cancelText:o.t("button.cancel"),confirmText:o.t("button.confirm")})?(await r.executeCommand(m.RemoveSheetCommand.id,{subUnitId:e}),!0):!1}},kr={id:"ui-sheet.command.show-menu-list",type:a.CommandType.OPERATION,handler:async n=>(n.get(Kt).triggerSheetBarMenu(),!0)},Nr={type:a.CommandType.COMMAND,id:"sheet.command.delete-worksheet-protection-from-sheet-bar",async handler(n,i){if(!i)return!1;const e=n.get(a.ICommandService),t=n.get(a.IUndoRedoService),r=n.get(m.WorksheetProtectionRuleModel),s=n.get(a.IUniverInstanceService).getCurrentUnitForType(Zl.UNIVER_SHEET),l=s==null?void 0:s.getActiveSheet(),c=s.getUnitId();if(!l)return!1;const d=l.getSheetId(),u=r.getRule(c,d);if(await e.executeCommand(m.DeleteWorksheetProtectionCommand.id,{unitId:c,subUnitId:d})){const g=[{id:m.DeleteWorksheetProtectionCommand.id,params:{unitId:c,subUnitId:d}}],S=[{id:m.AddWorksheetProtectionCommand.id,params:{unitId:c,rule:u}}];t.pushUndoRedo({unitID:c,redoMutations:g,undoMutations:S})}return!0}},Dr={type:a.CommandType.COMMAND,id:"sheet.command.change-sheet-protection-from-sheet-bar",async handler(n){return await n.get(a.ICommandService).executeCommand("sheet-permission.operation.openDialog"),!0}},ji={id:"sheet.operation.set-activate-cell-edit",type:a.CommandType.OPERATION,handler:(n,i)=>(n.get(Se).setEditCell(i),!0)},Hr={id:"sheet.operation.rename-sheet",type:a.CommandType.OPERATION,handler:async(n,i)=>{const e=n.get(Kt);return i&&e.setRenameId(i.subUnitId),!0}},Vs={type:a.CommandType.OPERATION,id:"sheet-permission.operation.openDialog",async handler(n,i){const e=n.get(_.IDialogService);return e.close("DESKTOP_FIND_REPLACE_DIALOG"),e.open({id:di,title:{title:"permission.dialog.allowedPermissionType"},children:{label:ql},width:393,destroyOnClose:!0,onClose:()=>e.close(di)}),!0}},wS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),b.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),b.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),b.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),b.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),b.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),b.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),b.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),b.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),b.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),b.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),b.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),b.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),b.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),b.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),b.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),b.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),b.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),b.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),b.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),b.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),TS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),b.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),b.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),b.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),b.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),b.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),b.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),b.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),b.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),b.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),b.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),b.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),b.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),b.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),b.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),b.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),b.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),b.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),b.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),b.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),yS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),b.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),b.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),b.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),b.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),b.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),b.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),b.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),b.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),b.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),b.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),b.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),b.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),b.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),b.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),b.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),b.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),b.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),b.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),b.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),MS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),b.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),b.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),b.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),b.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),b.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),b.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),b.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),b.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),b.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),b.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),b.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),b.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),b.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),b.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),b.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),b.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),b.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),b.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),b.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),b.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),b.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),b.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),b.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),b.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),b.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),b.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),b.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),b.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),b.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),b.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),b.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),b.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),b.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),b.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),b.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),b.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),b.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),b.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),b.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),b.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),b.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),b.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),b.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),b.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),b.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),PS=()=>b.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),OS=()=>b.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),b.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),b.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),b.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),b.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),b.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),b.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),b.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),b.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),xS=()=>b.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),b.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),b.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),b.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),b.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),b.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),b.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),b.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),b.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),b.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),b.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),AS=()=>b.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[b.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),b.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),b.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),b.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),b.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),b.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),b.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),b.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),b.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),b.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),b.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),b.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),b.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),b.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),b.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),b.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),b.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),b.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),b.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),b.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),kS=()=>b.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),Ma=()=>b.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function Pa(n){const{type:i=a.BorderStyleTypes.THIN}=n;switch(i){case a.BorderStyleTypes.DASH_DOT:return b.jsx(wS,{});case a.BorderStyleTypes.DASH_DOT_DOT:return b.jsx(TS,{});case a.BorderStyleTypes.DASHED:return b.jsx(yS,{});case a.BorderStyleTypes.HAIR:return b.jsx(MS,{});case a.BorderStyleTypes.MEDIUM:return b.jsx(PS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT:return b.jsx(OS,{});case a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return b.jsx(xS,{});case a.BorderStyleTypes.MEDIUM_DASHED:return b.jsx(AS,{});case a.BorderStyleTypes.THICK:return b.jsx(kS,{});case a.BorderStyleTypes.THIN:return b.jsx(Ma,{});default:return b.jsx(Ma,{})}}const Ws=`${Nn}_BORDER_PANEL_COMPONENT`,$l=[{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"}],NS=[{label:a.BorderStyleTypes.THIN,value:a.BorderStyleTypes.THIN},{label:a.BorderStyleTypes.HAIR,value:a.BorderStyleTypes.HAIR},{label:a.BorderStyleTypes.DOTTED,value:a.BorderStyleTypes.DOTTED},{label:a.BorderStyleTypes.DASHED,value:a.BorderStyleTypes.DASHED},{label:a.BorderStyleTypes.DASH_DOT,value:a.BorderStyleTypes.DASH_DOT},{label:a.BorderStyleTypes.DASH_DOT_DOT,value:a.BorderStyleTypes.DASH_DOT_DOT},{label:a.BorderStyleTypes.MEDIUM,value:a.BorderStyleTypes.MEDIUM},{label:a.BorderStyleTypes.MEDIUM_DASHED,value:a.BorderStyleTypes.MEDIUM_DASHED},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT},{label:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:a.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:a.BorderStyleTypes.THICK,value:a.BorderStyleTypes.THICK}];function ec(n){var l;const i=_.useDependency(_.ComponentManager),e=_.useDependency(m.BorderStyleManagerService),{onChange:t,value:r}=n;function o(c,d){t==null||t({...r,[d]:c})}function s(c){const d=i.get(c);return d&&b.jsx(d,{extend:{colorChannel1:"#2c53f1"}})}return b.jsxs("section",{className:"univer-box-border univer-grid univer-gap-2 univer-p-1.5",children:[b.jsx("div",{className:"univer-box-border univer-grid univer-grid-cols-5 univer-gap-2",children:$l.map(c=>b.jsx("a",{className:Y.clsx(`
|
|
59
59
|
univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center
|
|
60
60
|
univer-justify-self-center univer-rounded
|
|
61
61
|
hover:univer-bg-gray-100
|