@univerjs/docs-ui 1.0.1 → 1.0.2

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/umd/index.js CHANGED
@@ -38,7 +38,7 @@ td.UniverTableCell, th.UniverTableCell{mso-padding-alt:0cm 5.4pt 0cm 5.4pt;}
38
38
  `):e.length>1?e.map(e=>{var t;return((t=e.body)==null?void 0:t.dataStream)||``}).join(`
39
39
  `):((i=e[0].body)==null?void 0:i.dataStream)||``).replaceAll(t.DataStreamTreeTokenType.TABLE_START,``).replaceAll(t.DataStreamTreeTokenType.TABLE_END,``).replaceAll(t.DataStreamTreeTokenType.TABLE_ROW_START,``).replaceAll(t.DataStreamTreeTokenType.TABLE_ROW_END,``).replaceAll(t.DataStreamTreeTokenType.TABLE_CELL_START,``).replaceAll(t.DataStreamTreeTokenType.TABLE_CELL_END,``).replaceAll(t.DataStreamTreeTokenType.BLOCK_START,``).replaceAll(t.DataStreamTreeTokenType.BLOCK_END,``).replaceAll(`\r
40
40
  `,` `).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,``),s=this._umdToHtml.convert(e),c=``,l=null;if(e.length===1&&n){s=s.replace(/(<[a-z]+)/,(e,t)=>`${t} data-copy-id="${a}"`);let t=e[0],n=ue(t);jr.set(a,n),l=n}else l=de(e);l&&(l=this._applyCopyDocDataHooks(l,e),c=G(l),s=he(s,c)),s=_e(s),await this._clipboardInterfaceService.write(o,s,c?{[se]:c}:void 0),this._memoryClipboardData=t.Tools.deepClone(l)}_getSelectionParams(e){let t=this._docSelectionManagerService.__getCurrentSelection();return(t==null?void 0:t.unitId)===e?t:{unitId:e,subUnitId:e}}addClipboardHook(e){return this._clipboardHooks.push(e),(0,t.toDisposable)(()=>{let t=this._clipboardHooks.indexOf(e);t>-1&&this._clipboardHooks.splice(t,1)})}_applyCopyDocDataHooks(e,t){return this._clipboardHooks.reduce((e,n)=>{var r;return((r=n.onCopyDocData)==null?void 0:r.call(n,e,{sourceDocuments:t}))??e},e)}_getDocumentBodyInRanges(e,n){var r,i;let a=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),o=n??this._docSelectionManagerService.getDocRanges(),s=[],c=[],l=(r=this._clipboardHooks.find(e=>e.onCopyContent))==null?void 0:r.onCopyContent,u=!0;if(a==null||o.length===0)return;let d=o[0].segmentId,f=a==null||(i=a.getSelfOrHeaderFooterModel(d))==null?void 0:i.getBody(),p=a.getSnapshot();if(f!=null){for(let n of o){var m,h;let{startOffset:r,endOffset:i,collapsed:o,rangeType:p}=n;if(o||r==null||i==null)continue;if(p===t.DOC_RANGE_TYPE.RECT){u=!1;let e=Qi(f,n);s.push(e),c.push(e.dataStream);continue}let _={startOffset:r,endOffset:i,collapsed:o},v=(m=a.getSelfOrHeaderFooterModel(d))==null?void 0:m.sliceBody(_.startOffset,_.endOffset,e);if(v!=null){if((h=v.tables)!=null&&h.length){var g;let e=new Set((g=f.tables)==null?void 0:g.filter(e=>e.startIndex>=r&&e.endIndex<=i).map(e=>e.tableId));v.tables=v.tables.filter(t=>e.has(t.tableId))}s.push(v),c.push((l==null?void 0:l(_.startOffset,_.endOffset,{body:f,segmentId:d,unitId:a.getUnitId()}))??v.dataStream)}}return{newSnapshotList:s.map(e=>({...p,body:e})),needCache:u,plainTextList:c,snapshot:p,ranges:o}}}async _readClipboardItems(e){try{let t=``,n,r=``,i=[];for(let o of e)for(let e of o.types)switch(e){case se:r=await o.getType(e).then(e=>e&&e.text());break;case a.PLAIN_TEXT_CLIPBOARD_MIME_TYPE:n=await o.getType(e).then(e=>e&&e.text());break;case a.HTML_CLIPBOARD_MIME_TYPE:t=await o.getType(e).then(e=>e&&e.text());break;case a.FILE__BMP_CLIPBOARD_MIME_TYPE:case a.FILE__JPEG_CLIPBOARD_MIME_TYPE:case a.FILE__WEBP_CLIPBOARD_MIME_TYPE:case a.FILE_PNG_CLIPBOARD_MIME_TYPE:{let t=await o.getType(e),n=new File([t],`pasted_image.${e.split(`/`)[1]}`,{type:e});i.push(n);break}}return{html:t,text:n,internalJson:r,files:i}}catch(e){return Promise.reject(e)}}_genDocDataFromHtmlAndText(e,n,r,i){let a=K(i)??ge(e);if(a!=null&&a.body)return a;if(!e){if(n)return{body:t.BuildTextUtils.transform.fromPlainText(n)};throw Error(`[DocClipboardService] html and text cannot be both empty!`)}let o=Ar(e);if(o){let e=jr.get(o);if(e)return e}let s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=r||(s==null?void 0:s.getUnitId())||``,l=this._htmlToUDM.convert(e,{unitId:c});return o&&jr.set(o,l),l}async _uploadBase64ImagesInHtml(e){var n;if(!e||!e.includes(`data:image/`))return e;let r=(n=this._clipboardHooks.find(e=>e.onBeforePasteImage))==null?void 0:n.onBeforePasteImage;if(!r)return e;let i=new DOMParser().parseFromString(e,`text/html`),a=Array.from(i.querySelectorAll(`img[src^="data:image/"]`));return a.length===0?e:(await Promise.all(a.map(async(e,n)=>{if(e.dataset.imageSourceType&&e.dataset.imageSourceType!==t.ImageSourceType.BASE64)return;let i=ia(e.getAttribute(`src`)||e.src,`pasted_image_${n}`),a=await r(i);a&&(e.dataset.imageSourceType=a.imageSourceType,a.imageSourceType===t.ImageSourceType.UUID?(e.dataset.source=a.source,e.setAttribute(`src`,a.source)):(e.removeAttribute(`data-source`),e.setAttribute(`src`,a.source)))})),/<(?:html|head)\b/i.test(e)?i.documentElement.outerHTML:i.body.innerHTML)}async _createImagePasteHtml(e){var n;let r={id:``,documentStyle:{},body:{dataStream:``,customBlocks:[]},drawings:{}},i=async e=>{let n=new FileReader;return new Promise(r=>{n.onloadend=function(){r({source:n.result,imageSourceType:t.ImageSourceType.BASE64})},n.readAsDataURL(e)})},a=e=>{let t=new Image;return new Promise(n=>{t.src=typeof e==`string`?e:URL.createObjectURL(e),t.onload=()=>{let e=Math.min(500,t.naturalWidth);n({width:e,height:e*(t.naturalHeight/t.naturalWidth)})}})},o=((n=this._clipboardHooks.find(e=>e.onBeforePasteImage))==null?void 0:n.onBeforePasteImage)??i;return await Promise.all(e.map(async(e,n)=>{var i;let s=await o(e);if(!s)return Promise.resolve();let{width:c=100,height:l=100}=await a(e),u=`paste_image_id_${n}`,d=r.body,f=r.drawings;d.dataStream+=`\b`,(i=d.customBlocks)==null||i.push({startIndex:n,blockId:u}),f[u]={drawingId:u,unitId:``,subUnitId:``,imageSourceType:s.imageSourceType,title:``,source:s.source,description:``,layoutType:t.PositionedObjectLayoutType.INLINE,drawingType:t.DrawingTypeEnum.DRAWING_IMAGE,transform:{width:c,height:l,angle:0},docTransform:{angle:0,size:{width:c,height:l},positionH:{relativeFrom:t.ObjectRelativeFromH.CHARACTER,posOffset:0},positionV:{relativeFrom:t.ObjectRelativeFromV.LINE,posOffset:0}}}})),this._umdToHtml.convert([r])}};ta=B([z(0,t.IUniverInstanceService),z(1,t.ILogService),z(2,t.ICommandService),z(3,t.IPermissionService),z(4,a.IClipboardInterfaceService),z(5,(0,t.Inject)(t.ErrorService)),z(6,(0,t.Inject)(Ji)),z(7,(0,t.Inject)(n.DocSelectionManagerService)),z(8,(0,t.Inject)(n.DocStateChangeManagerService)),z(9,(0,t.Inject)(U)),z(10,t.IUndoRedoService)],ta);function na(e){let n=e[e.length-1];return n===t.DataStreamTreeTokenType.PARAGRAPH||n===t.DataStreamTreeTokenType.SECTION_BREAK||n===t.DataStreamTreeTokenType.BLOCK_END||n===t.DataStreamTreeTokenType.TABLE_END||n===t.DataStreamTreeTokenType.COLUMN_GROUP_END}function ra(e,n,r){var i;if(na(e.dataStream)||!r.every(e=>e.collapsed&&k(n.dataStream,e.startOffset)))return;let a=e.dataStream.length,o=new Set(((i=e.paragraphs)==null?void 0:i.map(e=>e.paragraphId))??[]);e.dataStream+=t.DataStreamTreeTokenType.PARAGRAPH,e.paragraphs=[...e.paragraphs??[],{startIndex:a,paragraphId:(0,t.createParagraphId)(o)}]}function ia(e,t){let n=/^data:([^;,]+)(;base64)?,(.*)$/i.exec(e);if(!n)throw Error(`[DocClipboardService] invalid image data url.`);let[,r,i,a]=n,o=i?Uint8Array.from(atob(a),e=>e.charCodeAt(0)):new TextEncoder().encode(decodeURIComponent(a)),s=r.split(`/`)[1]||`png`;return new File([o],`${t}.${s}`,{type:r})}function aa(e){return e.getContextValue(t.FOCUSING_DOC)||e.getContextValue(t.EDITOR_ACTIVATED)}let oa={id:a.CopyCommand.id,name:`doc.command.copy`,type:t.CommandType.COMMAND,multi:!0,priority:999,preconditions:aa,handler:async e=>e.get(ea).copy()},sa={id:`doc.command.copy-current-paragraph`,type:t.CommandType.COMMAND,handler:async e=>{let n=e.get(ea),r=Fn(e);return r?n.copy(t.SliceBodyType.copy,[{startOffset:r.paragraphStart,endOffset:r.paragraphEnd+1,collapsed:!1}]):!1}},ca={id:a.CutCommand.id,name:`doc.command.cut`,type:t.CommandType.COMMAND,multi:!0,priority:999,preconditions:aa,handler:async e=>e.get(ea).cut()},la={id:`doc.command.cut-current-paragraph`,type:t.CommandType.COMMAND,handler:async e=>{let n=e.get(ea),r=Fn(e);return r?n.cut([{startOffset:r.paragraphStart,endOffset:r.paragraphEnd+1,collapsed:!1,rangeType:t.DOC_RANGE_TYPE.TEXT}]):!1}},ua={id:`doc.command.paste-special`,type:t.CommandType.COMMAND,handler:async(e,n)=>{if(!n||![`source`,`destination`,`text`].includes(n.value))return!1;let r=e.get(ea);try{return await r.pasteFromClipboard(n.value)}catch{let n=e.get(t.LocaleService),r=e.get(t.IContextService).getContextValue(a.MOBILE_UI_MODE)?null:e.get(a.IShortcutService).getShortcutDisplayOfCommand(a.PasteCommand.id);return e.get(a.IMessageService).show({type:i.MessageType.Info,content:r?n.t(`docs-ui.pasteOptions.useKeyboard`,r):n.t(`docs-ui.pasteOptions.useSystemPaste`)}),!1}}},da={id:a.PasteCommand.id,name:`doc.command.paste`,type:t.CommandType.COMMAND,multi:!0,priority:999,preconditions:aa,handler:e=>ua.handler(e,{value:`source`})},fa={id:`doc.command.change-paste-mode`,type:t.CommandType.COMMAND,handler:async(e,n)=>{if(!n||![`source`,`destination`,`text`].includes(n.value))return!1;try{return await e.get(ea).changePasteMode(n.value)}catch{e.get(ea).dismissPasteOptions();let n=e.get(t.LocaleService);return e.get(a.IMessageService).show({type:i.MessageType.Error,content:n.t(`docs-ui.pasteOptions.failed`)}),!1}}},pa=[`paragraphs`,`sectionBreaks`,`tables`,`columnGroups`,`customBlocks`,`blockRanges`,`customRanges`,`customDecorations`,`textRuns`],ma={id:`doc.command.move-block`,type:t.CommandType.COMMAND,handler:async(e,r)=>{if(!r)return!1;let i=e.get(t.IUniverInstanceService),a=e.get(t.ICommandService),{unitId:o,sourceRange:s,targetOffset:c}=r,l=o?i.getUnit(o,t.UniverInstanceType.UNIVER_DOC):i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!l)return!1;let u=l.getSnapshot(),d=ha({documentData:u,sourceRange:s,targetOffset:c}),{nextDocumentData:f,movedRange:p}=e.get(n.DocBlockMoveValidatorService).transformMoveResult({unitId:l.getUnitId(),sourceRange:s,targetOffset:c,previousDocumentData:u,result:d}),m=ga(u,f,{sourceRange:s,targetOffset:c,movedRange:p});if(!m)return!1;let h=[{startOffset:p.startOffset,endOffset:p.endOffset,collapsed:!1}];return!!a.syncExecuteCommand(n.RichTextEditingMutation.id,{unitId:l.getUnitId(),actions:m,textRanges:h})}};function ha(e){let n=t.Tools.deepClone(e.documentData),r=n.body;if(!(r!=null&&r.dataStream))return{nextDocumentData:n,movedRange:e.sourceRange};let i=r.dataStream.length,a=Aa(e.sourceRange.startOffset,0,i),o=Aa(e.sourceRange.endOffset,a,i),s=Aa(e.targetOffset,0,i);if(a===o||s>=a&&s<=o)return{nextDocumentData:n,movedRange:{startOffset:a,endOffset:o}};let c=r.dataStream.slice(a,o),l=c.length,u=s>o?s-l:s,d=r.dataStream.slice(0,a)+r.dataStream.slice(o);return r.dataStream=d.slice(0,u)+c+d.slice(u),Ta(r,a,o,s,u,l),{nextDocumentData:n,movedRange:{startOffset:u,endOffset:u+l}}}function ga(e,n,r){t.JSONX.getInstance();let i=e.body,a=n.body;if(!i||!a)return null;let o=[],s=t.Tools.deepClone(e),c=r?_a(i,a,r):null;c&&(o.push(c),s=t.JSONX.apply(s,c));let l=va(s.body,a);return l&&(o.push(l),s=t.JSONX.apply(s,l)),c||ba(s.body,a,o),o.reduce((e,n)=>t.JSONX.compose(e,n),null)}function _a(e,n,r){let i=e.dataStream.length,a=Aa(r.sourceRange.startOffset,0,i),o=Aa(r.sourceRange.endOffset,a,i),s=Aa(r.targetOffset,0,i),c=o-a;if(c<=0||s>=a&&s<=o)return null;let l=new t.TextX,u=r.movedRange.startOffset,d=(0,t.getBodySliceForTextXAction)(n,u,u+c,!1);return s<a?(l.retain(s),l.insert(c,d),l.retain(a-s),l.delete(c)):(l.retain(a),l.delete(c),l.retain(s-o),l.insert(c,d)),t.JSONX.getInstance().editOp(l.serialize(),[`body`])}function va(e,n){let r=ya(e==null?void 0:e.dataStream,n.dataStream);if(!r)return null;let i=new t.TextX;return i.retain(r.start),r.insertLength>0&&i.insert(r.insertLength,(0,t.getBodySliceForTextXAction)(n,r.start,r.start+r.insertLength,!1)),r.deleteLength>0&&i.delete(r.deleteLength),t.JSONX.getInstance().editOp(i.serialize(),[`body`])}function ya(e,t){if(e==null||t==null||e===t)return null;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n++;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)r--,i--;return{start:n,deleteLength:r-n,insertLength:i-n}}function ba(e,n,r){for(let i of pa)xa(t.JSONX.getInstance(),[`body`,i],e==null?void 0:e[i],n[i],r)}function xa(e,n,r,i,a){if(!wa(r,i)&&!t.Tools.diffValue(r,i)){if(r==null){a.push(e.insertOp(n,i));return}if(i==null){a.push(e.removeOp(n,r));return}if(Array.isArray(r)&&Array.isArray(i)){Sa(e,n,r,i,a);return}if(Ca(r)&&Ca(i)){new Set([...Object.keys(r),...Object.keys(i)]).forEach(t=>{xa(e,[...n,t],r[t],i[t],a)});return}a.push(e.replaceOp(n,r,i))}}function Sa(e,n,r,i,a){if(r.length===i.length){r.forEach((t,r)=>xa(e,[...n,r],t,i[r],a));return}let o=0;for(;o<r.length&&o<i.length&&t.Tools.diffValue(r[o],i[o]);)o++;let s=r.length-1,c=i.length-1;for(;s>=o&&c>=o&&t.Tools.diffValue(r[s],i[c]);)s--,c--;for(let t=s;t>=o;t--)a.push(e.removeOp([...n,t],r[t]));for(let t=o;t<=c;t++)a.push(e.insertOp([...n,t],i[t]))}function Ca(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wa(e,t){return e==null&&Array.isArray(t)&&t.length===0||t==null&&Array.isArray(e)&&e.length===0}function Ta(e,t,n,r,i,a){var o,s,c,l,u,d,f,p,m;e.paragraphs=(o=e.paragraphs)==null?void 0:o.map(e=>({...e,startIndex:Oa(e.startIndex,t,n,r,i,a)})).sort((e,t)=>e.startIndex-t.startIndex),e.sectionBreaks=(s=e.sectionBreaks)==null?void 0:s.map(e=>({...e,startIndex:Oa(e.startIndex,t,n,r,i,a)})).sort((e,t)=>e.startIndex-t.startIndex),e.customBlocks=(c=e.customBlocks)==null?void 0:c.map(e=>({...e,startIndex:Oa(e.startIndex,t,n,r,i,a)})).sort((e,t)=>e.startIndex-t.startIndex),e.tables=(l=e.tables)==null?void 0:l.map(e=>Ea(e,t,n,r,i,a)).sort((e,t)=>e.startIndex-t.startIndex),e.columnGroups=(u=e.columnGroups)==null?void 0:u.map(e=>Ea(e,t,n,r,i,a)).sort((e,t)=>e.startIndex-t.startIndex),e.blockRanges=(d=e.blockRanges)==null?void 0:d.map(e=>Da(e,t,n,r,i,a)).sort((e,t)=>e.startIndex-t.startIndex),e.customRanges=(f=e.customRanges)==null?void 0:f.map(e=>Da(e,t,n,r,i,a)).sort((e,t)=>e.startIndex-t.startIndex),e.customDecorations=(p=e.customDecorations)==null?void 0:p.map(e=>Da(e,t,n,r,i,a)).sort((e,t)=>e.startIndex-t.startIndex),e.textRuns=(m=e.textRuns)==null?void 0:m.map(e=>{let o=Ea({startIndex:e.st,endIndex:e.ed},t,n,r,i,a);return{...e,st:o.startIndex,ed:o.endIndex}}).sort((e,t)=>e.st-t.st)}function Ea(e,t,n,r,i,a){return e.startIndex>=t&&e.endIndex<=n?{...e,startIndex:i+e.startIndex-t,endIndex:i+e.endIndex-t}:{...e,startIndex:Oa(e.startIndex,t,n,r,i,a),endIndex:ka(e.endIndex,t,n,r,i,a)}}function Da(e,t,n,r,i,a){return e.startIndex>=t&&e.endIndex<n?{...e,startIndex:i+e.startIndex-t,endIndex:i+e.endIndex-t}:{...e,startIndex:Oa(e.startIndex,t,n,r,i,a),endIndex:Oa(e.endIndex,t,n,r,i,a)}}function Oa(e,t,n,r,i,a){return e>=t&&e<n?i+e-t:r<t&&e>=r&&e<t?e+a:r>n&&e>=n&&e<r?e-a:e}function ka(e,t,n,r,i,a){return e>t&&e<=n?i+e-t:r>n&&e>=n&&e<=r?e-a:Oa(e,t,n,r,i,a)}function Aa(e,t,n){return Math.min(Math.max(e,t),n)}let ja={id:`doc.command.horizontal-line`,type:t.CommandType.COMMAND,handler:(e,n)=>e.get(t.ICommandService).syncExecuteCommand(W.id,{horizontalLine:{padding:5,color:{rgb:`#CDD0D8`},width:1,dashStyle:t.DashStyleType.SOLID},insertionMode:n==null?void 0:n.insertionMode,textRange:n==null?void 0:n.insertRange})},Ma={id:`doc.command.insert-horizontal-line-bellow`,type:t.CommandType.COMMAND,handler:e=>{let r=e.get(t.ICommandService),i=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),a=null;try{a=e.get(n.DocContentInsertService).consumeInsertRange(i==null?void 0:i.getUnitId())}catch{a=null}if(a)return r.syncExecuteCommand(ja.id,{insertionMode:`insert-gap`,insertRange:{startOffset:a.startOffset,endOffset:a.endOffset}});let o=Fn(e);return o?r.syncExecuteCommand(ja.id,{insertRange:{startOffset:o.startIndex+1,endOffset:o.startIndex+1}}):!1}},Na={id:`doc.command.select-all`,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i;let a=e.get(t.IUniverInstanceService),o=e.get(n.DocSelectionManagerService),s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=o.getDocRanges(),l=c.find(e=>e.isActive)??c[0];if(s==null)return!1;let u=(r==null?void 0:r.segmentId)??(l==null?void 0:l.segmentId);if(u==null)return!1;let d=s.getUnitId(),f=(i=s.getSelfOrHeaderFooterModel(u))==null?void 0:i.getBody();if(f==null)return!1;let{dataStream:p}=f;if(p===`\r
41
- `)return!0;let m,h;if(r!=null&&r.wholeDocument)m=Fa(f),h=!0;else{if(l==null)return!1;let e=za(f,l),t=e.findIndex(e=>Ga(c,e));m=e[Math.min(t+1,e.length-1)],h=m===e[e.length-1]}return o.replaceDocRanges(m,{unitId:d,subUnitId:d},!1,{wholeDocument:h}),!0}},Pa={id:`doc.command.select-word`,type:t.CommandType.COMMAND,handler:e=>{var r,i;let a=e.get(t.IUniverInstanceService),o=e.get(n.DocSelectionManagerService),s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=o.getActiveTextRange();if(!s||!(c!=null&&c.collapsed)||c.startOffset==null)return!1;let l=(r=s.getSelfOrHeaderFooterModel(c.segmentId))==null?void 0:r.getBody();if(!l)return!1;let u=(0,t.getParagraphContentStartOffsets)(l),d=(i=l.paragraphs)==null?void 0:i.find(e=>(u.get(e.startIndex)??0)<=c.startOffset&&c.startOffset<=e.startIndex);if(!d)return!1;let f=u.get(d.startIndex)??0,p=l.dataStream.slice(f,d.startIndex),m=c.startOffset-f,h=Ht(p,m,f)??Ht(p,m-1,f);if(!h)return!1;let g=s.getUnitId();return o.replaceDocRanges([{...h,rangeType:t.DOC_RANGE_TYPE.TEXT}],{unitId:g,subUnitId:g},!1),!0}};function Fa(e){return Ia(e,0,e.dataStream.length-2)}function Ia(e,t,n){let r=[...e.columnGroups??[]].sort((e,t)=>e.startIndex-t.startIndex),i=[],a=t;for(let o of r)if(!(o.endIndex<t||o.startIndex>n)){a<o.startIndex&&i.push(...La(e,a,Math.min(n,o.startIndex-1)));for(let r of Ba(e,o)){let a=Math.max(t,r.startOffset),o=Math.min(n,r.endOffset);a<=o&&i.push(...La(e,a,o))}a=o.endIndex+1}return a<=n&&i.push(...La(e,a,n)),i}function La(e,t,n){let r=[],i=t;for(let a of[...e.tables??[]].sort((e,t)=>e.startIndex-t.startIndex)){let{startIndex:o,endIndex:s}=a;o<t||s>n||(i!==o&&r.push(...Ra(e,i,o-1)),r.push(Ha(a)),i=s)}return i<=n&&r.push(...Ra(e,i,n)),r}function Ra(e,n,r){if(n>r)return[];let i=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex),a=[],o=n;for(let e of i)if(!(e.startIndex<o)){if(e.startIndex>r)break;a.push({startOffset:o,endOffset:e.startIndex,rangeType:t.DOC_RANGE_TYPE.TEXT}),o=e.startIndex+1}return o<=r&&a.push({startOffset:o,endOffset:r,rangeType:t.DOC_RANGE_TYPE.TEXT}),a}function za(e,n){let r=[],i=e=>{e!=null&&e.length&&!r.some(t=>Ga(t,e))&&r.push(e)},a=n.startOffset,o=n.endOffset;if(a==null||o==null)return[Fa(e)];let s=(e.tables??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex)),c=(e.customBlocks??[]).find(e=>e.startIndex>=a&&e.startIndex<=o),l=(e.blockRanges??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex));if(s)i([Ha(s)]);else if(c)i([{endOffset:c.startIndex,rangeType:t.DOC_RANGE_TYPE.TEXT,startOffset:c.startIndex}]);else if(l)i([{endOffset:Math.max(l.startIndex+1,l.endIndex-1),rangeType:t.DOC_RANGE_TYPE.TEXT,startOffset:l.startIndex+1}]);else{let n=Va(Ua(e,a),e.tables??[],a);i(n?[{...n,rangeType:t.DOC_RANGE_TYPE.TEXT}]:null)}let u=(e.columnGroups??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex));if(u){let t=Ba(e,u).find(e=>Wa(a,o,e.startOffset,e.endOffset));t&&i(Ia(e,t.startOffset,t.endOffset)),i(Ia(e,u.startIndex,u.endIndex))}return i(Fa(e)),r}function Ba(e,n){let r=[],i;for(let a=n.startIndex;a<=n.endIndex;a++){let n=e.dataStream[a];n===t.DataStreamTreeTokenType.COLUMN_START?i=a+1:n===t.DataStreamTreeTokenType.COLUMN_END&&i!=null&&(r.push({startOffset:i,endOffset:a-1,rangeType:t.DOC_RANGE_TYPE.TEXT}),i=void 0)}return r}function Va(e,t,n){if(!e)return null;let r={...e};for(let e of t)n<e.startIndex&&r.startOffset<e.startIndex&&e.startIndex<=r.endOffset?r.endOffset=e.startIndex-1:n>=e.endIndex&&r.startOffset<=e.endIndex&&e.endIndex<r.endOffset&&(r.startOffset=e.endIndex);return r.startOffset<=r.endOffset?r:null}function Ha(e){return{startOffset:e.startIndex+3,endOffset:e.endIndex-5,rangeType:t.DOC_RANGE_TYPE.RECT}}function Ua(e,n){let r=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex),i=(0,t.getParagraphContentStartOffsets)(e);for(let e of r){let t=i.get(e.startIndex)??0;if(t<=n&&n<=e.startIndex)return{endOffset:e.startIndex,startOffset:t}}return null}function Wa(e,t,n,r){return e>=n&&t<=r}function Ga(e,n){return e.length===n.length?e.every((e,r)=>{let i=n[r],a=qa(e)===qa(i),o=a&&qa(i)===t.DOC_RANGE_TYPE.TEXT&&!e.collapsed&&e.endOffset+1===i.endOffset;return e.startOffset===i.startOffset&&(e.endOffset===i.endOffset||o)&&a}):Ka(e,n)}function Ka(e,n){if(n.length!==1||qa(n[0])!==t.DOC_RANGE_TYPE.TEXT)return!1;let r=n[0];if(r.startOffset==null||r.endOffset==null||e.some(e=>qa(e)!==t.DOC_RANGE_TYPE.TEXT||e.startOffset==null||e.endOffset==null))return!1;let i=Math.min(...e.map(e=>e.startOffset)),a=Math.max(...e.map(e=>e.endOffset));return i===r.startOffset&&a===r.endOffset&&e.every(e=>e.startOffset>=r.startOffset&&e.endOffset<=r.endOffset)}function qa(e){return e.rangeType??t.DOC_RANGE_TYPE.TEXT}var Ja=class extends t.RxDisposable{constructor(e){super(),this._context=e,R(this,`_previousActiveRange`,null),R(this,`_previousDocRanges`,[]),R(this,`_compositionRange`,null),R(this,`_previousSelectionOptions`,null),R(this,`_undoMutationParamsCache`,[]),R(this,`_redoMutationParamsCache`,[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:e=[],redoCache:t=[]}){this._undoMutationParamsCache=e,this._redoMutationParamsCache=t}getActiveRange(){return this._previousActiveRange}setActiveRange(e){this._previousActiveRange=e,this._compositionRange=e}getCompositionRange(){return this._compositionRange}setCompositionRange(e){this._compositionRange=e}getPreviousDocRanges(){return this._previousDocRanges}setPreviousDocRanges(e){this._previousDocRanges=e}getPreviousSelectionOptions(){return this._previousSelectionOptions}setPreviousSelectionOptions(e){this._previousSelectionOptions=e}pushUndoRedoMutationParams(e,t){this._undoMutationParamsCache.push(e),this._redoMutationParamsCache.push(t)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;let{unitId:e}=this._undoMutationParamsCache[0],n=this._undoMutationParamsCache[0],r=this._redoMutationParamsCache[this._redoMutationParamsCache.length-1],i={unitId:e,actions:this._undoMutationParamsCache.reverse().reduce((e,n)=>t.JSONX.compose(e,n.actions),null),textRanges:[],segmentId:n.segmentId,...n.layoutState===void 0?{}:{layoutState:n.layoutState}};return{redoMutationParams:{unitId:e,actions:this._redoMutationParamsCache.reduce((e,n)=>t.JSONX.compose(e,n.actions),null),textRanges:(r==null?void 0:r.textRanges)??[],segmentId:r==null?void 0:r.segmentId,...(r==null?void 0:r.layoutState)===void 0?{}:{layoutState:r.layoutState},options:r==null?void 0:r.options,isEditing:r==null?void 0:r.isEditing},undoMutationParams:i,previousActiveRange:this._previousActiveRange,previousDocRanges:this._previousDocRanges,previousSelectionOptions:this._previousSelectionOptions}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null,this._previousDocRanges=[],this._compositionRange=null,this._previousSelectionOptions=null}};let Ya={id:`doc.command.ime-input`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a,o,s,c,l;let{unitId:u,newText:d,oldTextLen:f,isCompositionEnd:p,isCompositionStart:m,isCompositionCanceled:h}=i,g=e.get(t.ICommandService),_=e.get(r.IRenderManagerService),v=e.get(t.IUniverInstanceService),y=e.get(U),b=(a=_.getRenderUnitById(u))==null?void 0:a.with(Ja),x=v.getUnit(u,t.UniverInstanceType.UNIVER_DOC);if(x==null||b==null)return!1;let S=b.getCompositionRange();if(S==null)return!1;if(h){let e=b.fetchComposedUndoRedoMutationParams();if(e==null)return!0;let{undoMutationParams:t,previousActiveRange:r,previousDocRanges:i,previousSelectionOptions:a}=e,o={...t,textRanges:i.length?i:[r],options:a??void 0,noHistory:!0,trigger:Ya.id};return!!g.syncExecuteCommand(n.RichTextEditingMutation.id,o)}let{style:C,segmentId:w}=S,T=(o=x.getSelfOrHeaderFooterModel(w))==null?void 0:o.getBody();if(T==null)return!1;Object.assign(S,S);let{startOffset:E,endOffset:D}=S,O=b.getPreviousDocRanges(),k=O.filter(Xa),A=O.filter(e=>!Xa(e)),j=((s=b.getPreviousSelectionOptions())==null?void 0:s.wholeDocument)===!0,F=m&&(j||k.length>0||A.length>1),I=F?j?0:Dn(A,k):E;if(I==null)return!1;let L=d.length,R=[{startOffset:I+L,endOffset:I+L,collapsed:!0,style:C,segmentId:w}],z={id:n.RichTextEditingMutation.id,params:{unitId:u,actions:[],textRanges:R,segmentId:w,trigger:Ya.id}},B=y.getDefaultStyle(),V=y.getStyleCache(),te=F?I:E+f,ne;if(!m&&f>0){var re;ne=((re=T.customRanges)==null?void 0:re.filter(e=>!e.wholeEntity&&e.startIndex<=E&&e.endIndex>=E+f-1))??[]}else{let e=ee(T.customRanges??[],te,t.SHEET_EDITOR_UNITS.includes(u));ne=e?[e]:[]}let H=m&&!F?N(T,{startOffset:E,endOffset:D},B,V,t.SHEET_EDITOR_UNITS.includes(u),((c=Be(x))==null?void 0:c.inheritParagraphStartStyle)===!0):M(T,F?I:E+f,B,V,t.SHEET_EDITOR_UNITS.includes(u),((l=Be(x))==null?void 0:l.inheritParagraphStartStyle)===!0),ie=P(T.customDecorations??[],te),W={dataStream:d,textRuns:H?[{...H,st:0,ed:d.length}]:[],customRanges:ne.map(e=>({...e,startIndex:0,endIndex:d.length-1})),customDecorations:ie.map(e=>({...e,startIndex:0,endIndex:d.length-1}))},ae=new t.TextX,oe=t.JSONX.getInstance();if(F){var se;let e=(se=_.getRenderUnitById(u))==null?void 0:se.with(n.DocSkeletonManagerService);if(!e)return!1;let t=En(A,k,x,e.getViewModel(),w??``,W,j);if(!t)return!1;I=t.insertOffset,z.params.actions=t.actions,z.params.textRanges=[{startOffset:I+L,endOffset:I+L,collapsed:!0,style:C,segmentId:w}]}else if(!S.collapsed&&m){let e=t.BuildTextUtils.selection.delete([S],T,0,null,!1);ae.push(...e),z.params.textRanges=[{startOffset:I+L,endOffset:I+L,collapsed:!0,segmentId:w}]}else ae.push({t:t.TextXActionType.RETAIN,len:E});if(!F&&f>0&&ae.push({t:t.TextXActionType.DELETE,len:f}),F||ae.push({t:t.TextXActionType.INSERT,body:W,len:d.length}),!F){let e=(0,t.getRichTextEditPath)(x,w);z.params.actions=oe.editOp(ae.serialize(),e)}z.params.noHistory=!p,z.params.isCompositionEnd=p;let ce=g.syncExecuteCommand(z.id,z.params);return b.pushUndoRedoMutationParams(ce,z.params),F&&b.setCompositionRange({...S,startOffset:I,endOffset:I,collapsed:!0}),!!ce}};function Xa(e){return`tableId`in e}let Za={id:`doc.command.insert-custom-range`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.ICommandService),{unitId:a,rangeId:o=(0,t.generateRandomId)(),textRanges:s,properties:c,text:l,wholeEntity:u}=r,d={unitId:a,historyAction:n.DocHistoryAction.InsertCustomRange,textRanges:s,body:{dataStream:l,customRanges:[{startIndex:0,endIndex:l.length-1,rangeId:o,rangeType:t.CustomRangeType.CUSTOM,properties:c,wholeEntity:u}]}};return i.syncExecuteCommand(Ne.id,d)}},Qa={id:`doc.command.list-operation`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),l=r.listType,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=r.docRange??o.getDocRanges()??[];if(u==null||d.length===0)return!1;let f=d[0].segmentId,p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(!m.length)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d,isEditing:!1}};new t.MemoryCursor().reset();let y=t.BuildTextUtils.paragraph.bullet.switch({paragraphs:g,listType:l,document:u,segmentId:f}),b=t.JSONX.getInstance(),x=(0,t.getRichTextEditPath)(u,f);return v.params.actions=b.editOp(y.serialize(),x),!!c.syncExecuteCommand(v.id,v.params)}},$a={id:`doc.command.change-list-type`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),{listType:l}=r,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=r.docRange??o.getDocRanges();if(u==null||d==null||!d.length)return!1;let{segmentId:f}=d[0],p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(!m.length)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v=t.BuildTextUtils.paragraph.bullet.set({paragraphs:g,listType:l,segmentId:f,document:u});if(!v)return!1;let y=t.JSONX.getInstance(),b={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d,isEditing:!1}},x=(0,t.getRichTextEditPath)(u,f);return b.params.actions=y.editOp(v.serialize(),x),!!c.syncExecuteCommand(b.id,b.params)}},eo=function(e){return e[e.increase=1]=`increase`,e[e.decrease=-1]=`decrease`,e}({}),to={id:`doc.command.change-list-nesting-level`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let{type:o}=r,s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(t.ICommandService),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(u==null||d==null)return!1;let{segmentId:f}=d,p=s.getDocRanges()??[],m=u.getSelfOrHeaderFooterModel(f),h=(m==null||(i=m.getBody())==null?void 0:i.paragraphs)??[],g=(m==null||(a=m.getBody())==null?void 0:a.dataStream)??``;if(!h.length)return!1;let _=t.BuildTextUtils.range.getParagraphsInRange(d,h,g),v=u.getUnitId(),y=t.JSONX.getInstance(),b=t.BuildTextUtils.paragraph.bullet.changeNestLevel({paragraphs:_,type:o,segmentId:f,document:u}),x={id:n.RichTextEditingMutation.id,params:{unitId:v,actions:[],textRanges:p,isEditing:!1}},S=(0,t.getRichTextEditPath)(u,f);return x.params.actions=y.editOp(b.serialize(),S),!!l.syncExecuteCommand(x.id,x.params)}},no={id:`doc.command.bullet-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.BULLET_LIST,docRange:n==null?void 0:n.docRange})}},ro={id:`doc.command.check-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.CHECK_LIST,docRange:n==null?void 0:n.docRange})}},io={id:`doc.command.toggle-check-list`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i;if(!r)return!1;let a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),{index:s,segmentId:c,textRanges:l}=r,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(u==null||((i=u.getSelfOrHeaderFooterModel(c))==null||(i=i.getBody())==null?void 0:i.paragraphs)==null)return!1;let d=u.getUnitId(),f={id:n.RichTextEditingMutation.id,params:{unitId:d,actions:[],textRanges:l??[],segmentId:c,isEditing:!1}},p=t.BuildTextUtils.paragraph.bullet.toggleChecklist({document:u,paragraphIndex:s,segmentId:c});if(!p)return!1;let m=t.JSONX.getInstance(),h=(0,t.getRichTextEditPath)(u,c);return f.params.actions=m.editOp(p.serialize(),h),!!o.syncExecuteCommand(f.id,f.params)}},ao={id:`doc.command.order-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.ORDER_LIST,docRange:n==null?void 0:n.docRange})}},oo={id:`doc.command.quick-list`,type:t.CommandType.COMMAND,handler(e,r){var i;if(!r)return!1;let a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),s=e.get(t.ICommandService),c=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=a.getActiveTextRange();if(c==null||l==null)return!1;let{segmentId:u,startOffset:d}=l,{listType:f,paragraph:p}=r,{paragraphStart:m,paragraphEnd:h}=p,g=new t.TextX,_=t.JSONX.getInstance(),{paragraphStyle:v={}}=p,y=(t.PRESET_LIST_TYPE[f].nestingLevel[0].paragraphProperties||{}).textStyle,b=(0,t.generateRandomId)(6),x=((i=c.getBody())==null?void 0:i.paragraphs)??[],S=x.findIndex(e=>e.startIndex===p.startIndex),C=x[S-1],w=x[S+1];C&&C.bullet&&C.bullet.listType.indexOf(f)===0?b=C.bullet.listId:w&&w.bullet&&w.bullet.listType.indexOf(f)===0&&(b=w.bullet.listId);let T={id:n.RichTextEditingMutation.id,params:{unitId:c.getUnitId(),actions:[],textRanges:[{startOffset:m,endOffset:m,collapsed:!0}],isEditing:!1}};g.push({t:t.TextXActionType.RETAIN,len:m}),g.push({t:t.TextXActionType.DELETE,len:d-m}),h>d&&g.push({t:t.TextXActionType.RETAIN,len:h-d}),g.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:p.paragraphId,paragraphStyle:{...v,textStyle:{...v.textStyle,...y},indentFirstLine:void 0},bullet:{...p.bullet??{nestingLevel:0},listType:f,listId:b}}]}});let E=(0,t.getRichTextEditPath)(c,u);return T.params.actions=_.editOp(g.serialize(),E),!!s.syncExecuteCommand(T.id,T.params)}};function so(e,r,i){let a=e.get(t.ICommandService),o=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!o)return!1;let s=null;try{s=e.get(n.DocContentInsertService).consumeInsertRange(o.getUnitId())}catch{s=null}let c=s?null:Fn(e);if(!s&&!c)return!1;let l=c||void 0,u=(s==null?void 0:s.startOffset)??l.startIndex+1,d=l==null?void 0:l.bullet,f=t.BuildTextUtils.selection.replace({doc:o,selection:{startOffset:u,endOffset:(s==null?void 0:s.endOffset)??u,collapsed:!0},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:(0,t.createParagraphId)(new Set),paragraphStyle:{...(l==null?void 0:l.paragraphStyle)??{}},bullet:{listType:r,listId:(d==null?void 0:d.listType)===r?d.listId:(0,t.generateRandomId)(6),nestingLevel:(d==null?void 0:d.listType)===r?d.nestingLevel:0}}]}});if(!f)return!1;let p={id:n.RichTextEditingMutation.id,params:{unitId:o.getUnitId(),actions:[],textRanges:[{startOffset:u,endOffset:u,collapsed:!0}],isEditing:!1,trigger:i}},m=t.JSONX.getInstance(),h=(0,t.getRichTextEditPath)(o);return p.params.actions=m.editOp(f.serialize(),h),!!a.syncExecuteCommand(p.id,p.params)}let co={id:`doc.command.insert-bullet-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.BULLET_LIST,co.id)},lo={id:`doc.command.insert-order-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.ORDER_LIST,lo.id)},uo={id:`doc.command.insert-check-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.CHECK_LIST,uo.id)},fo={id:`doc.command.align-action`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),{alignType:l}=r,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(u==null)return!1;let d=o.getDocRanges();if(d.length===0)return!1;let f=d[0].segmentId,p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(m==null)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v=g.every(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.horizontalAlign)===l}),y={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d}},b=new t.MemoryCursor;b.reset();let x=new t.TextX,S=t.JSONX.getInstance();for(let e of g){let{startIndex:n}=e;x.push({t:t.TextXActionType.RETAIN,len:n-b.cursor});let r={...e.paragraphStyle,horizontalAlign:v?t.HorizontalAlign.UNSPECIFIED:l};x.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...e,paragraphStyle:r,startIndex:0}]},coverType:t.UpdateDocsAttributeType.REPLACE}),b.moveCursorTo(n+1)}let C=(0,t.getRichTextEditPath)(u,f);return y.params.actions=S.editOp(x.serialize(),C),!!c.syncExecuteCommand(y.id,y.params)}},po={id:`doc.command.align-left`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.LEFT})},mo={id:`doc.command.align-center`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.CENTER})},ho={id:`doc.command.align-right`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.RIGHT})},go={id:`doc.command.align-justify`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.JUSTIFIED})},_o=(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r==null||r.setZoomRatio(n.zoomRatio),{...n}},vo={id:`doc.operation.set-zoom-ratio`,type:t.CommandType.OPERATION,handler:(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r?(r.setZoomRatio(n.zoomRatio),!0):!1}},yo={type:t.CommandType.COMMAND,id:`doc.command.set-zoom-ratio`,handler:async(e,n)=>{let r=e.get(t.ICommandService),i=e.get(t.IUndoRedoService),a=e.get(t.IUniverInstanceService),{zoomRatio:o=1,documentId:s}=n||{},c=s?a.getUnit(s,t.UniverInstanceType.UNIVER_DOC):a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!c)return!1;let l=c.getUnitId(),u={zoomRatio:o,unitId:l},d=_o(e,u);return r.syncExecuteCommand(vo.id,u)?(i.pushUndoRedo({unitID:l,undoMutations:[{id:vo.id,params:d}],redoMutations:[{id:vo.id,params:u}]}),!0):!1}};function bo(e){if(e>=t.NamedStyleType.HEADING_1&&e<=t.NamedStyleType.HEADING_5)return e-t.NamedStyleType.HEADING_1}let xo={id:`doc.command.set-paragraph-named-style`,type:t.CommandType.COMMAND,handler(e,r){if(!r)return!1;let i=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!i)return!1;let a=i.getUnitId(),o=e.get(n.DocSelectionManagerService),s=r.textRanges?null:(0,n.consumeContentInsertRange)(e,a);if(s)return So(e,i,r.value,s.startOffset,s.endOffset,s.segmentId);let c=r.textRanges??o.getTextRanges({unitId:a,subUnitId:a});if(!(c!=null&&c.length))return!1;let l=c[0].segmentId,u=i.getSelfOrHeaderFooterModel(l);if(!u)return!1;let d=t.BuildTextUtils.paragraph.style.set({document:u,textRanges:c,style:{namedStyleType:r.value,headingId:!r.value||r.value===t.NamedStyleType.NORMAL_TEXT?void 0:(0,t.generateRandomId)(6),outlineLevel:bo(r.value),spaceAbove:void 0,spaceBelow:void 0,lineSpacing:void 0,spacingRule:void 0},paragraphTextRun:{}}),f={id:n.RichTextEditingMutation.id,params:{actions:[],textRanges:c,unitId:a,segmentId:l}},p=t.JSONX.getInstance(),m=(0,t.getRichTextEditPath)(i,l);return f.params.actions=p.editOp(d.serialize(),m),!!e.get(t.ICommandService).syncExecuteCommand(f.id,f.params)}};function So(e,r,i,a,o,s=``){let c=t.BuildTextUtils.selection.replace({doc:r,selection:{startOffset:a,endOffset:o,collapsed:a===o,segmentId:s},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:(0,t.createParagraphId)(new Set),paragraphStyle:{namedStyleType:i,headingId:!i||i===t.NamedStyleType.NORMAL_TEXT?void 0:(0,t.generateRandomId)(6),outlineLevel:bo(i)}}]}});if(!c)return!1;let l=t.JSONX.getInstance(),u=!!e.get(t.ICommandService).syncExecuteCommand(n.RichTextEditingMutation.id,{actions:l.editOp(c.serialize(),(0,t.getRichTextEditPath)(r,s)),isEditing:!1,textRanges:[{startOffset:a,endOffset:a,collapsed:!0}],segmentId:s,unitId:r.getUnitId()});return u&&e.get(n.DocSelectionManagerService).replaceDocRanges([{startOffset:a,endOffset:a}],void 0,!1),u}let Co={id:`doc.command.quick-heading`,type:t.CommandType.COMMAND,handler(e,r){var i,a;if(!r)return!1;let{value:o}=r,s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(t.ICommandService),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(u==null||d==null||!d.collapsed)return!1;let{segmentId:f,startOffset:p}=d,m=u.getSelfOrHeaderFooterModel(f),h=(m==null||(i=m.getBody())==null?void 0:i.paragraphs)??[],g=(m==null||(a=m.getBody())==null?void 0:a.dataStream)??``,_=t.BuildTextUtils.paragraph.util.getParagraphsInRange(d,h,g)[0];if(!_)return!1;let{paragraphStart:v}=_,y=new t.TextX,b=t.JSONX.getInstance(),{paragraphStyle:x={}}=_,S={id:n.RichTextEditingMutation.id,params:{unitId:u.getUnitId(),actions:[],textRanges:[{startOffset:v,endOffset:v,collapsed:!0}],isEditing:!1}};y.push({t:t.TextXActionType.RETAIN,len:v}),t.BuildTextUtils.paragraph.style.set({textRanges:[d],document:u,style:{...x,headingId:(0,t.generateRandomId)(6),namedStyleType:o,outlineLevel:bo(o),lineSpacing:void 0,spacingRule:void 0},cursor:p,deleteLen:p-v,textX:y,paragraphTextRun:{}});let C=(0,t.getRichTextEditPath)(u,f);return S.params.actions=b.editOp(y.serialize(),C),!!l.syncExecuteCommand(S.id,S.params)}},wo={"#":t.NamedStyleType.HEADING_1,"##":t.NamedStyleType.HEADING_2,"###":t.NamedStyleType.HEADING_3,"####":t.NamedStyleType.HEADING_4,"#####":t.NamedStyleType.HEADING_5},To={id:`doc.command.h1-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_1})},Eo={id:`doc.command.h2-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_2})},Do={id:`doc.command.h3-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_3})},Oo={id:`doc.command.h4-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_4})},ko={id:`doc.command.h5-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_5})},Ao={id:`doc.command.normal-text-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.NORMAL_TEXT})},jo={id:`doc.command.title`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.TITLE})},Mo={id:`doc.command.subtitle-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.SUBTITLE})},No={id:`doc.command.switch-mode`,type:t.CommandType.COMMAND,handler:e=>{var i,a;let o=e.get(t.ICommandService),s=e.get(r.IRenderManagerService),c=e.get(n.DocSelectionManagerService),l=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null)return!1;let u=l.getUnitId(),d=(i=s.getRenderUnitById(u))==null?void 0:i.with(n.DocSkeletonManagerService).getSkeleton(),f=(a=s.getRenderUnitById(u))==null?void 0:a.with(q);if(d==null||f==null)return!1;let p=f==null?void 0:f.getSegment(),m=f==null?void 0:f.getSegmentPage(),h=l.getSnapshot().documentStyle.documentFlavor,g=c.getDocRanges(),_={id:n.RichTextEditingMutation.id,params:{unitId:u,actions:[],textRanges:h===t.DocumentFlavor.TRADITIONAL&&p?[]:g}},v=t.JSONX.getInstance(),y=[],b;if(b=h===void 0?v.insertOp([`documentStyle`,`documentFlavor`],t.DocumentFlavor.MODERN):h===t.DocumentFlavor.MODERN?v.replaceOp([`documentStyle`,`documentFlavor`],h,t.DocumentFlavor.TRADITIONAL):v.replaceOp([`documentStyle`,`documentFlavor`],h,t.DocumentFlavor.MODERN),b)y.push(b);else return!1;if(h!==t.DocumentFlavor.MODERN){let{drawings:e={},body:n}=l.getSnapshot(),r=(n==null?void 0:n.customBlocks)??[];for(let n in e){var x,S;let i=e[n],a=r.find(e=>e.blockId===n);if(a==null)continue;let o=i.docTransform.positionV,{relativeFrom:s,posOffset:c}=o;if(s===t.ObjectRelativeFromV.PARAGRAPH)continue;let{startIndex:l}=a,u=d.findNodeByCharIndex(l,p,m),f=u==null||(x=u.parent)==null?void 0:x.parent,h=f==null?void 0:f.parent,g=h==null?void 0:h.lines.find(e=>e.paragraphIndex===(f==null?void 0:f.paragraphIndex)&&e.paragraphStart),_=h==null||(S=h.parent)==null?void 0:S.parent;if(u==null||f==null||g==null||h==null||_==null)continue;let b=0;s===t.ObjectRelativeFromV.LINE?b-=f.top:s===t.ObjectRelativeFromV.PAGE&&(b+=_.marginTop),b+=g.top;let C={...o,relativeFrom:t.ObjectRelativeFromV.PARAGRAPH,posOffset:(c??0)-b},w=v.replaceOp([`drawings`,n,`docTransform`,`positionV`],o,C);w&&y.push(w)}}return _.params.actions=y.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(_.id,_.params)}};function Po(e){let{tableDataStream:n,tableParagraphs:r,sectionBreaks:i,tableId:a,textRun:o}=e,s=e.existingParagraphIds??new Set(r.map(e=>e.paragraphId)),c=`${n}${t.DataStreamTreeTokenType.PARAGRAPH}`,l=n.length;return{dataStream:c,paragraphs:[...r,{startIndex:l,paragraphId:(0,t.createParagraphId)(s)}],sectionBreaks:i,textRuns:[{...o,st:0,ed:l}],tables:[{startIndex:0,endIndex:l,tableId:a}]}}function Fo(e,n){return n<=0||e.dataStream[n-1]!==t.DataStreamTreeTokenType.PARAGRAPH}function Io(e,n){return n===0&&e.dataStream[0]===t.DataStreamTreeTokenType.PARAGRAPH?1:n}function Lo(e,t){return!(Ro(e.tables,t)||zo(e.blockRanges,t)||Bo(e.customBlocks,t))}function Ro(e,n){return!!(e!=null&&e.some(e=>(0,t.containsInteriorInsertionOffset)((0,t.getTableRangeInterval)(e),n)))}function zo(e,n){return!!(e!=null&&e.some(e=>(0,t.containsInteriorInsertionOffset)((0,t.getBlockRangeInterval)(e),n)))}function Bo(e,t){return!!(e!=null&&e.some(e=>e.startIndex===t))}let Vo={id:`doc.command.create-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i,a,o;let{rowCount:s,colCount:c}=r,l=e.get(n.DocSelectionManagerService),u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=e.get(U),p=u.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(p==null)return!1;let m=null;try{m=e.get(n.DocContentInsertService).consumeInsertRange(p.getUnitId())}catch{m=null}let h=l.getActiveTextRange();if(h==null&&m==null)return!1;let g=(m==null?void 0:m.segmentId)??(h==null?void 0:h.segmentId)??``,_=h==null?void 0:h.segmentPage,v=p==null||(i=p.getSelfOrHeaderFooterModel(g))==null?void 0:i.getBody();if(v==null)return!1;let y=p.getUnitId(),b=Te(e,y),x=b==null?void 0:b.getSkeleton();if(x==null)return!1;let S=Io(v,(m==null?void 0:m.startOffset)??h.startOffset);if(!Lo(v,S))return!1;let C=(v.paragraphs??[]).find(e=>(0,t.getParagraphContentStartOffset)(v,e)<S&&S<=e.startIndex),w=x.findNodeByCharIndex(S,g,_);if(w==null)return!1;let T=Fo(v,S),E=new t.TextX,D=t.JSONX.getInstance(),O=[],k=S+(T?4:3),A=[{startOffset:k,endOffset:k,collapsed:!0}],M={id:n.RichTextEditingMutation.id,params:{unitId:y,actions:[],textRanges:A}};S>0&&E.push({t:t.TextXActionType.RETAIN,len:S}),T&&E.push({t:t.TextXActionType.INSERT,body:{dataStream:t.DataStreamTreeTokenType.PARAGRAPH,paragraphs:(0,n.generateParagraphs)(t.DataStreamTreeTokenType.PARAGRAPH,C)},len:1});let N=j(v,S,f.getDefaultStyle(),f.getStyleCache()),{dataStream:ee,paragraphs:P,sectionBreaks:F}=qt(s,c),I=(a=w.parent)==null||(a=a.parent)==null||(a=a.parent)==null||(a=a.parent)==null?void 0:a.parent;if(I==null)return!1;let{pageWidth:L,marginLeft:R,marginRight:z}=I,B=Zt(s,c,L-R-z),V=Po({tableDataStream:ee,tableParagraphs:P,sectionBreaks:F,tableId:B.tableId,textRun:N,existingParagraphIds:new Set((o=v.paragraphs)==null?void 0:o.map(e=>e.paragraphId))});E.push({t:t.TextXActionType.INSERT,body:V,len:V.dataStream.length});let te=(0,t.getRichTextEditPath)(p,g);O.push(D.editOp(E.serialize(),te));let ne=D.insertOp([`tableSource`,B.tableId],B);return O.push(ne),M.params.actions=O.reduce((e,n)=>t.JSONX.compose(e,n),null),!!d.syncExecuteCommand(M.id,M.params)}},Ho={id:`doc.table.delete-rows`,type:t.CommandType.COMMAND,handler:async e=>{var r;let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=i.getRectRanges(),c=Qt(i.getActiveTextRange(),s);if(c==null)return!1;let{segmentId:l}=c,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=u==null||(r=u.getSelfOrHeaderFooterModel(l))==null?void 0:r.getBody();if(u==null||d==null)return!1;let f=Te(e,u.getUnitId());if(f==null)return!1;let p=f.getViewModel(),m=u==null?void 0:u.getUnitId(),h=new t.TextX,g=t.JSONX.getInstance(),_=on(c,p);if(_==null)return!1;let{offset:v,rowIndexes:y,len:b,tableId:x,cursor:S,selectWholeTable:C}=_;if(C)return o.executeCommand(Wo.id);let w=[],T=[{startOffset:S,endOffset:S,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:T,segmentId:l,trigger:Ho.id}};v>0&&h.push({t:t.TextXActionType.RETAIN,len:v}),h.push({t:t.TextXActionType.DELETE,len:b});let D=(0,t.getRichTextEditPath)(u,l);w.push(g.editOp(h.serialize(),D));for(let e of y.reverse()){let t=g.removeOp([`tableSource`,x,`tableRows`,e]);w.push(t)}return E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(E.id,E.params)}},Uo={id:`doc.table.delete-columns`,type:t.CommandType.COMMAND,handler:async e=>{var r;let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=i.getRectRanges(),c=Qt(i.getActiveTextRange(),s);if(c==null)return!1;let{segmentId:l}=c,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=u==null||(r=u.getSelfOrHeaderFooterModel(l))==null?void 0:r.getBody();if(u==null||d==null)return!1;let f=Te(e,u.getUnitId());if(f==null)return!1;let p=f.getViewModel(),m=u==null?void 0:u.getUnitId(),h=new t.TextX,g=t.JSONX.getInstance(),_=sn(c,p);if(_==null)return!1;let{offsets:v,columnIndexes:y,tableId:b,cursor:x,rowCount:S,selectWholeTable:C}=_;if(C)return o.executeCommand(Wo.id);let w=[],T=[{startOffset:x,endOffset:x,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:T,segmentId:l,trigger:Uo.id}};for(let e of v){let{retain:n,delete:r}=e;n>0&&h.push({t:t.TextXActionType.RETAIN,len:n}),h.push({t:t.TextXActionType.DELETE,len:r})}let D=(0,t.getRichTextEditPath)(u,l);w.push(g.editOp(h.serialize(),D)),y.reverse();for(let e=0;e<S;e++)for(let t of y){let n=g.removeOp([`tableSource`,b,`tableRows`,e,`tableCells`,t]);w.push(n)}for(let e of y){let t=g.removeOp([`tableSource`,b,`tableColumns`,e]);w.push(t)}return E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(E.id,E.params)}},Wo={id:`doc.table.delete-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i;let a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),s=e.get(t.ICommandService),c=a.getRectRanges(),l=a.getActiveTextRange(),u=Qt((r==null?void 0:r.targetRange)??l,r!=null&&r.targetRange?[]:c);if(u==null)return!1;let{segmentId:d}=u,f=r!=null&&r.unitId?o.getUnit(r.unitId,t.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=f==null||(i=f.getSelfOrHeaderFooterModel(d))==null?void 0:i.getBody();if(f==null||p==null)return!1;let m=Te(e,f.getUnitId());if(m==null)return!1;let h=m.getViewModel(),g=f==null?void 0:f.getUnitId(),_=new t.TextX,v=t.JSONX.getInstance(),y=cn(u,h);if(y==null)return!1;let{offset:b,len:x,tableId:S,cursor:C}=y,w=[],T=[{startOffset:C,endOffset:C,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:T,segmentId:d,trigger:Wo.id}};b>0&&_.push({t:t.TextXActionType.RETAIN,len:b}),_.push({t:t.TextXActionType.DELETE,len:x});let D=(0,t.getRichTextEditPath)(f,d);w.push(v.editOp(_.serialize(),D));let O=v.removeOp([`tableSource`,S]);return w.push(O),E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!s.syncExecuteCommand(E.id,E.params)}},Go=`doc.command.table-insert-row`,Ko=`doc.command.table-insert-column`,qo={id:`doc.command.table-insert-row-above`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Go,{position:0})},Jo={id:`doc.command.table-insert-row-bellow`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Go,{position:1})},Yo={id:`doc.command.table-insert-column-left`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Ko,{position:0})},Xo={id:`doc.command.table-insert-column-right`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Ko,{position:1})},Zo={id:Go,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i;let{position:a}=r,o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),l=o.getRectRanges(),u=Qt(o.getActiveTextRange(),l);if(u==null)return!1;let{segmentId:d}=u,f=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=f==null||(i=f.getSelfOrHeaderFooterModel(d))==null?void 0:i.getBody();if(f==null||p==null)return!1;let m=Te(e,f.getUnitId());if(m==null)return!1;let h=m.getViewModel(),g=f==null?void 0:f.getUnitId(),_=new t.TextX,v=t.JSONX.getInstance(),y=nn(u,a,h);if(y==null)return!1;let{offset:b,colCount:x,tableId:S,insertRowIndex:C}=y,w=[],T=b+2,E=[{startOffset:T,endOffset:T,collapsed:!0}],D={id:n.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:E}};b>0&&_.push({t:t.TextXActionType.RETAIN,len:b});let O=en(x);_.push({t:t.TextXActionType.INSERT,body:O,len:O.dataStream.length});let k=(0,t.getRichTextEditPath)(f,d);w.push(v.editOp(_.serialize(),k));let A=Yt(x),j=v.insertOp([`tableSource`,S,`tableRows`,C],A);return w.push(j),D.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!c.syncExecuteCommand(D.id,D.params)}},Qo={id:Ko,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i,a,o;let{position:s}=r,c=e.get(n.DocSelectionManagerService),l=e.get(t.IUniverInstanceService),u=e.get(t.ICommandService),d=c.getRectRanges(),f=Qt(c.getActiveTextRange(),d);if(f==null)return!1;let{segmentId:p}=f,m=l.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),h=m==null||(i=m.getSelfOrHeaderFooterModel(p))==null?void 0:i.getBody();if(m==null||h==null)return!1;let g=Te(e,m.getUnitId());if(g==null)return!1;let _=g.getViewModel(),v=m==null?void 0:m.getUnitId(),y=new t.TextX,b=t.JSONX.getInstance(),x=rn(f,s,_);if(x==null)return!1;let{offsets:S,columnIndex:C,tableId:w,rowCount:T}=x,E=[],D=S[0]+1,O=[{startOffset:D,endOffset:D,collapsed:!0}],k={id:n.RichTextEditingMutation.id,params:{unitId:v,actions:[],textRanges:O}};for(let e of S){y.push({t:t.TextXActionType.RETAIN,len:e});let n=tn();y.push({t:t.TextXActionType.INSERT,body:n,len:n.dataStream.length})}let A=(0,t.getRichTextEditPath)(m,p);E.push(b.editOp(y.serialize(),A));for(let e=0;e<T;e++){let t=Jt(),n=b.insertOp([`tableSource`,w,`tableRows`,e,`tableCells`,C],t);E.push(n)}let j=m.getSnapshot(),M=j.documentStyle,{marginLeft:N=0,marginRight:ee=0}=M,P=j==null||(a=j.tableSource)==null||(a=a[w])==null?void 0:a.tableColumns;if(!P)return!1;let F=(((o=M.pageSize)==null?void 0:o.width)??800)-N-ee,I=P.reduce((e,t)=>e+t.size.width.v,0),{newColWidth:L,widths:R}=an(I>0?I:F,P,C);for(let e=0;e<R.length;e++){let t=b.replaceOp([`tableSource`,w,`tableColumns`,e,`size`,`width`,`v`],P[e].size.width.v,R[e]);E.push(t)}let z=Xt(L),B=b.insertOp([`tableSource`,w,`tableColumns`,C],z);return E.push(B),k.params.actions=E.reduce((e,n)=>t.JSONX.compose(e,n),null),!!u.syncExecuteCommand(k.id,k.params)}},$o={id:`doc.table.tab-in-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let{shift:i}=r,a=e.get(n.DocSelectionManagerService),o=a.getDocRanges(),s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!c)return!1;let l=o.find(e=>e.isActive)??o[0],u=Te(e,c.getUnitId()),d=u==null?void 0:u.getSkeleton(),f=d==null?void 0:d.getViewModel().getSelfOrHeaderFooterViewModel(l==null?void 0:l.segmentId);if(f==null||l==null)return!1;let p=null;if(p=i?un(f,l,1):un(f,l,0),p){let{startOffset:e,endOffset:t}=p,n=[{startOffset:e,endOffset:t}];return a.replaceDocRanges(n),!0}return i!==!1||await s.executeCommand(Zo.id,{position:1})}},es=`COMPONENT_DOC_CREATE_TABLE_CONFIRM`,ts=`doc.component.create-table-confirm`,ns={id:`doc.operation.create-table`,type:t.CommandType.COMMAND,handler:async e=>{let n=e.get(t.LocaleService),r=e.get(t.IConfirmService),i=e.get(t.ICommandService),a={rowCount:3,colCount:5};return await r.open({id:ts,children:{label:{name:es,props:{handleRowColChange:(e,t)=>{a.rowCount=e,a.colCount=t},tableCreateParams:a}}},width:`auto`,title:{title:n.t(`docs-ui.toolbar.table.insert`)},onConfirm:()=>{i.executeCommand(Vo.id,a),r.close(ts)},onClose:()=>{r.close(ts)}}),!0}},rs={id:`doc.operation.move-cursor`,type:t.CommandType.OPERATION,handler:(e,t)=>!!t},is={id:`doc.operation.move-selection`,type:t.CommandType.OPERATION,handler:(e,t)=>!!t},as=`docs-ui.config`,os=`DOC_UI_PLUGIN`,ss={mode:`none`,target:`viewport`,paddingX:20,minScale:1,maxScale:void 0,align:`center`},cs={toc:!1,footer:!0,wordCount:!0,placeholder:!0,fitToWidth:ss},ls={...cs,fitToWidth:{...ss,mode:`fit-width`,paddingX:12,minScale:0,maxScale:1}},us=1.5,ds=class extends t.RxDisposable{constructor(e,t,n,r){super(),this._context=e,this._textSelectionManagerService=t,this._editorService=n,this._docSkeletonManagerService=r,R(this,`_pendingSelectionScrollFrame`,null),R(this,`_suppressedSelection`,null),R(this,`_pendingExplicitRange`,null),R(this,`_selectionBeforeExplicitRange`,null),R(this,`_scrollingToRange`,!1),this._init()}_init(){let e=this._context.scene.getViewport(`viewMain`);if(e!=null){let t=e.viewportScrollX,n=e.viewportScrollY;this.disposeWithMe(e.onScrollAfter$.subscribeEvent(e=>{let r=e.viewportScrollX!==t||e.viewportScrollY!==n;t=e.viewportScrollX,n=e.viewportScrollY,r&&!this._scrollingToRange&&this._suspendSelectionScroll()}))}this.disposeWithMe(this._context.scene.onPointerDown$.subscribeEvent(()=>this._suspendSelectionScroll())),this._textSelectionManagerService.textSelection$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;let{isEditing:n,unitId:r}=e,i=e.textRanges.find(e=>e.isActive);if(r!==this._context.unitId)return;if(!n){if(this._ownsPendingExplicitRange(i))return;this._suspendSelectionScroll();return}if(this._context.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||this._ownsPendingExplicitRange(i))return;this._clearExplicitRangeOwnership();let a=this._suppressedSelection;(i==null||a==null||i.startOffset!==a.startOffset||i.endOffset!==a.endOffset||(i.segmentId??``)!==(a.segmentId??``)||(i.segmentPage??-1)!==(a.segmentPage??-1))&&(this._suppressedSelection=null,this._scheduleScrollToSelection())})}dispose(){this._cancelPendingSelectionScroll(),this._suppressedSelection=null,this._clearExplicitRangeOwnership(),super.dispose()}_suspendSelectionScroll(){this._cancelPendingSelectionScroll(),this._clearExplicitRangeOwnership();let e=this._textSelectionManagerService.getActiveTextRange();this._suppressedSelection=e==null?null:{startOffset:e.startOffset,endOffset:e.endOffset,collapsed:e.collapsed,segmentId:e.segmentId,segmentPage:e.segmentPage}}_cancelPendingSelectionScroll(){this._pendingSelectionScrollFrame!=null&&typeof cancelAnimationFrame<`u`&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=null}_scheduleScrollToSelection(){if(typeof requestAnimationFrame>`u`){this._scrollToSelection();return}this._pendingSelectionScrollFrame!=null&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=requestAnimationFrame(()=>{this._pendingSelectionScrollFrame=null,this._scrollToSelection()})}scrollToRange(e,t){this._cancelPendingSelectionScroll(),this._pendingExplicitRange??(this._selectionBeforeExplicitRange=this._textSelectionManagerService.getActiveTextRange()),this._pendingExplicitRange=e,this._scrollingToRange=!0;try{this._scrollToRange(e,t)}finally{this._scrollingToRange=!1,this._pendingSelectionScrollFrame??this._clearExplicitRangeOwnership()}}_isSameRange(e,t){return e!=null&&t!=null&&e.startOffset===t.startOffset&&e.endOffset===t.endOffset&&(e.segmentId??``)===(t.segmentId??``)&&(e.segmentPage??-1)===(t.segmentPage??-1)}_ownsPendingExplicitRange(e){return this._pendingExplicitRange!=null&&(e==null||this._isSameRange(e,this._pendingExplicitRange)||this._isSameRange(e,this._selectionBeforeExplicitRange))}_clearExplicitRangeOwnership(){this._pendingExplicitRange=null,this._selectionBeforeExplicitRange=null}_scrollToRange(e,t){var n;let i=this._docSkeletonManagerService.getSkeleton();if(!i)return;if(!this.isViewportReady()){this._scheduleScrollToReadyRange(e,0,t);return}let{startOffset:a,segmentId:o,segmentPage:s}=e,c=i.findNodePositionByCharIndex(a,!0,o??``,s??-1);if(c==null){this._deferUnresolvedRange(i,e,t);return}let l=(n=i.getSkeletonData())==null?void 0:n.pages,u=c.pageType===r.DocumentSkeletonPageType.HEADER||c.pageType===r.DocumentSkeletonPageType.FOOTER||c.pageType===r.DocumentSkeletonPageType.CELL&&(l==null?void 0:l[c.page])==null?c.segmentPage:c.page,d=l==null?void 0:l[u];d==null||d.isLayoutPlaceholder||(this.scrollToNode(c),t==null||t())}_deferUnresolvedRange(e,t,n){var r;let i=e.findBodyPageIndexByCharIndex(t.startOffset),a=(r=e.getSkeletonData())==null?void 0:r.pages[i];a!=null&&a.isMaterializationPlaceholder?(this._scrollToPage(i),this._scheduleScrollToReadyRange(t,0,n)):i<0&&this._isValidBodyOffset(e,t.startOffset)&&this._scheduleScrollToReadyRange(t,0,n)}_scheduleScrollToReadyRange(e,t=0,n){typeof requestAnimationFrame>`u`||t>=6e3||(this._pendingSelectionScrollFrame!=null&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=requestAnimationFrame(()=>{this._pendingSelectionScrollFrame=null;let r=this._docSkeletonManagerService.getSkeleton(),i=r.findBodyPageIndexByCharIndex(e.startOffset);if(!this.isViewportReady()||i<0&&this._isValidBodyOffset(r,e.startOffset)){this._scheduleScrollToReadyRange(e,t+1,n);return}this.scrollToRange(e,n)}))}_isValidBodyOffset(e,t){var n;let r=((n=e.getViewModel().getDataModel().getBody())==null?void 0:n.dataStream.length)??0;return t>=0&&t<r}isViewportReady(){let{mainComponent:e,scene:t}=this._context;if(!(e instanceof r.Documents))return!0;let{docsLeft:n,docsTop:i}=e.getOffsetConfig();if(n<=-1e4||i<=-1e4)return!1;let a=t.getViewport(`viewMain`);if(a==null)return!0;let o=a.calcViewportInfo().viewBound;return o.right-o.left>1&&o.bottom-o.top>1}_scrollToPage(e){var t;let{mainComponent:n,scene:i}=this._context,a=(t=this._docSkeletonManagerService.getSkeleton().getSkeletonData())==null?void 0:t.pages;if(!(n instanceof r.Documents)||a==null||a[e]==null)return;let o=i.getViewport(`viewMain`);if(o==null)return;let{docsLeft:s,docsTop:c,pageLayoutType:l=r.PageLayoutType.VERTICAL,pageMarginLeft:u,pageMarginTop:d}=n.getOffsetConfig(),f=s,p=c;for(let t=0;t<e;t++)l===r.PageLayoutType.HORIZONTAL?f+=a[t].pageWidth+u:p+=a[t].pageHeight+d;let m=o.calcViewportInfo().viewBound,h=l===r.PageLayoutType.HORIZONTAL?f-m.left:0,g=l===r.PageLayoutType.HORIZONTAL?0:p-m.top;o.scrollByBarDeltaValue(o.transViewportScroll2ScrollValue(h,g))}scrollToNode(e){let{unitId:t,scene:n,mainComponent:i}=this._context,a=this._docSkeletonManagerService.getSkeleton();if(!(i instanceof r.Documents)||a==null)return;let o=i.getOffsetConfig(),{docsLeft:s,docsTop:c}=o,{contentBoxPointGroup:l}=new Ze(o,a).getRangePointData(e,e);if(l.length===0)return;let{left:u,top:d,height:f}=Ct(l),p=u+s,m=d+c,h=n.getViewport(`viewMain`);if(h==null)return;let{left:g,top:_,right:v,bottom:y}=h.calcViewportInfo().viewBound,b=0,x=0,S=this._editorService.getEditorRenderConfig(t);if(S!=null&&S.disableBackScroll)return;let C=S?S.backScrollOffset??0:100;if(b=this._getVerticalScrollDelta(m,f,_,y,C),p<g?x=p-g:p>v-us&&(x=p-v+us),x===0&&b===0)return;let w=h.transViewportScroll2ScrollValue(x,b);h.scrollByBarDeltaValue(w)}_getVerticalScrollDelta(e,t,n,r,i){return e<n?e-n-i:e>r-t?e-r+t+i:0}_scrollToSelection(){let e=this._textSelectionManagerService.getActiveTextRange();if(e==null)return;let{collapsed:t}=e;t&&this.scrollToRange(e)}};ds=B([z(1,(0,t.Inject)(n.DocSelectionManagerService)),z(2,J),z(3,(0,t.Inject)(n.DocSkeletonManagerService))],ds);let fs=`gray.300`,ps=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._context=e,this._localeService=t,this._docSelectionManagerService=n,this._configService=r,this._themeService=i,this._initParagraphPlaceholderRender()}_initParagraphPlaceholderRender(){let e=this._configService.getConfig(as);if(!ms(this._context.unit,this._context.unitId,e))return;let t=this._context.mainComponent;t&&(this.disposeWithMe(t.pageRender$.subscribe(e=>this._drawPagePlaceholders(e))),this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({unitId:e})=>{e===this._context.unitId&&t.makeDirty(!0)})))}_drawPagePlaceholders({page:e,pageLeft:t,pageTop:n,ctx:r}){var i,a;let o=(i=this._context.unit.getSelfOrHeaderFooterModel(e.segmentId))==null?void 0:i.getBody();if(!o)return;let s=this._docSelectionManagerService.getActiveTextRange();if(!s||(s.segmentId??``)!==(e.segmentId??``)||s.startOffset==null||s.endOffset==null||s.startOffset!==s.endOffset)return;let c=hs(e,o,this._getLocale(),t,n,s.startOffset,{docsLeft:(a=this._context.mainComponent)==null?void 0:a.getOffsetConfig().docsLeft,unitId:this._context.unitId});c.length&&Ts(r,c,this._themeService.darkMode?`gray.400`:fs)}_getLocale(){return{heading1:this._localeService.t(`docs-ui.placeholder.heading1`),heading2:this._localeService.t(`docs-ui.placeholder.heading2`),heading3:this._localeService.t(`docs-ui.placeholder.heading3`),heading4:this._localeService.t(`docs-ui.placeholder.heading4`),heading5:this._localeService.t(`docs-ui.placeholder.heading5`),listItem:this._localeService.t(`docs-ui.placeholder.listItem`),normalText:this._localeService.t(`docs-ui.placeholder.normalText`)}}};ps=B([z(1,(0,t.Inject)(t.LocaleService)),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,t.IConfigService),z(4,(0,t.Inject)(t.ThemeService))],ps);function ms(e,n,r){var i;return(r==null?void 0:r.placeholder)===!1||(0,t.isInternalEditorID)(n)?!1:((i=e.getSnapshot().documentStyle)==null?void 0:i.documentFlavor)===t.DocumentFlavor.MODERN}function hs(e,t,n,i=0,a=0,o,s){var c;let l=new Map((t.paragraphs??[]).map(e=>[e.startIndex,e])),u=[],d=(e,r,i,a)=>{for(let s of e.columns)gs(s,t,l,n,u,r+s.left,i+e.top,o,a)};for(let t of e.sections)d(t,i+e.marginLeft,a+e.marginTop);return(c=e.skeTables)==null||c.forEach((t,n)=>{let o=(0,r.getTableIdAndSliceIndex)(t.tableId??n).tableId,c=(0,r.getDocsTableRenderViewport)((s==null?void 0:s.unitId)??``,o),l=c!=null&&(c.leadingInsetLeft??0)+c.contentWidth+(c.trailingInsetRight??0)>c.viewportWidth,u=i+e.marginLeft+t.left,f=l?(0,r.getDocsTableViewportLeft)(c,u-(c.leadingInsetLeft??0),s==null?void 0:s.docsLeft):u,p=f+(l?c.viewportWidth:t.width),m=l?c.scrollLeft:0;for(let n of t.rows)for(let r of n.cells){let i=u+r.left-m,o=i+r.marginLeft,s=i+r.pageWidth-r.marginRight,c=Math.max(o,f),l=Math.min(s,p);if(!(l<=c))for(let i of r.sections)d(i,o,a+e.marginTop+t.top+n.top+r.marginTop,{left:c,right:l})}}),u}function gs(e,t,n,r,i,a,o,s,c){for(let l of e.lines){if(!l.paragraphStart)continue;let e=l.st,u=l.paragraphIndex;if(!_s(s,e,u))continue;let d=n.get(u);if(!d||!bs(t.dataStream,l.st,l.paragraphIndex))continue;let f=vs(d,r);f&&i.push(ys(l,d,f,a,o,c))}}function _s(e,t,n){return t<=e&&e<=n}function vs(e,n){var r;if(e.bullet)return n.listItem;switch((r=e.paragraphStyle)==null?void 0:r.namedStyleType){case t.NamedStyleType.HEADING_1:return n.heading1;case t.NamedStyleType.HEADING_2:return n.heading2;case t.NamedStyleType.HEADING_3:return n.heading3;case t.NamedStyleType.HEADING_4:return n.heading4;case t.NamedStyleType.HEADING_5:return n.heading5;default:return n.normalText}}function ys(e,n,r,i,a,o){var s;let c=e.divides[0],l=((c==null?void 0:c.glyphGroup)??[])[0],u=((s=n.paragraphStyle)==null?void 0:s.namedStyleType)??t.NamedStyleType.NORMAL_TEXT,d=t.NAMED_STYLE_MAP[u],f=Cs(e,n),p=ws(e)??`Arial`,m=d!=null&&d.bl?`bold`:`normal`,h=i+((c==null?void 0:c.left)??0)+((c==null?void 0:c.paddingLeft)??0),g=n.bullet&&l?l.left+l.width+4:0,_=h+g,v=Math.max(0,((c==null?void 0:c.width)??e.width??0)-g),y=Math.max(_,(o==null?void 0:o.left)??_),b=Math.min(_+v,(o==null?void 0:o.right)??_+v),x=a+e.top;return{clipBottom:x+e.lineHeight,clipLeft:y,clipRight:b,clipTop:x,fontFamily:p,fontSize:f,fontWeight:m,maxWidth:Math.max(0,b-y),text:r,x:_,y:a+e.top+e.marginTop+e.paddingTop+e.asc}}function bs(e,t,n){return xs((e==null?void 0:e.slice(t,n))??``).trim()===``}function xs(e){return e.replaceAll(t.DataStreamTreeTokenType.PARAGRAPH,``).replaceAll(t.DataStreamTreeTokenType.SECTION_BREAK,``).replaceAll(t.DataStreamTreeTokenType.DOCS_END,``)}function Ss(e){for(let i of e.divides)for(let e of i.glyphGroup){var t,n,r;let i=((t=e.fontStyle)==null?void 0:t.originFontSize)??((n=e.fontStyle)==null?void 0:n.fontSize)??((r=e.ts)==null?void 0:r.fs);if(i)return i}return null}function Cs(e,n){var r;let i=((r=n.paragraphStyle)==null?void 0:r.namedStyleType)??t.NamedStyleType.NORMAL_TEXT,a=t.NAMED_STYLE_MAP[i],o=Ss(e)??(a==null?void 0:a.fs)??12;return i===t.NamedStyleType.NORMAL_TEXT?Math.max(o,16):o}function ws(e){for(let r of e.divides)for(let e of r.glyphGroup){var t,n;let r=((t=e.fontStyle)==null?void 0:t.fontFamily)??((n=e.ts)==null?void 0:n.ff);if(r)return r}return null}function Ts(e,t,n=fs){e.save(),e.fillStyle=n,e.textBaseline=`alphabetic`;for(let n of t){let t=n.clipLeft??n.x,r=n.clipRight??n.x+n.maxWidth,i=n.clipTop??n.y-n.fontSize,a=n.clipBottom??n.y+n.fontSize;r<=t||a<=i||(e.save(),e.beginPath(),e.rectByPrecision(t,i,r-t,a-i),e.closePath(),e.clip(),e.font=`${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,e.fillText(n.text,n.x,n.y),e.restore())}e.restore()}var Es=class extends r.Documents{isHit(e){var t,n;if(!super.isHit(e))return!1;let i=this.getSkeleton(),a=this.layer;if(!(a!=null&&(t=this.getScene())!=null&&t.getLayers().some(t=>t.zIndex<a.zIndex&&t.getObjects().some(t=>!(t instanceof r.Documents)&&!(t instanceof r.DocBackground)&&!t.isInGroup&&t.visible&&t.evented&&t.isHit(e))))||!i)return!0;let o=this.getInverseCoord(e),s=i.findNodeByCoord(o,this.pageLayoutType,this.pageMarginLeft,this.pageMarginTop);if(s!=null&&(n=s.node.content)!=null&&n.trim()){let e=i.findPositionByGlyph(s.node,s.segmentPage);if(e){let{contentBoxPointGroup:t}=new Ze(this.getOffsetConfig(),i).getRangePointData({...e,isBack:!0},{...e,isBack:!1});if(t.some(e=>o.x>=e[0].x&&o.x<=e[2].x&&o.y>=e[0].y&&o.y<=e[2].y))return!0}}let c=i.getSkeletonData();if(!c)return!1;let{docsLeft:l,docsTop:u}=this.getOffsetConfig();return(0,r.documentSkeletonTableIterator)(c.pages,{docsLeft:l,docsTop:u,includeCells:!1,pageMarginTop:this.pageMarginTop,skeHeaders:c.skeHeaders,skeFooters:c.skeFooters,unitId:i.getViewModel().getDataModel().getUnitId()}).some(({tableRect:e})=>o.x+l>=e.left-24&&o.x+l<=e.right+24&&o.y+u>=e.top-24&&o.y+u<=e.bottom+24)}};let Ds=0;function Os(e){if(!(`scheduling`in e))return!1;let t=e.scheduling;return typeof t==`object`&&!!t&&`isInputPending`in t&&typeof t.isInputPending==`function`}function ks(){return typeof navigator>`u`?!1:Os(navigator)&&navigator.scheduling.isInputPending({includeContinuous:!0})}function As(e){return e===`edit`?120:4}function js(e){return Math.min(5,Math.max(3,Math.floor(e??5)))}function Ms(e){if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}let t=setTimeout(e,0);return()=>clearTimeout(t)}var Ns=class extends t.Disposable{constructor(e=Ms){super(),this._scheduleVisualFrame=e,R(this,`_mountId`,`docs-layout-mount-${++Ds}`),R(this,`_mountEpoch`,0),R(this,`_viewportEpoch`,0),R(this,`_workerMount`,null),R(this,`_scheduledLayout`,null),R(this,`_animationFrameId`,null),R(this,`_idleCallbackId`,null),R(this,`_fallbackTimerId`,null),R(this,`_pendingWorkerPresentation`,null),R(this,`_workerPresentationPaused`,!1)}schedule(e,t,n){this.cancel();let r=e.startIncrementalLayout({...t,waitForHyphenationPatterns:!0}),i=As(t.reason);if(this._scheduledLayout={executor:`main-thread`,skeleton:e,generation:r,callbacks:n,backgroundResumeDelayMs:i,nextBackgroundDelayMs:i,anchorReady:!1,foregroundStarted:!1,foregroundBudgetMs:t.foregroundBudgetMs??28,foregroundElapsedMs:0,foregroundWindowSize:js(t.foregroundWindowSize),foregroundTargetProgressCount:null,foregroundEndOffset:t.foregroundEndOffset??null,waitForAnimationFrame:t.reason!==`edit`||t.deferForeground===!0},t.reason===`edit`&&t.deferForeground!==!0){this._scheduledLayout.foregroundStarted=!0;let e=0;for(;this._scheduledLayout!=null&&!this._scheduledLayout.anchorReady&&e<4;)this._runSlice(0,!1,!1),e++;let t=this._scheduledLayout;(t==null?void 0:t.executor)===`main-thread`&&t.anchorReady&&t.foregroundEndOffset!=null&&t.foregroundElapsedMs<t.foregroundBudgetMs&&this._runSlice(Math.min(8,t.foregroundBudgetMs-t.foregroundElapsedMs),!1,!1);let n=this._scheduledLayout;n!=null&&(n.executor===`main-thread`&&(!n.anchorReady||n.callbacks.onForegroundReady!=null)&&(n.foregroundStarted=!1,n.waitForAnimationFrame=!0),!n.anchorReady||n.callbacks.onForegroundReady!=null?this._scheduleForeground():this._scheduleBackground())}else this._scheduleForeground();return r}scheduleWorker(e,t,n,r,i,a,o,s=!1){this.cancel();let c=this._workerMount;c!=null&&(c.unitId!==e||c.executorService!==n)&&c.executorService.disposeLayoutMount({unitId:c.unitId,mountId:this._mountId,mountEpoch:c.mountEpoch,viewportEpoch:c.viewportEpoch}).catch(o),(c==null||c.unitId!==e||c.executorService!==n)&&this._mountEpoch++;let l=++this._viewportEpoch;this._workerMount={unitId:e,executorService:n,onError:o,mountEpoch:this._mountEpoch,viewportEpoch:l},s||t.beginExternalLayout({reason:r.reason,protectedRange:i});let u=As(r.reason);this._scheduledLayout={executor:`worker`,unitId:e,mountId:this._mountId,mountEpoch:this._mountEpoch,viewportEpoch:l,skeleton:t,executorService:n,preserveCompletedLayout:s,options:r,generation:null,modelRevision:null,metricsRevision:null,callbacks:a,onError:o,backgroundResumeDelayMs:u,nextBackgroundDelayMs:u,anchorReady:!1},this._runSlice(32,!1)}async getWorkerPage(e){let t=this._workerMount;if(t==null)return null;let n=await t.executorService.getLayoutPage({unitId:t.unitId,mountId:this._mountId,mountEpoch:t.mountEpoch,viewportEpoch:t.viewportEpoch,pageIndex:e});return this._workerMount!==t||n.unitId!==t.unitId||n.mountId!==this._mountId||n.mountEpoch!==t.mountEpoch||n.viewportEpoch!==t.viewportEpoch?null:n}deferBackgroundWork(){let e=this._scheduledLayout;e!=null&&e.anchorReady&&(e.nextBackgroundDelayMs=e.backgroundResumeDelayMs,e.executor!==`worker`&&(this._cancelCallbacks(),this._scheduleBackground()))}setWorkerPresentationPaused(e){if(this._workerPresentationPaused!==e&&(this._workerPresentationPaused=e,!e)){var t;(t=this._pendingWorkerPresentation)==null||t.resume()}}hasScheduledLayout(){return this._scheduledLayout!=null}cancel(){let e=this._scheduledLayout;e!=null&&(e.executor===`main-thread`?e.skeleton.cancelIncrementalLayout(e.generation):e.generation!=null&&e.executorService.cancelLayout({unitId:e.unitId,mountId:e.mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch,generation:e.generation}).catch(e.onError),e.executor===`worker`&&!e.preserveCompletedLayout&&e.skeleton.cancelExternalLayout()),this._scheduledLayout=null,this._cancelCallbacks()}dispose(){this.cancel();let e=this._workerMount;this._workerMount=null,e!=null&&e.executorService.disposeLayoutMount({unitId:e.unitId,mountId:this._mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch}).catch(e.onError),super.dispose()}_scheduleForeground(){if(this._scheduledLayout==null||this._animationFrameId!=null||this._fallbackTimerId!=null)return;if(this._scheduledLayout.executor===`worker`){this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._runSlice(32,!1)},0);return}let e=this._scheduledLayout;if(e.foregroundStarted||!e.waitForAnimationFrame){this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))},0);return}if(typeof requestAnimationFrame==`function`){this._animationFrameId=requestAnimationFrame(()=>{this._animationFrameId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))});return}this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))},0)}_scheduleBackground(){if(this._scheduledLayout==null||this._idleCallbackId!=null||this._fallbackTimerId!=null)return;let e=this._scheduledLayout.nextBackgroundDelayMs;this._scheduledLayout.nextBackgroundDelayMs=4,this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null;let e=this._scheduledLayout;if(e!=null){if(e.executor===`worker`){if(ks()){this._scheduleBackground();return}this._runSlice(128,!0);return}if(typeof requestIdleCallback==`function`){this._idleCallbackId=requestIdleCallback(e=>{if(this._idleCallbackId=null,ks()){this._scheduleBackground();return}let t=e.timeRemaining(),n=t>0?Math.min(12,Math.max(1,t)):8;this._runSlice(n,!0)});return}this._runSlice(8,!0)}},e)}_runSlice(e,t,n=!0){let r=this._scheduledLayout;if(r!=null){if(r.executor===`worker`){this._runWorkerSlice(r,e,t).catch(e=>{this._scheduledLayout===r&&(r.preserveCompletedLayout||r.skeleton.cancelExternalLayout(),this._scheduledLayout=null,this._cancelCallbacks(),r.onError(e))});return}try{this._runMainThreadSlice(r,e,t,n)}catch(e){throw this.cancel(),e}}}_runMainThreadSlice(e,t,n,r){if(this._publishMainThreadBacklog(e,n,r))return;let i=performance.now(),a=e.skeleton.stepIncrementalLayout(e.generation,t);if(e.foregroundElapsedMs+=performance.now()-i,this._scheduledLayout!==e)return;if(a.cancelled){this._scheduledLayout=null,this._cancelCallbacks();return}e.anchorReady=a.anchorReady;let o=a.complete&&a.mode!==`continuous`&&e.callbacks.onForegroundReady!=null?{...a,complete:!1}:a;if(e.callbacks.onProgress(o),!this._finishForegroundWindow(e,a,r)){if(a.complete){var s,c;this._scheduledLayout=null,(s=(c=e.callbacks).onComplete)==null||s.call(c,a);return}r&&(e.anchorReady?this._scheduleBackground():this._scheduleForeground())}}_publishMainThreadBacklog(e,t,n){if(!t||!e.anchorReady||ks()||typeof e.skeleton.publishIncrementalLayoutBacklog!=`function`)return!1;let r=e.skeleton.publishIncrementalLayoutBacklog(e.generation);if(this._scheduledLayout!==e||r.cancelled)return!0;if(!r.didPublish)return!1;if(e.anchorReady=r.anchorReady,e.callbacks.onProgress(r),r.complete){var i,a;return this._scheduledLayout=null,(i=(a=e.callbacks).onComplete)==null||i.call(a,r),!0}return n&&this._scheduleBackground(),!0}_finishForegroundWindow(e,t,n){let r=e.callbacks.onForegroundReady;if(r==null)return!1;if(t.complete)return this._completeForegroundWindow(e,t,r),!0;let i=t.mode===`continuous`?t.processedBlockCount:t.publishedPageCount;if(t.didPublishAnchor&&t.interactionWindowComplete)return this._completeForegroundWindow(e,t,r),!0;t.didPublishAnchor&&e.foregroundTargetProgressCount==null&&(e.foregroundTargetProgressCount=i+Math.max(0,e.foregroundWindowSize-1));let a=e.foregroundTargetProgressCount;return a==null?!1:(t.mode===`continuous`&&e.foregroundEndOffset!=null?t.stableLaidOutThrough>=e.foregroundEndOffset:i>=a||e.foregroundElapsedMs>=e.foregroundBudgetMs)?(this._completeForegroundWindow(e,t,r),!0):(n&&this._scheduleForeground(),!0)}_completeForegroundWindow(e,t,n){this._scheduledLayout=null,e.skeleton.cancelIncrementalLayout(e.generation),this._cancelCallbacks(),n(t)}async _runWorkerSlice(e,t,n){if(e.generation==null&&await this._startWorkerLayout(e,t)||await this._publishWorkerBacklog(e,n))return;let r=await e.executorService.stepLayout({...this._getWorkerIdentity(e),generation:this._getWorkerGeneration(e),budgetMs:t});this._assertWorkerResultIdentity(e,r),this._assertWorkerResultRevisions(e,r,`step`),!(this._scheduledLayout!==e||r.progress.cancelled)&&await this._publishWorkerResult(e,r)&&(r.progress.complete||(e.anchorReady?this._scheduleBackground():this._scheduleForeground()))}async _startWorkerLayout(e,t){let r=await e.executorService.startLayout(this._getWorkerIdentity(e),e.options,t);if(this._scheduledLayout!==e)return(r==null?void 0:r.status)===n.DocLayoutSessionStatus.ACCEPTED&&await e.executorService.cancelLayout({unitId:r.step.unitId,mountId:r.step.mountId,mountEpoch:r.step.mountEpoch,viewportEpoch:r.step.viewportEpoch,generation:r.step.progress.generation}),!0;if((r==null?void 0:r.status)!==n.DocLayoutSessionStatus.ACCEPTED)throw Error(`The document layout Worker could not start a synchronized session.`);return this._assertWorkerResultIdentity(e,r.step),e.generation=r.step.progress.generation,e.modelRevision=r.step.modelRevision,e.metricsRevision=r.step.metricsRevision,r.step.progress.cancelled||!await this._publishWorkerResult(e,r.step)?!0:r.step.progress.complete||e.anchorReady?(r.step.progress.complete||this._scheduleBackground(),!0):!1}async _publishWorkerBacklog(e,t){if(!t||!e.anchorReady)return!1;if(ks())return this._scheduleBackground(),!0;let n=await e.executorService.publishBacklog({...this._getWorkerIdentity(e),generation:this._getWorkerGeneration(e)});return this._assertWorkerResultIdentity(e,n),this._assertWorkerResultRevisions(e,n,`backlog`),this._scheduledLayout!==e||n.progress.cancelled?!0:n.progress.didPublish?(await this._publishWorkerResult(e,n)&&(n.progress.complete||this._scheduleBackground()),!0):!1}_assertWorkerResultRevisions(e,t,n){if(t.modelRevision!==e.modelRevision)throw Error(`The document layout Worker returned a stale ${n} model revision.`);if(t.metricsRevision!==e.metricsRevision)throw Error(`The document layout Worker returned stale ${n} Custom Block metrics.`)}_publishWorkerResult(e,t){return new Promise((n,r)=>{let i=!1,a=null,o=e=>{i||(i=!0,n(e))},s=()=>{a==null||a(),a=null,o(!1)},c=()=>{if(!(i||a!=null)){if(this._workerPresentationPaused){this._pendingWorkerPresentation={cancel:s,resume:c};return}a=this._scheduleVisualFrame(()=>{if(a=null,this._workerPresentationPaused){this._pendingWorkerPresentation={cancel:s,resume:c};return}if(this._pendingWorkerPresentation=null,this._scheduledLayout!==e){o(!1);return}try{if(e.anchorReady=t.progress.anchorReady,e.preserveCompletedLayout||e.callbacks.onProgress(t.progress,t.publication),t.progress.complete){var n,l;this._scheduledLayout=null,(n=(l=e.callbacks).onComplete)==null||n.call(l,t.progress)}o(!0)}catch(e){i||(i=!0,r(e))}}),this._pendingWorkerPresentation={cancel:s,resume:c}}};c()})}_getWorkerIdentity(e){return{unitId:e.unitId,mountId:e.mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch}}_getWorkerGeneration(e){if(e.generation==null)throw Error(`The document layout Worker session has not started.`);return e.generation}_assertWorkerResultIdentity(e,t){if(t.unitId!==e.unitId||t.mountId!==e.mountId||t.mountEpoch!==e.mountEpoch||t.viewportEpoch!==e.viewportEpoch||e.generation!=null&&t.progress.generation!==e.generation)throw Error(`The document layout Worker returned a stale publication identity.`)}_cancelCallbacks(){var e;this._animationFrameId!=null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this._animationFrameId),this._idleCallbackId!=null&&typeof cancelIdleCallback==`function`&&cancelIdleCallback(this._idleCallbackId),this._fallbackTimerId!=null&&clearTimeout(this._fallbackTimerId),(e=this._pendingWorkerPresentation)==null||e.cancel(),this._animationFrameId=null,this._idleCallbackId=null,this._fallbackTimerId=null,this._pendingWorkerPresentation=null}},Ps=class extends t.Disposable{constructor(...e){super(...e),R(this,`_active$`,new s.BehaviorSubject(!1)),R(this,`_interactionCount`,0),R(this,`active$`,this._active$.asObservable())}get isActive(){return this._interactionCount>0}beginInteraction(){this.ensureNotDisposed(),this._interactionCount++,this._interactionCount===1&&this._active$.next(!0);let e=!1;return{dispose:()=>{e||(e=!0,!this._disposed&&(this._interactionCount--,this._interactionCount===0&&this._active$.next(!1)))}}}dispose(){this._disposed||(this._interactionCount>0&&(this._interactionCount=0,this._active$.next(!1)),this._active$.complete(),super.dispose())}};function Fs(e){var n,r;return((n=e.getSettings())==null?void 0:n.zoomRatio)??((r=e.getSnapshot().documentStyle)==null||r.documentFlavor,t.DocumentFlavor.MODERN,1)}function Is(e){return{...ss,...e}}function Ls(e,t){if(typeof t==`number`)return Number.isFinite(t)?t:0;if(typeof t==`string`){let n=t.trim();if(n.endsWith(`%`)){let t=Number(n.slice(0,-1));return Number.isFinite(t)?e*t/100:0}}return 0}function Rs(e){let t=Is(e.options);if(t.mode!==`fit-width`||!Number.isFinite(e.availableWidth)||!Number.isFinite(e.baseWidth)||e.baseWidth<=0)return 1;let n=Ls(e.availableWidth,t.paddingX),r=Math.max(0,e.availableWidth-n*2)/e.baseWidth,i=t.maxScale??1/0;return Math.min(i,Math.max(t.minScale,r))}function zs(e){return e.documentStylePageWidth!=null&&Number.isFinite(e.documentStylePageWidth)&&e.documentStylePageWidth>0?e.documentStylePageWidth:e.documentFlavor===t.DocumentFlavor.MODERN?t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM]:e.skeletonPageWidth!=null&&Number.isFinite(e.skeletonPageWidth)&&e.skeletonPageWidth>0?e.skeletonPageWidth:t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM]}function Bs(e,t){return e*t}let Vs=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._configService=t}getPluginConfig(){return this._configService.getConfig(`docs-ui.config`)??{}}getOptions(){return this.getPluginConfig().fitToWidth??ss}getBaseWidth(){var e,t,n;let r=(e=this._context.unit)==null||(t=e.getSnapshot)==null||(t=t.call(e))==null?void 0:t.documentStyle;return zs({documentFlavor:r==null?void 0:r.documentFlavor,documentStylePageWidth:r==null||(n=r.pageSize)==null?void 0:n.width})}getAvailableWidth(){let e=this.getPluginConfig();if(Is(e.fitToWidth).target===`container`){let t=this._resolveContainer(e.container),n=t==null?void 0:t.clientWidth;if(n!=null&&Number.isFinite(n)&&n>0)return n}return this._context.engine.width}getUserZoomRatio(){return this._context.unit==null?1:Fs(this._context.unit)}getFitToWidthScale(){return Rs({availableWidth:this.getAvailableWidth(),baseWidth:this.getBaseWidth(),options:this.getOptions()})}getViewScale(e=this.getUserZoomRatio()){return Bs(e,this.getFitToWidthScale())}_resolveContainer(e){if(e!=null)return typeof e==`string`?document.querySelector(e)??document.getElementById(e)??void 0:e}};Vs=B([z(1,t.IConfigService)],Vs);let Hs=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._docViewScaleService=t,R(this,`_bottomReserve`,0)}setBottomReserve(e){let t=Math.max(0,e);t!==this._bottomReserve&&(this._bottomReserve=t,this.calculatePagePosition())}resolveSceneHeight(e){return e+this._bottomReserve/Math.max(this._docViewScaleService.getViewScale(),.01)}calculatePagePosition(){if(this._disposed)return;let e=x(this._context),t=this._docViewScaleService.getViewScale(),n=this._docViewScaleService.getOptions(),r=n.mode===`fit-width`&&n.align===`start`,{document:i,scene:a,docBackground:o}=e;(a.scaleX!==t||a.scaleY!==t)&&a.scale(t,t);let s=a==null?void 0:a.getParent(),{width:c,height:l,pageMarginLeft:u,pageMarginTop:d}=i,f=r?Ls(this._docViewScaleService.getAvailableWidth(),n.paddingX)/t:u;if(s==null||c===1/0||l===1/0)return;let{width:p,height:m}=s,h=0,g=d,_=0,v=0,y=1/0;p>(c+f*2)*t?(h=r?f:(p/2-c*t/2)/t,_=(p-f*2)/t,y=0):(h=f,_=c+f*2,y=0),v=m>l?(m-d*2)/t:l+d*2,v=this.resolveSceneHeight(v),a.transformByState({width:_,height:v}),p<=1&&(h=-1e4,g=-1e4),i.translate(h,g),o.translate(h,g);let b=a.getViewport(`viewMain`);return y!==1/0&&b!=null&&b.scrollToViewportPos({viewportScrollX:y}),this}};Hs=B([z(1,(0,t.Inject)(Vs))],Hs);let Us=new Set([`blockRanges`,`columnGroups`,`customBlocks`,`customDecorations`,`customRanges`,`paragraphs`,`renderedPageBreaks`,`sectionBreaks`,`tables`,`textRuns`]);var Ws=class{constructor(e,t){this._body=e,this._styles=t,R(this,`_tableRanges`,null),R(this,`_drawingRanges`,null),R(this,`_listRanges`,null),R(this,`_styleRanges`,null),R(this,`_styleDependents`,null)}getTableRange(e){if(this._tableRanges==null){var t;this._tableRanges=new Map;for(let e of((t=this._body)==null?void 0:t.tables)??[])this._tableRanges.has(e.tableId)||this._tableRanges.set(e.tableId,{start:e.startIndex,end:e.endIndex})}return this._tableRanges.get(e)}getDrawingRange(e){if(this._drawingRanges==null){var t;this._drawingRanges=new Map;for(let e of((t=this._body)==null?void 0:t.customBlocks)??[])this._drawingRanges.has(e.blockId)||this._drawingRanges.set(e.blockId,{start:e.startIndex,end:e.startIndex+1})}return this._drawingRanges.get(e)}getListRange(e){return this._ensureParagraphRanges(),Gs(this._listRanges,e)}getStyleRange(e){if(this._ensureParagraphRanges(),this._styleDependents==null){this._styleDependents=new Map;for(let[e,t]of Object.entries(this._styles??{})){if(t.basedOn==null)continue;let n=this._styleDependents.get(t.basedOn)??[];n.push(e),this._styleDependents.set(t.basedOn,n)}}let t=new Set(e),n=[...e];for(;n.length>0;){let e=n.pop();for(let r of this._styleDependents.get(e)??[])t.has(r)||(t.add(r),n.push(r))}return Gs(this._styleRanges,t)}_ensureParagraphRanges(){var e;if(this._listRanges==null||this._styleRanges==null){this._listRanges=new Map,this._styleRanges=new Map;for(let n of((e=this._body)==null?void 0:e.paragraphs)??[]){var t;let e={start:n.startIndex,end:n.startIndex+1},r=(t=n.bullet)==null?void 0:t.listId;r!=null&&this._listRanges.set(r,rc(this._listRanges.get(r),e)),n.styleId!=null&&this._styleRanges.set(n.styleId,rc(this._styleRanges.get(n.styleId),e))}}}};function Gs(e,t){let n;for(let r of t)n=rc(n,e.get(r));return n}function Ks(e,n){if(n||e==null)return;let r,i=!1;try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{let a=n.getPath();a.length===1&&a[0]===`body`&&e.et===t.TextX.name&&Array.isArray(e.e)&&(r==null?r=e.e:i=!0)})}catch{return}return i?void 0:r}function qs(e,t){return e!=null&&e.length===2&&e[0]===`body`?Ks(e,t):void 0}function Js(e,n){if(e==null)return{global:!0};let r=!1,i,a=!1,o=!1,{body:s,styles:c}=n,l=new Ws(s,c);try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{a=!0;let t=Ys(n.getPath(),e,s,l);r||=t.global,o||=t.unresolvedLocal===!0,i=rc(i,t.range)})}catch{return{global:!0}}return{global:r||!a,range:i,unresolvedLocal:o}}function Ys(e,n,r,i){let a=e[0];if(a===`drawingsOrder`)return{global:!1};if(a===`body`)return Xs(e,n,r);if(a===`notes`){let i=nc(e,n),a;for(let e of(r==null?void 0:r.customRanges)??[]){var o;let n=(o=e.properties)==null?void 0:o.noteId;(e.rangeType===t.CustomRangeType.FOOTNOTE||e.rangeType===t.CustomRangeType.ENDNOTE)&&typeof n==`string`&&i.has(n)&&(a=rc(a,{start:e.startIndex,end:e.endIndex+1}))}return{global:!1,range:a,unresolvedLocal:a==null}}if(a===`tableSource`){let t=e[1],n=typeof t==`string`?i.getTableRange(t):void 0;return{global:!1,range:n,unresolvedLocal:n==null}}if(a===`drawings`){let t=e[1],n=typeof t==`string`?i.getDrawingRange(t):void 0;return{global:!1,range:n,unresolvedLocal:n==null}}if(a===`lists`){let t=r==null?void 0:i.getListRange(nc(e,n));return{global:!1,range:t,unresolvedLocal:t==null}}if(a===`styles`){let t=r==null?void 0:i.getStyleRange(nc(e,n));return{global:!1,range:t,unresolvedLocal:t==null}}return{global:!0}}function Xs(e,n,r){if(e.length===1&&n.et===t.TextX.name&&Array.isArray(n.e))return{global:!1};let i=e[1];if(typeof i!=`string`||!Us.has(i))return{global:!0};let a=r==null?void 0:$s(r,e,n);return{global:!1,range:a,unresolvedLocal:a==null}}function Zs(e,t){return t==null?e:e==null?{oldStart:t.start,oldEnd:t.end,newEnd:t.end}:{oldStart:Math.min(e.oldStart,ic(t.start,e)),oldEnd:Math.max(e.oldEnd,ic(t.end,e)),newEnd:Math.max(e.newEnd,t.end)}}function Qs(e,t,n){if(t.global||t.unresolvedLocal&&e==null)return{anchor:void 0,invalidation:void 0};let r=Zs(e,t.range);return{anchor:(r==null?void 0:r.oldStart)??(n.length>0?Math.min(...n):void 0),invalidation:r}}function $s(e,t,n){let r=t[1];if(typeof r!=`string`||!Us.has(r)||`p`in n||`d`in n)return;let i=t[2];if(typeof i==`number`){let a=t.length===3&&(`r`in n||`i`in n)?void 0:ec(e,r,i);return a=rc(a,tc(n.r,r)),rc(a,tc(n.i,r))}let a;for(let e of[n.r,n.i])if(Array.isArray(e))for(let t of e)a=rc(a,tc(t,r));return a}function ec(e,t,n){let r=e[t];return Array.isArray(r)?tc(r[n],t):void 0}function tc(e,t){if(t===`renderedPageBreaks`&&typeof e==`number`)return{start:e,end:e+1};if(typeof e!=`object`||!e)return;if(`st`in e&&`ed`in e&&typeof e.st==`number`&&typeof e.ed==`number`)return{start:e.st,end:e.ed};if(!(`startIndex`in e)||typeof e.startIndex!=`number`)return;let n=`endIndex`in e&&typeof e.endIndex==`number`?e.endIndex+(t===`tables`?0:1):e.startIndex+1;return{start:e.startIndex,end:n}}function nc(e,t){let n=new Set;if(typeof e[1]==`string`)return n.add(e[1]),n;for(let e of[t.r,t.i])typeof e==`object`&&e&&!Array.isArray(e)&&Object.keys(e).forEach(e=>n.add(e));return n}function rc(e,t){return t==null?e:e==null?t:{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function ic(e,t){return e<t.oldStart?e:e<t.newEnd?t.oldStart:e-(t.newEnd-t.oldEnd)}function ac(e){if(typeof e==`object`&&e&&`t`in e&&`len`in e)return typeof e.len==`number`&&Number.isFinite(e.len)&&e.len>=0?e.len:void 0}function oc(e){return e.t===t.TextXActionType.RETAIN&&!(`body`in e)&&!(`oldBody`in e)&&!(`coverType`in e)}function sc(e){return typeof e==`object`&&!!e&&`rangeType`in e&&e.rangeType===t.CustomRangeType.HYPERLINK}function cc(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===t.CustomDecorationType.COMMENT||e.type===t.CustomDecorationType.DELETED)}function lc(e){let t=e.customRanges,n=e.customDecorations;return t!=null&&(!Array.isArray(t)||!t.every(sc))||n!=null&&(!Array.isArray(n)||!n.every(cc))?null:(Array.isArray(t)?t.length:0)+(Array.isArray(n)?n.length:0)}function uc(e){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==`customRanges`&&e!==`customDecorations`))}function dc(e,n){let r=qs(e,n);return r!=null&&r.length>0&&r.every(e=>{if(typeof e!=`object`||!e||!(`t`in e)||e.t!==t.TextXActionType.RETAIN)return!1;if(oc(e))return!0;if(!(`body`in e)||typeof e.body!=`object`||e.body==null)return!1;let n=e.body,r=lc(n);if(n.dataStream===``&&r!=null&&r>0&&Object.keys(n).every(e=>e===`dataStream`||e===`customRanges`||e===`customDecorations`))return!0;if(!(`oldBody`in e)||typeof e.oldBody!=`object`||e.oldBody==null)return!1;let i=e.oldBody,a=lc(i);return n.dataStream===``&&i.dataStream===``&&r!=null&&a!=null&&r+a>0&&t.Tools.diffValue(uc(n),uc(i))})}function fc(e,n){let r=Ks(e,n);if(r==null)return;let i=0,a=0,o,s=r.every(e=>typeof e==`object`&&!!e&&`t`in e&&e.t===t.TextXActionType.RETAIN),c=!1;for(let e of r){let n=ac(e);if(n==null||typeof e!=`object`||!e||!(`t`in e))return;if(oc(e)){i+=n,a+=n,c||=o!=null;continue}if(c&&!s)return;switch(o??={oldStart:i,oldEnd:i,newEnd:a},e.t){case t.TextXActionType.RETAIN:i+=n,a+=n;break;case t.TextXActionType.INSERT:a+=n;break;case t.TextXActionType.DELETE:i+=n;break;default:return}o.oldEnd=i,o.newEnd=a}return o}function pc(e){switch(e){case t.PositionedObjectLayoutType.INLINE:case t.PositionedObjectLayoutType.WRAP_NONE:case t.PositionedObjectLayoutType.WRAP_POLYGON:case t.PositionedObjectLayoutType.WRAP_SQUARE:case t.PositionedObjectLayoutType.WRAP_THROUGH:case t.PositionedObjectLayoutType.WRAP_TIGHT:case t.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:return!0;default:return!1}}function mc(e){if(typeof e!=`object`||!e||!(`layoutType`in e))return;let t=e.layoutType;return pc(t)?t:void 0}function hc(e){return typeof e==`object`&&!!e&&`unitId`in e&&typeof e.unitId==`string`&&`actions`in e&&(e.actions==null||Array.isArray(e.actions))}function gc(e,t){return!t&&e.isSync!==!0&&e.noNeedSetTextRange!==!0&&e.trigger!=null&&e.textRanges!=null}function _c(e,t){if(!(e instanceof r.Documents)||t==null)return null;let n=t.calcViewportInfo().viewBound,{docsLeft:i,docsTop:a,pageLayoutType:o=r.PageLayoutType.VERTICAL,pageMarginLeft:s,pageMarginTop:c}=e.getOffsetConfig(),l=o!==r.PageLayoutType.HORIZONTAL;return{pageGap:l?c:s,vertical:l,viewportCenter:l?(n.top+n.bottom)/2-a:(n.left+n.right)/2-i}}function vc(e,t){return t==null||e<t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd}function yc(e,t){if(e==null||t==null)return;let n=e.newEnd-e.oldEnd,r=t=>t<e.oldStart?t:t<e.newEnd?e.oldStart:t-n,i=Math.min(e.oldStart,r(t.oldStart)),a=Math.max(e.oldEnd,r(t.oldEnd)),o=t.newEnd-t.oldEnd;return{oldStart:i,oldEnd:a,newEnd:a+n+o}}function bc(e,t,n,r){let i=r+Math.max(0,r-n),a;for(let n of e.sections)for(let r of n.columns){let o=i-t-e.marginTop-n.top,s=0,c=r.lines.length;for(;s<c;){let e=s+Math.floor((c-s)/2);r.lines[e].top<=o?s=e+1:c=e}let l=r.lines[s-1];l!=null&&(a=Math.max(a??l.ed,l.ed))}return a}let xc=new Set([`title`,`description`]);function Sc(e,n){if(e==null||!Array.isArray(e)||e.length===0)return!0;let r=new Map,i=!1,a=!0;try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{i=!0;let t=n.getPath();if(t[0]===`drawingsOrder`)return;let o=t[1];if(t[0]!==`drawings`||typeof o!=`string`){a=!1;return}if(t.length>=3&&xc.has(String(t[2])))return;let s=r.get(o)??{};t.length===2?(s.before=mc(e.r),s.after=mc(e.i)):t.length===3&&t[2]===`layoutType`&&(s.before=pc(e.r)?e.r:s.before,s.after=pc(e.i)?e.i:s.after),r.set(o,s)})}catch{return!0}if(!i||!a)return!0;if(r.size===0)return!1;for(let[e,i]of r){var o;let r=n==null||(o=n[e])==null?void 0:o.layoutType,a=i.before??r,s=i.after??r;if(a==null||s==null||a!==t.PositionedObjectLayoutType.WRAP_NONE||s!==t.PositionedObjectLayoutType.WRAP_NONE)return!0}return!1}let Cc=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._context=e,this._commandService=t,this._docSelectionRenderService=n,this._docSkeletonManagerService=r,this._editorService=i,this._renderManagerService=a,this._univerInstanceService=o,this._docPageLayoutService=s,this._textSelectionManagerService=c,this._docViewScaleService=l,this._themeService=u,this._docLayoutExecutorService=d,this._docLayoutInteractionService=f,this._logService=p,R(this,`_changesetRenderScheduled`,!1),R(this,`_pendingChangesetLayoutRequest`,null),R(this,`_layoutCoordinator`,void 0),R(this,`_layoutRequestId`,0),R(this,`_workerHandoffTimer`,null),R(this,`_workerPresentationResumeTimer`,null),R(this,`_pendingWorkerHandoff`,null),R(this,`_pendingWorkerEditBatch`,null),R(this,`_latestLayoutRestart`,null),R(this,`_pendingImeLayoutRestart`,null),R(this,`_isImeComposing`,!1),R(this,`_recoveryViewportAnchor`,null),R(this,`_pendingMaterializedPageRange`,null),R(this,`_isMaterializingPages`,!1),R(this,`_reservedLayoutWidth`,0),R(this,`_reservedLayoutHeight`,0),R(this,`_fontInitialization`,null),this._layoutCoordinator=new Ns(e=>this._scheduleVisualFrame(e)),this.disposeWithMe(this._layoutCoordinator),this._addNewRender(),this._initRenderRefresh(),this._initCommandListener(),this._initInteractionLayoutProtection(),this._initThemeListener()}_scheduleVisualFrame(e){let t=this._context.engine.beginFrame$;if(t==null){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}let n=!1,r=null,i=()=>{let a=t.pipe((0,s.take)(1)).subscribe(()=>{if(n)return;let t=this._context.scene.getParent();if(t==null||t.width<=1||t.height<=1){i();return}e()});r=()=>a.unsubscribe()};return i(),()=>{n=!0,r==null||r()}}reRender(e,t,r,i,a=!0,o=!1,s=!1){var c;let l=(c=this._renderManagerService.getRenderUnitById(e))==null?void 0:c.with(n.DocSkeletonManagerService);if(!l)return;let u=l.getSkeleton();if(!u||u.getViewModel().getDataModel().getSnapshot().disabled)return;if(!l.supportsIncrementalLayout()){l.recalculate();return}let d=t!=null||i!=null||r!=null,f=!u.hasCompleteLayout()&&!d?{reason:`initial`}:{reason:`edit`,anchor:t??0,priorityAnchor:i,invalidation:r,...s?{deferForeground:!0}:{}};this._scheduleLayout(e,u,f,a,o)}dispose(){this._layoutRequestId++,this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._workerPresentationResumeTimer!=null&&(clearTimeout(this._workerPresentationResumeTimer),this._workerPresentationResumeTimer=null),this._pendingWorkerHandoff=null,this._pendingWorkerEditBatch=null,this._pendingChangesetLayoutRequest=null,this._latestLayoutRestart=null,this._fontInitialization=null,this._pendingImeLayoutRestart=null,this._pendingMaterializedPageRange=null,this._recoveryViewportAnchor=null,super.dispose()}refreshCustomBlockPresentation(e){var t;let r=(t=this._renderManagerService.getRenderUnitById(e))==null||(t=t.with(n.DocSkeletonManagerService))==null?void 0:t.getSkeleton();if(r==null)return!1;let i=r.refreshCustomBlockPresentationViewports();if(i.didRefresh){var a,o;(a=this._context.mainComponent)==null||a.makeDirty(!0),(o=this._context.components.get(`__Document_Render_Background__`))==null||o.makeDirty(!0)}return!i.requiresLayout}_scheduleLayout(e,t,n,i=!0,a=!1){this._latestLayoutRestart=()=>this._scheduleLayout(e,t,n,i,a),this._isImeComposing&&(this._pendingImeLayoutRestart=null);let o=++this._layoutRequestId;this._cancelWorkerHandoff();let s=n.reason===`initial`,c=this._context.mainComponent;if(!(c instanceof r.Documents)||this._waitForConfiguredFonts(o))return;this._prepareReservedLayoutExtent(t,c);let l=this._createLayoutCallbacks(e,t,n,i,!0,a,void 0,!1);if(n.reuseMainBaseline){this._layoutCoordinator.schedule(t,n,l);return}if(this._docLayoutExecutorService.getExecutor()==null){this._pendingWorkerEditBatch=null,this._layoutCoordinator.schedule(t,n,l);return}let u=s?n:this._accumulateWorkerEditBatch(n);if(s){this._pendingWorkerEditBatch=null,this._scheduleInitialInteractionWindow(o,e,t,n,u,l,a);return}this._scheduleMainInteractionWindow(o,e,t,n,u,l,i,a)}_waitForConfiguredFonts(e){var t;let n=(t=this._docLayoutExecutorService.getExecutor())==null?void 0:t.renderingFontsReady;return n==null||this._fontInitialization===n?!1:(n.then(()=>{var t;this._disposed||e!==this._layoutRequestId||(this._fontInitialization=n,(t=this._latestLayoutRestart)==null||t.call(this))},e=>this._logService.error(`[DocRenderController]: configured document fonts failed to initialize.`,e)),!0)}_scheduleInitialInteractionWindow(e,t,n,r,i,a,o){this._layoutCoordinator.schedule(n,{...r,priorityAnchor:r.priorityAnchor??0},{onProgress:a.onProgress,onForegroundReady:s=>{if(s.complete)return;let c=this._resolveProtectedRange(n,0,s);this._queueWorkerHandoff(e,()=>{this._scheduleWorkerLayout(e,t,n,r,i,c,a,o)})}})}_prepareReservedLayoutExtent(e,t){e.hasCompleteLayout()?(this._reservedLayoutWidth=Math.max(this._reservedLayoutWidth,t.width||0),this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,t.height||0)):(this._reservedLayoutWidth=0,this._reservedLayoutHeight=0)}_scheduleMainInteractionWindow(e,t,n,r,i,a,o,s){let c=r.priorityAnchor!=null&&r.invalidation!=null&&r.priorityAnchor>=r.invalidation.oldStart&&r.priorityAnchor<=r.invalidation.newEnd,l=c?r.anchor:r.priorityAnchor??r.anchor,u=c?null:this._captureViewportAnchor(n,r.priorityAnchor,r.invalidation),d=this._resolveContinuousForegroundEndOffset(n,r.invalidation);this._layoutCoordinator.schedule(n,{...r,anchor:l,...d==null?{}:{foregroundEndOffset:d},preserveInteractionWindow:l!=null&&l!==r.anchor,reuseUnaffectedTail:!1},{onProgress:(e,t)=>{a.onProgress(e,t),u!=null&&(e.didPublishAnchor||e.complete)&&(this._restoreViewportAnchor(n,u),u=null)},onForegroundReady:c=>{this._refreshSelectionAfterForegroundLayout(t,o);let l=this._resolveProtectedRange(n,r.priorityAnchor??r.anchor,c);this._queueWorkerHandoff(e,()=>{this._scheduleWorkerLayout(e,t,n,r,i,l,a,s,!0,c.mode===`continuous`&&c.complete)})}})}_refreshSelectionAfterForegroundLayout(e,t){t||this._refreshPagePositionAndSelection(this._getActiveEditingRange(e)!=null)}_resolveContinuousForegroundEndOffset(e,n){var i;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN)return;let a=(i=e.getSkeletonData())==null?void 0:i.pages[0],o=this._context.mainComponent,s=this._context.scene.getViewport(`viewMain`);if(a==null||!(o instanceof r.Documents)||s==null)return;let c=s.calcViewportInfo().viewBound;if(!Number.isFinite(c.top)||!Number.isFinite(c.bottom))return;let l=bc(a,o.getOffsetConfig().docsTop,c.top,c.bottom);return l==null?void 0:vc(l,n)}_createLayoutCallbacks(e,t,n,r,i,a,o,s){let c=n.reason===`initial`;return{onProgress:(l,u)=>this._handleLayoutProgress(e,t,n,l,u,c,r,i,a,o,s)}}_handleLayoutProgress(e,t,n,r,i,a,o,s,c,l,u){var d,f;if(!r.didPublish)return;if(u&&r.complete&&i!=null&&l!=null&&this._docLayoutInteractionService.isActive){this._queueWorkerHandoff(l,()=>this._handleLayoutProgress(e,t,n,r,i,a,o,s,c,l,!1),!0);return}let p=this._captureCompletionViewportAnchor(e,t,i!=null&&r.complete&&!a,c),m=this._applyLayoutPublication(e,t,i,r),h=this._editorService.getEditorRenderConfig(e);if(h&&!h.scrollBar){this._markDocumentRenderDirty();return}this._recalculateSizeBySkeleton(t,r),r.complete?this._completeLayoutPresentation(e,t,p,s,o,(m==null?void 0:m.didReplaceProtectedPages)===!0):a?this._refreshPagePosition():(r.didPublishAnchor&&(o||this._docSelectionRenderService.hasPendingSelection)||i!=null&&((d=this._context.unit.getSnapshot().notes)==null?void 0:d[((f=this._getActiveRange(e))==null?void 0:f.segmentId)??``])!=null)&&this._textSelectionManagerService.refreshSelection({unitId:e,subUnitId:e},this._getActiveEditingRange(e)!=null),this._markDocumentRenderDirty()}_applyLayoutPublication(e,n,r,i){if(r==null)return null;let a=t.Tools.now();try{let e=i.mode===`paginated`?this._resolveMaterializedPageRange(n,i.publishedPageCount):void 0;return n.applyLayoutPublication(r,i,e)}finally{this._docLayoutExecutorService.recordHydrationDuration(e,t.Tools.now()-a)}}_completeLayoutPresentation(e,t,n,r,i,a){if(this._docLayoutExecutorService.completeRecovery(e),r||a||this._docSelectionRenderService.hasPendingSelection){let t=i||a||this._getActiveEditingRange(e)!=null;this._refreshPagePositionAndSelection(t)}else this._refreshPagePosition();this._restoreViewportAnchor(t,n),this._restoreRecoveryViewportAnchor(t)}_scheduleWorkerLayout(e,t,n,r,i,a,o,s,c=!0,l=!1){e===this._layoutRequestId&&this._layoutCoordinator.scheduleWorker(t,n,this._docLayoutExecutorService,i,a,{...this._createLayoutCallbacks(t,n,r,!1,!1,s,e,!0),onComplete:()=>{e===this._layoutRequestId&&(this._pendingWorkerEditBatch=null)}},u=>this._handleWorkerLayoutFailure(e,t,n,r,i,a,o,s,c,u,l),l)}_handleWorkerLayoutFailure(e,t,n,r,i,a,o,s,c,l,u){if(this._disposed||e!==this._layoutRequestId)return;if(!c){this._logService.error(`[DocRenderController]: Worker layout failed; using main-thread layout.`,l),this._layoutCoordinator.schedule(n,r,o);return}this._recoveryViewportAnchor=this._captureViewportAnchor(n,r.priorityAnchor??r.anchor,r.invalidation);let d=l instanceof Error?l.message:String(l);this._logService.warn(`[DocRenderController]: restarting the document layout Worker after a fatal layout failure.`,l),this._docLayoutExecutorService.recoverExecutor(t,d).then(()=>{this._scheduleWorkerLayout(e,t,n,r,i,a,o,s,!1,u)}).catch(t=>{this._disposed||e!==this._layoutRequestId||(this._logService.error(`[DocRenderController]: document layout Worker recovery failed; using main-thread layout.`,t),this._layoutCoordinator.schedule(n,r,o))})}_accumulateWorkerEditBatch(e){let t=this._pendingWorkerEditBatch;return this._pendingWorkerEditBatch=t==null?{anchor:e.anchor,invalidation:e.invalidation}:{anchor:t.anchor==null||e.anchor==null?void 0:Math.min(t.anchor,e.anchor),invalidation:yc(t.invalidation,e.invalidation)},{...e,anchor:this._pendingWorkerEditBatch.anchor,priorityAnchor:this._pendingWorkerEditBatch.anchor,invalidation:this._pendingWorkerEditBatch.invalidation}}_initInteractionLayoutProtection(){this._docLayoutInteractionService.active$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e){var t;this._workerPresentationResumeTimer!=null&&(clearTimeout(this._workerPresentationResumeTimer),this._workerPresentationResumeTimer=null),this._layoutCoordinator.setWorkerPresentationPaused(!0),(t=this._pendingWorkerHandoff)!=null&&t.waitForInteractionEnd&&this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null);return}this._workerPresentationResumeTimer=setTimeout(()=>{this._workerPresentationResumeTimer=null,this._docLayoutInteractionService.isActive||this._layoutCoordinator.setWorkerPresentationPaused(!1)},150),this._startWorkerHandoffTimer()}),this._docSelectionRenderService.onCompositionstart$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{e!=null&&(this._isImeComposing=!0,this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._pendingWorkerHandoff==null&&this._layoutCoordinator.hasScheduledLayout()&&(this._pendingImeLayoutRestart=this._latestLayoutRestart),this._layoutCoordinator.cancel())}),this._docSelectionRenderService.onCompositionend$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;this._isImeComposing=!1;let t=this._pendingImeLayoutRestart;if(this._pendingImeLayoutRestart=null,t!=null){t();return}this._startWorkerHandoffTimer()})}_queueWorkerHandoff(e,t,n=!1){this._cancelWorkerHandoff(),this._pendingWorkerHandoff={layoutRequestId:e,run:t,waitForInteractionEnd:n},this._startWorkerHandoffTimer()}_startWorkerHandoffTimer(){this._pendingWorkerHandoff==null||this._workerHandoffTimer!=null||this._isImeComposing||this._pendingWorkerHandoff.waitForInteractionEnd&&this._docLayoutInteractionService.isActive||(this._workerHandoffTimer=setTimeout(()=>{this._workerHandoffTimer=null;let e=this._pendingWorkerHandoff;if(e!=null){if(e.layoutRequestId!==this._layoutRequestId){this._pendingWorkerHandoff=null;return}if(this._isImeComposing||e.waitForInteractionEnd&&this._docLayoutInteractionService.isActive||this._docSelectionRenderService.isOnPointerEvent){this._startWorkerHandoffTimer();return}this._pendingWorkerHandoff=null,e.run()}},150))}_deferWorkerHandoff(){this._pendingWorkerHandoff!=null&&(this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._startWorkerHandoffTimer())}_cancelWorkerHandoff(){this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._pendingWorkerHandoff=null}_resolveProtectedRange(e,t,n){var r,i,a,o;if(n.mode===`continuous`)return n.stableLaidOutThrough<0?void 0:{mode:`continuous`,startOffset:Math.max(0,Math.min(t??n.stableLaidOutThrough,n.stableLaidOutThrough)),endOffset:n.stableLaidOutThrough};let s=(r=e.getSkeletonData())==null?void 0:r.pages;if(s==null||s.length===0||n.publishedPageCount<=0)return;let c=Math.min(n.publishedPageCount,s.length)-1,l=t==null?Math.max(0,c-4):((i=e.findNodePositionByCharIndex(t))==null?void 0:i.page)??-1;for((l<0||l>c)&&(l=Math.max(0,c-4));l<=c&&((a=s[l])!=null&&a.isLayoutPlaceholder||(o=s[l])!=null&&o.isMaterializationPlaceholder);)l++;if(!(l>c))return{mode:`paginated`,startPageIndex:l,endPageIndex:c}}_resolveMaterializedPageRange(e,n){var r;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let i=(r=e.getSkeletonData())==null?void 0:r.pages,a=this._context.mainComponent,o=_c(a,this._context.scene.getViewport(`viewMain`));if(i==null||i.length===0||o==null)return;let{pageGap:s,vertical:c,viewportCenter:l}=o,u=0,d=0;for(;d<i.length;d++){let e=i[d],t=c?e.pageHeight:e.pageWidth;if(l<=u+t)break;u+=t+s}let f=Math.max(i.length,n??0);if(d>=i.length&&f>i.length){let e=i.at(-1),t=c?e==null?void 0:e.pageHeight:e==null?void 0:e.pageWidth;t!=null&&t+s>0&&(d+=Math.floor(Math.max(0,l-u)/(t+s)))}d=Math.max(0,Math.min(d,f-1));let p=Math.max(0,d-1),m=Math.min(f-1,p+5-1);return{startPageIndex:Math.max(0,m-5+1),endPageIndex:m}}_queueMaterializedPageRange(e){this._pendingMaterializedPageRange=e,!this._isMaterializingPages&&(this._isMaterializingPages=!0,this._materializePendingPageRanges().catch(e=>{this._logService.warn(`[DocRenderController]: failed to materialize a document page.`,e)}).finally(()=>{this._isMaterializingPages=!1,this._pendingMaterializedPageRange!=null&&this._queueMaterializedPageRange(this._pendingMaterializedPageRange)}))}async _materializePendingPageRanges(){for(;this._pendingMaterializedPageRange!=null;){let n=this._pendingMaterializedPageRange;this._pendingMaterializedPageRange=null;let r=this._layoutRequestId,i=this._docSkeletonManagerService.getSkeleton();if(i==null)return;for(let a=n.startPageIndex;a<=n.endPageIndex;a++){var e;if(!((e=i.getSkeletonData())!=null&&(e=e.pages[a])!=null&&e.isMaterializationPlaceholder))continue;let o=await this._layoutCoordinator.getWorkerPage(a);if(r!==this._layoutRequestId||o==null)return;if(o.page==null)continue;let s=t.Tools.now();try{i.applyLayoutPagePublication(o.page,n)}finally{this._docLayoutExecutorService.recordHydrationDuration(this._context.unitId,t.Tools.now()-s)}this._markDocumentRenderDirty()}}}_captureViewportAnchor(e,t,n){if(t==null)return null;let i=n==null||t<n.oldStart?t:t<n.newEnd?n.oldStart:t-(n.newEnd-n.oldEnd),a=e.findNodePositionByCharIndex(i),o=this._context.mainComponent,s=this._context.scene.getViewport(`viewMain`);if(a==null||!(o instanceof r.Documents)||s==null)return null;let c=o.getOffsetConfig(),{contentBoxPointGroup:l}=new Ze(c,e).getRangePointData(a,a),u=Ct(l),d=s.calcViewportInfo().viewBound;return{offset:t,relativeLeft:u.left+c.docsLeft-d.left,relativeTop:u.top+c.docsTop-d.top}}_restoreRecoveryViewportAnchor(e){let t=this._recoveryViewportAnchor;t!=null&&(this._recoveryViewportAnchor=null,this._restoreViewportAnchor(e,t))}_restoreViewportAnchor(e,t){if(t==null)return;let n=e.findNodePositionByCharIndex(t.offset),i=this._context.mainComponent,a=this._context.scene.getViewport(`viewMain`);if(n==null||!(i instanceof r.Documents)||a==null)return;let o=i.getOffsetConfig(),{contentBoxPointGroup:s}=new Ze(o,e).getRangePointData(n,n),c=Ct(s),l=a.calcViewportInfo().viewBound;a.scrollByViewportDeltaVal({viewportScrollX:c.left+o.docsLeft-l.left-t.relativeLeft,viewportScrollY:c.top+o.docsTop-l.top-t.relativeTop})}_addNewRender(){let{scene:e,engine:t}=this._context,n=new r.Viewport(`viewMain`,e,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});e.attachControl(),this._initViewportInteraction(n),new r.ScrollBar(n,{enableHorizontal:this._shouldEnableHorizontalScrollBar()}),e.addLayer(new r.Layer(e,[],2),new r.Layer(e,[],4)),this._addComponent();let i=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(e=>{e?t.runRenderLoop(i):t.stopRenderLoop(i)})),this._docSelectionRenderService.__attachScrollEvent()}_initViewportInteraction(e){var n;let{scene:r}=this._context,i=(n=r.onPointerDown$)==null?void 0:n.subscribeEvent(()=>{this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork()});i!=null&&this.disposeWithMe(i),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(()=>{let e=this._docSkeletonManagerService.getSkeleton(),t=e==null?void 0:this._resolveMaterializedPageRange(e);t!=null&&this._queueMaterializedPageRange(t)})),typeof document<`u`&&this.disposeWithMe((0,s.merge)((0,s.fromEvent)(document,`keydown`,{capture:!0}),(0,s.fromEvent)(document,`beforeinput`,{capture:!0})).pipe((0,s.takeUntil)(this.dispose$)).subscribe(()=>{let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(e==null?void 0:e.getUnitId())===this._context.unitId&&(this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork())})),r.onMouseWheel$.subscribeEvent((n,i)=>{let a=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if((a==null?void 0:a.getUnitId())===this._context.unitId){if(this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork(),n.ctrlKey){let e=Math.abs(n.deltaX),t=e<40?.2:e<80?.4:.2;t*=n.deltaY>0?-1:1,r.scaleX<1&&(t/=2),r.scaleX+t>4?r.scale(4,4):r.scaleX+t<.1?r.scale(.1,.1):n.preventDefault()}else e.onMouseWheel(n,i)}})}_shouldEnableHorizontalScrollBar(){let e=this._docViewScaleService.getOptions();return e.mode!==`fit-width`||e.target!==`container`||e.align!==`start`}_getHorizontalPageMargin(){return 20}_addComponent(){let{scene:e,unit:t,components:n}=this._context,i={pageMarginLeft:this._getHorizontalPageMargin(),pageMarginTop:20,...this._getEditorBackgroundConfig()},a=new(this._isEditorRenderUnit(t.getUnitId())?r.Documents:Es)(`__Document_Render_Main__`,void 0,i);a.zIndex=10;let o=new r.DocBackground(`__Document_Render_Background__`,void 0,i);o.zIndex=10,this._context.mainComponent=a,n.set(`__Document_Render_Main__`,a),n.set(`__Document_Render_Background__`,o),e.addObjects([a],2),e.addObjects([o],0),this._isEditorRenderUnit(t.getUnitId())||e.enableLayerCache(2)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(!e)return;let{mainComponent:t,components:n}=this._context,r=t,i=n.get(`__Document_Render_Background__`);r.changeSkeleton(e),i.changeSkeleton(e),this._syncCanvasBackground();let{unitId:a}=this._context;if(e.getSkeletonData()==null){this._scheduleLayout(a,e,{reason:`initial`});return}let o=this._editorService.getEditorRenderConfig(a);if(o&&!o.scrollBar){var s;(s=this._context.mainComponent)==null||s.makeDirty();return}this._recalculateSizeBySkeleton(e),this._refreshPagePositionAndSelection(this._getActiveEditingRange(a)!=null)}_initCommandListener(){let e=[n.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((r,i)=>{if(!e.includes(r.id))return;let a=r.params;if(!hc(a))return;let{unitId:o,textRanges:s}=a;if(o!==this._context.unitId)return;let c=this._context.unit.getSnapshot();if(!Sc(a.actions,c.drawings))return;let l=(s==null?void 0:s.filter(e=>!(e.segmentId??a.segmentId)))??[],{anchor:u,invalidation:d}=Qs(fc(a.actions,a.segmentId),Js(a.actions,c),l.map(e=>e.startOffset));if(i!=null&&i.fromChangeset){this._scheduleChangesetRender(u,d);return}let f=this._getActiveEditingRange(o),p=a.isSync===!0||(i==null?void 0:i.fromCollab)===!0,m=p?void 0:l.find(e=>e.isActive)??(l.length===1?l[0]:void 0),h=(m==null?void 0:m.endOffset)??(f!=null&&f.segmentId||f==null?void 0:f.endOffset),g=gc(a,p);if(d!=null&&dc(a.actions,a.segmentId)){var _,v;let e=(_=this._renderManagerService.getRenderUnitById(o))==null?void 0:_.with(n.DocSkeletonManagerService),r=e==null?void 0:e.getSkeleton(),i=r==null||(v=r.getSkeletonData())==null?void 0:v.pages,a=[d.oldStart,Math.max(d.oldStart,d.oldEnd-1)],s=r!=null&&i!=null&&a.every(e=>{var t;let n=((t=r.findNodePositionByCharIndex(e))==null?void 0:t.page)??-1,a=i[n];return a!=null&&!a.isLayoutPlaceholder&&!a.isMaterializationPlaceholder});if(e!=null&&e.supportsIncrementalLayout()&&this._context.unit.documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL&&!this._context.unit.getSnapshot().disabled&&r!=null&&r.hasCompleteLayout()&&r.getLayoutProgress()==null&&i!=null&&i.length>0&&i.every(e=>!e.isLayoutPlaceholder)&&s){this._scheduleLayout(o,r,{reason:`edit`,anchor:u,priorityAnchor:h,invalidation:d,reuseMainBaseline:!0,allowMetadataOnlyStructuralTailReuse:!0},!g,p);return}}this.reRender(o,u,d,h,!g,p,Array.isArray(a.actions)&&a.actions.length>0&&l.length===0&&d==null)}))}_scheduleChangesetRender(e,t){let n=this._pendingChangesetLayoutRequest;this._pendingChangesetLayoutRequest=n==null?{anchor:e,invalidation:t}:{anchor:n.anchor==null||e==null?void 0:Math.min(n.anchor,e),invalidation:yc(n.invalidation,t)},!this._changesetRenderScheduled&&(this._changesetRenderScheduled=!0,queueMicrotask(()=>{if(this._changesetRenderScheduled=!1,this._disposed)return;let e=this._pendingChangesetLayoutRequest;this._pendingChangesetLayoutRequest=null,this.reRender(this._context.unitId,e==null?void 0:e.anchor,e==null?void 0:e.invalidation)}))}_initThemeListener(){this.disposeWithMe((0,s.combineLatest)([this._themeService.currentTheme$,this._themeService.darkMode$]).pipe((0,s.takeUntil)(this.dispose$)).subscribe(()=>{this._syncCanvasBackground(),this._markDocumentRenderDirty()}))}_markDocumentRenderDirty(){var e,t;(e=this._context.mainComponent)==null||e.makeDirty(!0),(t=this._context.components.get(`__Document_Render_Background__`))==null||t.makeDirty(!0)}_refreshPagePositionAndSelection(e=!1){if(this._refreshPagePosition(),this._isEditorRenderUnit())return;let t=this._context.unitId,n=this._getActiveEditingRange(t);this._textSelectionManagerService.refreshSelection({unitId:t,subUnitId:t},e&&n!=null)}_getFocusedSelectionInfo(e){var t;if(((t=this._univerInstanceService.getFocusedUnit())==null?void 0:t.getUnitId())===e)return this._textSelectionManagerService.getSelectionInfo({unitId:e,subUnitId:e})}_getActiveEditingRange(e){let t=this._getFocusedSelectionInfo(e);if((t==null?void 0:t.isEditing)===!0)return t.textRanges.find(e=>e.isActive)}_getActiveRange(e){let t=this._getFocusedSelectionInfo(e);return t==null?void 0:t.textRanges.find(e=>e.isActive)}_captureCompletionViewportAnchor(e,t,n,r){if(!n||this._recoveryViewportAnchor!=null)return null;let i=this._getFocusedSelectionInfo(e);if((i==null?void 0:i.isEditing)!==!0&&!r)return null;let a=i==null?void 0:i.textRanges.find(e=>e.isActive);return a==null||a.segmentId?null:this._captureViewportAnchor(t,a.endOffset,void 0)}_refreshPagePosition(){this._isEditorRenderUnit()||this._docPageLayoutService.calculatePagePosition()}_recalculateSizeBySkeleton(e,t){var n,r;let{mainComponent:i,scene:a,unitId:o,components:s}=this._context,c=i,l=s.get(`__Document_Render_Background__`),u=(n=e.getSkeletonData())==null?void 0:n.pages;if(u==null)return;let d=this._context.unit.getSnapshot().documentStyle.documentFlavor;this._syncCanvasBackground(d);let f=this._measureDocumentExtent(u,c,d),p=t??((r=e.getLayoutProgress)==null?void 0:r.call(e))??null,{width:m,height:h}=this._reserveDocumentExtent(f,u,c,d,p),g=this._docPageLayoutService.resolveSceneHeight(h);c.resize(m,h),l.resize(m,h);let _=this._editorService.getEditorRenderConfig(o);(!_||_.scrollBar)&&(a.width!==m||a.height!==g)&&a.transformByState({width:m,height:g})}_measureDocumentExtent(e,n,i){let a=0,o=0;for(let s=0,c=e.length;s<c;s++){let l=e[s],{pageWidth:u,pageHeight:d}=l;if(i===t.DocumentFlavor.MODERN){let e=wc(l);u=e.pageWidth,d=e.pageHeight}n.pageLayoutType===r.PageLayoutType.VERTICAL?(o+=d,o+=n.pageMarginTop,s===c-1&&(o+=n.pageMarginTop),a=Math.max(a,u)):n.pageLayoutType===r.PageLayoutType.HORIZONTAL&&(a+=u,s!==c-1&&(a+=n.pageMarginLeft),o=Math.max(o,d))}return{width:a,height:o}}_reserveDocumentExtent(e,n,i,a,o){let{width:s,height:c}=e;if(o!=null&&!o.complete&&n.length>0){let e=n[0];if(a===t.DocumentFlavor.MODERN)this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,o.estimatedHeight+i.pageMarginTop*2);else if(i.pageLayoutType===r.PageLayoutType.VERTICAL){let t=o.estimatedPageCount*(e.pageHeight+i.pageMarginTop)+i.pageMarginTop;this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,t)}else{let t=o.estimatedPageCount*(e.pageWidth+i.pageMarginLeft);this._reservedLayoutWidth=Math.max(this._reservedLayoutWidth,t)}a===t.DocumentFlavor.MODERN||i.pageLayoutType===r.PageLayoutType.VERTICAL?c=Math.max(c,this._reservedLayoutHeight):s=Math.max(s,this._reservedLayoutWidth)}else this._reservedLayoutWidth=s,this._reservedLayoutHeight=c;return{width:s,height:c}}_syncCanvasBackground(e=this._context.unit.getSnapshot().documentStyle.documentFlavor){var t;let n=this._editorService.getEditorRenderConfig(this._context.unitId),r=n==null?void 0:n.canvasStyle.backgroundColor,i=Se({documentFlavor:e,canvasColorService:this._context.engine.canvasColorService,editorBackgroundColor:r,isEditor:this._isEditorRenderUnit()});this._context.engine.getCanvas().getCanvasEle().style.backgroundColor=i.canvasElementBackgroundColor;let a=this._context.components.get(`__Document_Render_Background__`);a==null||(t=a.setFillColors)==null||t.call(a,i.docBackgroundFillColor,i.docBackgroundFillColor,i.docBackgroundFillColor,i.docBackgroundFillColor)}_getEditorBackgroundConfig(){if(!this._isEditorRenderUnit())return{};let e=`transparent`;return{backgroundFillColor:e,pageFillColor:e,pageStrokeColor:e,marginStrokeColor:e}}_isEditorRenderUnit(e=this._context.unitId){return this._editorService.isEditor(e)||(0,t.isInternalEditorID)(e)}};Cc=B([z(1,t.ICommandService),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,J),z(5,r.IRenderManagerService),z(6,t.IUniverInstanceService),z(7,(0,t.Inject)(Hs)),z(8,(0,t.Inject)(n.DocSelectionManagerService)),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Inject)(t.ThemeService)),z(11,(0,t.Inject)(n.DocLayoutExecutorService)),z(12,(0,t.Inject)(Ps)),z(13,t.ILogService)],Cc);function wc(e){let{pageWidth:t,pageHeight:n}=e,{marginLeft:r,marginRight:i,marginTop:a,marginBottom:o,skeDrawings:s,skeTables:c}=e;t===1/0&&(t=e.width+r+i),n===1/0&&(n=e.height+a+o);for(let e of s.values())n=Math.max(n,e.aTop+e.height+a+o);for(let e of c.values())n=Math.max(n,e.top+e.height+a+o);return{pageWidth:t,pageHeight:n}}function Tc(e){let{dataStream:n}=e.body??{},r=[t.DataStreamTreeTokenType.TABLE_START,t.DataStreamTreeTokenType.TABLE_CELL_END,t.DataStreamTreeTokenType.TABLE_CELL_START,t.DataStreamTreeTokenType.TABLE_END,t.DataStreamTreeTokenType.TABLE_ROW_END,t.DataStreamTreeTokenType.TABLE_ROW_START,t.DataStreamTreeTokenType.COLUMN_BREAK,t.DataStreamTreeTokenType.PAGE_BREAK,t.DataStreamTreeTokenType.TAB,t.DataStreamTreeTokenType.DOCS_END,t.DataStreamTreeTokenType.CUSTOM_BLOCK];if(typeof n==`string`)for(let e=0;e<n.length;e++){let t=n[e];if(!r.includes(t))return e}return 0}function Ec(e,r){let i=e.body?(0,n.getTopLevelSectionBreaks)(e.body):[],a=(r==null?void 0:r.sectionId)==null?-1:i.findIndex(e=>e.sectionId===r.sectionId),o=a<0?void 0:i[a],s=o==null?{}:(0,t.resolveSectionHeaderFooterReferences)(e.documentStyle,i,a);return{sectionId:o==null?void 0:o.sectionId,sectionIndex:a,sections:i,section:o,config:{...e.documentStyle,...o,...s}}}function Dc(e,i,a,o){let{sectionId:s,config:c}=Ec(e.getDataModel().getSnapshot(),o),{defaultHeaderId:l,defaultFooterId:u,evenPageHeaderId:d,evenPageFooterId:f,firstPageHeaderId:p,firstPageFooterId:m,evenAndOddHeaders:h,useFirstPageHeaderFooter:g}=c,_=o?o.pageNumber===o.pageNumberStart:a===0,v=o?o.pageNumber%2==0:a%2==1;if(i===r.DocumentEditArea.BODY)return{createType:null,headerFooterId:null,sectionId:s};let y=i===r.DocumentEditArea.HEADER;if(!y&&i!==r.DocumentEditArea.FOOTER)throw Error(`Invalid editArea: ${i}`);let b=y?{first:[p,n.HeaderFooterType.FIRST_PAGE_HEADER],even:[d,n.HeaderFooterType.EVEN_PAGE_HEADER],default:[l,n.HeaderFooterType.DEFAULT_HEADER]}:{first:[m,n.HeaderFooterType.FIRST_PAGE_FOOTER],even:[f,n.HeaderFooterType.EVEN_PAGE_FOOTER],default:[u,n.HeaderFooterType.DEFAULT_FOOTER]},[x,S]=g===t.BooleanNumber.TRUE&&_?b.first:h===t.BooleanNumber.TRUE&&v?b.even:b.default;return{createType:x?null:S,headerFooterId:x??null,sectionId:s}}let Oc=`COMPONENT_DOC_HEADER_FOOTER_PANEL`,kc={id:`sidebar.operation.doc-header-footer-panel`,type:t.CommandType.OPERATION,handler:async(e,n)=>{let r=e.get(a.ISidebarService),i=e.get(t.LocaleService);switch(n.value){case`open`:r.open({header:{title:i.t(`docs-ui.headerFooter.panel`)},children:{label:Oc},onClose:()=>{},width:400});break;default:r.close()}return!0}},Ac=`doc.command.core-header-footer`,jc={id:Ac,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a;let o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.IRenderManagerService),{unitId:l,segmentId:u,createType:d,headerFooterProps:f,sectionId:p}=i,m=(a=c.getRenderUnitById(l))==null?void 0:a.with(n.DocSkeletonManagerService),h=s.getUnit(l,t.UniverInstanceType.UNIVER_DOC),g=m==null?void 0:m.getViewModel();if(h==null||g==null)return!1;let _=g.getEditArea(),v=h.getSnapshot(),y=p,b=v.body?(0,n.getTopLevelSectionBreaks)(v.body):[],x=y==null?-1:b.findIndex(e=>e.sectionId===y),S=x<0?void 0:b[x],C=y==null?v.documentStyle:{...v.documentStyle,...S,...(0,t.resolveSectionHeaderFooterReferences)(v.documentStyle,b,x)},w=d;return f!=null&&Object.keys(f).forEach(e=>{let i=f[e];w==null&&e===`useFirstPageHeaderFooter`&&i===t.BooleanNumber.TRUE&&!C.firstPageHeaderId?w=_===r.DocumentEditArea.HEADER?n.HeaderFooterType.FIRST_PAGE_HEADER:n.HeaderFooterType.FIRST_PAGE_FOOTER:w==null&&e===`evenAndOddHeaders`&&i===t.BooleanNumber.TRUE&&!C.evenPageHeaderId&&(w=_===r.DocumentEditArea.HEADER?n.HeaderFooterType.EVEN_PAGE_HEADER:n.HeaderFooterType.EVEN_PAGE_FOOTER)}),o.syncExecuteCommand(n.CreateHeaderFooterCommand.id,{unitId:l,segmentId:u,createType:w,headerFooterProps:f,createMode:y==null?`pair`:`single`,sectionId:y})}},Mc={id:`doc.command.open-header-footer-panel`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a;let o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.IRenderManagerService),l=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null)return!1;let u=l.getUnitId(),d=c.getRenderUnitById(u),f=d==null?void 0:d.with(n.DocSkeletonManagerService),p=f==null?void 0:f.getViewModel(),m=f==null?void 0:f.getSkeleton(),h=d==null?void 0:d.with(q),g=m==null||(a=m.getSkeletonData())==null?void 0:a.pages;if(p==null||h==null||!(g!=null&&g.length))return!1;let _=h.getSegmentPage(),v=_>=0&&_<g.length?_:0,y=g[v];p.setEditArea(r.DocumentEditArea.HEADER);let{createType:b,headerFooterId:x,sectionId:S}=Dc(p,r.DocumentEditArea.HEADER,v,y);if(h.setSegmentPage(v),b!=null){let e=(0,t.generateRandomId)(6);if(h.setSegment(e),!await o.executeCommand(jc.id,{unitId:u,createType:b,segmentId:e,sectionId:S}))return h.setSegment(``),h.setSegmentPage(-1),p.setEditArea(r.DocumentEditArea.BODY),!1}else x!=null&&h.setSegment(x);return o.executeCommand(kc.id,{value:`open`})}},Nc={id:`doc.command.close-header-footer`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a,o,s;let c=e.get(t.ICommandService),l=e.get(r.IRenderManagerService),u=e.get(n.DocSelectionManagerService),d=e.get(t.IUniverInstanceService),f=(i==null?void 0:i.unitId)??((a=d.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:a.getUnitId());if(f==null)return!1;let p=l.getRenderUnitById(f);if(p==null)return!1;let m=p.with(n.DocSkeletonManagerService),h=m==null?void 0:m.getViewModel();if(h==null||h.getEditArea()===r.DocumentEditArea.BODY)return!1;let g=m==null?void 0:m.getSkeleton();if(g==null)return!1;let{scene:_}=p,v=_.getTransformerByCreate(),y=p.with(q);return u.replaceDocRanges([]),v.clearSelectedObjects(),y.setSegment(``),y.setSegmentPage(-1),h.setEditArea(r.DocumentEditArea.BODY),(typeof g.getSkeletonData==`function`?((o=g.getSkeletonData())==null?void 0:o.pages.length)??0:0)===0&&g.calculate(),(s=p.mainComponent)==null||s.makeDirty(!0),queueMicrotask(()=>{let e=d.getUnit(f),t=e==null?void 0:e.getSnapshot();if(t==null)return;let n=Tc(t);u.replaceDocRanges([{startOffset:n,endOffset:n}])}),c.executeCommand(kc.id,{value:`close`}),!0}};function Pc(e,t){let n=Fc(e.left,e.top,t),r=Fc(e.right,e.bottom,t);return{left:n.x,top:n.y,right:r.x,bottom:r.y}}function Fc(e,t,n){let{scaleX:r,scaleY:i}=n.getAncestorScale(),a=n.getViewport(`viewMain`);if(!a)return{x:e,y:t};let{viewportScrollX:o,viewportScrollY:s}=a;return{x:(e-o)*r,y:(t-s)*i}}function Ic(e,t,n){let{scaleX:r,scaleY:i}=n.getAncestorScale(),a=n.getViewport(`viewMain`);if(!a)return{x:e,y:t};let{viewportScrollX:o,viewportScrollY:s}=a;return{x:e/r+o,y:t/i+s}}let Lc=(e,t)=>{let{scene:i,mainComponent:a,engine:o}=t,s=t.with(n.DocSkeletonManagerService).getSkeleton(),c;if(e.collapsed){let t=s.findNodePositionByCharIndex(e.startOffset,!0,e.segmentId,e.segmentPage);t&&(c={startPosition:t,endPosition:t})}else c=Ve(s,e.startOffset,e.endOffset-1,e.segmentId,e.segmentPage);let l=a;if(!c)return;let u=l.getOffsetConfig(),{docsLeft:d,docsTop:f}=u,p=o.getCanvasElement();if(p==null)return;let m=p.getBoundingClientRect(),h=(0,r.pxToNum)(p.style.width),{top:g,left:_,width:v}=m,y=v/h,{scaleX:b,scaleY:x}=i.getAncestorScale(),{borderBoxPointGroup:S}=new Ze(u,s).getRangePointData(c.startPosition,e.collapsed?c.startPosition:c.endPosition);return wt(S).map(e=>Pc(e,i)).map(e=>({left:(e.left+d*b)*y+_,right:(e.right+d*b)*y+_,top:(e.top+f*x)*y+g,bottom:(e.bottom+f*x)*y+g}))},Rc=class extends t.Disposable{constructor(e,t,n,r){super(),this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._commandService=r,R(this,`_popupCountByUnit`,new Map),R(this,`_popupUnits$`,new s.BehaviorSubject(new Set)),R(this,`popupUnits$`,this._popupUnits$.asObservable())}dispose(){this._popupCountByUnit.clear(),this._popupUnits$.next(new Set),this._popupUnits$.complete(),super.dispose()}_beginPopupActivity(e){this._popupCountByUnit.set(e,(this._popupCountByUnit.get(e)??0)+1),this._publishPopupUnits();let t=!1;return{dispose:()=>{if(t)return;t=!0;let n=this._popupCountByUnit.get(e)??0;n<=1?this._popupCountByUnit.delete(e):this._popupCountByUnit.set(e,n-1),this._publishPopupUnits()}}}_publishPopupUnits(){this._popupUnits$.next(new Set(this._popupCountByUnit.keys()))}getRangeBounds(e,t){let n=this._renderManagerService.getRenderUnitById(t);return n?Lc(e,n):void 0}_shouldUpdateForCommand(e,t){if(e.id!==vo.id&&e.id!==n.RichTextEditingMutation.id)return!1;let r=e.params;return(r==null?void 0:r.unitId)==null||r.unitId===t}_createRectPositionObserver(e,n){let i=()=>{let{scene:t,engine:i}=n,a=typeof e==`function`?e():e,o=i.getCanvasElement();if(o==null)return;let s=o.getBoundingClientRect(),c=(0,r.pxToNum)(o.style.width),l=Pc(a,t),{top:u,left:d,width:f}=s,p=f/c;return{left:l.left*p+d,right:l.right*p+d,top:l.top*p+u,bottom:l.bottom*p+u}},a=i();if(a==null)throw Error(`Current render canvas not found, unitId: ${n.unitId}`);let o=new s.BehaviorSubject(a),c=new t.DisposableCollection,l=()=>{try{let e=i();e&&o.next(e)}catch{}};c.add(this._commandService.onCommandExecuted(e=>{this._shouldUpdateForCommand(e,n.unitId)&&l()}));let u=n.scene.getViewport(`viewMain`);return u&&c.add(u.onScrollAfter$.subscribeEvent(()=>{l()})),c.add(n.scene.onTransformChange$.subscribeEvent(()=>{l()})),{position:a,position$:o,disposable:c,updatePosition:l}}_createObjectPositionObserver(e,t){let n=this._createRectPositionObserver(()=>{let{left:t,top:n,width:r,height:i}=e;return{left:t,right:t+r,top:n,bottom:n+i}},t);return n.disposable.add(e.onTransformChange$.subscribeEvent(n.updatePosition)),n}_createRangePositionObserver(e,r){var i;let a=Lc(e,r)??[],o=new s.BehaviorSubject(a),c=new t.DisposableCollection,l=()=>{try{o.next(Lc(e,r)??[])}catch{}},u=(i=r.with(n.DocSkeletonManagerService).getSkeleton().dirty$)==null?void 0:i.subscribe(l);u&&c.add(u),c.add(this._commandService.onCommandExecuted(e=>{this._shouldUpdateForCommand(e,r.unitId)&&l()}));let d=r.scene.getViewport(`viewMain`);return d&&c.add(d.onScrollAfter$.subscribeEvent(()=>{l()})),c.add(r.scene.onTransformChange$.subscribeEvent(()=>{l()})),{positions:a,positions$:o,disposable:c}}attachPopupToRect(e,t,n){let r=this._renderManagerService.getRenderUnitById(n);if(!r)throw Error(`Current render not found, unitId: ${n}`);let i=this._resolveEmbeddedPopupInjector(n,r),a=this._resolvePopupManagerService(i),{position:o,position$:s,disposable:c}=this._createRectPositionObserver(e,r),l=a.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:i,anchorRect:o,anchorRect$:s,canvasElement:r.engine.getCanvasElement()}),u=t.requiresStableLayout===!1?null:this._beginPopupActivity(n);return{dispose:()=>{a.removePopup(l),s.complete(),c.dispose(),u==null||u.dispose()},canDispose:()=>a.activePopupId!==l}}attachPopupToObject(e,t,n){let r=this._renderManagerService.getRenderUnitById(n);if(!r)throw Error(`Current render not found, unitId: ${n}`);let i=this._resolveEmbeddedPopupInjector(n,r),a=this._resolvePopupManagerService(i),{position:o,position$:s,disposable:c}=this._createObjectPositionObserver(e,r),l=a.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:i,anchorRect:o,anchorRect$:s,canvasElement:r.engine.getCanvasElement()}),u=t.requiresStableLayout===!1?null:this._beginPopupActivity(n);return{dispose:()=>{a.removePopup(l),s.complete(),c.dispose(),u==null||u.dispose()},canDispose:()=>a.activePopupId!==l}}attachPopupToRange(e,t,n){if(!this._univerInstanceService.getUnit(n))throw Error(`Document not found, unitId: ${n}`);let{direction:r=`top`,multipleDirection:i}=t,a=this._renderManagerService.getRenderUnitById(n);if(!a)throw Error(`Current render not found, unitId: ${n}`);let o=this._resolveEmbeddedPopupInjector(n,a),c=this._resolvePopupManagerService(o),{positions$:l,disposable:u}=this._createRangePositionObserver(e,a),d=n=>{if(t.rangeAnchor===`selection-end`){let t=e.direction===`backward`,r=t?n[0]:n[n.length-1],i=t?r.left:r.right;return{...r,left:i,right:i}}return r.includes(`top`)?n[0]:n[n.length-1]},f=l.pipe((0,s.filter)(e=>e.length>0),(0,s.map)(d)),p,m=null,h=()=>{p!=null&&(c.removePopup(p),p=void 0),m==null||m.dispose(),m=null};return u.add(l.subscribe(e=>{if(e.length===0){h();return}p??(p=c.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:o,anchorRect:d(e),anchorRect$:f,excludeRects:e,excludeRects$:l,direction:[`top`,`bottom`,`horizontal`].some(e=>r.includes(e))&&e.length>1?i??r:r,canvasElement:a.engine.getCanvasElement()}),m=t.requiresStableLayout===!1?null:this._beginPopupActivity(n))})),{dispose:()=>{h(),l.complete(),u.dispose()},canDispose:()=>p==null||c.activePopupId!==p}}_resolveEmbeddedPopupInjector(e,t){var n,r;return t.isMainScene===!1||((n=this._univerInstanceService.getUnitCreateOptions(e))==null?void 0:n.embeddedRender)===!0?(r=t.getInjector)==null?void 0:r.call(t):void 0}_resolvePopupManagerService(e){return e!=null&&e.has(a.ICanvasPopupService)?e.get(a.ICanvasPopupService):this._globalPopupManagerService}};Rc=B([z(0,(0,t.Inject)(a.ICanvasPopupService)),z(1,r.IRenderManagerService),z(2,t.IUniverInstanceService),z(3,t.ICommandService)],Rc);let zc=(e,t,n,r)=>{let i=n.getSkeletonData(),a=e.collapsed?e.startOffset:e.endOffset-1;if(e.segmentId){var o,s;let t=Array.from((i==null||(o=i.skeFooters.get(e.segmentId))==null?void 0:o.values())??[])[0]??Array.from((i==null||(s=i.skeHeaders.get(e.segmentId))==null?void 0:s.values())??[])[0];t&&(a=Math.min(t.ed,a))}let c=Ve(n,e.startOffset,a,e.segmentId,r);if(!c)return;let l=t.getOffsetConfig(),{borderBoxPointGroup:u}=new Ze(l,n).getRangePointData(c.startPosition,c.endPosition);return wt(u).map(e=>({top:e.top+l.docsTop-4,bottom:e.bottom+l.docsTop+4,left:e.left+l.docsLeft,right:e.right+l.docsLeft}))},Bc=(e,t,n,r)=>{let i=[];for(let a of e){let e=a.top;for(let o of a.columns){let s=o.left,c=a.colCount===1?r:o.width,l=null;for(let r of o.lines){let a=r.paragraphIndex;if(r.paragraphStart){l&&=(i.push(l),null);let o={top:t+e+r.top,left:n+s,right:n+s+c,bottom:t+e+r.top+r.lineHeight};l={paragraphStart:r.st,paragraphEnd:a,startIndex:a,rect:o,fisrtLine:{top:t+e+r.top+r.marginTop+r.paddingTop,left:n+s,right:n+s+c,bottom:t+e+r.top+r.marginTop+r.paddingTop+r.contentHeight}}}else l&&l.startIndex===a&&(l.rect.bottom=t+e+r.top+r.lineHeight)}l&&i.push(l)}}return i},Vc=(e,t,n)=>{let r=[],i=new Map;for(let a of e){let{column:e,line:o,lineWidth:s,pageLeft:c,sectionTop:l}=a,u=o.paragraphIndex,d=c+e.left+t,f=l+o.top+n,p=Hc(a,f),m=`${a.source}:${a.pageIndex}:${c}:${e.left}:${u}`;if(o.paragraphStart){let e=i.get(m);e&&r.push(e),i.set(m,{paragraphStart:o.st,paragraphEnd:u,startIndex:u,rect:{top:f,left:d,right:d+s,bottom:p},fisrtLine:{top:f+o.marginTop+o.paddingTop,left:d,right:d+s,bottom:f+o.marginTop+o.paddingTop+o.contentHeight}})}else{let e=i.get(m);e&&(e.rect.bottom=p)}}return r.push(...i.values()),r};function Hc(e,t){let n=t+e.line.lineHeight;if(e.source!==`column`||e.line!==e.column.lines[e.column.lines.length-1]||!Number.isFinite(e.page.pageHeight))return n;let r=t-e.line.top-e.section.top;return Math.max(n,r+e.page.pageHeight)}let Uc=(e,t,n,r=-1)=>{let i=n.findPositionByGlyph(e,r);if(!i)return;let a=t.getOffsetConfig(),o={...i,isBack:!0},{borderBoxPointGroup:s}=new Ze(a,n).getRangePointData(o,o),c=wt(s)[0];if(c)return{top:c.top+a.docsTop,bottom:c.bottom+a.docsTop,left:c.left+a.docsLeft,right:c.left+a.docsLeft+e.width}};function Wc(e,t,n){let r=qc(e,t);return!r||!Jc(n.x,n.y,r.rect)?null:r}function Gc(e,t,n){return Wc(e,t,n)}function Kc(e){return e===t.PresetListType.CHECK_LIST||e===t.PresetListType.CHECK_LIST_CHECKED}function qc(e,t){return t!=null&&t.bullet?{paragraph:t,rect:{bottom:e.firstLine.bottom,left:e.rect.left,right:Math.min(e.rect.right,e.rect.left+36),top:e.firstLine.top},segmentId:e.segmentId,segmentPageIndex:e.pageIndex}:null}function Jc(e,t,n){let{left:r,right:i,top:a,bottom:o}=n;return e>=r&&e<=i&&t>=a&&t<=o}function Yc(e){return Math.max(0,e.right-e.left)*Math.max(0,e.bottom-e.top)}function Xc(e,t){return e.left<=t.left&&e.right>=t.right&&e.top<=t.top&&e.bottom>=t.bottom}function Zc(e){return Math.max(0,e.paragraphEnd-e.paragraphStart)}function Qc(e){return e.sort((e,t)=>Yc(e.rect)-Yc(t.rect)||Zc(e)-Zc(t))[0]}function $c(e){return e.filter(t=>!e.some(e=>e!==t&&Yc(e.rect)<Yc(t.rect)&&Xc(t.rect,e.rect)))}function el(e){return{bottom:e.bottom,left:e.left-72,right:e.right,top:e.top-42}}function tl(e,t,n){let r=nl(n),i=r?e-(n.leadingInsetLeft??0):e;return{scrollLeft:r?n.scrollLeft:0,visibleLeft:i,visibleRight:i+(r?n.viewportWidth:t)}}function nl(e){return e!=null&&(e.leadingInsetLeft??0)+e.contentWidth+(e.trailingInsetRight??0)>e.viewportWidth}let rl=class extends t.Disposable{get hoverParagraph(){return this._hoverParagraph$.value}get hoverParagraphLeft(){return this._hoverParagraphLeft$.value}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}get _documents(){return this._context.mainComponent}constructor(e,t){super(),this._context=e,this._docSkeletonManagerService=t,R(this,`_hoverCustomRanges$`,new s.BehaviorSubject([])),R(this,`hoverCustomRanges$`,this._hoverCustomRanges$.pipe((0,s.distinctUntilChanged)((e,t)=>e.length===t.length&&e.every((e,n)=>t[n].range.rangeId===e.range.rangeId&&t[n].segmentId===e.segmentId&&t[n].segmentPageIndex===e.segmentPageIndex&&t[n].range.startIndex===e.range.startIndex)))),R(this,`_clickCustomRanges$`,new s.Subject),R(this,`clickCustomRanges$`,this._clickCustomRanges$.asObservable()),R(this,`_pointerDownCustomRanges$`,new s.Subject),R(this,`pointerDownCustomRanges$`,this._pointerDownCustomRanges$.asObservable()),R(this,`_hoverBullet$`,new s.Subject),R(this,`hoverBullet$`,this._hoverBullet$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.paragraph.startIndex)===(t==null?void 0:t.paragraph.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.segmentPageIndex)===(t==null?void 0:t.segmentPageIndex)))),R(this,`_clickBullet$`,new s.Subject),R(this,`clickBullets$`,this._clickBullet$.asObservable()),R(this,`_contextMenuBullet$`,new s.Subject),R(this,`contextMenuBullets$`,this._contextMenuBullet$.asObservable()),R(this,`_hoverParagraph$`,new s.BehaviorSubject(null)),R(this,`hoverParagraph$`,this._hoverParagraph$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.startIndex)===(t==null?void 0:t.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverParagraphRealTime$`,this._hoverParagraph$.asObservable()),R(this,`_hoverParagraphLeft$`,new s.BehaviorSubject(null)),R(this,`hoverParagraphLeft$`,this._hoverParagraphLeft$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.startIndex)===(t==null?void 0:t.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverParagraphLeftRealTime$`,this._hoverParagraphLeft$.asObservable()),R(this,`_hoverTableCell$`,new s.Subject),R(this,`hoverTableCell$`,this._hoverTableCell$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.rowIndex)===(t==null?void 0:t.rowIndex)&&(e==null?void 0:e.colIndex)===(t==null?void 0:t.colIndex)&&(e==null?void 0:e.tableId)===(t==null?void 0:t.tableId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverTableCellRealTime$`,this._hoverTableCell$.asObservable()),R(this,`_hoverTable$`,new s.Subject),R(this,`hoverTable$`,this._hoverTable$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.tableId)===(t==null?void 0:t.tableId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverTableRealTime$`,this._hoverTable$.asObservable()),R(this,`_customRangeDirty`,!0),R(this,`_customRangeCount`,-1),R(this,`_customRangeSkeletonSignature`,``),R(this,`_bulletDirty`,!0),R(this,`_paragraphDirty`,!0),R(this,`_tableBoundsDirty`,!0),R(this,`_customRangeBounds`,[]),R(this,`_bulletBounds`,[]),R(this,`_paragraphBounds`,new Map),R(this,`_paragraphLeftBounds`,[]),R(this,`_tableParagraphBounds`,new Map),R(this,`_tableParagraphBoundsByIndex`,new Map),R(this,`_segmentParagraphBounds`,new Map),R(this,`_tableViewportSignature`,``),R(this,`_tableCellBounds`,new Map),R(this,`_tableCellGeometries`,new Map),R(this,`_tableCellPages`,new Set),R(this,`_tableBounds`,new Map),R(this,`contextMenuParagraph`,null),this._initResetDirty(),this._initEvents(),this._initPointer()}dispose(){this._hoverCustomRanges$.complete(),this._clickCustomRanges$.complete(),this._pointerDownCustomRanges$.complete(),super.dispose()}_initPointer(){let e=r.CURSOR_TYPE.TEXT;this.disposeWithMe(this.hoverCustomRanges$.subscribe(t=>{t.length?(e=this._context.scene.getCursor(),this._context.scene.setCursor(r.CURSOR_TYPE.POINTER)):this._context.scene.setCursor(e)}))}_initResetDirty(){this.disposeWithMe(this._skeleton.dirty$.subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0})),this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.filter)(e=>e.type===r.TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)).subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0})),this.disposeWithMe((0,t.fromEventSubject)(this._context.scene.onTransformChange$).pipe((0,s.filter)(e=>e.type===r.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale)).subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0}))}_initEvents(){this.disposeWithMe((0,t.fromEventSubject)(this._context.scene.onPointerMove$).pipe((0,s.throttleTime)(30,void 0,{leading:!0,trailing:!0})).subscribe(e=>{if(e.buttons>0){this._hoverBullet$.next(null),this._hoverCustomRanges$.next([]),this._hoverParagraph$.next(null),this._hoverParagraphLeft$.next(null),this._hoverTableCell$.next(null),this._hoverTable$.next(null);return}let{x:t,y:n}=Ic(e.offsetX,e.offsetY,this._context.scene);this._hoverCustomRanges$.next(this._calcActiveRanges({x:t,y:n})),this._hoverParagraph$.next(this._calcActiveParagraph({x:t,y:n})),this._hoverParagraphLeft$.next(this._calcActiveParagraphLeft({x:t,y:n})),this._hoverBullet$.next(this._calcActiveBullet({x:t,y:n}))})),this.disposeWithMe(this._context.scene.onPointerEnter$.subscribeEvent(()=>{this._hoverBullet$.next(null),this._hoverCustomRanges$.next([])}));let e=(0,t.fromEventSubject)(this._context.mainComponent.onPointerDown$),n=(0,t.fromEventSubject)(this._context.scene.onPointerUp$);this.disposeWithMe(e.pipe((0,s.tap)(e=>{if(e.button!==0)return;let t=Ic(e.offsetX,e.offsetY,this._context.scene);this._pointerDownCustomRanges$.next(this._calcActiveRanges(t))}),(0,s.switchMap)(e=>n.pipe((0,s.take)(1),(0,s.map)(t=>({down:e,up:t})))),(0,s.filter)(({down:e,up:t})=>e.target===t.target&&(e.button===2||t.timeStamp-e.timeStamp<300))).subscribe(({down:e})=>{let n=Ic(e.offsetX,e.offsetY,this._context.scene);if(e.button===2){let t=this._calcActiveBullet(n)??this._calcActiveListParagraph(n);t&&this._contextMenuBullet$.next({...t,x:e.offsetX,y:e.offsetY});return}let r=this._calcActiveRanges(n);if(r.length){let n=r.filter(({range:e})=>e.rangeType===t.CustomRangeType.HYPERLINK).pop(),i=r.filter(({range:e})=>e.rangeType===t.CustomRangeType.SDT).sort((e,t)=>e.range.endIndex-e.range.startIndex-(t.range.endIndex-t.range.startIndex))[0];this._clickCustomRanges$.next({...n??i??r.pop(),ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey})}let i=this._calcActiveBullet(n);i&&this._clickBullet$.next(i)}))}isPointerOnBullet(e,t){return!!this._calcActiveBullet(Ic(e,t,this._context.scene))}isPointerOnInteractiveRange(e,n){return this._calcActiveRanges(Ic(e,n,this._context.scene)).some(({range:e})=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK||e.rangeType===t.CustomRangeType.SDT&&[`checkbox`,`date`,`dropDownList`,`comboBox`,`text`,`richText`,`picture`].includes((n=e.properties)==null?void 0:n.kind)})}isPointerOnNonChecklistBullet(e,t){var n;let r=this._calcActiveBullet(Ic(e,t,this._context.scene));return!(!r||Kc((n=r.paragraph.bullet)==null?void 0:n.listType))}getBulletBounds(){return this._buildBulletBounds(),[...this._bulletBounds]}getListContextMenuBulletByOffset(e,t){let n=Ic(e,t,this._context.scene);return this._calcActiveBullet(n)??this._calcActiveListParagraph(n)}_buildCustomRangeBoundsBySegment(e,t=-1){var n;let r=((n=this._context.unit.getSelfOrHeaderFooterModel(e))==null||(n=n.getBody())==null?void 0:n.customRanges)??[],i=[];return r.forEach(n=>{let r={startOffset:n.startIndex,endOffset:n.endIndex+1,collapsed:!1,segmentId:e},a;try{a=zc(r,this._documents,this._skeleton,t)}catch{return}a&&i.push({customRange:n,rects:a,segmentId:e,segmentPageIndex:t})}),i}_buildCustomRangeBounds(){var e,t,n,r,i;let a=((e=(t=this._context.unit).getBody)==null||(e=e.call(t))==null||(e=e.customRanges)==null?void 0:e.length)??0,o=((n=this._skeleton.getSkeletonData())==null?void 0:n.pages)??[],s=`${o.length}:${((r=o[o.length-1])==null?void 0:r.ed)??-1}`,c=this._customRangeCount===-1||this._customRangeCount===a,l=this._customRangeSkeletonSignature===``||this._customRangeSkeletonSignature===s;if(!this._customRangeDirty&&c&&l&&(a===0||this._customRangeBounds.length>0))return;this._customRangeDirty=!1,this._customRangeCount=a,this._customRangeSkeletonSignature=s;let u=[];u.push(...this._buildCustomRangeBoundsBySegment()),(i=this._skeleton.getSkeletonData())==null||i.pages.forEach((e,t)=>{e.headerId&&u.push(...this._buildCustomRangeBoundsBySegment(e.headerId,t)),e.footerId&&u.push(...this._buildCustomRangeBoundsBySegment(e.footerId,t))}),this._customRangeBounds=u}_calcActiveRanges(e){this._buildCustomRangeBounds();let{x:t,y:n}=e;return this._customRangeBounds.filter(e=>e.rects.some(e=>Jc(t,n,e))).map(e=>({segmentId:e.segmentId,range:e.customRange,segmentPageIndex:e.segmentPageIndex,rects:e.rects}))}_buildBulletBoundsBySegment(e,t=-1){var n;let r=(n=this._context.unit.getSelfOrHeaderFooterModel(e))==null?void 0:n.getBody(),i=((r==null?void 0:r.paragraphs)??[]).filter(e=>e.bullet),a=[],o=this._skeleton.getSkeletonData();if(!o)return a;let s=n=>{for(let o of n){let n=[...o.sections];if(o.skeTables){let e=Array.from(o.skeTables.values());n.push(...e.map(e=>e.rows.map(e=>e.cells.map(e=>e.sections))).flat(4))}for(let o of n)for(let n of o.columns)for(let o of n.lines)if(o.paragraphStart){let n=i.find(e=>e.startIndex===o.paragraphIndex);if(n){var r;let i=o,s=i==null||(r=i.divides)==null||(r=r[0])==null||(r=r.glyphGroup)==null?void 0:r[0];if(!s)continue;let c=Uc(s,this._documents,this._skeleton,t);if(!c)continue;a.push({rect:c,segmentId:e,segmentPageIndex:t,paragraph:n})}}}return a};if(e){var c,l;let t=((c=o.skeFooters.get(e))==null?void 0:c.values())??((l=o.skeHeaders.get(e))==null?void 0:l.values());return t?s(Array.from(t)):a}return s(o.pages)}_buildBulletBounds(){var e;this._bulletDirty&&(this._bulletDirty=!1,this._bulletBounds=[],this._bulletBounds.push(...this._buildBulletBoundsBySegment()),(e=this._skeleton.getSkeletonData())==null||e.pages.forEach((e,t)=>{e.headerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(e.headerId,t)),e.footerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(e.footerId,t))}))}_calcActiveBullet(e){this._buildBulletBounds();let{x:t,y:n}=e,r=this._bulletBounds.find(e=>Jc(t,n,e.rect));if(r)return r;let i=this._calcActiveParagraph(e);return i?Wc(i,this._getParagraphByStartIndex(i.startIndex,i.segmentId),e):null}_calcActiveListParagraph(e){let t=this._calcActiveParagraph(e);return t?Gc(t,this._getParagraphByStartIndex(t.startIndex,t.segmentId),e):null}_getParagraphByStartIndex(e,t){var n;return(n=this._context.unit.getSelfOrHeaderFooterModel(t))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(t=>t.startIndex===e)}_buildParagraphBoundsBySegment(e){let t=this._skeleton.getSkeletonData(),n=this._documents.getOffsetConfig();if(!t)return null;let i=t=>{let i=new Map,a=(e,t,n,r)=>{t.forEach(t=>{if(!e.has(t.startIndex))e.set(t.startIndex,{rect:t.rect,paragraphStart:t.paragraphStart,paragraphEnd:t.paragraphEnd,startIndex:t.startIndex,rects:[t.rect],pageIndex:n,segmentId:r,firstLine:t.fisrtLine});else{let n=e.get(t.startIndex);n&&(n.rect.bottom=t.rect.bottom,n.rects.push(t.rect))}})},o=new Map;return(0,r.documentSkeletonLineIterator)(t,{docsLeft:n.docsLeft,pageMarginTop:n.pageMarginTop,unitId:this._context.unitId},e=>{if(e.source===`table-cell`)return;let t=o.get(e.pageIndex)??[];t.push(e),o.set(e.pageIndex,t)}),o.forEach((t,r)=>{a(i,Vc(t,n.docsLeft,n.docsTop),r,e)}),i};if(e){var a,o;let n=((a=t.skeFooters.get(e))==null?void 0:a.values())??((o=t.skeHeaders.get(e))==null?void 0:o.values());return n?i(Array.from(n)):null}return i(t.pages)}_buildParagraphBounds(){var e;if(!this._paragraphDirty)return;this._paragraphDirty=!1,this._tableParagraphBounds=new Map,this._tableParagraphBoundsByIndex=new Map,this._paragraphBounds=this._buildParagraphBoundsBySegment()??new Map,this._paragraphLeftBounds=Array.from(this._paragraphBounds.values()).map(e=>({...e,rect:{left:e.rect.left-60,right:e.rect.left,top:e.rect.top,bottom:e.rect.bottom}}));let t=e=>{this._segmentParagraphBounds.set(e,this._buildParagraphBoundsBySegment(e)??new Map)};(e=this._skeleton.getSkeletonData())==null||e.pages.forEach(e=>{e.headerId&&t(e.headerId),e.footerId&&t(e.footerId)})}_buildTableBounds(){let e=this._getTableViewportSignature();if(!this._tableBoundsDirty&&this._tableViewportSignature===e)return;this._tableBoundsDirty=!1,this._tableViewportSignature=e,this._tableBounds=new Map,this._tableCellBounds=new Map,this._tableCellGeometries=new Map,this._tableCellPages=new Set,this._tableParagraphBounds=new Map,this._tableParagraphBoundsByIndex=new Map;let t=this._skeleton.getSkeletonData(),n=t==null?void 0:t.pages;if(!n)return;let{docsLeft:i,docsTop:a,pageMarginTop:o}=this._documents.getOffsetConfig();for(let e of(0,r.documentSkeletonTableIterator)(n,{docsLeft:i,docsTop:a,includeCells:!1,pageMarginTop:o,skeFooters:t.skeFooters,skeHeaders:t.skeHeaders,unitId:this._context.unitId})){let t=e.tableId,n=(0,r.getTableIdAndSliceIndex)(t).tableId,i=tl(e.tableRect.left,e.table.width,(0,r.getDocsTableRenderViewport)(this._context.unitId,n));this._tableBounds.set(t,{rect:{...e.tableRect,right:i.visibleRight},pageIndex:e.pageIndex,tableId:t})}}_buildTableCellsForPage(e){if(this._tableCellPages.has(e))return;let t=this._skeleton.getSkeletonData(),n=t==null?void 0:t.pages[e];if(!t||!n)return;this._tableCellPages.add(e);let{docsLeft:i,docsTop:a,pageMarginTop:o}=this._documents.getOffsetConfig(),s=t.pages.slice(0,e).reduce((e,t)=>e+(t.pageHeight===1/0?0:t.pageHeight)+o,0),c=(0,r.documentSkeletonTableIterator)([n],{docsLeft:i,docsTop:a+s,includeCells:!0,pageMarginTop:o,skeFooters:t.skeFooters,skeHeaders:t.skeHeaders,unitId:this._context.unitId});for(let t of c){let n=t.tableId,r=t.source===`header`?t.rootPage.headerId:t.source===`footer`?t.rootPage.footerId:void 0,i=this._tableCellGeometries.get(n)??[],a=this._tableCellBounds.get(n)??[];for(let o of t.cells)i.push({cellGeometry:o,pageIndex:e,segmentId:r}),a.push({rect:o.cellRect,pageIndex:e,rowIndex:o.rowIndex,colIndex:o.columnIndex,tableId:n});this._tableCellGeometries.set(n,i),this._tableCellBounds.set(n,a)}}_buildTableCellsForDocumentRange(e,t){var n;let i=(n=this._context.unit.getSelfOrHeaderFooterModel())==null?void 0:n.getBody(),a=new Set(((i==null?void 0:i.tables)??[]).filter(n=>t>=n.startIndex&&e<n.endIndex).map(e=>e.tableId));if(a.size===0){this._tableBounds.forEach(e=>this._buildTableCellsForPage(e.pageIndex));return}this._tableBounds.forEach((e,t)=>{a.has((0,r.getTableIdAndSliceIndex)(t).tableId)&&this._buildTableCellsForPage(e.pageIndex)})}_getTableParagraphBoundsForCell(e,t,n,r){var i,a;let o=(i=this._tableParagraphBounds.get(e))==null?void 0:i.filter(e=>e.pageIndex===r&&e.rowIndex===t&&e.colIndex===n);if(o!=null&&o.length)return o;let s=(a=this._tableCellGeometries.get(e))==null?void 0:a.find(e=>e.pageIndex===r&&e.cellGeometry.rowIndex===t&&e.cellGeometry.columnIndex===n);if(!s)return[];let{cellGeometry:c,segmentId:l}=s,u=c.cell,d=(u.pageWidth??0)-(u.marginLeft??0)-(u.marginRight??0),f=Bc(u.sections,c.pageTop,c.pageLeft,d).map(e=>ol(e,c.clipLeft,c.clipRight)).filter(e=>e!=null).map(i=>({rect:i.rect,paragraphStart:i.paragraphStart,paragraphEnd:i.paragraphEnd,startIndex:i.startIndex,pageIndex:r,segmentId:l,rowIndex:t,colIndex:n,firstLine:i.fisrtLine,tableId:e})),p=(this._tableParagraphBounds.get(e)??[]).filter(e=>e.pageIndex!==r||e.rowIndex!==t||e.colIndex!==n);return p.push(...f),this._tableParagraphBounds.set(e,p),f.forEach(e=>this._tableParagraphBoundsByIndex.set(e.startIndex,e)),f}getParagraphByOffset(e,t){return this._calcActiveParagraph(Ic(e,t,this._context.scene))}_calcActiveParagraph(e){let{x:t,y:n}=e;this._buildTableBounds();let i=(0,r.getTopmostDocsTableHit)(Array.from(this._tableBounds.values()),e=>Jc(t,n,e.rect),e=>Jc(t,n,el(e.rect)),(e,t)=>Yc(t.rect)<Yc(e.rect)&&Xc(e.rect,t.rect));if(this._hoverTable$.next(i),i){var a;this._buildTableCellsForPage(i.pageIndex);let e=(a=this._tableCellBounds.get(i.tableId))==null?void 0:a.find(e=>Jc(t,n,e.rect));if(this._hoverTableCell$.next(e),!e)return null;let r=this._getTableParagraphBoundsForCell(e.tableId,e.rowIndex,e.colIndex,e.pageIndex),o=r==null?void 0:r.find(e=>Jc(t,n,e.rect));return o&&{...o,rects:[o.rect]}}return this._buildParagraphBounds(),Qc([...this._paragraphBounds.values()].filter(e=>e.rects.some(e=>Jc(t,n,e))))}_calcActiveParagraphLeft(e){this._buildParagraphBounds();let{x:t,y:n}=e;return Qc(this._paragraphLeftBounds.filter(e=>Jc(t,n,e.rect)))}get paragraphBounds(){return this._buildParagraphBounds(),this._paragraphBounds}get tableBounds(){return this._buildTableBounds(),this._tableBounds}findTableCellBound(e,t,n,i){var a;return this._buildTableBounds(),i==null?this._tableBounds.forEach((t,n)=>{(0,r.getTableIdAndSliceIndex)(n).tableId===(0,r.getTableIdAndSliceIndex)(e).tableId&&this._buildTableCellsForPage(t.pageIndex)}):this._buildTableCellsForPage(i),(a=this._tableCellBounds.get(e))==null?void 0:a.find(e=>e.rowIndex===t&&e.colIndex===n&&(i==null||e.pageIndex===i))}findParagraphBoundByIndex(e){this._buildTableBounds(),this._buildTableCellsForDocumentRange(e,e);let t=this._tableParagraphBoundsByIndex.get(e);if(!t)for(let[n,r]of this._tableCellGeometries)for(let i of r){let{st:r,ed:a}=i.cellGeometry.cell;if(!(r!=null&&a!=null&&(e<r||e>a))&&(this._getTableParagraphBoundsForCell(n,i.cellGeometry.rowIndex,i.cellGeometry.columnIndex,i.pageIndex),t=this._tableParagraphBoundsByIndex.get(e),t))return t}if(t)return t;this._buildParagraphBounds();let n=this._paragraphBounds.get(e);if(n)return n}findParagraphBoundsInRange(e,t){this._buildTableBounds(),this._buildTableCellsForDocumentRange(e,t),this._buildParagraphBounds();for(let[n,r]of this._tableCellGeometries)r.filter(n=>{let{st:r,ed:i}=n.cellGeometry.cell;return r==null||i==null||t>=r&&e<=i}).forEach(e=>this._getTableParagraphBoundsForCell(n,e.cellGeometry.rowIndex,e.cellGeometry.columnIndex,e.pageIndex));return il([...this._paragraphBounds.values()],Array.from(this._tableParagraphBounds.values()).flat().map(e=>({rect:e.rect,paragraphStart:e.paragraphStart,paragraphEnd:e.paragraphEnd,startIndex:e.startIndex,rects:[e.rect],pageIndex:e.pageIndex,segmentId:e.segmentId,firstLine:e.firstLine})),e,t)}_getTableViewportSignature(){var e;if(this._tableBounds.size>0){let e=new Set;return this._tableBounds.forEach((t,n)=>e.add((0,r.getTableIdAndSliceIndex)(n).tableId)),Array.from(e).map(e=>{let t=(0,r.getDocsTableRenderViewport)(this._context.unitId,e);return t?`${e}:${t.contentWidth}:${t.viewportWidth}:${t.scrollLeft}`:`${e}:none`}).join(`|`)}let t=((e=this._skeleton.getSkeletonData())==null?void 0:e.pages)??[],n=[];for(let e of(0,r.documentSkeletonTableIterator)(t,{includeCells:!1,pageMarginTop:this._documents.getOffsetConfig().pageMarginTop,resolveViewport:!1,unitId:this._context.unitId})){let t=(0,r.getTableIdAndSliceIndex)(e.tableId).tableId,i=(0,r.getDocsTableRenderViewport)(this._context.unitId,t);if(!i){n.push(`${t}:none`);continue}n.push(`${t}:${i.contentWidth}:${i.viewportWidth}:${i.scrollLeft}`)}return n.join(`|`)}};rl=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService))],rl);function il(e,t,n,r){let i=t.filter(e=>al(e,n,r));return i.length?i:$c(e.filter(e=>al(e,n,r)))}function al(e,t,n){return Math.max(e.paragraphStart,t)<=Math.min(e.paragraphEnd,n)}function ol(e,t,n){let r=sl(e.rect,t,n);return r?{...e,rect:r,fisrtLine:sl(e.fisrtLine,t,n)??r}:null}function sl(e,t,n){let r=Math.max(e.left,t),i=Math.min(e.right,n);return i<=r?null:{...e,left:r,right:i}}let cl={id:`doc.operation.open-paragraph-permission`,type:t.CommandType.OPERATION,handler(e){var i;let s=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=s&&((i=e.get(r.IRenderManagerService).getRenderUnitById(s.getUnitId()))==null?void 0:i.with(rl).contextMenuParagraph);if(!c)return!1;let{unitId:l,segmentId:u,paragraphId:d}=c,f=()=>{var n;return((n=e.get(t.IUniverInstanceService).getUnit(l))==null||(n=n.getSelfOrHeaderFooterModel(u))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.some(e=>e.paragraphId===d))===!0};return f()?(0,a.openObjectPermissionDialog)(e,{target:{unitId:l,objectId:(0,n.getDocumentParagraphPermissionObjectId)(u,d),objectType:o.UnitObject.DocumentParagraph},name:e.get(t.LocaleService).t(`docs-ui.objectPermission.paragraph`),commandId:n.SetDocumentPermissionCommand.id,exists:f}):!1}},ll={id:`doc.operation.open-permission-panel`,type:t.CommandType.OPERATION,handler(e){let r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!r||(0,t.isInternalEditorID)(r.getUnitId()))return!1;let i=r,s=i.getUnitId();function*c(){let e=i.getSnapshot(),t=n.SetDocumentPermissionCommand.id,r=new Set([``,...Object.keys(e.headers??{}),...Object.keys(e.footers??{})]);for(let l of r){var a,c;let r=l?((a=e.headers)==null||(a=a[l])==null?void 0:a.body)??((c=e.footers)==null||(c=c[l])==null?void 0:c.body):e.body;for(let e of(r==null?void 0:r.sectionBreaks)??[]){if(!e.sectionId)continue;let r=(0,n.getDocumentSectionPermissionObjectId)(l,e.sectionId);yield{target:{unitId:s,objectId:r,objectType:o.UnitObject.DocumentSection},name:``,commandId:t,exists:()=>{var t;return((t=i.getSelfOrHeaderFooterModel(l))==null||(t=t.getBody())==null||(t=t.sectionBreaks)==null?void 0:t.some(t=>t.sectionId===e.sectionId))===!0}}}}}return(0,a.openObjectPermissionPanel)(e,{unitId:s,target:{unitId:s,objectId:s,objectType:o.UnitObject.DocumentSection},getTargets:c})}},ul=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._sidebarService=t,R(this,`_id`,void 0)}openPanel(){let e={header:{title:`docs-ui.doc.slider.paragraphSetting`},id:this._id,children:{label:`doc_ui_paragraph-setting-panel`},width:300};this._sidebarService.open(e)}closePanel(){this._sidebarService.close(this._id)}};ul=B([z(0,t.ICommandService),z(1,(0,t.Inject)(a.ISidebarService))],ul);let dl={id:`sidebar.operation.doc-paragraph-setting-panel`,type:t.CommandType.OPERATION,handler:e=>(e.get(ul).openPanel(),!0)},fl=`doc_ui_section-setting-panel`,pl=class extends t.Disposable{constructor(e,t){super(),this._sidebarService=e,this._selectionManager=t,R(this,`_panelId`,`DocSectionSetting`)}openPanel(){this._sidebarService.open({header:{title:`docs-ui.doc.slider.sectionSetting`},id:this._panelId,children:{label:fl},width:300})}closePanel(){this._sidebarService.close(this._panelId)}navigateToSectionEnd(e,t,n){let r={unitId:e,subUnitId:e},i=Math.max(t,n-1);this._selectionManager.replaceDocRanges([{startOffset:i,endOffset:i}],r,!0,{shouldFocus:!1})}};pl=B([z(0,(0,t.Inject)(a.ISidebarService)),z(1,(0,t.Inject)(n.DocSelectionManagerService))],pl);let ml={id:`sidebar.operation.doc-section-setting-panel`,type:t.CommandType.OPERATION,handler:e=>(e.get(pl).openPanel(),!0)};function hl(e){let t=e.getActiveTextRange();return!(t!=null&&t.collapsed)||t.segmentId||!Number.isInteger(t.startOffset)?null:t.startOffset}let gl={id:`docs.operation.insert-column-break`,type:t.CommandType.OPERATION,handler:e=>{let r=e.get(t.IUniverInstanceService),i=e.get(n.DocSelectionManagerService),a=e.get(t.ICommandService),o=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),s=hl(i);return!o||o.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||s==null?!1:a.syncExecuteCommand(n.InsertDocumentColumnBreakCommand.id,{unitId:o.getUnitId(),offset:s})}},_l={id:`docs.operation.insert-section-break`,type:t.CommandType.OPERATION,handler:(e,r)=>{var i;if(!r)return!1;let a=e.get(t.IUniverInstanceService),o=e.get(n.DocSelectionManagerService),s=e.get(t.ICommandService),c=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=hl(o),u=c==null?void 0:c.getBody();if(!c||!u||c.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||l==null)return!1;let d=(0,t.createSectionId)(new Set((i=u.sectionBreaks)==null?void 0:i.map(e=>e.sectionId)));return s.syncExecuteCommand(n.InsertDocumentSectionBreakCommand.id,{unitId:c.getUnitId(),offset:l,sectionId:d,nextSectionType:r.sectionType})}},vl=[t.ModernDocumentWidthMode.NARROW,t.ModernDocumentWidthMode.MEDIUM,t.ModernDocumentWidthMode.WIDE],yl=e=>Object.keys(t.PAGE_SIZE).find(n=>{let{width:r,height:i}=t.PAGE_SIZE[n];return e.width===r&&e.height===i})??`A4`,bl=e=>{let n=(e==null?void 0:e.width)??t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM];return vl.reduce((e,r)=>{let i=Math.abs(t.MODERN_DOCUMENT_WIDTH[e]-n);return Math.abs(t.MODERN_DOCUMENT_WIDTH[r]-n)<i?r:e},t.ModernDocumentWidthMode.MEDIUM)};function xl(e){let{children:t,muted:n}=e;return(0,u.jsx)(`label`,{className:(0,i.clsx)(`univer-text-sm univer-font-medium`,n?`univer-text-gray-500`:`univer-text-gray-900 dark:!univer-text-gray-0`),children:t})}function Sl(e){let{hooks:n,InputNumberComponent:r=i.InputNumber,SelectComponent:o=i.Select}=e,s=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC).getDocumentStyle(),c=(0,a.useDependency)(t.LocaleService),[d,f]=(0,l.useState)(()=>{var e,n;return{mode:s.documentFlavor===t.DocumentFlavor.TRADITIONAL?t.DocumentFlavor.TRADITIONAL:t.DocumentFlavor.MODERN,modernWidth:bl(s.pageSize),paperSize:yl(s.pageSize??t.PAGE_SIZE.A4),pageSize:{width:((e=s.pageSize)==null?void 0:e.width)??0,height:((n=s.pageSize)==null?void 0:n.height)??0},orientation:s.pageOrient??t.PageOrientType.PORTRAIT,margins:{top:s.marginTop??0,bottom:s.marginBottom??0,left:s.marginLeft??0,right:s.marginRight??0}}});(0,l.useEffect)(()=>{n.beforeClose=()=>d,n.beforeConfirm=()=>d},[d]);let p=e=>{f(n=>({...n,paperSize:e,pageSize:t.PAGE_SIZE[e]}))},m=(e,t)=>{f(n=>({...n,margins:{...n.margins,[e]:t||0}}))},h=e=>{f(t=>({...t,modernWidth:e}))};return(0,u.jsx)(`div`,{className:`univer-flex univer-flex-col univer-gap-4`,children:d.mode===t.DocumentFlavor.MODERN?(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2.5`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.modern-width`)}),(0,u.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2`,children:vl.map(e=>(0,u.jsxs)(`button`,{type:`button`,className:(0,i.clsx)(i.resetButtonClassName,i.borderClassName,`univer-h-16 univer-flex-col univer-gap-1 univer-rounded-lg univer-bg-gray-0 univer-text-sm univer-font-medium univer-text-gray-700 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-100`,{"!univer-border-primary-500 !univer-bg-primary-50 !univer-text-primary-600 dark:!univer-bg-primary-900":d.modernWidth===e}),onClick:()=>h(e),children:[(0,u.jsx)(`span`,{children:c.t(`docs-ui.page-settings.modern-width-${e}`)}),(0,u.jsxs)(`span`,{className:`univer-text-xs univer-font-normal univer-text-gray-400`,children:[t.MODERN_DOCUMENT_WIDTH[e],`px`]})]},e))})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.paper-size`)}),(0,u.jsx)(o,{className:`univer-w-full`,value:d.paperSize,onChange:p,options:t.PAPER_TYPES.map(e=>({label:c.t(`docs-ui.page-settings.page-size.${e.toLocaleLowerCase()}`),value:e}))})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.custom-paper-size`)}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.top`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.height/2,value:d.margins.top,onChange:e=>m(`top`,e)})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.bottom`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.height/2,value:d.margins.bottom,onChange:e=>m(`bottom`,e)})]})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.left`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.width/2,value:d.margins.left,onChange:e=>m(`left`,e)})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.right`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.width/2,value:d.margins.right,onChange:e=>m(`right`,e)})]})]})]})]})]})})}let Cl=`docs.component.page-setting`;function wl(e){var n;let r=((n=e.pageSize)==null?void 0:n.width)??0;return r?e.documentFlavor===t.DocumentFlavor.MODERN?Math.max(0,r-t.MODERN_DOCUMENT_DEFAULT_MARGIN*2):Math.max(0,r-(e.marginLeft??0)-(e.marginRight??0)):0}function Tl(e){return e.tableColumns.reduce((e,t)=>e+(t.size.width.v??0),0)}function El(e,t){if(t<=0||e.tableColumns.length===0)return!1;let n=Tl(e)||e.size.width.v;return Math.abs(n-t)<=2}function Dl(e,t,n,r,i){!n||r<=0||i<=0||Math.abs(r-i)<=2||Object.entries(n).forEach(([n,a])=>{if(!El(a,r))return;let o=Tl(a);if(o<=0)return;let s=e.replaceOp([`tableSource`,n,`size`,`width`,`v`],a.size.width.v,i);s&&t.push(s),a.tableColumns.forEach((r,a)=>{let s=r.size.width.v/o*i,c=e.replaceOp([`tableSource`,n,`tableColumns`,a,`size`,`width`,`v`],r.size.width.v,s);c&&t.push(c)})})}function Ol(e,t,r,i){var a;if(!(r!=null&&(a=r.sectionBreaks)!=null&&a.length))return;let o=new Set((0,n.getTopLevelSectionBreaks)(r).map(({sectionId:e})=>e));r.sectionBreaks.forEach((n,r)=>{if(!o.has(n.sectionId))return;let a={...n,...i},s=e.replaceOp([`body`,`sectionBreaks`,r],n,a);s&&t.push(s)})}let kl={id:`docs.command.page-setup`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.IUniverInstanceService),a=e.get(t.ICommandService),o=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!o)return!1;let{documentFlavor:s,marginLeft:c,marginRight:l,marginBottom:u,marginTop:d,pageOrient:f,pageSize:p}=r,m=t.JSONX.getInstance(),h=o.getDocumentStyle(),g=o.getSnapshot(),_={...h,documentFlavor:s??h.documentFlavor,marginBottom:u,marginLeft:c,marginRight:l,marginTop:d,pageOrient:f,pageSize:p},{marginBottom:v,marginLeft:y,marginRight:b,marginTop:x,pageOrient:S,pageSize:C,documentFlavor:w}=h,T=[];if(Dl(m,T,g.tableSource,wl(h),wl(_)),_.documentFlavor!==t.DocumentFlavor.MODERN&&Ol(m,T,g.body,{marginBottom:u,marginLeft:c,marginRight:l,marginTop:d,pageOrient:f,pageSize:p}),s!==void 0){if(w===void 0){let e=m.insertOp([`documentStyle`,`documentFlavor`],s);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`documentFlavor`],w,s);e&&T.push(e)}}if(v===void 0){let e=m.insertOp([`documentStyle`,`marginBottom`],u);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginBottom`],v,u);e&&T.push(e)}if(y===void 0){let e=m.insertOp([`documentStyle`,`marginLeft`],c);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginLeft`],y,c);e&&T.push(e)}if(b===void 0){let e=m.insertOp([`documentStyle`,`marginRight`],l);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginRight`],b,l);e&&T.push(e)}if(x===void 0){let e=m.insertOp([`documentStyle`,`marginTop`],d);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginTop`],x,d);e&&T.push(e)}if(C===void 0){let e=m.insertOp([`documentStyle`,`pageSize`],p);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`pageSize`],C,p);e&&T.push(e)}if(S===void 0){let e=m.insertOp([`documentStyle`,`pageOrient`],f);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`pageOrient`],S,f);e&&T.push(e)}let E={id:n.RichTextEditingMutation.id,params:{unitId:o.getUnitId(),historyAction:n.DocHistoryAction.UpdatePageLayout,actions:[],textRanges:void 0}};return E.params.actions=T.reduce((e,n)=>t.JSONX.compose(e,n),null),!!a.syncExecuteCommand(E.id,E.params)}},Al={id:`docs.operation.open-page-setting`,type:t.CommandType.OPERATION,handler:e=>{let n=e.get(t.IConfirmService),r=e.get(t.ICommandService),i=e.get(t.LocaleService),a=n.open({id:Cl,title:{label:i.t(`docs-ui.page-settings.document-setting`)},children:{label:Cl},width:528,onClose:()=>{a.dispose()},onConfirm:async e=>{if(!e)return;let n=e.mode===t.DocumentFlavor.MODERN?{width:t.MODERN_DOCUMENT_WIDTH[e.modernWidth],height:t.PAGE_SIZE.A4.height}:t.PAGE_SIZE[e.paperSize];await r.executeCommand(kl.id,{documentFlavor:e.mode,pageOrient:e.orientation,marginTop:e.margins.top,marginBottom:e.margins.bottom,marginLeft:e.margins.left,marginRight:e.margins.right,pageSize:n})&&a.dispose()},confirmText:i.t(`docs-ui.page-settings.confirm`),cancelText:i.t(`docs-ui.page-settings.cancel`)});return!0}},jl={id:`doc.command.insert-special-character`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!(r!=null&&r.value))return!1;let o=e.get(t.ICommandService),s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(U),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(!u||!d)return!1;let{segmentId:f}=d,p=(i=u.getSelfOrHeaderFooterModel(f))==null?void 0:i.getBody();if(!p)return!1;let{value:m}=r,h=N(p,d,l.getDefaultStyle(),l.getStyleCache(),!1,((a=Be(u))==null?void 0:a.inheritParagraphStartStyle)===!0),g=ee(p.customRanges??[],d.endOffset),_=P(p.customDecorations??[],d.endOffset);return o.executeCommand(n.InsertTextCommand.id,{unitId:u.getUnitId(),body:{dataStream:m,textRuns:[{...h,st:0,ed:m.length}],customRanges:g?[{...g,startIndex:0,endIndex:m.length-1}]:[],customDecorations:_.map(e=>({...e,startIndex:0,endIndex:m.length-1}))},range:d,segmentId:f})}},Ml=`UI_PLUGIN_DOCS`,Nl=e=>{let{value:n,onChange:r,options:a}=e,o=[{id:`level-0-top`,levelIndex:0},{id:`level-1`,levelIndex:1},{id:`level-2`,levelIndex:2},{id:`level-0-bottom`,levelIndex:0}],s=[``,`univer-pl-2`,`univer-pl-4`],c=e=>{switch(e){case t.ListGlyphType.DECIMAL_ZERO:return`01`;case t.ListGlyphType.UPPER_LETTER:return`A`;case t.ListGlyphType.LOWER_LETTER:return`a`;case t.ListGlyphType.UPPER_ROMAN:return`I`;case t.ListGlyphType.LOWER_ROMAN:return`i`;default:return`1`}},l=(e,n)=>{var r;let i=t.PRESET_LIST_TYPE[e].nestingLevel,a=i[n];return a.glyphSymbol?a.glyphSymbol:((r=a.glyphFormat)==null?void 0:r.replace(/%(\d+)/g,(e,t)=>{var n;return c((n=i[Number(t)-1])==null?void 0:n.glyphType)}))??`1.`};return(0,u.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 univer-p-1.5`,"data-u-editor-interaction-boundary":`true`,children:a.map(e=>(0,u.jsx)(`a`,{className:(0,i.clsx)(`univer-block univer-h-20 univer-w-[72px] univer-cursor-pointer univer-overflow-hidden univer-rounded univer-transition-all hover:univer-border-primary-500`,i.borderClassName,{"univer-border-primary-500":n===e}),onClick:()=>r(e),children:(0,u.jsx)(`div`,{className:`univer-box-border univer-grid univer-size-full univer-grid-rows-4 univer-gap-1 univer-bg-gray-50 univer-p-2 univer-text-gray-900`,"data-u-comp":`list-type-preview`,children:o.map(({id:t,levelIndex:n})=>(0,u.jsxs)(`div`,{className:(0,i.clsx)(`univer-flex univer-items-center univer-gap-1`,s[n]),children:[(0,u.jsx)(`span`,{className:`univer-w-3 univer-shrink-0 univer-overflow-hidden univer-text-center univer-text-[10px] univer-leading-none`,children:l(e,n)}),(0,u.jsx)(`span`,{className:`univer-h-1 univer-flex-1 univer-rounded univer-bg-gray-200`})]},t))})},e))})},Pl=[t.PresetListType.ORDER_LIST,t.PresetListType.ORDER_LIST_1,t.PresetListType.ORDER_LIST_2,t.PresetListType.ORDER_LIST_3,t.PresetListType.ORDER_LIST_4,t.PresetListType.ORDER_LIST_5],Fl=e=>(0,u.jsx)(Nl,{...e,options:Pl}),Il=[t.PresetListType.BULLET_LIST,t.PresetListType.BULLET_LIST_1,t.PresetListType.BULLET_LIST_2,t.PresetListType.BULLET_LIST_3,t.PresetListType.BULLET_LIST_4,t.PresetListType.BULLET_LIST_5],Ll=e=>(0,u.jsx)(Nl,{...e,options:Il}),Rl=`${Ml}_ORDER_LIST_TYPE_COMPONENT`,zl=`${Ml}_BULLET_LIST_TYPE_COMPONENT`;function Y(e){let n,r;try{n=e.get(t.IUniverInstanceService)}catch(e){if(Ju(e))return!0;throw e}try{r=e.get(Le)}catch{return!1}let i=n.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),a=i==null?void 0:i.getUnitId();return r.shouldSuppressHostInteraction(a)}function Bl(e){let i=e.get(t.IUniverInstanceService),a=e.get(r.IRenderManagerService);return new s.Observable(e=>{let o=null,s=i.focused$.subscribe(s=>{if(o==null||o.unsubscribe(),o=null,s==null||i.getUnitType(s)!==t.UniverInstanceType.UNIVER_DOC)return e.next(!0);let c=a.getRenderUnitById(s);if(c==null)return e.next(!0);o=c.with(n.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe(t=>{e.next(t===r.DocumentEditArea.HEADER||t===r.DocumentEditArea.FOOTER)})});return()=>{o==null||o.unsubscribe(),s.unsubscribe()}})}function Vl(e){let i=e.get(t.IUniverInstanceService),a=e.get(r.IRenderManagerService);return new s.Observable(e=>{let o=null,s,c=t=>{t!==s&&(s=t,e.next(t))},l=i.focused$.subscribe(e=>{if(o==null||o.unsubscribe(),o=null,!e||i.getUnitType(e)!==t.UniverInstanceType.UNIVER_DOC){c(!0);return}let s=a.getRenderUnitById(e),l=s==null?void 0:s.with(n.DocSkeletonManagerService),u=l==null?void 0:l.getViewModel();if(!u){c(!0);return}let d=e=>{let t=e??u.getEditArea();c(t===r.DocumentEditArea.HEADER||t===r.DocumentEditArea.FOOTER)};d(),o=u.editAreaChange$.subscribe(d)});return()=>{o==null||o.unsubscribe(),l.unsubscribe()}})}function Hl(e){let r=e.get(t.IUniverInstanceService),i=e.get(t.ICommandService);return new s.Observable(e=>{let a=i.onCommandExecuted(i=>{if(i.id===n.RichTextEditingMutation.id){let{unitId:n}=i.params,a=r.getUnit(n);if(a==null){e.next(!0);return}let{documentStyle:o}=a.getSnapshot();e.next((o==null?void 0:o.documentFlavor)!==t.DocumentFlavor.TRADITIONAL)}}),o=r.focused$.subscribe(n=>{if(n==null)return e.next(!0);let i=r.getUnit(n,t.UniverInstanceType.UNIVER_DOC),a=i==null?void 0:i.getSnapshot().documentStyle.documentFlavor;e.next(a!==t.DocumentFlavor.TRADITIONAL)}),s=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=s==null?void 0:s.getSnapshot().documentStyle.documentFlavor;return e.next(s==null||c!==t.DocumentFlavor.TRADITIONAL),()=>{a.dispose(),o.unsubscribe()}})}function Ul(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(n=>{let a=r.textSelection$.subscribe(r=>{if(r==null){n.next(!0);return}let{textRanges:a}=r;if(a.length!==1){n.next(!0);return}let{collapsed:o,startNodePosition:s,startOffset:c}=a[0];if(!o||c==null){n.next(!0);return}let l=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null){n.next(!0);return}let u=Te(e,l.getUnitId());if(u==null){n.next(!0);return}if(u.getViewModel().getCustomRangeRaw(c)){n.next(!0);return}if(s!=null){let{path:e}=s;if(e.indexOf(`cells`)!==-1){n.next(!0);return}}n.next(!1)});return()=>a.unsubscribe()})}function X(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService),a=new s.Observable(e=>{let n=r.textSelection$.subscribe(n=>{var r;if(n==null){e.next(!0);return}let{textRanges:a,rectRanges:o}=n;if(a.length===0&&o.length===0){e.next(!0);return}let s=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(((s==null||(r=s.getBody())==null||(r=r.blockRanges)==null?void 0:r.filter(e=>e.blockType===t.DocumentBlockRangeType.CODE))??[]).some(e=>a.some(t=>Math.max(t.startOffset,e.startIndex)<=Math.min(t.endOffset,e.endIndex)))){e.next(!0);return}e.next(!1)});return()=>n.unsubscribe()});return(0,s.combineLatest)([a,Wl(e)]).pipe((0,s.map)(([e,t])=>e||t))}function Z(e,r){let i=e.get(t.IUniverInstanceService),a=e.get(t.IPermissionService);return(0,s.combineLatest)([i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),a.permissionPointUpdate$.pipe((0,s.startWith)(void 0))]).pipe((0,s.map)(([e])=>!e||!(0,n.getDocumentPermissionValue)(a,e.getUnitId(),e.getUnitId(),r)))}function Wl(e){return Z(e,o.UnitAction.Edit)}let Gl=`doc.menu.insert-emoji`,Kl=`doc.menu.insert-symbol`;function ql(e){return{id:Gl,type:a.MenuItemType.SELECTOR,icon:`SmileIcon`,tooltip:`ui.emojiPicker.emojis`,selectionsCommandId:jl.id,selections:[{label:{name:a.EMOJI_PICKER_COMPONENT,hoverable:!1,selectable:!1,props:{embedded:!0}}}],disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Jl(e){return{id:Kl,type:a.MenuItemType.SELECTOR,icon:`SymbolsIcon`,tooltip:`ui.emojiPicker.symbols`,selectionsCommandId:jl.id,selections:[{label:{name:a.SYMBOL_PICKER_COMPONENT,hoverable:!1,selectable:!1,props:{embedded:!0}}}],disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Yl(e,t){var n;let r=(e==null||(n=e.getBody())==null?void 0:n.blockRanges)??[],i=t.startOffset,a=t.collapsed?t.startOffset:t.endOffset-1;return r.some(e=>Math.max(i,e.startIndex)<=Math.min(a,e.endIndex))}function Xl(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let n=n=>{var a;let o=(a=r.__getCurrentSelection)==null?void 0:a.call(r),s=(n==null?void 0:n.textRanges)??[...r.getTextRanges()??[]],c=(n==null?void 0:n.unitId)??(o==null?void 0:o.unitId),l=c?i.getUnit(c,t.UniverInstanceType.UNIVER_DOC):i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);e.next(s.some(e=>Yl(l,e)))};n();let a=r.textSelection$.subscribe(e=>n(e));return()=>a.unsubscribe()})}function Zl(e){let r=e.get(t.ICommandService);return{id:Qn.id,type:a.MenuItemType.BUTTON,icon:`BoldIcon`,title:`docs-ui.toolbar.bold`,tooltip:`docs-ui.toolbar.bold`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.bl;i.next(a===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ql(e){let r=e.get(t.ICommandService);return{id:er.id,type:a.MenuItemType.BUTTON,icon:`ItalicIcon`,title:`docs-ui.toolbar.italic`,tooltip:`docs-ui.toolbar.italic`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.it;i.next(a===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function $l(e){let r=e.get(t.ICommandService);return{id:nr.id,type:a.MenuItemType.BUTTON,icon:`UnderlineIcon`,title:`docs-ui.toolbar.underline`,tooltip:`docs-ui.toolbar.underline`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.ul;i.next((a==null?void 0:a.s)===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function eu(e){let r=e.get(t.ICommandService);return{id:ir.id,type:a.MenuItemType.BUTTON,icon:`StrikethroughIcon`,title:`docs-ui.toolbar.strikethrough`,tooltip:`docs-ui.toolbar.strikethrough`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.st;i.next((a==null?void 0:a.s)===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function tu(e){let r=e.get(t.ICommandService);return{id:or.id,type:a.MenuItemType.BUTTON,icon:`SubscriptIcon`,tooltip:`docs-ui.toolbar.subscript`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.va;i.next(a===t.BaselineOffset.SUBSCRIPT)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function nu(e){let r=e.get(t.ICommandService);return{id:cr.id,type:a.MenuItemType.BUTTON,icon:`SuperscriptIcon`,tooltip:`docs-ui.toolbar.superscript`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.va;i.next(a===t.BaselineOffset.SUPERSCRIPT)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ru(e){let r=e.get(t.ICommandService);return{id:fr.id,tooltip:`docs-ui.toolbar.font`,type:a.MenuItemType.SELECTOR,label:{name:a.FONT_FAMILY_COMPONENT,props:{id:fr.id}},selections:[{label:{name:a.FONT_FAMILY_ITEM_COMPONENT,hoverable:!1,selectable:!1,props:{id:fr.id}}}],value$:new s.Observable(i=>{let a=t.DEFAULT_STYLES.ff,o=()=>{var t;if(Y(e))return;let n=Ku(e);if(n==null){i.next(a);return}let r=(t=n.ts)==null?void 0:t.ff;i.next(r??a)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===fr.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function iu(e){let r=e.get(t.ICommandService);return{id:ur.id,type:a.MenuItemType.SELECTOR,tooltip:`docs-ui.toolbar.fontSize`,label:{name:a.FONT_SIZE_COMPONENT,props:{min:1,max:400}},selections:a.FONT_SIZE_LIST,value$:new s.Observable(i=>{let a=t.DEFAULT_STYLES.fs,o=()=>{var t;if(Y(e))return;let n=Ku(e);if(n==null){i.next(a);return}let r=(t=n.ts)==null?void 0:t.fs;i.next(r??a)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function au(e){let r=e.get(t.ICommandService);return{id:xo.id,type:a.MenuItemType.SELECTOR,tooltip:`docs-ui.toolbar.heading.tooltip`,label:{name:a.COMMON_LABEL_COMPONENT,props:{selections:a.HEADING_LIST}},selections:a.HEADING_LIST.map(e=>({label:{name:a.HEADING_ITEM_COMPONENT,props:{value:e.value,text:e.label}},value:e.value})),value$:new s.Observable(i=>{let a=t.NamedStyleType.NORMAL_TEXT,o=()=>{var t;if(Y(e))return;let n=qu(e);if(n==null){i.next(a);return}let r=((t=n.paragraphStyle)==null?void 0:t.namedStyleType)??a;i.next(r)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let ou=`doc.menu.float-text-style`,su=`doc.menu.float-toolbar`,cu=[{icon:`TextTypeIcon`,label:`docs-ui.toolbar.heading.normal`,value:t.NamedStyleType.NORMAL_TEXT},{icon:`H1Icon`,label:`docs-ui.toolbar.heading.leading1`,value:t.NamedStyleType.HEADING_1},{icon:`H2Icon`,label:`docs-ui.toolbar.heading.leading2`,value:t.NamedStyleType.HEADING_2},{icon:`H3Icon`,label:`docs-ui.toolbar.heading.leading3`,value:t.NamedStyleType.HEADING_3},{icon:`H4Icon`,label:`docs-ui.toolbar.heading.leading4`,value:t.NamedStyleType.HEADING_4},{icon:`H5Icon`,label:`docs-ui.toolbar.heading.leading5`,value:t.NamedStyleType.HEADING_5},{id:ao.id,icon:`OrderIcon`,label:`docs-ui.toolbar.order`,value:t.PresetListType.ORDER_LIST},{id:no.id,icon:`UnorderIcon`,label:`docs-ui.toolbar.unorder`,value:t.PresetListType.BULLET_LIST},{id:ro.id,icon:`TodoListDoubleIcon`,label:`docs-ui.toolbar.checklist`,value:t.PresetListType.CHECK_LIST}];function lu(e){var n,r;let i=e==null||(n=e.bullet)==null?void 0:n.listType;return i!=null&&i.startsWith(t.PresetListType.ORDER_LIST)?t.PresetListType.ORDER_LIST:i!=null&&i.startsWith(t.PresetListType.BULLET_LIST)?t.PresetListType.BULLET_LIST:i===t.PresetListType.CHECK_LIST||i===t.PresetListType.CHECK_LIST_CHECKED?t.PresetListType.CHECK_LIST:(e==null||(r=e.paragraphStyle)==null?void 0:r.namedStyleType)??t.NamedStyleType.NORMAL_TEXT}function uu(e){let r=e.get(t.ICommandService);return{id:ou,commandId:xo.id,type:a.MenuItemType.SELECTOR,icon:(0,s.of)(``),label:{name:a.COMMON_LABEL_COMPONENT,props:{selections:cu}},tooltip:`docs-ui.toolbar.heading.tooltip`,selections:cu,value$:new s.Observable(t=>{let i=()=>{Y(e)||t.next(lu(qu(e)))},a=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===xo.id||t===ao.id||t===no.id||t===ro.id)&&i()});return i(),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function du(e){let n=e.get(t.ICommandService),r=e.get(t.ThemeService);return{id:mr.id,icon:`FontColorDoubleIcon`,tooltip:`docs-ui.toolbar.textColor.main`,type:a.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:a.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1},value$:new s.Observable(t=>{let i=r.getColorFromTheme(`gray.900`),a=()=>{var n;if(Y(e))return;let r=Ku(e);if(!r){t.next(i);return}let a=(n=r.ts)==null||(n=n.cl)==null?void 0:n.rgb;t.next(a??i)},o=n.onCommandExecuted(e=>{e.id===mr.id&&a()});return a(),o.dispose})}],value$:new s.Observable(t=>{let i=r.getColorFromTheme(`gray.900`),a=n.onCommandExecuted(n=>{if(n.id===mr.id){if(Y(e))return;let r=n.params.value;t.next(r??i)}});return t.next(i),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function fu(e){return{id:Mc.id,type:a.MenuItemType.BUTTON,icon:`HeaderFooterIcon`,tooltip:`docs-ui.toolbar.headerFooter`,hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Hl(e),(e,t)=>e||t)}}let pu=`doc.menu.breaks`,mu=`doc.menu.section-break.next-page`,hu=`doc.menu.section-break.continuous`,gu=`doc.menu.section-break.next-column`,_u=`doc.menu.section-break.even-page`,vu=`doc.menu.section-break.odd-page`;function yu(e){return{id:pu,type:a.MenuItemType.SUBITEMS,icon:`ColumnIcon`,tooltip:`docs-ui.toolbar.breaks`,disabled$:X(e),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Hl(e),(e,t)=>e||t)}}function bu(e){return{id:gl.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.columnBreak`,disabled$:X(e)}}function xu(e,t,n,r){return{id:t,commandId:_l.id,params:{sectionType:r},type:a.MenuItemType.BUTTON,title:n,disabled$:X(e)}}function Su(e){return xu(e,mu,`docs-ui.toolbar.sectionBreakNextPage`,t.SectionType.NEXT_PAGE)}function Cu(e){return xu(e,hu,`docs-ui.toolbar.sectionBreakContinuous`,t.SectionType.CONTINUOUS)}function wu(e){return xu(e,gu,`docs-ui.toolbar.sectionBreakNextColumn`,t.SectionType.NEXT_COLUMN)}function Tu(e){return xu(e,_u,`docs-ui.toolbar.sectionBreakEvenPage`,t.SectionType.EVEN_PAGE)}function Eu(e){return xu(e,vu,`docs-ui.toolbar.sectionBreakOddPage`,t.SectionType.ODD_PAGE)}let Du=`GridIcon`,Ou=`doc.menu.table`;function ku(e){return{id:Ou,type:a.MenuItemType.SUBITEMS,icon:Du,tooltip:`docs-ui.toolbar.table.main`,disabled$:Ul(e),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Bl(e),(e,t)=>e||t)}}function Au(e){return{id:ns.id,title:`docs-ui.toolbar.table.insert`,type:a.MenuItemType.BUTTON,icon:Du,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ju(e){return{id:ns.id,commandId:Vo.id,params:{rowCount:3,colCount:5},title:`docs-ui.toolbar.table.insert`,type:a.MenuItemType.BUTTON,icon:Du,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Mu(e){let r=e.get(t.ICommandService);return{id:po.id,type:a.MenuItemType.BUTTON,icon:`LeftJustifyingIcon`,tooltip:`docs-ui.toolbar.alignLeft`,disabled$:X(e),activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.LEFT)}});return i.next(!1),a.dispose}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Nu(e){let r=e.get(t.ICommandService);return{id:mo.id,type:a.MenuItemType.BUTTON,icon:`HorizontallyIcon`,tooltip:`docs-ui.toolbar.alignCenter`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.CENTER)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Pu(e){let r=e.get(t.ICommandService);return{id:ho.id,type:a.MenuItemType.BUTTON,icon:`RightJustifyingIcon`,tooltip:`docs-ui.toolbar.alignRight`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.RIGHT)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Fu(e){let r=e.get(t.ICommandService);return{id:go.id,type:a.MenuItemType.BUTTON,icon:`AlignTextBothIcon`,tooltip:`docs-ui.toolbar.alignJustify`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.JUSTIFIED)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let Iu=[{id:po.id,value:t.HorizontalAlign.LEFT,label:`docs-ui.toolbar.alignLeft`,icon:`LeftJustifyingIcon`},{id:mo.id,value:t.HorizontalAlign.CENTER,label:`docs-ui.toolbar.alignCenter`,icon:`HorizontallyIcon`},{id:ho.id,value:t.HorizontalAlign.RIGHT,label:`docs-ui.toolbar.alignRight`,icon:`RightJustifyingIcon`},{id:go.id,value:t.HorizontalAlign.JUSTIFIED,label:`docs-ui.toolbar.alignJustify`,icon:`AlignTextBothIcon`}];function Lu(e){let r=e.get(t.ICommandService),i=new s.Observable(i=>{let a=()=>{var n;if(Y(e)){i.next(t.HorizontalAlign.LEFT);return}let r=qu(e);i.next((r==null||(n=r.paragraphStyle)==null?void 0:n.horizontalAlign)??t.HorizontalAlign.LEFT)},o=r.onCommandExecuted(e=>{(e.id===n.SetTextSelectionsOperation.id||e.id===fo.id)&&a()});return a(),o.dispose}).pipe((0,s.distinctUntilChanged)(),(0,s.shareReplay)({bufferSize:1,refCount:!0}));return{id:fo.id,type:a.MenuItemType.SELECTOR,icon:i.pipe((0,s.map)(e=>{var t;return((t=Iu.find(t=>t.value===e))==null?void 0:t.icon)??`LeftJustifyingIcon`})),tooltip:`docs-ui.toolbar.alignLeft`,selections:Iu,value$:i,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ru(e){return{id:ja.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,tooltip:`docs-ui.toolbar.horizontalLine`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let zu=e=>new s.Observable(r=>{let i=e.get(t.IUniverInstanceService),a=e.get(n.DocSelectionManagerService),o=i.focused$.subscribe(n=>{if(Y(e)||n==null)return;let o=i.getUnit(n,t.UniverInstanceType.UNIVER_DOC);if(o==null)return;let s=a.getDocRanges(),c=s.find(e=>e.isActive)??s[0];if(c){var l,u;let e=o.getSelfOrHeaderFooterModel(c==null?void 0:c.segmentId),n=t.BuildTextUtils.range.getParagraphsInRange(c,(e==null||(l=e.getBody())==null?void 0:l.paragraphs)??[],(e==null||(u=e.getBody())==null?void 0:u.dataStream)??``),i;if(n.every(e=>{if(!i){var t;i=(t=e.bullet)==null?void 0:t.listType}return e.bullet&&e.bullet.listType===i})){r.next(i);return}}r.next(void 0)});return()=>{o.unsubscribe()}});function Bu(e){return{id:ao.id,type:a.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:Rl,hoverable:!1,selectable:!1},value$:zu(e)}],icon:`OrderIcon`,tooltip:`docs-ui.toolbar.order`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:X(e),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`ORDER_LIST`)===0)))}}function Vu(e){return{id:no.id,type:a.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:zl,hoverable:!1,selectable:!1},value$:zu(e)}],icon:`UnorderIcon`,tooltip:`docs-ui.toolbar.unorder`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`BULLET_LIST`)===0)))}}function Hu(e){return{id:ro.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,tooltip:`docs-ui.toolbar.checklist`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`CHECK_LIST`)===0)))}}function Uu(e){let n=e.get(t.ThemeService);return{id:gr.id,commandId:mr.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.resetColor`,icon:`NoColorDoubleIcon`,params:()=>({value:n.getColorFromTheme(`gray.900`)})}}function Wu(e){let n=e.get(t.ThemeService);return{id:Sr.id,commandId:br.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.resetColor`,icon:`NoColorDoubleIcon`,params:()=>({value:n.getColorFromTheme(`primary.600`)})}}function Gu(e){let n=e.get(t.ICommandService),r=e.get(t.ThemeService);return{id:br.id,tooltip:`docs-ui.toolbar.fillColor.main`,type:a.MenuItemType.BUTTON_SELECTOR,icon:`PaintBucketDoubleIcon`,selections:[{label:{name:a.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1},value$:new s.Observable(t=>{let i=r.getColorFromTheme(`primary.600`),a=()=>{var n;if(Y(e))return;let r=Ku(e);if(!r){t.next(i);return}let a=(n=r.ts)==null||(n=n.bg)==null?void 0:n.rgb;t.next(a??i)},o=n.onCommandExecuted(e=>{e.id===br.id&&a()});return a(),o.dispose})}],value$:new s.Observable(t=>{let i=r.getColorFromTheme(`primary.600`),a=n.onCommandExecuted(n=>{if(n.id===br.id){if(Y(e))return;let r=n.params.value;t.next(r??i)}});return t.next(i),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ku(e){var r,i,a;if(Y(e))return;let o,s,c;try{o=e.get(t.IUniverInstanceService),s=e.get(n.DocSelectionManagerService),c=e.get(U)}catch(e){if(Ju(e))return;throw e}let l=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),u=s.getDocRanges(),d=u.find(e=>e.isActive)??u[0],f=c.getDefaultStyle(),p=c.getStyleCache()??{},m=qu(e),h=m!=null&&(r=m.paragraphStyle)!=null&&r.namedStyleType?t.NAMED_STYLE_MAP[m==null||(i=m.paragraphStyle)==null?void 0:i.namedStyleType]:null;if(l==null||d==null)return{ts:{...f,...h,...p}};let{segmentId:g}=d,_=(a=l.getSelfOrHeaderFooterModel(g))==null?void 0:a.getBody();if(_==null)return{ts:{...f,...h,...p}};let v=Or(_,d,{});return t.Tools.deleteNull(v),{ts:{...f,...h,...v,...p}}}function qu(e){var r;if(Y(e))return;let i,a;try{i=e.get(t.IUniverInstanceService),a=e.get(n.DocSelectionManagerService)}catch(e){if(Ju(e))return;throw e}let o=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),s=a.getDocRanges(),c=s.find(e=>e.isActive)??s[0];if(o==null||c==null)return;let{startOffset:l,segmentId:u}=c,d=(r=o.getSelfOrHeaderFooterModel(u))==null||(r=r.getBody())==null?void 0:r.paragraphs;if(d==null)return;let f=-1;for(let e of d){let{startIndex:t}=e;if(l>f&&l<=t)return e;f=t}return null}function Ju(e){return e instanceof Error?e.name===`InjectorAlreadyDisposedError`||e.message.includes(`Injector cannot be accessed after it was disposed`):!1}function Yu(e){return{id:Al.id,type:a.MenuItemType.BUTTON,icon:`DocSettingIcon`,tooltip:`docs-ui.toolbar.pageSetup`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:Wl(e)}}let Xu=e=>{let r=e.get(n.DocSelectionManagerService);return new s.Observable(e=>{let n=r.textSelection$.subscribe(()=>{r.getDocRanges().some(e=>e.collapsed===!1||e.rangeType===t.DOC_RANGE_TYPE.RECT)?e.next(!1):e.next(!0)});return()=>n.unsubscribe()})},Zu=e=>{let t=e.get(n.DocSelectionManagerService);return new s.Observable(e=>{let n=()=>{let n=t.getDocRanges(),r=n[0];e.next(n.length!==1||r.collapsed!==!0&&r.startOffset!==r.endOffset)};n();let r=t.textSelection$.subscribe(n);return()=>r.unsubscribe()})};function Qu(...e){return(0,s.combineLatest)(e).pipe((0,s.map)(e=>e.some(Boolean)))}function $u(e){if(e.length<2)return!0;let t=e.map(e=>e.tableId);return t.every(e=>e===t[0])}function ed(e,n,r){let i=n.getRectRanges(),a=n.getActiveTextRange();if(i&&i.length&&$u(i)&&a==null){e.next(!1);return}if(a&&(i==null||i.length===0)){var o;let{segmentId:n,startOffset:i,endOffset:s}=a;if(a.collapsed!==!0&&i!==s){e.next(!0);return}let c=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=c==null||(o=c.getSelfOrHeaderFooterModel(n))==null||(o=o.getBody())==null?void 0:o.tables;if(l&&l.length&&l.some(e=>{let{startIndex:t,endIndex:n}=e;return i>t&&i<n||s>t&&s<n})){e.next(!1);return}}e.next(!0)}let td=e=>{let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let t=r.textSelection$.subscribe(()=>{ed(e,r,i)});return ed(e,r,i),()=>t.unsubscribe()})};function nd(e){return{id:oa.name,commandId:oa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Copy)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function rd(e){return{id:dl.id,type:a.MenuItemType.BUTTON,title:`docs-ui.doc.menu.paragraphSetting`,icon:`ParagraphSettingIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function id(e){return{id:ca.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.cut`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Copy),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ad(e){return{id:da.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.paste`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function od(e){return{id:Pa.id,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.select`,disabled$:Zu(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function sd(e){return{id:Na.id,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.selectAll`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function cd(e){return{id:Vn.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.delete`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let ld=`doc.menu.table-insert`;function ud(e){return{id:ld,type:a.MenuItemType.SUBITEMS,title:`docs-ui.table.insert`,icon:`InsertDoubleIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),td(e),(e,t)=>e||t)}}function dd(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let n=()=>{var n;let a=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),o=r.getActiveTextRange(),s=a==null?void 0:a.getBody(),c=!a||a.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||!o||!!o.segmentId||!!(s!=null&&(n=s.tables)!=null&&n.some(e=>o.startOffset>e.startIndex&&o.startOffset<e.endIndex));e.next(c)};n();let a=r.textSelection$.subscribe(n);return()=>a.unsubscribe()})}function fd(e){return{id:ml.id,type:a.MenuItemType.BUTTON,title:`docs-ui.doc.menu.sectionSetting`,icon:`SectionSettingIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),dd(e),(e,t)=>e||t)}}function pd(e){return{id:qo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertRowAbove`,icon:`InsertRowAboveDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function md(e){return{id:Jo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertRowBelow`,icon:`InsertRowBelowDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function hd(e){return{id:Yo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertColumnLeft`,icon:`LeftInsertColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function gd(e){return{id:Xo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertColumnRight`,icon:`RightInsertColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let _d=`doc.menu.table-delete`;function vd(e){return{id:_d,type:a.MenuItemType.SUBITEMS,title:`docs-ui.table.delete`,icon:`ReduceDoubleIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),td(e),(e,t)=>e||t)}}function yd(e){return{id:Ho.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteRows`,icon:`DeleteRowDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function bd(e){return{id:Uo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteColumns`,icon:`DeleteColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function xd(e){return{id:Wo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteTable`,icon:`DeleteTableDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Sd(e){return{id:ua.id,type:a.MenuItemType.SELECTOR,icon:`DocPasteOptionsIcon`,title:`docs-ui.pasteOptions.title`,tooltip:`docs-ui.pasteOptions.title`,selections:gi.map(e=>({...e})),disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Cd(e,n){let r=`highlight.background.${n+1}`,i=e.getColorFromTheme(r);if(i==null||typeof i.color!=`string`||typeof i.alpha!=`number`)throw Error(`Theme token ${r} is required.`);let a=e.getColorFromTheme(i.color)??i.color;return new t.ColorKit(a).setAlpha(i.alpha).toRgbString()}let wd=[`#FE4B4B`,`#FF8C51`,`#A4DC16`,`#2DAEFF`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Td=[`DocParagraphTextColorSwatchIcon.0`,`DocParagraphTextColorSwatchIcon.1`,`DocParagraphTextColorSwatchIcon.2`,`DocParagraphTextColorSwatchIcon.3`,`DocParagraphTextColorSwatchIcon.4`,`DocParagraphTextColorSwatchIcon.5`,`DocParagraphTextColorSwatchIcon.6`],Ed=[`DocParagraphBackgroundColorSwatchIcon.0`,`DocParagraphBackgroundColorSwatchIcon.1`,`DocParagraphBackgroundColorSwatchIcon.2`,`DocParagraphBackgroundColorSwatchIcon.3`,`DocParagraphBackgroundColorSwatchIcon.4`,`DocParagraphBackgroundColorSwatchIcon.5`,`DocParagraphBackgroundColorSwatchIcon.6`,`DocParagraphBackgroundColorSwatchIcon.7`,`DocParagraphBackgroundColorSwatchIcon.8`,`DocParagraphBackgroundColorSwatchIcon.9`,`DocParagraphBackgroundColorSwatchIcon.10`,`DocParagraphBackgroundColorSwatchIcon.11`,`DocParagraphBackgroundColorSwatchIcon.12`,`DocParagraphBackgroundColorSwatchIcon.13`,`DocParagraphBackgroundColorSwatchIcon.14`];function Dd(e,r){let i=e.get(t.ICommandService);return new s.Observable(a=>{let o=t.NamedStyleType.NORMAL_TEXT,s=()=>{var t;if(Y(e))return;let n=qu(e);if(n==null){a.next(o===r);return}let i=((t=n.paragraphStyle)==null?void 0:t.namedStyleType)??o;a.next(i===r)},c=i.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&s()});return s(),c.dispose})}function Od(e){return{id:To.id,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_1)}}function kd(e){return{id:Eo.id,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_2)}}function Ad(e){return{id:Do.id,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_3)}}function jd(e){return{id:Oo.id,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_4)}}function Md(e){return{id:ko.id,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_5)}}function Nd(e){return{id:Ao.id,type:a.MenuItemType.BUTTON,icon:`TextTypeIcon`,title:`docs-ui.toolbar.heading.normal`,tooltip:`docs-ui.toolbar.heading.normal`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.NORMAL_TEXT)}}function Pd(e){return{id:jo.id,type:a.MenuItemType.BUTTON,icon:`TitleTypeIcon`,title:`docs-ui.toolbar.heading.title`,tooltip:`docs-ui.toolbar.heading.title`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.TITLE)}}function Fd(e){return{id:Mo.id,type:a.MenuItemType.BUTTON,icon:`SubtitleTypeIcon`,title:`docs-ui.toolbar.heading.subTitle`,tooltip:`docs-ui.toolbar.heading.subTitle`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.SUBTITLE)}}let Id=`doc.menu.empty-paragraph`;function Ld(){return{id:To.id,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`}}function Rd(){return{id:Eo.id,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`}}function zd(){return{id:Do.id,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`}}function Bd(){return{id:Oo.id,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`}}function Vd(){return{id:ko.id,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`}}function Hd(){return{id:Ao.id,type:a.MenuItemType.BUTTON,icon:`TextTypeIcon`,title:`docs-ui.toolbar.heading.normal`,tooltip:`docs-ui.toolbar.heading.normal`}}function Ud(){return{id:ao.id,type:a.MenuItemType.BUTTON,icon:`OrderIcon`,title:`docs-ui.rightClick.orderList`,tooltip:`docs-ui.rightClick.orderList`}}function Wd(){return{id:no.id,type:a.MenuItemType.BUTTON,icon:`UnorderIcon`,title:`docs-ui.rightClick.bulletList`,tooltip:`docs-ui.rightClick.bulletList`}}function Gd(){return{id:ro.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,title:`docs-ui.rightClick.checkList`,tooltip:`docs-ui.rightClick.checkList`}}function Kd(){return{id:ja.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,title:`docs-ui.toolbar.horizontalLine`,tooltip:`docs-ui.toolbar.horizontalLine`}}function qd(e){return{id:sa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Z(e,o.UnitAction.Copy)}}function Jd(e){return{id:la.id,type:a.MenuItemType.BUTTON,icon:`CutIcon`,title:`docs-ui.rightClick.cut`,disabled$:Z(e,o.UnitAction.Copy)}}function Yd(){return{id:Yn.id,type:a.MenuItemType.BUTTON,icon:`DeleteIcon`,title:`docs-ui.rightClick.delete`}}function Xd(){return{id:co.id,type:a.MenuItemType.BUTTON,icon:`UnorderIcon`,title:`docs-ui.rightClick.bulletList`,tooltip:`docs-ui.rightClick.bulletList`}}function Zd(){return{id:lo.id,type:a.MenuItemType.BUTTON,icon:`OrderIcon`,title:`docs-ui.rightClick.orderList`,tooltip:`docs-ui.rightClick.orderList`}}function Qd(){return{id:uo.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,title:`docs-ui.rightClick.checkList`,tooltip:`docs-ui.rightClick.checkList`}}function $d(){return{id:Ma.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,title:`docs-ui.toolbar.horizontalLine`,tooltip:`docs-ui.toolbar.horizontalLine`}}let ef=`doc.menu.insert-bellow`,tf=`doc.menu.content-insert`,nf=`doc.menu.table-block`,rf=`doc.menu.paragraph-t.insert`,af=`doc.menu.paragraph-t.edit`,of=`doc.menu.paragraph-t.divider`,sf=`doc.menu.paragraph-t.align`,cf=`doc.menu.paragraph-t.colors`,lf=`doc.menu.paragraph-t.insert-below`,uf=`doc.menu.paragraph-t.indent.increase`,df=`doc.menu.paragraph-t.indent.decrease`,ff=`doc.menu.paragraph-t.insert-below.command`;function pf(e){return`doc.block-range.${e}.menu`}function mf(e){return{id:oa.name,commandId:oa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Z(e,o.UnitAction.Copy)}}function hf(){return{id:da.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.paste`}}function gf(){return{id:Wo.id,type:a.MenuItemType.BUTTON,icon:`DeleteIcon`,title:`docs-ui.rightClick.delete`}}function _f(){return{id:ef,type:a.MenuItemType.SUBITEMS,title:`docs-ui.rightClick.insertBellow`}}function vf(e){return{id:sf,type:a.MenuItemType.SUBITEMS,icon:`LeftJustifyingIcon`,title:`docs-ui.paragraphMenu.alignAndIndent`,tooltip:`docs-ui.paragraphMenu.alignAndIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function yf(e){return{id:cf,type:a.MenuItemType.SUBITEMS,icon:`PaintBucketDoubleIcon`,title:`docs-ui.paragraphMenu.color`,tooltip:`docs-ui.paragraphMenu.color`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function bf(e){return{...du(e),icon:`HeaderTextColorIcon`,tooltip:void 0,title:void 0}}function xf(e){return{...Gu(e),icon:`PaintBucketDoubleIcon`,tooltip:void 0,title:void 0}}function Sf(e){return{id:lf,type:a.MenuItemType.SUBITEMS,icon:`TextTypeIcon`,title:`docs-ui.rightClick.insertBellow`,tooltip:`docs-ui.rightClick.insertBellow`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Cf(e){return{id:`${ff}.h1`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`,params:{commandId:To.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function wf(e){return{id:`${ff}.h2`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`,params:{commandId:Eo.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Tf(e){return{id:`${ff}.h3`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`,params:{commandId:Do.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ef(e){return{id:`${ff}.h4`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`,params:{commandId:Oo.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Df(e){return{id:`${ff}.h5`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`,params:{commandId:ko.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Of(e){return{id:`${ns.id}.below`,commandId:ns.id,type:a.MenuItemType.BUTTON,icon:`GridIcon`,title:`docs-ui.toolbar.table.insert`,tooltip:`docs-ui.toolbar.table.insert`,params:{rowCount:3,colCount:5},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function kf(e){return{id:uf,type:a.MenuItemType.BUTTON,icon:`LineIndentIncreaseIcon`,title:`docs-ui.paragraphMenu.increase`,tooltip:`docs-ui.paragraphMenu.increaseIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Af(e){return{id:df,type:a.MenuItemType.BUTTON,icon:`LineIndentDecreaseIcon`,title:`docs-ui.paragraphMenu.decrease`,tooltip:`docs-ui.paragraphMenu.decreaseIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function jf(e){return{id:Sr.id,type:a.MenuItemType.BUTTON,icon:`NoColorDoubleIcon`,title:`docs-ui.paragraphMenu.noBackground`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Mf(e){let n=e.get(t.ThemeService);return{id:gr.id,commandId:mr.id,type:a.MenuItemType.BUTTON,icon:`NoColorDoubleIcon`,title:`docs-ui.toolbar.resetColor`,tooltip:`docs-ui.toolbar.resetColor`,params:()=>({value:n.getColorFromTheme(`gray.900`)}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let Nf=wd.reduce((e,n,r)=>{let i=`doc.menu.paragraph-t.text-color.${r}`;return e[i]={order:r,menuItemFactory:e=>({id:i,commandId:mr.id,type:a.MenuItemType.BUTTON,icon:Td[r],params:{value:n},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)})},e},{}),Pf=Ed.reduce((e,n,r)=>{let i=`doc.menu.paragraph-t.background-color.${r}`;return e[i]={order:r,menuItemFactory:e=>{let o=Cd(e.get(t.ThemeService),r);return{id:i,commandId:br.id,type:a.MenuItemType.BUTTON,icon:n,params:{value:o},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}},e},{});function Ff(e){return(0,a.objectPermissionMenuItemFactory)(e,ll.id,t.UniverInstanceType.UNIVER_DOC,o.UnitObject.DocumentSection)}function If(e){return{...(0,a.objectPermissionMenuItemFactory)(e,cl.id,t.UniverInstanceType.UNIVER_DOC,o.UnitObject.DocumentParagraph),title:`docs-ui.objectPermission.paragraphPermission`}}let Lf={[su]:{[ou]:{order:0,menuItemFactory:uu}}},Rf={...Lf,[a.RibbonStartGroup.OTHERS]:{[ua.id]:{order:-1,gridLayout:{row:1,column:2,rowSpan:2,showLabel:!0},menuItemFactory:Sd},[ll.id]:{order:0,gridLayout:{row:1,column:1,rowSpan:2,showLabel:!0},menuItemFactory:Ff}},[a.RibbonStartGroup.FORMAT]:{[Qn.id]:{order:0,gridLayout:{row:2,column:1},menuItemFactory:Zl},[er.id]:{order:1,gridLayout:{row:2,column:2},menuItemFactory:Ql},[nr.id]:{order:2,gridLayout:{row:2,column:3},menuItemFactory:$l},[ir.id]:{order:3,gridLayout:{row:2,column:4},menuItemFactory:eu},[or.id]:{order:4,gridLayout:{row:2,column:5},menuItemFactory:tu},[cr.id]:{order:5,gridLayout:{row:2,column:6},menuItemFactory:nu},[xo.id]:{order:5.5,gridLayout:{row:1,column:1,columnSpan:2,width:100},menuItemFactory:au},[ur.id]:{order:6,gridLayout:{row:1,column:7,width:64},menuItemFactory:iu},[fr.id]:{order:7,gridLayout:{row:1,column:3,columnSpan:4,width:160},menuItemFactory:ru},[mr.id]:{order:8,gridLayout:{row:2,column:7},menuItemFactory:du,[gr.id]:{order:0,menuItemFactory:Uu}},[br.id]:{order:9,gridLayout:{row:2,column:8},menuItemFactory:Gu,[Sr.id]:{order:0,menuItemFactory:Wu}}},[a.RibbonStartGroup.LAYOUT]:{[fo.id]:{order:2,gridLayout:{row:1,column:1},menuItemFactory:Lu},[ao.id]:{order:7,gridLayout:{row:2,column:1},menuItemFactory:Bu},[no.id]:{order:8,gridLayout:{row:1,column:2},menuItemFactory:Vu},[ro.id]:{order:9,gridLayout:{row:2,column:2},menuItemFactory:Hu},[Mc.id]:{order:10,gridLayout:{row:1,column:3,rowSpan:2,showLabel:!0},menuItemFactory:fu},[Al.id]:{order:12,gridLayout:{row:1,column:4,rowSpan:2,showLabel:!0},menuItemFactory:Yu}},[a.RibbonInsertGroup.MEDIA]:{[Ou]:{order:2,gridLayout:{row:1,column:2},menuItemFactory:ku,[ns.id]:{order:0,menuItemFactory:Au}},[ja.id]:{order:4,gridLayout:{row:2,column:5},menuItemFactory:Ru},[pu]:{order:4,gridLayout:{row:1,column:1,rowSpan:2,showLabel:!0},menuItemFactory:yu,[gl.id]:{order:0,menuItemFactory:bu},[mu]:{order:1,menuItemFactory:Su},[hu]:{order:2,menuItemFactory:Cu},[gu]:{order:3,menuItemFactory:wu},[_u]:{order:4,menuItemFactory:Tu},[vu]:{order:5,menuItemFactory:Eu}},[Gl]:{order:5,gridLayout:{row:1,column:3},menuItemFactory:ql},[Kl]:{order:6,gridLayout:{row:2,column:3},menuItemFactory:Jl}},[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.OTHERS]:{[cl.id]:{order:10,menuItemFactory:If}},[a.ContextMenuGroup.QUICK]:{quickLayout:`tile`,[oa.name]:{order:0,menuItemFactory:nd},[ca.id]:{order:1,menuItemFactory:id},[da.id]:{order:2,menuItemFactory:ad},[ua.id]:{order:3,menuItemFactory:Sd}},[a.ContextMenuGroup.FORMAT]:{[Vn.id]:{order:0,menuItemFactory:cd}},[a.ContextMenuGroup.LAYOUT]:{[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[ld]:{order:1,menuItemFactory:ud,[qo.id]:{order:1,menuItemFactory:pd},[Jo.id]:{order:2,menuItemFactory:md},[Yo.id]:{order:3,menuItemFactory:hd},[Xo.id]:{order:4,menuItemFactory:gd}},[_d]:{order:2,menuItemFactory:vd,[Ho.id]:{order:1,menuItemFactory:yd},[Uo.id]:{order:2,menuItemFactory:bd},[Wo.id]:{order:3,menuItemFactory:xd}}}},[a.ContextMenuPosition.PARAGRAPH]:{[a.ContextMenuGroup.QUICK]:{[To.id]:{order:0,menuItemFactory:Od},[Eo.id]:{order:1,menuItemFactory:kd},[Do.id]:{order:2,menuItemFactory:Ad},[Oo.id]:{order:3,menuItemFactory:jd},[ko.id]:{order:4,menuItemFactory:Md},[jo.id]:{order:-1,menuItemFactory:Pd},[Mo.id]:{order:-1,menuItemFactory:Fd},[Ao.id]:{order:5,menuItemFactory:Nd}},[a.ContextMenuGroup.FORMAT]:{[sa.id]:{order:0,menuItemFactory:qd},[la.id]:{order:1,menuItemFactory:Jd},[Yn.id]:{order:2,menuItemFactory:Yd}},[a.ContextMenuGroup.LAYOUT]:{[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[ef]:{order:1,menuItemFactory:_f,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}},[tf]:{[a.ContextMenuGroup.QUICK]:{order:-2,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Od},[Eo.id]:{order:1,menuItemFactory:kd},[Do.id]:{order:2,menuItemFactory:Ad},[Oo.id]:{order:3,menuItemFactory:jd},[ko.id]:{order:4,menuItemFactory:Md},[Ao.id]:{order:5,menuItemFactory:Nd}},[a.ContextMenuGroup.LAYOUT]:{order:1,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}},[Id]:{[a.ContextMenuGroup.QUICK]:{order:-1,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Ld},[Eo.id]:{order:1,menuItemFactory:Rd},[Do.id]:{order:2,menuItemFactory:zd},[Oo.id]:{order:3,menuItemFactory:Bd},[ko.id]:{order:4,menuItemFactory:Vd},[Ao.id]:{order:5,menuItemFactory:Hd}},[a.ContextMenuGroup.LAYOUT]:{order:1,[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[no.id]:{order:1,menuItemFactory:Wd},[ao.id]:{order:2,menuItemFactory:Ud},[ro.id]:{order:3,menuItemFactory:Gd},[ja.id]:{order:4,menuItemFactory:Kd},[ns.id]:{order:5,menuItemFactory:ju}}},[nf]:{[a.ContextMenuGroup.FORMAT]:{[oa.name]:{order:0,menuItemFactory:mf},[da.id]:{order:1,menuItemFactory:hf},[Wo.id]:{order:2,menuItemFactory:gf}},[a.ContextMenuGroup.LAYOUT]:{[ef]:{order:0,menuItemFactory:_f,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}}},[rf]:{quickTop:{order:0,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Ld},[Eo.id]:{order:1,menuItemFactory:Rd},[Do.id]:{order:2,menuItemFactory:zd},[Oo.id]:{order:3,menuItemFactory:Bd},[ko.id]:{order:4,menuItemFactory:Vd},[ao.id]:{order:5,menuItemFactory:Ud}},quickBottom:{order:1,quickLayout:`icon`,[no.id]:{order:0,menuItemFactory:Wd},[ro.id]:{order:1,menuItemFactory:Gd},[ja.id]:{order:5,menuItemFactory:Kd}},insert:{order:2,[ns.id]:{order:0,menuItemFactory:ju}},format:{order:3,[da.id]:{order:0,menuItemFactory:ad}}},[lf]:{quickTop:{order:0,quickLayout:`icon`,[`${ff}.h1`]:{order:0,menuItemFactory:Cf},[`${ff}.h2`]:{order:1,menuItemFactory:wf},[`${ff}.h3`]:{order:2,menuItemFactory:Tf},[`${ff}.h4`]:{order:3,menuItemFactory:Ef},[`${ff}.h5`]:{order:4,menuItemFactory:Df},[lo.id]:{order:5,menuItemFactory:Zd}},quickBottom:{order:1,quickLayout:`icon`,[co.id]:{order:0,menuItemFactory:Xd},[uo.id]:{order:1,menuItemFactory:Qd},[Ma.id]:{order:5,menuItemFactory:$d}},insert:{order:2,[`${ns.id}.below`]:{order:0,menuItemFactory:Of}}},[af]:{quickTop:{order:0,quickLayout:`icon`,[Ao.id]:{order:0,menuItemFactory:Nd},[To.id]:{order:1,menuItemFactory:Od},[Eo.id]:{order:2,menuItemFactory:kd},[Do.id]:{order:3,menuItemFactory:Ad},[Oo.id]:{order:4,menuItemFactory:jd},[ko.id]:{order:5,menuItemFactory:Md},[jo.id]:{order:6,menuItemFactory:Pd},[Mo.id]:{order:7,menuItemFactory:Fd}},quickBottom:{order:1,quickLayout:`icon`,[ao.id]:{order:0,menuItemFactory:Bu},[no.id]:{order:1,menuItemFactory:Vu},[ro.id]:{order:2,menuItemFactory:Hu}},layout:{order:2,[sf]:{order:0,menuItemFactory:vf},[cf]:{order:1,menuItemFactory:yf}},format:{order:3,[la.id]:{order:0,menuItemFactory:Jd},[sa.id]:{order:1,menuItemFactory:qd},[da.id]:{order:2,menuItemFactory:ad},[Yn.id]:{order:3,menuItemFactory:Yd}},others:{order:4,[lf]:{order:0,menuItemFactory:Sf}}},[of]:{layout:{order:1,[cf]:{order:0,menuItemFactory:yf}},format:{order:2,[la.id]:{order:0,menuItemFactory:Jd},[sa.id]:{order:1,menuItemFactory:qd},[Yn.id]:{order:2,menuItemFactory:Yd}},others:{order:3,[lf]:{order:0,menuItemFactory:Sf}}},[sf]:{align:{order:0,title:`docs-ui.paragraphMenu.align`,quickLayout:`icon`,[fo.id]:{order:0,menuItemFactory:Mu},[`${fo.id}.center`]:{order:1,menuItemFactory:Nu},[`${fo.id}.right`]:{order:2,menuItemFactory:Pu},[`${fo.id}.justify`]:{order:3,menuItemFactory:Fu}},indent:{order:1,title:`docs-ui.paragraphMenu.indent`,[uf]:{order:0,menuItemFactory:kf},[df]:{order:1,menuItemFactory:Af}}},[cf]:{text:{order:0,title:`docs-ui.toolbar.textColor.main`,headerActionMenuItemFactory:bf,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,[gr.id]:{order:0,menuItemFactory:Mf},...Nf},backgroundTop:{order:1,title:`docs-ui.toolbar.fillColor.main`,headerActionMenuItemFactory:xf,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,[Sr.id]:{order:0,menuItemFactory:jf},...Object.fromEntries(Object.entries(Pf).filter(([,e])=>e.order<7))},backgroundBottom:{order:2,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,...Object.fromEntries(Object.entries(Pf).filter(([,e])=>e.order>=7))}}}};function Q(e){return e.getContextValue(t.FOCUSING_DOC)&&e.getContextValue(t.FOCUSING_UNIVER_EDITOR)&&!e.getContextValue(t.FOCUSING_COMMON_DRAWINGS)}function zf(e){return e.getContextValue(t.FOCUSING_DOC)&&e.getContextValue(t.FOCUSING_UNIVER_EDITOR)&&!e.getContextValue(t.FOCUSING_COMMON_DRAWINGS)}let Bf={id:te.id,binding:a.KeyCode.TAB,preconditions:Q},Vf={id:te.id,binding:a.KeyCode.TAB|a.MetaKeys.SHIFT,preconditions:Q,staticParameters:{shift:!0}},Hf={id:Qn.id,binding:a.KeyCode.B|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Uf={id:er.id,binding:a.KeyCode.I|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Wf={id:nr.id,binding:a.KeyCode.U|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Gf={id:ir.id,binding:a.KeyCode.X|a.MetaKeys.SHIFT|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Kf={id:or.id,binding:a.KeyCode.COMMA|a.MetaKeys.CTRL_COMMAND,preconditions:Q},qf={id:cr.id,binding:a.KeyCode.PERIOD|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Jf={id:po.id,binding:a.KeyCode.L|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Yf={id:ho.id,binding:a.KeyCode.R|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Xf={id:mo.id,binding:a.KeyCode.E|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Zf={id:go.id,binding:a.KeyCode.J|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Qf={id:ao.id,binding:a.KeyCode.Digit7|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},$f={id:no.id,binding:a.KeyCode.Digit8|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},ep=[50,80,100,130,150,170,200,400],tp=[10,400];function np(){let e=(0,a.useDependency)(t.ICommandService),n=(0,a.useDependency)(t.IUniverInstanceService),r=(0,a.useObservable)(()=>n.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.filter)(e=>e!=null)),null,!1,[n]),i=(0,l.useCallback)((e=r)=>e?Math.round(Fs(e)*100):100,[r]),[o,c]=(0,l.useState)(100);(0,l.useEffect)(()=>c(i(r)),[r,i]),(0,l.useEffect)(()=>e.onCommandExecuted(e=>{e.id===vo.id&&c(i())}).dispose,[e,i]);function d(t){if(c(t),r==null)return;let n=t/100;e.executeCommand(vo.id,{unitId:r.getUnitId(),zoomRatio:n})}return(0,u.jsx)(a.Slider,{min:tp[0],value:o,shortcuts:ep,onChange:d})}function rp(e){return(0,u.jsx)(`section`,{className:`univer-flex univer-flex-shrink-0 univer-justify-end`,children:(0,u.jsx)(np,{})})}function $({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return sp(d.current)},[n,r]),ip(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function ip(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...ap(e,n,i),...r},(op(e,n).children||[]).map((r,a)=>ip(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function ap(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function op(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function sp(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:cp(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(lp(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function cp(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function lp(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}$.displayName=`UniverIcon`;let up={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.9998 1.65005H3.64981C2.54524 1.65005 1.6498 2.54548 1.6498 3.65005V12.35C1.6498 13.4546 2.54523 14.35 3.6498 14.35H12.3498C13.4544 14.35 14.3498 13.4546 14.3498 12.3501V8.00005`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.6498 11.2148L5.43408 8.29588L10.711 12.0198`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.46559 10.1621L10.9774 8.65032C11.2042 8.42344 11.5634 8.39794 11.8201 8.59045L14.3498 10.4877`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.8097 1.74783V6.24167M9.6603 3.897H14.1541`,strokeLinecap:`round`,strokeWidth:1.2}}]},dp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`add-image-icon`,ref:t,icon:up}))});dp.displayName=`AddImageIcon`;let fp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 5.56641C1.66853 5.56641 1.3999 5.83504 1.3999 6.16641C1.3999 6.49778 1.66853 6.76641 1.9999 6.76641H13.9999C14.3313 6.76641 14.5999 6.49778 14.5999 6.16641C14.5999 5.83504 14.3313 5.56641 13.9999 5.56641H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 12.9004C1.66853 12.9004 1.3999 13.169 1.3999 13.5004C1.3999 13.8318 1.66853 14.1004 1.9999 14.1004H13.9999C14.3313 14.1004 14.5999 13.8318 14.5999 13.5004C14.5999 13.169 14.3313 12.9004 13.9999 12.9004H1.9999Z`}}]},pp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`align-text-both-icon`,ref:t,icon:fp}))});pp.displayName=`AlignTextBothIcon`;let mp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},hp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`bold-icon`,ref:t,icon:mp}))});hp.displayName=`BoldIcon`;let gp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9834 3.98332C1.9834 3.61513 2.28188 3.31665 2.65007 3.31665H13.3167C13.6849 3.31665 13.9834 3.61513 13.9834 3.98332C13.9834 4.35151 13.6849 4.64998 13.3167 4.64998H2.65007C2.28188 4.64998 1.9834 4.35151 1.9834 3.98332Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9834 7.98267C1.9834 7.61448 2.28188 7.316 2.65007 7.316H10.6501C11.0183 7.316 11.3167 7.61448 11.3167 7.98267C11.3167 8.35086 11.0183 8.64933 10.6501 8.64933H2.65007C2.28188 8.64933 1.9834 8.35086 1.9834 7.98267Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.65007 11.316C2.28188 11.316 1.9834 11.6145 1.9834 11.9827C1.9834 12.3509 2.28188 12.6493 2.65007 12.6493H7.9834C8.35159 12.6493 8.65006 12.3509 8.65006 11.9827C8.65006 11.6145 8.35159 11.316 7.9834 11.316H2.65007Z`}}]},_p=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`catalogue-icon`,ref:t,icon:gp}))});_p.displayName=`CatalogueIcon`;let vp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},yp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:vp}))});yp.displayName=`CheckMarkIcon`;let bp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z`}}]},xp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`close-icon`,ref:t,icon:bp}))});xp.displayName=`CloseIcon`;let Sp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.52,height:4,x:2.63,y:2.89,stroke:`currentColor`,rx:1.1,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.80825 2.89202V6.89199M10.9821 2.89202V6.89199`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:4,height:4,x:2.63,y:9.8,stroke:`currentColor`,rx:1.1,strokeWidth:1.2}}]},Cp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`column-icon`,ref:t,icon:Sp}))});Cp.displayName=`ColumnIcon`;let wp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.50095 1.84399C2.73322 1.60765 3.11311 1.60435 3.34945 1.83662L8.00012 6.40726L12.6508 1.83662C12.8871 1.60435 13.267 1.60765 13.4993 1.84399C13.7316 2.08032 13.7283 2.46021 13.4919 2.69248L8.85611 7.24852L10.8941 9.25146C11.1382 9.17563 11.3976 9.13477 11.6667 9.13477C13.1026 9.13477 14.2667 10.2988 14.2667 11.7348C14.2667 13.1707 13.1026 14.3348 11.6667 14.3348C10.2307 14.3348 9.06665 13.1707 9.06665 11.7348C9.06665 11.0143 9.35973 10.3622 9.83319 9.89129L8.00012 8.08978L6.16708 9.89127C6.64055 10.3622 6.93364 11.0142 6.93364 11.7348C6.93364 13.1707 5.76958 14.3348 4.33364 14.3348C2.8977 14.3348 1.73364 13.1707 1.73364 11.7348C1.73364 10.2988 2.8977 9.13477 4.33364 9.13477C4.60263 9.13477 4.86208 9.17562 5.10612 9.25145L7.14413 7.24852L2.50831 2.69248C2.27197 2.46021 2.26868 2.08032 2.50095 1.84399ZM2.93364 11.7348C2.93364 10.9616 3.56044 10.3348 4.33364 10.3348C5.10684 10.3348 5.73364 10.9616 5.73364 11.7348C5.73364 12.508 5.10684 13.1348 4.33364 13.1348C3.56044 13.1348 2.93364 12.508 2.93364 11.7348ZM10.2667 11.7348C10.2667 10.9616 10.8935 10.3348 11.6667 10.3348C12.4398 10.3348 13.0667 10.9616 13.0667 11.7348C13.0667 12.508 12.4398 13.1348 11.6667 13.1348C10.8935 13.1348 10.2667 12.508 10.2667 11.7348Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Tp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`cut-icon`,ref:t,icon:wp}))});Tp.displayName=`CutIcon`;let Ep={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-icon`,ref:t,icon:Ep}))});Dp.displayName=`DeleteIcon`;let Op={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 2.75H3.25C2.56 2.75 2 3.31 2 4V12.75C2 13.44 2.56 14 3.25 14H5.5M8.5 2.75H9.75C10.44 2.75 11 3.31 11 4V5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`rect`,attrs:{width:4,height:2.5,x:4.5,y:1.5,stroke:`currentColor`,rx:.75,strokeWidth:1.33}},{tag:`rect`,attrs:{width:7,height:7,x:7.5,y:7,stroke:`currentColor`,rx:1.25,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.25 9.25H12.75M9.25 11.75H12.75M10.25 8.5V10M11.75 11V12.5`,strokeLinecap:`round`,strokeWidth:1.33}}]},kp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`doc-paste-options-icon`,ref:t,icon:Op}))});kp.displayName=`DocPasteOptionsIcon`;let Ap={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.18958 14.085H4.0929C2.98833 14.085 2.0929 13.1895 2.0929 12.085V3.5918C2.0929 2.48723 2.98833 1.5918 4.0929 1.5918H10.5031C11.6077 1.5918 12.5031 2.48723 12.5031 3.5918V6.41602`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.73547 4.57324H9.96594M4.73547 7.08105H7.91614`,strokeLinecap:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.0255 9.17969H11.9572L13.7687 11.7939L11.9572 14.4082H10.0255L8.21399 11.7939L10.0255 9.17969Z`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.9913 11.7939H10.9914`,strokeLinecap:`round`,strokeWidth:1.83}}]},jp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`doc-setting-icon`,ref:t,icon:Ap}))});jp.displayName=`DocSettingIcon`;let Mp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.55935 11.7617C8.29238 12.1202 7.75558 12.1202 7.48861 11.7617L3.08649 5.84931C2.75722 5.40708 3.07292 4.77771 3.62432 4.77771H12.4236C12.975 4.77771 13.2907 5.40708 12.9614 5.84931L8.55935 11.7617Z`}}]},Np=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`down-icon`,ref:t,icon:Mp}))});Np.displayName=`DownIcon`;let Pp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.06,height:12.06,x:1.97,y:1.97,stroke:`currentColor`,rx:.63,strokeWidth:1.27}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.7777 1.96817V14.0317M9.90468 1.96817V14.0317M1.96817 6.09516H14.0317M1.96817 9.90468H14.0317`,strokeWidth:1.27}}]},Fp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`grid-icon`,ref:t,icon:Pp}))});Fp.displayName=`GridIcon`;let Ip={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.0999 2.66689C3.0999 2.33552 2.83127 2.06689 2.4999 2.06689C2.16853 2.06689 1.8999 2.33552 1.8999 2.66689V13.3336C1.8999 13.6649 2.16853 13.9336 2.4999 13.9336C2.83127 13.9336 3.0999 13.6649 3.0999 13.3336V8.5999H8.2334V13.3336C8.2334 13.6649 8.50203 13.9336 8.8334 13.9336C9.16477 13.9336 9.4334 13.6649 9.4334 13.3336V2.66689C9.4334 2.33552 9.16477 2.06689 8.8334 2.06689C8.50203 2.06689 8.2334 2.33552 8.2334 2.66689V7.3999H3.0999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.0999 6.33879C14.0999 6.09377 13.9509 5.87336 13.7236 5.78203C13.4962 5.6907 13.2362 5.74679 13.0667 5.92373L11.4753 7.58486C11.2461 7.82415 11.2542 8.20396 11.4935 8.43319C11.7328 8.66243 12.1126 8.65427 12.3419 8.41499L12.8999 7.83245V13.3333C12.8999 13.6646 13.1686 13.9333 13.4999 13.9333C13.8313 13.9333 14.0999 13.6646 14.0999 13.3333V6.33879Z`}}]},Lp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h1-icon`,ref:t,icon:Ip}))});Lp.displayName=`H1Icon`;let Rp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11.2667 8.33356C11.2667 7.67245 11.8201 7.26689 12.3333 7.26689C12.8465 7.26689 13.4 7.67244 13.4 8.33356C13.4 8.62807 13.2712 8.94814 12.9954 9.32391C12.7183 9.70153 12.3394 10.0744 11.9174 10.4803L11.8355 10.559C11.4524 10.9268 11.0365 11.3263 10.7149 11.7373C10.3718 12.1759 10.0667 12.7122 10.0667 13.3336C10.0667 13.6649 10.3353 13.9336 10.6667 13.9336H14C14.3314 13.9336 14.6 13.6649 14.6 13.3336C14.6 13.0022 14.3314 12.7336 14 12.7336H11.4782C11.5286 12.6531 11.5889 12.5676 11.6601 12.4767C11.9269 12.1355 12.2843 11.792 12.6877 11.4043L12.7492 11.3452C13.1606 10.9496 13.615 10.5079 13.9629 10.0338C14.3122 9.55787 14.6 8.98906 14.6 8.33356C14.6 6.88362 13.3757 6.06689 12.3333 6.06689C11.291 6.06689 10.0667 6.88361 10.0667 8.33356C10.0667 8.66493 10.3353 8.93356 10.6667 8.93356C10.998 8.93356 11.2667 8.66493 11.2667 8.33356Z`}}]},zp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h2-icon`,ref:t,icon:Rp}))});zp.displayName=`H2Icon`;let Bp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.6667 6.06689C10.3353 6.06689 10.0667 6.33552 10.0667 6.66689C10.0667 6.99827 10.3353 7.26689 10.6667 7.26689H12.7732L11.193 9.29853C11.0524 9.47942 11.027 9.72465 11.1277 9.93051C11.2283 10.1364 11.4375 10.2669 11.6667 10.2669C12.2418 10.2669 12.6786 10.4115 12.9585 10.6354C13.2204 10.845 13.4 11.166 13.4 11.6669C13.4 12.1622 13.2254 12.3937 13.0567 12.5202C12.8588 12.6686 12.5829 12.7336 12.3333 12.7336C11.7271 12.7336 11.3432 12.4858 11.1106 12.23C10.8877 11.9848 10.5082 11.9667 10.2631 12.1896C10.0179 12.4125 9.99979 12.792 10.2227 13.0372C10.6568 13.5147 11.3522 13.9336 12.3333 13.9336C12.7504 13.9336 13.3078 13.8319 13.7767 13.4802C14.2746 13.1068 14.6 12.5049 14.6 11.6669C14.6 10.8345 14.2796 10.1555 13.7081 9.69837C13.4342 9.47923 13.117 9.32231 12.7746 9.21971L14.4736 7.03526C14.6143 6.85437 14.6397 6.60914 14.539 6.40328C14.4383 6.19743 14.2291 6.06689 14 6.06689H10.6667Z`}}]},Vp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h3-icon`,ref:t,icon:Bp}))});Vp.displayName=`H3Icon`;let Hp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.4334 2.66689C2.4334 2.33552 2.16477 2.06689 1.8334 2.06689C1.50203 2.06689 1.2334 2.33552 1.2334 2.66689V13.3336C1.2334 13.6649 1.50203 13.9336 1.8334 13.9336C2.16477 13.9336 2.4334 13.6649 2.4334 13.3336V8.5999H7.2334V13.3336C7.2334 13.6649 7.50203 13.9336 7.8334 13.9336C8.16477 13.9336 8.4334 13.6649 8.4334 13.3336V2.66689C8.4334 2.33552 8.16477 2.06689 7.8334 2.06689C7.50203 2.06689 7.2334 2.33552 7.2334 2.66689V7.3999H2.4334V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.7591 6.66645C13.7591 6.40387 13.5884 6.1718 13.3377 6.09364C13.087 6.01549 12.8147 6.10941 12.6654 6.32546L9.67321 10.6577C9.60398 10.7579 9.56689 10.8769 9.56689 10.9987V11.6731C9.56689 12.0045 9.83552 12.2731 10.1669 12.2731H12.5591V13.3331C12.5591 13.6645 12.8278 13.9331 13.1591 13.9331C13.4905 13.9331 13.7591 13.6645 13.7591 13.3331V12.2731H14.1669C14.4983 12.2731 14.7669 12.0045 14.7669 11.6731C14.7669 11.3417 14.4983 11.0731 14.1669 11.0731H13.7591V6.66645ZM12.5591 8.59091V11.0731H10.8447L12.5591 8.59091Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Up=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h4-icon`,ref:t,icon:Hp}))});Up.displayName=`H4Icon`;let Wp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.6669 6.40332C10.3355 6.40332 10.0669 6.67195 10.0669 7.00332V9.34492C10.0669 9.67629 10.3355 9.94492 10.6669 9.94492C10.7822 9.94492 10.8899 9.91238 10.9814 9.85599C10.9901 9.85195 11.0027 9.84632 11.0192 9.83936C11.0764 9.81533 11.1692 9.78033 11.2927 9.74447C11.5397 9.67268 11.8996 9.60022 12.3336 9.60022C12.4975 9.60022 12.5978 9.63412 12.6624 9.67167C12.7263 9.70877 12.79 9.76953 12.8503 9.87834C12.983 10.1181 13.0669 10.5337 13.0669 11.1669C13.0669 11.8061 12.9802 12.1936 12.8338 12.414C12.7252 12.5775 12.5275 12.7336 12.0002 12.7336C11.6445 12.7336 11.4936 12.622 11.4192 12.5328C11.3289 12.4245 11.2669 12.2453 11.2669 12.0028C11.2669 11.6714 10.9983 11.4028 10.6669 11.4028C10.3355 11.4028 10.0669 11.6714 10.0669 12.0028C10.0669 12.4244 10.1716 12.9106 10.4979 13.3016C10.8401 13.7118 11.356 13.9336 12.0002 13.9336C12.8063 13.9336 13.4419 13.6673 13.8334 13.0779C14.1869 12.5456 14.2669 11.8497 14.2669 11.1669C14.2669 10.4781 14.1841 9.81027 13.9002 9.29724C13.7521 9.02964 13.545 8.79662 13.2651 8.63403C12.986 8.4719 12.6697 8.40022 12.3336 8.40022C11.9239 8.40022 11.5627 8.44957 11.2669 8.51389V7.60332H13.3336C13.6649 7.60332 13.9336 7.33469 13.9336 7.00332C13.9336 6.67195 13.6649 6.40332 13.3336 6.40332H10.6669Z`}}]},Gp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h5-icon`,ref:t,icon:Wp}))});Gp.displayName=`H5Icon`;let Kp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.2,height:13,x:1.9,y:1.5,stroke:`currentColor`,rx:1.4,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.9999 4.50137H10.9999M4.9999 11.4987H10.9999`,strokeLinecap:`round`,strokeWidth:1.2}}]},qp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`header-footer-icon`,ref:t,icon:Kp}))});qp.displayName=`HeaderFooterIcon`;let Jp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33315 5.56641C3.00178 5.56641 2.73315 5.83504 2.73315 6.16641C2.73315 6.49778 3.00178 6.76641 3.33315 6.76641H12.6665C12.9979 6.76641 13.2665 6.49778 13.2665 6.16641C13.2665 5.83504 12.9979 5.56641 12.6665 5.56641H3.33315Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33315 12.9004C3.00178 12.9004 2.73315 13.169 2.73315 13.5004C2.73315 13.8318 3.00178 14.1004 3.33315 14.1004H12.6665C12.9979 14.1004 13.2665 13.8318 13.2665 13.5004C13.2665 13.169 12.9979 12.9004 12.6665 12.9004H3.33315Z`}}]},Yp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`horizontally-icon`,ref:t,icon:Jp}))});Yp.displayName=`HorizontallyIcon`;let Xp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z`}}]},Zp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`italic-icon`,ref:t,icon:Xp}))});Zp.displayName=`ItalicIcon`;let Qp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.39986 6.33339C3.39986 6.00202 3.66849 5.73339 3.99986 5.73339H4.66652C4.99789 5.73339 5.26652 6.00202 5.26652 6.33339C5.26652 6.66476 4.99789 6.93339 4.66652 6.93339H3.99986C3.66849 6.93339 3.39986 6.66476 3.39986 6.33339Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.99986 5.73339C6.66849 5.73339 6.39986 6.00202 6.39986 6.33339C6.39986 6.66476 6.66849 6.93339 6.99986 6.93339H7.66652C7.99789 6.93339 8.26652 6.66476 8.26652 6.33339C8.26652 6.00202 7.99789 5.73339 7.66652 5.73339H6.99986Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.06636 6.33339C9.06636 6.00202 9.33499 5.73339 9.66636 5.73339H11.9997C12.3311 5.73339 12.5997 6.00202 12.5997 6.33339C12.5997 6.66476 12.3311 6.93339 11.9997 6.93339H9.66636C9.33499 6.93339 9.06636 6.66476 9.06636 6.33339Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.99986 8.73339C3.66849 8.73339 3.39986 9.00202 3.39986 9.33339C3.39986 9.66476 3.66849 9.93339 3.99986 9.93339H11.9999C12.3312 9.93339 12.5999 9.66476 12.5999 9.33339C12.5999 9.00202 12.3312 8.73339 11.9999 8.73339H3.99986Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33338 1.73345L12.6667 1.7334C14.1026 1.73339 15.2667 2.89745 15.2667 4.3334V11C15.2667 12.4359 14.1027 13.6 12.6667 13.6H3.33355C1.89763 13.6 0.733583 12.4359 0.73355 11L0.733398 4.33351C0.733366 2.89755 1.89742 1.73346 3.33338 1.73345ZM12.6667 2.9334L3.33339 2.93345C2.56018 2.93346 1.93338 3.56028 1.9334 4.33348L1.93355 11C1.93357 11.7732 2.56036 12.4 3.33355 12.4H12.6667C13.4399 12.4 14.0667 11.7732 14.0667 11V4.3334C14.0667 3.5602 13.4399 2.93339 12.6667 2.9334Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},$p=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`keyboard-icon`,ref:t,icon:Qp}))});$p.displayName=`KeyboardIcon`;let em={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 5.56641C1.66853 5.56641 1.3999 5.83504 1.3999 6.16641C1.3999 6.49778 1.66853 6.76641 1.9999 6.76641H11.3332C11.6646 6.76641 11.9332 6.49778 11.9332 6.16641C11.9332 5.83504 11.6646 5.56641 11.3332 5.56641H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 12.9004C1.66853 12.9004 1.3999 13.169 1.3999 13.5004C1.3999 13.8318 1.66853 14.1004 1.9999 14.1004H11.3332C11.6646 14.1004 11.9332 13.8318 11.9332 13.5004C11.9332 13.169 11.6646 12.9004 11.3332 12.9004H1.9999Z`}}]},tm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`left-justifying-icon`,ref:t,icon:em}))});tm.displayName=`LeftJustifyingIcon`;let nm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.1 2.5H13.9M7.1 5.8H13.9M7.1 9.1H13.9M2.1 12.4H13.9`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 5.6L2.4 8L5 10.4`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.4 8H5.1`,strokeLinecap:`round`,strokeWidth:1.3}}]},rm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`line-indent-decrease-icon`,ref:t,icon:nm}))});rm.displayName=`LineIndentDecreaseIcon`;let im={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.1 2.5H13.9M7.1 5.8H13.9M7.1 9.1H13.9M2.1 12.4H13.9`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.4 5.6L5 8L2.4 10.4`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.3 8H5`,strokeLinecap:`round`,strokeWidth:1.3}}]},am=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`line-indent-increase-icon`,ref:t,icon:im}))});am.displayName=`LineIndentIncreaseIcon`;let om={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.66504 2.8666C1.66504 2.53523 1.93367 2.2666 2.26504 2.2666H13.735C14.0664 2.2666 14.335 2.53523 14.335 2.8666C14.335 3.19797 14.0664 3.4666 13.735 3.4666H2.26504C1.93367 3.4666 1.66504 3.19797 1.66504 2.8666Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.66504 8.00002C1.66504 7.66865 1.93367 7.40002 2.26504 7.40002H13.735C14.0664 7.40002 14.335 7.66865 14.335 8.00002C14.335 8.3314 14.0664 8.60002 13.735 8.60002H2.26504C1.93367 8.60002 1.66504 8.3314 1.66504 8.00002Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.26504 12.5334C1.93367 12.5334 1.66504 12.8021 1.66504 13.1334C1.66504 13.4648 1.93367 13.7334 2.26504 13.7334H13.735C14.0664 13.7334 14.335 13.4648 14.335 13.1334C14.335 12.8021 14.0664 12.5334 13.735 12.5334H2.26504Z`}}]},sm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`menu-icon`,ref:t,icon:om}))});sm.displayName=`MenuIcon`;let cm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`}}]},lm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:cm}))});lm.displayName=`MoreHorizontalIcon`;let um={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3536 12.3536C10.1583 12.5488 9.84171 12.5488 9.64645 12.3536L6.64645 9.35355C6.45118 9.15829 6.45118 8.84171 6.64645 8.64645L9.64645 5.64645C9.84171 5.45118 10.1583 5.45118 10.3536 5.64645C10.5488 5.84171 10.5488 6.15829 10.3536 6.35355L7.70711 9L10.3536 11.6464C10.5488 11.8417 10.5488 12.1583 10.3536 12.3536Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},dm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:um}))});dm.displayName=`MoreLeftIcon`;let fm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.14645 4.64645C6.34171 4.45118 6.65829 4.45118 6.85355 4.64645L9.85355 7.64645C10.0488 7.84171 10.0488 8.15829 9.85355 8.35355L6.85355 11.3536C6.65829 11.5488 6.34171 11.5488 6.14645 11.3536C5.95118 11.1583 5.95118 10.8417 6.14645 10.6464L8.79289 8L6.14645 5.35355C5.95118 5.15829 5.95118 4.84171 6.14645 4.64645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},pm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-right-icon`,ref:t,icon:fm}))});pm.displayName=`MoreRightIcon`;let mm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.65465 3.96697V2.9942C1.65465 2.9188 1.64353 2.86563 1.62465 2.83387C1.61052 2.81011 1.58943 2.79243 1.53852 2.79243H1.44483C1.23836 2.79243 1.07099 2.62506 1.07099 2.41859C1.07099 2.23956 1.19714 2.09152 1.36369 2.04728C1.4425 2.02634 1.51336 2.00423 1.57642 1.98104C1.65529 1.94986 1.73286 1.91381 1.80913 1.87285C1.8974 1.82544 1.99768 1.79517 2.10303 1.79517C2.41692 1.79517 2.67137 2.04962 2.67137 2.36351V4.02047C2.67137 4.12385 2.75517 4.20765 2.85855 4.20765C3.0614 4.20765 3.22585 4.3721 3.22585 4.57495V4.63332C3.22585 4.86842 3.03527 5.059 2.80018 5.059H1.41884C1.1829 5.059 0.993164 4.86511 0.993164 4.63087C0.993164 4.39932 1.18072 4.20765 1.41398 4.20765C1.5469 4.20765 1.65465 4.09989 1.65465 3.96697Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M0.949709 9.2145C1.14957 9.02907 1.33226 8.85497 1.49677 8.69321C1.6914 8.50496 1.84244 8.33306 1.95136 8.17747C2.05826 8.02476 2.10492 7.89219 2.10492 7.77781C2.10492 7.65255 2.07293 7.57986 2.02759 7.53865L2.0245 7.5357C1.97641 7.48761 1.9103 7.46013 1.81635 7.46013C1.71986 7.46013 1.6383 7.47348 1.5822 7.51611L1.58034 7.51749C1.42279 7.63092 1.19425 7.67086 1.03149 7.50811L1.02187 7.49849C0.868433 7.34505 0.852261 7.07998 1.03819 6.93364C1.12802 6.86293 1.21897 6.8051 1.31109 6.76081C1.48788 6.67257 1.69616 6.63037 1.93278 6.63037C2.15191 6.63037 2.34929 6.67491 2.52246 6.76665C2.69563 6.85514 2.83257 6.98323 2.93172 7.14966C3.03175 7.31758 3.08022 7.51184 3.08022 7.72929C3.08022 7.91104 3.03028 8.09333 2.93429 8.27521C2.84374 8.45283 2.72797 8.62691 2.58859 8.79616C2.51109 8.88842 2.43304 8.97759 2.35442 9.06369C2.34919 9.06941 2.34388 9.07573 2.33892 9.08228C2.34542 9.08201 2.35268 9.08151 2.36075 9.08073C2.46266 9.07087 2.54985 9.06576 2.62168 9.06576H2.78662C3.02915 9.06576 3.22576 9.26237 3.22576 9.5049C3.22576 9.74742 3.02915 9.94403 2.78662 9.94403H1.23472C1.00261 9.94403 0.814453 9.75587 0.814453 9.52376C0.814453 9.40615 0.86379 9.29421 0.949709 9.2145Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.2579 14.674C1.45109 14.7553 1.67487 14.7946 1.92711 14.7946C2.1451 14.7946 2.34841 14.7599 2.53619 14.6895L2.53746 14.689C2.7264 14.6148 2.88145 14.5071 2.99952 14.3647L3.00018 14.3639C3.12167 14.2138 3.18089 14.0326 3.18089 13.8252C3.18089 13.6181 3.12169 13.4411 2.99737 13.3022C2.91596 13.2112 2.81864 13.1388 2.70642 13.0846C2.80611 13.023 2.88805 12.9505 2.95017 12.8661C3.04138 12.7422 3.08609 12.5977 3.08609 12.4365C3.08609 12.1403 2.97594 11.9041 2.7521 11.7404C2.53645 11.5772 2.25212 11.5002 1.90815 11.5002C1.7136 11.5002 1.52963 11.5372 1.35712 11.6115C1.28512 11.6418 1.21426 11.6776 1.14456 11.7188C0.938688 11.8404 0.928034 12.1099 1.06649 12.2774C1.21291 12.4544 1.46028 12.4561 1.63989 12.363C1.70891 12.3286 1.78521 12.3109 1.87023 12.3109C1.96356 12.3109 2.01717 12.3317 2.04691 12.3578C2.07449 12.3821 2.09529 12.4231 2.09529 12.4981C2.09529 12.5709 2.0658 12.6284 1.99667 12.6764C1.96042 12.6999 1.8978 12.7216 1.80025 12.7355C1.61051 12.7625 1.44118 12.9145 1.44118 13.1237C1.44118 13.3319 1.60937 13.4885 1.80489 13.5068C1.87785 13.5136 1.93575 13.5234 1.97985 13.5355C2.07997 13.562 2.12905 13.596 2.14927 13.6246C2.17519 13.6614 2.19008 13.7078 2.19008 13.7684C2.19008 13.8334 2.16583 13.8754 2.1142 13.9064C2.05357 13.9428 1.96521 13.965 1.84179 13.965C1.749 13.965 1.6547 13.9433 1.55817 13.8981C1.363 13.7983 1.08846 13.8083 0.942801 14.01L0.936366 14.0189C0.827321 14.1699 0.821861 14.401 0.994678 14.5262C1.07406 14.5836 1.16225 14.633 1.2579 14.674Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.13037 2.827C4.799 2.827 4.53037 3.09563 4.53037 3.427C4.53037 3.75837 4.799 4.027 5.13037 4.027H15.1489C15.4803 4.027 15.7489 3.75837 15.7489 3.427C15.7489 3.09563 15.4803 2.827 15.1489 2.827H5.13037Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53037 8.28711C4.53037 7.95574 4.799 7.68711 5.13037 7.68711H15.1489C15.4803 7.68711 15.7489 7.95574 15.7489 8.28711C15.7489 8.61848 15.4803 8.88711 15.1489 8.88711H5.13037C4.799 8.88711 4.53037 8.61848 4.53037 8.28711Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.13037 12.5475C4.799 12.5475 4.53037 12.8161 4.53037 13.1475C4.53037 13.4788 4.799 13.7475 5.13037 13.7475H15.1489C15.4803 13.7475 15.7489 13.4788 15.7489 13.1475C15.7489 12.8161 15.4803 12.5475 15.1489 12.5475H5.13037Z`}}]},hm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`order-icon`,ref:t,icon:mm}))});hm.displayName=`OrderIcon`;let gm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.5 2H4.5C2.84315 2 1.5 3.34315 1.5 5C1.5 6.65685 2.84315 8 4.5 8H5M5 2V13.5M7.5 2V13.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.8 9H12.7L14.5 11.5L12.7 14H10.8L9 11.5L10.8 9Z`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.75 11.5H11.7501`,strokeLinecap:`round`,strokeWidth:1.8}}]},_m=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paragraph-setting-icon`,ref:t,icon:gm}))});_m.displayName=`ParagraphSettingIcon`;let vm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.518 3.816a.51.51 0 0 1 0 .72l-.798.797.797.798a.51.51 0 0 1-.72.72L12 6.054l-.797.797a.51.51 0 0 1-.72-.72l.797-.798-.798-.797a.51.51 0 0 1 .72-.72l.798.797.797-.797a.51.51 0 0 1 .72 0M9.25 8.25a1 1 0 0 0-1 1v5.5a1 1 0 0 0 1 1h5.5a1 1 0 0 0 1-1v-5.5a1 1 0 0 0-1-1zm4.268 9.62a.51.51 0 0 0-.72-.72l-.798.797-.797-.798a.51.51 0 0 0-.72.72l.797.798-.798.797a.51.51 0 0 0 .72.72l.798-.797.797.797a.51.51 0 0 0 .72-.72l-.797-.797zM6.85 10.482a.51.51 0 0 1 0 .72L6.053 12l.798.797a.51.51 0 0 1-.72.72l-.798-.797-.797.798a.51.51 0 1 1-.72-.72L4.613 12l-.797-.797a.51.51 0 1 1 .72-.72l.797.797.798-.797a.51.51 0 0 1 .72 0m13.333.72a.51.51 0 1 0-.72-.72l-.797.797-.798-.797a.51.51 0 1 0-.72.72l.797.797-.797.797a.51.51 0 1 0 .72.72l.798-.797.797.798a.51.51 0 1 0 .72-.72L19.387 12zM9.75 9.75v4.5h4.5v-4.5z`,transform:`scale(.83333)`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ym=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`quick-add-icon`,ref:t,icon:vm}))});ym.displayName=`QuickAddIcon`;let bm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.9999 7.9999H13.9999`,strokeLinecap:`round`,strokeWidth:1.2}}]},xm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`reduce-icon`,ref:t,icon:bm}))});xm.displayName=`ReduceIcon`;let Sm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.66665 5.56641C4.33528 5.56641 4.06665 5.83504 4.06665 6.16641C4.06665 6.49778 4.33528 6.76641 4.66665 6.76641H14C14.3314 6.76641 14.6 6.49778 14.6 6.16641C14.6 5.83504 14.3314 5.56641 14 5.56641H4.66665Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.66665 12.9004C4.33528 12.9004 4.06665 13.169 4.06665 13.5004C4.06665 13.8318 4.33528 14.1004 4.66665 14.1004H14C14.3314 14.1004 14.6 13.8318 14.6 13.5004C14.6 13.169 14.3314 12.9004 14 12.9004H4.66665Z`}}]},Cm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`right-justifying-icon`,ref:t,icon:Sm}))});Cm.displayName=`RightJustifyingIcon`;let wm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.5 14H3.5C2.67157 14 2 13.3284 2 12.5V3C2 2.17157 2.67157 1.5 3.5 1.5H11C11.8284 1.5 12.5 2.17157 12.5 3V6.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 4H10M4.5 10H6.5M2 7H3M5.25 7H6.25M8.5 7H9.5M11.75 7H12.5`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.8 9H12.7L14.5 11.5L12.7 14H10.8L9 11.5L10.8 9Z`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.75 11.5H11.7501`,strokeLinecap:`round`,strokeWidth:1.8}}]},Tm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`section-setting-icon`,ref:t,icon:wm}))});Tm.displayName=`SectionSettingIcon`;let Em={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M14.35 5.3V4A2.35 2.35 0 0 0 12 1.65H4A2.35 2.35 0 0 0 1.65 4V12A2.35 2.35 0 0 0 4 14.35H5.3`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`circle`,attrs:{cx:12.5,cy:12.5,r:5.85,stroke:`currentColor`,strokeWidth:1.3}}]},Dm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`shape-icon`,ref:t,icon:Em}))});Dm.displayName=`ShapeIcon`;let Om={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:8,cy:8,r:6.4,stroke:`currentColor`,strokeWidth:1.2}},{tag:`circle`,attrs:{cx:5.75,cy:6.3,r:.75,fill:`currentColor`}},{tag:`circle`,attrs:{cx:10.25,cy:6.3,r:.75,fill:`currentColor`}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 9.3C5.65 10.65 6.65 11.35 8 11.35C9.35 11.35 10.35 10.65 11 9.3`,strokeLinecap:`round`,strokeWidth:1.2}}]},km=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`smile-icon`,ref:t,icon:Om}))});km.displayName=`SmileIcon`;let Am={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:11.2,height:13.2,x:2.4,y:1.4,stroke:`currentColor`,rx:1.6,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 12H11M5.5 9.7V7.8M8 9.7V5M10.5 9.7V6.5M5 9.7H11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},jm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`statistical-function-icon`,ref:t,icon:Am}))});jm.displayName=`StatisticalFunctionIcon`;let Mm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z`}}]},Nm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`strikethrough-icon`,ref:t,icon:Mm}))});Nm.displayName=`StrikethroughIcon`;let Pm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.08596 14.1387L10.3379 2.66873`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.3379 14.1387L2.08596 2.66873`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M12.8098 10.0174C13.4565 9.45285 14.781 9.44507 15.0272 10.5759C15.2798 11.736 13.8101 13.2515 12.7376 14.1033C12.7227 14.1151 12.7315 14.1389 12.7505 14.1388L15.2251 14.1388`,strokeLinecap:`round`,strokeWidth:1.2}}]},Fm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`subscript-icon`,ref:t,icon:Pm}))});Fm.displayName=`SubscriptIcon`;let Im={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.5 4.5C10.75 3.5 9.5 3 8 3C6 3 4.5 4 4.5 5.5C4.5 9 11.5 7 11.5 10.5C11.5 12 10 13 8 13C6.5 13 5.25 12.5 4.5 11.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},Lm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`subtitle-type-icon`,ref:t,icon:Im}))});Lm.displayName=`SubtitleTypeIcon`;let Rm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.10904 14.4537L10.299 3.06987`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.2989 14.4537L2.10899 3.06987`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M12.7525 3.35933C13.3943 2.79901 14.7089 2.79129 14.9533 3.91363C15.204 5.06487 13.7456 6.56876 12.6812 7.41429C12.6663 7.4261 12.6751 7.44982 12.6941 7.44982L15.1497 7.44977`,strokeLinecap:`round`,strokeWidth:1.2}}]},zm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`superscript-icon`,ref:t,icon:Rm}))});zm.displayName=`SuperscriptIcon`;let Bm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M3 20H7.5A.5.5 0 0 0 8 19.5V19.218A.52.52 0 0 0 7.753 18.781A8 8 0 1 1 16.247 18.78A.52.52 0 0 0 16 19.218V19.5A.5.5 0 0 0 16.5 20H21`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2}}]},Vm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`symbols-icon`,ref:t,icon:Bm}))});Vm.displayName=`SymbolsIcon`;let Hm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.22891 2.67227H11.5622M6.89541 2.67227V14.0056M10.2289 7.00552H15.5622M12.8954 7.00552V14.0055`,strokeLinecap:`round`,strokeWidth:1.2}}]},Um=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-icon`,ref:t,icon:Hm}))});Um.displayName=`TextIcon`;let Wm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.06641 1.9999C2.06641 1.66853 2.33504 1.3999 2.66641 1.3999H13.3331C13.6644 1.3999 13.9331 1.66853 13.9331 1.9999V3.64434C13.9331 3.97571 13.6644 4.24434 13.3331 4.24434C13.0017 4.24434 12.7331 3.97571 12.7331 3.64434V2.5999H8.59966V13.3999H10.6665C10.9979 13.3999 11.2665 13.6685 11.2665 13.9999C11.2665 14.3313 10.9979 14.5999 10.6665 14.5999L7.99966 14.5999L5.33315 14.5999C5.00178 14.5999 4.73315 14.3313 4.73315 13.9999C4.73315 13.6685 5.00178 13.3999 5.33315 13.3999H7.39966V2.5999H3.26641V3.64434C3.26641 3.97571 2.99778 4.24434 2.66641 4.24434C2.33504 4.24434 2.06641 3.97571 2.06641 3.64434V1.9999Z`}}]},Gm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-type-icon`,ref:t,icon:Wm}))});Gm.displayName=`TextTypeIcon`;let Km={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.75 4H9.25M5.5 4V12.5M10.25 7.5H14.25M11.75 5.5V11C11.75 12 12.25 12.5 13.25 12.5H14.25`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},qm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`title-type-icon`,ref:t,icon:Km}))});qm.displayName=`TitleTypeIcon`;let Jm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z`}}]},Ym=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`underline-icon`,ref:t,icon:Jm}))});Ym.displayName=`UnderlineIcon`;let Xm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.03012 3.14006C3.03012 3.59845 2.65851 3.97006 2.20012 3.97006C1.74172 3.97006 1.37012 3.59845 1.37012 3.14006C1.37012 2.68166 1.74172 2.31006 2.20012 2.31006C2.65851 2.31006 3.03012 2.68166 3.03012 3.14006Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 2.54014C4.1989 2.54014 3.93027 2.80877 3.93027 3.14014C3.93027 3.47151 4.1989 3.74014 4.53027 3.74014H14.5488C14.8802 3.74014 15.1488 3.47151 15.1488 3.14014C15.1488 2.80877 14.8802 2.54014 14.5488 2.54014H4.53027Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.20012 8.82992C2.65851 8.82992 3.03012 8.45832 3.03012 7.99992C3.03012 7.54153 2.65851 7.16992 2.20012 7.16992C1.74172 7.16992 1.37012 7.54153 1.37012 7.99992C1.37012 8.45832 1.74172 8.82992 2.20012 8.82992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 7.4C4.1989 7.4 3.93027 7.66863 3.93027 8C3.93027 8.33137 4.1989 8.6 4.53027 8.6H14.5488C14.8802 8.6 15.1488 8.33137 15.1488 8C15.1488 7.66863 14.8802 7.4 14.5488 7.4H4.53027Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.20012 13.6905C2.65851 13.6905 3.03012 13.3189 3.03012 12.8605C3.03012 12.4021 2.65851 12.0305 2.20012 12.0305C1.74172 12.0305 1.37012 12.4021 1.37012 12.8605C1.37012 13.3189 1.74172 13.6905 2.20012 13.6905Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 12.2604C4.1989 12.2604 3.93027 12.529 3.93027 12.8604C3.93027 13.1917 4.1989 13.4604 4.53027 13.4604H14.5488C14.8802 13.4604 15.1488 13.1917 15.1488 12.8604C15.1488 12.529 14.8802 12.2604 14.5488 12.2604H4.53027Z`}}]},Zm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`unorder-icon`,ref:t,icon:Xm}))});Zm.displayName=`UnorderIcon`;let Qm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},$m=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`write-icon`,ref:t,icon:Qm}))});$m.displayName=`WriteIcon`;let eh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:10,cy:10,r:9,fill:`#F5F5F5`}},{tag:`path`,attrs:{fill:`#6646E8`,d:`M10 10L10 1A9 9 0 0 1 19 10Z`}},{tag:`path`,attrs:{fill:`#55B144`,d:`M10 10L19 10A9 9 0 0 1 10 19Z`}},{tag:`path`,attrs:{fill:`#CBC443`,d:`M10 10L10 19A9 9 0 0 1 1 10Z`}},{tag:`path`,attrs:{fill:`#E8433D`,d:`M10 10L1 10A9 9 0 0 1 10 1Z`}},{tag:`circle`,attrs:{cx:10,cy:10,r:9,fill:`url(#color-wheel-multi-icon_color-wheel-multi-icon-radial)`}},{tag:`defs`,attrs:{},children:[{tag:`radialGradient`,attrs:{id:`color-wheel-multi-icon_color-wheel-multi-icon-radial`,cx:0,cy:0,r:1,gradientTransform:`matrix(0 9 -9 0 10 10)`,gradientUnits:`userSpaceOnUse`},children:[{tag:`stop`,attrs:{stopColor:`white`,stopOpacity:.82}},{tag:`stop`,attrs:{offset:1,stopColor:`#F5F5F5`,stopOpacity:.01}}]}]}],defIds:[`color-wheel-multi-icon_color-wheel-multi-icon-radial`]},th=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`color-wheel-multi-icon`,ref:t,icon:eh}))});th.displayName=`ColorWheelMultiIcon`;let nh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`#0B9EFB`,d:`M8.79993 14.0166C8.79993 14.4585 8.44176 14.8166 7.99993 14.8166C4.23529 14.8166 1.18345 11.7648 1.18345 8.00017C1.18345 4.23554 4.23529 1.18369 7.99993 1.1837C11.7646 1.1837 14.8164 4.23554 14.8164 8.00017C14.8164 8.442 14.4582 8.80017 14.0164 8.80017C13.5746 8.80017 13.2164 8.442 13.2164 8.00017C13.2164 5.11919 10.8809 2.7837 7.99993 2.7837C5.11895 2.7837 2.78345 5.11919 2.78345 8.00017C2.78345 10.8812 5.11895 13.2166 7.99993 13.2166C8.44176 13.2166 8.79993 13.5748 8.79993 14.0166Z`,fillOpacity:.2,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`#0B9EFB`,d:`M7.20007 1.98384C7.20007 1.54201 7.55824 1.18384 8.00007 1.18384C11.7647 1.18384 14.8165 4.23568 14.8165 8.00032C14.8165 11.765 11.7647 14.8168 8.00007 14.8168C4.23543 14.8168 1.18359 11.765 1.18359 8.00032C1.18359 7.55849 1.54177 7.20031 1.98359 7.20031C2.42542 7.20031 2.78359 7.55849 2.78359 8.00032C2.78359 10.8813 5.11909 13.2168 8.00007 13.2168C10.8811 13.2168 13.2165 10.8813 13.2165 8.00032C13.2165 5.11933 10.8811 2.78384 8.00007 2.78384C7.55824 2.78384 7.20007 2.42567 7.20007 1.98384Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},rh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`loading-multi-icon`,ref:t,icon:nh}))});rh.displayName=`LoadingMultiIcon`;let ih={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M5.4004 2.60213C5.25792 2.60213 5.14241 2.71763 5.14241 2.86011V4.32679C5.14241 4.67752 4.85809 4.96184 4.50736 4.96184C4.15663 4.96184 3.87231 4.67752 3.87231 4.32679V2.86011C3.87231 2.01618 4.55646 1.33203 5.4004 1.33203H13.14C13.984 1.33203 14.6681 2.01618 14.6681 2.86011V10.5998C14.6681 11.4437 13.984 12.1278 13.14 12.1278H11.6568C11.3061 12.1278 11.0218 11.8435 11.0218 11.4928C11.0218 11.1421 11.3061 10.8577 11.6568 10.8577H13.14C13.2825 10.8577 13.398 10.7422 13.398 10.5998V2.86011C13.398 2.71763 13.2825 2.60213 13.14 2.60213H5.4004Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.33203 5.40015C1.33203 4.55622 2.01618 3.87207 2.86011 3.87207H10.5998C11.4437 3.87207 12.1278 4.55622 12.1278 5.40015V13.1398C12.1278 13.9837 11.4437 14.6679 10.5998 14.6679H2.86011C2.01618 14.6679 1.33203 13.9837 1.33203 13.1398V5.40015ZM2.86011 5.14217C2.71763 5.14217 2.60213 5.25767 2.60213 5.40015V13.1398C2.60213 13.2823 2.71763 13.3978 2.86011 13.3978H10.5998C10.7422 13.3978 10.8577 13.2823 10.8577 13.1398V5.40015C10.8577 5.25767 10.7422 5.14217 10.5998 5.14217H2.86011Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ah=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`copy-double-icon`,ref:t,icon:ih}))});ah.displayName=`CopyDoubleIcon`;let oh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.9503 1.33317C12.6866 1.33317 13.2836 1.9301 13.2836 2.6665V13.3332C13.2836 14.0695 12.6866 14.6665 11.9503 14.6665H9.28359C8.54721 14.6665 7.95026 14.0696 7.95026 13.3332L7.95026 2.6665C7.95026 1.9301 8.54721 1.33317 9.28359 1.33317H11.9503ZM11.9503 2.6665V13.3332H9.28359V2.6665H11.9503Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M3.8542 6.29716C3.59385 6.03681 3.17174 6.03681 2.91139 6.29716C2.65104 6.55751 2.65104 6.97962 2.91139 7.23997L3.67157 8.00014L2.9114 8.76031C2.65105 9.02066 2.65105 9.44277 2.9114 9.70312C3.17175 9.96347 3.59387 9.96347 3.85421 9.70312L4.61437 8.94296L5.37459 9.70318C5.63494 9.96352 6.05705 9.96353 6.31741 9.70318C6.57775 9.44283 6.57775 9.02072 6.31741 8.76036L5.55718 8.00014L6.31742 7.23991C6.57777 6.97956 6.57777 6.55745 6.31742 6.2971C6.05707 6.03675 5.63496 6.03675 5.37461 6.2971L4.61437 7.05734L3.8542 6.29716Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},sh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-column-double-icon`,ref:t,icon:oh}))});sh.displayName=`DeleteColumnDoubleIcon`;let ch={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.6666 11.9502C14.6666 12.6866 14.0697 13.2835 13.3333 13.2835H2.66665C1.93027 13.2835 1.33331 12.6866 1.33331 11.9502V9.28353C1.33331 8.54715 1.93027 7.9502 2.66665 7.9502L13.3333 7.9502C14.0697 7.9502 14.6666 8.54715 14.6666 9.28353V11.9502ZM13.3333 11.9502H2.66665V9.28353H13.3333V11.9502Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M9.60134 3.85438C9.86169 3.59403 9.86169 3.17192 9.60134 2.91157C9.34099 2.65122 8.91888 2.65122 8.65853 2.91157L7.89835 3.67175L7.13819 2.91159C6.87784 2.65124 6.45573 2.65124 6.19538 2.91159C5.93503 3.17194 5.93503 3.59405 6.19538 3.8544L6.95554 4.61456L6.19532 5.37478C5.93497 5.63513 5.93497 6.05724 6.19532 6.31759C6.45567 6.57794 6.87778 6.57794 7.13813 6.31759L7.89835 5.55737L8.65859 6.3176C8.91893 6.57796 9.34105 6.57796 9.60139 6.3176C9.86175 6.05726 9.86175 5.63514 9.60139 5.3748L8.84116 4.61456L9.60134 3.85438Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},lh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-row-double-icon`,ref:t,icon:ch}))});lh.displayName=`DeleteRowDoubleIcon`;let uh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 1.5H13.5M1.5 1.5V13.5M5.5 1.5V13.5M9.5 1.5V8M1.5 5.5H13.5M1.5 9.5H8M13.5 1.5V8M1.5 13.5H8`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`colorChannel1`,d:`M9.7 9.7L14.5 14.5M14.5 9.7L9.7 14.5`,strokeLinecap:`round`,strokeWidth:1.3}}]},dh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-table-double-icon`,ref:t,icon:uh}))});dh.displayName=`DeleteTableDoubleIcon`;let fh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ph=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`font-color-double-icon`,ref:t,icon:fh}))});ph.displayName=`FontColorDoubleIcon`;let mh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.53337 14C2.35658 14 2.18704 13.9297 2.06203 13.8047C1.93703 13.6797 1.86681 13.5101 1.86681 13.3333C1.86681 13.1565 1.93703 12.987 2.06203 12.862C2.18704 12.7369 2.35658 12.6667 2.53337 12.6667L13.4667 12.6667C13.6435 12.6667 13.813 12.7369 13.938 12.862C14.063 12.987 14.1333 13.1565 14.1333 13.3333C14.1333 13.5101 14.063 13.6797 13.938 13.8047C13.813 13.9297 13.6435 14 13.4667 14L2.53337 14ZM2.53337 3.33333C2.35658 3.33331 2.18703 3.26306 2.06203 3.13804C1.93703 3.01301 1.86681 2.84346 1.86681 2.66667C1.86681 2.48987 1.93703 2.32032 2.06203 2.1953C2.18703 2.07028 2.35658 2.00003 2.53337 2L13.4667 2C13.6435 2.00003 13.813 2.07028 13.938 2.1953C14.063 2.32032 14.1333 2.48987 14.1333 2.66667C14.1333 2.84346 14.063 3.01301 13.938 3.13803C13.813 3.26306 13.6435 3.33331 13.4667 3.33333L2.53337 3.33333Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M11.0573 7.33327L10.1953 6.47127C10.0703 6.34627 10.0001 6.17672 10.0001 5.99994C10.0001 5.82315 10.0703 5.65361 10.1953 5.52861C10.3203 5.4036 10.4899 5.33337 10.6667 5.33337C10.8434 5.33337 11.013 5.4036 11.138 5.52861L13.138 7.5286C13.2 7.59046 13.2491 7.66393 13.2827 7.74481C13.3162 7.82569 13.3335 7.91238 13.3335 7.99994C13.3335 8.08749 13.3162 8.17419 13.2827 8.25507C13.2491 8.33594 13.2 8.40941 13.138 8.47127L11.138 10.4713C11.0761 10.5332 11.0026 10.5823 10.9217 10.6158C10.8409 10.6493 10.7542 10.6665 10.6667 10.6665C10.5791 10.6665 10.4925 10.6493 10.4116 10.6158C10.3307 10.5823 10.2572 10.5332 10.1953 10.4713C10.1334 10.4094 10.0843 10.3359 10.0508 10.255C10.0173 10.1742 10.0001 10.0875 10.0001 9.99994C10.0001 9.9124 10.0173 9.82573 10.0508 9.74486C10.0843 9.66398 10.1334 9.5905 10.1953 9.52861L11.0573 8.6666L3.33333 8.66661C3.15652 8.66661 2.98695 8.59637 2.86193 8.47134C2.7369 8.34632 2.66666 8.17675 2.66666 7.99994C2.66666 7.82313 2.7369 7.65356 2.86193 7.52853C2.98695 7.40351 3.15652 7.33327 3.33333 7.33327L11.0573 7.33327Z`}}]},hh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-double-icon`,ref:t,icon:mh}))});hh.displayName=`InsertDoubleIcon`;let gh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.3333 13.4087C14.0697 13.4087 14.6666 12.8117 14.6666 12.0754L14.6666 9.40869C14.6666 8.67231 14.0697 8.07536 13.3333 8.07536L2.66663 8.07536C1.93023 8.07536 1.33329 8.67231 1.33329 9.40869L1.33329 12.0754C1.33329 12.8117 1.93023 13.4087 2.66663 13.4087L13.3333 13.4087ZM2.66663 12.0754L13.3333 12.0754L13.3333 9.40869L2.66663 9.40869L2.66663 12.0754Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M7.74168 2.59137C8.10987 2.59137 8.40835 2.88984 8.40835 3.25804L8.40835 4.33309L9.48348 4.33309C9.85167 4.33309 10.1501 4.63156 10.1501 4.99976C10.1501 5.36794 9.85167 5.66642 9.48348 5.66642L8.40835 5.66642L8.40835 6.74154C8.40835 7.10973 8.10987 7.4082 7.74168 7.4082C7.37349 7.4082 7.07501 7.10973 7.07501 6.74154L7.07501 5.66642L5.99998 5.66642C5.63179 5.66642 5.33331 5.36794 5.33331 4.99976C5.33331 4.63156 5.63179 4.33309 5.99998 4.33309L7.07501 4.33309L7.07501 3.25804C7.07501 2.88984 7.37349 2.59137 7.74168 2.59137Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},_h=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-row-above-double-icon`,ref:t,icon:gh}))});_h.displayName=`InsertRowAboveDoubleIcon`;let vh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66671 2.59131C1.93033 2.59131 1.33337 3.18826 1.33337 3.92464L1.33337 6.59131C1.33337 7.32769 1.93033 7.92464 2.66671 7.92464L13.3334 7.92464C14.0698 7.92464 14.6667 7.32769 14.6667 6.59131L14.6667 3.92464C14.6667 3.18826 14.0698 2.59131 13.3334 2.59131L2.66671 2.59131ZM13.3334 3.92464L2.66671 3.92464L2.66671 6.59131L13.3334 6.59131L13.3334 3.92464Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M8.25838 13.4086C7.8902 13.4086 7.59172 13.1102 7.59172 12.742L7.59172 11.6669L6.51658 11.6669C6.14839 11.6669 5.84992 11.3684 5.84991 11.0002C5.84991 10.6321 6.14839 10.3336 6.51658 10.3336L7.59172 10.3336L7.59171 9.25846C7.59171 8.89027 7.89019 8.5918 8.25838 8.5918C8.62657 8.5918 8.92505 8.89027 8.92505 9.25846L8.92505 10.3336L10.0001 10.3336C10.3683 10.3336 10.6667 10.6321 10.6667 11.0002C10.6667 11.3684 10.3683 11.6669 10.0001 11.6669L8.92505 11.6669L8.92505 12.742C8.92505 13.1102 8.62658 13.4086 8.25838 13.4086Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},yh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-row-below-double-icon`,ref:t,icon:vh}))});yh.displayName=`InsertRowBelowDoubleIcon`;let bh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.4322 2.66683C13.4322 1.93045 12.8352 1.3335 12.0989 1.3335H9.43219C8.69581 1.3335 8.09886 1.93045 8.09886 2.66683V13.3335C8.09886 14.0699 8.69581 14.6668 9.43219 14.6668H12.0989C12.8352 14.6668 13.4322 14.0699 13.4322 13.3335V2.66683ZM12.0989 13.3335V2.66683H9.43219V13.3335H12.0989Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M2.56769 7.99978C2.56769 7.63159 2.86616 7.33311 3.23435 7.33311H4.30941V6.25798C4.30941 5.88979 4.60788 5.59131 4.97607 5.59131C5.34426 5.59131 5.64274 5.88979 5.64274 6.25798V7.33311H6.71785C7.08604 7.33311 7.38452 7.63159 7.38452 7.99978C7.38452 8.36797 7.08604 8.66644 6.71785 8.66644H5.64274V9.74148C5.64274 10.1097 5.34426 10.4081 4.97607 10.4081C4.60788 10.4081 4.30941 10.1097 4.30941 9.74148V8.66644H3.23435C2.86616 8.66644 2.56769 8.36797 2.56769 7.99978Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},xh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`left-insert-column-double-icon`,ref:t,icon:bh}))});xh.displayName=`LeftInsertColumnDoubleIcon`;let Sh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.665 2.66496H3.33496C2.96493 2.66496 2.66496 2.96493 2.66496 3.33496V12.665C2.66496 13.035 2.96493 13.335 3.33496 13.335H12.665C13.035 13.335 13.335 13.035 13.335 12.665V3.33496C13.335 2.96493 13.035 2.66496 12.665 2.66496ZM3.33496 1.33496C2.23039 1.33496 1.33496 2.23039 1.33496 3.33496V12.665C1.33496 13.7695 2.23039 14.665 3.33496 14.665H12.665C13.7695 14.665 14.665 13.7695 14.665 12.665V3.33496C14.665 2.23039 13.7695 1.33496 12.665 1.33496H3.33496Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M13.2559 14.1963L1.64941 2.58984L2.58987 1.64939L14.1963 13.2558L13.2559 14.1963Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Ch=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`no-color-double-icon`,ref:t,icon:Sh}))});Ch.displayName=`NoColorDoubleIcon`;let wh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}}]},Th=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paint-bucket-double-icon`,ref:t,icon:wh}))});Th.displayName=`PaintBucketDoubleIcon`;let Eh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463C12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523C7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paste-special-double-icon`,ref:t,icon:Eh}))});Dh.displayName=`PasteSpecialDoubleIcon`;let Oh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.53331 14C2.35652 14 2.18697 13.9297 2.06197 13.8047C1.93697 13.6797 1.86675 13.5101 1.86675 13.3333C1.86675 13.1565 1.93697 12.987 2.06197 12.862C2.18697 12.7369 2.35652 12.6667 2.53331 12.6667L13.4666 12.6667C13.6434 12.6667 13.813 12.7369 13.938 12.862C14.063 12.987 14.1332 13.1565 14.1332 13.3333C14.1332 13.5101 14.063 13.6797 13.938 13.8047C13.813 13.9297 13.6434 14 13.4666 14L2.53331 14ZM2.53331 3.33333C2.35652 3.33331 2.18697 3.26306 2.06197 3.13804C1.93697 3.01301 1.86675 2.84346 1.86675 2.66667C1.86675 2.48987 1.93697 2.32032 2.06197 2.1953C2.18697 2.07028 2.35652 2.00003 2.53331 2L13.4666 2C13.6434 2.00003 13.813 2.07028 13.938 2.1953C14.063 2.32032 14.1332 2.48987 14.1332 2.66667C14.1332 2.84346 14.063 3.01301 13.938 3.13803C13.813 3.26306 13.6434 3.33331 13.4666 3.33333L2.53331 3.33333Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M10.8142 10.8141C10.5588 11.0695 10.1447 11.0695 9.88929 10.8141L7.97868 8.90354L6.14021 10.742C5.89652 10.9857 5.50142 10.9857 5.25774 10.742C5.01405 10.4983 5.01405 10.1032 5.25774 9.85955L7.09621 8.02107L5.18561 6.11047C4.93021 5.85507 4.93021 5.44098 5.18561 5.18557C5.44101 4.93017 5.8551 4.93017 6.11051 5.18557L8.02111 7.09618L9.85959 5.2577C10.1033 5.01401 10.4984 5.01401 10.7421 5.2577C10.9857 5.50139 10.9857 5.89648 10.7421 6.14017L8.90358 7.97865L10.8142 9.88925C11.0696 10.1447 11.0696 10.5587 10.8142 10.8141Z`}}]},kh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`reduce-double-icon`,ref:t,icon:Oh}))});kh.displayName=`ReduceDoubleIcon`;let Ah={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56781 13.3332C2.56781 14.0695 3.16476 14.6665 3.90114 14.6665L6.56781 14.6665C7.30419 14.6665 7.90114 14.0695 7.90114 13.3332L7.90114 2.6665C7.90114 1.9301 7.30419 1.33317 6.56781 1.33317L3.90114 1.33317C3.16476 1.33317 2.56781 1.9301 2.56781 2.6665L2.56781 13.3332ZM3.90114 2.6665L3.90114 13.3332L6.56781 13.3332L6.56781 2.6665L3.90114 2.6665Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M13.4323 8.00022C13.4323 8.36841 13.1338 8.66689 12.7656 8.66689L11.6906 8.66689L11.6906 9.74202C11.6906 10.1102 11.3921 10.4087 11.0239 10.4087C10.6557 10.4087 10.3573 10.1102 10.3573 9.74202L10.3573 8.66689L9.28215 8.66689C8.91396 8.66689 8.61548 8.36841 8.61548 8.00022C8.61548 7.63203 8.91396 7.33356 9.28214 7.33356L10.3573 7.33356L10.3573 6.25852C10.3573 5.89033 10.6557 5.59186 11.0239 5.59186C11.3921 5.59186 11.6906 5.89033 11.6906 6.25852L11.6906 7.33356L12.7656 7.33356C13.1338 7.33356 13.4323 7.63203 13.4323 8.00022Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},jh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`right-insert-column-double-icon`,ref:t,icon:Ah}))});jh.displayName=`RightInsertColumnDoubleIcon`;let Mh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:14,height:14,x:1,y:1,stroke:`currentColor`,rx:1.75,strokeOpacity:.12}},{tag:`path`,attrs:{stroke:`colorChannel1`,d:`M4.75 11.5L8 4.5L11.25 11.5M6 9H10`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},Nh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-color-swatch-double-icon`,ref:t,icon:Mh}))});Nh.displayName=`TextColorSwatchDoubleIcon`;let Ph={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.96372 2.59116C5.19803 2.35684 5.19803 1.97695 4.96372 1.74263C4.7294 1.50832 4.3495 1.50832 4.11519 1.74263L2.53945 3.31837L1.96372 2.74263C1.7294 2.50832 1.3495 2.50832 1.11519 2.74263C0.880874 2.97695 0.880874 3.35684 1.11519 3.59116L2.11519 4.59116C2.3495 4.82547 2.7294 4.82547 2.96372 4.59116L4.96372 2.59116Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.4605 2.56689H6.8981C6.56672 2.56689 6.2981 2.83552 6.2981 3.16689C6.2981 3.49827 6.56672 3.76689 6.8981 3.76689H14.4605C14.7918 3.76689 15.0605 3.49827 15.0605 3.16689C15.0605 2.83552 14.7918 2.56689 14.4605 2.56689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.8981 7.2334C6.56672 7.2334 6.2981 7.50203 6.2981 7.8334C6.2981 8.16477 6.56672 8.4334 6.8981 8.4334H14.4605C14.7918 8.4334 15.0605 8.16477 15.0605 7.8334C15.0605 7.50203 14.7918 7.2334 14.4605 7.2334H6.8981Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.2981 12.4999C6.2981 12.1685 6.56672 11.8999 6.8981 11.8999H14.4605C14.7918 11.8999 15.0605 12.1685 15.0605 12.4999C15.0605 12.8313 14.7918 13.0999 14.4605 13.0999H6.8981C6.56672 13.0999 6.2981 12.8313 6.2981 12.4999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.87279 5.8999C1.80504 5.8999 0.939453 6.76549 0.939453 7.83324C0.939453 8.90099 1.80504 9.76657 2.87279 9.76657C3.94054 9.76657 4.80612 8.90099 4.80612 7.83324C4.80612 6.76549 3.94054 5.8999 2.87279 5.8999ZM2.13945 7.83324C2.13945 7.42823 2.46778 7.0999 2.87279 7.0999C3.2778 7.0999 3.60612 7.42823 3.60612 7.83324C3.60612 8.23824 3.2778 8.56657 2.87279 8.56657C2.46778 8.56657 2.13945 8.23824 2.13945 7.83324Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M0.939453 12.5002C0.939453 11.4325 1.80504 10.5669 2.87279 10.5669C3.94054 10.5669 4.80612 11.4325 4.80612 12.5002C4.80612 13.568 3.94054 14.4336 2.87279 14.4336C1.80504 14.4336 0.939453 13.568 0.939453 12.5002ZM2.87279 11.7669C2.46778 11.7669 2.13945 12.0952 2.13945 12.5002C2.13945 12.9052 2.46778 13.2336 2.87279 13.2336C3.2778 13.2336 3.60612 12.9052 3.60612 12.5002C3.60612 12.0952 3.2778 11.7669 2.87279 11.7669Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Fh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`todo-list-double-icon`,ref:t,icon:Ph}))});Fh.displayName=`TodoListDoubleIcon`;let Ih={currentPage:null,totalPages:null,dragTooltip:null};function Lh(e,t,n,r,i){let a=i==null||i.complete?e.length:null,o=i==null||i.complete?e.length:Math.min(i.publishedPageCount,e.length),s=0;for(let i=0;i<o;i++){let o=e[i],c=r?o.pageHeight:o.pageWidth;if(t<=s+c)return{currentPage:!o.isLayoutPlaceholder&&!o.isMaterializationPlaceholder?i+1:null,totalPages:a};s+=c+n}return{currentPage:null,totalPages:a}}function Rh(){let e=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useObservable)((0,l.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[e])),d=c?s.getRenderUnitById(c.getUnitId()):null,f=d==null?void 0:d.with(n.DocSkeletonManagerService),p=(0,a.useObservable)((f==null?void 0:f.currentSkeleton$)??null,(f==null?void 0:f.getSkeleton())??null,!1,[f]),m=(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL&&d!=null&&p!=null&&d.mainComponent instanceof r.Documents,[h,g]=(0,l.useState)(Ih),_=(0,l.useRef)(null),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{let e=d==null?void 0:d.scene.getViewport(`viewMain`),n=d==null?void 0:d.mainComponent;if(!m||d==null||p==null||e==null||!(n instanceof r.Documents))return;let i=()=>{var t;let i=((t=p.getSkeletonData())==null?void 0:t.pages)??[],a=e.calcViewportInfo().viewBound,{docsLeft:o,docsTop:s,pageLayoutType:c=r.PageLayoutType.VERTICAL,pageMarginLeft:l,pageMarginTop:u}=n.getOffsetConfig(),d=c!==r.PageLayoutType.HORIZONTAL;return Lh(i,d?(a.top+a.bottom)/2-s:(a.left+a.right)/2-o,d?u:l,d,p.getLayoutProgress()??null)},a=()=>{let e=i();g(t=>t.currentPage===e.currentPage&&t.totalPages===e.totalPages?t:{...t,...e})},o=()=>{_.current!=null&&clearTimeout(_.current),_.current=setTimeout(a,120)},s=(t,n)=>{let r=e.getScrollBar(),i=r==null?void 0:r.verticalThumbRect,a=d.engine.getCanvasElement();if(!(r!=null&&r.hasVerticalThumb())||i==null||a==null)return null;let o=a.getBoundingClientRect(),s=d.engine.width>0?o.width/d.engine.width:1,c=d.engine.height>0?o.height/d.engine.height:1;return{page:t,left:o.left+(e.left+i.left)*s-8,top:o.top+(e.top+n+r.verticalThumbSize/2)*c}},c=e=>{let t=i().currentPage,n=t==null?null:s(t,e.scrollY);g(e=>({...e,dragTooltip:n}))},l=()=>{v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{g(e=>e.dragTooltip==null?e:{...e,dragTooltip:null})},500)},u=new t.DisposableCollection,f=()=>{u.dispose(),_.current!=null&&(clearTimeout(_.current),_.current=null),v.current!=null&&(clearTimeout(v.current),v.current=null)};return u.add((0,t.fromEventSubject)(n.onDispose$).subscribe(()=>{f(),g(Ih)})),o(),u.add((0,t.fromEventSubject)(e.onScrollAfter$).subscribe(e=>{if(e.isBarDragging||e.isBarDragEnd){v.current!=null&&(clearTimeout(v.current),v.current=null),c(e),e.isBarDragEnd&&(l(),o());return}o()})),u.add(p.layoutProgress$.subscribe(a)),u.add(p.layoutPageMaterialized$.subscribe(a)),f},[m,d,p]),!m)return null;let y=null;return h.currentPage!=null&&(y=h.totalPages==null?o.t(`docs-ui.statistics.currentPage`,String(h.currentPage)):o.t(`docs-ui.statistics.currentPageOfTotal`,String(h.currentPage),String(h.totalPages))),(0,u.jsxs)(u.Fragment,{children:[y&&(0,u.jsx)(`span`,{className:`univer-tabular-nums`,children:y}),h.dragTooltip&&(0,u.jsx)(i.Popup,{visible:!0,overflowVisible:!0,offset:[h.dragTooltip.left,h.dragTooltip.top],children:(0,u.jsx)(`div`,{"data-testid":`doc-scroll-page-tooltip`,className:`univer-pointer-events-none univer-absolute univer-whitespace-nowrap univer-rounded univer-border univer-border-gray-300 univer-bg-white univer-px-2 univer-py-1 univer-text-xs univer-font-medium univer-tabular-nums univer-text-gray-700 univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-800 dark:!univer-text-gray-200`,style:{transform:`translate(-100%, -50%)`},children:o.t(`docs-ui.statistics.currentPage`,String(h.dragTooltip.page))})})]})}let zh={words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0},Bh={pages:0,lines:0};function Vh(e){return(e.getTextRanges()??[]).filter(e=>!e.collapsed&&!e.segmentId).map(({collapsed:e,direction:t,endOffset:n,isActive:r,rangeType:i,segmentId:a,segmentPage:o,startOffset:s})=>({collapsed:e,direction:t,endOffset:n,isActive:r,rangeType:i,segmentId:a,segmentPage:o,startOffset:s}))}function Hh(e,t,n){let r=Math.min(e.startOffset,e.endOffset),i=Math.max(e.startOffset,e.endOffset);return r<n&&i>t}function Uh(e,t=[],n=!0){var i;let a=(e==null||(i=e.getSkeletonData())==null?void 0:i.pages)??[];if(t.length===0){let e=0;return(0,r.documentSkeletonLineIterator)(a,{},()=>e++),{lines:e,pages:n?a.length:0}}let o=0,s=n?new Set:null;return(0,r.documentSkeletonLineIterator)(a,{},({line:e,pageIndex:n})=>{t.some(t=>Hh(t,e.st,e.ed))&&(o+=1,s==null||s.add(n))}),{lines:o,pages:(s==null?void 0:s.size)??0}}async function Wh({calculateLayout:e,calculatePages:t,documentDataModel:n,cachedStatistics:r,locale:i,selectionRanges:a,signal:o,skeleton:s}){let c=e?Uh(s,[],t):Bh,l=e&&a.length>0?Uh(s,a,t):Bh,[u,d]=await Promise.all([r??n.getStatistics({locale:i,signal:o}),a.length>0?n.getStatistics({locale:i,ranges:a,signal:o}):null]);return{document:{...u,...c},selection:d?{...d,...l}:null}}function Gh(e,t,n,r,i){e.current={documentDataModel:t,locale:n,revision:r,statistics:{words:i.words,charactersWithoutSpaces:i.charactersWithoutSpaces,charactersWithSpaces:i.charactersWithSpaces,paragraphs:i.paragraphs,nonAsianWords:i.nonAsianWords,asianCharactersAndKoreanWords:i.asianCharactersAndKoreanWords}}}function Kh(e,t){return(0,a.useObservable)(e?()=>(0,s.combineLatest)([t.textSelection$.pipe((0,s.startWith)(void 0)),e.change$]).pipe((0,s.map)(([,e])=>({ranges:Vh(t),revision:e}))):null,{ranges:[],revision:0},!1,[e,t])}function qh(e,t){var r;let i=e?(r=t.getRenderUnitById(e.getUnitId()))==null?void 0:r.with(n.DocSkeletonManagerService):null;return(0,a.useObservable)(i?i.currentSkeleton$.pipe((0,s.map)(e=>({value:e}))):null,{value:(i==null?void 0:i.getSkeleton())??null},!1,[i]).value}function Jh(e=!1){let i=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useDependency)(n.DocSelectionManagerService),u=(0,l.useRef)(null),d=(0,a.useObservable)((0,l.useMemo)(()=>i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[i])),f=Kh(d,c),p=(0,a.useObservable)(o.currentLocale$,o.getCurrentLocale()),m=(d==null?void 0:d.getDocumentStyle().documentFlavor)!==t.DocumentFlavor.MODERN,h=qh(e?d:null,s),[g,_]=(0,l.useState)({document:{...zh,lines:0,pages:0},selection:null,loading:!0}),v=f.ranges;return(0,l.useEffect)(()=>{if(!(d!=null&&d.getBody()))return;let t=d,n=u.current,r=(n==null?void 0:n.documentDataModel)===t&&n.locale===p&&n.revision===f.revision,i=new AbortController,a=setTimeout(async()=>{_(e=>({...e,loading:!0}));try{let a=await Wh({calculateLayout:e,calculatePages:m,documentDataModel:t,cachedStatistics:r?n.statistics:void 0,locale:p,selectionRanges:v,signal:i.signal,skeleton:h??null});r||Gh(u,t,p,f.revision,a.document),_({...a,loading:!1})}catch{i.signal.aborted||_(e=>({...e,loading:!1}))}},200);return()=>{clearTimeout(a),i.abort()}},[e,d,p,v,f,m,h]),{...g,showPages:m}}let Yh=[[{key:`pages`,label:`docs-ui.statistics.pages`},{key:`words`,label:`docs-ui.statistics.words`}],[{key:`charactersWithoutSpaces`,label:`docs-ui.statistics.charactersWithoutSpaces`},{key:`charactersWithSpaces`,label:`docs-ui.statistics.charactersWithSpaces`}],[{key:`paragraphs`,label:`docs-ui.statistics.paragraphs`},{key:`lines`,label:`docs-ui.statistics.lines`}],[{key:`nonAsianWords`,label:`docs-ui.statistics.nonAsianWords`},{key:`asianCharactersAndKoreanWords`,label:`docs-ui.statistics.asianCharactersAndKoreanWords`}]];function Xh({statistics:e,selection:n,showPages:r,loading:o}){let s=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(t.RegionService),l=(0,a.useObservable)(s.direction$,s.getDirection()),d=(0,a.useObservable)(c.currentRegion$,c.getCurrentRegion()),f=t.LOCALE_META[d].tag,p=Yh.map(e=>e.filter(({key:e})=>r||e!==`pages`)).filter(e=>e.length>0),m=o&&p.flat().every(({key:t})=>e[t]===0);return(0,u.jsxs)(`div`,{className:`univer-w-full`,dir:l,children:[(0,u.jsxs)(`header`,{className:`univer-flex univer-items-center univer-gap-3 univer-px-4 univer-py-3`,children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-flex-1 rtl:univer-text-right`,children:[(0,u.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-semibold univer-leading-5`,children:s.t(`docs-ui.statistics.title`)}),(0,u.jsx)(`div`,{className:`univer-truncate univer-text-xs univer-leading-4 univer-text-gray-500 dark:!univer-text-gray-400`,children:s.t(n?`docs-ui.statistics.selection`:`docs-ui.statistics.document`)})]}),o&&(0,u.jsx)(rh,{"aria-hidden":`true`,className:`univer-size-4 univer-shrink-0 univer-animate-spin univer-text-primary-600`})]}),(0,u.jsx)(i.Separator,{}),(0,u.jsx)(`dl`,{className:`univer-m-0 univer-p-2`,children:p.map((t,n)=>(0,u.jsxs)(`div`,{children:[n>0&&(0,u.jsx)(i.Separator,{className:`univer-my-1`}),t.map(({key:t,label:n})=>(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-between univer-gap-4 univer-rounded-md univer-px-2 univer-py-1`,children:[(0,u.jsx)(`dt`,{className:`univer-min-w-0 univer-flex-1 univer-text-sm univer-leading-5 univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-300`,children:s.t(n)}),(0,u.jsx)(`dd`,{className:`univer-m-0 univer-min-w-12 univer-shrink-0 univer-text-right univer-text-sm univer-font-semibold univer-tabular-nums univer-leading-5 univer-text-gray-900 rtl:univer-text-left dark:!univer-text-gray-0`,children:m?`—`:e[t].toLocaleString(f)})]},t))]},t[0].key))})]})}function Zh(){let e=(0,a.useDependency)(t.LocaleService),n=(0,a.useDependency)(t.RegionService),[r,o]=(0,l.useState)(!1),{document:s,selection:c,loading:d,showPages:f}=Jh(r),p=(0,a.useObservable)(n.currentRegion$,n.getCurrentRegion()),m=t.LOCALE_META[p].tag,h=c??s,g=e.t(`docs-ui.statistics.open`),_=e.t(`docs-ui.statistics.title`),v=c?e.t(`docs-ui.statistics.selectedWords`,c.words.toLocaleString(m),s.words.toLocaleString(m)):e.t(`docs-ui.statistics.wordCount`,s.words.toLocaleString(m));return(0,u.jsx)(i.Dropdown,{align:`start`,className:`univer-w-80 univer-shadow-xl`,side:`top`,open:r,"aria-busy":d,"aria-label":_,onOpenChange:o,overlay:(0,u.jsx)(Xh,{statistics:h,selection:c!=null,showPages:f,loading:d}),children:(0,u.jsx)(`span`,{title:r?void 0:g,children:(0,u.jsx)(a.ToolbarButton,{noIcon:!0,active:r,className:`!univer-h-7 univer-px-2 univer-text-xs !univer-text-gray-600 focus-visible:univer-ring-2 focus-visible:univer-ring-primary-500 dark:!univer-text-gray-300`,"aria-expanded":r,"aria-haspopup":`dialog`,"aria-label":g,children:(0,u.jsxs)(`span`,{className:`univer-flex univer-items-center univer-gap-1.5`,children:[(0,u.jsx)(jm,{className:`univer-size-4`}),(0,u.jsx)(Rh,{}),(0,u.jsx)(`span`,{children:v}),d&&(0,u.jsx)(rh,{className:`univer-size-3.5 univer-animate-spin`})]})})})})}let Qh=class extends t.RxDisposable{constructor(e){super(),this._univerInstanceService=e,R(this,`_progressByUnit$`,new s.BehaviorSubject(new Map)),R(this,`currentProgress$`,void 0),this.currentProgress$=(0,s.combineLatest)([this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),this._progressByUnit$]).pipe((0,s.map)(([e,t])=>{if(!e)return null;let n=e.getUnitId(),r=t.get(n);return r==null?null:{progress:r,unitId:n}}),(0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.unitId)===(t==null?void 0:t.unitId)&&(e==null?void 0:e.progress)===(t==null?void 0:t.progress)),(0,s.takeUntil)(this.dispose$))}setProgress(e,t){let n=this._progressByUnit$.value;n.get(e)!==t&&this._progressByUnit$.next(new Map(n).set(e,t))}clearProgress(e){let t=this._progressByUnit$.value;if(!t.has(e))return;let n=new Map(t);n.delete(e),this._progressByUnit$.next(n)}dispose(){this._progressByUnit$.complete(),super.dispose()}};Qh=B([z(0,t.IUniverInstanceService)],Qh);function $h(){let e=(0,a.useDependency)(t.LocaleService),n=(0,a.useObservable)((0,a.useDependency)(Qh).currentProgress$,null);if(n==null)return null;let{progress:r}=n,i=e.t(`docs-ui.layout.progress`);return(0,u.jsxs)(`div`,{className:`univer-pointer-events-none univer-absolute univer-left-1/2 univer-top-1/2 univer-flex -univer-translate-x-1/2 -univer-translate-y-1/2 univer-items-center univer-gap-2 univer-text-xs univer-text-gray-600 dark:univer-text-gray-300`,children:[(0,u.jsx)(`span`,{className:`univer-whitespace-nowrap`,children:i}),(0,u.jsx)(`div`,{"aria-label":i,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":r,className:`univer-h-1 univer-w-32 univer-overflow-hidden univer-rounded-full univer-bg-gray-200 dark:univer-bg-gray-700`,role:`progressbar`,children:(0,u.jsx)(`div`,{className:`univer-h-full univer-rounded-full univer-bg-primary-600 univer-transition-[width]`,style:{width:`${r}%`}})}),(0,u.jsxs)(`span`,{className:`univer-w-8 univer-tabular-nums`,children:[r,`%`]})]})}function eg(){let e=(0,a.useConfigValue)(as);return((e==null?void 0:e.footer)??!0)&&(0,u.jsxs)(`div`,{className:`univer-relative univer-box-border univer-flex univer-items-center univer-justify-between univer-px-5 univer-py-1.5`,children:[(e==null?void 0:e.wordCount)!==!1&&(0,u.jsx)(Zh,{}),(0,u.jsx)($h,{}),(0,u.jsx)(rp,{})]})}function tg(){let e=(0,a.useDependency)(a.IWorkbenchService);return(0,a.useObservable)(e.rootUnitType$,null,!0)===t.UniverInstanceType.UNIVER_DOC?(0,u.jsx)(eg,{}):null}let ng=(0,l.forwardRef)((e,t)=>{let{label:n,menus:r,onClick:a,className:o,style:s,mode:c,maxHeight:d,activeId:f,open:p,onOpenChange:m,maxWidth:h,wrapperClass:g,wrapperStyle:_,iconClass:v,iconStyle:y}=e,b=(0,l.useId)(),x=(0,l.useRef)(null),S=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useRef)(new Map),T=Math.min(256,h??256),E=(0,l.useMemo)(()=>({scrollTo:e=>{let t=S.current,n=w.current.get(e);if(!t||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<t.scrollTop?t.scrollTo({top:r}):i>t.scrollTop+t.clientHeight&&t.scrollTo({top:i-t.clientHeight})}}),[]);(0,l.useImperativeHandle)(t,()=>E),(0,l.useEffect)(()=>{p&&f&&E.scrollTo(f)},[f,E,p]),(0,l.useEffect)(()=>{if(!p||c!==`float`)return;let e=e=>{var t;e.target instanceof Node&&!((t=x.current)!=null&&t.contains(e.target))&&(m==null||m(!1))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[c,m,p]);let D=e=>{var t;if(e.key===`Escape`&&p){var n;e.preventDefault(),e.stopPropagation(),m==null||m(!1),(n=C.current)==null||n.focus();return}let r=Array.from(w.current.values()),i=r.indexOf(e.target);if(i===-1)return;let a;switch(e.key){case`ArrowDown`:a=Math.min(i+1,r.length-1);break;case`ArrowUp`:a=Math.max(i-1,0);break;case`Home`:a=0;break;case`End`:a=r.length-1;break;default:return}e.preventDefault(),e.stopPropagation(),(t=r[a])==null||t.focus()};return(0,u.jsxs)(`div`,{ref:x,className:(0,i.clsx)(`univer-relative univer-ml-3`,g),style:{width:T,..._},onKeyDown:D,children:[(0,u.jsx)(`button`,{ref:C,type:`button`,"aria-label":n,"aria-expanded":!!p,"aria-controls":p?b:void 0,title:n,onClick:()=>m==null?void 0:m(!p),className:(0,i.clsx)(`univer-absolute univer-top-1.5 univer-z-10 univer-flex univer-size-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md univer-border-0 univer-bg-gray-0 univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 hover:univer-text-gray-900 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:univer-outline-primary-600 dark:univer-bg-gray-900 dark:univer-text-gray-400 dark:hover:univer-bg-gray-800`,!p&&`univer-shadow-sm`,v),style:{left:p?T-40:0,...y},children:p?(0,u.jsx)(dm,{"aria-hidden":`true`}):(0,u.jsx)(_p,{"aria-hidden":`true`})}),p&&(0,u.jsxs)(`nav`,{id:b,"aria-label":n,className:(0,i.clsx)(`univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-text-gray-700 dark:univer-border-gray-700 dark:univer-bg-gray-900 dark:univer-text-gray-200`,c===`float`?`univer-shadow-md`:`univer-shadow-sm`,o),style:{maxHeight:d,...s},children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-px-3 univer-pr-12 univer-text-xs univer-font-medium univer-text-gray-500 dark:univer-text-gray-400`,children:[(0,u.jsx)(_p,{"aria-hidden":`true`,className:`univer-shrink-0 univer-text-sm`}),(0,u.jsx)(`span`,{className:`univer-truncate`,children:n})]}),(0,u.jsx)(`div`,{ref:S,className:(0,i.clsx)(`univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-px-2 univer-pb-2`,i.scrollbarClassName),children:(0,u.jsx)(`ol`,{className:`univer-m-0 univer-list-none univer-p-0`,children:r==null?void 0:r.map(e=>(0,u.jsx)(`li`,{className:e.isTitle?`univer-mb-1 univer-pb-1`:void 0,children:(0,u.jsxs)(`button`,{ref:t=>{t?w.current.set(e.id,t):w.current.delete(e.id)},type:`button`,"aria-current":e.id===f?`location`:void 0,title:e.text,className:(0,i.clsx)(`univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded univer-border-0 univer-bg-transparent univer-py-1.5 univer-pr-2 univer-text-left univer-text-sm univer-leading-5 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:-univer-outline-offset-2 focus-visible:univer-outline-primary-600 dark:hover:univer-bg-gray-800`,e.isTitle?`univer-font-semibold`:`univer-font-normal`,{"univer-bg-primary-50 univer-text-primary-700 hover:univer-bg-primary-50 dark:univer-bg-gray-700 dark:univer-text-primary-200 dark:hover:univer-bg-gray-700":e.id===f,"univer-text-gray-900 dark:univer-text-gray-100":e.isTitle&&e.id!==f,"univer-text-gray-600 dark:univer-text-gray-300":!e.isTitle&&e.id!==f}),style:{paddingLeft:10+Math.max(0,e.level-1)*12},onClick:()=>{if(a==null||a(e),c===`float`){var t;m==null||m(!1),(t=C.current)==null||t.focus()}},children:[e.level>1&&(0,u.jsx)(`span`,{"aria-hidden":`true`,className:`univer-absolute univer-bottom-0 univer-top-0 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700`,style:{left:14+Math.max(0,e.level-2)*12}}),e.id===f&&(0,u.jsx)(`span`,{"aria-hidden":`true`,className:`univer-absolute univer-bottom-2 univer-left-0 univer-top-2 univer-w-0.5 univer-rounded-full univer-bg-primary-600 dark:univer-bg-primary-400`}),(0,u.jsx)(`span`,{className:e.isTitle?`univer-line-clamp-2 univer-break-words`:`univer-truncate`,children:e.text})]})},e.id))})})]})]})}),rg=e=>{switch(e){case t.NamedStyleType.HEADING_1:return 1;case t.NamedStyleType.HEADING_2:return 2;case t.NamedStyleType.HEADING_3:return 3;case t.NamedStyleType.HEADING_4:return 4;case t.NamedStyleType.HEADING_5:return 5;case t.NamedStyleType.TITLE:return 1;default:return 1}};function ig(e,t,n,r){if(!e)return;let i=Array.from(e.values()),a=i.findIndex(e=>e.paragraphStart!==e.paragraphEnd&&e.rect.top<r&&e.rect.bottom>n);if(a===-1)return;let o=i==null?void 0:i.findLastIndex(e=>e.paragraphStart!==e.paragraphEnd&&e.rect.top<r&&e.rect.bottom>n);for(let e=a;e<=o;e++){var s;let n=i[e],r=t.get(n.startIndex);if(r!=null&&(s=r.paragraphStyle)!=null&&s.headingId)return r.paragraphStyle.headingId}for(let e=a;e>=0;e--){var c;let n=i[e],r=t.get(n.startIndex);if(r!=null&&(c=r.paragraphStyle)!=null&&c.headingId)return r.paragraphStyle.headingId}}let ag=`__title`;function og(){let e=(0,a.useConfigValue)(as),n=(0,a.useDependency)(a.IWorkbenchService);return(0,a.useObservable)(n.rootUnitType$,null,!0)===t.UniverInstanceType.UNIVER_DOC&&e!=null&&e.toc?(0,u.jsx)(sg,{}):null}function sg(){var e,n;let i=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),c=(0,a.useObservable)(()=>i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),void 0,!1,[i]),d=(0,a.useDependency)(r.IRenderManagerService),f=(0,a.useObservable)(c?()=>c.change$.pipe((0,s.debounceTime)(100),(0,s.map)(()=>c.getSnapshot())):null,c==null?void 0:c.getSnapshot(),!1,[c]),p=(f==null||(e=f.body)==null?void 0:e.dataStream)??``,[m,h]=(0,l.useState)(void 0),g=(c==null?void 0:c.getUnitId())??``,_=d.getRenderUnitById(g),v=f==null?void 0:f.title,y=_==null?void 0:_.with(rl),b=y==null?void 0:y.paragraphBounds,x=()=>{var e;return{left:(_==null||(e=_.mainComponent)==null?void 0:e.left)??0,canvasHeight:(_==null?void 0:_.engine.height)??0,canvasWidth:(_==null?void 0:_.engine.width)??0,scaleY:(_==null?void 0:_.scene.scaleY)??1}},{left:S,canvasHeight:C,canvasWidth:w,scaleY:T}=(0,a.useObservable)(_!=null&&_.engine.onTransformChange$?()=>(0,s.merge)((0,t.fromEventSubject)(_.engine.onTransformChange$),..._.mainComponent?[(0,t.fromEventSubject)(_.mainComponent.onTransformChange$)]:[]).pipe((0,s.auditTime)(33),(0,s.map)(x),(0,s.startWith)(x())):null,x(),!1,[_]),E=(0,l.useMemo)(()=>{var e;return(f==null||(e=f.body)==null?void 0:e.paragraphs)??[]},[f==null||(n=f.body)==null?void 0:n.paragraphs]),D=(0,l.useMemo)(()=>(0,t.getParagraphContentStartOffsets)({dataStream:p,paragraphs:E}),[p,E]),O=(0,l.useMemo)(()=>{let e=new Map;return E.forEach(t=>{e.set(t.startIndex,t)}),e},[E]),k=S<240?`float`:`side-bar`,A=E==null?void 0:E.filter(e=>{var n;return((n=e.paragraphStyle)==null?void 0:n.namedStyleType)!==void 0&&e.paragraphStyle.namedStyleType!==t.NamedStyleType.SUBTITLE&&e.paragraphStyle.namedStyleType!==t.NamedStyleType.NORMAL_TEXT}).map(e=>{var n;let r=rg(e.paragraphStyle.namedStyleType);return{id:e.paragraphStyle.headingId,text:(0,t.getPlainText)(p.slice(D.get(e.startIndex),e.startIndex)),level:r,isTitle:((n=e.paragraphStyle)==null?void 0:n.namedStyleType)===t.NamedStyleType.TITLE}}).filter(e=>e==null?void 0:e.text),j=(0,a.useEvent)(e=>{let t=e.viewportScrollY,n=t+C/T,r=ig(b,O,t,n);r&&h(r)}),M=A!=null&&A.find(e=>e.isTitle)?A:[...v?[{id:ag,text:v,level:1,isTitle:!0}]:[],...A??[]].filter(Boolean),[N,ee]=(0,l.useState)(!0);(0,l.useEffect)(()=>{let e=_==null?void 0:_.scene.getViewport(`viewMain`);if(!e)return;let n=(0,t.fromEventSubject)(e.onScrollAfter$).pipe((0,s.throttleTime)(33)).subscribe(j);return()=>{n.unsubscribe()}},[j,_]);let P=(0,a.useEvent)(e=>{let t=_==null?void 0:_.scene.getViewport(`viewMain`);if(!t)return;if(e.id===ag){t.scrollToViewportPos({viewportScrollY:0}),h(e.id);return}let n=E.find(t=>{var n;return((n=t.paragraphStyle)==null?void 0:n.headingId)===e.id});if(!n)return;let r=b==null?void 0:b.get(n.startIndex);r&&(t.scrollToViewportPos({viewportScrollY:r.rect.top}),h(e.id))});return!c||(0,t.isInternalEditorID)(g)||!(M!=null&&M.length)?null:(0,u.jsx)(`div`,{className:`univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]`,children:(0,u.jsx)(ng,{label:o.t(`docs-ui.outline.title`),menus:M,open:N,onOpenChange:ee,mode:k,maxWidth:Math.max(0,Math.floor(k===`float`?w:S)-24),wrapperClass:`univer-mt-4`,activeId:m,onClick:P,maxHeight:Math.max(0,C-32)})})}let cg=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._injector=e,this._commandService=t,this._layoutService=n,this._menuManagerService=r,this._uiPartsService=i,this._univerInstanceService=a,this._shortcutService=o,this._configService=s,this._embedRuntimeFocusCoordinator=l,this._init()}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.FOOTER,()=>(0,a.connectInjector)(tg,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.CONTENT,()=>(0,a.connectInjector)(og,this._injector)))}_initMenus(){this._menuManagerService.appendRootMenu(Lf),this._menuManagerService.mergeMenu(Rf)}_initShortCut(){[Hf,Uf,Wf,Gf,Kf,qf,Xf,Zf,Yf,Jf,Qf,$f,Bf].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts(),this._initShortCut()}_initCommands(){[ll,cl,jc,Mc,kc].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(t.UniverInstanceType.UNIVER_DOC,e=>{if(this._shouldPreserveEmbedFocus(e))return;let t=this._injector.get(r.IRenderManagerService).getRenderUnitById(e);t&&t.with(q).focus()}))}_shouldPreserveEmbedFocus(e){var t;return!!((t=this._embedRuntimeFocusCoordinator)!=null&&t.shouldSuppressHostInteraction(e))}};cg=B([z(0,(0,t.Inject)(t.Injector)),z(1,t.ICommandService),z(2,a.ILayoutService),z(3,a.IMenuManagerService),z(4,a.IUIPartsService),z(5,t.IUniverInstanceService),z(6,a.IShortcutService),z(7,t.IConfigService),z(8,(0,t.Optional)(Ie)),z(9,(0,t.Optional)(Le))],cg);function lg(){if(typeof window>`u`)return{bleedLeft:0,bleedRight:0,bleedWidth:1,contentWidth:1,virtualWidth:1};let e=Math.max(1,window.innerWidth-20);return{bleedLeft:0,bleedRight:0,bleedWidth:e,contentWidth:1,virtualWidth:e}}function ug(e,t,n){let r=e.getBoundingClientRect(),i=n==null?void 0:n.viewScale,a=typeof i==`number`&&Number.isFinite(i)&&i>0?i:1,o=Math.max(1,r.width/a),s=Math.max(1,t),c=n==null?void 0:n.bleedLeft,l=n==null?void 0:n.bleedWidth,u=Number.isFinite(l)&&(l??0)>0;if(s<=o&&(n!=null&&n.authoritativeContentWidth||!u))return{bleedLeft:0,bleedRight:0,bleedWidth:o,contentWidth:s,virtualWidth:o};if(u){let e=Math.max(0,c??0),t=Math.max(1,l);return{bleedLeft:e,bleedRight:Math.max(0,t-e-o),bleedWidth:t,contentWidth:s,virtualWidth:Math.max(t,e+s)}}let d=pg(e),f=d.left+10,p=Math.max(1,d.width-20),m=Math.max(0,(r.left-f)/a),h=Math.max(0,(f+p-r.right)/a),g=p/a;return{bleedLeft:m,bleedRight:h,bleedWidth:g,contentWidth:s,virtualWidth:Math.max(g,m+s)}}function dg(e,t){return Number.isFinite(e)&&(e??0)>0?e:Math.max(1,t)}function fg(e,t){return Number.isFinite(e)&&(e??0)>0?e:Math.max(1,t)}function pg(e){let t=mg(e);if(t){let e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&e.width>0)return{left:e.left,width:e.width}}return{left:0,width:typeof window>`u`?1:Math.max(1,window.innerWidth)}}function mg(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){if(hg(t))return t;t=t.parentElement}return null}function hg(e){let t=window.getComputedStyle(e);return gg(t.overflow)||gg(t.overflowX)||gg(t.overflowY)}function gg(e){return e===`hidden`||e===`auto`||e===`scroll`||e===`clip`}function _g(e,t){let r=new Set;return Object.values(e??{}).forEach(e=>{let i=vg(e),a=i?(t==null?void 0:t(i))??(typeof i.childUnitId==`string`?i.childUnitId:void 0):void 0,o=typeof(i==null?void 0:i.childType)==`number`?i.childType:void 0;a&&(0,n.isSheetLikeDocsCustomBlockChildType)(o)&&r.add(a)}),r}function vg(e){if(!e||typeof e!=`object`)return;let t=e.data;return t&&typeof t==`object`?t:void 0}function yg(e){if(!e||typeof e!=`object`)return;let t=e;return typeof t.unitId==`string`?t.unitId:typeof t.unitID==`string`?t.unitID:void 0}function bg(e){if(e.commandId&&Sg(e.commandId))return!1;let t=yg(e.commandParams);return!!(t&&t!==e.hostUnitId&&e.childUnitIds.has(t))}let xg=new Set([`sheet.command.expand-selection`,`sheet.command.move-selection`,`sheet.operation.scroll-to-cell`,`sheet.operation.scroll-to-range`,`sheet.operation.set-activate-cell-edit`,`sheet.operation.set-cell-edit-visible`,`sheet.operation.set-cell-edit-visible-arrow`,`sheet.operation.set-cell-edit-visible-f2`,`sheet.operation.set-format-painter`,`sheet.operation.set-scroll`,`sheet.operation.set-selections`,`sheet.operation.set-zoom-ratio`]);function Sg(e){return xg.has(e)}function Cg(e){let t;return{dispose:()=>{t!=null&&(window.cancelAnimationFrame(t),t=void 0)},schedule:()=>{t??=window.requestAnimationFrame(()=>{t=void 0,e()})}}}function wg(e,t,n={}){if(e.defaultPrevented||e.ctrlKey||e.metaKey)return!1;let r=e.deltaX||(e.shiftKey?e.deltaY:0),i=e.shiftKey?0:e.deltaY,a=t.scrollLeft,o=t.scrollTop,s=Og(t,n.maxScrollLeft);return r&&Tg(t,r,s)&&(t.scrollLeft=Dg(a+r,0,s)),i&&Eg(t,i)&&(t.scrollTop=Dg(o+i,0,t.scrollHeight-t.clientHeight)),t.scrollLeft!==a||t.scrollTop!==o}function Tg(e,t,n){return e.scrollWidth>e.clientWidth&&(t<0?e.scrollLeft>0:e.scrollLeft<n)}function Eg(e,t){return e.scrollHeight>e.clientHeight&&(t<0?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight)}function Dg(e,t,n){return Math.max(t,Math.min(n,e))}function Og(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth);return Number.isFinite(t)?Dg(t??n,0,n):n}function kg(e){let r=(0,n.resolveDocsCustomBlockSize)(e.childType),i=e.fallbackWidth??r.width,a=e.fallbackHeight??r.height,o=(0,n.isSheetLikeDocsCustomBlockChildType)(e.childType),s=Number.isFinite(e.contentHeight)&&(e.contentHeight??0)>0?e.contentHeight:a,c=Number.isFinite(e.visibleCanvasHeight)&&(e.visibleCanvasHeight??0)>0?e.visibleCanvasHeight:void 0,l=o?s:a,u=o&&c!=null?Math.min(s,c):l,d=e.scale&&e.scale>0?e.scale:1;if(!o)return{height:l,width:i};let f=e.pageWidth,p=e.pageMarginLeft??0,m=e.pageMarginRight??0,h=Number.isFinite(f)?Math.max(0,f-p-m):i,g=Number.isFinite(e.contentWidth)&&(e.contentWidth??0)>0?e.contentWidth:i;if(e.documentFlavor!==t.DocumentFlavor.MODERN||!Number.isFinite(f)){let e=Math.min(g,h||g);return{contentHeight:s,contentWidth:g,height:l,layoutWidth:e,offsetLeft:0,pageContentWidth:h,viewScale:d,visibleCanvasHeight:c,viewportHeight:u,width:e}}let _=10/d,v=e.docsLeft??0,y=v+_,b=Math.max(0,f-_*2),x=Number.isFinite(e.visibleCanvasLeft)&&Number.isFinite(e.visibleCanvasWidth)&&(e.visibleCanvasWidth??0)>0,S=x?e.visibleCanvasLeft+_:y,C=x?Math.max(0,e.visibleCanvasWidth-_*2):b,w=v+p,T=Math.max(0,w-S),E=Math.min(g,h||g);return{bleedLeft:T,bleedWidth:C,contentHeight:s,contentWidth:g,height:l,layoutWidth:E,offsetLeft:0,pageContentWidth:h,viewScale:d,visibleCanvasHeight:c,viewportHeight:u,width:E}}var Ag=`@univerjs/docs-ui`,jg=`1.0.1`;let Mg={id:`doc-paragraph-setting.command`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=i.getDocRanges();if(!s||c.length===0||!r)return!1;let l=c[0].segmentId,u=s.getUnitId(),d=s.getSelfOrHeaderFooterModel(l),f=d==null?void 0:d.getBody(),p=(f==null?void 0:f.paragraphs)??[],m=(f==null?void 0:f.dataStream)??``,h=t.BuildTextUtils.range.getParagraphsInRanges(c,p,m)??[],g={id:n.RichTextEditingMutation.id,params:{unitId:u,historyAction:n.DocHistoryAction.FormatParagraph,actions:[],textRanges:c}};if(!r.paragraph||Object.keys(r.paragraph).length===0)return!1;let _=new t.MemoryCursor;_.reset();let v=new t.TextX,y=t.JSONX.getInstance();for(let e of h){let{startIndex:n}=e;v.push({t:t.TextXActionType.RETAIN,len:n-_.cursor}),v.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...e,paragraphStyle:{...e.paragraphStyle,...r.paragraph},startIndex:0}]},coverType:t.UpdateDocsAttributeType.REPLACE}),_.moveCursorTo(n+1)}let b=(0,t.getRichTextEditPath)(s,l);return g.params.actions=y.editOp(v.serialize(),b),!!o.syncExecuteCommand(g.id,g.params)}};function Ng(e){return Object.prototype.hasOwnProperty.call(t.QuickListTypeMap,e)}function Pg(e){return Object.prototype.hasOwnProperty.call(wo,e)}let Fg=class extends t.Disposable{constructor(e,t){super(),this._docAutoFormatService=e,this._renderManagerService=t,this._initListTabAutoFormat(),this._initSpaceAutoFormat(),this._initDefaultEnterFormat(),this._initExitListAutoFormat()}_initListTabAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:te.id,match:e=>{let{selection:t,paragraphs:n,unit:r}=e;if(n.length===1&&t.startOffset===n[0].paragraphStart&&n[0].bullet){var i;let e=(i=r.getBody())==null?void 0:i.paragraphs,t=e==null?void 0:e.filter(e=>{var t;return((t=e.bullet)==null?void 0:t.listId)===n[0].bullet.listId});return(t==null?void 0:t.findIndex(e=>e.startIndex===n[0].startIndex))!==0}return!!(n.length>1&&n.some(e=>e.bullet))},getMutations(e){let t=e.commandParams;return[{id:to.id,params:{type:t!=null&&t.shift?-1:1}}]},priority:100})),this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:te.id,match:e=>{let{selection:t,unit:r}=e,{startNodePosition:i,endNodePosition:a}=t,o=this._renderManagerService.getRenderUnitById(r.getUnitId()),s=o==null?void 0:o.with(n.DocSkeletonManagerService).getSkeleton();return s!=null&&!!(i&&a&&ot(s,i,a)||i&&!a&&i.path.indexOf(`cells`)>-1)},getMutations(e){let t=e.commandParams;return[{id:$o.id,params:{shift:!!(t!=null&&t.shift)}}]},priority:99}))}_initSpaceAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:ne.id,match:e=>{var t;let{selection:n,paragraphs:r,unit:i}=e;if(!n.collapsed||r.length!==1||!n.collapsed)return!1;let a=(t=i.getBody())==null?void 0:t.dataStream.slice(r[0].paragraphStart,n.startOffset-1);return!!(a&&(Ng(a)||Pg(a)))},getMutations(e){var n;let{paragraphs:r,unit:i,selection:a}=e,o=(n=i.getBody())==null?void 0:n.dataStream.slice(r[0].paragraphStart,a.startOffset-1);if(o&&Ng(o)){let e=t.QuickListTypeMap[o];return[{id:oo.id,params:{listType:e,paragraph:r[0]}}]}if(o&&Pg(o)){let e=wo[o];return[{id:Co.id,params:{value:e}}]}return[]}}))}_initExitListAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:re.id,match:e=>{let{paragraphs:t}=e;return!!(t.length===1&&t[0].bullet&&t[0].paragraphStart===t[0].paragraphEnd)},getMutations:e=>{let t=e.paragraphs[0].bullet;return t?t.nestingLevel>0?[{id:to.id,params:{type:-1}}]:[{id:Qa.id,params:{listType:e.paragraphs[0].bullet.listType}}]:[]}}))}_initDefaultEnterFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:re.id,match:()=>!0,getMutations(){return[{id:W.id}]},priority:-9999}))}};Fg=B([z(0,(0,t.Inject)(V)),z(1,r.IRenderManagerService)],Fg);var Ig=class extends r.BaseObject{constructor(e,t,n){super(e),this._documents=t,this._scene=n,R(this,`color`,``),this.evented=!1}render(e,n){let i=this._documents.getSkeleton(),a=i==null?void 0:i.getViewModel(),o=i==null?void 0:i.getSkeletonData();if(!o||!a||!this.color||a.getEditArea()!==r.DocumentEditArea.BODY||a.getDataModel().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let s=[];if(this._collectStoryBounds(o,s,n),this._collectDrawingBounds(a.getSnapshot(),s,n==null?void 0:n.viewBound),s.length!==0){e.save(),e.fillStyle=this.color,e.beginPath();for(let t of s)e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top);e.fill(),e.restore(),this.makeDirty(!1)}}_collectStoryBounds(e,t,n){let{pageLayoutType:i,pageMarginTop:a,pageMarginLeft:o}=this._documents.getOffsetConfig(),s=0,c=0;for(let d of e.pages){if(!d.isLayoutPlaceholder&&!d.isMaterializationPlaceholder&&!this._documents.isSkipByDiffBounds(d,c,s,n)){var l,u;let n=this._transformBounds({left:s,top:c,right:s+d.pageWidth,bottom:c+d.pageHeight}),r=(l=e.skeHeaders.get(d.headerId))==null?void 0:l.get(d.pageWidth),i=(u=e.skeFooters.get(d.footerId))==null?void 0:u.get(d.pageWidth),a=[];r&&this._collectTextAndTables(r,s+d.marginLeft,c+r.marginTop,a),i&&this._collectTextAndTables(i,s+d.marginLeft,c+d.pageHeight-i.height-i.marginBottom,a);for(let e of a)this._appendClipped(t,this._transformBounds(e),n)}i===r.PageLayoutType.HORIZONTAL?s+=d.pageWidth+o:c+=d.pageHeight+a}}_collectDrawingBounds(e,n,i){let a=e.id,o=(0,d.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:a,drawingId:``});for(let a of this._scene.getAllObjects()){var s;if(!a.visible||a.classType===r.RENDER_CLASS_TYPE.GROUP||!a.oKey.startsWith(o))continue;let c=a.oKey.slice(o.length).split(`#-#`,1)[0],l=(s=e.drawings)==null?void 0:s[c];if((l==null?void 0:l.isMultiTransform)!==t.BooleanNumber.TRUE)continue;let u=l.effectExtent,d=this._transformBounds({left:-((u==null?void 0:u.left)??0),top:-((u==null?void 0:u.top)??0),right:a.width+((u==null?void 0:u.right)??0),bottom:a.height+((u==null?void 0:u.bottom)??0)},a.ancestorTransform),f=a.clipBounds,p=[];this._appendClipped(p,d,f?{left:f.left,top:f.top,right:f.left+f.width,bottom:f.top+f.height}:void 0);for(let e of p)this._appendClipped(n,e,i)}}_transformBounds(e,t=this._documents.getOffsetConfig().documentTransform){let n=[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]].map(([e,n])=>t.applyPoint(new r.Vector2(e,n)));return{left:Math.min(...n.map(e=>e.x)),right:Math.max(...n.map(e=>e.x)),top:Math.min(...n.map(e=>e.y)),bottom:Math.max(...n.map(e=>e.y))}}_appendClipped(e,t,n){let r=n?{left:Math.max(t.left,n.left),right:Math.min(t.right,n.right),top:Math.max(t.top,n.top),bottom:Math.min(t.bottom,n.bottom)}:t;Object.values(r).every(Number.isFinite)&&r.right>r.left&&r.bottom>r.top&&e.push(r)}_collectTextAndTables(e,t,n,r){for(let i of e.sections)for(let e of i.columns)for(let a of e.lines){let o=n+i.top+a.top+a.marginTop+a.paddingTop;for(let n of a.divides)for(let i of n.glyphGroup){if(!Array.from(i.content).some(e=>e.charCodeAt(0)>32&&e.trim())||i.width<=0)continue;let s=t+e.left+n.left+n.paddingLeft+i.left+i.xOffset,c=o+a.asc;r.push({left:s-1,right:s+Math.max(i.width,i.bBox.width)+1,top:Math.min(o,c-i.bBox.aba)-1,bottom:Math.max(o+a.lineHeight,c+i.bBox.abd)+1})}(a.borderTop||a.borderBottom||a.borderLeft||a.borderRight||a.borderBetween)&&r.push({left:t+e.left,right:t+e.left+e.width,top:o-2,bottom:o+a.lineHeight+2})}for(let i of e.skeTables.values())r.push({left:t+i.left-1,right:t+i.left+i.width+1,top:n+i.top-1,bottom:n+i.top+i.height+1})}};function Lg(e,t){let{radius:n,width:r,height:i}=t;n??=0,r??=30,i??=30;let a=0;a=Math.min(n,r/2,i/2),e.beginPath(),e.moveTo(0,0),e.lineTo(r,0),e.lineTo(r,i-a),e.arc(r-a,i-a,a,0,Math.PI/2,!1),e.lineTo(0,i),e.lineTo(0,0),e.closePath(),t.fill&&(e.save(),e.fillStyle=t.fill,t.fillRule===`evenodd`?e.fill(`evenodd`):e.fill(),e.restore())}var Rg=class e extends r.Shape{constructor(e,t){super(e,t),R(this,`color`,void 0),R(this,`text`,void 0),this.color=t==null?void 0:t.color,this.text=t==null?void 0:t.text}static drawWith(e,t){let{text:n,color:r}=t;e.save(),e.font=`13px Source Han Sans CN`;let i=e.measureText(n).width;if(Lg(e,{height:18,width:Math.min(i+12,200),radius:4,fill:r,evented:!1}),e.fillStyle=`rgba(58, 96, 247, 1)`,i>188){let t=``,r=0;for(let i of n){let n=e.measureText(i).width;if(r+n<=188-e.measureText(`...`).width)t+=i,r+=n;else{t+=`...`;break}}e.fillText(t,6,14)}else e.fillText(n,6,14);e.restore()}_draw(t){e.drawWith(t,this)}};let zg=.5,Bg=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._commandService=t,this._editorService=n,this._docSkeletonManagerService=r,this._docSelectionRenderService=i,this._localeService=a,this._themeService=o,R(this,`_loadedMap`,new WeakSet),R(this,`_contentCover`,void 0),R(this,`_headerFooterColors`,{primary:``,cover:``,label:``}),this._initialize()}_initialize(){this._initThemeColors(),this._init(),this._drawHeaderFooterLabel(),this._listenSwitchMode()}_initThemeColors(){this.disposeWithMe(this._themeService.currentTheme$.subscribe(()=>{let e=this._themeService.getColorFromTheme(`primary.600`);this._headerFooterColors={primary:e,cover:new t.ColorKit(this._themeService.getColorFromTheme(`gray.0`)).setAlpha(zg).toRgbString(),label:new t.ColorKit(e).setAlpha(.08).toRgbString()},this._contentCover&&(this._contentCover.color=this._headerFooterColors.cover,this._contentCover.makeDirty(!0))}))}dispose(){super.dispose()}_listenSwitchMode(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.RichTextEditingMutation.id===e.id){let e=this._context.unit,n=this._docSkeletonManagerService.getViewModel().getEditArea(),i=e.getSnapshot().documentStyle.documentFlavor;n!==r.DocumentEditArea.BODY&&i===t.DocumentFlavor.MODERN&&this._commandService.executeCommand(Nc.id,{unitId:this._context.unitId})}}))}_init(){let{unitId:e}=this._context,t=x(this._context);t!=null&&t.document!=null&&(this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document)))}_initialMain(e){let{document:n}=x(this._context);this.disposeWithMe(n.onDblclick$.subscribeEvent(async i=>{var a;if(this._isEditorReadOnly(e)||!this._isTraditionalMode())return;let{offsetX:o,offsetY:s}=i,{pageLayoutType:c=r.PageLayoutType.VERTICAL,pageMarginLeft:l,pageMarginTop:u}=n.getOffsetConfig(),d=this._getTransformCoordForDocumentOffset(o,s);if(d==null)return;let f=this._docSkeletonManagerService.getViewModel(),p=this._docSkeletonManagerService.getSkeleton(),m=f.getEditArea(),{editArea:h,pageNumber:g}=p.findEditAreaByCoord(d,c,l,u);if(m===h&&(h===r.DocumentEditArea.BODY||this._docSelectionRenderService.getSegmentPage()===g))return;f.setEditArea(h);let{createType:_,headerFooterId:v,sectionId:y}=Dc(f,h,g,(a=p.getSkeletonData())==null?void 0:a.pages[g]);if(h===r.DocumentEditArea.BODY)this._docSelectionRenderService.setSegment(``),this._docSelectionRenderService.setSegmentPage(-1),this._docSelectionRenderService.setCursorManually(o,s);else if(_!=null){let n=(0,t.generateRandomId)(6);this._docSelectionRenderService.setSegment(n),this._docSelectionRenderService.setSegmentPage(g),await this._commandService.executeCommand(jc.id,{unitId:e,createType:_,segmentId:n,sectionId:y})}else v!=null&&(this._docSelectionRenderService.setSegment(v),this._docSelectionRenderService.setSegmentPage(g),this._docSelectionRenderService.setCursorManually(o,s))}))}_getTransformCoordForDocumentOffset(e,t){let{document:n,scene:i}=x(this._context),{documentTransform:a}=n.getOffsetConfig(),o=i.getViewports()[0];if(o==null)return;let s=o.transformVector2SceneCoord(r.Vector2.FromArray([e,t]));return a.clone().invert().applyPoint(s)}_drawHeaderFooterLabel(){let{unitId:e,mainComponent:n}=this._context;if(this._editorService.isEditor(e)||n==null)return;let i=n,a=new Ig(`${e}-header-footer-cover`,i,this._context.scene);a.color=this._headerFooterColors.cover,this._contentCover=a,this._context.scene.addObject(a,r.DRAWING_OBJECT_UPPER_LAYER_INDEX),this.disposeWithMe(a),this.disposeWithMe((0,t.toDisposable)(()=>{this._contentCover=void 0})),i.setInactiveAreaOpacity(zg),this.disposeWithMe((0,t.toDisposable)(()=>i.setInactiveAreaOpacity(1))),this.disposeWithMe(this._docSkeletonManagerService.getViewModel().editAreaChange$.subscribe(()=>{i.makeDirty(!0)})),this.disposeWithMe(i.pageRender$.subscribe(t=>this._drawHeaderFooterPage(t,e)))}_drawHeaderFooterPage(e,t){if(this._editorService.isEditor(t)||!this._isTraditionalMode()||this._docSkeletonManagerService.getViewModel().getEditArea()===r.DocumentEditArea.BODY)return;let{pageLeft:n,pageTop:i,ctx:a}=e;a.save(),a.translate(n-.5,i-.5),this._drawHeaderFooterGuides(e),a.restore()}_drawHeaderFooterGuides({page:e,ctx:t}){let{pageWidth:n,pageHeight:i,marginTop:a,marginBottom:o}=e,s={dataArray:[{command:`M`,points:[0,a]},{command:`L`,points:[n,a]}],strokeWidth:1,stroke:this._headerFooterColors.primary},c={dataArray:[{command:`M`,points:[0,i-o]},{command:`L`,points:[n,i-o]}],strokeWidth:1,stroke:this._headerFooterColors.primary};r.Path.drawWith(t,s),r.Path.drawWith(t,c),t.translate(0,a+1),Rg.drawWith(t,{text:this._localeService.t(`docs-ui.headerFooter.header`),color:this._headerFooterColors.label}),t.translate(0,i-a-o),Rg.drawWith(t,{text:this._localeService.t(`docs-ui.headerFooter.footer`),color:this._headerFooterColors.label})}_isEditorReadOnly(e){let t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_isTraditionalMode(){return this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL}};Bg=B([z(1,t.ICommandService),z(2,J),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(t.LocaleService)),z(6,(0,t.Inject)(t.ThemeService))],Bg);function Vg(e,t){let{ed:n}=e,{skeTables:r}=t,i=null;for(let e of r.values())if(e.st===n+1){i=e;break}return i}function Hg(e,t){let{st:n}=e,{skeTables:r}=t,i=null;for(let e of r.values())if(e.ed===n-1){i=e;break}return i}function Ug(e){return e.sections[0].columns[0].lines[0]}function Wg(e){let t=(0,r.getLastColumn)(e);return t.lines[t.lines.length-1]}let Gg=class extends t.Disposable{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._renderManagerService=t,this._textSelectionManagerService=n,this._commandService=r,R(this,`_onInputSubscription`,void 0),this._commandExecutedListener()}dispose(){var e;super.dispose(),(e=this._onInputSubscription)==null||e.unsubscribe()}_commandExecutedListener(){let e=[rs.id,is.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(!e.includes(t.id))return;let n=t.params;switch(t.id){case rs.id:return this._handleMoveCursor(n.direction,n.granularity??`character`);case is.id:return this._handleShiftMoveSelection(n.direction,n.granularity??`character`);default:throw Error(`Unknown command`)}}))}_handleShiftMoveSelection(e,r=`character`){var i;let a=this._textSelectionManagerService.getActiveTextRange(),o=this._textSelectionManagerService.getTextRanges(),s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(s==null)return;let c=this._renderManagerService.getRenderUnitById(s.getUnitId()),l=c==null?void 0:c.with(n.DocSkeletonManagerService).getSkeleton(),u=c?x(c):null;if(a==null||l==null||u==null)return;let{startOffset:d,endOffset:f,style:p,collapsed:m,direction:h,segmentId:g,startNodePosition:_,endNodePosition:v,segmentPage:y}=a,b=g??``,S=y??-1;if(o.length>1){let n=1/0,r=-1/0;for(let e of o)n=Math.min(n,e.startOffset),r=Math.max(r,e.endOffset);this._textSelectionManagerService.replaceDocRanges([{startOffset:e===t.Direction.LEFT||e===t.Direction.UP?r:n,endOffset:e===t.Direction.LEFT||e===t.Direction.UP?n:r,style:p}],void 0,!1);return}let C=m||h===t.RANGE_DIRECTION.FORWARD?d:f,w=m||h===t.RANGE_DIRECTION.FORWARD?f:d,T=(i=s.getSelfOrHeaderFooterModel(b))==null?void 0:i.getBody();if(T==null)return;let E=T.dataStream.length??1/0,D=s.getCustomRanges()??[];if(r!==`character`){let t=this._getCursorOffsetByGranularity(l,w,e,r,b,S,E,T.dataStream);if(t==null||t===w)return;let n=this._normalizeRenderableCursorOffset(l,T.dataStream,D,t,e,b,S);if(n==null||n===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:n,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),n);return}if(e===t.Direction.LEFT||e===t.Direction.RIGHT){let n=l.findNodeByCharIndex(w-1,g,y),r=l.findNodeByCharIndex(w,g,y);w=e===t.Direction.RIGHT?w+((r==null?void 0:r.count)??1):w-((n==null?void 0:n.count)??1),w=this._normalizeCursorOffset(T.dataStream,D,w,e),w=Math.min(E-2,Math.max(0,w));let i=this._normalizeRenderableCursorOffset(l,T.dataStream,D,w,e,b,S);if(i==null)return;w=i,this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:w,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),w)}else{let n=l.findNodeByCharIndex(w,g,y),r=u.document.getOffsetConfig(),i=m?_:h===t.RANGE_DIRECTION.FORWARD?v:_,a=this._getTopOrBottomPosition(l,n,i,e===t.Direction.DOWN,!0);if(a==null){let n=this._normalizeRenderableCursorOffset(l,T.dataStream,D,e===t.Direction.UP?0:E-2,e,b,S);if(n==null||n===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:n,style:p}],void 0,!1);return}let o=new Ze(r,l).getRangePointData(a,a).cursorList[0],c=this._normalizeRenderableCursorOffset(l,T.dataStream,D,o.endOffset,e,b,S);if(c==null||c===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:c,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),c)}}_handleMoveCursor(e,r=`character`){var i;let a=this._textSelectionManagerService.getActiveTextRange(),o=this._textSelectionManagerService.getTextRanges(),s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(s==null)return!1;let c=this._renderManagerService.getRenderUnitById(s.getUnitId()),l=c==null?void 0:c.with(n.DocSkeletonManagerService).getSkeleton(),u=c?x(c):null;if(a==null||l==null||u==null||o==null)return;let{startOffset:d,endOffset:f,style:p,collapsed:m,segmentId:h,startNodePosition:g,endNodePosition:_,segmentPage:v}=a,y=h??``,b=v??-1,S=(i=s.getSelfOrHeaderFooterModel(y))==null?void 0:i.getBody();if(S==null)return;let C=S.dataStream.length??1/0,w=s.getCustomRanges()??[];if(r!==`character`){let n;if(!a.collapsed||o.length>1){let r=1/0,i=-1/0;for(let e of o)r=Math.min(r,e.startOffset),i=Math.max(i,e.endOffset);n=e===t.Direction.LEFT||e===t.Direction.UP?r:i}else n=e===t.Direction.LEFT||e===t.Direction.UP?d:f;let i=this._getCursorOffsetByGranularity(l,n,e,r,y,b,C,S.dataStream);if(i==null||this._deferUnmaterializedCursorMove(s,l,i,y,()=>this._handleMoveCursor(e,r))||(i=this._normalizeRenderableCursorOffset(l,S.dataStream,w,i,e,y,b),i==null))return;this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:i,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),i);return}if(e===t.Direction.LEFT||e===t.Direction.RIGHT){let n;if(!a.collapsed||o.length>1){let r=1/0,i=-1/0;for(let e of o)r=Math.min(r,e.startOffset),i=Math.max(i,e.endOffset);n=e===t.Direction.LEFT?r:i}else{let r=l.findNodeByCharIndex(d-1,h,v),i=l.findNodeByCharIndex(d,h,v),a=l.findNodeByCharIndex(d+1,h,v);n=e===t.Direction.LEFT?Math.max(0,d-((r==null?void 0:r.count)??1)):Math.min(C-2,f+i.count+ +((a==null?void 0:a.streamType)===t.DataStreamTreeTokenType.SECTION_BREAK))}let r=[...this._getCursorSkipTokens()];if(e===t.Direction.LEFT)for(;r.includes(S.dataStream[n]);)n--;else for(;r.includes(S.dataStream[n]);)n++;n=this._normalizeCursorOffset(S.dataStream,w,n,e);let i=this._normalizeRenderableCursorOffset(l,S.dataStream,w,n,e,y,b);if(i==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:i,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),i)}else{let n=l.findNodeByCharIndex(d,h,v),r=l.findNodeByCharIndex(f,h,v),i=u.document.getOffsetConfig(),a=this._getTopOrBottomPosition(l,e===t.Direction.UP||m?n:r,e===t.Direction.UP||m?g:_,e===t.Direction.DOWN);if(a==null){let n;if(n=m?this._normalizeRenderableCursorOffset(l,S.dataStream,w,e===t.Direction.UP?0:C-2,e,y,b):this._normalizeRenderableCursorOffset(l,S.dataStream,w,e===t.Direction.UP?d:f,e,y,b),n==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:n,endOffset:n,style:p}],void 0,!1);return}let o=new Ze(i,l).getRangePointData(a,a).cursorList[0],c=this._normalizeRenderableCursorOffset(l,S.dataStream,w,o.endOffset,e,y,b);if(c==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:c,endOffset:c,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),c)}}_deferUnmaterializedCursorMove(e,n,r,i,a){var o,s,c;if(i!==``)return!1;let l=n.findBodyPageIndexByCharIndex(r),u=(o=n.getSkeletonData())==null?void 0:o.pages[l];if(l>=0&&!(u!=null&&u.isMaterializationPlaceholder))return!1;let d=this._renderManagerService.getRenderUnitById(e.getUnitId());if(!(d!=null&&(s=d.getInjector)!=null&&s.call(d).has(ds)))return!1;let f=this._textSelectionManagerService.getActiveTextRange(),p=(c=e.getBody())==null?void 0:c.dataStream;return d.with(ds).scrollToRange({startOffset:r,endOffset:r,collapsed:!0},()=>{var n,r;let i=this._textSelectionManagerService.getActiveTextRange();((n=e.getBody())==null?void 0:n.dataStream)===p&&(i==null?void 0:i.startOffset)===(f==null?void 0:f.startOffset)&&(i==null?void 0:i.endOffset)===(f==null?void 0:f.endOffset)&&(i==null?void 0:i.segmentId)===(f==null?void 0:f.segmentId)&&((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId())===e.getUnitId()&&a()}),!0}_getCursorOffsetByGranularity(e,n,r,i,a,o,s,c=``){switch(i){case`document`:return r===t.Direction.LEFT||r===t.Direction.UP?0:s-2;case`paragraph`:return this._getParagraphBoundaryOffset(c,n,r);case`line`:return this._getLineBoundaryOffset(e,n,r,a,o,s);case`word`:return this._getWordBoundaryOffset(e,n,r,a,o,s);default:return null}}_getParagraphBoundaryOffset(e,n,r){if(r!==t.Direction.UP&&r!==t.Direction.DOWN)return;if(e.length===0)return 0;let i=Math.min(Math.max(0,n),e.length-1);if(r===t.Direction.UP){let t=this._getCurrentParagraphStartOffset(e,i);return i>t?t:this._getCurrentParagraphStartOffset(e,Math.max(0,t-1))}let a=e.indexOf(t.DataStreamTreeTokenType.PARAGRAPH,i);return a===-1?e.length-1:a+1}_getCurrentParagraphStartOffset(e,n){for(let r=Math.min(n-1,e.length-1);r>=0;r--){let n=e[r];if(n===t.DataStreamTreeTokenType.PARAGRAPH||n===t.DataStreamTreeTokenType.SECTION_BREAK)return r+1}return 0}_getWordBoundaryOffset(e,n,r,i,a,o){if(r!==t.Direction.LEFT&&r!==t.Direction.RIGHT)return;let s=e.findNodeByCharIndex(n,i,a)??e.findNodeByCharIndex(Math.max(0,n-1),i,a);if(s==null)return r===t.Direction.LEFT?0:o-2;let c=Rt(s);if(c==null)return;let l=Math.min(Math.max(0,n-c.st),c.content.length),u=Ut(c.content,l,c.st,r);if(u!=null)return Math.min(o-2,Math.max(0,u))}_getLineBoundaryOffset(e,n,r,i,a,o){var s;if(r!==t.Direction.LEFT&&r!==t.Direction.RIGHT)return;let c=e.findNodeByCharIndex(n,i,a)??e.findNodeByCharIndex(Math.max(0,n-1),i,a),l=c==null||(s=c.parent)==null?void 0:s.parent;if(l==null)return r===t.Direction.LEFT?0:o-2;let u=r===t.Direction.LEFT?this._getFirstCursorGlyphInLine(l):this._getLastCursorGlyphInLine(l),d=u==null?void 0:e.findPositionByGlyph(u,a);if(d==null)return r===t.Direction.LEFT?0:o-2;let f=e.findCharIndexByPosition({...d,isBack:r===t.Direction.LEFT});if(f!=null)return Math.min(o-2,Math.max(0,f))}_getFirstCursorGlyphInLine(e){for(let t of e.divides)for(let e of t.glyphGroup)if(this._isCursorAddressableGlyph(e))return e}_getLastCursorGlyphInLine(e){for(let t=e.divides.length-1;t>=0;t--){let n=e.divides[t];for(let e=n.glyphGroup.length-1;e>=0;e--){let t=n.glyphGroup[e];if(this._isCursorAddressableGlyph(t))return t}}}_isCursorAddressableGlyph(e){return e.count>0&&!this._getCursorSkipTokens(!0).includes(e.streamType)}_normalizeCursorOffset(e,n,r,i){r=Math.max(0,r);let a=this._getCursorSkipTokens();if(i===t.Direction.LEFT||i===t.Direction.UP)for(;r>0&&a.includes(e[r]);)r--;else for(;r<e.length-1&&a.includes(e[r]);)r++;return this._normalizeWholeEntityRanges(n,r,i)}_normalizeRenderableCursorOffset(e,n,r,i,a,o,s){let c=Math.min(Math.max(0,i),Math.max(0,n.length-1)),l=this._findNearestRenderableCursorOffset(e,n,r,c,a,o,s);if(l!=null)return l;let u=a===t.Direction.LEFT||a===t.Direction.UP?t.Direction.DOWN:t.Direction.UP;return this._findNearestRenderableCursorOffset(e,n,r,c,u,o,s)}_findNearestRenderableCursorOffset(e,n,r,i,a,o,s){let c=a===t.Direction.LEFT||a===t.Direction.UP?-1:1,l=Math.min(Math.max(0,i),Math.max(0,n.length-1)),u=new Set;for(;l>=0&&l<n.length&&!u.has(l);){u.add(l);let t=this._normalizeCursorOffset(n,r,l,a);if(t<0||t>=n.length)return;if(this._isRenderableCursorOffset(e,n,t,o,s))return t;l=t+c}}_isRenderableCursorOffset(e,t,n,r,i){return n<0||n>=t.length||this._getNonRenderableCursorTokens().includes(t[n])?!1:e.findNodePositionByCharIndex(n,!0,r,i)!=null}_normalizeWholeEntityRanges(e,n,r){return e.filter(e=>e.wholeEntity&&e.startIndex<n&&e.endIndex>=n).forEach(e=>{n=r===t.Direction.LEFT||r===t.Direction.UP?Math.min(e.startIndex,n):Math.max(e.endIndex+1,n)}),n}_getCursorSkipTokens(e=!1){let n=[t.DataStreamTreeTokenType.TABLE_START,t.DataStreamTreeTokenType.TABLE_END,t.DataStreamTreeTokenType.TABLE_ROW_START,t.DataStreamTreeTokenType.TABLE_ROW_END,t.DataStreamTreeTokenType.TABLE_CELL_START,t.DataStreamTreeTokenType.TABLE_CELL_END,t.DataStreamTreeTokenType.SECTION_BREAK,t.DataStreamTreeTokenType.BLOCK_START,t.DataStreamTreeTokenType.BLOCK_END,t.DataStreamTreeTokenType.CUSTOM_RANGE_START,t.DataStreamTreeTokenType.CUSTOM_RANGE_END];return e&&n.push(t.DataStreamTreeTokenType.PARAGRAPH),n}_getNonRenderableCursorTokens(){return[...this._getCursorSkipTokens(),t.DataStreamTreeTokenType.COLUMN_GROUP_START,t.DataStreamTreeTokenType.COLUMN_GROUP_END,t.DataStreamTreeTokenType.COLUMN_START,t.DataStreamTreeTokenType.COLUMN_END]}_getTopOrBottomPosition(e,t,n,r,i=!1){if(t==null||n==null)return;let a=this._getGlyphLeftOffsetInLine(t),o=this._getNextOrPrevLineTarget(t,r,a,i);if(o==null)return;let s=this._matchPositionByLeftOffset(e,o.line,o.offsetLeft,n);if(s!=null)return{...s,isBack:!0}}_getGlyphLeftOffsetInLine(e){let t=e.parent;if(t==null)return-1/0;let n=t.left,{left:r}=e;return n+r}_matchPositionByLeftOffset(e,n,r,i){let a={distance:1/0},o={distance:1/0};for(let e of n.divides){let n=e.left;for(let i of e.glyphGroup){if(!this._isCursorAddressableGlyph(i)){if(i.streamType===t.DataStreamTreeTokenType.PARAGRAPH&&i.count>0){let{left:e}=i,t=n+e,a=Math.abs(r-t);a<o.distance&&(o.glyph=i,o.distance=a)}continue}let{left:e}=i,s=n+e,c=Math.abs(r-s);c<a.distance&&(a.glyph=i,a.distance=c)}}let s=a.glyph??o.glyph;if(s==null)return;let{segmentPage:c}=i;return e.findPositionByGlyph(s,c)}_getNextOrPrevLineTarget(e,t,n,r=!1){let i=e.parent,a=i==null?void 0:i.parent,o=a==null?void 0:a.parent,s=o==null?void 0:o.parent,c=s==null?void 0:s.parent;if(i==null||a==null||o==null||s==null||c==null)return;let l=o.lines.indexOf(a);if(l===-1)return;let u;if(this._isTableCellContentPage(c)&&r){let e=this._getAdjacentTableCellLineTarget(c,t,n);if(e!=null)return e}if(t===!0){u=o.lines[l+1];let e=this._getTableLineTargetFromPageLine(a,c,t,n);if(e!=null)return e}else{u=o.lines[l-1];let e=this._getTableLineTargetFromPageLine(a,c,t,n);if(e!=null)return e}let d=this._getColumnGroupLineTargetFromBlockLine(u,c,t,n);if(d!=null)return d;if(u!=null)return{line:u,offsetLeft:n};let f=s.columns.indexOf(o);if(f===-1)return;if(t===!0){var p;u=(p=s.columns[f+1])==null?void 0:p.lines[0]}else{var m;let e=(m=s.columns)==null||(m=m[f-1])==null?void 0:m.lines;u=e==null?void 0:e[e.length-1]}if(u!=null)return{line:u,offsetLeft:n};let h=c.sections.indexOf(s);if(h===-1)return;if(t===!0){var g;u=(g=c.sections[h-1])==null||(g=g.columns[0])==null?void 0:g.lines[0]}else{var _;let e=(_=c.sections)==null||(_=_[h-1])==null?void 0:_.columns,t=e==null?void 0:e[e.length-1],n=t==null?void 0:t.lines;u=n==null?void 0:n[n.length-1]}if(u!=null)return{line:u,offsetLeft:n};if(this._isColumnGroupContentPage(c))return this._getColumnGroupExitLineTarget(c,t,n);if(this._isTableCellContentPage(c))return this._getAdjacentTableCellLineTarget(c,t,n);let v=c.parent;if((v==null?void 0:v.pages)==null)return;let y=v.pages.indexOf(c);if(y!==-1){if(t===!0){var b;u=(b=v.pages[y+1])==null||(b=b.sections[0])==null||(b=b.columns[0])==null?void 0:b.lines[0]}else{var x,S;let e=(x=v.pages[y-1])==null?void 0:x.sections;if(e==null)return;let t=(S=e[e.length-1])==null?void 0:S.columns,n=t[t.length-1],r=n==null?void 0:n.lines;u=r[r.length-1]}if(u!=null)return{line:u,offsetLeft:n}}}_getTableLineTargetFromPageLine(e,t,n,r){let i=n?Vg(e,t):Hg(e,t);if(i!=null)return this._getTableBoundaryLineTarget(i,n,r)}_getTableBoundaryLineTarget(e,t,n){let r=t?e.rows:[...e.rows].reverse();for(let e of r){if(e.isRepeatRow)continue;let r=this._getNearestTableCellLineTarget(e.cells,t,n);if(r!=null)return r}}_getAdjacentTableCellLineTarget(e,t,n){let r=e.parent,i=r==null?void 0:r.parent;if(r==null||i==null)return;let a=this._getTableCellHostOffsetLeft(e)+n,o=this._findAdjacentTableRow(i,r,t);if(o!=null)return this._getNearestTableCellLineTarget(o.cells,t,a);let s=this._findLineAroundTable(i,t);if(s!=null)return{line:s,offsetLeft:a}}_findAdjacentTableRow(e,t,n){let r=e.rows.indexOf(t);if(r===-1)return;let i=n?1:-1,a=r+i;for(;a>=0&&a<e.rows.length;){let t=e.rows[a];if(!t.isRepeatRow)return t;a+=i}return this._findAdjacentTableSliceRow(e,n)}_findAdjacentTableSliceRow(e,t){if(!e.tableId.includes(`#-#`))return;let[n,r]=e.tableId.split(`#-#`),i=Number.parseInt(r),a=e.parent,o=a==null?void 0:a.parent;if(!Number.isFinite(i)||(o==null?void 0:o.pages)==null)return;let s=`${n}#-#${i+(t?1:-1)}`;for(let e of o.pages){var c;let n=(c=e.skeTables)==null?void 0:c.get(s),r=(n==null?[]:t?n.rows:[...n.rows].reverse()).find(e=>!e.isRepeatRow);if(r!=null)return r}}_getNearestTableCellLineTarget(e,t,n){let r=e.filter(e=>!e.isMergedCellCovered).map(e=>({cell:e,distance:this._getDistanceToTableCell(e,n)})).sort((e,t)=>e.distance-t.distance);for(let e of r){let r=t?Ug(e.cell):Wg(e.cell);if(r!=null)return{line:r,offsetLeft:n-this._getTableCellHostOffsetLeft(e.cell)}}}_findLineAroundTable(e,t){var n;let r=e.parent;if(r==null)return;let i=((n=r.parent)==null?void 0:n.pages)??[r],a=t?t=>t.st===e.ed+1:t=>t.ed===e.st-1;for(let e of i)for(let n of e.sections)for(let e of n.columns){let n=(t?e.lines:[...e.lines].reverse()).find(a);if(n!=null)return n}}_getDistanceToTableCell(e,t){let n=this._getTableCellHostOffsetLeft(e),r=n+this._getTableCellContentWidth(e);return t>=n&&t<=r?0:Math.min(Math.abs(t-n),Math.abs(t-r))}_getTableCellHostOffsetLeft(e){let t=e.parent,n=t==null?void 0:t.parent;return((n==null?void 0:n.left)??0)+(e.left??0)+(e.marginLeft??0)}_getTableCellContentWidth(e){return Math.max(0,(e.pageWidth??0)-(e.marginLeft??0)-(e.marginRight??0))}_isTableCellContentPage(e){var t;let n=e.parent,i=n==null?void 0:n.parent;return e.type===r.DocumentSkeletonPageType.CELL&&n!=null&&(i==null||(t=i.rows)==null?void 0:t.includes(n))===!0&&n.cells.includes(e)}_getColumnGroupLineTargetFromBlockLine(e,t,n,i){if(e==null||e.type!==r.LineType.BLOCK)return;let a=this._findColumnGroupByBlockLine(t,e);if(a!=null)return this._getColumnGroupContentLineTarget(a,n,i)}_getColumnGroupContentLineTarget(e,t,n){let r=e.columns.map(e=>({column:e,distance:this._getDistanceToColumnGroupColumn(e,n)})).sort((e,t)=>e.distance-t.distance);for(let e of r){let r=this._getColumnGroupColumnBoundaryLine(e.column,t);if(r!=null)return{line:r,offsetLeft:n-e.column.left}}}_getColumnGroupExitLineTarget(e,t,n){let r=e.parent,i=r==null?void 0:r.parent,a=i==null?void 0:i.parent;if(r==null||i==null||a==null)return;let o=this._findColumnGroupBlockLine(i),s=o==null?void 0:this._getAdjacentLineAroundBlockLine(o,t);if(s!=null)return{line:s,offsetLeft:r.left+n}}_findColumnGroupByBlockLine(e,t){var n;for(let r of((n=e.skeColumnGroups)==null?void 0:n.values())??[])if(t.paragraphIndex===r.ed||t.st<=r.ed&&t.ed>=r.st)return r}_findColumnGroupBlockLine(e){let t=e.parent;if(t!=null){for(let n of t.sections)for(let i of n.columns)for(let n of i.lines)if(n.type===r.LineType.BLOCK&&this._findColumnGroupByBlockLine(t,n)===e)return n}}_getAdjacentLineAroundBlockLine(e,t){var n;let r=e.parent,i=r==null?void 0:r.parent,a=i==null?void 0:i.parent;if(r==null||i==null||a==null)return;let o=r.lines.indexOf(e);if(o===-1)return;let s=r.lines[t?o+1:o-1];if(s!=null)return s;let c=i.columns.indexOf(r);if(c===-1)return;if(t){var l;return(l=i.columns[c+1])==null?void 0:l.lines[0]}let u=(n=i.columns[c-1])==null?void 0:n.lines;return u==null?void 0:u[u.length-1]}_getColumnGroupColumnBoundaryLine(e,t){let n=t?e.page.sections:[...e.page.sections].reverse();for(let e of n){let n=t?e.columns:[...e.columns].reverse();for(let e of n){let n=(t?e.lines:[...e.lines].reverse()).find(e=>e.type!==r.LineType.BLOCK);if(n!=null)return n}}}_getDistanceToColumnGroupColumn(e,t){return t>=e.left&&t<=e.left+e.width?0:Math.min(Math.abs(t-e.left),Math.abs(t-e.left-e.width))}_isColumnGroupContentPage(e){var t;let n=e.parent;return(n==null?void 0:n.page)===e&&((t=n.parent)==null||(t=t.columns)==null?void 0:t.includes(n))===!0}_scrollToFocusNodePosition(e,t){var n;let r=(n=this._renderManagerService.getRenderUnitById(e))==null?void 0:n.with(ds);r!=null&&r.scrollToRange({startOffset:t,endOffset:t,collapsed:!0})}};Gg=B([z(0,t.IUniverInstanceService),z(1,r.IRenderManagerService),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,t.ICommandService)],Gg);let Kg=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){this._init(),this._registerCommands()}_registerCommands(){[ns].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_init(){}};Kg=B([z(0,t.ICommandService)],Kg);let qg=`DOC_LAYOUT_RECOVERY_COMPONENT`;function Jg(){let e=(0,a.useDependency)(t.LocaleService);return(0,u.jsxs)(`div`,{"aria-live":`polite`,className:`univer-flex univer-items-center univer-gap-2 univer-rounded-lg univer-bg-white univer-px-4 univer-py-3 univer-text-sm univer-text-gray-700 univer-shadow-lg dark:univer-bg-gray-800 dark:univer-text-gray-200`,role:`status`,children:[(0,u.jsx)(rh,{"aria-hidden":!0,className:`univer-size-5 univer-animate-spin univer-text-violet-500`}),(0,u.jsx)(`span`,{children:e.t(`docs-ui.layout.recovering`)})]})}let Yg=`docs-ui.paste-options`;function Xg(){let e=(0,a.useDependency)(ea),n=(0,a.useDependency)(t.ICommandService),r=(0,a.useDependency)(t.LocaleService),o=(0,a.useDependency)(a.ILayoutService),s=(0,a.useObservable)(e.pasteOptions$,null),[c,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(!1),m=async e=>{d(!0);try{await n.executeCommand(fa.id,{value:e})}finally{d(!1),o.focus()}};return s?(0,u.jsx)(i.DropdownMenu,{align:`start`,open:f,onOpenChange:p,onCloseAutoFocus:e=>{e.preventDefault(),o.focus()},onEscapeKeyDown:()=>e.dismissPasteOptions(),items:gi.map(e=>({type:`checkbox`,value:e.value,label:r.t(e.label),checked:s.mode===e.value,disabled:c,onSelect:()=>m(e.value)})),children:(0,u.jsxs)(i.Button,{size:`small`,disabled:c,"aria-label":r.t(`docs-ui.pasteOptions.title`),title:r.t(`docs-ui.pasteOptions.title`),onMouseDown:e=>e.preventDefault(),onKeyDown:t=>{t.key===`Escape`&&(e.dismissPasteOptions(),o.focus())},className:`univer-shadow-sm`,children:[(0,u.jsx)(kp,{className:`!univer-size-5`,"aria-hidden":`true`}),(0,u.jsx)(`svg`,{className:`!univer-size-2`,width:`8`,height:`8`,viewBox:`0 0 8 8`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`m1 2 3 4 3-4Z`,fill:`currentColor`})})]})}):null}function Zg({className:e,style:t,onClick:n,color:r}){return(0,u.jsx)(`svg`,{className:e,style:t,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,onClick:n,children:(0,u.jsx)(`rect`,{x:3,y:3,width:18,height:18,rx:3,fill:r,stroke:`currentColor`,strokeOpacity:.12})})}function Qg({className:e,style:t,onClick:n,extend:r}){let i=(r==null?void 0:r.colorChannel1)??`currentColor`;return(0,u.jsx)(Nh,{className:e,style:t,onClick:n,extend:{colorChannel1:i},"aria-hidden":`true`})}function $g({className:e,style:t,onClick:n}){return(0,u.jsx)(Nh,{className:e,style:t,onClick:n,extend:{colorChannel1:`#000000`},"aria-hidden":`true`})}function e_(e){return function(t){return(0,u.jsx)(Nh,{...t,extend:{colorChannel1:e},"aria-hidden":`true`})}}function t_(e){return function(n){let r=(0,a.useDependency)(t.ThemeService),i=(0,a.useObservable)(()=>r.currentTheme$.pipe((0,s.map)(()=>Cd(r,e))),Cd(r,e),!1,[e,r]);return(0,u.jsx)(Zg,{...n,color:i})}}let n_=e_(`#FE4B4B`),r_=e_(`#FF8C51`),i_=e_(`#A4DC16`),a_=e_(`#2DAEFF`),o_=e_(`#3A60F7`),s_=e_(`#9E6DE3`),c_=e_(`#F248A6`),l_=t_(0),u_=t_(1),d_=t_(2),f_=t_(3),p_=t_(4),m_=t_(5),h_=t_(6),g_=t_(7),__=t_(8),v_=t_(9),y_=t_(10),b_=t_(11),x_=t_(12),S_=t_(13),C_=t_(14),w_=t_(15),T_=`docs-ui.mobile-element-menu`,E_=[{key:`edit`,order:0,item:{id:`edit`,type:a.MenuItemType.BUTTON,title:`docs-ui.mobile.edit`}},{key:`delete`,order:1,item:{id:`delete`,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.delete`}}];function D_(e){return(0,u.jsx)(a.MobileMenu,{schemas:E_,presentation:`context-bar`,onOptionSelect:async({id:t})=>{t===`edit`?await e.onEdit():t===`delete`&&await e.onDelete()}})}function O_({popup:e}){return(0,u.jsx)(D_,{...e.extraProps})}function k_({popup:e}){var n;let{unitId:o}=e.extraProps,s=(0,a.useDependency)(ea),c=(0,a.useDependency)(t.ICommandService),d=(0,a.useDependency)(t.LocaleService),f=(n=(0,a.useDependency)(r.IRenderManagerService).getRenderUnitById(o))==null?void 0:n.with(q),p=(0,a.useObservable)(s.pasteOptions$,null),m=(0,a.useObservable)(f==null?void 0:f.mobileKeyboardState$,{visible:!1,inset:0});(0,a.useObservable)(d.currentLocale$);let[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(`compact`),x=async e=>{v(!0);try{await c.executeCommand(fa.id,{value:e}),g(!1)}finally{v(!1)}};return!p||p.unitId!==o?null:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(i.Button,{"aria-label":d.t(`docs-ui.pasteOptions.title`),className:`univer-min-h-11 univer-min-w-11 univer-shadow-sm [&_svg]:!univer-size-6`,style:m.visible?{position:`fixed`,bottom:m.inset+56,insetInlineEnd:12}:void 0,onClick:()=>{f==null||f.suspendMobileEditingInput(),g(!0)},children:(0,u.jsx)(kp,{"aria-hidden":`true`})}),h&&(0,u.jsx)(`div`,{className:`univer-pointer-events-none univer-fixed univer-inset-x-0 univer-top-0`,style:{bottom:m.inset},children:(0,u.jsx)(a.MobileDrawer,{componentName:`mobile-doc-paste-options`,panelClassName:`univer-max-h-full`,snap:y,onSnapChange:b,onClose:()=>g(!1),expandLabel:d.t(`docs-ui.mobile.expand`),collapseLabel:d.t(`docs-ui.mobile.collapse`),ariaLabel:d.t(`docs-ui.pasteOptions.title`),header:(0,u.jsxs)(`div`,{className:`univer-flex univer-w-full univer-items-center univer-justify-between univer-gap-2 univer-px-4`,children:[(0,u.jsx)(`span`,{children:d.t(`docs-ui.pasteOptions.title`)}),(0,u.jsx)(i.Button,{variant:`text`,className:`univer-min-h-11`,onClick:()=>g(!1),children:d.t(`docs-ui.mobile.done`)})]}),children:(0,u.jsx)(`div`,{role:`menu`,"aria-label":d.t(`docs-ui.pasteOptions.title`),className:`univer-flex univer-flex-col univer-gap-1 univer-p-3`,children:gi.map(e=>(0,u.jsxs)(i.Button,{role:`menuitemradio`,"aria-checked":p.mode===e.value,disabled:_,variant:`text`,className:`!univer-h-auto univer-min-h-11 univer-justify-start univer-whitespace-normal univer-py-3 univer-text-start`,onClick:()=>x(e.value),children:[(0,u.jsx)(`span`,{className:`univer-inline-flex univer-size-5 univer-shrink-0 univer-items-center`,children:p.mode===e.value&&(0,u.jsx)(yp,{})}),d.t(e.label)]},e.value))})})})]})}function A_(e,n,i,a){let{useFirstPageHeaderFooter:o,evenAndOddHeaders:s,defaultHeaderId:c,defaultFooterId:l,firstPageHeaderId:u,firstPageFooterId:d,evenPageHeaderId:f,evenPageFooterId:p}=e,m=a?a.pageNumber===a.pageNumberStart:i===0,h=a?a.pageNumber%2==0:i%2==1;return n===r.DocumentEditArea.HEADER?o===t.BooleanNumber.TRUE&&m?u:s===t.BooleanNumber.TRUE&&h?f:c:o===t.BooleanNumber.TRUE&&m?d:s===t.BooleanNumber.TRUE&&h?p:l}function j_(e){var i,o;let s=(0,a.useDependency)(t.IUniverInstanceService),c=(0,a.useDependency)(r.IRenderManagerService),u=(0,a.useDependency)(t.ICommandService),d=(0,a.useDependency)(a.ILayoutService),f=c.getRenderUnitById(e).with(q),p=s.getUnit(e,t.UniverInstanceType.UNIVER_DOC),m=()=>{var t,r;let i=p==null?void 0:p.getSnapshot(),a=(t=c.getRenderUnitById(e))==null?void 0:t.with(n.DocSkeletonManagerService),o=a==null||(r=a.getSkeleton)==null||(r=r.call(a))==null||(r=r.getSkeletonData())==null?void 0:r.pages[f.getSegmentPage()];return i==null?void 0:{...Ec(i,o),page:o}},[h,g]=(0,l.useState)(()=>{var e;let n=(e=m())==null?void 0:e.config;return{marginHeader:(n==null?void 0:n.marginHeader)??0,marginFooter:(n==null?void 0:n.marginFooter)??0,useFirstPageHeaderFooter:(n==null?void 0:n.useFirstPageHeaderFooter)??t.BooleanNumber.FALSE,evenAndOddHeaders:(n==null?void 0:n.evenAndOddHeaders)??t.BooleanNumber.FALSE}}),_=m(),v=((i=c.getRenderUnitById(e))==null||(i=i.with(n.DocSkeletonManagerService))==null||(i=i.getViewModel())==null?void 0:i.getEditArea())===r.DocumentEditArea.FOOTER?`footer`:`header`,y=M_((_==null?void 0:_.config)??{},f.getSegmentPage(),_==null?void 0:_.page),b=(0,t.getSectionHeaderFooterReferenceKey)(v,y),x=((_==null?void 0:_.sectionIndex)??-1)>0,[S,C]=(0,l.useState)(x&&!(_!=null&&(o=_.section)!=null&&o[b]));return{canLinkToPrevious:x,linkedToPrevious:S,options:h,handleLinkToPreviousChange:async i=>{var a;let o=m();if(!(o!=null&&o.sectionId)||o.sectionIndex<=0||!p)return;let s=((a=c.getRenderUnitById(e))==null||(a=a.with(n.DocSkeletonManagerService))==null||(a=a.getViewModel())==null?void 0:a.getEditArea())===r.DocumentEditArea.FOOTER?`footer`:`header`,l=M_(o.config,f.getSegmentPage(),o.page),h=(0,t.getSectionHeaderFooterReferenceKey)(s,l),g=(0,t.generateRandomId)(6),_=(0,t.resolveSectionHeaderFooterReference)(p.getDocumentStyle(),o.sections,o.sectionIndex-1,h).segmentId;await u.executeCommand(n.SetSectionHeaderFooterLinkCommand.id,{unitId:e,sectionId:o.sectionId,kind:s,variant:l,linkedToPrevious:i,...i?{}:{segmentId:g}})&&(C(i),f.setSegment(i?_??``:g),d.focus())},handleCheckboxChange:(i,a)=>{var o;g(e=>({...e,[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE}));let s=m(),l=s==null?void 0:s.config,p=(o=c.getRenderUnitById(e))==null?void 0:o.with(n.DocSkeletonManagerService),h=p==null?void 0:p.getViewModel();if(l==null||h==null)return;let _=h.getEditArea(),v=!1,y=f.getSegmentPage(),b=s!=null&&s.page?s.page.pageNumber===s.page.pageNumberStart:y===0,x=s!=null&&s.page?s.page.pageNumber%2==0:y%2==1,S=!1;if(a===`useFirstPageHeaderFooter`&&i===!0&&((_===r.DocumentEditArea.HEADER&&!l.firstPageHeaderId||_===r.DocumentEditArea.FOOTER&&!l.firstPageFooterId)&&(v=!0),v&&b&&(S=!0)),a===`evenAndOddHeaders`&&i===!0&&((_===r.DocumentEditArea.HEADER&&!l.evenPageHeaderId||_===r.DocumentEditArea.FOOTER&&!l.evenPageFooterId)&&(v=!0),v&&x&&(S=!0)),v){let n=(0,t.generateRandomId)(6);S&&f.setSegment(n),u.executeCommand(Ac,{unitId:e,segmentId:n,headerFooterProps:{[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},sectionId:s==null?void 0:s.sectionId})}else{let n=f.getSegmentPage(),r=f.getSegment(),o=A_({...l,[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},_,n,s==null?void 0:s.page);o&&o!==r&&f.setSegment(o),u.executeCommand(Ac,{unitId:e,headerFooterProps:{[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},sectionId:s==null?void 0:s.sectionId})}d.focus()},handleMarginChange:async(t,n)=>{var r;g(e=>({...e,[n]:t})),await u.executeCommand(Ac,{unitId:e,headerFooterProps:{[n]:t},sectionId:(r=m())==null?void 0:r.sectionId}),f.removeAllRanges(),f.blur()},closeHeaderFooter:()=>{u.executeCommand(Nc.id,{unitId:e})}}}function M_(e,n,r){let i=r?r.pageNumber===r.pageNumberStart:n===0,a=r?r.pageNumber%2==0:n%2==1;return e.useFirstPageHeaderFooter===t.BooleanNumber.TRUE&&i?`first`:e.evenAndOddHeaders===t.BooleanNumber.TRUE&&a?`even`:`default`}let N_=e=>{let t=(0,a.useDependency)(r.IRenderManagerService).getRenderUnitById(e.unitId).with(q),n=(0,a.useObservable)(t.segmentContext$,{segmentId:t.getSegment(),segmentPage:t.getSegmentPage()}),i=e.ContentComponent??P_;return(0,u.jsx)(i,{...e},`${(n==null?void 0:n.segmentId)??``}:${(n==null?void 0:n.segmentPage)??-1}`)};function P_({unitId:e}){let n=(0,a.useDependency)(t.LocaleService),{canLinkToPrevious:r,linkedToPrevious:o,options:s,handleLinkToPreviousChange:c,handleCheckboxChange:l,handleMarginChange:d,closeHeaderFooter:f}=j_(e);return(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-4`,children:[r&&(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:o,onChange:e=>{c(!!e)},children:n.t(`docs-ui.headerFooter.linkToPrevious`)})}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-2`,children:[(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:s.useFirstPageHeaderFooter===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`useFirstPageHeaderFooter`)},children:n.t(`docs-ui.headerFooter.firstPageCheckBox`)})}),(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:s.evenAndOddHeaders===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`evenAndOddHeaders`)},children:n.t(`docs-ui.headerFooter.oddEvenCheckBox`)})})]}),(0,u.jsxs)(`div`,{className:`univer-mb-1 univer-flex`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.headerTopMargin`)}),(0,u.jsx)(i.InputNumber,{className:`univer-mt-1.5 univer-w-4/5`,min:0,max:200,precision:1,value:s.marginHeader,onChange:e=>{d(e??0,`marginHeader`)}})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.footerBottomMargin`)}),(0,u.jsx)(i.InputNumber,{className:`univer-mt-1.5 univer-w-4/5`,min:0,max:200,precision:1,value:s.marginFooter,onChange:e=>{d(e??0,`marginFooter`)}})]})]}),(0,u.jsx)(`div`,{className:`univer-flex univer-justify-end`,children:(0,u.jsx)(i.Button,{onClick:f,children:n.t(`docs-ui.headerFooter.closeHeaderFooter`)})})]})}let F_=e=>{var i;let o=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(r.IRenderManagerService),l=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC).getUnitId(),d=((i=c.getRenderUnitById(l))==null?void 0:i.with(n.DocSkeletonManagerService)).getViewModel(),f=(0,a.useObservable)(()=>d.editAreaChange$.pipe((0,s.filter)(e=>e!=null),(0,s.map)(e=>e!==r.DocumentEditArea.BODY)),d.getEditArea()!==r.DocumentEditArea.BODY,!1,[d]);return(0,u.jsx)(`div`,{className:`univer-text-sm`,children:f?(0,u.jsx)(N_,{...e,unitId:l}):(0,u.jsx)(`div`,{className:`univer-text-gray-400`,children:o.t(`docs-ui.headerFooter.disableText`)})})},I_={min:1,max:5,step:.1},L_={min:1,max:100};function R_(e,t){let n=10**t;return Math.round(e*n)/n}function z_(e,t,n){return Math.min(n,Math.max(t,e))}let B_=[{label:`docs-ui.doc.paragraphSetting.multiSpace`,value:`${t.SpacingRule.AUTO}`},{label:`docs-ui.doc.paragraphSetting.atLeast`,value:`${t.SpacingRule.AT_LEAST}`},{label:`docs-ui.doc.paragraphSetting.exactly`,value:`${t.SpacingRule.EXACT}`}];function V_(e){return e===t.SpacingRule.AUTO?I_:L_}function H_(e,n){return n===t.SpacingRule.AUTO?e:R_(e,2)}function U_(e,n){return n===t.SpacingRule.AUTO?e:R_(e,4)}function W_(e){if(!e)return null;let t=Math.max(0,...(e.divides??[]).flatMap(e=>(e.glyphGroup??[]).map(e=>{var t,n;return(((t=e.bBox)==null?void 0:t.ba)??0)+(((n=e.bBox)==null?void 0:n.bd)??0)})))||e.contentHeight||0;return t?{glyphLineHeight:t,renderedLineHeight:(e.paddingTop??0)+(e.contentHeight??t)+(e.paddingBottom??0)||t}:null}function G_(e,n,r,i){return n===r?e:r===t.SpacingRule.AUTO?i!=null&&i.glyphLineHeight&&i.renderedLineHeight?R_(z_(i.renderedLineHeight/i.glyphLineHeight,I_.min,I_.max),2):t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING:i!=null&&i.renderedLineHeight?R_(i.renderedLineHeight,4):R_(t.DEFAULT_STYLES.fs*e,4)}let K_=new Set([t.DocumentBlockRangeType.CALLOUT,t.DocumentBlockRangeType.CODE,t.DocumentBlockRangeType.QUOTE]);function q_(e,n,r){return e.map(e=>{var i;let a=((i=n.blockRanges)==null?void 0:i.some(t=>K_.has(t.blockType)&&e.startIndex>t.startIndex&&e.startIndex<t.endIndex))??!1;return{...e,paragraphStyle:(0,t.resolveDocumentParagraphStyle)(r,e.paragraphStyle,{excludeDocumentOuterSpacing:a})}})}let J_=()=>{let e=(0,a.useDependency)(n.DocSelectionManagerService),t=(0,a.useDependency)(ul),r=(0,l.useMemo)(()=>e.getDocRanges(),[]);return(0,l.useEffect)(()=>{r.length||t.closePanel()},[r]),r},Y_=()=>{let e=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),n=J_();if(!e||n.length===0)return[];let r=n[0].segmentId,i=e.getSelfOrHeaderFooterModel(r),o=i==null?void 0:i.getBody(),s=(o==null?void 0:o.paragraphs)??[],c=(o==null?void 0:o.dataStream)??``,l=t.BuildTextUtils.range.getParagraphsInRanges(n,s,c)??[];return o==null?l:q_(l,o,e.getDocumentStyle())},X_=(e,n)=>{let r=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let r=e[0];return r?String(((t=r.paragraphStyle)==null?void 0:t.horizontalAlign)??n):n});return[i,e=>(o(e),r.executeCommand(Mg.id,{paragraph:{horizontalAlign:Number(e)}}))]},Z_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentStart,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentStart:{v:e}}}))]},Q_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentEnd,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentEnd:{v:e}}}))]},$_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentFirstLine,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentFirstLine:{v:e}}}))]},ev=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.hanging,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{hanging:{v:e}}}))]},tv=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var n;let i=e[0];return i?(0,r.getNumberUnitValue)((n=i.paragraphStyle)==null?void 0:n.spaceAbove,t.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{spaceAbove:{v:e}}}))]},nv=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var n;let i=e[0];return i?(0,r.getNumberUnitValue)((n=i.paragraphStyle)==null?void 0:n.spaceBelow,t.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{spaceBelow:{v:e}}}))]},rv=e=>{let i=(0,a.useDependency)(t.ICommandService),o=(0,a.useDependency)(r.IRenderManagerService),u=(0,a.useDependency)(t.IUniverInstanceService),d=(0,l.useMemo)(()=>{var e;let r=u.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(r)return(e=o.getRenderUnitById(r==null?void 0:r.getUnitId()))==null?void 0:e.with(n.DocSkeletonManagerService).getSkeleton()},[]),f=(0,l.useMemo)(()=>new s.BehaviorSubject({}),[]),[p,m]=(0,l.useState)(()=>{var n;let r=e[0];return r?((n=r.paragraphStyle)==null?void 0:n.spacingRule)??t.SpacingRule.AUTO:t.SpacingRule.AUTO}),[h,g]=(0,l.useState)(()=>{var n,r;let i=e[0];if(!i)return t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;let a=((n=i.paragraphStyle)==null?void 0:n.spacingRule)??t.SpacingRule.AUTO;return H_(((r=i.paragraphStyle)==null?void 0:r.lineSpacing)??t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,a)});return(0,l.useEffect)(()=>{let e=f.pipe((0,c.filter)(e=>!!Object.keys(e).length),(0,c.bufferTime)(16),(0,c.filter)(e=>!!e.length),(0,c.map)(e=>e.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]=t[n]}),e),{}))).subscribe(e=>i.executeCommand(Mg.id,{paragraph:{...e}}));return()=>e.unsubscribe()},[]),{lineSpacing:[h,async e=>{g(e),f.next({lineSpacing:U_(e,p),spacingRule:p})}],spacingRule:[p,async t=>{if(t!==p){let n=d==null?void 0:d.findNodeByCharIndex(e[0].startIndex),r=n==null?void 0:n.parent,i=W_(r==null?void 0:r.parent),a=G_(U_(h,p),p,t,i),o=H_(a,t);g(o),m(t),f.next({spacingRule:t,lineSpacing:a})}}]}},iv=[{label:`docs-ui.toolbar.alignLeft`,value:String(t.HorizontalAlign.LEFT),icon:(0,u.jsx)(tm,{})},{label:`docs-ui.toolbar.alignCenter`,value:String(t.HorizontalAlign.CENTER),icon:(0,u.jsx)(Yp,{})},{label:`docs-ui.toolbar.alignRight`,value:String(t.HorizontalAlign.RIGHT),icon:(0,u.jsx)(Cm,{})},{label:`docs-ui.toolbar.alignJustify`,value:String(t.HorizontalAlign.JUSTIFIED),icon:(0,u.jsx)(pp,{})}],av=e=>{let{title:t,children:n,first:r=!1}=e;return(0,u.jsxs)(`section`,{className:(0,i.clsx)(!r&&`univer-mt-5`),children:[(0,u.jsx)(`div`,{className:`univer-text-sm univer-font-medium univer-leading-5`,children:t}),(0,u.jsx)(`div`,{className:`univer-mt-3`,children:n})]})},ov=e=>{let{label:t,unit:n,children:r}=e;return(0,u.jsxs)(`div`,{className:`univer-grid univer-min-h-8 univer-items-center univer-gap-3`,style:{gridTemplateColumns:`minmax(0, 1fr) minmax(160px, 180px)`},children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100`,children:[t,n]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:r})]})},sv=e=>{let{value:t,onChange:n,className:r=``,min:a=0,max:o=100,step:s=.1,precision:c=1}=e,d=(0,l.useRef)(null);return(0,u.jsx)(i.InputNumber,{step:s,precision:c,ref:d,min:a,max:o,value:t,onChange:e=>{n(e??0).finally(()=>{setTimeout(()=>{var e;(e=d.current)==null||e.focus()},30)})},className:(0,i.clsx)(`univer-w-full`,r)})};function cv({label:e,selected:t,onClick:n,children:r}){return(0,u.jsx)(i.Tooltip,{title:e,placement:`bottom`,children:(0,u.jsx)(i.Button,{type:`button`,variant:`text`,"aria-label":e,className:(0,i.clsx)({"!univer-bg-gray-200 dark:!univer-bg-gray-700":t}),onClick:n,children:(0,u.jsx)(`span`,{className:`univer-flex univer-size-5 univer-items-center univer-justify-center univer-text-lg`,children:r})})})}function lv({RowComponent:e=ov,NumberComponent:n=sv,SelectComponent:r=i.Select,AlignmentButtonComponent:o=cv}){let s=(0,a.useDependency)(t.LocaleService),c=Y_(),[d,f]=X_(c,iv[0].value),[p,m]=Z_(c),[h,g]=Q_(c),[_,v]=$_(c),[y,b]=ev(c),[x,S]=tv(c),[C,w]=nv(c),{lineSpacing:[T,E],spacingRule:[D,O]}=rv(c),k=(0,l.useMemo)(()=>V_(D),[D]),A=B_.map(e=>({...e,label:s.t(e.label)}));return(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full`,children:[(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.alignment`),first:!0,children:(0,u.jsx)(`div`,{className:(0,i.clsx)(`univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2 univer-rounded-lg univer-bg-gray-0 univer-p-1 dark:!univer-bg-gray-900`,i.borderClassName),children:iv.map(e=>(0,u.jsx)(`span`,{className:`univer-flex univer-w-full univer-items-center univer-justify-center`,children:(0,u.jsx)(o,{label:s.t(e.label),selected:d===e.value,onClick:()=>f(e.value),children:e.icon})},e.value))})}),(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.indentation`),children:(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.left`),unit:`(px)`,children:(0,u.jsx)(n,{value:p,onChange:e=>m(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.right`),unit:`(px)`,children:(0,u.jsx)(n,{value:h,onChange:e=>g(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.firstLine`),unit:`(px)`,children:(0,u.jsx)(n,{value:_,onChange:e=>v(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.hanging`),unit:`(px)`,children:(0,u.jsx)(n,{value:y,onChange:e=>b(e??0)})})]})}),(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.spacing`),children:(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.before`),unit:`(px)`,children:(0,u.jsx)(n,{value:x,onChange:e=>S(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.after`),unit:`(px)`,children:(0,u.jsx)(n,{value:C,onChange:e=>w(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.lineSpace`),children:(0,u.jsxs)(`div`,{className:`univer-flex univer-w-full univer-flex-col univer-gap-2`,children:[(0,u.jsx)(r,{className:`univer-w-full`,value:`${D}`,options:A,onChange:e=>O(Number(e))}),(0,u.jsx)(n,{...k,value:T,onChange:e=>E(e??0)})]})})]})})]})}let uv=(e,t)=>t.length===e.length&&e.some(e=>t.some(t=>t.startOffset===e.startOffset&&t.endOffset===e.endOffset));function dv(e){let r=(0,a.useDependency)(t.ICommandService),i=(0,a.useDependency)(t.LocaleService),o=(0,a.useObservable)(i.currentLocale$),[s,c]=(0,l.useState)(``),u=(0,l.useMemo)(()=>(0,t.debounce)(()=>c((0,t.generateRandomId)(4)),300),[]),d=(0,l.useRef)([]);return(0,l.useEffect)(()=>{let e=r.onCommandExecuted(e=>{if(n.SetTextSelectionsOperation.id===e.id){let n=e.params.ranges;uv(n,d.current)||c((0,t.generateRandomId)(4)),d.current=n}n.RichTextEditingMutation.id===e.id&&e.params.trigger!==Mg.id&&u()});return()=>e.dispose()},[u]),(0,l.useEffect)(()=>{c((0,t.generateRandomId)(4))},[o]),(0,l.useEffect)(()=>()=>u.cancel(),[u]),(0,l.createElement)(lv,{...e,key:s})}function fv({unitId:e,id:r,objectType:s,segmentId:c=``}){let l=(0,a.useInjector)(),d=(0,a.useDependency)(t.IUniverInstanceService),f=(0,a.useDependency)(t.ObjectPermissionService),p=(0,a.useDependency)(t.LocaleService);if((0,a.useObservable)(f.changed$,0),(0,a.useObservable)(p.currentLocale$),!e||!r)return null;let m=s===o.UnitObject.DocumentParagraph,h={unitId:e,objectId:m?(0,n.getDocumentParagraphPermissionObjectId)(c,r):(0,n.getDocumentSectionPermissionObjectId)(c,r),objectType:s},g=()=>{var t,n,i;let a=(t=d.getUnit(e))==null||(t=t.getSelfOrHeaderFooterModel(c))==null?void 0:t.getBody();return m?(a==null||(n=a.paragraphs)==null?void 0:n.some(e=>e.paragraphId===r))===!0:(a==null||(i=a.sectionBreaks)==null?void 0:i.some(e=>e.sectionId===r))===!0};return!f.supports(h)||!g()?null:(0,u.jsxs)(`div`,{className:`univer-mt-5`,children:[(0,u.jsx)(i.Separator,{className:`univer-mb-3`}),(0,u.jsx)(i.Button,{disabled:!f.canView(h),type:`button`,variant:`text`,className:`univer-w-full univer-justify-start`,onClick:()=>(0,a.openObjectPermissionDialog)(l,{target:h,name:p.t(m?`docs-ui.objectPermission.paragraph`:`docs-ui.objectPermission.section`),commandId:n.SetDocumentPermissionCommand.id,exists:g}),children:p.t(`docs-ui.objectPermission.title`)})]})}function pv(e){let t=e[0];return e.every(e=>e===t)?t:void 0}function mv(e){var t;return((t=e.columnProperties)==null?void 0:t.length)||1}function hv(e){var t;return((t=e.columnProperties)==null||(t=t[0])==null?void 0:t.paddingEnd)??18}function gv(e,n){return{columnCount:pv(e.map(mv)),columnGap:pv(e.map(hv)),separatorType:pv(e.map(e=>e.columnSeparatorType??t.ColumnSeparatorType.NONE)),sectionType:pv(e.map(e=>e.sectionType??t.SectionType.SECTION_TYPE_UNSPECIFIED)),pageWidth:pv(e.map(e=>{var t,r;return((t=e.pageSize)==null?void 0:t.width)??((r=n.pageSize)==null?void 0:r.width)})),pageHeight:pv(e.map(e=>{var t,r;return((t=e.pageSize)==null?void 0:t.height)??((r=n.pageSize)==null?void 0:r.height)})),pageOrient:pv(e.map(e=>e.pageOrient??n.pageOrient)),marginTop:pv(e.map(e=>e.marginTop??n.marginTop??0)),marginBottom:pv(e.map(e=>e.marginBottom??n.marginBottom??0)),marginLeft:pv(e.map(e=>e.marginLeft??n.marginLeft??0)),marginRight:pv(e.map(e=>e.marginRight??n.marginRight??0)),pageNumberStart:pv(e.map(e=>e.pageNumberStart??n.pageNumberStart??1))}}function _v(e,t,r){return e.map(e=>{let i=`columnCount`in r?r.columnCount:mv(e),a=`columnGap`in r?r.columnGap:hv(e);return{sectionId:e.sectionId,config:{columnProperties:(0,n.createSectionColumnProperties)(t,e,i,a)}}})}function vv(e,n,r){return e.map(e=>{let i=e.pageOrient??n.pageOrient??t.PageOrientType.PORTRAIT,a=e.pageSize??n.pageSize;return{sectionId:e.sectionId,config:{pageOrient:r,...i!==r&&(a==null?void 0:a.width)!=null&&a.height!=null?{pageSize:{width:a.height,height:a.width}}:{}}}})}function yv(e,t){let r=e.getBody();if(!r||t.length===0||t.some(e=>!!e.segmentId))return[];let i=(0,n.getTopLevelSectionBreaks)(r);return i.filter((e,n)=>{let r=n===0?0:i[n-1].startIndex+1;return t.some(t=>{let n=Math.min(t.startOffset,t.endOffset),i=Math.max(t.startOffset,t.endOffset);return n<=e.startIndex&&i>=r})})}function bv(e,t,n,r){let i=n.findIndex(e=>e.sectionId===r);!t||i<0||e.navigateToSectionEnd(t.getUnitId(),i===0?0:n[i-1].startIndex+1,n[i].startIndex)}function xv(){let e=(0,a.useDependency)(t.ICommandService),r=(0,a.useDependency)(t.IUniverInstanceService),i=(0,a.useDependency)(n.DocSelectionManagerService),o=(0,a.useDependency)(pl),c=(0,a.useObservable)((0,l.useMemo)(()=>r.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[r])),u=()=>(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL?yv(c,i.getDocRanges()):[],d=(0,a.useObservable)(c?()=>(0,s.combineLatest)([i.textSelection$.pipe((0,s.startWith)(void 0)),c.change$.pipe((0,s.startWith)(void 0))]).pipe((0,s.map)(u)):null,u(),!1,[c,i]),f=(c==null?void 0:c.getDocumentStyle())??{},p=gv(d,f),m=c==null?void 0:c.getBody(),h=(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL&&m?(0,n.getTopLevelSectionBreaks)(m):[],g=t=>!c||t.length===0?Promise.resolve(!1):e.executeCommand(n.UpdateDocumentSectionCommand.id,{unitId:c.getUnitId(),updates:t}),_=e=>g(d.map(t=>({sectionId:t.sectionId,config:e})));return{unitId:c==null?void 0:c.getUnitId(),valid:!!(c&&d.length>0),selectedCount:d.length,sectionOptions:h.map((e,t)=>({label:`#${t+1}`,value:e.sectionId})),selectedSectionId:d.length===1?d[0].sectionId:void 0,...p,selectSection(e){bv(o,c??void 0,h,e)},setColumnCount(e){let t=Math.max(1,Math.round(e));return g(c?_v(d,c.getDocumentStyle(),{columnCount:t}):[])},setColumnGap(e){let t=Math.max(0,e);return g(c?_v(d,c.getDocumentStyle(),{columnGap:t}):[])},setSeparatorType(e){return _({columnSeparatorType:e})},setSectionType(e){return _({sectionType:e})},setPageWidth(e){return g(d.map(t=>({sectionId:t.sectionId,config:{pageSize:{...f.pageSize,...t.pageSize,width:Math.max(1,e)}}})))},setPageHeight(e){return g(d.map(t=>({sectionId:t.sectionId,config:{pageSize:{...f.pageSize,...t.pageSize,height:Math.max(1,e)}}})))},setPageOrient(e){return g(vv(d,f,e))},setMarginTop(e){return _({marginTop:Math.max(0,e)})},setMarginBottom(e){return _({marginBottom:Math.max(0,e)})},setMarginLeft(e){return _({marginLeft:Math.max(0,e)})},setMarginRight(e){return _({marginRight:Math.max(0,e)})},setPageNumberStart(e){return _({pageNumberStart:Math.max(1,Math.round(e))})}}}function Sv(e){return(0,u.jsxs)(`div`,{className:`univer-grid univer-min-h-8 univer-items-center univer-gap-3`,style:{gridTemplateColumns:`minmax(0, 1fr) minmax(140px, 160px)`},children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100`,children:[e.label,e.unit]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:e.children})]})}function Cv({RowComponent:e=Sv,InputNumberComponent:n=i.InputNumber,SelectComponent:r=i.Select}){let s=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(pl),d=xv();return(0,a.useObservable)(s.currentLocale$),(0,l.useEffect)(()=>{d.valid||c.closePanel()},[c,d.valid]),d.valid?(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full`,children:[d.selectedCount>1&&(0,u.jsx)(`div`,{className:`univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300`,children:s.t(`docs-ui.doc.sectionSetting.selectedSections`,`${d.selectedCount}`)}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.slider.sectionSetting`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.selectedSectionId??``,options:[...d.selectedSectionId==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],...d.sectionOptions],onChange:d.selectSection})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnCount`),children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.columnCount`),className:`univer-w-full`,min:1,max:12,step:1,precision:0,value:d.columnCount,onChange:e=>e!=null&&d.setColumnCount(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnGap`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.columnGap`),className:`univer-w-full`,min:0,max:1e3,step:1,precision:1,value:d.columnGap,onChange:e=>e!=null&&d.setColumnGap(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnSeparator`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.separatorType==null?``:`${d.separatorType}`,options:[...d.separatorType==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.doc.sectionSetting.none`),value:`${t.ColumnSeparatorType.NONE}`},{label:s.t(`docs-ui.doc.sectionSetting.betweenColumns`),value:`${t.ColumnSeparatorType.BETWEEN_EACH_COLUMN}`}],onChange:e=>d.setSeparatorType(Number(e))})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.sectionStart`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.sectionType==null?``:`${d.sectionType}`,options:[...d.sectionType==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.doc.sectionSetting.unspecified`),value:`${t.SectionType.SECTION_TYPE_UNSPECIFIED}`},{label:s.t(`docs-ui.doc.sectionSetting.continuous`),value:`${t.SectionType.CONTINUOUS}`},{label:s.t(`docs-ui.doc.sectionSetting.nextColumn`),value:`${t.SectionType.NEXT_COLUMN}`},{label:s.t(`docs-ui.doc.sectionSetting.nextPage`),value:`${t.SectionType.NEXT_PAGE}`},{label:s.t(`docs-ui.doc.sectionSetting.evenPage`),value:`${t.SectionType.EVEN_PAGE}`},{label:s.t(`docs-ui.doc.sectionSetting.oddPage`),value:`${t.SectionType.ODD_PAGE}`}],onChange:e=>d.setSectionType(Number(e))})}),(0,u.jsx)(`div`,{className:`univer-pt-2 univer-text-sm univer-font-medium`,children:s.t(`docs-ui.doc.sectionSetting.pageSetup`)}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageWidth`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageWidth`),className:`univer-w-full`,min:1,step:1,precision:1,value:d.pageWidth,onChange:e=>e!=null&&d.setPageWidth(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageHeight`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageHeight`),className:`univer-w-full`,min:1,step:1,precision:1,value:d.pageHeight,onChange:e=>e!=null&&d.setPageHeight(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.orientation`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.pageOrient==null?``:`${d.pageOrient}`,options:[...d.pageOrient==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.page-settings.portrait`),value:`${t.PageOrientType.PORTRAIT}`},{label:s.t(`docs-ui.page-settings.landscape`),value:`${t.PageOrientType.LANDSCAPE}`}],onChange:e=>d.setPageOrient(Number(e))})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.top`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.top`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginTop,onChange:e=>e!=null&&d.setMarginTop(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.bottom`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.bottom`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginBottom,onChange:e=>e!=null&&d.setMarginBottom(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.left`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.left`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginLeft,onChange:e=>e!=null&&d.setMarginLeft(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.right`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.right`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginRight,onChange:e=>e!=null&&d.setMarginRight(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageNumberStart`),children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageNumberStart`),className:`univer-w-full`,min:1,step:1,precision:0,value:d.pageNumberStart,onChange:e=>e!=null&&d.setPageNumberStart(e)})})]}),(0,u.jsx)(fv,{unitId:d.unitId,id:d.selectedSectionId,objectType:o.UnitObject.DocumentSection})]}):null}function wv(e){let r=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>(0,t.generateRandomId)(4));return(0,l.useEffect)(()=>{let e=r.onCommandExecuted(e=>{e.id===n.SetTextSelectionsOperation.id?e.params.ranges.length>0&&o((0,t.generateRandomId)(4)):e.id===n.RichTextEditingMutation.id&&o((0,t.generateRandomId)(4))});return()=>e.dispose()},[r]),(0,l.createElement)(Cv,{...e,key:i})}function Tv({label:e,unit:t,children:n}){return(0,u.jsxs)(`div`,{className:`univer-flex univer-min-h-12 univer-flex-col univer-gap-2`,children:[(0,u.jsxs)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-gray-100`,children:[e,t]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:n})]})}let Ev=(0,l.forwardRef)((e,t)=>(0,u.jsx)(i.InputNumber,{...e,ref:t,className:(0,i.clsx)(e.className,`univer-h-12 univer-w-full`),inputClassName:(0,i.clsx)(e.inputClassName,`univer-text-base`)}));function Dv(e){return(0,u.jsx)(i.MobileSelect,{...e,className:(0,i.clsx)(e.className,`univer-h-12 univer-w-full`)})}function Ov({min:e=0,max:t=100,step:n=.1,precision:r=1,onChange:i,...a}){return(0,u.jsx)(Ev,{...a,min:e,max:t,step:n,precision:r,onChange:e=>i(e??0)})}function kv({label:e,selected:t,onClick:n,children:r}){return(0,u.jsx)(i.Button,{type:`button`,variant:`text`,"aria-label":e,"aria-pressed":t,className:(0,i.clsx)(`univer-h-12 univer-w-full`,{"!univer-bg-gray-200 dark:!univer-bg-gray-700":t}),onClick:n,children:(0,u.jsx)(`span`,{className:`univer-flex univer-size-5 univer-items-center univer-justify-center univer-text-lg`,children:r})})}function Av(e){return(0,u.jsx)(Sl,{...e,InputNumberComponent:Ev,SelectComponent:Dv})}function jv(){return(0,u.jsx)(dv,{RowComponent:Tv,NumberComponent:Ov,SelectComponent:Dv,AlignmentButtonComponent:kv})}function Mv(){return(0,u.jsx)(wv,{RowComponent:Tv,InputNumberComponent:Ev,SelectComponent:Dv})}function Nv(){return(0,u.jsx)(F_,{ContentComponent:Pv})}function Pv({unitId:e}){let n=(0,a.useDependency)(t.LocaleService),{canLinkToPrevious:r,linkedToPrevious:o,options:s,handleLinkToPreviousChange:c,handleCheckboxChange:l,handleMarginChange:d,closeHeaderFooter:f}=j_(e);return(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-4`,children:[r&&(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:o,onChange:e=>{c(!!e)},children:n.t(`docs-ui.headerFooter.linkToPrevious`)})}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-2`,children:[(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:s.useFirstPageHeaderFooter===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`useFirstPageHeaderFooter`)},children:n.t(`docs-ui.headerFooter.firstPageCheckBox`)})}),(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:s.evenAndOddHeaders===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`evenAndOddHeaders`)},children:n.t(`docs-ui.headerFooter.oddEvenCheckBox`)})})]}),(0,u.jsxs)(`div`,{className:`univer-mb-1 univer-flex univer-flex-col univer-gap-3`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.headerTopMargin`)}),(0,u.jsx)(Ev,{className:`univer-h-12 univer-w-full`,min:0,max:200,precision:1,value:s.marginHeader,onChange:e=>{d(e??0,`marginHeader`)}})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.footerBottomMargin`)}),(0,u.jsx)(Ev,{className:`univer-h-12 univer-w-full`,min:0,max:200,precision:1,value:s.marginFooter,onChange:e=>{d(e??0,`marginFooter`)}})]})]}),(0,u.jsx)(`div`,{className:`univer-flex`,children:(0,u.jsx)(i.Button,{className:`univer-h-12 univer-w-full`,onClick:f,children:n.t(`docs-ui.headerFooter.closeHeaderFooter`)})})]})}let Fv=({handleRowColChange:e,tableCreateParams:n})=>{let r=(0,a.useDependency)(t.LocaleService),[o,s]=(0,l.useState)(3),[c,d]=(0,l.useState)(5);function f(t,n){s(t),d(n),e(t,n)}return(0,l.useEffect)(()=>{s(n.rowCount),d(n.colCount)},[n]),(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-between univer-gap-2`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:[(0,u.jsx)(`span`,{children:r.t(`docs-ui.toolbar.table.rowCount`)}),(0,u.jsx)(i.InputNumber,{className:`univer-w-28`,min:1,max:20,precision:0,value:o,onChange:e=>{f(e,c)}})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:[(0,u.jsx)(`span`,{children:r.t(`docs-ui.toolbar.table.colCount`)}),(0,u.jsx)(i.InputNumber,{className:`univer-w-28`,min:1,max:20,precision:0,value:c,onChange:e=>{f(o,e)}})]})]})},Iv=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerParts(),this._registerIcons()}_registerParts(){let e=this._componentManager;this.disposeWithMe(e.register(es,Fv)),this.disposeWithMe(e.register(Yg,k_))}_registerIcons(){this.disposeWithMe(this._iconManager.register({DocPasteOptionsIcon:kp,AlignTextBothIcon:pp,AddImageIcon:dp,BoldIcon:hp,CopyDoubleIcon:ah,ColumnIcon:Cp,CutIcon:Tp,DeleteColumnDoubleIcon:sh,DeleteIcon:Dp,DeleteRowDoubleIcon:lh,DeleteTableDoubleIcon:dh,DocSettingIcon:jp,FontColorDoubleIcon:ph,GridIcon:Fp,H1Icon:Lp,H2Icon:zp,H3Icon:Vp,H4Icon:Up,H5Icon:Gp,HeaderFooterIcon:qp,HorizontallyIcon:Yp,InsertDoubleIcon:hh,InsertRowAboveDoubleIcon:_h,InsertRowBelowDoubleIcon:yh,ItalicIcon:Zp,KeyboardIcon:$p,LeftInsertColumnDoubleIcon:xh,LeftJustifyingIcon:tm,LineIndentDecreaseIcon:rm,LineIndentIncreaseIcon:am,MenuIcon:sm,TextTypeIcon:Gm,NoColorDoubleIcon:Ch,OrderIcon:hm,PaintBucketDoubleIcon:Th,ParagraphSettingIcon:_m,PasteSpecialDoubleIcon:Dh,ReduceDoubleIcon:kh,ReduceIcon:xm,RightInsertColumnDoubleIcon:jh,RightJustifyingIcon:Cm,SectionSettingIcon:Tm,ShapeIcon:Dm,SmileIcon:km,StrikethroughIcon:Nm,SubscriptIcon:Fm,SuperscriptIcon:zm,SymbolsIcon:Vm,TitleTypeIcon:qm,SubtitleTypeIcon:Lm,TodoListDoubleIcon:Fh,UnderlineIcon:Ym,UnorderIcon:Zm,DefaultTextColorIcon:$g,HeaderTextColorIcon:Qg,MoreRightIcon:pm,MoreLeftIcon:dm,"DocParagraphTextColorSwatchIcon.0":n_,"DocParagraphTextColorSwatchIcon.1":r_,"DocParagraphTextColorSwatchIcon.2":i_,"DocParagraphTextColorSwatchIcon.3":a_,"DocParagraphTextColorSwatchIcon.4":o_,"DocParagraphTextColorSwatchIcon.5":s_,"DocParagraphTextColorSwatchIcon.6":c_,"DocParagraphBackgroundColorSwatchIcon.0":l_,"DocParagraphBackgroundColorSwatchIcon.1":u_,"DocParagraphBackgroundColorSwatchIcon.2":d_,"DocParagraphBackgroundColorSwatchIcon.3":f_,"DocParagraphBackgroundColorSwatchIcon.4":p_,"DocParagraphBackgroundColorSwatchIcon.5":m_,"DocParagraphBackgroundColorSwatchIcon.6":h_,"DocParagraphBackgroundColorSwatchIcon.7":g_,"DocParagraphBackgroundColorSwatchIcon.8":__,"DocParagraphBackgroundColorSwatchIcon.9":v_,"DocParagraphBackgroundColorSwatchIcon.10":y_,"DocParagraphBackgroundColorSwatchIcon.11":b_,"DocParagraphBackgroundColorSwatchIcon.12":x_,"DocParagraphBackgroundColorSwatchIcon.13":S_,"DocParagraphBackgroundColorSwatchIcon.14":C_,"DocParagraphBackgroundColorSwatchIcon.15":w_}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(Oc,Nv)),this.disposeWithMe(this._componentManager.register(`doc_ui_paragraph-setting-panel`,jv)),this.disposeWithMe(this._componentManager.register(fl,Mv)),this.disposeWithMe(this._componentManager.register(Cl,Av)),this.disposeWithMe(this._componentManager.register(T_,O_)),this.disposeWithMe(this._componentManager.register(zl,Ll)),this.disposeWithMe(this._componentManager.register(Rl,Fl)),this.disposeWithMe(this._componentManager.register(qg,Jg))}};Iv=B([z(0,(0,t.Inject)(a.ComponentManager)),z(1,(0,t.Inject)(a.IconManager))],Iv);let Lv=`docs.contextMenu.caret`,Rv=`MOBILE_DOC_PINCH_ZOOMING`,zv={[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.QUICK]:{[Pa.id]:{order:3,menuItemFactory:od},[Na.id]:{order:4,menuItemFactory:sd}}},[Lv]:{[a.ContextMenuGroup.QUICK]:{quickLayout:`tile`,[da.id]:{order:0,menuItemFactory:ad},[ua.id]:{order:.5,menuItemFactory:Sd},[Pa.id]:{order:1,menuItemFactory:od},[Na.id]:{order:2,menuItemFactory:sd}}}};function Bv(e){let t=e.filter(e=>{var t;return((t=e.gridLayout)==null?void 0:t.row)===2}),n=e.filter(e=>{var t;return((t=e.gridLayout)==null?void 0:t.row)!==2}),r=[];return t.length&&r.push({key:`doc.mobile.format.quick`,order:0,quickLayout:`tile`,quickLayoutVariant:`compact`,quickColumns:4,children:t}),n.length&&r.push({key:`doc.mobile.format.detail`,order:1,children:n}),r}function Vv(e){let t=e.getMenuByPositionKey(a.RibbonStartGroup.FORMAT),n=[...e.getMenuByPositionKey(a.RibbonStartGroup.LAYOUT),...e.getMenuByPositionKey(a.RibbonStartGroup.OTHERS),...e.getMenuByPositionKey(a.RibbonInsertGroup.OTHERS)];return{insert:[{key:`doc.mobile.insert`,order:0,quickLayout:`tile`,quickColumns:4,children:e.getMenuByPositionKey(a.RibbonInsertGroup.MEDIA)}],format:Bv(t),more:[{key:`doc.mobile.more`,order:0,quickLayout:`tile`,quickColumns:4,children:n}]}}function Hv(e){let t=e.commandId??e.id;if(!t)return null;let n=typeof e.params==`function`?e.params(e.value):e.params;return{commandId:t,params:e.value===void 0?n:{value:e.value}}}function Uv(e){return(0,u.jsx)(`button`,{type:`button`,"aria-label":e.label,"aria-pressed":e.active,className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-h-10 univer-min-w-0 univer-flex-1 univer-items-center univer-justify-center univer-rounded-lg univer-text-xl univer-text-gray-700 active:univer-scale-95 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`,e.active&&`univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900`),onClick:e.onClick,children:e.icon})}function Wv(){var e,n;let i=(0,a.useDependency)(J),o=(0,a.useDependency)(t.IUniverInstanceService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useObservable)(()=>o.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),null,!0,[o]),l=c==null?void 0:c.getUnitId(),u=l?(e=s.getRenderUnitById(l))==null?void 0:e.with(q):void 0;return{isEditing:(0,a.useObservable)(u==null?void 0:u.mobileEditMode$,(u==null?void 0:u.isMobileEditMode)??!1),isReadOnly:!l||((n=i.getEditor(l))==null?void 0:n.isReadOnly())===!0,selectionService:u}}function Gv(){let e=(0,a.useDependency)(t.LocaleService),{isEditing:n,isReadOnly:r,selectionService:o}=Wv();return!n||r?null:(0,u.jsx)(`button`,{type:`button`,"aria-label":e.t(`docs-ui.mobile.done`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-10 univer-items-center univer-justify-center univer-rounded-lg univer-text-primary-600 active:univer-bg-primary-50 dark:!univer-text-primary-400 dark:active:!univer-bg-primary-900`),onClick:()=>o==null?void 0:o.exitMobileEditMode(),children:(0,u.jsx)(yp,{className:`univer-size-6`})})}function Kv(){let e=(0,a.useDependency)(t.ICommandService),n=(0,a.useDependency)(t.LocaleService),r=(0,a.useDependency)(a.IMenuManagerService),o=(0,a.useDependency)(a.IWorkbenchService),c=(0,a.useObservable)(o.rootUnitType$,null,!0),{isEditing:d,isReadOnly:f,selectionService:p}=Wv(),m=(0,a.useObservable)(p==null?void 0:p.mobileKeyboardState$,{visible:!1,inset:0}),h=m.visible,[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),[b,x]=(0,l.useState)(`compact`),[S,C]=(0,l.useState)(null),w=(0,a.useObservable)(()=>r.menuChanged$.pipe((0,s.startWith)(void 0),(0,s.map)(()=>Vv(r))),{insert:[],format:[],more:[]},!1,[r]),T=(0,l.useCallback)(()=>{_(null),x(`compact`),C(null)},[]);(0,l.useEffect)(()=>{let e=p==null?void 0:p.onFocus$.subscribe(()=>{T(),y(null)});return()=>e==null?void 0:e.unsubscribe()},[p,T]);let E=(0,l.useMemo)(()=>g?w[g]:[],[g,w]);if(c!==t.UniverInstanceType.UNIVER_DOC)return null;if(!d)return f?null:(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.edit`),className:(0,i.clsx)(i.resetButtonClassName,`univer-pointer-events-auto univer-absolute univer-bottom-4 univer-z-30 univer-flex univer-size-14 univer-items-center univer-justify-center univer-rounded-full univer-bg-primary-600 univer-text-2xl univer-text-white univer-shadow-lg active:univer-scale-95 active:univer-bg-primary-700 dark:!univer-bg-primary-500 dark:active:!univer-bg-primary-600`),style:{insetInlineEnd:`1rem`,marginBottom:`env(safe-area-inset-bottom, 0px)`},onClick:()=>{T(),y(null),p==null||p.enterMobileEditMode()},children:(0,u.jsx)($m,{})});function D(t){let n=Hv(t);n&&e.executeCommand(n.commandId,n.params).catch(()=>void 0)}function O(e){if(g===e){T();return}document.activeElement instanceof HTMLElement&&document.activeElement.blur(),y(null),C(null),x(`compact`),_(e)}function k(e){T(),y(t=>t===e?null:e)}function A(){T(),y(null),p==null||p.enterMobileEditMode(!0)}function j(){T(),y(null),p==null||p.suspendMobileEditingInput()}let M=(S==null?void 0:S.title)??n.t(g===`insert`?`docs-ui.mobile.insert`:g===`format`?`docs-ui.mobile.format`:`docs-ui.mobile.more`),N=v===`block`?af:sf;return(0,u.jsxs)(u.Fragment,{children:[h&&v&&(0,u.jsx)(`div`,{className:`univer-pointer-events-auto univer-absolute univer-inset-x-3 univer-z-30 univer-overflow-hidden`,style:{bottom:`${m.inset+48}px`},children:(0,u.jsx)(a.MobileMenu,{menuType:N,presentation:`context-bar`,onOptionSelect:D})}),h&&!g&&(0,u.jsxs)(`div`,{className:`univer-pointer-events-auto univer-absolute univer-inset-x-0 univer-z-30 univer-box-border univer-flex univer-h-12 univer-items-center univer-gap-0.5 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-1 dark:!univer-border-gray-700 dark:!univer-bg-gray-800`,style:{bottom:`${m.inset}px`,paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:[(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.insert`),icon:(0,u.jsx)(ym,{}),onClick:()=>O(`insert`)}),(0,u.jsx)(Uv,{active:v===`block`,label:n.t(`docs-ui.toolbar.heading.tooltip`),icon:(0,u.jsx)(Gm,{}),onClick:()=>k(`block`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.format`),icon:(0,u.jsx)(Um,{}),onClick:()=>O(`format`)}),(0,u.jsx)(Uv,{active:v===`align`,label:n.t(`docs-ui.paragraphMenu.alignAndIndent`),icon:(0,u.jsx)(pp,{}),onClick:()=>k(`align`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.more`),icon:(0,u.jsx)(lm,{}),onClick:()=>O(`more`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.hideKeyboard`),icon:(0,u.jsx)(xp,{}),onClick:j})]}),g&&(0,u.jsx)(a.MobileDrawer,{componentName:`mobile-doc-toolbar-drawer`,snap:b,expandLabel:n.t(`docs-ui.mobile.expand`),collapseLabel:n.t(`docs-ui.mobile.collapse`),onSnapChange:x,onClose:T,header:(0,u.jsxs)(`div`,{className:`univer-grid univer-h-12 univer-flex-1 univer-grid-cols-[56px_minmax(0,1fr)_56px] univer-items-center univer-px-2`,children:[(0,u.jsx)(`div`,{children:S&&(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.back`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-lg univer-text-2xl univer-text-gray-700 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`),onClick:S.onBack,children:(0,u.jsx)(dm,{})})}),(0,u.jsx)(`div`,{className:`univer-truncate univer-text-center univer-text-base univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100`,children:M}),(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.close`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-lg univer-text-2xl univer-text-gray-700 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`),onClick:T,children:(0,u.jsx)(xp,{})})]}),floatingActions:(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.keyboard`),className:(0,i.clsx)(i.resetButtonClassName,`univer-pointer-events-auto univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-full univer-bg-gray-0 univer-text-xl univer-text-primary-600 univer-shadow-lg active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:!univer-text-primary-400 dark:active:!univer-bg-gray-700`),onClick:A,children:(0,u.jsx)($p,{})}),children:(0,u.jsx)(a.MobileMenu,{schemas:E,menuManagerService:r,showHeader:!1,onNavigationChange:C,onOptionSelect:D})})]})}let qv=class extends t.Disposable{constructor(e,n){super(),this._popupService=e,R(this,`_pending`,null),R(this,`_editingBounds`,null),R(this,`_popup`,null),R(this,`_unitId`,null),this.disposeWithMe(n.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).subscribe(e=>{var t,n;this._unitId===e.getUnitId()&&this.close(),((t=this._pending)==null?void 0:t.unitId)===e.getUnitId()&&(this._pending=null),((n=this._editingBounds)==null?void 0:n.unitId)===e.getUnitId()&&(this._editingBounds=null)}))}capture(e){return this._pending=e,queueMicrotask(()=>{this._pending===e&&(this._pending=null)}),!0}takeTarget(e){let t=this._pending;this._pending=null;let n=(t==null?void 0:t.unitId)===e?t:null;return this._editingBounds=n,n}setEditingBounds(e,t){this._editingBounds={unitId:e,rect:t}}getEditingBounds(e){var t;return((t=this._editingBounds)==null?void 0:t.unitId)===e?this._editingBounds.rect:null}show(e){this.close(),this.setEditingBounds(e.unitId,e.rect),this._unitId=e.unitId,this._popup=this._popupService.attachPopupToRect(e.rect,{componentKey:T_,direction:`top-center`,onClickOutside:()=>this.close(),extraProps:{onEdit:()=>(this.close(),e.onEdit()),onDelete:()=>(this.close(),e.onDelete())}},e.unitId)}close(){var e;(e=this._popup)==null||e.dispose(),this._popup=null,this._unitId=null}dispose(){this._pending=null,this._editingBounds=null,this.close(),super.dispose()}};qv=B([z(0,(0,t.Inject)(Rc)),z(1,t.IUniverInstanceService)],qv);function Jv({containerRef:e,canvasRef:i}){let o=(0,a.useDependency)(t.IUniverInstanceService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useDependency)(qv),l=(0,a.useDependency)(n.DocSelectionManagerService),u=(0,a.useDependency)(a.IWorkbenchService),d=(0,a.useObservable)(u.rootUnitType$,null,!0);return(0,a.useMobileCanvasViewport)({containerRef:e,canvasRef:i,enabled:d===t.UniverInstanceType.UNIVER_DOC,panelsOnly:!0,onReveal:()=>{var e,n;let r=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),u=r&&s.getRenderUnitById(r.getUnitId()),d=u==null?void 0:u.scene.getViewport(`viewMain`);if(!u||!d)return;let f=(e=u.scene.getTransformer())==null?void 0:e.getSelectedObjectMap().values().next().value,p=c.getEditingBounds(u.unitId),m=p?Pc(p,u.scene):f&&Pc({left:f.left,top:f.top,right:f.left+f.width,bottom:f.top+f.height},u.scene);if(!m){var h;let e=l.getActiveTextRange(),t=e&&((h=Lc(e,u))==null?void 0:h[0]);if(t){let e=u.engine.getCanvasElement().getBoundingClientRect();m={left:t.left-e.left,top:t.top-e.top,right:t.right-e.left,bottom:t.bottom-e.top}}}let g=(n=i.current)==null?void 0:n.getBoundingClientRect();if(!m||!g)return;let _=(0,a.getMobileCanvasPanDelta)({left:m.left,top:m.top,width:m.right-m.left,height:m.bottom-m.top},g);if(_.x===0&&_.y===0)return;let v=u.scene.getAncestorScale();d.scrollToViewportPos({viewportScrollX:d.viewportScrollX-_.x/v.scaleX,viewportScrollY:d.viewportScrollY-_.y/v.scaleY})}}),null}let Yv=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._commandService=t,this._layoutService=n,this._menuManagerService=r,this._uiPartsService=i,this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts()}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.CONTENT,()=>(0,a.connectInjector)(Jv,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.FOOTER,()=>(0,a.connectInjector)(Kv,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.HEADER_MENU,()=>(0,a.connectInjector)(Gv,this._injector)))}_initMenus(){this._menuManagerService.mergeMenu(Rf),this._menuManagerService.appendRootMenu(zv)}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(t.UniverInstanceType.UNIVER_DOC,()=>{}))}_initCommands(){[ll,cl,jc,Mc,kc].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};Yv=B([z(0,(0,t.Inject)(t.Injector)),z(1,t.ICommandService),z(2,a.ILayoutService),z(3,a.IMenuManagerService),z(4,a.IUIPartsService)],Yv);let Xv=class extends t.Disposable{constructor(e,t,n){super(),this._context=e,this._canvasPopupManagerService=t,this._docLayoutInteractionService=n,R(this,`_layoutInteraction`,null),this.disposeWithMe(this._canvasPopupManagerService.popupUnits$.subscribe(e=>{e.has(this._context.unitId)?this._layoutInteraction??=this._docLayoutInteractionService.beginInteraction():this._endInteraction()}))}dispose(){this._endInteraction(),super.dispose()}_endInteraction(){var e;(e=this._layoutInteraction)==null||e.dispose(),this._layoutInteraction=null}};Xv=B([z(1,(0,t.Inject)(Rc)),z(2,(0,t.Inject)(Ps))],Xv);let Zv=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._docEventManagerService=r,this._textSelectionManagerService=i,this._initPointerDownObserver(),this._initHoverCursor()}_initPointerDownObserver(){this._docEventManagerService.clickBullets$.subscribe(e=>{let t=this._textSelectionManagerService.getTextRanges();this._commandService.executeCommand(io.id,{index:e.paragraph.startIndex,segmentId:e.segmentId,textRanges:t})})}_initHoverCursor(){this.disposeWithMe(this._docEventManagerService.hoverBullet$.subscribe(e=>{e?this._context.mainComponent.setCursor(r.CURSOR_TYPE.POINTER):this._context.mainComponent.setCursor(r.CURSOR_TYPE.TEXT)}))}_getTransformCoordForDocumentOffset(e,t,n,i){let{documentTransform:a}=e.getOffsetConfig(),o=t.transformVector2SceneCoord(r.Vector2.FromArray([n,i]));if(o)return a.clone().invert().applyPoint(o)}};Zv=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService)),z(2,t.ICommandService),z(3,(0,t.Inject)(rl)),z(4,(0,t.Inject)(n.DocSelectionManagerService))],Zv);let Qv=class extends t.RxDisposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._commandService=t,this._docClipboardService=n,this._docSelectionRenderService=r,this._contextService=i,this._editorService=a,this._init()}_init(){this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var e;(e=this._docSelectionRenderService)==null||e.onPaste$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{var t,n,r,i;if(!aa(this._contextService))return;e.event.preventDefault();let o=e.event,s=(t=o.clipboardData)==null?void 0:t.getData(a.HTML_CLIPBOARD_MIME_TYPE),c=(n=o.clipboardData)==null?void 0:n.getData(`application/x-doc-fragment+json`),l=(r=o.clipboardData)==null?void 0:r.getData(a.PLAIN_TEXT_CLIPBOARD_MIME_TYPE),u=[...((i=o.clipboardData)==null?void 0:i.items)||[]].filter(e=>a.imageMimeTypeSet.has(e.type)).map(e=>e.getAsFile()).filter(e=>!!e);this._editorService.getEditor(this._context.unitId)&&(s??``).indexOf(`</table>`)>-1&&(s=``),this._docClipboardService.legacyPaste({html:s,internalJson:c,text:l,files:u,unitId:this._context.unitId}).catch(()=>void 0)})}};Qv=B([z(1,t.ICommandService),z(2,ea),z(3,(0,t.Inject)(q)),z(4,t.IContextService),z(5,J)],Qv);let $v=[t.DEFAULT_EMPTY_DOCUMENT_VALUE,t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY],ey=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._contextMenuService=t,this._commandService=n,this._docEventManagerService=r,this._docSelectionManagerService=i,this._contextService=a,this._univerInstanceService=o,$v.includes(this._context.unitId)||(this._initPointerDown(),this._initEditChange())}_initPointerDown(){var e;let n=((e=this._context)==null||(e=e.mainComponent)==null?void 0:e.onPointerDown$).subscribeEvent(e=>{if(e.button===2){var n;if(this._docEventManagerService.isPointerOnNonChecklistBullet(e.offsetX,e.offsetY)||this._isSelectionInCodeBlock())return;let r=this._docEventManagerService.getParagraphByOffset(e.offsetX,e.offsetY),i=this._univerInstanceService.getUnit(this._context.unitId),o=(r==null?void 0:r.segmentId)??``,s=r&&(i==null||(n=i.getSelfOrHeaderFooterModel(o))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(e=>e.startIndex===r.startIndex));this._docEventManagerService.contextMenuParagraph=s!=null&&s.paragraphId?{unitId:this._context.unitId,segmentId:o,paragraphId:s.paragraphId}:null;let c=this._contextService.getContextValue(t.FOCUSING_COMMON_DRAWINGS)?a.ContextMenuPosition.DRAWING:a.ContextMenuPosition.MAIN_AREA;this._contextMenuService.triggerContextMenu(e,c)}});this.disposeWithMe(n)}_initEditChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===n.RichTextEditingMutation.id&&this._contextMenuService.visible&&this._contextMenuService.hideContextMenu()}))}_isSelectionInCodeBlock(){var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),r=(n==null||(e=n.getBody())==null||(e=e.blockRanges)==null?void 0:e.filter(e=>e.blockType===t.DocumentBlockRangeType.CODE))??[],i=this._docSelectionManagerService.getTextRanges()??[];return!r.length||!i.length?!1:r.some(e=>i.some(t=>ty(t,e.startIndex,e.endIndex)))}};ey=B([z(1,a.IContextMenuService),z(2,t.ICommandService),z(3,(0,t.Inject)(rl)),z(4,(0,t.Inject)(n.DocSelectionManagerService)),z(5,t.IContextService),z(6,(0,t.Inject)(t.IUniverInstanceService))],ey);function ty(e,t,n){return Math.max(e.startOffset,t)<=Math.min(e.endOffset,n)}let ny=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._univerInstanceService=t,this._editorService=n,this._commandService=r,this._docSelectionRenderService=i,this._docSkeletonManagerService=a,this._renderManagerService=o,R(this,`_initialEditors`,new Set),this._initialize()}_initialize(){this._editorService.getAllEditor().forEach(e=>{let t=e.getEditorId();t===this._context.unitId&&(this._initialEditors.has(t)||(this._initialEditors.add(t),this._resize(t)))}),this._commandExecutedListener(),this._initialBlur(),this._initialFocus()}_resize(e){if(e==null)return;let n=this._editorService.getEditor(e);if((n==null?void 0:n.cancelDefaultResizeListener)===!0)return;let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!r)return;let i=this._docSkeletonManagerService.getSkeleton();if(n==null||n.render==null||i==null||r==null)return;i.calculate();let{marginTop:a=0,marginBottom:o=0,marginLeft:s=0,marginRight:c=0}=r.getSnapshot().documentStyle,{scene:l,mainComponent:u}=n.render,{actualHeight:d,actualWidth:f}=i.getActualSize();d+=a+o,f+=s+c;let{width:p,height:m}=n.getBoundingClientRect(),h=Math.max(f,p),g=Math.max(d,m);l.transformByState({width:h,height:g}),u==null||u.resize(h,g)}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._docSelectionRenderService.blur()})),this.disposeWithMe(this._docSelectionRenderService.onBlur$.subscribe(()=>{let{unitId:e}=this._context,t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.getEditorId()===e||e.includes(`range_selector`)||e.includes(`embedding_formula_editor`)||this._editorService.blur()}))}_initialFocus(){let e=[`univer-formula-search`,`univer-formula-help`,`formula-help-decorator`,`univer-formula-help-param`];this.disposeWithMe((0,s.fromEvent)(window,`mousedown`).subscribe(n=>{let r=n.target.classList[0]||``;(0,t.checkForSubstrings)(r,e)&&n.stopPropagation()}));let n=new t.DisposableCollection;this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(n.dispose(),!e)return;let t=e.getUnitId(),r=this._renderManagerService.getRenderUnitById(t),i=r==null?void 0:r.engine.getCanvas().getCanvasEle();if(i==null)return;let a=(0,s.fromEvent)(i,`mousedown`).subscribe(e=>{e.stopPropagation()});n.add(a)})),this.disposeWithMe(()=>n.dispose())}_commandExecutedListener(){let e=[n.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){let{unitId:e}=t.params;if(this._editorService.isSheetEditor(e)||e!==this._context.unitId)return;let n=this._editorService.getEditorRenderConfig(e);n&&!n.scrollBar&&this._resize(e)}}))}};ny=B([z(1,t.IUniverInstanceService),z(2,J),z(3,t.ICommandService),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(n.DocSkeletonManagerService)),z(6,r.IRenderManagerService)],ny);let ry=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docSelectionRenderService=t,this._docImeInputManagerService=n,this._docSkeletonManagerService=r,this._docStateEmitService=i,this._docSelectionManagerService=a,this._commandService=o,R(this,`_previousIMEContent`,``),R(this,`_isCompositionStart`,!0),R(this,`_onStartSubscription`,void 0),R(this,`_onUpdateSubscription`,void 0),R(this,`_onEndSubscription`,void 0),this._initialize()}dispose(){var e,t,n;(e=this._onStartSubscription)==null||e.unsubscribe(),(t=this._onUpdateSubscription)==null||t.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._docSelectionRenderService.onCompositionstart$.subscribe(e=>{var n;if(e==null)return;this._resetIME();let{activeRange:r,rangeList:i=[]}=e;r!=null&&(this._docImeInputManagerService.setActiveRange(t.Tools.deepClone(r)),this._docImeInputManagerService.setPreviousDocRanges(t.Tools.deepClone([...i,...this._docSelectionRenderService.getAllRectRanges()])),this._docImeInputManagerService.setPreviousSelectionOptions(t.Tools.deepClone(((n=this._docSelectionManagerService.getSelectionInfo())==null?void 0:n.options)??null)))})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._docSelectionRenderService.onCompositionupdate$.subscribe(e=>{this._updateContent(e,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._docSelectionRenderService.onCompositionend$.subscribe(e=>{this._updateContent(e,!1)})}async _updateContent(e,t){if(e==null)return;let n=this._context.unitId,r=this._docSkeletonManagerService.getSkeleton(),{event:i,activeRange:a}=e;if(r==null||a==null)return;let o=i.data;if(!(t&&o===``)){if(!t&&o===``){this._previousIMEContent!==``&&await this._commandService.executeCommand(Ya.id,{unitId:n,newText:``,oldTextLen:this._previousIMEContent.length,isCompositionStart:!1,isCompositionEnd:!0,isCompositionCanceled:!0}),this._resetIME();return}if(!(o===this._previousIMEContent&&t)){if(!t&&o===this._previousIMEContent){this._finalizeComposition(),this._resetIME();return}await this._commandService.executeCommand(Ya.id,{unitId:n,newText:o,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!t}),t?(this._isCompositionStart&&=!1,this._previousIMEContent=o):this._resetIME()}}}_finalizeComposition(){let e=this._docImeInputManagerService.getActiveRange();e!=null&&this._docStateEmitService.emitStateChangeInfo({commandId:n.RichTextEditingMutation.id,unitId:this._context.unitId,segmentId:e.segmentId,trigger:Ya.id,redoState:{actions:[],textRanges:this._docImeInputManagerService.getPreviousDocRanges().length?this._docImeInputManagerService.getPreviousDocRanges():[e]},undoState:{actions:[],textRanges:this._docImeInputManagerService.getPreviousDocRanges().length?this._docImeInputManagerService.getPreviousDocRanges():[e],options:this._docImeInputManagerService.getPreviousSelectionOptions()??void 0},isCompositionEnd:!0})}_resetIME(){this._previousIMEContent=``,this._isCompositionStart=!0,this._docImeInputManagerService.clearUndoRedoMutationParamsCache(),this._docImeInputManagerService.setActiveRange(null),this._docImeInputManagerService.setPreviousDocRanges([]),this._docImeInputManagerService.setPreviousSelectionOptions(null)}};ry=B([z(1,(0,t.Inject)(q)),z(2,(0,t.Inject)(Ja)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,(0,t.Inject)(n.DocStateEmitService)),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,t.ICommandService)],ry);let iy=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docSelectionRenderService=t,this._docSkeletonManagerService=n,this._commandService=r,this._docMenuStyleService=i,this._embedRuntimeFocusCoordinator=o,R(this,`_onInputSubscription`,void 0),this._init()}dispose(){var e;super.dispose(),(e=this._onInputSubscription)==null||e.unsubscribe()}_init(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._docSelectionRenderService.onInput$.subscribe(async e=>{var r,i,a,o,s,c;if(e==null)return;let{unitId:l}=this._context,{event:u,content:d=``,activeRange:f,rangeList:p=[]}=e,m=u;if(m.defaultPrevented||!t.SHEET_EDITOR_UNITS.includes(l)&&this._isEmbedChildInputActive(l,m))return;let h=this._docSkeletonManagerService.getSkeleton();if(m.data==null||h==null||f==null)return;let{segmentId:g}=f,_=this._context.unit,v=(r=_.getSelfOrHeaderFooterModel(g))==null?void 0:r.getBody();if(!v)return;let y=this._docMenuStyleService.getDefaultStyle(),b=this._docMenuStyleService.getStyleCache(),x=ee((v==null?void 0:v.customRanges)??[],f.endOffset,t.SHEET_EDITOR_UNITS.includes(l)),S=N(v,f,y,b,t.SHEET_EDITOR_UNITS.includes(l),((i=Be(_))==null?void 0:i.inheritParagraphStartStyle)===!0),C=P((v==null?void 0:v.customDecorations)??[],f.endOffset),w={dataStream:d,textRuns:S?[{...S,st:0,ed:d.length}]:[],customRanges:x?[{...x,startIndex:0,endIndex:d.length-1}]:[],customDecorations:C.map(e=>({...e,startIndex:0,endIndex:d.length-1}))};!f.collapsed&&((a=v.blockRanges)!=null&&a.length||(o=v.columnGroups)!=null&&o.length||(s=v.customBlocks)!=null&&s.length||(c=v.tables)!=null&&c.length)||p.length>1||this._docSelectionRenderService.getAllRectRanges().length>0?await this._commandService.executeCommand(Ne.id,{unitId:l,body:w,segmentId:g}):await this._commandService.executeCommand(n.InsertTextCommand.id,{unitId:l,body:w,range:f,segmentId:g}),d===` `&&await this._commandService.executeCommand(ne.id)})}_isEmbedChildInputActive(e,t){var n,r,i;return(n=this._embedRuntimeFocusCoordinator)!=null&&n.isChildUnitRuntimeEvent(e,t.target,t)||(r=this._embedRuntimeFocusCoordinator)!=null&&r.isChildUnitInActiveSession(e)?!1:!!((i=this._embedRuntimeFocusCoordinator)!=null&&i.shouldSuppressHostInteraction(e,t.target,t))}};iy=B([z(1,(0,t.Inject)(q)),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.ICommandService),z(4,(0,t.Inject)(U)),z(5,(0,t.Optional)(Ie)),z(6,(0,t.Optional)(Le))],iy);function ay(e){if(e.complete)return 100;let t=e.totalBlockCount>0?e.processedBlockCount/e.totalBlockCount:0,n=Math.max(e.estimatedPageCount,e.pageCount),r=e.mode===`paginated`&&n>0?e.publishedPageCount/n:0,i=e.reason===`initial`&&e.totalBlockCount>0?t:Math.max(t,r);return Math.min(99,Math.max(0,Math.floor(i*100)))}let oy=class extends t.RxDisposable{constructor(e,t,n){super(),this._context=e,this._docSkeletonManagerService=t,this._docLayoutProgressService=n,R(this,`_visible`,!1),R(this,`_delayTimer`,null),R(this,`_cancelTimer`,null),R(this,`_latestProgress`,null),R(this,`_layoutStartedAt`,null),R(this,`_maxProgress`,0),this._docSkeletonManagerService.currentSkeleton$.pipe((0,s.switchMap)(e=>(this._reset(),(e==null?void 0:e.layoutProgress$)??s.EMPTY)),(0,s.takeUntil)(this.dispose$)).subscribe(e=>this._handleProgress(e))}dispose(){this._reset(),super.dispose()}_handleProgress(e){if(e.cancelled){this._latestProgress=null,this._scheduleCancelledClear();return}if(this._clearCancelTimer(),e.complete){this._reset();return}this._latestProgress=e,this._layoutStartedAt??=Date.now(),this._maxProgress=Math.max(this._maxProgress,ay(e)),this._visible&&this._docLayoutProgressService.setProgress(this._context.unitId,this._maxProgress),this._scheduleShow()}_scheduleShow(){if(this._visible||this._delayTimer!=null||this._layoutStartedAt==null)return;let e=Math.max(0,2e3-(Date.now()-this._layoutStartedAt));if(e===0){this._show();return}this._delayTimer=setTimeout(()=>{this._delayTimer=null,this._show()},e)}_show(){this._visible||this._latestProgress==null||this._latestProgress.complete||(this._visible=!0,this._docLayoutProgressService.setProgress(this._context.unitId,this._maxProgress))}_scheduleCancelledClear(){this._cancelTimer??=setTimeout(()=>{this._cancelTimer=null,this._latestProgress??this._reset()},1e3)}_clearCancelTimer(){this._cancelTimer!=null&&(clearTimeout(this._cancelTimer),this._cancelTimer=null)}_reset(){this._delayTimer!=null&&(clearTimeout(this._delayTimer),this._delayTimer=null),this._clearCancelTimer(),this._docLayoutProgressService.clearProgress(this._context.unitId),this._visible=!1,this._latestProgress=null,this._layoutStartedAt=null,this._maxProgress=0}};oy=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService)),z(2,(0,t.Inject)(Qh))],oy);function sy(e,n,r){let i=e.style.pointerEvents,a=e.style.opacity,o=e.getAttribute(`aria-busy`),s=n.forceDisable();return r(),e.style.pointerEvents=`none`,e.style.opacity=`0.55`,e.setAttribute(`aria-busy`,`true`),(0,t.toDisposable)(()=>{s.dispose(),e.style.pointerEvents=i,e.style.opacity=a,o==null?e.removeAttribute(`aria-busy`):e.setAttribute(`aria-busy`,o)})}let cy=class extends t.RxDisposable{constructor(e,t,r,i,a){super(),this._context=e,this._layoutExecutorService=t,this._docPopupManagerService=r,this._docSelectionRenderService=i,this._shortcutService=a,R(this,`_popup`,null),R(this,`_interactionLock`,null),R(this,`_visible`,!1),this._layoutExecutorService.executorStatus$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{e.state===n.DocLayoutExecutorState.RECOVERING&&e.recoveryUnitId===this._context.unitId?this._show():this._hide()})}dispose(){this._hide(),super.dispose()}_show(){if(this._visible)return;let e=this._context.engine.getCanvasElement();this._visible=!0;try{this._interactionLock=sy(e,this._shortcutService,()=>this._docSelectionRenderService.blur()),this._popup=this._docPopupManagerService.attachPopupToRect(()=>({left:this._context.scene.width/2,right:this._context.scene.width/2,top:this._context.scene.height/2,bottom:this._context.scene.height/2}),{componentKey:qg,customActive:!0,direction:`vertical-center`,zIndex:1021},this._context.unitId)}catch{this._restoreInteraction()}}_hide(){var e;this._visible&&((e=this._popup)==null||e.dispose(),this._popup=null,this._restoreInteraction())}_restoreInteraction(){var e;(e=this._interactionLock)==null||e.dispose(),this._interactionLock=null,this._visible=!1}};cy=B([z(1,(0,t.Inject)(n.DocLayoutExecutorService)),z(2,(0,t.Inject)(Rc)),z(3,(0,t.Inject)(q)),z(4,a.IShortcutService)],cy);let ly=class extends t.Disposable{constructor(e,n,r,i,o){if(super(),this._context=e,this._clipboard=n,R(this,`_popup`,void 0),(0,t.isInternalEditorID)(e.unitId))return;let s=o.getContextValue(a.MOBILE_UI_MODE)===!0;this.disposeWithMe(r.onKeydown$.subscribe(({event:e})=>{let t=e;(t.ctrlKey||t.metaKey)&&t.shiftKey&&t.key.toLowerCase()===`v`?this._clipboard.setNextPasteMode(`text`):[`Control`,`Meta`,`Shift`,`Alt`].includes(t.key)||(this._clipboard.setNextPasteMode(`source`),this._clipboard.dismissPasteOptions())})),this.disposeWithMe(r.onInputBefore$.subscribe(()=>this._clipboard.dismissPasteOptions())),this.disposeWithMe(r.onPointerDown$.subscribe(()=>{this._clipboard.setNextPasteMode(`source`),s||this._clipboard.dismissPasteOptions()})),this.disposeWithMe(r.onBlur$.subscribe(()=>this._clipboard.setNextPasteMode(`source`))),this.disposeWithMe(this._clipboard.pasteOptions$.subscribe(e=>{var t;(t=this._popup)==null||t.dispose(),this._popup=void 0,(e==null?void 0:e.unitId)===this._context.unitId&&(this._popup=i.attachPopupToRange(e.range,{componentKey:Yg,direction:`bottom-left`,rangeAnchor:`selection-end`,requiresStableLayout:!1,hideOnInvisible:!s,extraProps:{unitId:e.unitId},offset:[0,6],onClickOutside:s?void 0:()=>this._clipboard.dismissPasteOptions()},e.unitId))})),this.disposeWithMe(()=>{var e;(e=this._popup)==null||e.dispose(),this._clipboard.dismissPasteOptions()})}};ly=B([z(1,ea),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(Rc)),z(4,t.IContextService)],ly);function uy(e){if(typeof e!=`object`||!e||!(`getSkeleton`in e)||typeof e.getSkeleton!=`function`)return!1;let t=e.getSkeleton();if(typeof t!=`object`||!t||!(`getSkeletonData`in t)||typeof t.getSkeletonData!=`function`)return!1;let n=t.getSkeletonData();return typeof n==`object`&&!!n&&`pages`in n&&Array.isArray(n.pages)&&n.pages.length>0}let dy=class extends t.Disposable{constructor(e,n,r,i){super(),this._context=e,this._docPageLayoutService=n,this._textSelectionManagerService=r,this._sidebarService=i;let a=this._context.unitId;if((0,t.isInternalEditorID)(a))return this;this._initResize()}_initResize(){this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler)).subscribe(()=>this._refreshLayoutAndSelection())),this.disposeWithMe(this._sidebarService.sidebarOptions$.pipe((0,s.observeOn)(s.animationFrameScheduler)).subscribe(()=>this._refreshLayoutAndSelection()))}_refreshLayoutAndSelection(){if(this._disposed||!uy(this._context.mainComponent))return;this._docPageLayoutService.calculatePagePosition();let e=this._context.unitId;this._textSelectionManagerService.refreshSelection({unitId:e,subUnitId:e})}};dy=B([z(1,(0,t.Inject)(Hs)),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,a.ISidebarService)],dy);let fy=class extends ds{constructor(e,t,n,r,i,a){super(e,t,r,i),this._docSelectionRenderService=n,this._docPageLayoutService=a,R(this,`_mobileKeyboardInset`,0),this.disposeWithMe(this._docSelectionRenderService.mobileKeyboardState$.subscribe(({visible:e,inset:t})=>{let n=this._mobileKeyboardInset;this._mobileKeyboardInset=e?t+48:0,this._docPageLayoutService.setBottomReserve(e?this._mobileKeyboardInset+32:0),this._mobileKeyboardInset>n&&(this._cancelPendingSelectionScroll(),this._scrollToSelection())}))}dispose(){this._docPageLayoutService.setBottomReserve(0),super.dispose()}_getVerticalScrollDelta(e,t,n,r,i){let a=Math.max(this._context.scene.getAncestorScale().scaleY,.01),o=r-this._mobileKeyboardInset/a;if(e>=n&&e+t<=o)return 0;let s=Math.max(0,o-n-t)*.4;return e-n-s}};fy=B([z(1,(0,t.Inject)(n.DocSelectionManagerService)),z(2,(0,t.Inject)(q)),z(3,J),z(4,(0,t.Inject)(n.DocSkeletonManagerService)),z(5,(0,t.Inject)(Hs))],fy);function py(e){var t;let n=e.target;if(typeof Element<`u`&&n instanceof Element&&n.closest(`[data-embed-interaction-boundary-owner]`)!=null)return!0;if(typeof document>`u`)return!1;let r=my(e,n),i=r==null?void 0:r.clientX,a=r==null?void 0:r.clientY;return typeof i!=`number`||typeof a!=`number`||!Number.isFinite(i)||!Number.isFinite(a)||typeof document.elementFromPoint!=`function`?!1:((t=document.elementFromPoint(i,a))==null?void 0:t.closest(`[${Fe}]`))!=null}function my(e,t){if(Number.isFinite(e.clientX)&&Number.isFinite(e.clientY))return{clientX:e.clientX,clientY:e.clientY};if(typeof Element<`u`&&t instanceof Element&&Number.isFinite(e.offsetX)&&Number.isFinite(e.offsetY)){let n=t.getBoundingClientRect();return{clientX:n.left+e.offsetX,clientY:n.top+e.offsetY}}if(Number.isFinite(e.x)&&Number.isFinite(e.y))return{clientX:e.x,clientY:e.y}}let hy=.22,gy=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(),this._context=e,this._commandService=t,this._editorService=n,this._instanceSrv=r,this._docSelectionRenderService=i,this._docSkeletonManagerService=a,this._docSelectionManagerService=o,this._contextService=s,this._contextMenuService=c,this._mobileElementMenuService=l,this._embedRuntimeFocusCoordinator=d,R(this,`_loadedMap`,new WeakSet),R(this,`_deferredEditorFocusTimer`,null),R(this,`_gestureTimer`,null),R(this,`_gestureDisposables`,[]),R(this,`_lastTap`,null),R(this,`_inertiaAnimationId`,null),R(this,`_inertiaLastFrameTime`,0),R(this,`_inertiaVelocity`,{x:0,y:0}),R(this,`_initialSelectionReady`,!1),this._initialize()}_initialize(){this._init(),this._refreshListener(),this._syncSelection(),this._skeletonListener(),this._commandExecutedListener()}_init(){let{unitId:e}=this._context,t=x(this._context);t!=null&&t.document!=null&&(this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document)))}_refreshListener(){this.disposeWithMe(this._docSelectionManagerService.refreshSelection$.subscribe(e=>{if(e==null)return;let{unitId:t,docRanges:n,isEditing:r,options:i}=e;t===this._context.unitId&&this._docSelectionRenderService.replaceDocRanges(n,r,i)}))}_syncSelection(){this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe(e=>{e!=null&&((0,t.isInternalEditorID)(this._context.unitId)||!this._isEmbedChildInteractionActive(this._context.unitId))&&this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(e,{unitId:this._context.unitId,subUnitId:this._context.unitId})}))}_initialMain(e){if(this.disposeWithMe((0,s.fromEvent)(this._context.engine.getCanvasElement(),`mousedown`).subscribe(e=>{e.button===0&&this._docSelectionRenderService.isFocusing&&e.preventDefault()})),(0,t.isInternalEditorID)(e)){this._initialEditor(e);return}let{document:n,scene:r}=x(this._context);this._docSelectionRenderService.exitMobileEditMode(),this.disposeWithMe(r.onPointerDown$.subscribeEvent((e,t)=>{e.cancelable&&e.preventDefault(),this._startGesture(e,this._docSelectionRenderService.isMobileEditMode,this._getDocumentOffset(e),!1),t.stopPropagation()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((n,r)=>{var i;if(this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(n,e))return;let a=this._instanceSrv.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(a==null?void 0:a.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e),(i=this._editorService.getEditorRenderConfig(e))!=null&&i.preserveHostFocus||this._instanceSrv.focusUnit(e);let o=this._getDocumentOffset(n);this._syncEditArea(o.offsetX,o.offsetY),n.cancelable&&n.preventDefault(),this._startGesture(n,this._docSelectionRenderService.isMobileEditMode,o),n.button!==2&&r.stopPropagation()}))}_initialEditor(e){let{document:n,scene:i}=x(this._context);this.disposeWithMe(n.onPointerEnter$.subscribeEvent(()=>{this._isEditorReadOnly(e)||(n.cursor=r.CURSOR_TYPE.TEXT)})),this.disposeWithMe(n.onPointerLeave$.subscribeEvent(()=>{n.cursor=r.CURSOR_TYPE.DEFAULT,i.resetCursor()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((n,r)=>{var i;if(this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(n,e))return;let a=this._instanceSrv.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(a==null?void 0:a.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e),e!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&e!==t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&!((i=this._editorService.getEditorRenderConfig(e))!=null&&i.preserveHostFocus)&&this._instanceSrv.focusUnit(e);let{offsetX:o,offsetY:s}=n;this._syncEditArea(o,s),this._docSelectionRenderService.__onPointDown(n,!0),this._editorService.getEditor(e)&&(this._setEditorFocus(e),this._deferredEditorFocusTimer!=null&&clearTimeout(this._deferredEditorFocusTimer),this._deferredEditorFocusTimer=setTimeout(()=>{this._deferredEditorFocusTimer=null,!(e===this._editorService.getFocusId()||this._docSelectionRenderService.isOnPointerEvent)&&(this._setEditorFocus(e),this._docSelectionRenderService.setCursorManually(o,s))},0)),n.button!==2&&r.stopPropagation()})),this.disposeWithMe(n.onDblclick$.subscribeEvent(t=>{this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(t,e)||(this._editorService.getEditor(e)&&this._setEditorFocus(e),this._docSelectionRenderService.__handleDblClick(t))})),this.disposeWithMe(n.onTripleClick$.subscribeEvent(t=>{this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(t,e)||this._docSelectionRenderService.__handleTripleClick(t)}))}dispose(){this._clearGesture(),this._stopInertia(),this._deferredEditorFocusTimer!=null&&(clearTimeout(this._deferredEditorFocusTimer),this._deferredEditorFocusTimer=null),super.dispose()}_syncEditArea(e,t){let n=this._getTransformCoordForDocumentOffset(e,t);if(n==null)return;let{document:i}=x(this._context),{pageLayoutType:a=r.PageLayoutType.VERTICAL,pageMarginLeft:o,pageMarginTop:s}=i.getOffsetConfig(),{editArea:c}=this._docSkeletonManagerService.getSkeleton().findEditAreaByCoord(n,a,o,s),l=this._docSkeletonManagerService.getViewModel(),u=l.getEditArea();u!==r.DocumentEditArea.BODY&&c!==r.DocumentEditArea.BODY&&c!==u&&l.setEditArea(c)}_startGesture(e,n,r,i=!0){this._clearGesture(),this._stopInertia();let a=i?this._mobileElementMenuService.takeTarget(this._context.unitId):null;this._mobileElementMenuService.close(),this._contextMenuService.visible&&this._contextMenuService.hideContextMenu();let o=this._context.scene,s=o.getViewport(`viewMain`)??o.getViewports()[0],c=this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.MODERN,{x:l,y:u}=_y(e),[d,f]=[l,u],p=!1,m=!1,h=yy(c),g=this._docSelectionRenderService.getActiveTextRange(),_=g!=null&&g.collapsed?g.startOffset??null:null,v=this._docSelectionRenderService.isFocusing;i&&!(a!=null&&a.onTap)&&!(a!=null&&a.onDrag)&&(this._gestureTimer=setTimeout(()=>{this._gestureTimer=null,!this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)&&(m=!0,this._selectWord(e,n))},420));let y=o.onPointerMove$.subscribeEvent(e=>{if(m||this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`))return;let{x:t,y:n}=_y(e),r=t-d,i=n-f;!p&&Math.hypot(t-l,n-u)<12||(p=!0,this._lastTap=null,this._clearGestureTimer(),a!=null&&a.onDrag?a.onDrag(e):(this._scrollDocument(s,c,r,i),h.track(r,i)),d=t,f=n)}),b=o.onPointerUp$.subscribeEvent(()=>{if(this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)){this._clearGesture();return}i&&!p&&!m&&(a?a.onTap?a.onTap(r):this._mobileElementMenuService.show(a):this._handleTap(e,r,n,v,_)),p&&!(a!=null&&a.onDrag)&&this._startInertia(s,h.getVelocity()),this._clearGesture()}),x=o.onPointerCancel$.subscribeEvent(()=>this._clearGesture());this._gestureDisposables=[y,b,x]}_handleTap(e,t,n,r,i){var a;let{offsetX:o,offsetY:s}=t;if((a=this._context.scene.getTransformer())==null||a.clearSelectedObjects(),n){this._docSelectionRenderService.setCursorManually(o,s,!0,!0,{strict:!1});let t=this._docSelectionRenderService.getActiveTextRange();r&&i!=null&&t!=null&&t.collapsed&&t.startOffset===i&&this._showCaretMenu(e);return}let c=Date.now(),l=this._lastTap;l!=null&&c-l.time<=450&&Math.hypot(o-l.x,s-l.y)<=28?(this._lastTap=null,this._enterEditing(this._context.unitId,e)):this._lastTap={x:o,y:s,time:c}}_selectWord(e,t){var n;(n=this._context.scene.getTransformer())==null||n.clearSelectedObjects(),this._lastTap=null,this._docSelectionRenderService.__handleDblClick(e,!1,!1),t&&this._docSelectionRenderService.suspendMobileEditingInput()}_scrollDocument(e,t,n,r){let{scaleX:i,scaleY:a}=this._context.scene;e==null||e.scrollByViewportDeltaVal({viewportScrollX:t?0:vy(-n,i),viewportScrollY:vy(-r,a)})}_startInertia(e,t){if(this._inertiaVelocity={x:Math.max(-12,Math.min(12,t.x)),y:Math.max(-12,Math.min(12,t.y))},Math.hypot(this._inertiaVelocity.x,this._inertiaVelocity.y)<=hy*2)return;this._inertiaLastFrameTime=0;let n=t=>{if(this._inertiaLastFrameTime===0){this._inertiaLastFrameTime=t,this._inertiaAnimationId=requestAnimationFrame(n);return}let r=t-this._inertiaLastFrameTime;this._inertiaLastFrameTime=t;let i=.992,a=i**r;this._inertiaVelocity.x*=a,this._inertiaVelocity.y*=a;let o=-Math.log(i),{scaleX:s,scaleY:c}=this._context.scene;e==null||e.scrollByViewportDeltaVal({viewportScrollX:vy(this._inertiaVelocity.x*(1-a)/o,s),viewportScrollY:vy(this._inertiaVelocity.y*(1-a)/o,c)}),Math.hypot(this._inertiaVelocity.x,this._inertiaVelocity.y)>hy?this._inertiaAnimationId=requestAnimationFrame(n):(this._inertiaAnimationId=null,this._inertiaLastFrameTime=0)};this._inertiaAnimationId=requestAnimationFrame(n)}_stopInertia(){this._inertiaAnimationId!=null&&cancelAnimationFrame(this._inertiaAnimationId),this._inertiaAnimationId=null,this._inertiaLastFrameTime=0,this._inertiaVelocity={x:0,y:0}}_enterEditing(e,t){this._editorService.getEditor(e)&&this._setEditorFocus(e),this._docSelectionRenderService.enterMobileEditMode();let{offsetX:n,offsetY:r}=this._getDocumentOffset(t);this._docSelectionRenderService.setCursorManually(n,r,!0,!0,{strict:!1})}_getDocumentOffset(e){let t=this._context.scene.getEngine(),n=t==null?void 0:t.getCanvasElement();if(!t||!n||!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return{offsetX:e.offsetX,offsetY:e.offsetY};let r=n.getBoundingClientRect();return r.width<=0||r.height<=0?{offsetX:e.offsetX,offsetY:e.offsetY}:{offsetX:(e.clientX-r.left)*t.width/r.width,offsetY:(e.clientY-r.top)*t.height/r.height}}_showCaretMenu(e){let t=my(e,null);this._contextMenuService.triggerContextMenu({clientX:(t==null?void 0:t.clientX)??e.offsetX,clientY:(t==null?void 0:t.clientY)??e.offsetY,stopPropagation(){}},Lv,{caretAnchor:!0,unitId:this._context.unitId,subUnitId:this._context.unitId})}_clearGestureTimer(){this._gestureTimer!=null&&(clearTimeout(this._gestureTimer),this._gestureTimer=null)}_clearGesture(){this._clearGestureTimer(),this._gestureDisposables.forEach(e=>e.unsubscribe()),this._gestureDisposables=[]}_getTransformCoordForDocumentOffset(e,t){let{document:n,scene:i}=x(this._context),{documentTransform:a}=n.getOffsetConfig(),o=i.getViewports()[0];if(o==null)return;let s=o.transformVector2SceneCoord(r.Vector2.FromArray([e,t]));return a.clone().invert().applyPoint(s)}_isEditorReadOnly(e){var t;return((t=this._editorService.getEditor(e))==null?void 0:t.isReadOnly())??!1}_setEditorFocus(e){this._editorService.focus(e)}_isEmbedInteractionEvent(e,n){var r,i,a;if((0,t.isInternalEditorID)(n))return!1;let o=e.target;return(r=this._embedRuntimeFocusCoordinator)!=null&&r.isChildUnitRuntimeEvent(n,o,e)||(i=this._embedRuntimeFocusCoordinator)!=null&&i.isChildUnitInActiveSession(n)?!1:(a=this._embedRuntimeFocusCoordinator)!=null&&a.shouldSuppressHostInteraction(n,o,e)?!0:py(e)}_isEmbedChildInteractionActive(e){var t;return((t=this._embedRuntimeFocusCoordinator)==null?void 0:t.shouldSuppressHostInteraction(e))===!0}_commandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(!e.includes(t.id))return;let{unitId:r}=t.params;this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)||r!==((n=this._docSelectionManagerService.__getCurrentSelection())==null?void 0:n.unitId)||this._isEmbedChildInteractionActive(r)||this._docSelectionManagerService.refreshSelection()}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e||this._initialSelectionReady)return;let{unitId:n}=this._context;if((0,t.isInternalEditorID)(n)||this._isEmbedChildInteractionActive(n))return;this._initialSelectionReady=!0;let i=Tc(this._context.unit.getSnapshot()),a={unitId:n,subUnitId:n};this._docSelectionManagerService.replaceSelectionInfoWithoutRefresh({textRanges:[{startOffset:i,endOffset:i,collapsed:!0,isActive:!0}],rectRanges:[],segmentId:``,segmentPage:-1,isEditing:!1,style:r.NORMAL_TEXT_SELECTION_PLUGIN_STYLE},a),this._docSelectionManagerService.refreshSelection(a,!1),this._docSelectionRenderService.getActiveTextRange()??this.disposeWithMe(e.layoutProgress$.pipe((0,s.filter)(e=>(e==null?void 0:e.anchorReady)===!0||(e==null?void 0:e.complete)===!0),(0,s.take)(1)).subscribe(()=>this._docSelectionManagerService.refreshSelection(a,!1)))}))}};gy=B([z(1,t.ICommandService),z(2,J),z(3,t.IUniverInstanceService),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(n.DocSkeletonManagerService)),z(6,(0,t.Inject)(n.DocSelectionManagerService)),z(7,t.IContextService),z(8,a.IContextMenuService),z(9,(0,t.Inject)(qv)),z(10,(0,t.Optional)(Ie)),z(11,(0,t.Optional)(Le))],gy);function _y(e){let t=my(e,null);return{x:(t==null?void 0:t.clientX)??e.offsetX,y:(t==null?void 0:t.clientY)??e.offsetY}}function vy(e,t){return e/(Number.isFinite(t)&&t>0?t:1)}function yy(e){let t=performance.now(),n=t,r=[],i={x:0,y:0};return{track(t,a){let o=performance.now(),s=o-n;if(n=o,s<=0)return;let c=e?0:-t,l=-a;r.push({x:c/s*16,y:l/s*16}),r.length>5&&r.shift(),i.x+=Math.abs(c),i.y+=Math.abs(l)},getVelocity:()=>by(r,performance.now()-t,i)}}function by(e,t,n){if(e.length===0)return{x:0,y:0};let r=0,i=0,a=0;e.forEach((e,t)=>{let n=(t+1)**2;r+=n,i+=e.x*n,a+=e.y*n}),i/=r,a/=r;let o=Math.hypot(n.x,n.y),s=Math.hypot(i,a),c=t>0?o/t:0,l=t<240&&o>30,u=.05*(.5+Math.min(s/5,1)*.5);return l&&(u=.05+(.26-.05)*Math.min(c/2,1),t<150&&s>3&&(u*=1.3)),u=Math.max(.025,Math.min(.39,u)),n.x>n.y?{x:i*u,y:0}:{x:0,y:a*u}}let xy=class extends Cc{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(e,t,n,r,i,a,o,s,c,l,u,d,f,p),R(this,`_mobileModernPageWidth`,void 0),this._mobileModernPageWidth=this._getMobileModernLayoutOptions().modernPageWidth,this._initResponsiveLayout()}_scheduleLayout(e,t,n,r=!0,i=!1){let a={...n,...this._getMobileModernLayoutOptions()};this._mobileModernPageWidth=a.modernPageWidth,super._scheduleLayout(e,t,a,r,i)}_shouldEnableHorizontalScrollBar(){return this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN&&super._shouldEnableHorizontalScrollBar()}_getMobileModernLayoutOptions(){var e;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN)return{};let n=(e=this._context.scene.getParent())==null?void 0:e.width,r=n!=null&&n>1?n:this._context.engine.width;return!Number.isFinite(r)||r<=24?{}:{modernPageWidth:r-24,modernHorizontalMargin:super._getHorizontalPageMargin()}}_initResponsiveLayout(){this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.MODERN&&this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler),(0,s.takeUntil)(this.dispose$)).subscribe(()=>{let e=this._getMobileModernLayoutOptions().modernPageWidth;if(e==null||Math.abs(e-(this._mobileModernPageWidth??0))<1)return;let t=this._docSkeletonManagerService.getSkeleton();t&&this._scheduleLayout(this._context.unitId,t,{reason:`initial`})}))}_getHorizontalPageMargin(){return 12}};xy=B([z(1,t.ICommandService),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,J),z(5,r.IRenderManagerService),z(6,t.IUniverInstanceService),z(7,(0,t.Inject)(Hs)),z(8,(0,t.Inject)(n.DocSelectionManagerService)),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Inject)(t.ThemeService)),z(11,(0,t.Inject)(n.DocLayoutExecutorService)),z(12,(0,t.Inject)(Ps)),z(13,t.ILogService)],xy);function Sy(e,t,n){return t&&(e.ctrlKey||e.metaKey)}let Cy=class extends t.Disposable{constructor(e,n,r,i,a,o,s,c,l,u,d){super(),this._context=e,this._contextService=n,this._docSkeletonManagerService=r,this._univerInstanceService=i,this._commandService=a,this._textSelectionManagerService=o,this._editorService=s,this._docPageLayoutService=c,this._renderManagerService=l,this._docViewScaleService=u,this._embedInteractionBoundaryService=d,R(this,`_isSheetEditor`,!1),R(this,`_initTimer`,void 0),R(this,`_updateTimer`,void 0),R(this,`_fitToWidthAvailableWidth`,0),this._initSkeletonListener(),this._initCommandExecutedListener(),this._initFitToWidthResizeListener(),this._isSheetEditor=this._context.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY;let f=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),p=f&&this._renderManagerService.getRenderUnitById(f.getUnitId());this._initTimer=window.setTimeout(()=>{let e=p&&this._isSheetEditor?p.scene.scaleX:Fs(this._context.unit);this.updateViewZoom(e,!0)},20),(0,t.isInternalEditorID)(this._context.unitId)||this._initZoomEventListener()}dispose(){window.clearTimeout(this._initTimer),window.clearTimeout(this._updateTimer),super.dispose()}_initSkeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);n&&(this._updateTimer=window.setTimeout(()=>{let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e&&this._renderManagerService.getRenderUnitById(e.getUnitId()),i=this._isSheetEditor?(r==null?void 0:r.scene.scaleX)||1:Fs(n);this.updateViewZoom(i,!1)}))}))}_initCommandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)&&t.params.unitId===this._context.unitId){let e=this._context.unit,t=Fs(e);this.updateViewZoom(t)}})),this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{var n;(e.id===No.id||e.id===kl.id&&((n=e.params)==null?void 0:n.documentFlavor)===t.DocumentFlavor.MODERN)&&this._commandService.executeCommand(yo.id,{zoomRatio:1,documentId:this._context.unitId})}))}_initFitToWidthResizeListener(){this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler)).subscribe(()=>{if(this._docViewScaleService.getOptions().mode!==`fit-width`)return;let e=this._docViewScaleService.getAvailableWidth();e<=1||Math.abs(e-this._fitToWidthAvailableWidth)<1||(this._fitToWidthAvailableWidth=e,this.updateViewZoom(Fs(this._context.unit),!1))}))}updateViewZoom(e,n=!0){var r;let i=x(this._context),a=this._docViewScaleService.getViewScale(e),o=i.scene.scaleX!==a||i.scene.scaleY!==a;if(i.scene.scale(a,a),this._editorService.isEditor(this._context.unitId)||this._docPageLayoutService.calculatePagePosition(),n&&!this._editorService.isEditor(this._context.unitId)&&!((r=this._embedInteractionBoundaryService)!=null&&r.hasRecentInteraction())&&this._textSelectionManagerService.refreshSelection(),n&&o&&!(0,t.isInternalEditorID)(this._context.unitId)){var s;(s=i.scene.getTransformer())==null||s.clearSelectedObjects()}let c=this._univerInstanceService.getUnitCreateOptions(this._context.unitId);((c==null?void 0:c.embeddedRender)===!0||(c==null?void 0:c.skipAutoRender)===!0)&&(this._context.scene.makeDirty(),this._context.scene.render())}_initZoomEventListener(){let e=this._context.scene;this.disposeWithMe(e.onMouseWheel$.subscribeEvent(e=>{let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!n)return;let{documentFlavor:i}=n.getSnapshot().documentStyle;if(!Sy(e,!!this._contextService.getContextValue(t.FOCUSING_DOC),i))return;let a=Fs(n),o=(0,r.getNextWheelZoomRatio)(a,e);this._commandService.executeCommand(yo.id,{zoomRatio:o,documentId:n.getUnitId()}),e.preventDefault()}))}};Cy=B([z(1,t.IContextService),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.IUniverInstanceService),z(4,t.ICommandService),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,J),z(7,(0,t.Inject)(Hs)),z(8,r.IRenderManagerService),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Optional)(Ie))],Cy);function wy(e,t,n){if(t<=0||!Number.isFinite(n))return e;let r=e*n/t;return Math.round(Math.max(.5,Math.min(3,r))*100)/100}var Ty=class extends t.Disposable{constructor(e){super(),this._options=e,R(this,`_zoomIndicator`,void 0),R(this,`_gestureOwned`,!1),R(this,`_pinchZooming`,!1),R(this,`_initialDistance`,0),R(this,`_initialZoomRatio`,1),R(this,`_anchor`,r.Vector2.Zero()),R(this,`_handleTouchStart`,e=>{let{contextService:t,docViewScaleService:n,scene:r,viewport:i}=this._options;if(e.touches.length!==2||r.objectsEvented===!1)return;this._gestureOwned=!0,this._pinchZooming=!0,t.setContextValue(Rv,!0);let[a,o]=e.touches;this._initialDistance=this._getTouchDistance(a,o),this._initialZoomRatio=n.getUserZoomRatio(),this._anchor=i.transformVector2SceneCoord(this._getPinchCenter(a,o)),this._zoomIndicator.show(Math.round(this._initialZoomRatio*100)),e.preventDefault()}),R(this,`_handleTouchMove`,e=>{if(!this._gestureOwned||!this._pinchZooming||e.touches.length!==2)return;let{commandService:t,docViewScaleService:n,unitId:r,viewport:i}=this._options,[a,o]=e.touches,s=wy(this._initialZoomRatio,this._initialDistance,this._getTouchDistance(a,o));Math.abs(s-n.getUserZoomRatio())>=.01&&t.syncExecuteCommand(vo.id,{unitId:r,zoomRatio:s});let c=i.transformVector2SceneCoord(this._getPinchCenter(a,o));i.scrollByViewportDeltaVal({viewportScrollX:this._anchor.x-c.x,viewportScrollY:this._anchor.y-c.y}),this._zoomIndicator.show(Math.round(s*100)),e.preventDefault()}),R(this,`_handleTouchEnd`,e=>{this._gestureOwned&&(e.touches.length<2&&this._pinchZooming&&(this._pinchZooming=!1,this._zoomIndicator.hide()),e.touches.length===0&&this._finishPinch())}),R(this,`_handleTouchCancel`,()=>this._finishPinch());let{canvasElement:n}=e;this._zoomIndicator=new a.MobileZoomIndicator(n),this.disposeWithMe(this._zoomIndicator),n.addEventListener(`touchstart`,this._handleTouchStart,{passive:!1}),n.addEventListener(`touchmove`,this._handleTouchMove,{passive:!1}),n.addEventListener(`touchend`,this._handleTouchEnd,{passive:!1}),n.addEventListener(`touchcancel`,this._handleTouchCancel,{passive:!1}),this.disposeWithMe((0,t.toDisposable)(()=>{n.removeEventListener(`touchstart`,this._handleTouchStart),n.removeEventListener(`touchmove`,this._handleTouchMove),n.removeEventListener(`touchend`,this._handleTouchEnd),n.removeEventListener(`touchcancel`,this._handleTouchCancel),this._finishPinch()}))}_getTouchPoint(e){let{canvasElement:t,engine:n}=this._options,i=t.getBoundingClientRect();return i.width<=0||i.height<=0?r.Vector2.FromArray([e.clientX-i.left,e.clientY-i.top]):r.Vector2.FromArray([(e.clientX-i.left)*n.width/i.width,(e.clientY-i.top)*n.height/i.height])}_getPinchCenter(e,t){let n=this._getTouchPoint(e),i=this._getTouchPoint(t);return r.Vector2.FromArray([(n.x+i.x)/2,(n.y+i.y)/2])}_getTouchDistance(e,t){let n=this._getTouchPoint(e),r=this._getTouchPoint(t);return Math.hypot(n.x-r.x,n.y-r.y)}_finishPinch(){this._gestureOwned&&(this._gestureOwned=!1,this._pinchZooming=!1,this._options.contextService.setContextValue(Rv,!1),this._zoomIndicator.hide(),this._options.textSelectionManagerService.refreshSelection())}};let Ey=class extends Cy{constructor(e,n,r,i,a,o,s,c,l,u,d){super(e,n,r,i,a,o,s,c,l,u,d),(0,t.isInternalEditorID)(e.unitId)||this._initGestureZoom()}_initCommandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)&&t.params.unitId===this._context.unitId){let e=Fs(this._context.unit);this.updateViewZoom(e,!this._contextService.getContextValue(Rv))}})),this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{var n;(e.id===No.id||e.id===kl.id&&((n=e.params)==null?void 0:n.documentFlavor)===t.DocumentFlavor.MODERN)&&this._commandService.executeCommand(yo.id,{zoomRatio:1,documentId:this._context.unitId})}))}_initGestureZoom(){if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let e=this._context.scene,n=e.getEngine(),r=n==null?void 0:n.getCanvasElement(),i=e.getViewport(`viewMain`);n!=null&&r!=null&&i!=null&&this.disposeWithMe(new Ty({canvasElement:r,commandService:this._commandService,contextService:this._contextService,docViewScaleService:this._docViewScaleService,engine:n,scene:e,textSelectionManagerService:this._textSelectionManagerService,unitId:this._context.unitId,viewport:i}))}};Ey=B([z(1,t.IContextService),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.IUniverInstanceService),z(4,t.ICommandService),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,J),z(7,(0,t.Inject)(Hs)),z(8,r.IRenderManagerService),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Optional)(Ie))],Ey);let Dy=class{constructor(e){this._renderManagerService=e}transformChangeStateInfo(e){var t;let{isCompositionEnd:n,isSync:r,syncer:i}=e;if(!n)return e;let a=(t=this._renderManagerService.getRenderUnitById(r?i:e.unitId))==null?void 0:t.with(Ja);if(a==null)return null;let o=a.fetchComposedUndoRedoMutationParams();if(o==null)throw Error(`historyParams is null in RichTextEditingMutation`);let{undoMutationParams:s,redoMutationParams:c,previousActiveRange:l,previousDocRanges:u,previousSelectionOptions:d}=o;return{...e,redoState:{...e.redoState,...c.layoutState===void 0?{}:{layoutState:c.layoutState},actions:c.actions,textRanges:c.textRanges,options:c.options,isEditing:c.isEditing},undoState:{...e.undoState,...s.layoutState===void 0?{}:{layoutState:s.layoutState},actions:s.actions,textRanges:u.length?u:[l],options:d??void 0}}}};Dy=B([z(0,r.IRenderManagerService)],Dy);let Oy=(0,t.createInterceptorKey)(`PRINTING_COMPONENT_COLLECT`),ky=(0,t.createInterceptorKey)(`PRINTING_DOM_COLLECT`);var Ay=class extends t.Disposable{constructor(){super(),R(this,`_printComponentMap`,new Map),R(this,`_printPreparationHandlers`,new Set),R(this,`interceptor`,new t.InterceptorManager({PRINTING_COMPONENT_COLLECT:Oy,PRINTING_DOM_COLLECT:ky})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{priority:-1,handler:e=>e})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{priority:-1,handler:e=>e}))}registerPrintComponent(e,t){this._printComponentMap.set(e,t)}getPrintComponent(e){return this._printComponentMap.get(e)}getPageDrawingIds(e,t){var n,r;let i=e.getSkeletonData();if(!i||i.pages.length<=1||t==null)return null;let a=new Set,o=i.pages[t];if(!o)return a;jy(o,a);let s=(n=i.skeHeaders.get(o.headerId))==null?void 0:n.get(o.pageWidth),c=(r=i.skeFooters.get(o.footerId))==null?void 0:r.get(o.pageWidth);return s&&jy(s,a),c&&jy(c,a),a}registerPrintPreparation(e){return this._printPreparationHandlers.add(e),()=>this._printPreparationHandlers.delete(e)}async preparePrint(e){await Promise.all([...this._printPreparationHandlers].map(t=>t(e)))}dispose(){this._printPreparationHandlers.clear(),super.dispose()}};function jy(e,t){var n;for(let n of e.skeDrawings.keys())t.add(n);for(let n of e.notes??[])jy(n.page,t);for(let r of((n=e.skeColumnGroups)==null?void 0:n.values())??[])for(let e of r.columns)jy(e.page,t);for(let n of e.skeTables.values())for(let e of n.rows)for(let n of e.cells)jy(n,t)}let My=`univer-doc-main-canvas`;function Ny(e,t,n,r){return Se({documentFlavor:e,canvasColorService:t,editorBackgroundColor:n,isEditor:r}).canvasElementBackgroundColor}let Py=class extends t.RxDisposable{constructor(e,t){super(),this._instanceSrv=e,this._renderManagerService=t,this._init()}_init(){this._instanceSrv.getAllUnitsForType(t.UniverInstanceType.UNIVER_DOC).forEach(e=>this._createRenderer(e,this._instanceSrv.getUnitCreateOptions(e.getUnitId())??void 0)),this._instanceSrv.getTypeOfUnitAdded$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>this._createRenderer(e.unit,e.options)),this._instanceSrv.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e,t){if(t!=null&&t.skipAutoRender)return;let n=e.getUnitId();if(!this._renderManagerService.has(n)){this._createRenderWithId(n,e);return}let r=this._renderManagerService.getRenderUnitById(n);r&&this._syncRendererCanvas(r,e)}_createRenderWithId(e,t){let n=this._renderManagerService.createRender(e);t&&this._syncRendererCanvas(n,t)}_syncRendererCanvas(e,n){let r=n.getUnitId(),i=n.getSnapshot().documentStyle.documentFlavor,a=e.engine.getCanvas();a.setId(My),a.getContext().setId(My),a.getCanvasEle().style.backgroundColor=Ny(i,e.engine.canvasColorService,void 0,(0,t.isInternalEditorID)(r))}_disposeRenderer(e){let t=e.getUnitId();this._renderManagerService.removeRender(t)}};Py=B([z(0,t.IUniverInstanceService),z(1,r.IRenderManagerService)],Py);let Fy=`univer.doc.float-menu`,Iy=[ou,ur.id,Qn.id,er.id,nr.id,ir.id,or.id,cr.id,mr.id,{id:br.id,iconColor:`var(--univer-primary-600)`}];function Ly(e,t){let n=e.getMenuByPositionKey(su),r=[...e.getFlatMenuByPositionKey(su),...e.getFlatMenuByPositionKey(a.MenuManagerPosition.RIBBON)],i=[],o=t.map(e=>typeof e==`string`?e:e.id);for(let e of t){let t=typeof e==`string`?e:e.id,n=r.find(e=>e.key===t);n&&i.push(typeof e==`string`?n:{...n,iconColor:e.iconColor})}return{menus:i,extraMenus:n.filter(e=>e.item&&!o.includes(e.key))}}function Ry(e){var t,n;let{avaliableMenus:r=Iy}=e,o=(t=e.popup)==null||(t=t.extraProps)==null?void 0:t.onDismiss,s=(n=e.popup)==null||(n=n.extraProps)==null?void 0:n.onMount;(0,l.useEffect)(()=>s==null?void 0:s(),[s]);let c=(0,a.useDependency)(a.IMenuManagerService),d=(0,l.useRef)(null),f=(0,l.useRef)(!1),p=(0,l.useRef)(!1),[m,h]=(0,l.useState)([]),[g,_]=(0,l.useState)([]);(0,l.useEffect)(()=>{function e(){let{menus:e,extraMenus:t}=Ly(c,r);h(e),_(t)}e();let t=c.menuChanged$.subscribe(e);return()=>{t.unsubscribe()}},[r,c]),(0,l.useEffect)(()=>{let e=d.current;if(e)return(0,a.preventBrowserZoomInContainers)([e])},[]),(0,l.useEffect)(()=>{let e=d.current;if(!e||!o)return;let t=t=>{if(f.current||p.current||t.pointerType===`touch`)return;let n=e.getBoundingClientRect(),r=Math.max(n.left-t.clientX,t.clientX-n.right,n.top-t.clientY,t.clientY-n.bottom,0),i=Math.max(0,1-Math.max(0,r-10)/80);e.style.opacity=String(i),i===0&&(p.current=!0,o())};return e.ownerDocument.addEventListener(`pointermove`,t),()=>e.ownerDocument.removeEventListener(`pointermove`,t)},[o]);let v=()=>{f.current=!0,d.current&&(d.current.style.opacity=`1`)},y=m.filter(e=>e.key===`doc.menu.float-text-style`||e.key===ur.id),b=m.filter(e=>!y.includes(e));return(0,u.jsxs)(`div`,{ref:d,"data-doc-float-toolbar":!0,onPointerEnter:v,onFocusCapture:v,className:(0,i.clsx)(`univer-box-border univer-flex univer-flex-col univer-gap-1 univer-rounded univer-bg-gray-0 univer-p-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,i.borderClassName),children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-1 [&_.univer-toolbar-selector-root]:univer-text-xs`,children:[y.map(e=>e.item&&(0,u.jsx)(`div`,{className:e.key===`doc.menu.float-text-style`?`
41
+ `)return!0;let m,h;if(r!=null&&r.wholeDocument)m=Fa(f),h=!0;else{if(l==null)return!1;let e=za(f,l),t=e.findIndex(e=>Ga(c,e));m=e[Math.min(t+1,e.length-1)],h=m===e[e.length-1]}return o.replaceDocRanges(m,{unitId:d,subUnitId:d},!1,{wholeDocument:h}),!0}},Pa={id:`doc.command.select-word`,type:t.CommandType.COMMAND,handler:e=>{var r,i;let a=e.get(t.IUniverInstanceService),o=e.get(n.DocSelectionManagerService),s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=o.getActiveTextRange();if(!s||!(c!=null&&c.collapsed)||c.startOffset==null)return!1;let l=(r=s.getSelfOrHeaderFooterModel(c.segmentId))==null?void 0:r.getBody();if(!l)return!1;let u=(0,t.getParagraphContentStartOffsets)(l),d=(i=l.paragraphs)==null?void 0:i.find(e=>(u.get(e.startIndex)??0)<=c.startOffset&&c.startOffset<=e.startIndex);if(!d)return!1;let f=u.get(d.startIndex)??0,p=l.dataStream.slice(f,d.startIndex),m=c.startOffset-f,h=Ht(p,m,f)??Ht(p,m-1,f);if(!h)return!1;let g=s.getUnitId();return o.replaceDocRanges([{...h,rangeType:t.DOC_RANGE_TYPE.TEXT}],{unitId:g,subUnitId:g},!1),!0}};function Fa(e){return Ia(e,0,e.dataStream.length-2)}function Ia(e,t,n){let r=[...e.columnGroups??[]].sort((e,t)=>e.startIndex-t.startIndex),i=[],a=t;for(let o of r)if(!(o.endIndex<t||o.startIndex>n)){a<o.startIndex&&i.push(...La(e,a,Math.min(n,o.startIndex-1)));for(let r of Ba(e,o)){let a=Math.max(t,r.startOffset),o=Math.min(n,r.endOffset);a<=o&&i.push(...La(e,a,o))}a=o.endIndex+1}return a<=n&&i.push(...La(e,a,n)),i}function La(e,t,n){let r=[],i=t;for(let a of[...e.tables??[]].sort((e,t)=>e.startIndex-t.startIndex)){let{startIndex:o,endIndex:s}=a;o<t||s>n||(i!==o&&r.push(...Ra(e,i,o-1)),r.push(Ha(a)),i=s)}return i<=n&&r.push(...Ra(e,i,n)),r}function Ra(e,n,r){if(n>r)return[];let i=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex),a=[],o=n;for(let e of i)if(!(e.startIndex<o)){if(e.startIndex>r)break;a.push({startOffset:o,endOffset:e.startIndex,rangeType:t.DOC_RANGE_TYPE.TEXT}),o=e.startIndex+1}return o<=r&&a.push({startOffset:o,endOffset:r,rangeType:t.DOC_RANGE_TYPE.TEXT}),a}function za(e,n){let r=[],i=e=>{e!=null&&e.length&&!r.some(t=>Ga(t,e))&&r.push(e)},a=n.startOffset,o=n.endOffset;if(a==null||o==null)return[Fa(e)];let s=(e.tables??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex)),c=(e.customBlocks??[]).find(e=>e.startIndex>=a&&e.startIndex<=o),l=(e.blockRanges??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex));if(s)i([Ha(s)]);else if(c)i([{endOffset:c.startIndex,rangeType:t.DOC_RANGE_TYPE.TEXT,startOffset:c.startIndex}]);else if(l)i([{endOffset:Math.max(l.startIndex+1,l.endIndex-1),rangeType:t.DOC_RANGE_TYPE.TEXT,startOffset:l.startIndex+1}]);else{let n=Va(Ua(e,a),e.tables??[],a);i(n?[{...n,rangeType:t.DOC_RANGE_TYPE.TEXT}]:null)}let u=(e.columnGroups??[]).find(e=>Wa(a,o,e.startIndex,e.endIndex));if(u){let t=Ba(e,u).find(e=>Wa(a,o,e.startOffset,e.endOffset));t&&i(Ia(e,t.startOffset,t.endOffset)),i(Ia(e,u.startIndex,u.endIndex))}return i(Fa(e)),r}function Ba(e,n){let r=[],i;for(let a=n.startIndex;a<=n.endIndex;a++){let n=e.dataStream[a];n===t.DataStreamTreeTokenType.COLUMN_START?i=a+1:n===t.DataStreamTreeTokenType.COLUMN_END&&i!=null&&(r.push({startOffset:i,endOffset:a-1,rangeType:t.DOC_RANGE_TYPE.TEXT}),i=void 0)}return r}function Va(e,t,n){if(!e)return null;let r={...e};for(let e of t)n<e.startIndex&&r.startOffset<e.startIndex&&e.startIndex<=r.endOffset?r.endOffset=e.startIndex-1:n>=e.endIndex&&r.startOffset<=e.endIndex&&e.endIndex<r.endOffset&&(r.startOffset=e.endIndex);return r.startOffset<=r.endOffset?r:null}function Ha(e){return{startOffset:e.startIndex+3,endOffset:e.endIndex-5,rangeType:t.DOC_RANGE_TYPE.RECT}}function Ua(e,n){let r=[...e.paragraphs??[]].sort((e,t)=>e.startIndex-t.startIndex),i=(0,t.getParagraphContentStartOffsets)(e);for(let e of r){let t=i.get(e.startIndex)??0;if(t<=n&&n<=e.startIndex)return{endOffset:e.startIndex,startOffset:t}}return null}function Wa(e,t,n,r){return e>=n&&t<=r}function Ga(e,n){return e.length===n.length?e.every((e,r)=>{let i=n[r],a=qa(e)===qa(i),o=a&&qa(i)===t.DOC_RANGE_TYPE.TEXT&&!e.collapsed&&e.endOffset+1===i.endOffset;return e.startOffset===i.startOffset&&(e.endOffset===i.endOffset||o)&&a}):Ka(e,n)}function Ka(e,n){if(n.length!==1||qa(n[0])!==t.DOC_RANGE_TYPE.TEXT)return!1;let r=n[0];if(r.startOffset==null||r.endOffset==null||e.some(e=>qa(e)!==t.DOC_RANGE_TYPE.TEXT||e.startOffset==null||e.endOffset==null))return!1;let i=Math.min(...e.map(e=>e.startOffset)),a=Math.max(...e.map(e=>e.endOffset));return i===r.startOffset&&a===r.endOffset&&e.every(e=>e.startOffset>=r.startOffset&&e.endOffset<=r.endOffset)}function qa(e){return e.rangeType??t.DOC_RANGE_TYPE.TEXT}var Ja=class extends t.RxDisposable{constructor(e){super(),this._context=e,R(this,`_previousActiveRange`,null),R(this,`_previousDocRanges`,[]),R(this,`_compositionRange`,null),R(this,`_previousSelectionOptions`,null),R(this,`_undoMutationParamsCache`,[]),R(this,`_redoMutationParamsCache`,[])}clearUndoRedoMutationParamsCache(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[]}getUndoRedoMutationParamsCache(){return{undoCache:this._undoMutationParamsCache,redoCache:this._redoMutationParamsCache}}setUndoRedoMutationParamsCache({undoCache:e=[],redoCache:t=[]}){this._undoMutationParamsCache=e,this._redoMutationParamsCache=t}getActiveRange(){return this._previousActiveRange}setActiveRange(e){this._previousActiveRange=e,this._compositionRange=e}getCompositionRange(){return this._compositionRange}setCompositionRange(e){this._compositionRange=e}getPreviousDocRanges(){return this._previousDocRanges}setPreviousDocRanges(e){this._previousDocRanges=e}getPreviousSelectionOptions(){return this._previousSelectionOptions}setPreviousSelectionOptions(e){this._previousSelectionOptions=e}pushUndoRedoMutationParams(e,t){this._undoMutationParamsCache.push(e),this._redoMutationParamsCache.push(t)}fetchComposedUndoRedoMutationParams(){if(this._undoMutationParamsCache.length===0||this._previousActiveRange==null||this._redoMutationParamsCache.length===0)return null;let{unitId:e}=this._undoMutationParamsCache[0],n=this._undoMutationParamsCache[0],r=this._redoMutationParamsCache[this._redoMutationParamsCache.length-1],i={unitId:e,actions:this._undoMutationParamsCache.reverse().reduce((e,n)=>t.JSONX.compose(e,n.actions),null),textRanges:[],segmentId:n.segmentId,...n.layoutState===void 0?{}:{layoutState:n.layoutState}};return{redoMutationParams:{unitId:e,actions:this._redoMutationParamsCache.reduce((e,n)=>t.JSONX.compose(e,n.actions),null),textRanges:(r==null?void 0:r.textRanges)??[],segmentId:r==null?void 0:r.segmentId,...(r==null?void 0:r.layoutState)===void 0?{}:{layoutState:r.layoutState},options:r==null?void 0:r.options,isEditing:r==null?void 0:r.isEditing},undoMutationParams:i,previousActiveRange:this._previousActiveRange,previousDocRanges:this._previousDocRanges,previousSelectionOptions:this._previousSelectionOptions}}dispose(){this._undoMutationParamsCache=[],this._redoMutationParamsCache=[],this._previousActiveRange=null,this._previousDocRanges=[],this._compositionRange=null,this._previousSelectionOptions=null}};let Ya={id:`doc.command.ime-input`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a,o,s,c,l;let{unitId:u,newText:d,oldTextLen:f,isCompositionEnd:p,isCompositionStart:m,isCompositionCanceled:h}=i,g=e.get(t.ICommandService),_=e.get(r.IRenderManagerService),v=e.get(t.IUniverInstanceService),y=e.get(U),b=(a=_.getRenderUnitById(u))==null?void 0:a.with(Ja),x=v.getUnit(u,t.UniverInstanceType.UNIVER_DOC);if(x==null||b==null)return!1;let S=b.getCompositionRange();if(S==null)return!1;if(h){let e=b.fetchComposedUndoRedoMutationParams();if(e==null)return!0;let{undoMutationParams:t,previousActiveRange:r,previousDocRanges:i,previousSelectionOptions:a}=e,o={...t,textRanges:i.length?i:[r],options:a??void 0,noHistory:!0,trigger:Ya.id};return!!g.syncExecuteCommand(n.RichTextEditingMutation.id,o)}let{style:C,segmentId:w}=S,T=(o=x.getSelfOrHeaderFooterModel(w))==null?void 0:o.getBody();if(T==null)return!1;Object.assign(S,S);let{startOffset:E,endOffset:D}=S,O=b.getPreviousDocRanges(),k=O.filter(Xa),A=O.filter(e=>!Xa(e)),j=((s=b.getPreviousSelectionOptions())==null?void 0:s.wholeDocument)===!0,F=m&&(j||k.length>0||A.length>1),I=F?j?0:Dn(A,k):E;if(I==null)return!1;let L=d.length,R=[{startOffset:I+L,endOffset:I+L,collapsed:!0,style:C,segmentId:w}],z={id:n.RichTextEditingMutation.id,params:{unitId:u,actions:[],textRanges:R,segmentId:w,trigger:Ya.id}},B=y.getDefaultStyle(),V=y.getStyleCache(),te=F?I:E+f,ne;if(!m&&f>0){var re;ne=((re=T.customRanges)==null?void 0:re.filter(e=>!e.wholeEntity&&e.startIndex<=E&&e.endIndex>=E+f-1))??[]}else{let e=ee(T.customRanges??[],te,t.SHEET_EDITOR_UNITS.includes(u));ne=e?[e]:[]}let H=m&&!F?N(T,{startOffset:E,endOffset:D},B,V,t.SHEET_EDITOR_UNITS.includes(u),((c=Be(x))==null?void 0:c.inheritParagraphStartStyle)===!0):M(T,F?I:E+f,B,V,t.SHEET_EDITOR_UNITS.includes(u),((l=Be(x))==null?void 0:l.inheritParagraphStartStyle)===!0),ie=P(T.customDecorations??[],te),W={dataStream:d,textRuns:H?[{...H,st:0,ed:d.length}]:[],customRanges:ne.map(e=>({...e,startIndex:0,endIndex:d.length-1})),customDecorations:ie.map(e=>({...e,startIndex:0,endIndex:d.length-1}))},ae=new t.TextX,oe=t.JSONX.getInstance();if(F){var se;let e=(se=_.getRenderUnitById(u))==null?void 0:se.with(n.DocSkeletonManagerService);if(!e)return!1;let t=En(A,k,x,e.getViewModel(),w??``,W,j);if(!t)return!1;I=t.insertOffset,z.params.actions=t.actions,z.params.textRanges=[{startOffset:I+L,endOffset:I+L,collapsed:!0,style:C,segmentId:w}]}else if(!S.collapsed&&m){let e=t.BuildTextUtils.selection.delete([S],T,0,null,!1);ae.push(...e),z.params.textRanges=[{startOffset:I+L,endOffset:I+L,collapsed:!0,segmentId:w}]}else ae.push({t:t.TextXActionType.RETAIN,len:E});if(!F&&f>0&&ae.push({t:t.TextXActionType.DELETE,len:f}),F||ae.push({t:t.TextXActionType.INSERT,body:W,len:d.length}),!F){let e=(0,t.getRichTextEditPath)(x,w);z.params.actions=oe.editOp(ae.serialize(),e)}z.params.noHistory=!p,z.params.isCompositionEnd=p;let ce=g.syncExecuteCommand(z.id,z.params);return b.pushUndoRedoMutationParams(ce,z.params),F&&b.setCompositionRange({...S,startOffset:I,endOffset:I,collapsed:!0}),!!ce}};function Xa(e){return`tableId`in e}let Za={id:`doc.command.insert-custom-range`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.ICommandService),{unitId:a,rangeId:o=(0,t.generateRandomId)(),textRanges:s,properties:c,text:l,wholeEntity:u}=r,d={unitId:a,historyAction:n.DocHistoryAction.InsertCustomRange,textRanges:s,body:{dataStream:l,customRanges:[{startIndex:0,endIndex:l.length-1,rangeId:o,rangeType:t.CustomRangeType.CUSTOM,properties:c,wholeEntity:u}]}};return i.syncExecuteCommand(Ne.id,d)}},Qa={id:`doc.command.list-operation`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),l=r.listType,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=r.docRange??o.getDocRanges()??[];if(u==null||d.length===0)return!1;let f=d[0].segmentId,p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(!m.length)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d,isEditing:!1}};new t.MemoryCursor().reset();let y=t.BuildTextUtils.paragraph.bullet.switch({paragraphs:g,listType:l,document:u,segmentId:f}),b=t.JSONX.getInstance(),x=(0,t.getRichTextEditPath)(u,f);return v.params.actions=b.editOp(y.serialize(),x),!!c.syncExecuteCommand(v.id,v.params)}},$a={id:`doc.command.change-list-type`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),{listType:l}=r,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=r.docRange??o.getDocRanges();if(u==null||d==null||!d.length)return!1;let{segmentId:f}=d[0],p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(!m.length)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v=t.BuildTextUtils.paragraph.bullet.set({paragraphs:g,listType:l,segmentId:f,document:u});if(!v)return!1;let y=t.JSONX.getInstance(),b={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d,isEditing:!1}},x=(0,t.getRichTextEditPath)(u,f);return b.params.actions=y.editOp(v.serialize(),x),!!c.syncExecuteCommand(b.id,b.params)}},eo=function(e){return e[e.increase=1]=`increase`,e[e.decrease=-1]=`decrease`,e}({}),to={id:`doc.command.change-list-nesting-level`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!r)return!1;let{type:o}=r,s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(t.ICommandService),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(u==null||d==null)return!1;let{segmentId:f}=d,p=s.getDocRanges()??[],m=u.getSelfOrHeaderFooterModel(f),h=(m==null||(i=m.getBody())==null?void 0:i.paragraphs)??[],g=(m==null||(a=m.getBody())==null?void 0:a.dataStream)??``;if(!h.length)return!1;let _=t.BuildTextUtils.range.getParagraphsInRange(d,h,g),v=u.getUnitId(),y=t.JSONX.getInstance(),b=t.BuildTextUtils.paragraph.bullet.changeNestLevel({paragraphs:_,type:o,segmentId:f,document:u}),x={id:n.RichTextEditingMutation.id,params:{unitId:v,actions:[],textRanges:p,isEditing:!1}},S=(0,t.getRichTextEditPath)(u,f);return x.params.actions=y.editOp(b.serialize(),S),!!l.syncExecuteCommand(x.id,x.params)}},no={id:`doc.command.bullet-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.BULLET_LIST,docRange:n==null?void 0:n.docRange})}},ro={id:`doc.command.check-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.CHECK_LIST,docRange:n==null?void 0:n.docRange})}},io={id:`doc.command.toggle-check-list`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i;if(!r)return!1;let a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),{index:s,segmentId:c,textRanges:l}=r,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(u==null||((i=u.getSelfOrHeaderFooterModel(c))==null||(i=i.getBody())==null?void 0:i.paragraphs)==null)return!1;let d=u.getUnitId(),f={id:n.RichTextEditingMutation.id,params:{unitId:d,actions:[],textRanges:l??[],segmentId:c,isEditing:!1}},p=t.BuildTextUtils.paragraph.bullet.toggleChecklist({document:u,paragraphIndex:s,segmentId:c});if(!p)return!1;let m=t.JSONX.getInstance(),h=(0,t.getRichTextEditPath)(u,c);return f.params.actions=m.editOp(p.serialize(),h),!!o.syncExecuteCommand(f.id,f.params)}},ao={id:`doc.command.order-list`,type:t.CommandType.COMMAND,handler:(e,n)=>{let r=e.get(t.ICommandService);return n!=null&&n.value?r.syncExecuteCommand($a.id,{listType:n.value,docRange:n.docRange}):r.syncExecuteCommand(Qa.id,{listType:t.PresetListType.ORDER_LIST,docRange:n==null?void 0:n.docRange})}},oo={id:`doc.command.quick-list`,type:t.CommandType.COMMAND,handler(e,r){var i;if(!r)return!1;let a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),s=e.get(t.ICommandService),c=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=a.getActiveTextRange();if(c==null||l==null)return!1;let{segmentId:u,startOffset:d}=l,{listType:f,paragraph:p}=r,{paragraphStart:m,paragraphEnd:h}=p,g=new t.TextX,_=t.JSONX.getInstance(),{paragraphStyle:v={}}=p,y=(t.PRESET_LIST_TYPE[f].nestingLevel[0].paragraphProperties||{}).textStyle,b=(0,t.generateRandomId)(6),x=((i=c.getBody())==null?void 0:i.paragraphs)??[],S=x.findIndex(e=>e.startIndex===p.startIndex),C=x[S-1],w=x[S+1];C&&C.bullet&&C.bullet.listType.indexOf(f)===0?b=C.bullet.listId:w&&w.bullet&&w.bullet.listType.indexOf(f)===0&&(b=w.bullet.listId);let T={id:n.RichTextEditingMutation.id,params:{unitId:c.getUnitId(),actions:[],textRanges:[{startOffset:m,endOffset:m,collapsed:!0}],isEditing:!1}};g.push({t:t.TextXActionType.RETAIN,len:m}),g.push({t:t.TextXActionType.DELETE,len:d-m}),h>d&&g.push({t:t.TextXActionType.RETAIN,len:h-d}),g.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{startIndex:0,paragraphId:p.paragraphId,paragraphStyle:{...v,textStyle:{...v.textStyle,...y},indentFirstLine:void 0},bullet:{...p.bullet??{nestingLevel:0},listType:f,listId:b}}]}});let E=(0,t.getRichTextEditPath)(c,u);return T.params.actions=_.editOp(g.serialize(),E),!!s.syncExecuteCommand(T.id,T.params)}};function so(e,r,i){let a=e.get(t.ICommandService),o=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!o)return!1;let s=null;try{s=e.get(n.DocContentInsertService).consumeInsertRange(o.getUnitId())}catch{s=null}let c=s?null:Fn(e);if(!s&&!c)return!1;let l=c||void 0,u=(s==null?void 0:s.startOffset)??l.startIndex+1,d=l==null?void 0:l.bullet,f=t.BuildTextUtils.selection.replace({doc:o,selection:{startOffset:u,endOffset:(s==null?void 0:s.endOffset)??u,collapsed:!0},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:(0,t.createParagraphId)(new Set),paragraphStyle:{...(l==null?void 0:l.paragraphStyle)??{}},bullet:{listType:r,listId:(d==null?void 0:d.listType)===r?d.listId:(0,t.generateRandomId)(6),nestingLevel:(d==null?void 0:d.listType)===r?d.nestingLevel:0}}]}});if(!f)return!1;let p={id:n.RichTextEditingMutation.id,params:{unitId:o.getUnitId(),actions:[],textRanges:[{startOffset:u,endOffset:u,collapsed:!0}],isEditing:!1,trigger:i}},m=t.JSONX.getInstance(),h=(0,t.getRichTextEditPath)(o);return p.params.actions=m.editOp(f.serialize(),h),!!a.syncExecuteCommand(p.id,p.params)}let co={id:`doc.command.insert-bullet-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.BULLET_LIST,co.id)},lo={id:`doc.command.insert-order-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.ORDER_LIST,lo.id)},uo={id:`doc.command.insert-check-list-bellow`,type:t.CommandType.COMMAND,handler:e=>so(e,t.PresetListType.CHECK_LIST,uo.id)},fo={id:`doc.command.align-action`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;let o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),{alignType:l}=r,u=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(u==null)return!1;let d=o.getDocRanges();if(d.length===0)return!1;let f=d[0].segmentId,p=u.getSelfOrHeaderFooterModel(f),m=(p==null||(i=p.getBody())==null?void 0:i.paragraphs)??[],h=(p==null||(a=p.getBody())==null?void 0:a.dataStream)??``;if(m==null)return!1;let g=t.BuildTextUtils.range.getParagraphsInRanges(d,m,h),_=u.getUnitId(),v=g.every(e=>{var t;return((t=e.paragraphStyle)==null?void 0:t.horizontalAlign)===l}),y={id:n.RichTextEditingMutation.id,params:{unitId:_,actions:[],textRanges:d}},b=new t.MemoryCursor;b.reset();let x=new t.TextX,S=t.JSONX.getInstance();for(let e of g){let{startIndex:n}=e;x.push({t:t.TextXActionType.RETAIN,len:n-b.cursor});let r={...e.paragraphStyle,horizontalAlign:v?t.HorizontalAlign.UNSPECIFIED:l};x.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...e,paragraphStyle:r,startIndex:0}]},coverType:t.UpdateDocsAttributeType.REPLACE}),b.moveCursorTo(n+1)}let C=(0,t.getRichTextEditPath)(u,f);return y.params.actions=S.editOp(x.serialize(),C),!!c.syncExecuteCommand(y.id,y.params)}},po={id:`doc.command.align-left`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.LEFT})},mo={id:`doc.command.align-center`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.CENTER})},ho={id:`doc.command.align-right`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.RIGHT})},go={id:`doc.command.align-justify`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(fo.id,{alignType:t.HorizontalAlign.JUSTIFIED})},_o=(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r==null||r.setZoomRatio(n.zoomRatio),{...n}},vo={id:`doc.operation.set-zoom-ratio`,type:t.CommandType.OPERATION,handler:(e,n)=>{let r=e.get(t.IUniverInstanceService).getUnit(n.unitId,t.UniverInstanceType.UNIVER_DOC);return r?(r.setZoomRatio(n.zoomRatio),!0):!1}},yo={type:t.CommandType.COMMAND,id:`doc.command.set-zoom-ratio`,handler:async(e,n)=>{let r=e.get(t.ICommandService),i=e.get(t.IUndoRedoService),a=e.get(t.IUniverInstanceService),{zoomRatio:o=1,documentId:s}=n||{},c=s?a.getUnit(s,t.UniverInstanceType.UNIVER_DOC):a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!c)return!1;let l=c.getUnitId(),u={zoomRatio:o,unitId:l},d=_o(e,u);return r.syncExecuteCommand(vo.id,u)?(i.pushUndoRedo({unitID:l,undoMutations:[{id:vo.id,params:d}],redoMutations:[{id:vo.id,params:u}]}),!0):!1}};function bo(e){if(e>=t.NamedStyleType.HEADING_1&&e<=t.NamedStyleType.HEADING_5)return e-t.NamedStyleType.HEADING_1}let xo={id:`doc.command.set-paragraph-named-style`,type:t.CommandType.COMMAND,handler(e,r){if(!r)return!1;let i=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!i)return!1;let a=i.getUnitId(),o=e.get(n.DocSelectionManagerService),s=r.textRanges?null:(0,n.consumeContentInsertRange)(e,a);if(s)return So(e,i,r.value,s.startOffset,s.endOffset,s.segmentId);let c=r.textRanges??o.getTextRanges({unitId:a,subUnitId:a});if(!(c!=null&&c.length))return!1;let l=c[0].segmentId,u=i.getSelfOrHeaderFooterModel(l);if(!u)return!1;let d=t.BuildTextUtils.paragraph.style.set({document:u,textRanges:c,style:{namedStyleType:r.value,headingId:!r.value||r.value===t.NamedStyleType.NORMAL_TEXT?void 0:(0,t.generateRandomId)(6),outlineLevel:bo(r.value),spaceAbove:void 0,spaceBelow:void 0,lineSpacing:void 0,spacingRule:void 0},paragraphTextRun:{}}),f={id:n.RichTextEditingMutation.id,params:{actions:[],textRanges:c,unitId:a,segmentId:l}},p=t.JSONX.getInstance(),m=(0,t.getRichTextEditPath)(i,l);return f.params.actions=p.editOp(d.serialize(),m),!!e.get(t.ICommandService).syncExecuteCommand(f.id,f.params)}};function So(e,r,i,a,o,s=``){let c=t.BuildTextUtils.selection.replace({doc:r,selection:{startOffset:a,endOffset:o,collapsed:a===o,segmentId:s},body:{dataStream:`\r`,paragraphs:[{startIndex:0,paragraphId:(0,t.createParagraphId)(new Set),paragraphStyle:{namedStyleType:i,headingId:!i||i===t.NamedStyleType.NORMAL_TEXT?void 0:(0,t.generateRandomId)(6),outlineLevel:bo(i)}}]}});if(!c)return!1;let l=t.JSONX.getInstance(),u=!!e.get(t.ICommandService).syncExecuteCommand(n.RichTextEditingMutation.id,{actions:l.editOp(c.serialize(),(0,t.getRichTextEditPath)(r,s)),isEditing:!1,textRanges:[{startOffset:a,endOffset:a,collapsed:!0}],segmentId:s,unitId:r.getUnitId()});return u&&e.get(n.DocSelectionManagerService).replaceDocRanges([{startOffset:a,endOffset:a}],void 0,!1),u}let Co={id:`doc.command.quick-heading`,type:t.CommandType.COMMAND,handler(e,r){var i,a;if(!r)return!1;let{value:o}=r,s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(t.ICommandService),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(u==null||d==null||!d.collapsed)return!1;let{segmentId:f,startOffset:p}=d,m=u.getSelfOrHeaderFooterModel(f),h=(m==null||(i=m.getBody())==null?void 0:i.paragraphs)??[],g=(m==null||(a=m.getBody())==null?void 0:a.dataStream)??``,_=t.BuildTextUtils.paragraph.util.getParagraphsInRange(d,h,g)[0];if(!_)return!1;let{paragraphStart:v}=_,y=new t.TextX,b=t.JSONX.getInstance(),{paragraphStyle:x={}}=_,S={id:n.RichTextEditingMutation.id,params:{unitId:u.getUnitId(),actions:[],textRanges:[{startOffset:v,endOffset:v,collapsed:!0}],isEditing:!1}};y.push({t:t.TextXActionType.RETAIN,len:v}),t.BuildTextUtils.paragraph.style.set({textRanges:[d],document:u,style:{...x,headingId:(0,t.generateRandomId)(6),namedStyleType:o,outlineLevel:bo(o),lineSpacing:void 0,spacingRule:void 0},cursor:p,deleteLen:p-v,textX:y,paragraphTextRun:{}});let C=(0,t.getRichTextEditPath)(u,f);return S.params.actions=b.editOp(y.serialize(),C),!!l.syncExecuteCommand(S.id,S.params)}},wo={"#":t.NamedStyleType.HEADING_1,"##":t.NamedStyleType.HEADING_2,"###":t.NamedStyleType.HEADING_3,"####":t.NamedStyleType.HEADING_4,"#####":t.NamedStyleType.HEADING_5},To={id:`doc.command.h1-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_1})},Eo={id:`doc.command.h2-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_2})},Do={id:`doc.command.h3-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_3})},Oo={id:`doc.command.h4-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_4})},ko={id:`doc.command.h5-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.HEADING_5})},Ao={id:`doc.command.normal-text-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.NORMAL_TEXT})},jo={id:`doc.command.title`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.TITLE})},Mo={id:`doc.command.subtitle-heading`,type:t.CommandType.COMMAND,handler:e=>e.get(t.ICommandService).syncExecuteCommand(xo.id,{value:t.NamedStyleType.SUBTITLE})},No={id:`doc.command.switch-mode`,type:t.CommandType.COMMAND,handler:e=>{var i,a;let o=e.get(t.ICommandService),s=e.get(r.IRenderManagerService),c=e.get(n.DocSelectionManagerService),l=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null)return!1;let u=l.getUnitId(),d=(i=s.getRenderUnitById(u))==null?void 0:i.with(n.DocSkeletonManagerService).getSkeleton(),f=(a=s.getRenderUnitById(u))==null?void 0:a.with(q);if(d==null||f==null)return!1;let p=f==null?void 0:f.getSegment(),m=f==null?void 0:f.getSegmentPage(),h=l.getSnapshot().documentStyle.documentFlavor,g=c.getDocRanges(),_={id:n.RichTextEditingMutation.id,params:{unitId:u,actions:[],textRanges:h===t.DocumentFlavor.TRADITIONAL&&p?[]:g}},v=t.JSONX.getInstance(),y=[],b;if(b=h===void 0?v.insertOp([`documentStyle`,`documentFlavor`],t.DocumentFlavor.MODERN):h===t.DocumentFlavor.MODERN?v.replaceOp([`documentStyle`,`documentFlavor`],h,t.DocumentFlavor.TRADITIONAL):v.replaceOp([`documentStyle`,`documentFlavor`],h,t.DocumentFlavor.MODERN),b)y.push(b);else return!1;if(h!==t.DocumentFlavor.MODERN){let{drawings:e={},body:n}=l.getSnapshot(),r=(n==null?void 0:n.customBlocks)??[];for(let n in e){var x,S;let i=e[n],a=r.find(e=>e.blockId===n);if(a==null)continue;let o=i.docTransform.positionV,{relativeFrom:s,posOffset:c}=o;if(s===t.ObjectRelativeFromV.PARAGRAPH)continue;let{startIndex:l}=a,u=d.findNodeByCharIndex(l,p,m),f=u==null||(x=u.parent)==null?void 0:x.parent,h=f==null?void 0:f.parent,g=h==null?void 0:h.lines.find(e=>e.paragraphIndex===(f==null?void 0:f.paragraphIndex)&&e.paragraphStart),_=h==null||(S=h.parent)==null?void 0:S.parent;if(u==null||f==null||g==null||h==null||_==null)continue;let b=0;s===t.ObjectRelativeFromV.LINE?b-=f.top:s===t.ObjectRelativeFromV.PAGE&&(b+=_.marginTop),b+=g.top;let C={...o,relativeFrom:t.ObjectRelativeFromV.PARAGRAPH,posOffset:(c??0)-b},w=v.replaceOp([`drawings`,n,`docTransform`,`positionV`],o,C);w&&y.push(w)}}return _.params.actions=y.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(_.id,_.params)}};function Po(e){let{tableDataStream:n,tableParagraphs:r,sectionBreaks:i,tableId:a,textRun:o}=e,s=e.existingParagraphIds??new Set(r.map(e=>e.paragraphId)),c=`${n}${t.DataStreamTreeTokenType.PARAGRAPH}`,l=n.length;return{dataStream:c,paragraphs:[...r,{startIndex:l,paragraphId:(0,t.createParagraphId)(s)}],sectionBreaks:i,textRuns:[{...o,st:0,ed:l}],tables:[{startIndex:0,endIndex:l,tableId:a}]}}function Fo(e,n){return n<=0||e.dataStream[n-1]!==t.DataStreamTreeTokenType.PARAGRAPH}function Io(e,n){return n===0&&e.dataStream[0]===t.DataStreamTreeTokenType.PARAGRAPH?1:n}function Lo(e,t){return!(Ro(e.tables,t)||zo(e.blockRanges,t)||Bo(e.customBlocks,t))}function Ro(e,n){return!!(e!=null&&e.some(e=>(0,t.containsInteriorInsertionOffset)((0,t.getTableRangeInterval)(e),n)))}function zo(e,n){return!!(e!=null&&e.some(e=>(0,t.containsInteriorInsertionOffset)((0,t.getBlockRangeInterval)(e),n)))}function Bo(e,t){return!!(e!=null&&e.some(e=>e.startIndex===t))}let Vo={id:`doc.command.create-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i,a,o;let{rowCount:s,colCount:c}=r,l=e.get(n.DocSelectionManagerService),u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=e.get(U),p=u.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(p==null)return!1;let m=null;try{m=e.get(n.DocContentInsertService).consumeInsertRange(p.getUnitId())}catch{m=null}let h=l.getActiveTextRange();if(h==null&&m==null)return!1;let g=(m==null?void 0:m.segmentId)??(h==null?void 0:h.segmentId)??``,_=h==null?void 0:h.segmentPage,v=p==null||(i=p.getSelfOrHeaderFooterModel(g))==null?void 0:i.getBody();if(v==null)return!1;let y=p.getUnitId(),b=Te(e,y),x=b==null?void 0:b.getSkeleton();if(x==null)return!1;let S=Io(v,(m==null?void 0:m.startOffset)??h.startOffset);if(!Lo(v,S))return!1;let C=(v.paragraphs??[]).find(e=>(0,t.getParagraphContentStartOffset)(v,e)<S&&S<=e.startIndex),w=x.findNodeByCharIndex(S,g,_);if(w==null)return!1;let T=Fo(v,S),E=new t.TextX,D=t.JSONX.getInstance(),O=[],k=S+(T?4:3),A=[{startOffset:k,endOffset:k,collapsed:!0}],M={id:n.RichTextEditingMutation.id,params:{unitId:y,actions:[],textRanges:A}};S>0&&E.push({t:t.TextXActionType.RETAIN,len:S}),T&&E.push({t:t.TextXActionType.INSERT,body:{dataStream:t.DataStreamTreeTokenType.PARAGRAPH,paragraphs:(0,n.generateParagraphs)(t.DataStreamTreeTokenType.PARAGRAPH,C)},len:1});let N=j(v,S,f.getDefaultStyle(),f.getStyleCache()),{dataStream:ee,paragraphs:P,sectionBreaks:F}=qt(s,c),I=(a=w.parent)==null||(a=a.parent)==null||(a=a.parent)==null||(a=a.parent)==null?void 0:a.parent;if(I==null)return!1;let{pageWidth:L,marginLeft:R,marginRight:z}=I,B=Zt(s,c,L-R-z),V=Po({tableDataStream:ee,tableParagraphs:P,sectionBreaks:F,tableId:B.tableId,textRun:N,existingParagraphIds:new Set((o=v.paragraphs)==null?void 0:o.map(e=>e.paragraphId))});E.push({t:t.TextXActionType.INSERT,body:V,len:V.dataStream.length});let te=(0,t.getRichTextEditPath)(p,g);O.push(D.editOp(E.serialize(),te));let ne=D.insertOp([`tableSource`,B.tableId],B);return O.push(ne),M.params.actions=O.reduce((e,n)=>t.JSONX.compose(e,n),null),!!d.syncExecuteCommand(M.id,M.params)}},Ho={id:`doc.table.delete-rows`,type:t.CommandType.COMMAND,handler:async e=>{var r;let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=i.getRectRanges(),c=Qt(i.getActiveTextRange(),s);if(c==null)return!1;let{segmentId:l}=c,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=u==null||(r=u.getSelfOrHeaderFooterModel(l))==null?void 0:r.getBody();if(u==null||d==null)return!1;let f=Te(e,u.getUnitId());if(f==null)return!1;let p=f.getViewModel(),m=u==null?void 0:u.getUnitId(),h=new t.TextX,g=t.JSONX.getInstance(),_=on(c,p);if(_==null)return!1;let{offset:v,rowIndexes:y,len:b,tableId:x,cursor:S,selectWholeTable:C}=_;if(C)return o.executeCommand(Wo.id);let w=[],T=[{startOffset:S,endOffset:S,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:T,segmentId:l,trigger:Ho.id}};v>0&&h.push({t:t.TextXActionType.RETAIN,len:v}),h.push({t:t.TextXActionType.DELETE,len:b});let D=(0,t.getRichTextEditPath)(u,l);w.push(g.editOp(h.serialize(),D));for(let e of y.reverse()){let t=g.removeOp([`tableSource`,x,`tableRows`,e]);w.push(t)}return E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(E.id,E.params)}},Uo={id:`doc.table.delete-columns`,type:t.CommandType.COMMAND,handler:async e=>{var r;let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=i.getRectRanges(),c=Qt(i.getActiveTextRange(),s);if(c==null)return!1;let{segmentId:l}=c,u=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=u==null||(r=u.getSelfOrHeaderFooterModel(l))==null?void 0:r.getBody();if(u==null||d==null)return!1;let f=Te(e,u.getUnitId());if(f==null)return!1;let p=f.getViewModel(),m=u==null?void 0:u.getUnitId(),h=new t.TextX,g=t.JSONX.getInstance(),_=sn(c,p);if(_==null)return!1;let{offsets:v,columnIndexes:y,tableId:b,cursor:x,rowCount:S,selectWholeTable:C}=_;if(C)return o.executeCommand(Wo.id);let w=[],T=[{startOffset:x,endOffset:x,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:m,actions:[],textRanges:T,segmentId:l,trigger:Uo.id}};for(let e of v){let{retain:n,delete:r}=e;n>0&&h.push({t:t.TextXActionType.RETAIN,len:n}),h.push({t:t.TextXActionType.DELETE,len:r})}let D=(0,t.getRichTextEditPath)(u,l);w.push(g.editOp(h.serialize(),D)),y.reverse();for(let e=0;e<S;e++)for(let t of y){let n=g.removeOp([`tableSource`,b,`tableRows`,e,`tableCells`,t]);w.push(n)}for(let e of y){let t=g.removeOp([`tableSource`,b,`tableColumns`,e]);w.push(t)}return E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!o.syncExecuteCommand(E.id,E.params)}},Wo={id:`doc.table.delete-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i;let a=e.get(n.DocSelectionManagerService),o=e.get(t.IUniverInstanceService),s=e.get(t.ICommandService),c=a.getRectRanges(),l=a.getActiveTextRange(),u=Qt((r==null?void 0:r.targetRange)??l,r!=null&&r.targetRange?[]:c);if(u==null)return!1;let{segmentId:d}=u,f=r!=null&&r.unitId?o.getUnit(r.unitId,t.UniverInstanceType.UNIVER_DOC):o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=f==null||(i=f.getSelfOrHeaderFooterModel(d))==null?void 0:i.getBody();if(f==null||p==null)return!1;let m=Te(e,f.getUnitId());if(m==null)return!1;let h=m.getViewModel(),g=f==null?void 0:f.getUnitId(),_=new t.TextX,v=t.JSONX.getInstance(),y=cn(u,h);if(y==null)return!1;let{offset:b,len:x,tableId:S,cursor:C}=y,w=[],T=[{startOffset:C,endOffset:C,collapsed:!0}],E={id:n.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:T,segmentId:d,trigger:Wo.id}};b>0&&_.push({t:t.TextXActionType.RETAIN,len:b}),_.push({t:t.TextXActionType.DELETE,len:x});let D=(0,t.getRichTextEditPath)(f,d);w.push(v.editOp(_.serialize(),D));let O=v.removeOp([`tableSource`,S]);return w.push(O),E.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!s.syncExecuteCommand(E.id,E.params)}},Go=`doc.command.table-insert-row`,Ko=`doc.command.table-insert-column`,qo={id:`doc.command.table-insert-row-above`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Go,{position:0})},Jo={id:`doc.command.table-insert-row-bellow`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Go,{position:1})},Yo={id:`doc.command.table-insert-column-left`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Ko,{position:0})},Xo={id:`doc.command.table-insert-column-right`,type:t.CommandType.COMMAND,handler:async e=>e.get(t.ICommandService).executeCommand(Ko,{position:1})},Zo={id:Go,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i;let{position:a}=r,o=e.get(n.DocSelectionManagerService),s=e.get(t.IUniverInstanceService),c=e.get(t.ICommandService),l=o.getRectRanges(),u=Qt(o.getActiveTextRange(),l);if(u==null)return!1;let{segmentId:d}=u,f=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),p=f==null||(i=f.getSelfOrHeaderFooterModel(d))==null?void 0:i.getBody();if(f==null||p==null)return!1;let m=Te(e,f.getUnitId());if(m==null)return!1;let h=m.getViewModel(),g=f==null?void 0:f.getUnitId(),_=new t.TextX,v=t.JSONX.getInstance(),y=nn(u,a,h);if(y==null)return!1;let{offset:b,colCount:x,tableId:S,insertRowIndex:C}=y,w=[],T=b+2,E=[{startOffset:T,endOffset:T,collapsed:!0}],D={id:n.RichTextEditingMutation.id,params:{unitId:g,actions:[],textRanges:E}};b>0&&_.push({t:t.TextXActionType.RETAIN,len:b});let O=en(x);_.push({t:t.TextXActionType.INSERT,body:O,len:O.dataStream.length});let k=(0,t.getRichTextEditPath)(f,d);w.push(v.editOp(_.serialize(),k));let A=Yt(x),j=v.insertOp([`tableSource`,S,`tableRows`,C],A);return w.push(j),D.params.actions=w.reduce((e,n)=>t.JSONX.compose(e,n),null),!!c.syncExecuteCommand(D.id,D.params)}},Qo={id:Ko,type:t.CommandType.COMMAND,handler:async(e,r)=>{var i,a,o;let{position:s}=r,c=e.get(n.DocSelectionManagerService),l=e.get(t.IUniverInstanceService),u=e.get(t.ICommandService),d=c.getRectRanges(),f=Qt(c.getActiveTextRange(),d);if(f==null)return!1;let{segmentId:p}=f,m=l.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),h=m==null||(i=m.getSelfOrHeaderFooterModel(p))==null?void 0:i.getBody();if(m==null||h==null)return!1;let g=Te(e,m.getUnitId());if(g==null)return!1;let _=g.getViewModel(),v=m==null?void 0:m.getUnitId(),y=new t.TextX,b=t.JSONX.getInstance(),x=rn(f,s,_);if(x==null)return!1;let{offsets:S,columnIndex:C,tableId:w,rowCount:T}=x,E=[],D=S[0]+1,O=[{startOffset:D,endOffset:D,collapsed:!0}],k={id:n.RichTextEditingMutation.id,params:{unitId:v,actions:[],textRanges:O}};for(let e of S){y.push({t:t.TextXActionType.RETAIN,len:e});let n=tn();y.push({t:t.TextXActionType.INSERT,body:n,len:n.dataStream.length})}let A=(0,t.getRichTextEditPath)(m,p);E.push(b.editOp(y.serialize(),A));for(let e=0;e<T;e++){let t=Jt(),n=b.insertOp([`tableSource`,w,`tableRows`,e,`tableCells`,C],t);E.push(n)}let j=m.getSnapshot(),M=j.documentStyle,{marginLeft:N=0,marginRight:ee=0}=M,P=j==null||(a=j.tableSource)==null||(a=a[w])==null?void 0:a.tableColumns;if(!P)return!1;let F=(((o=M.pageSize)==null?void 0:o.width)??800)-N-ee,I=P.reduce((e,t)=>e+t.size.width.v,0),{newColWidth:L,widths:R}=an(I>0?I:F,P,C);for(let e=0;e<R.length;e++){let t=b.replaceOp([`tableSource`,w,`tableColumns`,e,`size`,`width`,`v`],P[e].size.width.v,R[e]);E.push(t)}let z=Xt(L),B=b.insertOp([`tableSource`,w,`tableColumns`,C],z);return E.push(B),k.params.actions=E.reduce((e,n)=>t.JSONX.compose(e,n),null),!!u.syncExecuteCommand(k.id,k.params)}},$o={id:`doc.table.tab-in-table`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let{shift:i}=r,a=e.get(n.DocSelectionManagerService),o=a.getDocRanges(),s=e.get(t.ICommandService),c=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!c)return!1;let l=o.find(e=>e.isActive)??o[0],u=Te(e,c.getUnitId()),d=u==null?void 0:u.getSkeleton(),f=d==null?void 0:d.getViewModel().getSelfOrHeaderFooterViewModel(l==null?void 0:l.segmentId);if(f==null||l==null)return!1;let p=null;if(p=i?un(f,l,1):un(f,l,0),p){let{startOffset:e,endOffset:t}=p,n=[{startOffset:e,endOffset:t}];return a.replaceDocRanges(n),!0}return i!==!1||await s.executeCommand(Zo.id,{position:1})}},es=`COMPONENT_DOC_CREATE_TABLE_CONFIRM`,ts=`doc.component.create-table-confirm`,ns={id:`doc.operation.create-table`,type:t.CommandType.COMMAND,handler:async e=>{let n=e.get(t.LocaleService),r=e.get(t.IConfirmService),i=e.get(t.ICommandService),a={rowCount:3,colCount:5};return await r.open({id:ts,children:{label:{name:es,props:{handleRowColChange:(e,t)=>{a.rowCount=e,a.colCount=t},tableCreateParams:a}}},width:`auto`,title:{title:n.t(`docs-ui.toolbar.table.insert`)},onConfirm:()=>{i.executeCommand(Vo.id,a),r.close(ts)},onClose:()=>{r.close(ts)}}),!0}},rs={id:`doc.operation.move-cursor`,type:t.CommandType.OPERATION,handler:(e,t)=>!!t},is={id:`doc.operation.move-selection`,type:t.CommandType.OPERATION,handler:(e,t)=>!!t},as=`docs-ui.config`,os=`DOC_UI_PLUGIN`,ss={mode:`none`,target:`viewport`,paddingX:20,minScale:1,maxScale:void 0,align:`center`},cs={toc:!1,footer:!0,wordCount:!0,placeholder:!0,fitToWidth:ss},ls={...cs,fitToWidth:{...ss,mode:`fit-width`,paddingX:12,minScale:0,maxScale:1}},us=1.5,ds=class extends t.RxDisposable{constructor(e,t,n,r){super(),this._context=e,this._textSelectionManagerService=t,this._editorService=n,this._docSkeletonManagerService=r,R(this,`_pendingSelectionScrollFrame`,null),R(this,`_suppressedSelection`,null),R(this,`_pendingExplicitRange`,null),R(this,`_selectionBeforeExplicitRange`,null),R(this,`_scrollingToRange`,!1),this._init()}_init(){let e=this._context.scene.getViewport(`viewMain`);if(e!=null){let t=e.viewportScrollX,n=e.viewportScrollY;this.disposeWithMe(e.onScrollAfter$.subscribeEvent(e=>{let r=e.viewportScrollX!==t||e.viewportScrollY!==n;t=e.viewportScrollX,n=e.viewportScrollY,r&&!this._scrollingToRange&&this._suspendSelectionScroll()}))}this.disposeWithMe(this._context.scene.onPointerDown$.subscribeEvent(()=>this._suspendSelectionScroll())),this._textSelectionManagerService.textSelection$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;let{isEditing:n,unitId:r}=e,i=e.textRanges.find(e=>e.isActive);if(r!==this._context.unitId)return;if(!n){if(this._ownsPendingExplicitRange(i))return;this._suspendSelectionScroll();return}if(this._context.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY||this._ownsPendingExplicitRange(i))return;this._clearExplicitRangeOwnership();let a=this._suppressedSelection;(i==null||a==null||i.startOffset!==a.startOffset||i.endOffset!==a.endOffset||(i.segmentId??``)!==(a.segmentId??``)||(i.segmentPage??-1)!==(a.segmentPage??-1))&&(this._suppressedSelection=null,this._scheduleScrollToSelection())})}dispose(){this._cancelPendingSelectionScroll(),this._suppressedSelection=null,this._clearExplicitRangeOwnership(),super.dispose()}_suspendSelectionScroll(){this._cancelPendingSelectionScroll(),this._clearExplicitRangeOwnership();let e=this._textSelectionManagerService.getActiveTextRange();this._suppressedSelection=e==null?null:{startOffset:e.startOffset,endOffset:e.endOffset,collapsed:e.collapsed,segmentId:e.segmentId,segmentPage:e.segmentPage}}_cancelPendingSelectionScroll(){this._pendingSelectionScrollFrame!=null&&typeof cancelAnimationFrame<`u`&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=null}_scheduleScrollToSelection(){if(typeof requestAnimationFrame>`u`){this._scrollToSelection();return}this._pendingSelectionScrollFrame!=null&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=requestAnimationFrame(()=>{this._pendingSelectionScrollFrame=null,this._scrollToSelection()})}scrollToRange(e,t){this._cancelPendingSelectionScroll(),this._pendingExplicitRange??(this._selectionBeforeExplicitRange=this._textSelectionManagerService.getActiveTextRange()),this._pendingExplicitRange=e,this._scrollingToRange=!0;try{this._scrollToRange(e,t)}finally{this._scrollingToRange=!1,this._pendingSelectionScrollFrame??this._clearExplicitRangeOwnership()}}_isSameRange(e,t){return e!=null&&t!=null&&e.startOffset===t.startOffset&&e.endOffset===t.endOffset&&(e.segmentId??``)===(t.segmentId??``)&&(e.segmentPage??-1)===(t.segmentPage??-1)}_ownsPendingExplicitRange(e){return this._pendingExplicitRange!=null&&(e==null||this._isSameRange(e,this._pendingExplicitRange)||this._isSameRange(e,this._selectionBeforeExplicitRange))}_clearExplicitRangeOwnership(){this._pendingExplicitRange=null,this._selectionBeforeExplicitRange=null}_scrollToRange(e,t){var n;let i=this._docSkeletonManagerService.getSkeleton();if(!i)return;if(!this.isViewportReady()){this._scheduleScrollToReadyRange(e,0,t);return}let{startOffset:a,segmentId:o,segmentPage:s}=e,c=i.findNodePositionByCharIndex(a,!0,o??``,s??-1);if(c==null){this._deferUnresolvedRange(i,e,t);return}let l=(n=i.getSkeletonData())==null?void 0:n.pages,u=c.pageType===r.DocumentSkeletonPageType.HEADER||c.pageType===r.DocumentSkeletonPageType.FOOTER||c.pageType===r.DocumentSkeletonPageType.CELL&&(l==null?void 0:l[c.page])==null?c.segmentPage:c.page,d=l==null?void 0:l[u];d==null||d.isLayoutPlaceholder||(this.scrollToNode(c),t==null||t())}_deferUnresolvedRange(e,t,n){var r;let i=e.findBodyPageIndexByCharIndex(t.startOffset),a=(r=e.getSkeletonData())==null?void 0:r.pages[i];a!=null&&a.isMaterializationPlaceholder?(this._scrollToPage(i),this._scheduleScrollToReadyRange(t,0,n)):i<0&&this._isValidBodyOffset(e,t.startOffset)&&this._scheduleScrollToReadyRange(t,0,n)}_scheduleScrollToReadyRange(e,t=0,n){typeof requestAnimationFrame>`u`||t>=6e3||(this._pendingSelectionScrollFrame!=null&&cancelAnimationFrame(this._pendingSelectionScrollFrame),this._pendingSelectionScrollFrame=requestAnimationFrame(()=>{this._pendingSelectionScrollFrame=null;let r=this._docSkeletonManagerService.getSkeleton(),i=r.findBodyPageIndexByCharIndex(e.startOffset);if(!this.isViewportReady()||i<0&&this._isValidBodyOffset(r,e.startOffset)){this._scheduleScrollToReadyRange(e,t+1,n);return}this.scrollToRange(e,n)}))}_isValidBodyOffset(e,t){var n;let r=((n=e.getViewModel().getDataModel().getBody())==null?void 0:n.dataStream.length)??0;return t>=0&&t<r}isViewportReady(){let{mainComponent:e,scene:t}=this._context;if(!(e instanceof r.Documents))return!0;let{docsLeft:n,docsTop:i}=e.getOffsetConfig();if(n<=-1e4||i<=-1e4)return!1;let a=t.getViewport(`viewMain`);if(a==null)return!0;let o=a.calcViewportInfo().viewBound;return o.right-o.left>1&&o.bottom-o.top>1}_scrollToPage(e){var t;let{mainComponent:n,scene:i}=this._context,a=(t=this._docSkeletonManagerService.getSkeleton().getSkeletonData())==null?void 0:t.pages;if(!(n instanceof r.Documents)||a==null||a[e]==null)return;let o=i.getViewport(`viewMain`);if(o==null)return;let{docsLeft:s,docsTop:c,pageLayoutType:l=r.PageLayoutType.VERTICAL,pageMarginLeft:u,pageMarginTop:d}=n.getOffsetConfig(),f=s,p=c;for(let t=0;t<e;t++)l===r.PageLayoutType.HORIZONTAL?f+=a[t].pageWidth+u:p+=a[t].pageHeight+d;let m=o.calcViewportInfo().viewBound,h=l===r.PageLayoutType.HORIZONTAL?f-m.left:0,g=l===r.PageLayoutType.HORIZONTAL?0:p-m.top;o.scrollByBarDeltaValue(o.transViewportScroll2ScrollValue(h,g))}scrollToNode(e){let{unitId:t,scene:n,mainComponent:i}=this._context,a=this._docSkeletonManagerService.getSkeleton();if(!(i instanceof r.Documents)||a==null)return;let o=i.getOffsetConfig(),{docsLeft:s,docsTop:c}=o,{contentBoxPointGroup:l}=new Ze(o,a).getRangePointData(e,e);if(l.length===0)return;let{left:u,top:d,height:f}=Ct(l),p=u+s,m=d+c,h=n.getViewport(`viewMain`);if(h==null)return;let{left:g,top:_,right:v,bottom:y}=h.calcViewportInfo().viewBound,b=0,x=0,S=this._editorService.getEditorRenderConfig(t);if(S!=null&&S.disableBackScroll)return;let C=S?S.backScrollOffset??0:100;if(b=this._getVerticalScrollDelta(m,f,_,y,C),p<g?x=p-g:p>v-us&&(x=p-v+us),x===0&&b===0)return;let w=h.transViewportScroll2ScrollValue(x,b);h.scrollByBarDeltaValue(w)}_getVerticalScrollDelta(e,t,n,r,i){return e<n?e-n-i:e>r-t?e-r+t+i:0}_scrollToSelection(){let e=this._textSelectionManagerService.getActiveTextRange();if(e==null)return;let{collapsed:t}=e;t&&this.scrollToRange(e)}};ds=B([z(1,(0,t.Inject)(n.DocSelectionManagerService)),z(2,J),z(3,(0,t.Inject)(n.DocSkeletonManagerService))],ds);let fs=`gray.300`,ps=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._context=e,this._localeService=t,this._docSelectionManagerService=n,this._configService=r,this._themeService=i,this._initParagraphPlaceholderRender()}_initParagraphPlaceholderRender(){let e=this._configService.getConfig(as);if(!ms(this._context.unit,this._context.unitId,e))return;let t=this._context.mainComponent;t&&(this.disposeWithMe(t.pageRender$.subscribe(e=>this._drawPagePlaceholders(e))),this.disposeWithMe(this._docSelectionManagerService.textSelection$.subscribe(({unitId:e})=>{e===this._context.unitId&&t.makeDirty(!0)})))}_drawPagePlaceholders({page:e,pageLeft:t,pageTop:n,ctx:r}){var i,a;let o=(i=this._context.unit.getSelfOrHeaderFooterModel(e.segmentId))==null?void 0:i.getBody();if(!o)return;let s=this._docSelectionManagerService.getActiveTextRange();if(!s||(s.segmentId??``)!==(e.segmentId??``)||s.startOffset==null||s.endOffset==null||s.startOffset!==s.endOffset)return;let c=hs(e,o,this._getLocale(),t,n,s.startOffset,{docsLeft:(a=this._context.mainComponent)==null?void 0:a.getOffsetConfig().docsLeft,unitId:this._context.unitId});c.length&&Ts(r,c,this._themeService.darkMode?`gray.400`:fs)}_getLocale(){return{heading1:this._localeService.t(`docs-ui.placeholder.heading1`),heading2:this._localeService.t(`docs-ui.placeholder.heading2`),heading3:this._localeService.t(`docs-ui.placeholder.heading3`),heading4:this._localeService.t(`docs-ui.placeholder.heading4`),heading5:this._localeService.t(`docs-ui.placeholder.heading5`),listItem:this._localeService.t(`docs-ui.placeholder.listItem`),normalText:this._localeService.t(`docs-ui.placeholder.normalText`)}}};ps=B([z(1,(0,t.Inject)(t.LocaleService)),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,t.IConfigService),z(4,(0,t.Inject)(t.ThemeService))],ps);function ms(e,n,r){var i;return(r==null?void 0:r.placeholder)===!1||(0,t.isInternalEditorID)(n)?!1:((i=e.getSnapshot().documentStyle)==null?void 0:i.documentFlavor)===t.DocumentFlavor.MODERN}function hs(e,t,n,i=0,a=0,o,s){var c;let l=new Map((t.paragraphs??[]).map(e=>[e.startIndex,e])),u=[],d=(e,r,i,a)=>{for(let s of e.columns)gs(s,t,l,n,u,r+s.left,i+e.top,o,a)};for(let t of e.sections)d(t,i+e.marginLeft,a+e.marginTop);return(c=e.skeTables)==null||c.forEach((t,n)=>{let o=(0,r.getTableIdAndSliceIndex)(t.tableId??n).tableId,c=(0,r.getDocsTableRenderViewport)((s==null?void 0:s.unitId)??``,o),l=c!=null&&(c.leadingInsetLeft??0)+c.contentWidth+(c.trailingInsetRight??0)>c.viewportWidth,u=i+e.marginLeft+t.left,f=l?(0,r.getDocsTableViewportLeft)(c,u-(c.leadingInsetLeft??0),s==null?void 0:s.docsLeft):u,p=f+(l?c.viewportWidth:t.width),m=l?c.scrollLeft:0;for(let n of t.rows)for(let r of n.cells){let i=u+r.left-m,o=i+r.marginLeft,s=i+r.pageWidth-r.marginRight,c=Math.max(o,f),l=Math.min(s,p);if(!(l<=c))for(let i of r.sections)d(i,o,a+e.marginTop+t.top+n.top+r.marginTop,{left:c,right:l})}}),u}function gs(e,t,n,r,i,a,o,s,c){for(let l of e.lines){if(!l.paragraphStart)continue;let e=l.st,u=l.paragraphIndex;if(!_s(s,e,u))continue;let d=n.get(u);if(!d||!bs(t.dataStream,l.st,l.paragraphIndex))continue;let f=vs(d,r);f&&i.push(ys(l,d,f,a,o,c))}}function _s(e,t,n){return t<=e&&e<=n}function vs(e,n){var r;if(e.bullet)return n.listItem;switch((r=e.paragraphStyle)==null?void 0:r.namedStyleType){case t.NamedStyleType.HEADING_1:return n.heading1;case t.NamedStyleType.HEADING_2:return n.heading2;case t.NamedStyleType.HEADING_3:return n.heading3;case t.NamedStyleType.HEADING_4:return n.heading4;case t.NamedStyleType.HEADING_5:return n.heading5;default:return n.normalText}}function ys(e,n,r,i,a,o){var s;let c=e.divides[0],l=((c==null?void 0:c.glyphGroup)??[])[0],u=((s=n.paragraphStyle)==null?void 0:s.namedStyleType)??t.NamedStyleType.NORMAL_TEXT,d=t.NAMED_STYLE_MAP[u],f=Cs(e,n),p=ws(e)??`Arial`,m=d!=null&&d.bl?`bold`:`normal`,h=i+((c==null?void 0:c.left)??0)+((c==null?void 0:c.paddingLeft)??0),g=n.bullet&&l?l.left+l.width+4:0,_=h+g,v=Math.max(0,((c==null?void 0:c.width)??e.width??0)-g),y=Math.max(_,(o==null?void 0:o.left)??_),b=Math.min(_+v,(o==null?void 0:o.right)??_+v),x=a+e.top;return{clipBottom:x+e.lineHeight,clipLeft:y,clipRight:b,clipTop:x,fontFamily:p,fontSize:f,fontWeight:m,maxWidth:Math.max(0,b-y),text:r,x:_,y:a+e.top+e.marginTop+e.paddingTop+e.asc}}function bs(e,t,n){return xs((e==null?void 0:e.slice(t,n))??``).trim()===``}function xs(e){return e.replaceAll(t.DataStreamTreeTokenType.PARAGRAPH,``).replaceAll(t.DataStreamTreeTokenType.SECTION_BREAK,``).replaceAll(t.DataStreamTreeTokenType.DOCS_END,``)}function Ss(e){for(let i of e.divides)for(let e of i.glyphGroup){var t,n,r;let i=((t=e.fontStyle)==null?void 0:t.originFontSize)??((n=e.fontStyle)==null?void 0:n.fontSize)??((r=e.ts)==null?void 0:r.fs);if(i)return i}return null}function Cs(e,n){var r;let i=((r=n.paragraphStyle)==null?void 0:r.namedStyleType)??t.NamedStyleType.NORMAL_TEXT,a=t.NAMED_STYLE_MAP[i],o=Ss(e)??(a==null?void 0:a.fs)??12;return i===t.NamedStyleType.NORMAL_TEXT?Math.max(o,16):o}function ws(e){for(let r of e.divides)for(let e of r.glyphGroup){var t,n;let r=((t=e.fontStyle)==null?void 0:t.fontFamily)??((n=e.ts)==null?void 0:n.ff);if(r)return r}return null}function Ts(e,t,n=fs){e.save(),e.fillStyle=n,e.textBaseline=`alphabetic`;for(let n of t){let t=n.clipLeft??n.x,r=n.clipRight??n.x+n.maxWidth,i=n.clipTop??n.y-n.fontSize,a=n.clipBottom??n.y+n.fontSize;r<=t||a<=i||(e.save(),e.beginPath(),e.rectByPrecision(t,i,r-t,a-i),e.closePath(),e.clip(),e.font=`${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,e.fillText(n.text,n.x,n.y),e.restore())}e.restore()}var Es=class extends r.Documents{isHit(e){var t,n;if(!super.isHit(e))return!1;let i=this.getSkeleton(),a=this.layer;if(!(a!=null&&(t=this.getScene())!=null&&t.getLayers().some(t=>t.zIndex<a.zIndex&&t.getObjects().some(t=>!(t instanceof r.Documents)&&!(t instanceof r.DocBackground)&&!t.isInGroup&&t.visible&&t.evented&&t.isHit(e))))||!i)return!0;let o=this.getInverseCoord(e),s=i.findNodeByCoord(o,this.pageLayoutType,this.pageMarginLeft,this.pageMarginTop);if(s!=null&&(n=s.node.content)!=null&&n.trim()){let e=i.findPositionByGlyph(s.node,s.segmentPage);if(e){let{contentBoxPointGroup:t}=new Ze(this.getOffsetConfig(),i).getRangePointData({...e,isBack:!0},{...e,isBack:!1});if(t.some(e=>o.x>=e[0].x&&o.x<=e[2].x&&o.y>=e[0].y&&o.y<=e[2].y))return!0}}let c=i.getSkeletonData();if(!c)return!1;let{docsLeft:l,docsTop:u}=this.getOffsetConfig();return(0,r.documentSkeletonTableIterator)(c.pages,{docsLeft:l,docsTop:u,includeCells:!1,pageMarginTop:this.pageMarginTop,skeHeaders:c.skeHeaders,skeFooters:c.skeFooters,unitId:i.getViewModel().getDataModel().getUnitId()}).some(({tableRect:e})=>o.x+l>=e.left-24&&o.x+l<=e.right+24&&o.y+u>=e.top-24&&o.y+u<=e.bottom+24)}};let Ds=0;function Os(e){if(!(`scheduling`in e))return!1;let t=e.scheduling;return typeof t==`object`&&!!t&&`isInputPending`in t&&typeof t.isInputPending==`function`}function ks(){return typeof navigator>`u`?!1:Os(navigator)&&navigator.scheduling.isInputPending({includeContinuous:!0})}function As(e){return e===`edit`?120:4}function js(e){return Math.min(5,Math.max(3,Math.floor(e??5)))}function Ms(e){if(typeof requestAnimationFrame==`function`){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}let t=setTimeout(e,0);return()=>clearTimeout(t)}var Ns=class extends t.Disposable{constructor(e=Ms){super(),this._scheduleVisualFrame=e,R(this,`_mountId`,`docs-layout-mount-${++Ds}`),R(this,`_mountEpoch`,0),R(this,`_viewportEpoch`,0),R(this,`_workerMount`,null),R(this,`_scheduledLayout`,null),R(this,`_animationFrameId`,null),R(this,`_idleCallbackId`,null),R(this,`_fallbackTimerId`,null),R(this,`_pendingWorkerPresentation`,null),R(this,`_workerPresentationPaused`,!1)}schedule(e,t,n){this.cancel();let r=e.startIncrementalLayout({...t,waitForHyphenationPatterns:!0}),i=As(t.reason);if(this._scheduledLayout={executor:`main-thread`,skeleton:e,generation:r,callbacks:n,backgroundResumeDelayMs:i,nextBackgroundDelayMs:i,anchorReady:!1,foregroundStarted:!1,foregroundBudgetMs:t.foregroundBudgetMs??28,foregroundElapsedMs:0,foregroundWindowSize:js(t.foregroundWindowSize),foregroundTargetProgressCount:null,foregroundEndOffset:t.foregroundEndOffset??null,waitForAnimationFrame:t.reason!==`edit`||t.deferForeground===!0},t.reason===`edit`&&t.deferForeground!==!0){this._scheduledLayout.foregroundStarted=!0;let e=0;for(;this._scheduledLayout!=null&&!this._scheduledLayout.anchorReady&&e<4;)this._runSlice(0,!1,!1),e++;let t=this._scheduledLayout;(t==null?void 0:t.executor)===`main-thread`&&t.anchorReady&&t.foregroundEndOffset!=null&&t.foregroundElapsedMs<t.foregroundBudgetMs&&this._runSlice(Math.min(8,t.foregroundBudgetMs-t.foregroundElapsedMs),!1,!1);let n=this._scheduledLayout;n!=null&&(n.executor===`main-thread`&&(!n.anchorReady||n.callbacks.onForegroundReady!=null)&&(n.foregroundStarted=!1,n.waitForAnimationFrame=!0),!n.anchorReady||n.callbacks.onForegroundReady!=null?this._scheduleForeground():this._scheduleBackground())}else this._scheduleForeground();return r}scheduleWorker(e,t,n,r,i,a,o,s=!1){this.cancel();let c=this._workerMount;c!=null&&(c.unitId!==e||c.executorService!==n)&&c.executorService.disposeLayoutMount({unitId:c.unitId,mountId:this._mountId,mountEpoch:c.mountEpoch,viewportEpoch:c.viewportEpoch}).catch(o),(c==null||c.unitId!==e||c.executorService!==n)&&this._mountEpoch++;let l=++this._viewportEpoch;this._workerMount={unitId:e,executorService:n,onError:o,mountEpoch:this._mountEpoch,viewportEpoch:l},s||t.beginExternalLayout({reason:r.reason,protectedRange:i});let u=As(r.reason);this._scheduledLayout={executor:`worker`,unitId:e,mountId:this._mountId,mountEpoch:this._mountEpoch,viewportEpoch:l,skeleton:t,executorService:n,preserveCompletedLayout:s,options:r,generation:null,modelRevision:null,metricsRevision:null,callbacks:a,onError:o,backgroundResumeDelayMs:u,nextBackgroundDelayMs:u,anchorReady:!1},this._runSlice(32,!1)}async getWorkerPage(e){let t=this._workerMount;if(t==null)return null;let n=await t.executorService.getLayoutPage({unitId:t.unitId,mountId:this._mountId,mountEpoch:t.mountEpoch,viewportEpoch:t.viewportEpoch,pageIndex:e});return this._workerMount!==t||n.unitId!==t.unitId||n.mountId!==this._mountId||n.mountEpoch!==t.mountEpoch||n.viewportEpoch!==t.viewportEpoch?null:n}deferBackgroundWork(){let e=this._scheduledLayout;e!=null&&e.anchorReady&&(e.nextBackgroundDelayMs=e.backgroundResumeDelayMs,e.executor!==`worker`&&(this._cancelCallbacks(),this._scheduleBackground()))}setWorkerPresentationPaused(e){if(this._workerPresentationPaused!==e&&(this._workerPresentationPaused=e,!e)){var t;(t=this._pendingWorkerPresentation)==null||t.resume()}}hasScheduledLayout(){return this._scheduledLayout!=null}cancel(){let e=this._scheduledLayout;e!=null&&(e.executor===`main-thread`?e.skeleton.cancelIncrementalLayout(e.generation):e.generation!=null&&e.executorService.cancelLayout({unitId:e.unitId,mountId:e.mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch,generation:e.generation}).catch(e.onError),e.executor===`worker`&&!e.preserveCompletedLayout&&e.skeleton.cancelExternalLayout()),this._scheduledLayout=null,this._cancelCallbacks()}dispose(){this.cancel();let e=this._workerMount;this._workerMount=null,e!=null&&e.executorService.disposeLayoutMount({unitId:e.unitId,mountId:this._mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch}).catch(e.onError),super.dispose()}_scheduleForeground(){if(this._scheduledLayout==null||this._animationFrameId!=null||this._fallbackTimerId!=null)return;if(this._scheduledLayout.executor===`worker`){this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._runSlice(32,!1)},0);return}let e=this._scheduledLayout;if(e.foregroundStarted||!e.waitForAnimationFrame){this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))},0);return}if(typeof requestAnimationFrame==`function`){this._animationFrameId=requestAnimationFrame(()=>{this._animationFrameId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))});return}this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null,this._scheduledLayout===e&&(e.foregroundStarted=!0,this._runSlice(8,!1))},0)}_scheduleBackground(){if(this._scheduledLayout==null||this._idleCallbackId!=null||this._fallbackTimerId!=null)return;let e=this._scheduledLayout.nextBackgroundDelayMs;this._scheduledLayout.nextBackgroundDelayMs=4,this._fallbackTimerId=setTimeout(()=>{this._fallbackTimerId=null;let e=this._scheduledLayout;if(e!=null){if(e.executor===`worker`){if(ks()){this._scheduleBackground();return}this._runSlice(128,!0);return}if(typeof requestIdleCallback==`function`){this._idleCallbackId=requestIdleCallback(e=>{if(this._idleCallbackId=null,ks()){this._scheduleBackground();return}let t=e.timeRemaining(),n=t>0?Math.min(12,Math.max(1,t)):8;this._runSlice(n,!0)});return}this._runSlice(8,!0)}},e)}_runSlice(e,t,n=!0){let r=this._scheduledLayout;if(r!=null){if(r.executor===`worker`){this._runWorkerSlice(r,e,t).catch(e=>{this._scheduledLayout===r&&(r.preserveCompletedLayout||r.skeleton.cancelExternalLayout(),this._scheduledLayout=null,this._cancelCallbacks(),r.onError(e))});return}try{this._runMainThreadSlice(r,e,t,n)}catch(e){throw this.cancel(),e}}}_runMainThreadSlice(e,t,n,r){if(this._publishMainThreadBacklog(e,n,r))return;let i=performance.now(),a=e.skeleton.stepIncrementalLayout(e.generation,t);if(e.foregroundElapsedMs+=performance.now()-i,this._scheduledLayout!==e)return;if(a.cancelled){this._scheduledLayout=null,this._cancelCallbacks();return}e.anchorReady=a.anchorReady;let o=a.complete&&a.mode!==`continuous`&&e.callbacks.onForegroundReady!=null?{...a,complete:!1}:a;if(e.callbacks.onProgress(o),!this._finishForegroundWindow(e,a,r)){if(a.complete){var s,c;this._scheduledLayout=null,(s=(c=e.callbacks).onComplete)==null||s.call(c,a);return}r&&(e.anchorReady?this._scheduleBackground():this._scheduleForeground())}}_publishMainThreadBacklog(e,t,n){if(!t||!e.anchorReady||ks()||typeof e.skeleton.publishIncrementalLayoutBacklog!=`function`)return!1;let r=e.skeleton.publishIncrementalLayoutBacklog(e.generation);if(this._scheduledLayout!==e||r.cancelled)return!0;if(!r.didPublish)return!1;if(e.anchorReady=r.anchorReady,e.callbacks.onProgress(r),r.complete){var i,a;return this._scheduledLayout=null,(i=(a=e.callbacks).onComplete)==null||i.call(a,r),!0}return n&&this._scheduleBackground(),!0}_finishForegroundWindow(e,t,n){let r=e.callbacks.onForegroundReady;if(r==null)return!1;if(t.complete)return this._completeForegroundWindow(e,t,r),!0;let i=t.mode===`continuous`?t.processedBlockCount:t.publishedPageCount;if(t.didPublishAnchor&&t.interactionWindowComplete)return this._completeForegroundWindow(e,t,r),!0;t.didPublishAnchor&&e.foregroundTargetProgressCount==null&&(e.foregroundTargetProgressCount=i+Math.max(0,e.foregroundWindowSize-1));let a=e.foregroundTargetProgressCount;return a==null?!1:(t.mode===`continuous`&&e.foregroundEndOffset!=null?t.stableLaidOutThrough>=e.foregroundEndOffset:i>=a||e.foregroundElapsedMs>=e.foregroundBudgetMs)?(this._completeForegroundWindow(e,t,r),!0):(n&&this._scheduleForeground(),!0)}_completeForegroundWindow(e,t,n){this._scheduledLayout=null,e.skeleton.cancelIncrementalLayout(e.generation),this._cancelCallbacks(),n(t)}async _runWorkerSlice(e,t,n){if(e.generation==null&&await this._startWorkerLayout(e,t)||await this._publishWorkerBacklog(e,n))return;let r=await e.executorService.stepLayout({...this._getWorkerIdentity(e),generation:this._getWorkerGeneration(e),budgetMs:t});this._assertWorkerResultIdentity(e,r),this._assertWorkerResultRevisions(e,r,`step`),!(this._scheduledLayout!==e||r.progress.cancelled)&&await this._publishWorkerResult(e,r)&&(r.progress.complete||(e.anchorReady?this._scheduleBackground():this._scheduleForeground()))}async _startWorkerLayout(e,t){let r=await e.executorService.startLayout(this._getWorkerIdentity(e),e.options,t);if(this._scheduledLayout!==e)return(r==null?void 0:r.status)===n.DocLayoutSessionStatus.ACCEPTED&&await e.executorService.cancelLayout({unitId:r.step.unitId,mountId:r.step.mountId,mountEpoch:r.step.mountEpoch,viewportEpoch:r.step.viewportEpoch,generation:r.step.progress.generation}),!0;if((r==null?void 0:r.status)!==n.DocLayoutSessionStatus.ACCEPTED)throw Error(`The document layout Worker could not start a synchronized session.`);return this._assertWorkerResultIdentity(e,r.step),e.generation=r.step.progress.generation,e.modelRevision=r.step.modelRevision,e.metricsRevision=r.step.metricsRevision,r.step.progress.cancelled||!await this._publishWorkerResult(e,r.step)?!0:r.step.progress.complete||e.anchorReady?(r.step.progress.complete||this._scheduleBackground(),!0):!1}async _publishWorkerBacklog(e,t){if(!t||!e.anchorReady)return!1;if(ks())return this._scheduleBackground(),!0;let n=await e.executorService.publishBacklog({...this._getWorkerIdentity(e),generation:this._getWorkerGeneration(e)});return this._assertWorkerResultIdentity(e,n),this._assertWorkerResultRevisions(e,n,`backlog`),this._scheduledLayout!==e||n.progress.cancelled?!0:n.progress.didPublish?(await this._publishWorkerResult(e,n)&&(n.progress.complete||this._scheduleBackground()),!0):!1}_assertWorkerResultRevisions(e,t,n){if(t.modelRevision!==e.modelRevision)throw Error(`The document layout Worker returned a stale ${n} model revision.`);if(t.metricsRevision!==e.metricsRevision)throw Error(`The document layout Worker returned stale ${n} Custom Block metrics.`)}_publishWorkerResult(e,t){return new Promise((n,r)=>{let i=!1,a=null,o=e=>{i||(i=!0,n(e))},s=()=>{a==null||a(),a=null,o(!1)},c=()=>{if(!(i||a!=null)){if(this._workerPresentationPaused){this._pendingWorkerPresentation={cancel:s,resume:c};return}a=this._scheduleVisualFrame(()=>{if(a=null,this._workerPresentationPaused){this._pendingWorkerPresentation={cancel:s,resume:c};return}if(this._pendingWorkerPresentation=null,this._scheduledLayout!==e){o(!1);return}try{if(e.anchorReady=t.progress.anchorReady,e.preserveCompletedLayout||e.callbacks.onProgress(t.progress,t.publication),t.progress.complete){var n,l;this._scheduledLayout=null,(n=(l=e.callbacks).onComplete)==null||n.call(l,t.progress)}o(!0)}catch(e){i||(i=!0,r(e))}}),this._pendingWorkerPresentation={cancel:s,resume:c}}};c()})}_getWorkerIdentity(e){return{unitId:e.unitId,mountId:e.mountId,mountEpoch:e.mountEpoch,viewportEpoch:e.viewportEpoch}}_getWorkerGeneration(e){if(e.generation==null)throw Error(`The document layout Worker session has not started.`);return e.generation}_assertWorkerResultIdentity(e,t){if(t.unitId!==e.unitId||t.mountId!==e.mountId||t.mountEpoch!==e.mountEpoch||t.viewportEpoch!==e.viewportEpoch||e.generation!=null&&t.progress.generation!==e.generation)throw Error(`The document layout Worker returned a stale publication identity.`)}_cancelCallbacks(){var e;this._animationFrameId!=null&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(this._animationFrameId),this._idleCallbackId!=null&&typeof cancelIdleCallback==`function`&&cancelIdleCallback(this._idleCallbackId),this._fallbackTimerId!=null&&clearTimeout(this._fallbackTimerId),(e=this._pendingWorkerPresentation)==null||e.cancel(),this._animationFrameId=null,this._idleCallbackId=null,this._fallbackTimerId=null,this._pendingWorkerPresentation=null}},Ps=class extends t.Disposable{constructor(...e){super(...e),R(this,`_active$`,new s.BehaviorSubject(!1)),R(this,`_interactionCount`,0),R(this,`active$`,this._active$.asObservable())}get isActive(){return this._interactionCount>0}beginInteraction(){this.ensureNotDisposed(),this._interactionCount++,this._interactionCount===1&&this._active$.next(!0);let e=!1;return{dispose:()=>{e||(e=!0,!this._disposed&&(this._interactionCount--,this._interactionCount===0&&this._active$.next(!1)))}}}dispose(){this._disposed||(this._interactionCount>0&&(this._interactionCount=0,this._active$.next(!1)),this._active$.complete(),super.dispose())}};function Fs(e){var n,r;return((n=e.getSettings())==null?void 0:n.zoomRatio)??((r=e.getSnapshot().documentStyle)==null||r.documentFlavor,t.DocumentFlavor.MODERN,1)}function Is(e){return{...ss,...e}}function Ls(e,t){if(typeof t==`number`)return Number.isFinite(t)?t:0;if(typeof t==`string`){let n=t.trim();if(n.endsWith(`%`)){let t=Number(n.slice(0,-1));return Number.isFinite(t)?e*t/100:0}}return 0}function Rs(e){let t=Is(e.options);if(t.mode!==`fit-width`||!Number.isFinite(e.availableWidth)||!Number.isFinite(e.baseWidth)||e.baseWidth<=0)return 1;let n=Ls(e.availableWidth,t.paddingX),r=Math.max(0,e.availableWidth-n*2)/e.baseWidth,i=t.maxScale??1/0;return Math.min(i,Math.max(t.minScale,r))}function zs(e){return e.documentStylePageWidth!=null&&Number.isFinite(e.documentStylePageWidth)&&e.documentStylePageWidth>0?e.documentStylePageWidth:e.documentFlavor===t.DocumentFlavor.MODERN?t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM]:e.skeletonPageWidth!=null&&Number.isFinite(e.skeletonPageWidth)&&e.skeletonPageWidth>0?e.skeletonPageWidth:t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM]}function Bs(e,t){return e*t}let Vs=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._configService=t}getPluginConfig(){return this._configService.getConfig(`docs-ui.config`)??{}}getOptions(){return this.getPluginConfig().fitToWidth??ss}getBaseWidth(){var e,t,n;let r=(e=this._context.unit)==null||(t=e.getSnapshot)==null||(t=t.call(e))==null?void 0:t.documentStyle;return zs({documentFlavor:r==null?void 0:r.documentFlavor,documentStylePageWidth:r==null||(n=r.pageSize)==null?void 0:n.width})}getAvailableWidth(){let e=this.getPluginConfig();if(Is(e.fitToWidth).target===`container`){let t=this._resolveContainer(e.container),n=t==null?void 0:t.clientWidth;if(n!=null&&Number.isFinite(n)&&n>0)return n}return this._context.engine.width}getUserZoomRatio(){return this._context.unit==null?1:Fs(this._context.unit)}getFitToWidthScale(){return Rs({availableWidth:this.getAvailableWidth(),baseWidth:this.getBaseWidth(),options:this.getOptions()})}getViewScale(e=this.getUserZoomRatio()){return Bs(e,this.getFitToWidthScale())}_resolveContainer(e){if(e!=null)return typeof e==`string`?document.querySelector(e)??document.getElementById(e)??void 0:e}};Vs=B([z(1,t.IConfigService)],Vs);let Hs=class extends t.Disposable{constructor(e,t){super(),this._context=e,this._docViewScaleService=t,R(this,`_bottomReserve`,0)}setBottomReserve(e){let t=Math.max(0,e);t!==this._bottomReserve&&(this._bottomReserve=t,this.calculatePagePosition())}resolveSceneHeight(e){return e+this._bottomReserve/Math.max(this._docViewScaleService.getViewScale(),.01)}calculatePagePosition(){if(this._disposed)return;let e=x(this._context),t=this._docViewScaleService.getViewScale(),n=this._docViewScaleService.getOptions(),r=n.mode===`fit-width`&&n.align===`start`,{document:i,scene:a,docBackground:o}=e;(a.scaleX!==t||a.scaleY!==t)&&a.scale(t,t);let s=a==null?void 0:a.getParent(),{width:c,height:l,pageMarginLeft:u,pageMarginTop:d}=i,f=r?Ls(this._docViewScaleService.getAvailableWidth(),n.paddingX)/t:u;if(s==null||c===1/0||l===1/0)return;let{width:p,height:m}=s,h=0,g=d,_=0,v=0,y=1/0;p>(c+f*2)*t?(h=r?f:(p/2-c*t/2)/t,_=(p-f*2)/t,y=0):(h=f,_=c+f*2,y=0),v=m>l?(m-d*2)/t:l+d*2,v=this.resolveSceneHeight(v),a.transformByState({width:_,height:v}),p<=1&&(h=-1e4,g=-1e4),i.translate(h,g),o.translate(h,g);let b=a.getViewport(`viewMain`);return y!==1/0&&b!=null&&b.scrollToViewportPos({viewportScrollX:y}),this}};Hs=B([z(1,(0,t.Inject)(Vs))],Hs);let Us=new Set([`blockRanges`,`columnGroups`,`customBlocks`,`customDecorations`,`customRanges`,`paragraphs`,`renderedPageBreaks`,`sectionBreaks`,`tables`,`textRuns`]);var Ws=class{constructor(e,t){this._body=e,this._styles=t,R(this,`_tableRanges`,null),R(this,`_drawingRanges`,null),R(this,`_listRanges`,null),R(this,`_styleRanges`,null),R(this,`_styleDependents`,null)}getTableRange(e){if(this._tableRanges==null){var t;this._tableRanges=new Map;for(let e of((t=this._body)==null?void 0:t.tables)??[])this._tableRanges.has(e.tableId)||this._tableRanges.set(e.tableId,{start:e.startIndex,end:e.endIndex})}return this._tableRanges.get(e)}getDrawingRange(e){if(this._drawingRanges==null){var t;this._drawingRanges=new Map;for(let e of((t=this._body)==null?void 0:t.customBlocks)??[])this._drawingRanges.has(e.blockId)||this._drawingRanges.set(e.blockId,{start:e.startIndex,end:e.startIndex+1})}return this._drawingRanges.get(e)}getListRange(e){return this._ensureParagraphRanges(),Gs(this._listRanges,e)}getStyleRange(e){if(this._ensureParagraphRanges(),this._styleDependents==null){this._styleDependents=new Map;for(let[e,t]of Object.entries(this._styles??{})){if(t.basedOn==null)continue;let n=this._styleDependents.get(t.basedOn)??[];n.push(e),this._styleDependents.set(t.basedOn,n)}}let t=new Set(e),n=[...e];for(;n.length>0;){let e=n.pop();for(let r of this._styleDependents.get(e)??[])t.has(r)||(t.add(r),n.push(r))}return Gs(this._styleRanges,t)}_ensureParagraphRanges(){var e;if(this._listRanges==null||this._styleRanges==null){this._listRanges=new Map,this._styleRanges=new Map;for(let n of((e=this._body)==null?void 0:e.paragraphs)??[]){var t;let e={start:n.startIndex,end:n.startIndex+1},r=(t=n.bullet)==null?void 0:t.listId;r!=null&&this._listRanges.set(r,rc(this._listRanges.get(r),e)),n.styleId!=null&&this._styleRanges.set(n.styleId,rc(this._styleRanges.get(n.styleId),e))}}}};function Gs(e,t){let n;for(let r of t)n=rc(n,e.get(r));return n}function Ks(e,n){if(n||e==null)return;let r,i=!1;try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{let a=n.getPath();a.length===1&&a[0]===`body`&&e.et===t.TextX.name&&Array.isArray(e.e)&&(r==null?r=e.e:i=!0)})}catch{return}return i?void 0:r}function qs(e,t){return e!=null&&e.length===2&&e[0]===`body`?Ks(e,t):void 0}function Js(e,n){if(e==null)return{global:!0};let r=!1,i,a=!1,o=!1,{body:s,styles:c}=n,l=new Ws(s,c);try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{a=!0;let t=Ys(n.getPath(),e,s,l);r||=t.global,o||=t.unresolvedLocal===!0,i=rc(i,t.range)})}catch{return{global:!0}}return{global:r||!a,range:i,unresolvedLocal:o}}function Ys(e,n,r,i){let a=e[0];if(a===`drawingsOrder`)return{global:!1};if(a===`body`)return Xs(e,n,r);if(a===`notes`){let i=nc(e,n),a;for(let e of(r==null?void 0:r.customRanges)??[]){var o;let n=(o=e.properties)==null?void 0:o.noteId;(e.rangeType===t.CustomRangeType.FOOTNOTE||e.rangeType===t.CustomRangeType.ENDNOTE)&&typeof n==`string`&&i.has(n)&&(a=rc(a,{start:e.startIndex,end:e.endIndex+1}))}return{global:!1,range:a,unresolvedLocal:a==null}}if(a===`tableSource`){let t=e[1],n=typeof t==`string`?i.getTableRange(t):void 0;return{global:!1,range:n,unresolvedLocal:n==null}}if(a===`drawings`){let t=e[1],n=typeof t==`string`?i.getDrawingRange(t):void 0;return{global:!1,range:n,unresolvedLocal:n==null}}if(a===`lists`){let t=r==null?void 0:i.getListRange(nc(e,n));return{global:!1,range:t,unresolvedLocal:t==null}}if(a===`styles`){let t=r==null?void 0:i.getStyleRange(nc(e,n));return{global:!1,range:t,unresolvedLocal:t==null}}return{global:!0}}function Xs(e,n,r){if(e.length===1&&n.et===t.TextX.name&&Array.isArray(n.e))return{global:!1};let i=e[1];if(typeof i!=`string`||!Us.has(i))return{global:!0};let a=r==null?void 0:$s(r,e,n);return{global:!1,range:a,unresolvedLocal:a==null}}function Zs(e,t){return t==null?e:e==null?{oldStart:t.start,oldEnd:t.end,newEnd:t.end}:{oldStart:Math.min(e.oldStart,ic(t.start,e)),oldEnd:Math.max(e.oldEnd,ic(t.end,e)),newEnd:Math.max(e.newEnd,t.end)}}function Qs(e,t,n){if(t.global||t.unresolvedLocal&&e==null)return{anchor:void 0,invalidation:void 0};let r=Zs(e,t.range);return{anchor:(r==null?void 0:r.oldStart)??(n.length>0?Math.min(...n):void 0),invalidation:r}}function $s(e,t,n){let r=t[1];if(typeof r!=`string`||!Us.has(r)||`p`in n||`d`in n)return;let i=t[2];if(typeof i==`number`){let a=t.length===3&&(`r`in n||`i`in n)?void 0:ec(e,r,i);return a=rc(a,tc(n.r,r)),rc(a,tc(n.i,r))}let a;for(let e of[n.r,n.i])if(Array.isArray(e))for(let t of e)a=rc(a,tc(t,r));return a}function ec(e,t,n){let r=e[t];return Array.isArray(r)?tc(r[n],t):void 0}function tc(e,t){if(t===`renderedPageBreaks`&&typeof e==`number`)return{start:e,end:e+1};if(typeof e!=`object`||!e)return;if(`st`in e&&`ed`in e&&typeof e.st==`number`&&typeof e.ed==`number`)return{start:e.st,end:e.ed};if(!(`startIndex`in e)||typeof e.startIndex!=`number`)return;let n=`endIndex`in e&&typeof e.endIndex==`number`?e.endIndex+(t===`tables`?0:1):e.startIndex+1;return{start:e.startIndex,end:n}}function nc(e,t){let n=new Set;if(typeof e[1]==`string`)return n.add(e[1]),n;for(let e of[t.r,t.i])typeof e==`object`&&e&&!Array.isArray(e)&&Object.keys(e).forEach(e=>n.add(e));return n}function rc(e,t){return t==null?e:e==null?t:{start:Math.min(e.start,t.start),end:Math.max(e.end,t.end)}}function ic(e,t){return e<t.oldStart?e:e<t.newEnd?t.oldStart:e-(t.newEnd-t.oldEnd)}function ac(e){if(typeof e==`object`&&e&&`t`in e&&`len`in e)return typeof e.len==`number`&&Number.isFinite(e.len)&&e.len>=0?e.len:void 0}function oc(e){return e.t===t.TextXActionType.RETAIN&&!(`body`in e)&&!(`oldBody`in e)&&!(`coverType`in e)}function sc(e){return typeof e==`object`&&!!e&&`rangeType`in e&&e.rangeType===t.CustomRangeType.HYPERLINK}function cc(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===t.CustomDecorationType.COMMENT||e.type===t.CustomDecorationType.DELETED)}function lc(e){let t=e.customRanges,n=e.customDecorations;return t!=null&&(!Array.isArray(t)||!t.every(sc))||n!=null&&(!Array.isArray(n)||!n.every(cc))?null:(Array.isArray(t)?t.length:0)+(Array.isArray(n)?n.length:0)}function uc(e){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==`customRanges`&&e!==`customDecorations`))}function dc(e,n){let r=qs(e,n);return r!=null&&r.length>0&&r.every(e=>{if(typeof e!=`object`||!e||!(`t`in e)||e.t!==t.TextXActionType.RETAIN)return!1;if(oc(e))return!0;if(!(`body`in e)||typeof e.body!=`object`||e.body==null)return!1;let n=e.body,r=lc(n);if(n.dataStream===``&&r!=null&&r>0&&Object.keys(n).every(e=>e===`dataStream`||e===`customRanges`||e===`customDecorations`))return!0;if(!(`oldBody`in e)||typeof e.oldBody!=`object`||e.oldBody==null)return!1;let i=e.oldBody,a=lc(i);return n.dataStream===``&&i.dataStream===``&&r!=null&&a!=null&&r+a>0&&t.Tools.diffValue(uc(n),uc(i))})}function fc(e,n){let r=Ks(e,n);if(r==null)return;let i=0,a=0,o,s=r.every(e=>typeof e==`object`&&!!e&&`t`in e&&e.t===t.TextXActionType.RETAIN),c=!1;for(let e of r){let n=ac(e);if(n==null||typeof e!=`object`||!e||!(`t`in e))return;if(oc(e)){i+=n,a+=n,c||=o!=null;continue}if(c&&!s)return;switch(o??={oldStart:i,oldEnd:i,newEnd:a},e.t){case t.TextXActionType.RETAIN:i+=n,a+=n;break;case t.TextXActionType.INSERT:a+=n;break;case t.TextXActionType.DELETE:i+=n;break;default:return}o.oldEnd=i,o.newEnd=a}return o}function pc(e){switch(e){case t.PositionedObjectLayoutType.INLINE:case t.PositionedObjectLayoutType.WRAP_NONE:case t.PositionedObjectLayoutType.WRAP_POLYGON:case t.PositionedObjectLayoutType.WRAP_SQUARE:case t.PositionedObjectLayoutType.WRAP_THROUGH:case t.PositionedObjectLayoutType.WRAP_TIGHT:case t.PositionedObjectLayoutType.WRAP_TOP_AND_BOTTOM:return!0;default:return!1}}function mc(e){if(typeof e!=`object`||!e||!(`layoutType`in e))return;let t=e.layoutType;return pc(t)?t:void 0}function hc(e){return typeof e==`object`&&!!e&&`unitId`in e&&typeof e.unitId==`string`&&`actions`in e&&(e.actions==null||Array.isArray(e.actions))}function gc(e,t){return!t&&e.isSync!==!0&&e.noNeedSetTextRange!==!0&&e.trigger!=null&&e.textRanges!=null}function _c(e,t){if(!(e instanceof r.Documents)||t==null)return null;let n=t.calcViewportInfo().viewBound,{docsLeft:i,docsTop:a,pageLayoutType:o=r.PageLayoutType.VERTICAL,pageMarginLeft:s,pageMarginTop:c}=e.getOffsetConfig(),l=o!==r.PageLayoutType.HORIZONTAL;return{pageGap:l?c:s,vertical:l,viewportCenter:l?(n.top+n.bottom)/2-a:(n.left+n.right)/2-i}}function vc(e,t){return t==null||e<t.oldStart?e:e>=t.oldEnd?e+t.newEnd-t.oldEnd:t.newEnd}function yc(e,t){if(e==null||t==null)return;let n=e.newEnd-e.oldEnd,r=t=>t<e.oldStart?t:t<e.newEnd?e.oldStart:t-n,i=Math.min(e.oldStart,r(t.oldStart)),a=Math.max(e.oldEnd,r(t.oldEnd)),o=t.newEnd-t.oldEnd;return{oldStart:i,oldEnd:a,newEnd:a+n+o}}function bc(e,t,n,r){let i=r+Math.max(0,r-n),a;for(let n of e.sections)for(let r of n.columns){let o=i-t-e.marginTop-n.top,s=0,c=r.lines.length;for(;s<c;){let e=s+Math.floor((c-s)/2);r.lines[e].top<=o?s=e+1:c=e}let l=r.lines[s-1];l!=null&&(a=Math.max(a??l.ed,l.ed))}return a}let xc=new Set([`title`,`description`]);function Sc(e,n){if(e==null||!Array.isArray(e)||e.length===0)return!0;let r=new Map,i=!1,a=!0;try{let n=t.JSON1.type.readCursor(e);n.traverse(null,e=>{i=!0;let t=n.getPath();if(t[0]===`drawingsOrder`)return;let o=t[1];if(t[0]!==`drawings`||typeof o!=`string`){a=!1;return}if(t.length>=3&&xc.has(String(t[2])))return;let s=r.get(o)??{};t.length===2?(s.before=mc(e.r),s.after=mc(e.i)):t.length===3&&t[2]===`layoutType`&&(s.before=pc(e.r)?e.r:s.before,s.after=pc(e.i)?e.i:s.after),r.set(o,s)})}catch{return!0}if(!i||!a)return!0;if(r.size===0)return!1;for(let[e,i]of r){var o;let r=n==null||(o=n[e])==null?void 0:o.layoutType,a=i.before??r,s=i.after??r;if(a==null||s==null||a!==t.PositionedObjectLayoutType.WRAP_NONE||s!==t.PositionedObjectLayoutType.WRAP_NONE)return!0}return!1}let Cc=class extends t.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._context=e,this._commandService=t,this._docSelectionRenderService=n,this._docSkeletonManagerService=r,this._editorService=i,this._renderManagerService=a,this._univerInstanceService=o,this._docPageLayoutService=s,this._textSelectionManagerService=c,this._docViewScaleService=l,this._themeService=u,this._docLayoutExecutorService=d,this._docLayoutInteractionService=f,this._logService=p,R(this,`_changesetRenderScheduled`,!1),R(this,`_pendingChangesetLayoutRequest`,null),R(this,`_layoutCoordinator`,void 0),R(this,`_layoutRequestId`,0),R(this,`_workerHandoffTimer`,null),R(this,`_workerPresentationResumeTimer`,null),R(this,`_pendingWorkerHandoff`,null),R(this,`_pendingWorkerEditBatch`,null),R(this,`_latestLayoutRestart`,null),R(this,`_pendingImeLayoutRestart`,null),R(this,`_isImeComposing`,!1),R(this,`_recoveryViewportAnchor`,null),R(this,`_pendingMaterializedPageRange`,null),R(this,`_isMaterializingPages`,!1),R(this,`_reservedLayoutWidth`,0),R(this,`_reservedLayoutHeight`,0),R(this,`_fontInitialization`,null),this._layoutCoordinator=new Ns(e=>this._scheduleVisualFrame(e)),this.disposeWithMe(this._layoutCoordinator),this._addNewRender(),this._initRenderRefresh(),this._initCommandListener(),this._initInteractionLayoutProtection(),this._initThemeListener()}_scheduleVisualFrame(e){let t=this._context.engine.beginFrame$;if(t==null){let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)}let n=!1,r=null,i=()=>{let a=t.pipe((0,s.take)(1)).subscribe(()=>{if(n)return;let t=this._context.scene.getParent();if(t==null||t.width<=1||t.height<=1){i();return}e()});r=()=>a.unsubscribe()};return i(),()=>{n=!0,r==null||r()}}reRender(e,t,r,i,a=!0,o=!1,s=!1){var c;let l=(c=this._renderManagerService.getRenderUnitById(e))==null?void 0:c.with(n.DocSkeletonManagerService);if(!l)return;let u=l.getSkeleton();if(!u||u.getViewModel().getDataModel().getSnapshot().disabled)return;if(!l.supportsIncrementalLayout()){l.recalculate();return}let d=t!=null||i!=null||r!=null,f=!u.hasCompleteLayout()&&!d?{reason:`initial`}:{reason:`edit`,anchor:t??0,priorityAnchor:i,invalidation:r,...s?{deferForeground:!0}:{}};this._scheduleLayout(e,u,f,a,o)}dispose(){this._layoutRequestId++,this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._workerPresentationResumeTimer!=null&&(clearTimeout(this._workerPresentationResumeTimer),this._workerPresentationResumeTimer=null),this._pendingWorkerHandoff=null,this._pendingWorkerEditBatch=null,this._pendingChangesetLayoutRequest=null,this._latestLayoutRestart=null,this._fontInitialization=null,this._pendingImeLayoutRestart=null,this._pendingMaterializedPageRange=null,this._recoveryViewportAnchor=null,super.dispose()}refreshCustomBlockPresentation(e){var t;let r=(t=this._renderManagerService.getRenderUnitById(e))==null||(t=t.with(n.DocSkeletonManagerService))==null?void 0:t.getSkeleton();if(r==null)return!1;let i=r.refreshCustomBlockPresentationViewports();if(i.didRefresh){var a,o;(a=this._context.mainComponent)==null||a.makeDirty(!0),(o=this._context.components.get(`__Document_Render_Background__`))==null||o.makeDirty(!0)}return!i.requiresLayout}_scheduleLayout(e,t,n,i=!0,a=!1){this._latestLayoutRestart=()=>this._scheduleLayout(e,t,n,i,a),this._isImeComposing&&(this._pendingImeLayoutRestart=null);let o=++this._layoutRequestId;this._cancelWorkerHandoff();let s=n.reason===`initial`,c=this._context.mainComponent;if(!(c instanceof r.Documents)||this._waitForConfiguredFonts(o))return;this._prepareReservedLayoutExtent(t,c);let l=this._createLayoutCallbacks(e,t,n,i,!0,a,void 0,!1);if(n.reuseMainBaseline){this._layoutCoordinator.schedule(t,n,l);return}if(this._docLayoutExecutorService.getExecutor()==null){this._pendingWorkerEditBatch=null,this._layoutCoordinator.schedule(t,n,l);return}let u=s?n:this._accumulateWorkerEditBatch(n);if(s){this._pendingWorkerEditBatch=null,this._scheduleInitialInteractionWindow(o,e,t,n,u,l,a);return}this._scheduleMainInteractionWindow(o,e,t,n,u,l,i,a)}_waitForConfiguredFonts(e){var t;let n=(t=this._docLayoutExecutorService.getExecutor())==null?void 0:t.renderingFontsReady;return n==null||this._fontInitialization===n?!1:(n.then(()=>{var t;this._disposed||e!==this._layoutRequestId||(this._fontInitialization=n,(t=this._latestLayoutRestart)==null||t.call(this))},e=>this._logService.error(`[DocRenderController]: configured document fonts failed to initialize.`,e)),!0)}_scheduleInitialInteractionWindow(e,t,n,r,i,a,o){this._layoutCoordinator.schedule(n,{...r,priorityAnchor:r.priorityAnchor??0},{onProgress:a.onProgress,onForegroundReady:s=>{if(s.complete)return;let c=this._resolveProtectedRange(n,0,s);this._queueWorkerHandoff(e,()=>{this._scheduleWorkerLayout(e,t,n,r,i,c,a,o)})}})}_prepareReservedLayoutExtent(e,t){e.hasCompleteLayout()?(this._reservedLayoutWidth=Math.max(this._reservedLayoutWidth,t.width||0),this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,t.height||0)):(this._reservedLayoutWidth=0,this._reservedLayoutHeight=0)}_scheduleMainInteractionWindow(e,t,n,r,i,a,o,s){let c=r.priorityAnchor!=null&&r.invalidation!=null&&r.priorityAnchor>=r.invalidation.oldStart&&r.priorityAnchor<=r.invalidation.newEnd,l=c?r.anchor:r.priorityAnchor??r.anchor,u=c?null:this._captureViewportAnchor(n,r.priorityAnchor,r.invalidation),d=this._resolveContinuousForegroundEndOffset(n,r.invalidation);this._layoutCoordinator.schedule(n,{...r,anchor:l,...d==null?{}:{foregroundEndOffset:d},preserveInteractionWindow:l!=null&&l!==r.anchor,reuseUnaffectedTail:!1},{onProgress:(e,t)=>{a.onProgress(e,t),u!=null&&(e.didPublishAnchor||e.complete)&&(this._restoreViewportAnchor(n,u),u=null)},onForegroundReady:c=>{this._refreshSelectionAfterForegroundLayout(t,o);let l=this._resolveProtectedRange(n,r.priorityAnchor??r.anchor,c);this._queueWorkerHandoff(e,()=>{this._scheduleWorkerLayout(e,t,n,r,i,l,a,s,!0,c.mode===`continuous`&&c.complete)})}})}_refreshSelectionAfterForegroundLayout(e,t){t||this._refreshPagePositionAndSelection(this._getActiveEditingRange(e)!=null)}_resolveContinuousForegroundEndOffset(e,n){var i;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN)return;let a=(i=e.getSkeletonData())==null?void 0:i.pages[0],o=this._context.mainComponent,s=this._context.scene.getViewport(`viewMain`);if(a==null||!(o instanceof r.Documents)||s==null)return;let c=s.calcViewportInfo().viewBound;if(!Number.isFinite(c.top)||!Number.isFinite(c.bottom))return;let l=bc(a,o.getOffsetConfig().docsTop,c.top,c.bottom);return l==null?void 0:vc(l,n)}_createLayoutCallbacks(e,t,n,r,i,a,o,s){let c=n.reason===`initial`;return{onProgress:(l,u)=>this._handleLayoutProgress(e,t,n,l,u,c,r,i,a,o,s)}}_handleLayoutProgress(e,t,n,r,i,a,o,s,c,l,u){var d,f;if(!r.didPublish)return;if(u&&r.complete&&i!=null&&l!=null&&this._docLayoutInteractionService.isActive){this._queueWorkerHandoff(l,()=>this._handleLayoutProgress(e,t,n,r,i,a,o,s,c,l,!1),!0);return}let p=this._captureCompletionViewportAnchor(e,t,i!=null&&r.complete&&!a,c),m=this._applyLayoutPublication(e,t,i,r),h=this._editorService.getEditorRenderConfig(e);if(h&&!h.scrollBar){this._markDocumentRenderDirty();return}this._recalculateSizeBySkeleton(t,r),r.complete?this._completeLayoutPresentation(e,t,p,s,o,(m==null?void 0:m.didReplaceProtectedPages)===!0):a?this._refreshPagePosition():(r.didPublishAnchor&&(o||this._docSelectionRenderService.hasPendingSelection)||i!=null&&((d=this._context.unit.getSnapshot().notes)==null?void 0:d[((f=this._getActiveRange(e))==null?void 0:f.segmentId)??``])!=null)&&this._textSelectionManagerService.refreshSelection({unitId:e,subUnitId:e},this._getActiveEditingRange(e)!=null),this._markDocumentRenderDirty()}_applyLayoutPublication(e,n,r,i){if(r==null)return null;let a=t.Tools.now();try{let e=i.mode===`paginated`?this._resolveMaterializedPageRange(n,i.publishedPageCount):void 0;return n.applyLayoutPublication(r,i,e)}finally{this._docLayoutExecutorService.recordHydrationDuration(e,t.Tools.now()-a)}}_completeLayoutPresentation(e,t,n,r,i,a){if(this._docLayoutExecutorService.completeRecovery(e),r||a||this._docSelectionRenderService.hasPendingSelection){let t=i||a||this._getActiveEditingRange(e)!=null;this._refreshPagePositionAndSelection(t)}else this._refreshPagePosition();this._restoreViewportAnchor(t,n),this._restoreRecoveryViewportAnchor(t)}_scheduleWorkerLayout(e,t,n,r,i,a,o,s,c=!0,l=!1){e===this._layoutRequestId&&this._layoutCoordinator.scheduleWorker(t,n,this._docLayoutExecutorService,i,a,{...this._createLayoutCallbacks(t,n,r,!1,!1,s,e,!0),onComplete:()=>{e===this._layoutRequestId&&(this._pendingWorkerEditBatch=null)}},u=>this._handleWorkerLayoutFailure(e,t,n,r,i,a,o,s,c,u,l),l)}_handleWorkerLayoutFailure(e,t,n,r,i,a,o,s,c,l,u){if(this._disposed||e!==this._layoutRequestId)return;if(!c){this._logService.error(`[DocRenderController]: Worker layout failed; using main-thread layout.`,l),this._layoutCoordinator.schedule(n,r,o);return}this._recoveryViewportAnchor=this._captureViewportAnchor(n,r.priorityAnchor??r.anchor,r.invalidation);let d=l instanceof Error?l.message:String(l);this._logService.warn(`[DocRenderController]: restarting the document layout Worker after a fatal layout failure.`,l),this._docLayoutExecutorService.recoverExecutor(t,d).then(()=>{this._scheduleWorkerLayout(e,t,n,r,i,a,o,s,!1,u)}).catch(t=>{this._disposed||e!==this._layoutRequestId||(this._logService.error(`[DocRenderController]: document layout Worker recovery failed; using main-thread layout.`,t),this._layoutCoordinator.schedule(n,r,o))})}_accumulateWorkerEditBatch(e){let t=this._pendingWorkerEditBatch;return this._pendingWorkerEditBatch=t==null?{anchor:e.anchor,invalidation:e.invalidation}:{anchor:t.anchor==null||e.anchor==null?void 0:Math.min(t.anchor,e.anchor),invalidation:yc(t.invalidation,e.invalidation)},{...e,anchor:this._pendingWorkerEditBatch.anchor,priorityAnchor:this._pendingWorkerEditBatch.anchor,invalidation:this._pendingWorkerEditBatch.invalidation}}_initInteractionLayoutProtection(){this._docLayoutInteractionService.active$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e){var t;this._workerPresentationResumeTimer!=null&&(clearTimeout(this._workerPresentationResumeTimer),this._workerPresentationResumeTimer=null),this._layoutCoordinator.setWorkerPresentationPaused(!0),(t=this._pendingWorkerHandoff)!=null&&t.waitForInteractionEnd&&this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null);return}this._workerPresentationResumeTimer=setTimeout(()=>{this._workerPresentationResumeTimer=null,this._docLayoutInteractionService.isActive||this._layoutCoordinator.setWorkerPresentationPaused(!1)},150),this._startWorkerHandoffTimer()}),this._docSelectionRenderService.onCompositionstart$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{e!=null&&(this._isImeComposing=!0,this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._pendingWorkerHandoff==null&&this._layoutCoordinator.hasScheduledLayout()&&(this._pendingImeLayoutRestart=this._latestLayoutRestart),this._layoutCoordinator.cancel())}),this._docSelectionRenderService.onCompositionend$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{if(e==null)return;this._isImeComposing=!1;let t=this._pendingImeLayoutRestart;if(this._pendingImeLayoutRestart=null,t!=null){t();return}this._startWorkerHandoffTimer()})}_queueWorkerHandoff(e,t,n=!1){this._cancelWorkerHandoff(),this._pendingWorkerHandoff={layoutRequestId:e,run:t,waitForInteractionEnd:n},this._startWorkerHandoffTimer()}_startWorkerHandoffTimer(){this._pendingWorkerHandoff==null||this._workerHandoffTimer!=null||this._isImeComposing||this._pendingWorkerHandoff.waitForInteractionEnd&&this._docLayoutInteractionService.isActive||(this._workerHandoffTimer=setTimeout(()=>{this._workerHandoffTimer=null;let e=this._pendingWorkerHandoff;if(e!=null){if(e.layoutRequestId!==this._layoutRequestId){this._pendingWorkerHandoff=null;return}if(this._isImeComposing||e.waitForInteractionEnd&&this._docLayoutInteractionService.isActive||this._docSelectionRenderService.isOnPointerEvent){this._startWorkerHandoffTimer();return}this._pendingWorkerHandoff=null,e.run()}},150))}_deferWorkerHandoff(){this._pendingWorkerHandoff!=null&&(this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._startWorkerHandoffTimer())}_cancelWorkerHandoff(){this._workerHandoffTimer!=null&&(clearTimeout(this._workerHandoffTimer),this._workerHandoffTimer=null),this._pendingWorkerHandoff=null}_resolveProtectedRange(e,t,n){var r,i,a,o;if(n.mode===`continuous`)return n.stableLaidOutThrough<0?void 0:{mode:`continuous`,startOffset:Math.max(0,Math.min(t??n.stableLaidOutThrough,n.stableLaidOutThrough)),endOffset:n.stableLaidOutThrough};let s=(r=e.getSkeletonData())==null?void 0:r.pages;if(s==null||s.length===0||n.publishedPageCount<=0)return;let c=Math.min(n.publishedPageCount,s.length)-1,l=t==null?Math.max(0,c-4):((i=e.findNodePositionByCharIndex(t))==null?void 0:i.page)??-1;for((l<0||l>c)&&(l=Math.max(0,c-4));l<=c&&((a=s[l])!=null&&a.isLayoutPlaceholder||(o=s[l])!=null&&o.isMaterializationPlaceholder);)l++;if(!(l>c))return{mode:`paginated`,startPageIndex:l,endPageIndex:c}}_resolveMaterializedPageRange(e,n){var r;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let i=(r=e.getSkeletonData())==null?void 0:r.pages,a=this._context.mainComponent,o=_c(a,this._context.scene.getViewport(`viewMain`));if(i==null||i.length===0||o==null)return;let{pageGap:s,vertical:c,viewportCenter:l}=o,u=0,d=0;for(;d<i.length;d++){let e=i[d],t=c?e.pageHeight:e.pageWidth;if(l<=u+t)break;u+=t+s}let f=Math.max(i.length,n??0);if(d>=i.length&&f>i.length){let e=i.at(-1),t=c?e==null?void 0:e.pageHeight:e==null?void 0:e.pageWidth;t!=null&&t+s>0&&(d+=Math.floor(Math.max(0,l-u)/(t+s)))}d=Math.max(0,Math.min(d,f-1));let p=Math.max(0,d-1),m=Math.min(f-1,p+5-1);return{startPageIndex:Math.max(0,m-5+1),endPageIndex:m}}_queueMaterializedPageRange(e){this._pendingMaterializedPageRange=e,!this._isMaterializingPages&&(this._isMaterializingPages=!0,this._materializePendingPageRanges().catch(e=>{this._logService.warn(`[DocRenderController]: failed to materialize a document page.`,e)}).finally(()=>{this._isMaterializingPages=!1,this._pendingMaterializedPageRange!=null&&this._queueMaterializedPageRange(this._pendingMaterializedPageRange)}))}async _materializePendingPageRanges(){for(;this._pendingMaterializedPageRange!=null;){let n=this._pendingMaterializedPageRange;this._pendingMaterializedPageRange=null;let r=this._layoutRequestId,i=this._docSkeletonManagerService.getSkeleton();if(i==null)return;for(let a=n.startPageIndex;a<=n.endPageIndex;a++){var e;if(!((e=i.getSkeletonData())!=null&&(e=e.pages[a])!=null&&e.isMaterializationPlaceholder))continue;let o=await this._layoutCoordinator.getWorkerPage(a);if(r!==this._layoutRequestId||o==null)return;if(o.page==null)continue;let s=t.Tools.now();try{i.applyLayoutPagePublication(o.page,n)}finally{this._docLayoutExecutorService.recordHydrationDuration(this._context.unitId,t.Tools.now()-s)}this._markDocumentRenderDirty()}}}_captureViewportAnchor(e,t,n){if(t==null)return null;let i=n==null||t<n.oldStart?t:t<n.newEnd?n.oldStart:t-(n.newEnd-n.oldEnd),a=e.findNodePositionByCharIndex(i),o=this._context.mainComponent,s=this._context.scene.getViewport(`viewMain`);if(a==null||!(o instanceof r.Documents)||s==null)return null;let c=o.getOffsetConfig(),{contentBoxPointGroup:l}=new Ze(c,e).getRangePointData(a,a),u=Ct(l),d=s.calcViewportInfo().viewBound;return{offset:t,relativeLeft:u.left+c.docsLeft-d.left,relativeTop:u.top+c.docsTop-d.top}}_restoreRecoveryViewportAnchor(e){let t=this._recoveryViewportAnchor;t!=null&&(this._recoveryViewportAnchor=null,this._restoreViewportAnchor(e,t))}_restoreViewportAnchor(e,t){if(t==null)return;let n=e.findNodePositionByCharIndex(t.offset),i=this._context.mainComponent,a=this._context.scene.getViewport(`viewMain`);if(n==null||!(i instanceof r.Documents)||a==null)return;let o=i.getOffsetConfig(),{contentBoxPointGroup:s}=new Ze(o,e).getRangePointData(n,n),c=Ct(s),l=a.calcViewportInfo().viewBound;a.scrollByViewportDeltaVal({viewportScrollX:c.left+o.docsLeft-l.left-t.relativeLeft,viewportScrollY:c.top+o.docsTop-l.top-t.relativeTop})}_addNewRender(){let{scene:e,engine:t}=this._context,n=new r.Viewport(`viewMain`,e,{left:0,top:0,bottom:0,right:0,isWheelPreventDefaultX:!0});e.attachControl(),this._initViewportInteraction(n),new r.ScrollBar(n,{enableHorizontal:this._shouldEnableHorizontalScrollBar()}),e.addLayer(new r.Layer(e,[],2),new r.Layer(e,[],4)),this._addComponent();let i=()=>e.render();this.disposeWithMe(this._context.activated$.subscribe(e=>{e?t.runRenderLoop(i):t.stopRenderLoop(i)})),this._docSelectionRenderService.__attachScrollEvent()}_initViewportInteraction(e){var n;let{scene:r}=this._context,i=(n=r.onPointerDown$)==null?void 0:n.subscribeEvent(()=>{this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork()});i!=null&&this.disposeWithMe(i),this.disposeWithMe(e.onScrollAfter$.subscribeEvent(()=>{let e=this._docSkeletonManagerService.getSkeleton(),t=e==null?void 0:this._resolveMaterializedPageRange(e);t!=null&&this._queueMaterializedPageRange(t)})),typeof document<`u`&&this.disposeWithMe((0,s.merge)((0,s.fromEvent)(document,`keydown`,{capture:!0}),(0,s.fromEvent)(document,`beforeinput`,{capture:!0})).pipe((0,s.takeUntil)(this.dispose$)).subscribe(()=>{let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(e==null?void 0:e.getUnitId())===this._context.unitId&&(this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork())})),r.onMouseWheel$.subscribeEvent((n,i)=>{let a=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if((a==null?void 0:a.getUnitId())===this._context.unitId){if(this._deferWorkerHandoff(),this._layoutCoordinator.deferBackgroundWork(),n.ctrlKey){let e=Math.abs(n.deltaX),t=e<40?.2:e<80?.4:.2;t*=n.deltaY>0?-1:1,r.scaleX<1&&(t/=2),r.scaleX+t>4?r.scale(4,4):r.scaleX+t<.1?r.scale(.1,.1):n.preventDefault()}else e.onMouseWheel(n,i)}})}_shouldEnableHorizontalScrollBar(){let e=this._docViewScaleService.getOptions();return e.mode!==`fit-width`||e.target!==`container`||e.align!==`start`}_getHorizontalPageMargin(){return 20}_addComponent(){let{scene:e,unit:t,components:n}=this._context,i={pageMarginLeft:this._getHorizontalPageMargin(),pageMarginTop:20,...this._getEditorBackgroundConfig()},a=new(this._isEditorRenderUnit(t.getUnitId())?r.Documents:Es)(`__Document_Render_Main__`,void 0,i);a.zIndex=10;let o=new r.DocBackground(`__Document_Render_Background__`,void 0,i);o.zIndex=10,this._context.mainComponent=a,n.set(`__Document_Render_Main__`,a),n.set(`__Document_Render_Background__`,o),e.addObjects([a],2),e.addObjects([o],0),this._isEditorRenderUnit(t.getUnitId())||e.enableLayerCache(2)}_initRenderRefresh(){this._docSkeletonManagerService.currentSkeletonBefore$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{this._create(e)})}_create(e){if(!e)return;let{mainComponent:t,components:n}=this._context,r=t,i=n.get(`__Document_Render_Background__`);r.changeSkeleton(e),i.changeSkeleton(e),this._syncCanvasBackground();let{unitId:a}=this._context;if(e.getSkeletonData()==null){this._scheduleLayout(a,e,{reason:`initial`});return}let o=this._editorService.getEditorRenderConfig(a);if(o&&!o.scrollBar){var s;(s=this._context.mainComponent)==null||s.makeDirty();return}this._recalculateSizeBySkeleton(e),this._refreshPagePositionAndSelection(this._getActiveEditingRange(a)!=null)}_initCommandListener(){let e=[n.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted((r,i)=>{if(!e.includes(r.id))return;let a=r.params;if(!hc(a))return;let{unitId:o,textRanges:s}=a;if(o!==this._context.unitId)return;let c=this._context.unit.getSnapshot();if(!Sc(a.actions,c.drawings))return;let l=(s==null?void 0:s.filter(e=>!(e.segmentId??a.segmentId)))??[],{anchor:u,invalidation:d}=Qs(fc(a.actions,a.segmentId),Js(a.actions,c),l.map(e=>e.startOffset));if(i!=null&&i.fromChangeset){this._scheduleChangesetRender(u,d);return}let f=this._getActiveEditingRange(o),p=a.isSync===!0||(i==null?void 0:i.fromCollab)===!0,m=p?void 0:l.find(e=>e.isActive)??(l.length===1?l[0]:void 0),h=(m==null?void 0:m.endOffset)??(f!=null&&f.segmentId||f==null?void 0:f.endOffset),g=gc(a,p);if(d!=null&&dc(a.actions,a.segmentId)){var _,v;let e=(_=this._renderManagerService.getRenderUnitById(o))==null?void 0:_.with(n.DocSkeletonManagerService),r=e==null?void 0:e.getSkeleton(),i=r==null||(v=r.getSkeletonData())==null?void 0:v.pages,a=[d.oldStart,Math.max(d.oldStart,d.oldEnd-1)],s=r!=null&&i!=null&&a.every(e=>{var t;let n=((t=r.findNodePositionByCharIndex(e))==null?void 0:t.page)??-1,a=i[n];return a!=null&&!a.isLayoutPlaceholder&&!a.isMaterializationPlaceholder});if(e!=null&&e.supportsIncrementalLayout()&&this._context.unit.documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL&&!this._context.unit.getSnapshot().disabled&&r!=null&&r.hasCompleteLayout()&&r.getLayoutProgress()==null&&i!=null&&i.length>0&&i.every(e=>!e.isLayoutPlaceholder)&&s){this._scheduleLayout(o,r,{reason:`edit`,anchor:u,priorityAnchor:h,invalidation:d,reuseMainBaseline:!0,allowMetadataOnlyStructuralTailReuse:!0},!g,p);return}}this.reRender(o,u,d,h,!g,p,Array.isArray(a.actions)&&a.actions.length>0&&l.length===0&&d==null)}))}_scheduleChangesetRender(e,t){let n=this._pendingChangesetLayoutRequest;this._pendingChangesetLayoutRequest=n==null?{anchor:e,invalidation:t}:{anchor:n.anchor==null||e==null?void 0:Math.min(n.anchor,e),invalidation:yc(n.invalidation,t)},!this._changesetRenderScheduled&&(this._changesetRenderScheduled=!0,queueMicrotask(()=>{if(this._changesetRenderScheduled=!1,this._disposed)return;let e=this._pendingChangesetLayoutRequest;this._pendingChangesetLayoutRequest=null,this.reRender(this._context.unitId,e==null?void 0:e.anchor,e==null?void 0:e.invalidation)}))}_initThemeListener(){this.disposeWithMe((0,s.combineLatest)([this._themeService.currentTheme$,this._themeService.darkMode$]).pipe((0,s.takeUntil)(this.dispose$)).subscribe(()=>{this._syncCanvasBackground(),this._markDocumentRenderDirty()}))}_markDocumentRenderDirty(){var e,t;(e=this._context.mainComponent)==null||e.makeDirty(!0),(t=this._context.components.get(`__Document_Render_Background__`))==null||t.makeDirty(!0)}_refreshPagePositionAndSelection(e=!1){if(this._refreshPagePosition(),this._isEditorRenderUnit())return;let t=this._context.unitId,n=this._getActiveEditingRange(t);this._textSelectionManagerService.refreshSelection({unitId:t,subUnitId:t},e&&n!=null)}_getFocusedSelectionInfo(e){var t;if(((t=this._univerInstanceService.getFocusedUnit())==null?void 0:t.getUnitId())===e)return this._textSelectionManagerService.getSelectionInfo({unitId:e,subUnitId:e})}_getActiveEditingRange(e){let t=this._getFocusedSelectionInfo(e);if((t==null?void 0:t.isEditing)===!0)return t.textRanges.find(e=>e.isActive)}_getActiveRange(e){let t=this._getFocusedSelectionInfo(e);return t==null?void 0:t.textRanges.find(e=>e.isActive)}_captureCompletionViewportAnchor(e,t,n,r){if(!n||this._recoveryViewportAnchor!=null)return null;let i=this._getFocusedSelectionInfo(e);if((i==null?void 0:i.isEditing)!==!0&&!r)return null;let a=i==null?void 0:i.textRanges.find(e=>e.isActive);return a==null||a.segmentId?null:this._captureViewportAnchor(t,a.endOffset,void 0)}_refreshPagePosition(){this._isEditorRenderUnit()||this._docPageLayoutService.calculatePagePosition()}_recalculateSizeBySkeleton(e,t){var n,r;let{mainComponent:i,scene:a,unitId:o,components:s}=this._context,c=i,l=s.get(`__Document_Render_Background__`),u=(n=e.getSkeletonData())==null?void 0:n.pages;if(u==null)return;let d=this._context.unit.getSnapshot().documentStyle.documentFlavor;this._syncCanvasBackground(d);let f=this._measureDocumentExtent(u,c,d),p=t??((r=e.getLayoutProgress)==null?void 0:r.call(e))??null,{width:m,height:h}=this._reserveDocumentExtent(f,u,c,d,p),g=this._docPageLayoutService.resolveSceneHeight(h);c.resize(m,h),l.resize(m,h);let _=this._editorService.getEditorRenderConfig(o);(!_||_.scrollBar)&&(a.width!==m||a.height!==g)&&a.transformByState({width:m,height:g})}_measureDocumentExtent(e,n,i){let a=0,o=0;for(let s=0,c=e.length;s<c;s++){let l=e[s],{pageWidth:u,pageHeight:d}=l;if(i===t.DocumentFlavor.MODERN){let e=wc(l);u=e.pageWidth,d=e.pageHeight}n.pageLayoutType===r.PageLayoutType.VERTICAL?(o+=d,o+=n.pageMarginTop,s===c-1&&(o+=n.pageMarginTop),a=Math.max(a,u)):n.pageLayoutType===r.PageLayoutType.HORIZONTAL&&(a+=u,s!==c-1&&(a+=n.pageMarginLeft),o=Math.max(o,d))}return{width:a,height:o}}_reserveDocumentExtent(e,n,i,a,o){let{width:s,height:c}=e;if(o!=null&&!o.complete&&n.length>0){let e=n[0];if(a===t.DocumentFlavor.MODERN)this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,o.estimatedHeight+i.pageMarginTop*2);else if(i.pageLayoutType===r.PageLayoutType.VERTICAL){let t=o.estimatedPageCount*(e.pageHeight+i.pageMarginTop)+i.pageMarginTop;this._reservedLayoutHeight=Math.max(this._reservedLayoutHeight,t)}else{let t=o.estimatedPageCount*(e.pageWidth+i.pageMarginLeft);this._reservedLayoutWidth=Math.max(this._reservedLayoutWidth,t)}a===t.DocumentFlavor.MODERN||i.pageLayoutType===r.PageLayoutType.VERTICAL?c=Math.max(c,this._reservedLayoutHeight):s=Math.max(s,this._reservedLayoutWidth)}else this._reservedLayoutWidth=s,this._reservedLayoutHeight=c;return{width:s,height:c}}_syncCanvasBackground(e=this._context.unit.getSnapshot().documentStyle.documentFlavor){var t;let n=this._editorService.getEditorRenderConfig(this._context.unitId),r=n==null?void 0:n.canvasStyle.backgroundColor,i=Se({documentFlavor:e,canvasColorService:this._context.engine.canvasColorService,editorBackgroundColor:r,isEditor:this._isEditorRenderUnit()});this._context.engine.getCanvas().getCanvasEle().style.backgroundColor=i.canvasElementBackgroundColor;let a=this._context.components.get(`__Document_Render_Background__`);a==null||(t=a.setFillColors)==null||t.call(a,i.docBackgroundFillColor,i.docBackgroundFillColor,i.docBackgroundFillColor,i.docBackgroundFillColor)}_getEditorBackgroundConfig(){if(!this._isEditorRenderUnit())return{};let e=`transparent`;return{backgroundFillColor:e,pageFillColor:e,pageStrokeColor:e,marginStrokeColor:e}}_isEditorRenderUnit(e=this._context.unitId){return this._editorService.isEditor(e)||(0,t.isInternalEditorID)(e)}};Cc=B([z(1,t.ICommandService),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,J),z(5,r.IRenderManagerService),z(6,t.IUniverInstanceService),z(7,(0,t.Inject)(Hs)),z(8,(0,t.Inject)(n.DocSelectionManagerService)),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Inject)(t.ThemeService)),z(11,(0,t.Inject)(n.DocLayoutExecutorService)),z(12,(0,t.Inject)(Ps)),z(13,t.ILogService)],Cc);function wc(e){let{pageWidth:t,pageHeight:n}=e,{marginLeft:r,marginRight:i,marginTop:a,marginBottom:o,skeDrawings:s,skeTables:c}=e;t===1/0&&(t=e.width+r+i),n===1/0&&(n=e.height+a+o);for(let e of s.values())n=Math.max(n,e.aTop+e.height+a+o);for(let e of c.values())n=Math.max(n,e.top+e.height+a+o);return{pageWidth:t,pageHeight:n}}function Tc(e){let{dataStream:n}=e.body??{},r=[t.DataStreamTreeTokenType.TABLE_START,t.DataStreamTreeTokenType.TABLE_CELL_END,t.DataStreamTreeTokenType.TABLE_CELL_START,t.DataStreamTreeTokenType.TABLE_END,t.DataStreamTreeTokenType.TABLE_ROW_END,t.DataStreamTreeTokenType.TABLE_ROW_START,t.DataStreamTreeTokenType.COLUMN_BREAK,t.DataStreamTreeTokenType.PAGE_BREAK,t.DataStreamTreeTokenType.TAB,t.DataStreamTreeTokenType.DOCS_END,t.DataStreamTreeTokenType.CUSTOM_BLOCK];if(typeof n==`string`)for(let e=0;e<n.length;e++){let t=n[e];if(!r.includes(t))return e}return 0}function Ec(e,r){let i=e.body?(0,n.getTopLevelSectionBreaks)(e.body):[],a=(r==null?void 0:r.sectionId)==null?-1:i.findIndex(e=>e.sectionId===r.sectionId),o=a<0?void 0:i[a],s=o==null?{}:(0,t.resolveSectionHeaderFooterReferences)(e.documentStyle,i,a);return{sectionId:o==null?void 0:o.sectionId,sectionIndex:a,sections:i,section:o,config:{...e.documentStyle,...o,...s}}}function Dc(e,i,a,o){let{sectionId:s,config:c}=Ec(e.getDataModel().getSnapshot(),o),{defaultHeaderId:l,defaultFooterId:u,evenPageHeaderId:d,evenPageFooterId:f,firstPageHeaderId:p,firstPageFooterId:m,evenAndOddHeaders:h,useFirstPageHeaderFooter:g}=c,_=o?o.pageNumber===o.pageNumberStart:a===0,v=o?o.pageNumber%2==0:a%2==1;if(i===r.DocumentEditArea.BODY)return{createType:null,headerFooterId:null,sectionId:s};let y=i===r.DocumentEditArea.HEADER;if(!y&&i!==r.DocumentEditArea.FOOTER)throw Error(`Invalid editArea: ${i}`);let b=y?{first:[p,n.HeaderFooterType.FIRST_PAGE_HEADER],even:[d,n.HeaderFooterType.EVEN_PAGE_HEADER],default:[l,n.HeaderFooterType.DEFAULT_HEADER]}:{first:[m,n.HeaderFooterType.FIRST_PAGE_FOOTER],even:[f,n.HeaderFooterType.EVEN_PAGE_FOOTER],default:[u,n.HeaderFooterType.DEFAULT_FOOTER]},[x,S]=g===t.BooleanNumber.TRUE&&_?b.first:h===t.BooleanNumber.TRUE&&v?b.even:b.default;return{createType:x?null:S,headerFooterId:x??null,sectionId:s}}let Oc=`COMPONENT_DOC_HEADER_FOOTER_PANEL`,kc={id:`sidebar.operation.doc-header-footer-panel`,type:t.CommandType.OPERATION,handler:async(e,n)=>{let r=e.get(a.ISidebarService),i=e.get(t.LocaleService);switch(n.value){case`open`:r.open({header:{title:i.t(`docs-ui.headerFooter.panel`)},children:{label:Oc},onClose:()=>{},width:400});break;default:r.close()}return!0}},Ac=`doc.command.core-header-footer`,jc={id:Ac,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a;let o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.IRenderManagerService),{unitId:l,segmentId:u,createType:d,headerFooterProps:f,sectionId:p}=i,m=(a=c.getRenderUnitById(l))==null?void 0:a.with(n.DocSkeletonManagerService),h=s.getUnit(l,t.UniverInstanceType.UNIVER_DOC),g=m==null?void 0:m.getViewModel();if(h==null||g==null)return!1;let _=g.getEditArea(),v=h.getSnapshot(),y=p,b=v.body?(0,n.getTopLevelSectionBreaks)(v.body):[],x=y==null?-1:b.findIndex(e=>e.sectionId===y),S=x<0?void 0:b[x],C=y==null?v.documentStyle:{...v.documentStyle,...S,...(0,t.resolveSectionHeaderFooterReferences)(v.documentStyle,b,x)},w=d;return f!=null&&Object.keys(f).forEach(e=>{let i=f[e];w==null&&e===`useFirstPageHeaderFooter`&&i===t.BooleanNumber.TRUE&&!C.firstPageHeaderId?w=_===r.DocumentEditArea.HEADER?n.HeaderFooterType.FIRST_PAGE_HEADER:n.HeaderFooterType.FIRST_PAGE_FOOTER:w==null&&e===`evenAndOddHeaders`&&i===t.BooleanNumber.TRUE&&!C.evenPageHeaderId&&(w=_===r.DocumentEditArea.HEADER?n.HeaderFooterType.EVEN_PAGE_HEADER:n.HeaderFooterType.EVEN_PAGE_FOOTER)}),o.syncExecuteCommand(n.CreateHeaderFooterCommand.id,{unitId:l,segmentId:u,createType:w,headerFooterProps:f,createMode:y==null?`pair`:`single`,sectionId:y})}},Mc={id:`doc.command.open-header-footer-panel`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a;let o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.IRenderManagerService),l=s.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null)return!1;let u=l.getUnitId(),d=c.getRenderUnitById(u),f=d==null?void 0:d.with(n.DocSkeletonManagerService),p=f==null?void 0:f.getViewModel(),m=f==null?void 0:f.getSkeleton(),h=d==null?void 0:d.with(q),g=m==null||(a=m.getSkeletonData())==null?void 0:a.pages;if(p==null||h==null||!(g!=null&&g.length))return!1;let _=h.getSegmentPage(),v=_>=0&&_<g.length?_:0,y=g[v];p.setEditArea(r.DocumentEditArea.HEADER);let{createType:b,headerFooterId:x,sectionId:S}=Dc(p,r.DocumentEditArea.HEADER,v,y);if(h.setSegmentPage(v),b!=null){let e=(0,t.generateRandomId)(6);if(h.setSegment(e),!await o.executeCommand(jc.id,{unitId:u,createType:b,segmentId:e,sectionId:S}))return h.setSegment(``),h.setSegmentPage(-1),p.setEditArea(r.DocumentEditArea.BODY),!1}else x!=null&&h.setSegment(x);return o.executeCommand(kc.id,{value:`open`})}},Nc={id:`doc.command.close-header-footer`,type:t.CommandType.COMMAND,handler:async(e,i)=>{var a,o,s;let c=e.get(t.ICommandService),l=e.get(r.IRenderManagerService),u=e.get(n.DocSelectionManagerService),d=e.get(t.IUniverInstanceService),f=(i==null?void 0:i.unitId)??((a=d.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:a.getUnitId());if(f==null)return!1;let p=l.getRenderUnitById(f);if(p==null)return!1;let m=p.with(n.DocSkeletonManagerService),h=m==null?void 0:m.getViewModel();if(h==null||h.getEditArea()===r.DocumentEditArea.BODY)return!1;let g=m==null?void 0:m.getSkeleton();if(g==null)return!1;let{scene:_}=p,v=_.getTransformerByCreate(),y=p.with(q);return u.replaceDocRanges([]),v.clearSelectedObjects(),y.setSegment(``),y.setSegmentPage(-1),h.setEditArea(r.DocumentEditArea.BODY),(typeof g.getSkeletonData==`function`?((o=g.getSkeletonData())==null?void 0:o.pages.length)??0:0)===0&&g.calculate(),(s=p.mainComponent)==null||s.makeDirty(!0),queueMicrotask(()=>{let e=d.getUnit(f),t=e==null?void 0:e.getSnapshot();if(t==null)return;let n=Tc(t);u.replaceDocRanges([{startOffset:n,endOffset:n}])}),c.executeCommand(kc.id,{value:`close`}),!0}};function Pc(e,t){let n=Fc(e.left,e.top,t),r=Fc(e.right,e.bottom,t);return{left:n.x,top:n.y,right:r.x,bottom:r.y}}function Fc(e,t,n){let{scaleX:r,scaleY:i}=n.getAncestorScale(),a=n.getViewport(`viewMain`);if(!a)return{x:e,y:t};let{viewportScrollX:o,viewportScrollY:s}=a;return{x:(e-o)*r,y:(t-s)*i}}function Ic(e,t,n){let{scaleX:r,scaleY:i}=n.getAncestorScale(),a=n.getViewport(`viewMain`);if(!a)return{x:e,y:t};let{viewportScrollX:o,viewportScrollY:s}=a;return{x:e/r+o,y:t/i+s}}let Lc=(e,t)=>{let{scene:i,mainComponent:a,engine:o}=t,s=t.with(n.DocSkeletonManagerService).getSkeleton(),c;if(e.collapsed){let t=s.findNodePositionByCharIndex(e.startOffset,!0,e.segmentId,e.segmentPage);t&&(c={startPosition:t,endPosition:t})}else c=Ve(s,e.startOffset,e.endOffset-1,e.segmentId,e.segmentPage);let l=a;if(!c)return;let u=l.getOffsetConfig(),{docsLeft:d,docsTop:f}=u,p=o.getCanvasElement();if(p==null)return;let m=p.getBoundingClientRect(),h=(0,r.pxToNum)(p.style.width),{top:g,left:_,width:v}=m,y=v/h,{scaleX:b,scaleY:x}=i.getAncestorScale(),{borderBoxPointGroup:S}=new Ze(u,s).getRangePointData(c.startPosition,e.collapsed?c.startPosition:c.endPosition);return wt(S).map(e=>Pc(e,i)).map(e=>({left:(e.left+d*b)*y+_,right:(e.right+d*b)*y+_,top:(e.top+f*x)*y+g,bottom:(e.bottom+f*x)*y+g}))},Rc=class extends t.Disposable{constructor(e,t,n,r){super(),this._globalPopupManagerService=e,this._renderManagerService=t,this._univerInstanceService=n,this._commandService=r,R(this,`_popupCountByUnit`,new Map),R(this,`_popupUnits$`,new s.BehaviorSubject(new Set)),R(this,`popupUnits$`,this._popupUnits$.asObservable())}dispose(){this._popupCountByUnit.clear(),this._popupUnits$.next(new Set),this._popupUnits$.complete(),super.dispose()}_beginPopupActivity(e){this._popupCountByUnit.set(e,(this._popupCountByUnit.get(e)??0)+1),this._publishPopupUnits();let t=!1;return{dispose:()=>{if(t)return;t=!0;let n=this._popupCountByUnit.get(e)??0;n<=1?this._popupCountByUnit.delete(e):this._popupCountByUnit.set(e,n-1),this._publishPopupUnits()}}}_publishPopupUnits(){this._popupUnits$.next(new Set(this._popupCountByUnit.keys()))}getRangeBounds(e,t){let n=this._renderManagerService.getRenderUnitById(t);return n?Lc(e,n):void 0}_shouldUpdateForCommand(e,t){if(e.id!==vo.id&&e.id!==n.RichTextEditingMutation.id)return!1;let r=e.params;return(r==null?void 0:r.unitId)==null||r.unitId===t}_createRectPositionObserver(e,n){let i=()=>{let{scene:t,engine:i}=n,a=typeof e==`function`?e():e,o=i.getCanvasElement();if(o==null)return;let s=o.getBoundingClientRect(),c=(0,r.pxToNum)(o.style.width),l=Pc(a,t),{top:u,left:d,width:f}=s,p=f/c;return{left:l.left*p+d,right:l.right*p+d,top:l.top*p+u,bottom:l.bottom*p+u}},a=i();if(a==null)throw Error(`Current render canvas not found, unitId: ${n.unitId}`);let o=new s.BehaviorSubject(a),c=new t.DisposableCollection,l=()=>{try{let e=i();e&&o.next(e)}catch{}};c.add(this._commandService.onCommandExecuted(e=>{this._shouldUpdateForCommand(e,n.unitId)&&l()}));let u=n.scene.getViewport(`viewMain`);return u&&c.add(u.onScrollAfter$.subscribeEvent(()=>{l()})),c.add(n.scene.onTransformChange$.subscribeEvent(()=>{l()})),{position:a,position$:o,disposable:c,updatePosition:l}}_createObjectPositionObserver(e,t){let n=this._createRectPositionObserver(()=>{let{left:t,top:n,width:r,height:i}=e;return{left:t,right:t+r,top:n,bottom:n+i}},t);return n.disposable.add(e.onTransformChange$.subscribeEvent(n.updatePosition)),n}_createRangePositionObserver(e,r){var i;let a=Lc(e,r)??[],o=new s.BehaviorSubject(a),c=new t.DisposableCollection,l=()=>{try{o.next(Lc(e,r)??[])}catch{}},u=(i=r.with(n.DocSkeletonManagerService).getSkeleton().dirty$)==null?void 0:i.subscribe(l);u&&c.add(u),c.add(this._commandService.onCommandExecuted(e=>{this._shouldUpdateForCommand(e,r.unitId)&&l()}));let d=r.scene.getViewport(`viewMain`);return d&&c.add(d.onScrollAfter$.subscribeEvent(()=>{l()})),c.add(r.scene.onTransformChange$.subscribeEvent(()=>{l()})),{positions:a,positions$:o,disposable:c}}attachPopupToRect(e,t,n){let r=this._renderManagerService.getRenderUnitById(n);if(!r)throw Error(`Current render not found, unitId: ${n}`);let i=this._resolveEmbeddedPopupInjector(n,r),a=this._resolvePopupManagerService(i),{position:o,position$:s,disposable:c}=this._createRectPositionObserver(e,r),l=a.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:i,anchorRect:o,anchorRect$:s,canvasElement:r.engine.getCanvasElement()}),u=t.requiresStableLayout===!1?null:this._beginPopupActivity(n);return{dispose:()=>{a.removePopup(l),s.complete(),c.dispose(),u==null||u.dispose()},canDispose:()=>a.activePopupId!==l}}attachPopupToObject(e,t,n){let r=this._renderManagerService.getRenderUnitById(n);if(!r)throw Error(`Current render not found, unitId: ${n}`);let i=this._resolveEmbeddedPopupInjector(n,r),a=this._resolvePopupManagerService(i),{position:o,position$:s,disposable:c}=this._createObjectPositionObserver(e,r),l=a.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:i,anchorRect:o,anchorRect$:s,canvasElement:r.engine.getCanvasElement()}),u=t.requiresStableLayout===!1?null:this._beginPopupActivity(n);return{dispose:()=>{a.removePopup(l),s.complete(),c.dispose(),u==null||u.dispose()},canDispose:()=>a.activePopupId!==l}}attachPopupToRange(e,t,n){if(!this._univerInstanceService.getUnit(n))throw Error(`Document not found, unitId: ${n}`);let{direction:r=`top`,multipleDirection:i}=t,a=this._renderManagerService.getRenderUnitById(n);if(!a)throw Error(`Current render not found, unitId: ${n}`);let o=this._resolveEmbeddedPopupInjector(n,a),c=this._resolvePopupManagerService(o),{positions$:l,disposable:u}=this._createRangePositionObserver(e,a),d=n=>{if(t.rangeAnchor===`selection-end`){let t=e.direction===`backward`,r=t?n[0]:n[n.length-1],i=t?r.left:r.right;return{...r,left:i,right:i}}return r.includes(`top`)?n[0]:n[n.length-1]},f=l.pipe((0,s.filter)(e=>e.length>0),(0,s.map)(d)),p,m=null,h=()=>{p!=null&&(c.removePopup(p),p=void 0),m==null||m.dispose(),m=null};return u.add(l.subscribe(e=>{if(e.length===0){h();return}p??(p=c.addPopup({...t,unitId:n,subUnitId:`default`,connectorInjector:o,anchorRect:d(e),anchorRect$:f,excludeRects:e,excludeRects$:l,direction:[`top`,`bottom`,`horizontal`].some(e=>r.includes(e))&&e.length>1?i??r:r,canvasElement:a.engine.getCanvasElement()}),m=t.requiresStableLayout===!1?null:this._beginPopupActivity(n))})),{dispose:()=>{h(),l.complete(),u.dispose()},canDispose:()=>p==null||c.activePopupId!==p}}_resolveEmbeddedPopupInjector(e,t){var n,r;return t.isMainScene===!1||((n=this._univerInstanceService.getUnitCreateOptions(e))==null?void 0:n.embeddedRender)===!0?(r=t.getInjector)==null?void 0:r.call(t):void 0}_resolvePopupManagerService(e){return e!=null&&e.has(a.ICanvasPopupService)?e.get(a.ICanvasPopupService):this._globalPopupManagerService}};Rc=B([z(0,(0,t.Inject)(a.ICanvasPopupService)),z(1,r.IRenderManagerService),z(2,t.IUniverInstanceService),z(3,t.ICommandService)],Rc);let zc=(e,t,n,r)=>{let i=n.getSkeletonData(),a=e.collapsed?e.startOffset:e.endOffset-1;if(e.segmentId){var o,s;let t=Array.from((i==null||(o=i.skeFooters.get(e.segmentId))==null?void 0:o.values())??[])[0]??Array.from((i==null||(s=i.skeHeaders.get(e.segmentId))==null?void 0:s.values())??[])[0];t&&(a=Math.min(t.ed,a))}let c=Ve(n,e.startOffset,a,e.segmentId,r);if(!c)return;let l=t.getOffsetConfig(),{borderBoxPointGroup:u}=new Ze(l,n).getRangePointData(c.startPosition,c.endPosition);return wt(u).map(e=>({top:e.top+l.docsTop-4,bottom:e.bottom+l.docsTop+4,left:e.left+l.docsLeft,right:e.right+l.docsLeft}))},Bc=(e,t,n,r)=>{let i=[];for(let a of e){let e=a.top;for(let o of a.columns){let s=o.left,c=a.colCount===1?r:o.width,l=null;for(let r of o.lines){let a=r.paragraphIndex;if(r.paragraphStart){l&&=(i.push(l),null);let o={top:t+e+r.top,left:n+s,right:n+s+c,bottom:t+e+r.top+r.lineHeight};l={paragraphStart:r.st,paragraphEnd:a,startIndex:a,rect:o,fisrtLine:{top:t+e+r.top+r.marginTop+r.paddingTop,left:n+s,right:n+s+c,bottom:t+e+r.top+r.marginTop+r.paddingTop+r.contentHeight}}}else l&&l.startIndex===a&&(l.rect.bottom=t+e+r.top+r.lineHeight)}l&&i.push(l)}}return i},Vc=(e,t,n)=>{let r=[],i=new Map;for(let a of e){let{column:e,line:o,lineWidth:s,pageLeft:c,sectionTop:l}=a,u=o.paragraphIndex,d=c+e.left+t,f=l+o.top+n,p=Hc(a,f),m=`${a.source}:${a.pageIndex}:${c}:${e.left}:${u}`;if(o.paragraphStart){let e=i.get(m);e&&r.push(e),i.set(m,{paragraphStart:o.st,paragraphEnd:u,startIndex:u,rect:{top:f,left:d,right:d+s,bottom:p},fisrtLine:{top:f+o.marginTop+o.paddingTop,left:d,right:d+s,bottom:f+o.marginTop+o.paddingTop+o.contentHeight}})}else{let e=i.get(m);e&&(e.rect.bottom=p)}}return r.push(...i.values()),r};function Hc(e,t){let n=t+e.line.lineHeight;if(e.source!==`column`||e.line!==e.column.lines[e.column.lines.length-1]||!Number.isFinite(e.page.pageHeight))return n;let r=t-e.line.top-e.section.top;return Math.max(n,r+e.page.pageHeight)}let Uc=(e,t,n,r=-1)=>{let i=n.findPositionByGlyph(e,r);if(!i)return;let a=t.getOffsetConfig(),o={...i,isBack:!0},{borderBoxPointGroup:s}=new Ze(a,n).getRangePointData(o,o),c=wt(s)[0];if(c)return{top:c.top+a.docsTop,bottom:c.bottom+a.docsTop,left:c.left+a.docsLeft,right:c.left+a.docsLeft+e.width}};function Wc(e,t,n){let r=qc(e,t);return!r||!Jc(n.x,n.y,r.rect)?null:r}function Gc(e,t,n){return Wc(e,t,n)}function Kc(e){return e===t.PresetListType.CHECK_LIST||e===t.PresetListType.CHECK_LIST_CHECKED}function qc(e,t){return t!=null&&t.bullet?{paragraph:t,rect:{bottom:e.firstLine.bottom,left:e.rect.left,right:Math.min(e.rect.right,e.rect.left+36),top:e.firstLine.top},segmentId:e.segmentId,segmentPageIndex:e.pageIndex}:null}function Jc(e,t,n){let{left:r,right:i,top:a,bottom:o}=n;return e>=r&&e<=i&&t>=a&&t<=o}function Yc(e){return Math.max(0,e.right-e.left)*Math.max(0,e.bottom-e.top)}function Xc(e,t){return e.left<=t.left&&e.right>=t.right&&e.top<=t.top&&e.bottom>=t.bottom}function Zc(e){return Math.max(0,e.paragraphEnd-e.paragraphStart)}function Qc(e){return e.sort((e,t)=>Yc(e.rect)-Yc(t.rect)||Zc(e)-Zc(t))[0]}function $c(e){return e.filter(t=>!e.some(e=>e!==t&&Yc(e.rect)<Yc(t.rect)&&Xc(t.rect,e.rect)))}function el(e){return{bottom:e.bottom,left:e.left-72,right:e.right,top:e.top-42}}function tl(e,t,n){let r=nl(n),i=r?e-(n.leadingInsetLeft??0):e;return{scrollLeft:r?n.scrollLeft:0,visibleLeft:i,visibleRight:i+(r?n.viewportWidth:t)}}function nl(e){return e!=null&&(e.leadingInsetLeft??0)+e.contentWidth+(e.trailingInsetRight??0)>e.viewportWidth}let rl=class extends t.Disposable{get hoverParagraph(){return this._hoverParagraph$.value}get hoverParagraphLeft(){return this._hoverParagraphLeft$.value}get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}get _documents(){return this._context.mainComponent}constructor(e,t){super(),this._context=e,this._docSkeletonManagerService=t,R(this,`_hoverCustomRanges$`,new s.BehaviorSubject([])),R(this,`hoverCustomRanges$`,this._hoverCustomRanges$.pipe((0,s.distinctUntilChanged)((e,t)=>e.length===t.length&&e.every((e,n)=>t[n].range.rangeId===e.range.rangeId&&t[n].segmentId===e.segmentId&&t[n].segmentPageIndex===e.segmentPageIndex&&t[n].range.startIndex===e.range.startIndex)))),R(this,`_clickCustomRanges$`,new s.Subject),R(this,`clickCustomRanges$`,this._clickCustomRanges$.asObservable()),R(this,`_pointerDownCustomRanges$`,new s.Subject),R(this,`pointerDownCustomRanges$`,this._pointerDownCustomRanges$.asObservable()),R(this,`_hoverBullet$`,new s.Subject),R(this,`hoverBullet$`,this._hoverBullet$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.paragraph.startIndex)===(t==null?void 0:t.paragraph.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.segmentPageIndex)===(t==null?void 0:t.segmentPageIndex)))),R(this,`_clickBullet$`,new s.Subject),R(this,`clickBullets$`,this._clickBullet$.asObservable()),R(this,`_contextMenuBullet$`,new s.Subject),R(this,`contextMenuBullets$`,this._contextMenuBullet$.asObservable()),R(this,`_hoverParagraph$`,new s.BehaviorSubject(null)),R(this,`hoverParagraph$`,this._hoverParagraph$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.startIndex)===(t==null?void 0:t.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverParagraphRealTime$`,this._hoverParagraph$.asObservable()),R(this,`_hoverParagraphLeft$`,new s.BehaviorSubject(null)),R(this,`hoverParagraphLeft$`,this._hoverParagraphLeft$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.startIndex)===(t==null?void 0:t.startIndex)&&(e==null?void 0:e.segmentId)===(t==null?void 0:t.segmentId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverParagraphLeftRealTime$`,this._hoverParagraphLeft$.asObservable()),R(this,`_hoverTableCell$`,new s.Subject),R(this,`hoverTableCell$`,this._hoverTableCell$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.rowIndex)===(t==null?void 0:t.rowIndex)&&(e==null?void 0:e.colIndex)===(t==null?void 0:t.colIndex)&&(e==null?void 0:e.tableId)===(t==null?void 0:t.tableId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverTableCellRealTime$`,this._hoverTableCell$.asObservable()),R(this,`_hoverTable$`,new s.Subject),R(this,`hoverTable$`,this._hoverTable$.pipe((0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.tableId)===(t==null?void 0:t.tableId)&&(e==null?void 0:e.pageIndex)===(t==null?void 0:t.pageIndex)))),R(this,`hoverTableRealTime$`,this._hoverTable$.asObservable()),R(this,`_customRangeDirty`,!0),R(this,`_customRangeCount`,-1),R(this,`_customRangeSkeletonSignature`,``),R(this,`_bulletDirty`,!0),R(this,`_paragraphDirty`,!0),R(this,`_tableBoundsDirty`,!0),R(this,`_customRangeBounds`,[]),R(this,`_bulletBounds`,[]),R(this,`_paragraphBounds`,new Map),R(this,`_paragraphLeftBounds`,[]),R(this,`_tableParagraphBounds`,new Map),R(this,`_tableParagraphBoundsByIndex`,new Map),R(this,`_segmentParagraphBounds`,new Map),R(this,`_tableViewportSignature`,``),R(this,`_tableCellBounds`,new Map),R(this,`_tableCellGeometries`,new Map),R(this,`_tableCellPages`,new Set),R(this,`_tableBounds`,new Map),R(this,`contextMenuParagraph`,null),this._initResetDirty(),this._initEvents(),this._initPointer()}dispose(){this._hoverCustomRanges$.complete(),this._clickCustomRanges$.complete(),this._pointerDownCustomRanges$.complete(),super.dispose()}_initPointer(){let e=r.CURSOR_TYPE.TEXT;this.disposeWithMe(this.hoverCustomRanges$.subscribe(t=>{t.length?(e=this._context.scene.getCursor(),this._context.scene.setCursor(r.CURSOR_TYPE.POINTER)):this._context.scene.setCursor(e)}))}_initResetDirty(){this.disposeWithMe(this._skeleton.dirty$.subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0})),this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.filter)(e=>e.type===r.TRANSFORM_CHANGE_OBSERVABLE_TYPE.resize)).subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0})),this.disposeWithMe((0,t.fromEventSubject)(this._context.scene.onTransformChange$).pipe((0,s.filter)(e=>e.type===r.TRANSFORM_CHANGE_OBSERVABLE_TYPE.scale)).subscribe(()=>{this._customRangeDirty=!0,this._bulletDirty=!0,this._paragraphDirty=!0,this._tableBoundsDirty=!0}))}_initEvents(){this.disposeWithMe((0,t.fromEventSubject)(this._context.scene.onPointerMove$).pipe((0,s.throttleTime)(30,void 0,{leading:!0,trailing:!0})).subscribe(e=>{if(e.buttons>0){this._hoverBullet$.next(null),this._hoverCustomRanges$.next([]),this._hoverParagraph$.next(null),this._hoverParagraphLeft$.next(null),this._hoverTableCell$.next(null),this._hoverTable$.next(null);return}let{x:t,y:n}=Ic(e.offsetX,e.offsetY,this._context.scene);this._hoverCustomRanges$.next(this._calcActiveRanges({x:t,y:n})),this._hoverParagraph$.next(this._calcActiveParagraph({x:t,y:n})),this._hoverParagraphLeft$.next(this._calcActiveParagraphLeft({x:t,y:n})),this._hoverBullet$.next(this._calcActiveBullet({x:t,y:n}))})),this.disposeWithMe(this._context.scene.onPointerEnter$.subscribeEvent(()=>{this._hoverBullet$.next(null),this._hoverCustomRanges$.next([])}));let e=(0,t.fromEventSubject)(this._context.mainComponent.onPointerDown$),n=(0,t.fromEventSubject)(this._context.scene.onPointerUp$);this.disposeWithMe(e.pipe((0,s.tap)(e=>{if(e.button!==0)return;let t=Ic(e.offsetX,e.offsetY,this._context.scene);this._pointerDownCustomRanges$.next(this._calcActiveRanges(t))}),(0,s.switchMap)(e=>n.pipe((0,s.take)(1),(0,s.map)(t=>({down:e,up:t})))),(0,s.filter)(({down:e,up:t})=>e.target===t.target&&(e.button===2||t.timeStamp-e.timeStamp<300))).subscribe(({down:e})=>{let n=Ic(e.offsetX,e.offsetY,this._context.scene);if(e.button===2){let t=this._calcActiveBullet(n)??this._calcActiveListParagraph(n);t&&this._contextMenuBullet$.next({...t,x:e.offsetX,y:e.offsetY});return}let r=this._calcActiveRanges(n);if(r.length){let n=r.filter(({range:e})=>e.rangeType===t.CustomRangeType.HYPERLINK).pop(),i=r.filter(({range:e})=>e.rangeType===t.CustomRangeType.SDT).sort((e,t)=>e.range.endIndex-e.range.startIndex-(t.range.endIndex-t.range.startIndex))[0];this._clickCustomRanges$.next({...n??i??r.pop(),ctrlKey:!!e.ctrlKey,metaKey:!!e.metaKey})}let i=this._calcActiveBullet(n);i&&this._clickBullet$.next(i)}))}isPointerOnBullet(e,t){return!!this._calcActiveBullet(Ic(e,t,this._context.scene))}isPointerOnInteractiveRange(e,n){return this._calcActiveRanges(Ic(e,n,this._context.scene)).some(({range:e})=>{var n;return e.rangeType===t.CustomRangeType.HYPERLINK||e.rangeType===t.CustomRangeType.SDT&&[`checkbox`,`date`,`dropDownList`,`comboBox`,`text`,`richText`,`picture`].includes((n=e.properties)==null?void 0:n.kind)})}isPointerOnNonChecklistBullet(e,t){var n;let r=this._calcActiveBullet(Ic(e,t,this._context.scene));return!(!r||Kc((n=r.paragraph.bullet)==null?void 0:n.listType))}getBulletBounds(){return this._buildBulletBounds(),[...this._bulletBounds]}getListContextMenuBulletByOffset(e,t){let n=Ic(e,t,this._context.scene);return this._calcActiveBullet(n)??this._calcActiveListParagraph(n)}_buildCustomRangeBoundsBySegment(e,t=-1){var n;let r=((n=this._context.unit.getSelfOrHeaderFooterModel(e))==null||(n=n.getBody())==null?void 0:n.customRanges)??[],i=[];return r.forEach(n=>{let r={startOffset:n.startIndex,endOffset:n.endIndex+1,collapsed:!1,segmentId:e},a;try{a=zc(r,this._documents,this._skeleton,t)}catch{return}a&&i.push({customRange:n,rects:a,segmentId:e,segmentPageIndex:t})}),i}_buildCustomRangeBounds(){var e,t,n,r,i;let a=((e=(t=this._context.unit).getBody)==null||(e=e.call(t))==null||(e=e.customRanges)==null?void 0:e.length)??0,o=((n=this._skeleton.getSkeletonData())==null?void 0:n.pages)??[],s=`${o.length}:${((r=o[o.length-1])==null?void 0:r.ed)??-1}`,c=this._customRangeCount===-1||this._customRangeCount===a,l=this._customRangeSkeletonSignature===``||this._customRangeSkeletonSignature===s;if(!this._customRangeDirty&&c&&l&&(a===0||this._customRangeBounds.length>0))return;this._customRangeDirty=!1,this._customRangeCount=a,this._customRangeSkeletonSignature=s;let u=[];u.push(...this._buildCustomRangeBoundsBySegment()),(i=this._skeleton.getSkeletonData())==null||i.pages.forEach((e,t)=>{e.headerId&&u.push(...this._buildCustomRangeBoundsBySegment(e.headerId,t)),e.footerId&&u.push(...this._buildCustomRangeBoundsBySegment(e.footerId,t))}),this._customRangeBounds=u}_calcActiveRanges(e){this._buildCustomRangeBounds();let{x:t,y:n}=e;return this._customRangeBounds.filter(e=>e.rects.some(e=>Jc(t,n,e))).map(e=>({segmentId:e.segmentId,range:e.customRange,segmentPageIndex:e.segmentPageIndex,rects:e.rects}))}_buildBulletBoundsBySegment(e,t=-1){var n;let r=(n=this._context.unit.getSelfOrHeaderFooterModel(e))==null?void 0:n.getBody(),i=((r==null?void 0:r.paragraphs)??[]).filter(e=>e.bullet),a=[],o=this._skeleton.getSkeletonData();if(!o)return a;let s=n=>{for(let o of n){let n=[...o.sections];if(o.skeTables){let e=Array.from(o.skeTables.values());n.push(...e.map(e=>e.rows.map(e=>e.cells.map(e=>e.sections))).flat(4))}for(let o of n)for(let n of o.columns)for(let o of n.lines)if(o.paragraphStart){let n=i.find(e=>e.startIndex===o.paragraphIndex);if(n){var r;let i=o,s=i==null||(r=i.divides)==null||(r=r[0])==null||(r=r.glyphGroup)==null?void 0:r[0];if(!s)continue;let c=Uc(s,this._documents,this._skeleton,t);if(!c)continue;a.push({rect:c,segmentId:e,segmentPageIndex:t,paragraph:n})}}}return a};if(e){var c,l;let t=((c=o.skeFooters.get(e))==null?void 0:c.values())??((l=o.skeHeaders.get(e))==null?void 0:l.values());return t?s(Array.from(t)):a}return s(o.pages)}_buildBulletBounds(){var e;this._bulletDirty&&(this._bulletDirty=!1,this._bulletBounds=[],this._bulletBounds.push(...this._buildBulletBoundsBySegment()),(e=this._skeleton.getSkeletonData())==null||e.pages.forEach((e,t)=>{e.headerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(e.headerId,t)),e.footerId&&this._bulletBounds.push(...this._buildBulletBoundsBySegment(e.footerId,t))}))}_calcActiveBullet(e){this._buildBulletBounds();let{x:t,y:n}=e,r=this._bulletBounds.find(e=>Jc(t,n,e.rect));if(r)return r;let i=this._calcActiveParagraph(e);return i?Wc(i,this._getParagraphByStartIndex(i.startIndex,i.segmentId),e):null}_calcActiveListParagraph(e){let t=this._calcActiveParagraph(e);return t?Gc(t,this._getParagraphByStartIndex(t.startIndex,t.segmentId),e):null}_getParagraphByStartIndex(e,t){var n;return(n=this._context.unit.getSelfOrHeaderFooterModel(t))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(t=>t.startIndex===e)}_buildParagraphBoundsBySegment(e){let t=this._skeleton.getSkeletonData(),n=this._documents.getOffsetConfig();if(!t)return null;let i=t=>{let i=new Map,a=(e,t,n,r)=>{t.forEach(t=>{if(!e.has(t.startIndex))e.set(t.startIndex,{rect:t.rect,paragraphStart:t.paragraphStart,paragraphEnd:t.paragraphEnd,startIndex:t.startIndex,rects:[t.rect],pageIndex:n,segmentId:r,firstLine:t.fisrtLine});else{let n=e.get(t.startIndex);n&&(n.rect.bottom=t.rect.bottom,n.rects.push(t.rect))}})},o=new Map;return(0,r.documentSkeletonLineIterator)(t,{docsLeft:n.docsLeft,pageMarginTop:n.pageMarginTop,unitId:this._context.unitId},e=>{if(e.source===`table-cell`)return;let t=o.get(e.pageIndex)??[];t.push(e),o.set(e.pageIndex,t)}),o.forEach((t,r)=>{a(i,Vc(t,n.docsLeft,n.docsTop),r,e)}),i};if(e){var a,o;let n=((a=t.skeFooters.get(e))==null?void 0:a.values())??((o=t.skeHeaders.get(e))==null?void 0:o.values());return n?i(Array.from(n)):null}return i(t.pages)}_buildParagraphBounds(){var e;if(!this._paragraphDirty)return;this._paragraphDirty=!1,this._tableParagraphBounds=new Map,this._tableParagraphBoundsByIndex=new Map,this._paragraphBounds=this._buildParagraphBoundsBySegment()??new Map,this._paragraphLeftBounds=Array.from(this._paragraphBounds.values()).map(e=>({...e,rect:{left:e.rect.left-60,right:e.rect.left,top:e.rect.top,bottom:e.rect.bottom}}));let t=e=>{this._segmentParagraphBounds.set(e,this._buildParagraphBoundsBySegment(e)??new Map)};(e=this._skeleton.getSkeletonData())==null||e.pages.forEach(e=>{e.headerId&&t(e.headerId),e.footerId&&t(e.footerId)})}_buildTableBounds(){let e=this._getTableViewportSignature();if(!this._tableBoundsDirty&&this._tableViewportSignature===e)return;this._tableBoundsDirty=!1,this._tableViewportSignature=e,this._tableBounds=new Map,this._tableCellBounds=new Map,this._tableCellGeometries=new Map,this._tableCellPages=new Set,this._tableParagraphBounds=new Map,this._tableParagraphBoundsByIndex=new Map;let t=this._skeleton.getSkeletonData(),n=t==null?void 0:t.pages;if(!n)return;let{docsLeft:i,docsTop:a,pageMarginTop:o}=this._documents.getOffsetConfig();for(let e of(0,r.documentSkeletonTableIterator)(n,{docsLeft:i,docsTop:a,includeCells:!1,pageMarginTop:o,skeFooters:t.skeFooters,skeHeaders:t.skeHeaders,unitId:this._context.unitId})){let t=e.tableId,n=(0,r.getTableIdAndSliceIndex)(t).tableId,i=tl(e.tableRect.left,e.table.width,(0,r.getDocsTableRenderViewport)(this._context.unitId,n));this._tableBounds.set(t,{rect:{...e.tableRect,right:i.visibleRight},pageIndex:e.pageIndex,tableId:t})}}_buildTableCellsForPage(e){if(this._tableCellPages.has(e))return;let t=this._skeleton.getSkeletonData(),n=t==null?void 0:t.pages[e];if(!t||!n)return;this._tableCellPages.add(e);let{docsLeft:i,docsTop:a,pageMarginTop:o}=this._documents.getOffsetConfig(),s=t.pages.slice(0,e).reduce((e,t)=>e+(t.pageHeight===1/0?0:t.pageHeight)+o,0),c=(0,r.documentSkeletonTableIterator)([n],{docsLeft:i,docsTop:a+s,includeCells:!0,pageMarginTop:o,skeFooters:t.skeFooters,skeHeaders:t.skeHeaders,unitId:this._context.unitId});for(let t of c){let n=t.tableId,r=t.source===`header`?t.rootPage.headerId:t.source===`footer`?t.rootPage.footerId:void 0,i=this._tableCellGeometries.get(n)??[],a=this._tableCellBounds.get(n)??[];for(let o of t.cells)i.push({cellGeometry:o,pageIndex:e,segmentId:r}),a.push({rect:o.cellRect,pageIndex:e,rowIndex:o.rowIndex,colIndex:o.columnIndex,tableId:n});this._tableCellGeometries.set(n,i),this._tableCellBounds.set(n,a)}}_buildTableCellsForDocumentRange(e,t){var n;let i=(n=this._context.unit.getSelfOrHeaderFooterModel())==null?void 0:n.getBody(),a=new Set(((i==null?void 0:i.tables)??[]).filter(n=>t>=n.startIndex&&e<n.endIndex).map(e=>e.tableId));if(a.size===0){this._tableBounds.forEach(e=>this._buildTableCellsForPage(e.pageIndex));return}this._tableBounds.forEach((e,t)=>{a.has((0,r.getTableIdAndSliceIndex)(t).tableId)&&this._buildTableCellsForPage(e.pageIndex)})}_getTableParagraphBoundsForCell(e,t,n,r){var i,a;let o=(i=this._tableParagraphBounds.get(e))==null?void 0:i.filter(e=>e.pageIndex===r&&e.rowIndex===t&&e.colIndex===n);if(o!=null&&o.length)return o;let s=(a=this._tableCellGeometries.get(e))==null?void 0:a.find(e=>e.pageIndex===r&&e.cellGeometry.rowIndex===t&&e.cellGeometry.columnIndex===n);if(!s)return[];let{cellGeometry:c,segmentId:l}=s,u=c.cell,d=(u.pageWidth??0)-(u.marginLeft??0)-(u.marginRight??0),f=Bc(u.sections,c.pageTop,c.pageLeft,d).map(e=>ol(e,c.clipLeft,c.clipRight)).filter(e=>e!=null).map(i=>({rect:i.rect,paragraphStart:i.paragraphStart,paragraphEnd:i.paragraphEnd,startIndex:i.startIndex,pageIndex:r,segmentId:l,rowIndex:t,colIndex:n,firstLine:i.fisrtLine,tableId:e})),p=(this._tableParagraphBounds.get(e)??[]).filter(e=>e.pageIndex!==r||e.rowIndex!==t||e.colIndex!==n);return p.push(...f),this._tableParagraphBounds.set(e,p),f.forEach(e=>this._tableParagraphBoundsByIndex.set(e.startIndex,e)),f}getParagraphByOffset(e,t){return this._calcActiveParagraph(Ic(e,t,this._context.scene))}_calcActiveParagraph(e){let{x:t,y:n}=e;this._buildTableBounds();let i=(0,r.getTopmostDocsTableHit)(Array.from(this._tableBounds.values()),e=>Jc(t,n,e.rect),e=>Jc(t,n,el(e.rect)),(e,t)=>Yc(t.rect)<Yc(e.rect)&&Xc(e.rect,t.rect));if(this._hoverTable$.next(i),i){var a;this._buildTableCellsForPage(i.pageIndex);let e=(a=this._tableCellBounds.get(i.tableId))==null?void 0:a.find(e=>Jc(t,n,e.rect));if(this._hoverTableCell$.next(e),!e)return null;let r=this._getTableParagraphBoundsForCell(e.tableId,e.rowIndex,e.colIndex,e.pageIndex),o=r==null?void 0:r.find(e=>Jc(t,n,e.rect));return o&&{...o,rects:[o.rect]}}return this._buildParagraphBounds(),Qc([...this._paragraphBounds.values()].filter(e=>e.rects.some(e=>Jc(t,n,e))))}_calcActiveParagraphLeft(e){this._buildParagraphBounds();let{x:t,y:n}=e;return Qc(this._paragraphLeftBounds.filter(e=>Jc(t,n,e.rect)))}get paragraphBounds(){return this._buildParagraphBounds(),this._paragraphBounds}get tableBounds(){return this._buildTableBounds(),this._tableBounds}findTableCellBound(e,t,n,i){var a;return this._buildTableBounds(),i==null?this._tableBounds.forEach((t,n)=>{(0,r.getTableIdAndSliceIndex)(n).tableId===(0,r.getTableIdAndSliceIndex)(e).tableId&&this._buildTableCellsForPage(t.pageIndex)}):this._buildTableCellsForPage(i),(a=this._tableCellBounds.get(e))==null?void 0:a.find(e=>e.rowIndex===t&&e.colIndex===n&&(i==null||e.pageIndex===i))}findParagraphBoundByIndex(e){this._buildTableBounds(),this._buildTableCellsForDocumentRange(e,e);let t=this._tableParagraphBoundsByIndex.get(e);if(!t)for(let[n,r]of this._tableCellGeometries)for(let i of r){let{st:r,ed:a}=i.cellGeometry.cell;if(!(r!=null&&a!=null&&(e<r||e>a))&&(this._getTableParagraphBoundsForCell(n,i.cellGeometry.rowIndex,i.cellGeometry.columnIndex,i.pageIndex),t=this._tableParagraphBoundsByIndex.get(e),t))return t}if(t)return t;this._buildParagraphBounds();let n=this._paragraphBounds.get(e);if(n)return n}findParagraphBoundsInRange(e,t){this._buildTableBounds(),this._buildTableCellsForDocumentRange(e,t),this._buildParagraphBounds();for(let[n,r]of this._tableCellGeometries)r.filter(n=>{let{st:r,ed:i}=n.cellGeometry.cell;return r==null||i==null||t>=r&&e<=i}).forEach(e=>this._getTableParagraphBoundsForCell(n,e.cellGeometry.rowIndex,e.cellGeometry.columnIndex,e.pageIndex));return il([...this._paragraphBounds.values()],Array.from(this._tableParagraphBounds.values()).flat().map(e=>({rect:e.rect,paragraphStart:e.paragraphStart,paragraphEnd:e.paragraphEnd,startIndex:e.startIndex,rects:[e.rect],pageIndex:e.pageIndex,segmentId:e.segmentId,firstLine:e.firstLine})),e,t)}_getTableViewportSignature(){var e;if(this._tableBounds.size>0){let e=new Set;return this._tableBounds.forEach((t,n)=>e.add((0,r.getTableIdAndSliceIndex)(n).tableId)),Array.from(e).map(e=>{let t=(0,r.getDocsTableRenderViewport)(this._context.unitId,e);return t?`${e}:${t.contentWidth}:${t.viewportWidth}:${t.scrollLeft}`:`${e}:none`}).join(`|`)}let t=((e=this._skeleton.getSkeletonData())==null?void 0:e.pages)??[],n=[];for(let e of(0,r.documentSkeletonTableIterator)(t,{includeCells:!1,pageMarginTop:this._documents.getOffsetConfig().pageMarginTop,resolveViewport:!1,unitId:this._context.unitId})){let t=(0,r.getTableIdAndSliceIndex)(e.tableId).tableId,i=(0,r.getDocsTableRenderViewport)(this._context.unitId,t);if(!i){n.push(`${t}:none`);continue}n.push(`${t}:${i.contentWidth}:${i.viewportWidth}:${i.scrollLeft}`)}return n.join(`|`)}};rl=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService))],rl);function il(e,t,n,r){let i=t.filter(e=>al(e,n,r));return i.length?i:$c(e.filter(e=>al(e,n,r)))}function al(e,t,n){return Math.max(e.paragraphStart,t)<=Math.min(e.paragraphEnd,n)}function ol(e,t,n){let r=sl(e.rect,t,n);return r?{...e,rect:r,fisrtLine:sl(e.fisrtLine,t,n)??r}:null}function sl(e,t,n){let r=Math.max(e.left,t),i=Math.min(e.right,n);return i<=r?null:{...e,left:r,right:i}}let cl={id:`doc.operation.open-paragraph-permission`,type:t.CommandType.OPERATION,handler(e){var i;let s=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=s&&((i=e.get(r.IRenderManagerService).getRenderUnitById(s.getUnitId()))==null?void 0:i.with(rl).contextMenuParagraph);if(!c)return!1;let{unitId:l,segmentId:u,paragraphId:d}=c,f=()=>{var n;return((n=e.get(t.IUniverInstanceService).getUnit(l))==null||(n=n.getSelfOrHeaderFooterModel(u))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.some(e=>e.paragraphId===d))===!0};return f()?(0,a.openObjectPermissionDialog)(e,{target:{unitId:l,objectId:(0,n.getDocumentParagraphPermissionObjectId)(u,d),objectType:o.UnitObject.DocumentParagraph},name:e.get(t.LocaleService).t(`docs-ui.objectPermission.paragraph`),commandId:n.SetDocumentPermissionCommand.id,exists:f}):!1}},ll={id:`doc.operation.open-permission-panel`,type:t.CommandType.OPERATION,handler(e){let r=e.get(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!r||(0,t.isInternalEditorID)(r.getUnitId()))return!1;let i=r,s=i.getUnitId();function*c(){let e=i.getSnapshot(),t=n.SetDocumentPermissionCommand.id,r=new Set([``,...Object.keys(e.headers??{}),...Object.keys(e.footers??{})]);for(let l of r){var a,c;let r=l?((a=e.headers)==null||(a=a[l])==null?void 0:a.body)??((c=e.footers)==null||(c=c[l])==null?void 0:c.body):e.body;for(let e of(r==null?void 0:r.sectionBreaks)??[]){if(!e.sectionId)continue;let r=(0,n.getDocumentSectionPermissionObjectId)(l,e.sectionId);yield{target:{unitId:s,objectId:r,objectType:o.UnitObject.DocumentSection},name:``,commandId:t,exists:()=>{var t;return((t=i.getSelfOrHeaderFooterModel(l))==null||(t=t.getBody())==null||(t=t.sectionBreaks)==null?void 0:t.some(t=>t.sectionId===e.sectionId))===!0}}}}}return(0,a.openObjectPermissionPanel)(e,{unitId:s,target:{unitId:s,objectId:s,objectType:o.UnitObject.DocumentSection},getTargets:c})}},ul=class extends t.Disposable{constructor(e,t){super(),this._commandService=e,this._sidebarService=t,R(this,`_id`,void 0)}openPanel(){let e={header:{title:`docs-ui.doc.slider.paragraphSetting`},id:this._id,children:{label:`doc_ui_paragraph-setting-panel`},width:300};this._sidebarService.open(e)}closePanel(){this._sidebarService.close(this._id)}};ul=B([z(0,t.ICommandService),z(1,(0,t.Inject)(a.ISidebarService))],ul);let dl={id:`sidebar.operation.doc-paragraph-setting-panel`,type:t.CommandType.OPERATION,handler:e=>(e.get(ul).openPanel(),!0)},fl=`doc_ui_section-setting-panel`,pl=class extends t.Disposable{constructor(e,t){super(),this._sidebarService=e,this._selectionManager=t,R(this,`_panelId`,`DocSectionSetting`)}openPanel(){this._sidebarService.open({header:{title:`docs-ui.doc.slider.sectionSetting`},id:this._panelId,children:{label:fl},width:300})}closePanel(){this._sidebarService.close(this._panelId)}navigateToSectionEnd(e,t,n){let r={unitId:e,subUnitId:e},i=Math.max(t,n-1);this._selectionManager.replaceDocRanges([{startOffset:i,endOffset:i}],r,!0,{shouldFocus:!1})}};pl=B([z(0,(0,t.Inject)(a.ISidebarService)),z(1,(0,t.Inject)(n.DocSelectionManagerService))],pl);let ml={id:`sidebar.operation.doc-section-setting-panel`,type:t.CommandType.OPERATION,handler:e=>(e.get(pl).openPanel(),!0)};function hl(e){let t=e.getActiveTextRange();return!(t!=null&&t.collapsed)||t.segmentId||!Number.isInteger(t.startOffset)?null:t.startOffset}let gl={id:`docs.operation.insert-column-break`,type:t.CommandType.OPERATION,handler:e=>{let r=e.get(t.IUniverInstanceService),i=e.get(n.DocSelectionManagerService),a=e.get(t.ICommandService),o=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),s=hl(i);return!o||o.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||s==null?!1:a.syncExecuteCommand(n.InsertDocumentColumnBreakCommand.id,{unitId:o.getUnitId(),offset:s})}},_l={id:`docs.operation.insert-section-break`,type:t.CommandType.OPERATION,handler:(e,r)=>{var i;if(!r)return!1;let a=e.get(t.IUniverInstanceService),o=e.get(n.DocSelectionManagerService),s=e.get(t.ICommandService),c=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=hl(o),u=c==null?void 0:c.getBody();if(!c||!u||c.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||l==null)return!1;let d=(0,t.createSectionId)(new Set((i=u.sectionBreaks)==null?void 0:i.map(e=>e.sectionId)));return s.syncExecuteCommand(n.InsertDocumentSectionBreakCommand.id,{unitId:c.getUnitId(),offset:l,sectionId:d,nextSectionType:r.sectionType})}},vl=[t.ModernDocumentWidthMode.NARROW,t.ModernDocumentWidthMode.MEDIUM,t.ModernDocumentWidthMode.WIDE],yl=e=>Object.keys(t.PAGE_SIZE).find(n=>{let{width:r,height:i}=t.PAGE_SIZE[n];return e.width===r&&e.height===i})??`A4`,bl=e=>{let n=(e==null?void 0:e.width)??t.MODERN_DOCUMENT_WIDTH[t.ModernDocumentWidthMode.MEDIUM];return vl.reduce((e,r)=>{let i=Math.abs(t.MODERN_DOCUMENT_WIDTH[e]-n);return Math.abs(t.MODERN_DOCUMENT_WIDTH[r]-n)<i?r:e},t.ModernDocumentWidthMode.MEDIUM)};function xl(e){let{children:t,muted:n}=e;return(0,u.jsx)(`label`,{className:(0,i.clsx)(`univer-text-sm univer-font-medium`,n?`univer-text-gray-500`:`univer-text-gray-900 dark:!univer-text-gray-0`),children:t})}function Sl(e){let{hooks:n,InputNumberComponent:r=i.InputNumber,SelectComponent:o=i.Select}=e,s=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC).getDocumentStyle(),c=(0,a.useDependency)(t.LocaleService),[d,f]=(0,l.useState)(()=>{var e,n;return{mode:s.documentFlavor===t.DocumentFlavor.TRADITIONAL?t.DocumentFlavor.TRADITIONAL:t.DocumentFlavor.MODERN,modernWidth:bl(s.pageSize),paperSize:yl(s.pageSize??t.PAGE_SIZE.A4),pageSize:{width:((e=s.pageSize)==null?void 0:e.width)??0,height:((n=s.pageSize)==null?void 0:n.height)??0},orientation:s.pageOrient??t.PageOrientType.PORTRAIT,margins:{top:s.marginTop??0,bottom:s.marginBottom??0,left:s.marginLeft??0,right:s.marginRight??0}}});(0,l.useEffect)(()=>{n.beforeClose=()=>d,n.beforeConfirm=()=>d},[d]);let p=e=>{f(n=>({...n,paperSize:e,pageSize:t.PAGE_SIZE[e]}))},m=(e,t)=>{f(n=>({...n,margins:{...n.margins,[e]:t||0}}))},h=e=>{f(t=>({...t,modernWidth:e}))};return(0,u.jsx)(`div`,{className:`univer-flex univer-flex-col univer-gap-4`,children:d.mode===t.DocumentFlavor.MODERN?(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2.5`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.modern-width`)}),(0,u.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2`,children:vl.map(e=>(0,u.jsxs)(`button`,{type:`button`,className:(0,i.clsx)(i.resetButtonClassName,i.borderClassName,`univer-h-16 univer-flex-col univer-gap-1 univer-rounded-lg univer-bg-gray-0 univer-text-sm univer-font-medium univer-text-gray-700 univer-transition-colors hover:univer-border-primary-500 hover:univer-text-primary-600 dark:!univer-bg-gray-900 dark:!univer-text-gray-100`,{"!univer-border-primary-500 !univer-bg-primary-50 !univer-text-primary-600 dark:!univer-bg-primary-900":d.modernWidth===e}),onClick:()=>h(e),children:[(0,u.jsx)(`span`,{children:c.t(`docs-ui.page-settings.modern-width-${e}`)}),(0,u.jsxs)(`span`,{className:`univer-text-xs univer-font-normal univer-text-gray-400`,children:[t.MODERN_DOCUMENT_WIDTH[e],`px`]})]},e))})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.paper-size`)}),(0,u.jsx)(o,{className:`univer-w-full`,value:d.paperSize,onChange:p,options:t.PAPER_TYPES.map(e=>({label:c.t(`docs-ui.page-settings.page-size.${e.toLocaleLowerCase()}`),value:e}))})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{children:c.t(`docs-ui.page-settings.custom-paper-size`)}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.top`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.height/2,value:d.margins.top,onChange:e=>m(`top`,e)})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.bottom`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.height/2,value:d.margins.bottom,onChange:e=>m(`bottom`,e)})]})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-gap-2.5`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.left`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.width/2,value:d.margins.left,onChange:e=>m(`left`,e)})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-1 univer-flex-col univer-gap-2`,children:[(0,u.jsx)(xl,{muted:!0,children:c.t(`docs-ui.page-settings.right`)}),(0,u.jsx)(r,{className:`univer-w-full`,precision:2,min:0,max:d.pageSize.width/2,value:d.margins.right,onChange:e=>m(`right`,e)})]})]})]})]})]})})}let Cl=`docs.component.page-setting`;function wl(e){var n;let r=((n=e.pageSize)==null?void 0:n.width)??0;return r?e.documentFlavor===t.DocumentFlavor.MODERN?Math.max(0,r-t.MODERN_DOCUMENT_DEFAULT_MARGIN*2):Math.max(0,r-(e.marginLeft??0)-(e.marginRight??0)):0}function Tl(e){return e.tableColumns.reduce((e,t)=>e+(t.size.width.v??0),0)}function El(e,t){if(t<=0||e.tableColumns.length===0)return!1;let n=Tl(e)||e.size.width.v;return Math.abs(n-t)<=2}function Dl(e,t,n,r,i){!n||r<=0||i<=0||Math.abs(r-i)<=2||Object.entries(n).forEach(([n,a])=>{if(!El(a,r))return;let o=Tl(a);if(o<=0)return;let s=e.replaceOp([`tableSource`,n,`size`,`width`,`v`],a.size.width.v,i);s&&t.push(s),a.tableColumns.forEach((r,a)=>{let s=r.size.width.v/o*i,c=e.replaceOp([`tableSource`,n,`tableColumns`,a,`size`,`width`,`v`],r.size.width.v,s);c&&t.push(c)})})}function Ol(e,t,r,i){var a;if(!(r!=null&&(a=r.sectionBreaks)!=null&&a.length))return;let o=new Set((0,n.getTopLevelSectionBreaks)(r).map(({sectionId:e})=>e));r.sectionBreaks.forEach((n,r)=>{if(!o.has(n.sectionId))return;let a={...n,...i},s=e.replaceOp([`body`,`sectionBreaks`,r],n,a);s&&t.push(s)})}let kl={id:`docs.command.page-setup`,type:t.CommandType.COMMAND,handler:(e,r)=>{if(!r)return!1;let i=e.get(t.IUniverInstanceService),a=e.get(t.ICommandService),o=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!o)return!1;let{documentFlavor:s,marginLeft:c,marginRight:l,marginBottom:u,marginTop:d,pageOrient:f,pageSize:p}=r,m=t.JSONX.getInstance(),h=o.getDocumentStyle(),g=o.getSnapshot(),_={...h,documentFlavor:s??h.documentFlavor,marginBottom:u,marginLeft:c,marginRight:l,marginTop:d,pageOrient:f,pageSize:p},{marginBottom:v,marginLeft:y,marginRight:b,marginTop:x,pageOrient:S,pageSize:C,documentFlavor:w}=h,T=[];if(Dl(m,T,g.tableSource,wl(h),wl(_)),_.documentFlavor!==t.DocumentFlavor.MODERN&&Ol(m,T,g.body,{marginBottom:u,marginLeft:c,marginRight:l,marginTop:d,pageOrient:f,pageSize:p}),s!==void 0){if(w===void 0){let e=m.insertOp([`documentStyle`,`documentFlavor`],s);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`documentFlavor`],w,s);e&&T.push(e)}}if(v===void 0){let e=m.insertOp([`documentStyle`,`marginBottom`],u);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginBottom`],v,u);e&&T.push(e)}if(y===void 0){let e=m.insertOp([`documentStyle`,`marginLeft`],c);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginLeft`],y,c);e&&T.push(e)}if(b===void 0){let e=m.insertOp([`documentStyle`,`marginRight`],l);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginRight`],b,l);e&&T.push(e)}if(x===void 0){let e=m.insertOp([`documentStyle`,`marginTop`],d);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`marginTop`],x,d);e&&T.push(e)}if(C===void 0){let e=m.insertOp([`documentStyle`,`pageSize`],p);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`pageSize`],C,p);e&&T.push(e)}if(S===void 0){let e=m.insertOp([`documentStyle`,`pageOrient`],f);e&&T.push(e)}else{let e=m.replaceOp([`documentStyle`,`pageOrient`],S,f);e&&T.push(e)}let E={id:n.RichTextEditingMutation.id,params:{unitId:o.getUnitId(),historyAction:n.DocHistoryAction.UpdatePageLayout,actions:[],textRanges:void 0}};return E.params.actions=T.reduce((e,n)=>t.JSONX.compose(e,n),null),!!a.syncExecuteCommand(E.id,E.params)}},Al={id:`docs.operation.open-page-setting`,type:t.CommandType.OPERATION,handler:e=>{let n=e.get(t.IConfirmService),r=e.get(t.ICommandService),i=e.get(t.LocaleService),a=n.open({id:Cl,title:{label:i.t(`docs-ui.page-settings.document-setting`)},children:{label:Cl},width:528,onClose:()=>{a.dispose()},onConfirm:async e=>{if(!e)return;let n=e.mode===t.DocumentFlavor.MODERN?{width:t.MODERN_DOCUMENT_WIDTH[e.modernWidth],height:t.PAGE_SIZE.A4.height}:t.PAGE_SIZE[e.paperSize];await r.executeCommand(kl.id,{documentFlavor:e.mode,pageOrient:e.orientation,marginTop:e.margins.top,marginBottom:e.margins.bottom,marginLeft:e.margins.left,marginRight:e.margins.right,pageSize:n})&&a.dispose()},confirmText:i.t(`docs-ui.page-settings.confirm`),cancelText:i.t(`docs-ui.page-settings.cancel`)});return!0}},jl={id:`doc.command.insert-special-character`,type:t.CommandType.COMMAND,handler:(e,r)=>{var i,a;if(!(r!=null&&r.value))return!1;let o=e.get(t.ICommandService),s=e.get(n.DocSelectionManagerService),c=e.get(t.IUniverInstanceService),l=e.get(U),u=c.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),d=s.getActiveTextRange();if(!u||!d)return!1;let{segmentId:f}=d,p=(i=u.getSelfOrHeaderFooterModel(f))==null?void 0:i.getBody();if(!p)return!1;let{value:m}=r,h=N(p,d,l.getDefaultStyle(),l.getStyleCache(),!1,((a=Be(u))==null?void 0:a.inheritParagraphStartStyle)===!0),g=ee(p.customRanges??[],d.endOffset),_=P(p.customDecorations??[],d.endOffset);return o.executeCommand(n.InsertTextCommand.id,{unitId:u.getUnitId(),body:{dataStream:m,textRuns:[{...h,st:0,ed:m.length}],customRanges:g?[{...g,startIndex:0,endIndex:m.length-1}]:[],customDecorations:_.map(e=>({...e,startIndex:0,endIndex:m.length-1}))},range:d,segmentId:f})}},Ml=`UI_PLUGIN_DOCS`,Nl=e=>{let{value:n,onChange:r,options:a}=e,o=[{id:`level-0-top`,levelIndex:0},{id:`level-1`,levelIndex:1},{id:`level-2`,levelIndex:2},{id:`level-0-bottom`,levelIndex:0}],s=[``,`univer-pl-2`,`univer-pl-4`],c=e=>{switch(e){case t.ListGlyphType.DECIMAL_ZERO:return`01`;case t.ListGlyphType.UPPER_LETTER:return`A`;case t.ListGlyphType.LOWER_LETTER:return`a`;case t.ListGlyphType.UPPER_ROMAN:return`I`;case t.ListGlyphType.LOWER_ROMAN:return`i`;default:return`1`}},l=(e,n)=>{var r;let i=t.PRESET_LIST_TYPE[e].nestingLevel,a=i[n];return a.glyphSymbol?a.glyphSymbol:((r=a.glyphFormat)==null?void 0:r.replace(/%(\d+)/g,(e,t)=>{var n;return c((n=i[Number(t)-1])==null?void 0:n.glyphType)}))??`1.`};return(0,u.jsx)(`div`,{className:`univer-grid univer-grid-cols-3 univer-gap-2 univer-p-1.5`,"data-u-editor-interaction-boundary":`true`,children:a.map(e=>(0,u.jsx)(`a`,{className:(0,i.clsx)(`univer-block univer-h-20 univer-w-[72px] univer-cursor-pointer univer-overflow-hidden univer-rounded univer-transition-all hover:univer-border-primary-500`,i.borderClassName,{"univer-border-primary-500":n===e}),onClick:()=>r(e),children:(0,u.jsx)(`div`,{className:`univer-box-border univer-grid univer-size-full univer-grid-rows-4 univer-gap-1 univer-bg-gray-50 univer-p-2 univer-text-gray-900`,"data-u-comp":`list-type-preview`,children:o.map(({id:t,levelIndex:n})=>(0,u.jsxs)(`div`,{className:(0,i.clsx)(`univer-flex univer-items-center univer-gap-1`,s[n]),children:[(0,u.jsx)(`span`,{className:`univer-w-3 univer-shrink-0 univer-overflow-hidden univer-text-center univer-text-[10px] univer-leading-none`,children:l(e,n)}),(0,u.jsx)(`span`,{className:`univer-h-1 univer-flex-1 univer-rounded univer-bg-gray-200`})]},t))})},e))})},Pl=[t.PresetListType.ORDER_LIST,t.PresetListType.ORDER_LIST_1,t.PresetListType.ORDER_LIST_2,t.PresetListType.ORDER_LIST_3,t.PresetListType.ORDER_LIST_4,t.PresetListType.ORDER_LIST_5],Fl=e=>(0,u.jsx)(Nl,{...e,options:Pl}),Il=[t.PresetListType.BULLET_LIST,t.PresetListType.BULLET_LIST_1,t.PresetListType.BULLET_LIST_2,t.PresetListType.BULLET_LIST_3,t.PresetListType.BULLET_LIST_4,t.PresetListType.BULLET_LIST_5],Ll=e=>(0,u.jsx)(Nl,{...e,options:Il}),Rl=`${Ml}_ORDER_LIST_TYPE_COMPONENT`,zl=`${Ml}_BULLET_LIST_TYPE_COMPONENT`;function Y(e){let n,r;try{n=e.get(t.IUniverInstanceService)}catch(e){if(Ju(e))return!0;throw e}try{r=e.get(Le)}catch{return!1}let i=n.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),a=i==null?void 0:i.getUnitId();return r.shouldSuppressHostInteraction(a)}function Bl(e){let i=e.get(t.IUniverInstanceService),a=e.get(r.IRenderManagerService);return new s.Observable(e=>{let o=null,s=i.focused$.subscribe(s=>{if(o==null||o.unsubscribe(),o=null,s==null||i.getUnitType(s)!==t.UniverInstanceType.UNIVER_DOC)return e.next(!0);let c=a.getRenderUnitById(s);if(c==null)return e.next(!0);o=c.with(n.DocSkeletonManagerService).getViewModel().editAreaChange$.subscribe(t=>{e.next(t===r.DocumentEditArea.HEADER||t===r.DocumentEditArea.FOOTER)})});return()=>{o==null||o.unsubscribe(),s.unsubscribe()}})}function Vl(e){let i=e.get(t.IUniverInstanceService),a=e.get(r.IRenderManagerService);return new s.Observable(e=>{let o=null,s,c=t=>{t!==s&&(s=t,e.next(t))},l=i.focused$.subscribe(e=>{if(o==null||o.unsubscribe(),o=null,!e||i.getUnitType(e)!==t.UniverInstanceType.UNIVER_DOC){c(!0);return}let s=a.getRenderUnitById(e),l=s==null?void 0:s.with(n.DocSkeletonManagerService),u=l==null?void 0:l.getViewModel();if(!u){c(!0);return}let d=e=>{let t=e??u.getEditArea();c(t===r.DocumentEditArea.HEADER||t===r.DocumentEditArea.FOOTER)};d(),o=u.editAreaChange$.subscribe(d)});return()=>{o==null||o.unsubscribe(),l.unsubscribe()}})}function Hl(e){let r=e.get(t.IUniverInstanceService),i=e.get(t.ICommandService);return new s.Observable(e=>{let a=i.onCommandExecuted(i=>{if(i.id===n.RichTextEditingMutation.id){let{unitId:n}=i.params,a=r.getUnit(n);if(a==null){e.next(!0);return}let{documentStyle:o}=a.getSnapshot();e.next((o==null?void 0:o.documentFlavor)!==t.DocumentFlavor.TRADITIONAL)}}),o=r.focused$.subscribe(n=>{if(n==null)return e.next(!0);let i=r.getUnit(n,t.UniverInstanceType.UNIVER_DOC),a=i==null?void 0:i.getSnapshot().documentStyle.documentFlavor;e.next(a!==t.DocumentFlavor.TRADITIONAL)}),s=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=s==null?void 0:s.getSnapshot().documentStyle.documentFlavor;return e.next(s==null||c!==t.DocumentFlavor.TRADITIONAL),()=>{a.dispose(),o.unsubscribe()}})}function Ul(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(n=>{let a=r.textSelection$.subscribe(r=>{if(r==null){n.next(!0);return}let{textRanges:a}=r;if(a.length!==1){n.next(!0);return}let{collapsed:o,startNodePosition:s,startOffset:c}=a[0];if(!o||c==null){n.next(!0);return}let l=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(l==null){n.next(!0);return}let u=Te(e,l.getUnitId());if(u==null){n.next(!0);return}if(u.getViewModel().getCustomRangeRaw(c)){n.next(!0);return}if(s!=null){let{path:e}=s;if(e.indexOf(`cells`)!==-1){n.next(!0);return}}n.next(!1)});return()=>a.unsubscribe()})}function X(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService),a=new s.Observable(e=>{let n=r.textSelection$.subscribe(n=>{var r;if(n==null){e.next(!0);return}let{textRanges:a,rectRanges:o}=n;if(a.length===0&&o.length===0){e.next(!0);return}let s=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(((s==null||(r=s.getBody())==null||(r=r.blockRanges)==null?void 0:r.filter(e=>e.blockType===t.DocumentBlockRangeType.CODE))??[]).some(e=>a.some(t=>Math.max(t.startOffset,e.startIndex)<=Math.min(t.endOffset,e.endIndex)))){e.next(!0);return}e.next(!1)});return()=>n.unsubscribe()});return(0,s.combineLatest)([a,Wl(e)]).pipe((0,s.map)(([e,t])=>e||t))}function Z(e,r){let i=e.get(t.IUniverInstanceService),a=e.get(t.IPermissionService);return(0,s.combineLatest)([i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),a.permissionPointUpdate$.pipe((0,s.startWith)(void 0))]).pipe((0,s.map)(([e])=>!e||!(0,n.getDocumentPermissionValue)(a,e.getUnitId(),e.getUnitId(),r)))}function Wl(e){return Z(e,o.UnitAction.Edit)}let Gl=`doc.menu.insert-emoji`,Kl=`doc.menu.insert-symbol`;function ql(e){return{id:Gl,type:a.MenuItemType.SELECTOR,icon:`SmileIcon`,tooltip:`ui.emojiPicker.emojis`,selectionsCommandId:jl.id,selections:[{label:{name:a.EMOJI_PICKER_COMPONENT,hoverable:!1,selectable:!1,props:{embedded:!0}}}],disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Jl(e){return{id:Kl,type:a.MenuItemType.SELECTOR,icon:`SymbolsIcon`,tooltip:`ui.emojiPicker.symbols`,selectionsCommandId:jl.id,selections:[{label:{name:a.SYMBOL_PICKER_COMPONENT,hoverable:!1,selectable:!1,props:{embedded:!0}}}],disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Yl(e,t){var n;let r=(e==null||(n=e.getBody())==null?void 0:n.blockRanges)??[],i=t.startOffset,a=t.collapsed?t.startOffset:t.endOffset-1;return r.some(e=>Math.max(i,e.startIndex)<=Math.min(a,e.endIndex))}function Xl(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let n=n=>{var a;let o=(a=r.__getCurrentSelection)==null?void 0:a.call(r),s=(n==null?void 0:n.textRanges)??[...r.getTextRanges()??[]],c=(n==null?void 0:n.unitId)??(o==null?void 0:o.unitId),l=c?i.getUnit(c,t.UniverInstanceType.UNIVER_DOC):i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);e.next(s.some(e=>Yl(l,e)))};n();let a=r.textSelection$.subscribe(e=>n(e));return()=>a.unsubscribe()})}function Zl(e){let r=e.get(t.ICommandService);return{id:Qn.id,type:a.MenuItemType.BUTTON,icon:`BoldIcon`,title:`docs-ui.toolbar.bold`,tooltip:`docs-ui.toolbar.bold`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.bl;i.next(a===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ql(e){let r=e.get(t.ICommandService);return{id:er.id,type:a.MenuItemType.BUTTON,icon:`ItalicIcon`,title:`docs-ui.toolbar.italic`,tooltip:`docs-ui.toolbar.italic`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.it;i.next(a===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function $l(e){let r=e.get(t.ICommandService);return{id:nr.id,type:a.MenuItemType.BUTTON,icon:`UnderlineIcon`,title:`docs-ui.toolbar.underline`,tooltip:`docs-ui.toolbar.underline`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.ul;i.next((a==null?void 0:a.s)===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function eu(e){let r=e.get(t.ICommandService);return{id:ir.id,type:a.MenuItemType.BUTTON,icon:`StrikethroughIcon`,title:`docs-ui.toolbar.strikethrough`,tooltip:`docs-ui.toolbar.strikethrough`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.st;i.next((a==null?void 0:a.s)===t.BooleanNumber.TRUE)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function tu(e){let r=e.get(t.ICommandService);return{id:or.id,type:a.MenuItemType.BUTTON,icon:`SubscriptIcon`,tooltip:`docs-ui.toolbar.subscript`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.va;i.next(a===t.BaselineOffset.SUBSCRIPT)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function nu(e){let r=e.get(t.ICommandService);return{id:cr.id,type:a.MenuItemType.BUTTON,icon:`SuperscriptIcon`,tooltip:`docs-ui.toolbar.superscript`,activated$:new s.Observable(i=>{let a=()=>{var n;if(Y(e))return;let r=Ku(e);if(r==null){i.next(!1);return}let a=(n=r.ts)==null?void 0:n.va;i.next(a===t.BaselineOffset.SUPERSCRIPT)},o=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===wr.id)&&a()});return a(),o.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ru(e){let r=e.get(t.ICommandService);return{id:fr.id,tooltip:`docs-ui.toolbar.font`,type:a.MenuItemType.SELECTOR,label:{name:a.FONT_FAMILY_COMPONENT,props:{id:fr.id}},selections:[{label:{name:a.FONT_FAMILY_ITEM_COMPONENT,hoverable:!1,selectable:!1,props:{id:fr.id}}}],value$:new s.Observable(i=>{let a=t.DEFAULT_STYLES.ff,o=()=>{var t;if(Y(e))return;let n=Ku(e);if(n==null){i.next(a);return}let r=(t=n.ts)==null?void 0:t.ff;i.next(r??a)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===fr.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function iu(e){let r=e.get(t.ICommandService);return{id:ur.id,type:a.MenuItemType.SELECTOR,tooltip:`docs-ui.toolbar.fontSize`,label:{name:a.FONT_SIZE_COMPONENT,props:{min:1,max:400}},selections:a.FONT_SIZE_LIST,value$:new s.Observable(i=>{let a=t.DEFAULT_STYLES.fs,o=()=>{var t;if(Y(e))return;let n=Ku(e);if(n==null){i.next(a);return}let r=(t=n.ts)==null?void 0:t.fs;i.next(r??a)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function au(e){let r=e.get(t.ICommandService);return{id:xo.id,type:a.MenuItemType.SELECTOR,tooltip:`docs-ui.toolbar.heading.tooltip`,label:{name:a.COMMON_LABEL_COMPONENT,props:{selections:a.HEADING_LIST}},selections:a.HEADING_LIST.map(e=>({label:{name:a.HEADING_ITEM_COMPONENT,props:{value:e.value,text:e.label}},value:e.value})),value$:new s.Observable(i=>{let a=t.NamedStyleType.NORMAL_TEXT,o=()=>{var t;if(Y(e))return;let n=qu(e);if(n==null){i.next(a);return}let r=((t=n.paragraphStyle)==null?void 0:t.namedStyleType)??a;i.next(r)},s=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&o()});return o(),s.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let ou=`doc.menu.float-text-style`,su=`doc.menu.float-toolbar`,cu=[{icon:`TextTypeIcon`,label:`docs-ui.toolbar.heading.normal`,value:t.NamedStyleType.NORMAL_TEXT},{icon:`H1Icon`,label:`docs-ui.toolbar.heading.leading1`,value:t.NamedStyleType.HEADING_1},{icon:`H2Icon`,label:`docs-ui.toolbar.heading.leading2`,value:t.NamedStyleType.HEADING_2},{icon:`H3Icon`,label:`docs-ui.toolbar.heading.leading3`,value:t.NamedStyleType.HEADING_3},{icon:`H4Icon`,label:`docs-ui.toolbar.heading.leading4`,value:t.NamedStyleType.HEADING_4},{icon:`H5Icon`,label:`docs-ui.toolbar.heading.leading5`,value:t.NamedStyleType.HEADING_5},{id:ao.id,icon:`OrderIcon`,label:`docs-ui.toolbar.order`,value:t.PresetListType.ORDER_LIST},{id:no.id,icon:`UnorderIcon`,label:`docs-ui.toolbar.unorder`,value:t.PresetListType.BULLET_LIST},{id:ro.id,icon:`TodoListDoubleIcon`,label:`docs-ui.toolbar.checklist`,value:t.PresetListType.CHECK_LIST}];function lu(e){var n,r;let i=e==null||(n=e.bullet)==null?void 0:n.listType;return i!=null&&i.startsWith(t.PresetListType.ORDER_LIST)?t.PresetListType.ORDER_LIST:i!=null&&i.startsWith(t.PresetListType.BULLET_LIST)?t.PresetListType.BULLET_LIST:i===t.PresetListType.CHECK_LIST||i===t.PresetListType.CHECK_LIST_CHECKED?t.PresetListType.CHECK_LIST:(e==null||(r=e.paragraphStyle)==null?void 0:r.namedStyleType)??t.NamedStyleType.NORMAL_TEXT}function uu(e){let r=e.get(t.ICommandService);return{id:ou,commandId:xo.id,type:a.MenuItemType.SELECTOR,icon:(0,s.of)(``),label:{name:a.COMMON_LABEL_COMPONENT,props:{selections:cu}},tooltip:`docs-ui.toolbar.heading.tooltip`,selections:cu,value$:new s.Observable(t=>{let i=()=>{Y(e)||t.next(lu(qu(e)))},a=r.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===xo.id||t===ao.id||t===no.id||t===ro.id)&&i()});return i(),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function du(e){let n=e.get(t.ICommandService),r=e.get(t.ThemeService);return{id:mr.id,icon:`FontColorDoubleIcon`,tooltip:`docs-ui.toolbar.textColor.main`,type:a.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:a.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1},value$:new s.Observable(t=>{let i=r.getColorFromTheme(`gray.900`),a=()=>{var n;if(Y(e))return;let r=Ku(e);if(!r){t.next(i);return}let a=(n=r.ts)==null||(n=n.cl)==null?void 0:n.rgb;t.next(a??i)},o=n.onCommandExecuted(e=>{e.id===mr.id&&a()});return a(),o.dispose})}],value$:new s.Observable(t=>{let i=r.getColorFromTheme(`gray.900`),a=n.onCommandExecuted(n=>{if(n.id===mr.id){if(Y(e))return;let r=n.params.value;t.next(r??i)}});return t.next(i),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function fu(e){return{id:Mc.id,type:a.MenuItemType.BUTTON,icon:`HeaderFooterIcon`,tooltip:`docs-ui.toolbar.headerFooter`,hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Hl(e),(e,t)=>e||t)}}let pu=`doc.menu.breaks`,mu=`doc.menu.section-break.next-page`,hu=`doc.menu.section-break.continuous`,gu=`doc.menu.section-break.next-column`,_u=`doc.menu.section-break.even-page`,vu=`doc.menu.section-break.odd-page`;function yu(e){return{id:pu,type:a.MenuItemType.SUBITEMS,icon:`ColumnIcon`,tooltip:`docs-ui.toolbar.breaks`,disabled$:X(e),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Hl(e),(e,t)=>e||t)}}function bu(e){return{id:gl.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.columnBreak`,disabled$:X(e)}}function xu(e,t,n,r){return{id:t,commandId:_l.id,params:{sectionType:r},type:a.MenuItemType.BUTTON,title:n,disabled$:X(e)}}function Su(e){return xu(e,mu,`docs-ui.toolbar.sectionBreakNextPage`,t.SectionType.NEXT_PAGE)}function Cu(e){return xu(e,hu,`docs-ui.toolbar.sectionBreakContinuous`,t.SectionType.CONTINUOUS)}function wu(e){return xu(e,gu,`docs-ui.toolbar.sectionBreakNextColumn`,t.SectionType.NEXT_COLUMN)}function Tu(e){return xu(e,_u,`docs-ui.toolbar.sectionBreakEvenPage`,t.SectionType.EVEN_PAGE)}function Eu(e){return xu(e,vu,`docs-ui.toolbar.sectionBreakOddPage`,t.SectionType.ODD_PAGE)}let Du=`GridIcon`,Ou=`doc.menu.table`;function ku(e){return{id:Ou,type:a.MenuItemType.SUBITEMS,icon:Du,tooltip:`docs-ui.toolbar.table.main`,disabled$:Ul(e),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),Bl(e),(e,t)=>e||t)}}function Au(e){return{id:ns.id,title:`docs-ui.toolbar.table.insert`,type:a.MenuItemType.BUTTON,icon:Du,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ju(e){return{id:ns.id,commandId:Vo.id,params:{rowCount:3,colCount:5},title:`docs-ui.toolbar.table.insert`,type:a.MenuItemType.BUTTON,icon:Du,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Mu(e){let r=e.get(t.ICommandService);return{id:po.id,type:a.MenuItemType.BUTTON,icon:`LeftJustifyingIcon`,tooltip:`docs-ui.toolbar.alignLeft`,disabled$:X(e),activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.LEFT)}});return i.next(!1),a.dispose}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Nu(e){let r=e.get(t.ICommandService);return{id:mo.id,type:a.MenuItemType.BUTTON,icon:`HorizontallyIcon`,tooltip:`docs-ui.toolbar.alignCenter`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.CENTER)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Pu(e){let r=e.get(t.ICommandService);return{id:ho.id,type:a.MenuItemType.BUTTON,icon:`RightJustifyingIcon`,tooltip:`docs-ui.toolbar.alignRight`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.RIGHT)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Fu(e){let r=e.get(t.ICommandService);return{id:go.id,type:a.MenuItemType.BUTTON,icon:`AlignTextBothIcon`,tooltip:`docs-ui.toolbar.alignJustify`,activated$:new s.Observable(i=>{let a=r.onCommandExecuted(r=>{let a=r.id;if(a===n.SetTextSelectionsOperation.id||a===fo.id){var o;if(Y(e))return;let n=qu(e);if(n==null)return;let r=(o=n.paragraphStyle)==null?void 0:o.horizontalAlign;i.next(r===t.HorizontalAlign.JUSTIFIED)}});return i.next(!1),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let Iu=[{id:po.id,value:t.HorizontalAlign.LEFT,label:`docs-ui.toolbar.alignLeft`,icon:`LeftJustifyingIcon`},{id:mo.id,value:t.HorizontalAlign.CENTER,label:`docs-ui.toolbar.alignCenter`,icon:`HorizontallyIcon`},{id:ho.id,value:t.HorizontalAlign.RIGHT,label:`docs-ui.toolbar.alignRight`,icon:`RightJustifyingIcon`},{id:go.id,value:t.HorizontalAlign.JUSTIFIED,label:`docs-ui.toolbar.alignJustify`,icon:`AlignTextBothIcon`}];function Lu(e){let r=e.get(t.ICommandService),i=new s.Observable(i=>{let a=()=>{var n;if(Y(e)){i.next(t.HorizontalAlign.LEFT);return}let r=qu(e);i.next((r==null||(n=r.paragraphStyle)==null?void 0:n.horizontalAlign)??t.HorizontalAlign.LEFT)},o=r.onCommandExecuted(e=>{(e.id===n.SetTextSelectionsOperation.id||e.id===fo.id)&&a()});return a(),o.dispose}).pipe((0,s.distinctUntilChanged)(),(0,s.shareReplay)({bufferSize:1,refCount:!0}));return{id:fo.id,type:a.MenuItemType.SELECTOR,icon:i.pipe((0,s.map)(e=>{var t;return((t=Iu.find(t=>t.value===e))==null?void 0:t.icon)??`LeftJustifyingIcon`})),tooltip:`docs-ui.toolbar.alignLeft`,selections:Iu,value$:i,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ru(e){return{id:ja.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,tooltip:`docs-ui.toolbar.horizontalLine`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let zu=e=>new s.Observable(r=>{let i=e.get(t.IUniverInstanceService),a=e.get(n.DocSelectionManagerService),o=i.focused$.subscribe(n=>{if(Y(e)||n==null)return;let o=i.getUnit(n,t.UniverInstanceType.UNIVER_DOC);if(o==null)return;let s=a.getDocRanges(),c=s.find(e=>e.isActive)??s[0];if(c){var l,u;let e=o.getSelfOrHeaderFooterModel(c==null?void 0:c.segmentId),n=t.BuildTextUtils.range.getParagraphsInRange(c,(e==null||(l=e.getBody())==null?void 0:l.paragraphs)??[],(e==null||(u=e.getBody())==null?void 0:u.dataStream)??``),i;if(n.every(e=>{if(!i){var t;i=(t=e.bullet)==null?void 0:t.listType}return e.bullet&&e.bullet.listType===i})){r.next(i);return}}r.next(void 0)});return()=>{o.unsubscribe()}});function Bu(e){return{id:ao.id,type:a.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:Rl,hoverable:!1,selectable:!1},value$:zu(e)}],icon:`OrderIcon`,tooltip:`docs-ui.toolbar.order`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:X(e),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`ORDER_LIST`)===0)))}}function Vu(e){return{id:no.id,type:a.MenuItemType.BUTTON_SELECTOR,slot:!0,selections:[{label:{name:zl,hoverable:!1,selectable:!1},value$:zu(e)}],icon:`UnorderIcon`,tooltip:`docs-ui.toolbar.unorder`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`BULLET_LIST`)===0)))}}function Hu(e){return{id:ro.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,tooltip:`docs-ui.toolbar.checklist`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:zu(e).pipe((0,s.map)(e=>!!(e&&e.indexOf(`CHECK_LIST`)===0)))}}function Uu(e){let n=e.get(t.ThemeService);return{id:gr.id,commandId:mr.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.resetColor`,icon:`NoColorDoubleIcon`,params:()=>({value:n.getColorFromTheme(`gray.900`)})}}function Wu(e){let n=e.get(t.ThemeService);return{id:Sr.id,commandId:br.id,type:a.MenuItemType.BUTTON,title:`docs-ui.toolbar.resetColor`,icon:`NoColorDoubleIcon`,params:()=>({value:n.getColorFromTheme(`primary.600`)})}}function Gu(e){let n=e.get(t.ICommandService),r=e.get(t.ThemeService);return{id:br.id,tooltip:`docs-ui.toolbar.fillColor.main`,type:a.MenuItemType.BUTTON_SELECTOR,icon:`PaintBucketDoubleIcon`,selections:[{label:{name:a.COLOR_PICKER_COMPONENT,hoverable:!1,selectable:!1},value$:new s.Observable(t=>{let i=r.getColorFromTheme(`primary.600`),a=()=>{var n;if(Y(e))return;let r=Ku(e);if(!r){t.next(i);return}let a=(n=r.ts)==null||(n=n.bg)==null?void 0:n.rgb;t.next(a??i)},o=n.onCommandExecuted(e=>{e.id===br.id&&a()});return a(),o.dispose})}],value$:new s.Observable(t=>{let i=r.getColorFromTheme(`primary.600`),a=n.onCommandExecuted(n=>{if(n.id===br.id){if(Y(e))return;let r=n.params.value;t.next(r??i)}});return t.next(i),a.dispose}),disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ku(e){var r,i,a;if(Y(e))return;let o,s,c;try{o=e.get(t.IUniverInstanceService),s=e.get(n.DocSelectionManagerService),c=e.get(U)}catch(e){if(Ju(e))return;throw e}let l=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),u=s.getDocRanges(),d=u.find(e=>e.isActive)??u[0],f=c.getDefaultStyle(),p=c.getStyleCache()??{},m=qu(e),h=m!=null&&(r=m.paragraphStyle)!=null&&r.namedStyleType?t.NAMED_STYLE_MAP[m==null||(i=m.paragraphStyle)==null?void 0:i.namedStyleType]:null;if(l==null||d==null)return{ts:{...f,...h,...p}};let{segmentId:g}=d,_=(a=l.getSelfOrHeaderFooterModel(g))==null?void 0:a.getBody();if(_==null)return{ts:{...f,...h,...p}};let v=Or(_,d,{});return t.Tools.deleteNull(v),{ts:{...f,...h,...v,...p}}}function qu(e){var r;if(Y(e))return;let i,a;try{i=e.get(t.IUniverInstanceService),a=e.get(n.DocSelectionManagerService)}catch(e){if(Ju(e))return;throw e}let o=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),s=a.getDocRanges(),c=s.find(e=>e.isActive)??s[0];if(o==null||c==null)return;let{startOffset:l,segmentId:u}=c,d=(r=o.getSelfOrHeaderFooterModel(u))==null||(r=r.getBody())==null?void 0:r.paragraphs;if(d==null)return;let f=-1;for(let e of d){let{startIndex:t}=e;if(l>f&&l<=t)return e;f=t}return null}function Ju(e){return e instanceof Error?e.name===`InjectorAlreadyDisposedError`||e.message.includes(`Injector cannot be accessed after it was disposed`):!1}function Yu(e){return{id:Al.id,type:a.MenuItemType.BUTTON,icon:`DocSettingIcon`,tooltip:`docs-ui.toolbar.pageSetup`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),disabled$:Wl(e)}}let Xu=e=>{let r=e.get(n.DocSelectionManagerService);return new s.Observable(e=>{let n=r.textSelection$.subscribe(()=>{r.getDocRanges().some(e=>e.collapsed===!1||e.rangeType===t.DOC_RANGE_TYPE.RECT)?e.next(!1):e.next(!0)});return()=>n.unsubscribe()})},Zu=e=>{let t=e.get(n.DocSelectionManagerService);return new s.Observable(e=>{let n=()=>{let n=t.getDocRanges(),r=n[0];e.next(n.length!==1||r.collapsed!==!0&&r.startOffset!==r.endOffset)};n();let r=t.textSelection$.subscribe(n);return()=>r.unsubscribe()})};function Qu(...e){return(0,s.combineLatest)(e).pipe((0,s.map)(e=>e.some(Boolean)))}function $u(e){if(e.length<2)return!0;let t=e.map(e=>e.tableId);return t.every(e=>e===t[0])}function ed(e,n,r){let i=n.getRectRanges(),a=n.getActiveTextRange();if(i&&i.length&&$u(i)&&a==null){e.next(!1);return}if(a&&(i==null||i.length===0)){var o;let{segmentId:n,startOffset:i,endOffset:s}=a;if(a.collapsed!==!0&&i!==s){e.next(!0);return}let c=r.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),l=c==null||(o=c.getSelfOrHeaderFooterModel(n))==null||(o=o.getBody())==null?void 0:o.tables;if(l&&l.length&&l.some(e=>{let{startIndex:t,endIndex:n}=e;return i>t&&i<n||s>t&&s<n})){e.next(!1);return}}e.next(!0)}let td=e=>{let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let t=r.textSelection$.subscribe(()=>{ed(e,r,i)});return ed(e,r,i),()=>t.unsubscribe()})};function nd(e){return{id:oa.name,commandId:oa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Copy)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function rd(e){return{id:dl.id,type:a.MenuItemType.BUTTON,title:`docs-ui.doc.menu.paragraphSetting`,icon:`ParagraphSettingIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function id(e){return{id:ca.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.cut`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Copy),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function ad(e){return{id:da.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.paste`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function od(e){return{id:Pa.id,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.select`,disabled$:Zu(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function sd(e){return{id:Na.id,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.selectAll`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function cd(e){return{id:Vn.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.delete`,disabled$:Qu(Xu(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let ld=`doc.menu.table-insert`;function ud(e){return{id:ld,type:a.MenuItemType.SUBITEMS,title:`docs-ui.table.insert`,icon:`InsertDoubleIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),td(e),(e,t)=>e||t)}}function dd(e){let r=e.get(n.DocSelectionManagerService),i=e.get(t.IUniverInstanceService);return new s.Observable(e=>{let n=()=>{var n;let a=i.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),o=r.getActiveTextRange(),s=a==null?void 0:a.getBody(),c=!a||a.getDocumentStyle().documentFlavor!==t.DocumentFlavor.TRADITIONAL||!o||!!o.segmentId||!!(s!=null&&(n=s.tables)!=null&&n.some(e=>o.startOffset>e.startIndex&&o.startOffset<e.endIndex));e.next(c)};n();let a=r.textSelection$.subscribe(n);return()=>a.unsubscribe()})}function fd(e){return{id:ml.id,type:a.MenuItemType.BUTTON,title:`docs-ui.doc.menu.sectionSetting`,icon:`SectionSettingIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),dd(e),(e,t)=>e||t)}}function pd(e){return{id:qo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertRowAbove`,icon:`InsertRowAboveDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function md(e){return{id:Jo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertRowBelow`,icon:`InsertRowBelowDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function hd(e){return{id:Yo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertColumnLeft`,icon:`LeftInsertColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function gd(e){return{id:Xo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.insertColumnRight`,icon:`RightInsertColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let _d=`doc.menu.table-delete`;function vd(e){return{id:_d,type:a.MenuItemType.SUBITEMS,title:`docs-ui.table.delete`,icon:`ReduceDoubleIcon`,disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,s.combineLatest)((0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),td(e),(e,t)=>e||t)}}function yd(e){return{id:Ho.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteRows`,icon:`DeleteRowDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function bd(e){return{id:Uo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteColumns`,icon:`DeleteColumnDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function xd(e){return{id:Wo.id,type:a.MenuItemType.BUTTON,title:`docs-ui.table.deleteTable`,icon:`DeleteTableDoubleIcon`,disabled$:Qu(td(e),Z(e,o.UnitAction.Edit)),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Sd(e){return{id:ua.id,type:a.MenuItemType.SELECTOR,icon:`DocPasteOptionsIcon`,title:`docs-ui.pasteOptions.title`,tooltip:`docs-ui.pasteOptions.title`,selections:gi.map(e=>({...e})),disabled$:Z(e,o.UnitAction.Edit),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Cd(e,n){let r=`highlight.background.${n+1}`,i=e.getColorFromTheme(r);if(i==null||typeof i.color!=`string`||typeof i.alpha!=`number`)throw Error(`Theme token ${r} is required.`);let a=e.getColorFromTheme(i.color)??i.color;return new t.ColorKit(a).setAlpha(i.alpha).toRgbString()}let wd=[`#FE4B4B`,`#FF8C51`,`#A4DC16`,`#2DAEFF`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Td=[`DocParagraphTextColorSwatchIcon.0`,`DocParagraphTextColorSwatchIcon.1`,`DocParagraphTextColorSwatchIcon.2`,`DocParagraphTextColorSwatchIcon.3`,`DocParagraphTextColorSwatchIcon.4`,`DocParagraphTextColorSwatchIcon.5`,`DocParagraphTextColorSwatchIcon.6`],Ed=[`DocParagraphBackgroundColorSwatchIcon.0`,`DocParagraphBackgroundColorSwatchIcon.1`,`DocParagraphBackgroundColorSwatchIcon.2`,`DocParagraphBackgroundColorSwatchIcon.3`,`DocParagraphBackgroundColorSwatchIcon.4`,`DocParagraphBackgroundColorSwatchIcon.5`,`DocParagraphBackgroundColorSwatchIcon.6`,`DocParagraphBackgroundColorSwatchIcon.7`,`DocParagraphBackgroundColorSwatchIcon.8`,`DocParagraphBackgroundColorSwatchIcon.9`,`DocParagraphBackgroundColorSwatchIcon.10`,`DocParagraphBackgroundColorSwatchIcon.11`,`DocParagraphBackgroundColorSwatchIcon.12`,`DocParagraphBackgroundColorSwatchIcon.13`,`DocParagraphBackgroundColorSwatchIcon.14`];function Dd(e,r){let i=e.get(t.ICommandService);return new s.Observable(a=>{let o=t.NamedStyleType.NORMAL_TEXT,s=()=>{var t;if(Y(e))return;let n=qu(e);if(n==null){a.next(o===r);return}let i=((t=n.paragraphStyle)==null?void 0:t.namedStyleType)??o;a.next(i===r)},c=i.onCommandExecuted(e=>{let t=e.id;(t===n.SetTextSelectionsOperation.id||t===ur.id)&&s()});return s(),c.dispose})}function Od(e){return{id:To.id,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_1)}}function kd(e){return{id:Eo.id,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_2)}}function Ad(e){return{id:Do.id,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_3)}}function jd(e){return{id:Oo.id,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_4)}}function Md(e){return{id:ko.id,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.HEADING_5)}}function Nd(e){return{id:Ao.id,type:a.MenuItemType.BUTTON,icon:`TextTypeIcon`,title:`docs-ui.toolbar.heading.normal`,tooltip:`docs-ui.toolbar.heading.normal`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.NORMAL_TEXT)}}function Pd(e){return{id:jo.id,type:a.MenuItemType.BUTTON,icon:`TitleTypeIcon`,title:`docs-ui.toolbar.heading.title`,tooltip:`docs-ui.toolbar.heading.title`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.TITLE)}}function Fd(e){return{id:Mo.id,type:a.MenuItemType.BUTTON,icon:`SubtitleTypeIcon`,title:`docs-ui.toolbar.heading.subTitle`,tooltip:`docs-ui.toolbar.heading.subTitle`,disabled$:X(e),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC),activated$:Dd(e,t.NamedStyleType.SUBTITLE)}}let Id=`doc.menu.empty-paragraph`;function Ld(){return{id:To.id,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`}}function Rd(){return{id:Eo.id,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`}}function zd(){return{id:Do.id,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`}}function Bd(){return{id:Oo.id,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`}}function Vd(){return{id:ko.id,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`}}function Hd(){return{id:Ao.id,type:a.MenuItemType.BUTTON,icon:`TextTypeIcon`,title:`docs-ui.toolbar.heading.normal`,tooltip:`docs-ui.toolbar.heading.normal`}}function Ud(){return{id:ao.id,type:a.MenuItemType.BUTTON,icon:`OrderIcon`,title:`docs-ui.rightClick.orderList`,tooltip:`docs-ui.rightClick.orderList`}}function Wd(){return{id:no.id,type:a.MenuItemType.BUTTON,icon:`UnorderIcon`,title:`docs-ui.rightClick.bulletList`,tooltip:`docs-ui.rightClick.bulletList`}}function Gd(){return{id:ro.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,title:`docs-ui.rightClick.checkList`,tooltip:`docs-ui.rightClick.checkList`}}function Kd(){return{id:ja.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,title:`docs-ui.toolbar.horizontalLine`,tooltip:`docs-ui.toolbar.horizontalLine`}}function qd(e){return{id:sa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Z(e,o.UnitAction.Copy)}}function Jd(e){return{id:la.id,type:a.MenuItemType.BUTTON,icon:`CutIcon`,title:`docs-ui.rightClick.cut`,disabled$:Z(e,o.UnitAction.Copy)}}function Yd(){return{id:Yn.id,type:a.MenuItemType.BUTTON,icon:`DeleteIcon`,title:`docs-ui.rightClick.delete`}}function Xd(){return{id:co.id,type:a.MenuItemType.BUTTON,icon:`UnorderIcon`,title:`docs-ui.rightClick.bulletList`,tooltip:`docs-ui.rightClick.bulletList`}}function Zd(){return{id:lo.id,type:a.MenuItemType.BUTTON,icon:`OrderIcon`,title:`docs-ui.rightClick.orderList`,tooltip:`docs-ui.rightClick.orderList`}}function Qd(){return{id:uo.id,type:a.MenuItemType.BUTTON,icon:`TodoListDoubleIcon`,title:`docs-ui.rightClick.checkList`,tooltip:`docs-ui.rightClick.checkList`}}function $d(){return{id:Ma.id,type:a.MenuItemType.BUTTON,icon:`ReduceIcon`,title:`docs-ui.toolbar.horizontalLine`,tooltip:`docs-ui.toolbar.horizontalLine`}}let ef=`doc.menu.insert-bellow`,tf=`doc.menu.content-insert`,nf=`doc.menu.table-block`,rf=`doc.menu.paragraph-t.insert`,af=`doc.menu.paragraph-t.edit`,of=`doc.menu.paragraph-t.divider`,sf=`doc.menu.paragraph-t.align`,cf=`doc.menu.paragraph-t.colors`,lf=`doc.menu.paragraph-t.insert-below`,uf=`doc.menu.paragraph-t.indent.increase`,df=`doc.menu.paragraph-t.indent.decrease`,ff=`doc.menu.paragraph-t.insert-below.command`;function pf(e){return`doc.block-range.${e}.menu`}function mf(e){return{id:oa.name,commandId:oa.id,type:a.MenuItemType.BUTTON,icon:`CopyDoubleIcon`,title:`docs-ui.rightClick.copy`,disabled$:Z(e,o.UnitAction.Copy)}}function hf(){return{id:da.id,type:a.MenuItemType.BUTTON,icon:`PasteSpecialDoubleIcon`,title:`docs-ui.rightClick.paste`}}function gf(){return{id:Wo.id,type:a.MenuItemType.BUTTON,icon:`DeleteIcon`,title:`docs-ui.rightClick.delete`}}function _f(){return{id:ef,type:a.MenuItemType.SUBITEMS,title:`docs-ui.rightClick.insertBellow`}}function vf(e){return{id:sf,type:a.MenuItemType.SUBITEMS,icon:`LeftJustifyingIcon`,title:`docs-ui.paragraphMenu.alignAndIndent`,tooltip:`docs-ui.paragraphMenu.alignAndIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function yf(e){return{id:cf,type:a.MenuItemType.SUBITEMS,icon:`PaintBucketDoubleIcon`,title:`docs-ui.paragraphMenu.color`,tooltip:`docs-ui.paragraphMenu.color`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function bf(e){return{...du(e),icon:`HeaderTextColorIcon`,tooltip:void 0,title:void 0}}function xf(e){return{...Gu(e),icon:`PaintBucketDoubleIcon`,tooltip:void 0,title:void 0}}function Sf(e){return{id:lf,type:a.MenuItemType.SUBITEMS,icon:`TextTypeIcon`,title:`docs-ui.rightClick.insertBellow`,tooltip:`docs-ui.rightClick.insertBellow`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Cf(e){return{id:`${ff}.h1`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H1Icon`,title:`docs-ui.toolbar.heading.leading1`,tooltip:`docs-ui.toolbar.heading.leading1`,params:{commandId:To.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function wf(e){return{id:`${ff}.h2`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H2Icon`,title:`docs-ui.toolbar.heading.leading2`,tooltip:`docs-ui.toolbar.heading.leading2`,params:{commandId:Eo.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Tf(e){return{id:`${ff}.h3`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H3Icon`,title:`docs-ui.toolbar.heading.leading3`,tooltip:`docs-ui.toolbar.heading.leading3`,params:{commandId:Do.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Ef(e){return{id:`${ff}.h4`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H4Icon`,title:`docs-ui.toolbar.heading.leading4`,tooltip:`docs-ui.toolbar.heading.leading4`,params:{commandId:Oo.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Df(e){return{id:`${ff}.h5`,commandId:ff,type:a.MenuItemType.BUTTON,icon:`H5Icon`,title:`docs-ui.toolbar.heading.leading5`,tooltip:`docs-ui.toolbar.heading.leading5`,params:{commandId:ko.id,paragraphMenuInsertMode:`breakline`},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Of(e){return{id:`${ns.id}.below`,commandId:ns.id,type:a.MenuItemType.BUTTON,icon:`GridIcon`,title:`docs-ui.toolbar.table.insert`,tooltip:`docs-ui.toolbar.table.insert`,params:{rowCount:3,colCount:5},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function kf(e){return{id:uf,type:a.MenuItemType.BUTTON,icon:`LineIndentIncreaseIcon`,title:`docs-ui.paragraphMenu.increase`,tooltip:`docs-ui.paragraphMenu.increaseIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Af(e){return{id:df,type:a.MenuItemType.BUTTON,icon:`LineIndentDecreaseIcon`,title:`docs-ui.paragraphMenu.decrease`,tooltip:`docs-ui.paragraphMenu.decreaseIndent`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function jf(e){return{id:Sr.id,type:a.MenuItemType.BUTTON,icon:`NoColorDoubleIcon`,title:`docs-ui.paragraphMenu.noBackground`,hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}function Mf(e){let n=e.get(t.ThemeService);return{id:gr.id,commandId:mr.id,type:a.MenuItemType.BUTTON,icon:`NoColorDoubleIcon`,title:`docs-ui.toolbar.resetColor`,tooltip:`docs-ui.toolbar.resetColor`,params:()=>({value:n.getColorFromTheme(`gray.900`)}),hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}let Nf=wd.reduce((e,n,r)=>{let i=`doc.menu.paragraph-t.text-color.${r}`;return e[i]={order:r,menuItemFactory:e=>({id:i,commandId:mr.id,type:a.MenuItemType.BUTTON,icon:Td[r],params:{value:n},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)})},e},{}),Pf=Ed.reduce((e,n,r)=>{let i=`doc.menu.paragraph-t.background-color.${r}`;return e[i]={order:r,menuItemFactory:e=>{let o=Cd(e.get(t.ThemeService),r);return{id:i,commandId:br.id,type:a.MenuItemType.BUTTON,icon:n,params:{value:o},hidden$:(0,a.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_DOC)}}},e},{});function Ff(e){return(0,a.objectPermissionMenuItemFactory)(e,ll.id,t.UniverInstanceType.UNIVER_DOC,o.UnitObject.DocumentSection)}function If(e){return{...(0,a.objectPermissionMenuItemFactory)(e,cl.id,t.UniverInstanceType.UNIVER_DOC,o.UnitObject.DocumentParagraph),title:`docs-ui.objectPermission.paragraphPermission`}}let Lf={[su]:{[ou]:{order:0,menuItemFactory:uu}}},Rf={...Lf,[a.RibbonStartGroup.OTHERS]:{[ua.id]:{order:-1,gridLayout:{row:1,column:2,rowSpan:2,showLabel:!0},menuItemFactory:Sd},[ll.id]:{order:0,gridLayout:{row:1,column:1,rowSpan:2,showLabel:!0},menuItemFactory:Ff}},[a.RibbonStartGroup.FORMAT]:{[Qn.id]:{order:0,gridLayout:{row:2,column:1},menuItemFactory:Zl},[er.id]:{order:1,gridLayout:{row:2,column:2},menuItemFactory:Ql},[nr.id]:{order:2,gridLayout:{row:2,column:3},menuItemFactory:$l},[ir.id]:{order:3,gridLayout:{row:2,column:4},menuItemFactory:eu},[or.id]:{order:4,gridLayout:{row:2,column:5},menuItemFactory:tu},[cr.id]:{order:5,gridLayout:{row:2,column:6},menuItemFactory:nu},[xo.id]:{order:5.5,gridLayout:{row:1,column:1,columnSpan:2,width:100},menuItemFactory:au},[ur.id]:{order:6,gridLayout:{row:1,column:7,width:64},menuItemFactory:iu},[fr.id]:{order:7,gridLayout:{row:1,column:3,columnSpan:4,width:160},menuItemFactory:ru},[mr.id]:{order:8,gridLayout:{row:2,column:7},menuItemFactory:du,[gr.id]:{order:0,menuItemFactory:Uu}},[br.id]:{order:9,gridLayout:{row:2,column:8},menuItemFactory:Gu,[Sr.id]:{order:0,menuItemFactory:Wu}}},[a.RibbonStartGroup.LAYOUT]:{[fo.id]:{order:2,gridLayout:{row:1,column:1},menuItemFactory:Lu},[ao.id]:{order:7,gridLayout:{row:2,column:1},menuItemFactory:Bu},[no.id]:{order:8,gridLayout:{row:1,column:2},menuItemFactory:Vu},[ro.id]:{order:9,gridLayout:{row:2,column:2},menuItemFactory:Hu},[Mc.id]:{order:10,gridLayout:{row:1,column:3,rowSpan:2,showLabel:!0},menuItemFactory:fu},[Al.id]:{order:12,gridLayout:{row:1,column:4,rowSpan:2,showLabel:!0},menuItemFactory:Yu}},[a.RibbonInsertGroup.MEDIA]:{[Ou]:{order:2,gridLayout:{row:1,column:2},menuItemFactory:ku,[ns.id]:{order:0,menuItemFactory:Au}},[ja.id]:{order:4,gridLayout:{row:2,column:5},menuItemFactory:Ru},[pu]:{order:4,gridLayout:{row:1,column:1,rowSpan:2,showLabel:!0},menuItemFactory:yu,[gl.id]:{order:0,menuItemFactory:bu},[mu]:{order:1,menuItemFactory:Su},[hu]:{order:2,menuItemFactory:Cu},[gu]:{order:3,menuItemFactory:wu},[_u]:{order:4,menuItemFactory:Tu},[vu]:{order:5,menuItemFactory:Eu}},[Gl]:{order:5,gridLayout:{row:1,column:3},menuItemFactory:ql},[Kl]:{order:6,gridLayout:{row:2,column:3},menuItemFactory:Jl}},[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.OTHERS]:{[cl.id]:{order:10,menuItemFactory:If}},[a.ContextMenuGroup.QUICK]:{quickLayout:`tile`,[oa.name]:{order:0,menuItemFactory:nd},[ca.id]:{order:1,menuItemFactory:id},[da.id]:{order:2,menuItemFactory:ad},[ua.id]:{order:3,menuItemFactory:Sd}},[a.ContextMenuGroup.FORMAT]:{[Vn.id]:{order:0,menuItemFactory:cd}},[a.ContextMenuGroup.LAYOUT]:{[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[ld]:{order:1,menuItemFactory:ud,[qo.id]:{order:1,menuItemFactory:pd},[Jo.id]:{order:2,menuItemFactory:md},[Yo.id]:{order:3,menuItemFactory:hd},[Xo.id]:{order:4,menuItemFactory:gd}},[_d]:{order:2,menuItemFactory:vd,[Ho.id]:{order:1,menuItemFactory:yd},[Uo.id]:{order:2,menuItemFactory:bd},[Wo.id]:{order:3,menuItemFactory:xd}}}},[a.ContextMenuPosition.PARAGRAPH]:{[a.ContextMenuGroup.QUICK]:{[To.id]:{order:0,menuItemFactory:Od},[Eo.id]:{order:1,menuItemFactory:kd},[Do.id]:{order:2,menuItemFactory:Ad},[Oo.id]:{order:3,menuItemFactory:jd},[ko.id]:{order:4,menuItemFactory:Md},[jo.id]:{order:-1,menuItemFactory:Pd},[Mo.id]:{order:-1,menuItemFactory:Fd},[Ao.id]:{order:5,menuItemFactory:Nd}},[a.ContextMenuGroup.FORMAT]:{[sa.id]:{order:0,menuItemFactory:qd},[la.id]:{order:1,menuItemFactory:Jd},[Yn.id]:{order:2,menuItemFactory:Yd}},[a.ContextMenuGroup.LAYOUT]:{[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[ef]:{order:1,menuItemFactory:_f,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}},[tf]:{[a.ContextMenuGroup.QUICK]:{order:-2,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Od},[Eo.id]:{order:1,menuItemFactory:kd},[Do.id]:{order:2,menuItemFactory:Ad},[Oo.id]:{order:3,menuItemFactory:jd},[ko.id]:{order:4,menuItemFactory:Md},[Ao.id]:{order:5,menuItemFactory:Nd}},[a.ContextMenuGroup.LAYOUT]:{order:1,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}},[Id]:{[a.ContextMenuGroup.QUICK]:{order:-1,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Ld},[Eo.id]:{order:1,menuItemFactory:Rd},[Do.id]:{order:2,menuItemFactory:zd},[Oo.id]:{order:3,menuItemFactory:Bd},[ko.id]:{order:4,menuItemFactory:Vd},[Ao.id]:{order:5,menuItemFactory:Hd}},[a.ContextMenuGroup.LAYOUT]:{order:1,[dl.id]:{order:0,menuItemFactory:rd},[ml.id]:{order:1,menuItemFactory:fd},[no.id]:{order:1,menuItemFactory:Wd},[ao.id]:{order:2,menuItemFactory:Ud},[ro.id]:{order:3,menuItemFactory:Gd},[ja.id]:{order:4,menuItemFactory:Kd},[ns.id]:{order:5,menuItemFactory:ju}}},[nf]:{[a.ContextMenuGroup.FORMAT]:{[oa.name]:{order:0,menuItemFactory:mf},[da.id]:{order:1,menuItemFactory:hf},[Wo.id]:{order:2,menuItemFactory:gf}},[a.ContextMenuGroup.LAYOUT]:{[ef]:{order:0,menuItemFactory:_f,[co.id]:{order:0,menuItemFactory:Xd},[lo.id]:{order:1,menuItemFactory:Zd},[uo.id]:{order:2,menuItemFactory:Qd},[Ma.id]:{order:3,menuItemFactory:$d},[ns.id]:{order:4,menuItemFactory:ju}}}},[rf]:{quickTop:{order:0,quickLayout:`icon`,[To.id]:{order:0,menuItemFactory:Ld},[Eo.id]:{order:1,menuItemFactory:Rd},[Do.id]:{order:2,menuItemFactory:zd},[Oo.id]:{order:3,menuItemFactory:Bd},[ko.id]:{order:4,menuItemFactory:Vd},[ao.id]:{order:5,menuItemFactory:Ud}},quickBottom:{order:1,quickLayout:`icon`,[no.id]:{order:0,menuItemFactory:Wd},[ro.id]:{order:1,menuItemFactory:Gd},[ja.id]:{order:5,menuItemFactory:Kd}},insert:{order:2,[ns.id]:{order:0,menuItemFactory:ju}},format:{order:3,[da.id]:{order:0,menuItemFactory:ad}}},[lf]:{quickTop:{order:0,quickLayout:`icon`,[`${ff}.h1`]:{order:0,menuItemFactory:Cf},[`${ff}.h2`]:{order:1,menuItemFactory:wf},[`${ff}.h3`]:{order:2,menuItemFactory:Tf},[`${ff}.h4`]:{order:3,menuItemFactory:Ef},[`${ff}.h5`]:{order:4,menuItemFactory:Df},[lo.id]:{order:5,menuItemFactory:Zd}},quickBottom:{order:1,quickLayout:`icon`,[co.id]:{order:0,menuItemFactory:Xd},[uo.id]:{order:1,menuItemFactory:Qd},[Ma.id]:{order:5,menuItemFactory:$d}},insert:{order:2,[`${ns.id}.below`]:{order:0,menuItemFactory:Of}}},[af]:{quickTop:{order:0,quickLayout:`icon`,[Ao.id]:{order:0,menuItemFactory:Nd},[To.id]:{order:1,menuItemFactory:Od},[Eo.id]:{order:2,menuItemFactory:kd},[Do.id]:{order:3,menuItemFactory:Ad},[Oo.id]:{order:4,menuItemFactory:jd},[ko.id]:{order:5,menuItemFactory:Md},[jo.id]:{order:6,menuItemFactory:Pd},[Mo.id]:{order:7,menuItemFactory:Fd}},quickBottom:{order:1,quickLayout:`icon`,[ao.id]:{order:0,menuItemFactory:Bu},[no.id]:{order:1,menuItemFactory:Vu},[ro.id]:{order:2,menuItemFactory:Hu}},layout:{order:2,[sf]:{order:0,menuItemFactory:vf},[cf]:{order:1,menuItemFactory:yf}},format:{order:3,[la.id]:{order:0,menuItemFactory:Jd},[sa.id]:{order:1,menuItemFactory:qd},[da.id]:{order:2,menuItemFactory:ad},[Yn.id]:{order:3,menuItemFactory:Yd}},others:{order:4,[lf]:{order:0,menuItemFactory:Sf}}},[of]:{layout:{order:1,[cf]:{order:0,menuItemFactory:yf}},format:{order:2,[la.id]:{order:0,menuItemFactory:Jd},[sa.id]:{order:1,menuItemFactory:qd},[Yn.id]:{order:2,menuItemFactory:Yd}},others:{order:3,[lf]:{order:0,menuItemFactory:Sf}}},[sf]:{align:{order:0,title:`docs-ui.paragraphMenu.align`,quickLayout:`icon`,[fo.id]:{order:0,menuItemFactory:Mu},[`${fo.id}.center`]:{order:1,menuItemFactory:Nu},[`${fo.id}.right`]:{order:2,menuItemFactory:Pu},[`${fo.id}.justify`]:{order:3,menuItemFactory:Fu}},indent:{order:1,title:`docs-ui.paragraphMenu.indent`,[uf]:{order:0,menuItemFactory:kf},[df]:{order:1,menuItemFactory:Af}}},[cf]:{text:{order:0,title:`docs-ui.toolbar.textColor.main`,headerActionMenuItemFactory:bf,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,[gr.id]:{order:0,menuItemFactory:Mf},...Nf},backgroundTop:{order:1,title:`docs-ui.toolbar.fillColor.main`,headerActionMenuItemFactory:xf,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,[Sr.id]:{order:0,menuItemFactory:jf},...Object.fromEntries(Object.entries(Pf).filter(([,e])=>e.order<7))},backgroundBottom:{order:2,quickLayout:`icon`,quickColumns:8,quickLayoutVariant:`compact`,...Object.fromEntries(Object.entries(Pf).filter(([,e])=>e.order>=7))}}}};function Q(e){return e.getContextValue(t.FOCUSING_DOC)&&e.getContextValue(t.FOCUSING_UNIVER_EDITOR)&&!e.getContextValue(t.FOCUSING_COMMON_DRAWINGS)}function zf(e){return e.getContextValue(t.FOCUSING_DOC)&&e.getContextValue(t.FOCUSING_UNIVER_EDITOR)&&!e.getContextValue(t.FOCUSING_COMMON_DRAWINGS)}let Bf={id:te.id,binding:a.KeyCode.TAB,preconditions:Q},Vf={id:te.id,binding:a.KeyCode.TAB|a.MetaKeys.SHIFT,preconditions:Q,staticParameters:{shift:!0}},Hf={id:Qn.id,binding:a.KeyCode.B|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Uf={id:er.id,binding:a.KeyCode.I|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Wf={id:nr.id,binding:a.KeyCode.U|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Gf={id:ir.id,binding:a.KeyCode.X|a.MetaKeys.SHIFT|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Kf={id:or.id,binding:a.KeyCode.COMMA|a.MetaKeys.CTRL_COMMAND,preconditions:Q},qf={id:cr.id,binding:a.KeyCode.PERIOD|a.MetaKeys.CTRL_COMMAND,preconditions:Q},Jf={id:po.id,binding:a.KeyCode.L|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Yf={id:ho.id,binding:a.KeyCode.R|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Xf={id:mo.id,binding:a.KeyCode.E|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Zf={id:go.id,binding:a.KeyCode.J|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},Qf={id:ao.id,binding:a.KeyCode.Digit7|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},$f={id:no.id,binding:a.KeyCode.Digit8|a.MetaKeys.CTRL_COMMAND|a.MetaKeys.SHIFT,preconditions:Q},ep=[50,80,100,130,150,170,200,400],tp=[10,400];function np(){let e=(0,a.useDependency)(t.ICommandService),n=(0,a.useDependency)(t.IUniverInstanceService),r=(0,a.useObservable)(()=>n.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.filter)(e=>e!=null)),null,!1,[n]),i=(0,l.useCallback)((e=r)=>e?Math.round(Fs(e)*100):100,[r]),[o,c]=(0,l.useState)(100);(0,l.useEffect)(()=>c(i(r)),[r,i]),(0,l.useEffect)(()=>e.onCommandExecuted(e=>{e.id===vo.id&&c(i())}).dispose,[e,i]);function d(t){if(c(t),r==null)return;let n=t/100;e.executeCommand(vo.id,{unitId:r.getUnitId(),zoomRatio:n})}return(0,u.jsx)(a.Slider,{min:tp[0],value:o,shortcuts:ep,onChange:d})}function rp(e){return(0,u.jsx)(`section`,{className:`univer-flex univer-flex-shrink-0 univer-justify-end`,children:(0,u.jsx)(np,{})})}function $({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),u=`_${(0,l.useId)()}`,d=(0,l.useRef)(null);return(0,l.useImperativeHandle)(e,()=>d.current),(0,l.useLayoutEffect)(()=>{if(n&&d.current&&d.current.localName===r.tag)return sp(d.current)},[n,r]),ip(r,`${i}`,{defIds:r.defIds,idSuffix:u},{ref:d,className:c,...s},o)}function ip(e,t,n,r,i){return(0,l.createElement)(e.tag,{key:t,...ap(e,n,i),...r},(op(e,n).children||[]).map((r,a)=>ip(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function ap(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function op(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function sp(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:cp(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(lp(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function cp(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function lp(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}$.displayName=`UniverIcon`;let up={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.9998 1.65005H3.64981C2.54524 1.65005 1.6498 2.54548 1.6498 3.65005V12.35C1.6498 13.4546 2.54523 14.35 3.6498 14.35H12.3498C13.4544 14.35 14.3498 13.4546 14.3498 12.3501V8.00005`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.6498 11.2148L5.43408 8.29588L10.711 12.0198`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.46559 10.1621L10.9774 8.65032C11.2042 8.42344 11.5634 8.39794 11.8201 8.59045L14.3498 10.4877`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.8097 1.74783V6.24167M9.6603 3.897H14.1541`,strokeLinecap:`round`,strokeWidth:1.2}}]},dp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`add-image-icon`,ref:t,icon:up}))});dp.displayName=`AddImageIcon`;let fp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 5.56641C1.66853 5.56641 1.3999 5.83504 1.3999 6.16641C1.3999 6.49778 1.66853 6.76641 1.9999 6.76641H13.9999C14.3313 6.76641 14.5999 6.49778 14.5999 6.16641C14.5999 5.83504 14.3313 5.56641 13.9999 5.56641H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 12.9004C1.66853 12.9004 1.3999 13.169 1.3999 13.5004C1.3999 13.8318 1.66853 14.1004 1.9999 14.1004H13.9999C14.3313 14.1004 14.5999 13.8318 14.5999 13.5004C14.5999 13.169 14.3313 12.9004 13.9999 12.9004H1.9999Z`}}]},pp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`align-text-both-icon`,ref:t,icon:fp}))});pp.displayName=`AlignTextBothIcon`;let mp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},hp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`bold-icon`,ref:t,icon:mp}))});hp.displayName=`BoldIcon`;let gp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9834 3.98332C1.9834 3.61513 2.28188 3.31665 2.65007 3.31665H13.3167C13.6849 3.31665 13.9834 3.61513 13.9834 3.98332C13.9834 4.35151 13.6849 4.64998 13.3167 4.64998H2.65007C2.28188 4.64998 1.9834 4.35151 1.9834 3.98332Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9834 7.98267C1.9834 7.61448 2.28188 7.316 2.65007 7.316H10.6501C11.0183 7.316 11.3167 7.61448 11.3167 7.98267C11.3167 8.35086 11.0183 8.64933 10.6501 8.64933H2.65007C2.28188 8.64933 1.9834 8.35086 1.9834 7.98267Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.65007 11.316C2.28188 11.316 1.9834 11.6145 1.9834 11.9827C1.9834 12.3509 2.28188 12.6493 2.65007 12.6493H7.9834C8.35159 12.6493 8.65006 12.3509 8.65006 11.9827C8.65006 11.6145 8.35159 11.316 7.9834 11.316H2.65007Z`}}]},_p=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`catalogue-icon`,ref:t,icon:gp}))});_p.displayName=`CatalogueIcon`;let vp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},yp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:vp}))});yp.displayName=`CheckMarkIcon`;let bp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.71274 2.86421C3.47843 2.6299 3.09853 2.6299 2.86421 2.86421C2.6299 3.09853 2.6299 3.47843 2.86421 3.71274L7.15154 8.00007L2.86421 12.2874C2.6299 12.5217 2.6299 12.9016 2.86421 13.1359C3.09853 13.3702 3.47843 13.3702 3.71274 13.1359L8.00007 8.84859L12.2874 13.1359C12.5217 13.3702 12.9016 13.3702 13.1359 13.1359C13.3702 12.9016 13.3702 12.5217 13.1359 12.2874L8.84859 8.00007L13.1359 3.71274C13.3702 3.47843 13.3702 3.09853 13.1359 2.86421C12.9016 2.6299 12.5217 2.6299 12.2874 2.86421L8.00007 7.15154L3.71274 2.86421Z`}}]},xp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`close-icon`,ref:t,icon:bp}))});xp.displayName=`CloseIcon`;let Sp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.52,height:4,x:2.63,y:2.89,stroke:`currentColor`,rx:1.1,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.80825 2.89202V6.89199M10.9821 2.89202V6.89199`,strokeWidth:1.2}},{tag:`rect`,attrs:{width:4,height:4,x:2.63,y:9.8,stroke:`currentColor`,rx:1.1,strokeWidth:1.2}}]},Cp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`column-icon`,ref:t,icon:Sp}))});Cp.displayName=`ColumnIcon`;let wp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.50095 1.84399C2.73322 1.60765 3.11311 1.60435 3.34945 1.83662L8.00012 6.40726L12.6508 1.83662C12.8871 1.60435 13.267 1.60765 13.4993 1.84399C13.7316 2.08032 13.7283 2.46021 13.4919 2.69248L8.85611 7.24852L10.8941 9.25146C11.1382 9.17563 11.3976 9.13477 11.6667 9.13477C13.1026 9.13477 14.2667 10.2988 14.2667 11.7348C14.2667 13.1707 13.1026 14.3348 11.6667 14.3348C10.2307 14.3348 9.06665 13.1707 9.06665 11.7348C9.06665 11.0143 9.35973 10.3622 9.83319 9.89129L8.00012 8.08978L6.16708 9.89127C6.64055 10.3622 6.93364 11.0142 6.93364 11.7348C6.93364 13.1707 5.76958 14.3348 4.33364 14.3348C2.8977 14.3348 1.73364 13.1707 1.73364 11.7348C1.73364 10.2988 2.8977 9.13477 4.33364 9.13477C4.60263 9.13477 4.86208 9.17562 5.10612 9.25145L7.14413 7.24852L2.50831 2.69248C2.27197 2.46021 2.26868 2.08032 2.50095 1.84399ZM2.93364 11.7348C2.93364 10.9616 3.56044 10.3348 4.33364 10.3348C5.10684 10.3348 5.73364 10.9616 5.73364 11.7348C5.73364 12.508 5.10684 13.1348 4.33364 13.1348C3.56044 13.1348 2.93364 12.508 2.93364 11.7348ZM10.2667 11.7348C10.2667 10.9616 10.8935 10.3348 11.6667 10.3348C12.4398 10.3348 13.0667 10.9616 13.0667 11.7348C13.0667 12.508 12.4398 13.1348 11.6667 13.1348C10.8935 13.1348 10.2667 12.508 10.2667 11.7348Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Tp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`cut-icon`,ref:t,icon:wp}))});Tp.displayName=`CutIcon`;let Ep={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-icon`,ref:t,icon:Ep}))});Dp.displayName=`DeleteIcon`;let Op={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 2.75H3.25C2.56 2.75 2 3.31 2 4V12.75C2 13.44 2.56 14 3.25 14H5.5M8.5 2.75H9.75C10.44 2.75 11 3.31 11 4V5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`rect`,attrs:{width:4,height:2.5,x:4.5,y:1.5,stroke:`currentColor`,rx:.75,strokeWidth:1.33}},{tag:`rect`,attrs:{width:7,height:7,x:7.5,y:7,stroke:`currentColor`,rx:1.25,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M9.25 9.25H12.75M9.25 11.75H12.75M10.25 8.5V10M11.75 11V12.5`,strokeLinecap:`round`,strokeWidth:1.33}}]},kp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`doc-paste-options-icon`,ref:t,icon:Op}))});kp.displayName=`DocPasteOptionsIcon`;let Ap={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.18958 14.085H4.0929C2.98833 14.085 2.0929 13.1895 2.0929 12.085V3.5918C2.0929 2.48723 2.98833 1.5918 4.0929 1.5918H10.5031C11.6077 1.5918 12.5031 2.48723 12.5031 3.5918V6.41602`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.73547 4.57324H9.96594M4.73547 7.08105H7.91614`,strokeLinecap:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.0255 9.17969H11.9572L13.7687 11.7939L11.9572 14.4082H10.0255L8.21399 11.7939L10.0255 9.17969Z`,strokeLinejoin:`round`,strokeWidth:1.33}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.9913 11.7939H10.9914`,strokeLinecap:`round`,strokeWidth:1.83}}]},jp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`doc-setting-icon`,ref:t,icon:Ap}))});jp.displayName=`DocSettingIcon`;let Mp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.55935 11.7617C8.29238 12.1202 7.75558 12.1202 7.48861 11.7617L3.08649 5.84931C2.75722 5.40708 3.07292 4.77771 3.62432 4.77771H12.4236C12.975 4.77771 13.2907 5.40708 12.9614 5.84931L8.55935 11.7617Z`}}]},Np=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`down-icon`,ref:t,icon:Mp}))});Np.displayName=`DownIcon`;let Pp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.06,height:12.06,x:1.97,y:1.97,stroke:`currentColor`,rx:.63,strokeWidth:1.27}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5.7777 1.96817V14.0317M9.90468 1.96817V14.0317M1.96817 6.09516H14.0317M1.96817 9.90468H14.0317`,strokeWidth:1.27}}]},Fp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`grid-icon`,ref:t,icon:Pp}))});Fp.displayName=`GridIcon`;let Ip={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.0999 2.66689C3.0999 2.33552 2.83127 2.06689 2.4999 2.06689C2.16853 2.06689 1.8999 2.33552 1.8999 2.66689V13.3336C1.8999 13.6649 2.16853 13.9336 2.4999 13.9336C2.83127 13.9336 3.0999 13.6649 3.0999 13.3336V8.5999H8.2334V13.3336C8.2334 13.6649 8.50203 13.9336 8.8334 13.9336C9.16477 13.9336 9.4334 13.6649 9.4334 13.3336V2.66689C9.4334 2.33552 9.16477 2.06689 8.8334 2.06689C8.50203 2.06689 8.2334 2.33552 8.2334 2.66689V7.3999H3.0999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.0999 6.33879C14.0999 6.09377 13.9509 5.87336 13.7236 5.78203C13.4962 5.6907 13.2362 5.74679 13.0667 5.92373L11.4753 7.58486C11.2461 7.82415 11.2542 8.20396 11.4935 8.43319C11.7328 8.66243 12.1126 8.65427 12.3419 8.41499L12.8999 7.83245V13.3333C12.8999 13.6646 13.1686 13.9333 13.4999 13.9333C13.8313 13.9333 14.0999 13.6646 14.0999 13.3333V6.33879Z`}}]},Lp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h1-icon`,ref:t,icon:Ip}))});Lp.displayName=`H1Icon`;let Rp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M11.2667 8.33356C11.2667 7.67245 11.8201 7.26689 12.3333 7.26689C12.8465 7.26689 13.4 7.67244 13.4 8.33356C13.4 8.62807 13.2712 8.94814 12.9954 9.32391C12.7183 9.70153 12.3394 10.0744 11.9174 10.4803L11.8355 10.559C11.4524 10.9268 11.0365 11.3263 10.7149 11.7373C10.3718 12.1759 10.0667 12.7122 10.0667 13.3336C10.0667 13.6649 10.3353 13.9336 10.6667 13.9336H14C14.3314 13.9336 14.6 13.6649 14.6 13.3336C14.6 13.0022 14.3314 12.7336 14 12.7336H11.4782C11.5286 12.6531 11.5889 12.5676 11.6601 12.4767C11.9269 12.1355 12.2843 11.792 12.6877 11.4043L12.7492 11.3452C13.1606 10.9496 13.615 10.5079 13.9629 10.0338C14.3122 9.55787 14.6 8.98906 14.6 8.33356C14.6 6.88362 13.3757 6.06689 12.3333 6.06689C11.291 6.06689 10.0667 6.88361 10.0667 8.33356C10.0667 8.66493 10.3353 8.93356 10.6667 8.93356C10.998 8.93356 11.2667 8.66493 11.2667 8.33356Z`}}]},zp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h2-icon`,ref:t,icon:Rp}))});zp.displayName=`H2Icon`;let Bp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.6667 6.06689C10.3353 6.06689 10.0667 6.33552 10.0667 6.66689C10.0667 6.99827 10.3353 7.26689 10.6667 7.26689H12.7732L11.193 9.29853C11.0524 9.47942 11.027 9.72465 11.1277 9.93051C11.2283 10.1364 11.4375 10.2669 11.6667 10.2669C12.2418 10.2669 12.6786 10.4115 12.9585 10.6354C13.2204 10.845 13.4 11.166 13.4 11.6669C13.4 12.1622 13.2254 12.3937 13.0567 12.5202C12.8588 12.6686 12.5829 12.7336 12.3333 12.7336C11.7271 12.7336 11.3432 12.4858 11.1106 12.23C10.8877 11.9848 10.5082 11.9667 10.2631 12.1896C10.0179 12.4125 9.99979 12.792 10.2227 13.0372C10.6568 13.5147 11.3522 13.9336 12.3333 13.9336C12.7504 13.9336 13.3078 13.8319 13.7767 13.4802C14.2746 13.1068 14.6 12.5049 14.6 11.6669C14.6 10.8345 14.2796 10.1555 13.7081 9.69837C13.4342 9.47923 13.117 9.32231 12.7746 9.21971L14.4736 7.03526C14.6143 6.85437 14.6397 6.60914 14.539 6.40328C14.4383 6.19743 14.2291 6.06689 14 6.06689H10.6667Z`}}]},Vp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h3-icon`,ref:t,icon:Bp}))});Vp.displayName=`H3Icon`;let Hp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.4334 2.66689C2.4334 2.33552 2.16477 2.06689 1.8334 2.06689C1.50203 2.06689 1.2334 2.33552 1.2334 2.66689V13.3336C1.2334 13.6649 1.50203 13.9336 1.8334 13.9336C2.16477 13.9336 2.4334 13.6649 2.4334 13.3336V8.5999H7.2334V13.3336C7.2334 13.6649 7.50203 13.9336 7.8334 13.9336C8.16477 13.9336 8.4334 13.6649 8.4334 13.3336V2.66689C8.4334 2.33552 8.16477 2.06689 7.8334 2.06689C7.50203 2.06689 7.2334 2.33552 7.2334 2.66689V7.3999H2.4334V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.7591 6.66645C13.7591 6.40387 13.5884 6.1718 13.3377 6.09364C13.087 6.01549 12.8147 6.10941 12.6654 6.32546L9.67321 10.6577C9.60398 10.7579 9.56689 10.8769 9.56689 10.9987V11.6731C9.56689 12.0045 9.83552 12.2731 10.1669 12.2731H12.5591V13.3331C12.5591 13.6645 12.8278 13.9331 13.1591 13.9331C13.4905 13.9331 13.7591 13.6645 13.7591 13.3331V12.2731H14.1669C14.4983 12.2731 14.7669 12.0045 14.7669 11.6731C14.7669 11.3417 14.4983 11.0731 14.1669 11.0731H13.7591V6.66645ZM12.5591 8.59091V11.0731H10.8447L12.5591 8.59091Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Up=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h4-icon`,ref:t,icon:Hp}))});Up.displayName=`H4Icon`;let Wp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.5999 2.66689C2.5999 2.33552 2.33127 2.06689 1.9999 2.06689C1.66853 2.06689 1.3999 2.33552 1.3999 2.66689V13.3336C1.3999 13.6649 1.66853 13.9336 1.9999 13.9336C2.33127 13.9336 2.5999 13.6649 2.5999 13.3336V8.5999H7.3999V13.3336C7.3999 13.6649 7.66853 13.9336 7.9999 13.9336C8.33127 13.9336 8.5999 13.6649 8.5999 13.3336V2.66689C8.5999 2.33552 8.33127 2.06689 7.9999 2.06689C7.66853 2.06689 7.3999 2.33552 7.3999 2.66689V7.3999H2.5999V2.66689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.6669 6.40332C10.3355 6.40332 10.0669 6.67195 10.0669 7.00332V9.34492C10.0669 9.67629 10.3355 9.94492 10.6669 9.94492C10.7822 9.94492 10.8899 9.91238 10.9814 9.85599C10.9901 9.85195 11.0027 9.84632 11.0192 9.83936C11.0764 9.81533 11.1692 9.78033 11.2927 9.74447C11.5397 9.67268 11.8996 9.60022 12.3336 9.60022C12.4975 9.60022 12.5978 9.63412 12.6624 9.67167C12.7263 9.70877 12.79 9.76953 12.8503 9.87834C12.983 10.1181 13.0669 10.5337 13.0669 11.1669C13.0669 11.8061 12.9802 12.1936 12.8338 12.414C12.7252 12.5775 12.5275 12.7336 12.0002 12.7336C11.6445 12.7336 11.4936 12.622 11.4192 12.5328C11.3289 12.4245 11.2669 12.2453 11.2669 12.0028C11.2669 11.6714 10.9983 11.4028 10.6669 11.4028C10.3355 11.4028 10.0669 11.6714 10.0669 12.0028C10.0669 12.4244 10.1716 12.9106 10.4979 13.3016C10.8401 13.7118 11.356 13.9336 12.0002 13.9336C12.8063 13.9336 13.4419 13.6673 13.8334 13.0779C14.1869 12.5456 14.2669 11.8497 14.2669 11.1669C14.2669 10.4781 14.1841 9.81027 13.9002 9.29724C13.7521 9.02964 13.545 8.79662 13.2651 8.63403C12.986 8.4719 12.6697 8.40022 12.3336 8.40022C11.9239 8.40022 11.5627 8.44957 11.2669 8.51389V7.60332H13.3336C13.6649 7.60332 13.9336 7.33469 13.9336 7.00332C13.9336 6.67195 13.6649 6.40332 13.3336 6.40332H10.6669Z`}}]},Gp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`h5-icon`,ref:t,icon:Wp}))});Gp.displayName=`H5Icon`;let Kp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:12.2,height:13,x:1.9,y:1.5,stroke:`currentColor`,rx:1.4,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.9999 4.50137H10.9999M4.9999 11.4987H10.9999`,strokeLinecap:`round`,strokeWidth:1.2}}]},qp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`header-footer-icon`,ref:t,icon:Kp}))});qp.displayName=`HeaderFooterIcon`;let Jp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33315 5.56641C3.00178 5.56641 2.73315 5.83504 2.73315 6.16641C2.73315 6.49778 3.00178 6.76641 3.33315 6.76641H12.6665C12.9979 6.76641 13.2665 6.49778 13.2665 6.16641C13.2665 5.83504 12.9979 5.56641 12.6665 5.56641H3.33315Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33315 12.9004C3.00178 12.9004 2.73315 13.169 2.73315 13.5004C2.73315 13.8318 3.00178 14.1004 3.33315 14.1004H12.6665C12.9979 14.1004 13.2665 13.8318 13.2665 13.5004C13.2665 13.169 12.9979 12.9004 12.6665 12.9004H3.33315Z`}}]},Yp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`horizontally-icon`,ref:t,icon:Jp}))});Yp.displayName=`HorizontallyIcon`;let Xp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z`}}]},Zp=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`italic-icon`,ref:t,icon:Xp}))});Zp.displayName=`ItalicIcon`;let Qp={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.39986 6.33339C3.39986 6.00202 3.66849 5.73339 3.99986 5.73339H4.66652C4.99789 5.73339 5.26652 6.00202 5.26652 6.33339C5.26652 6.66476 4.99789 6.93339 4.66652 6.93339H3.99986C3.66849 6.93339 3.39986 6.66476 3.39986 6.33339Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.99986 5.73339C6.66849 5.73339 6.39986 6.00202 6.39986 6.33339C6.39986 6.66476 6.66849 6.93339 6.99986 6.93339H7.66652C7.99789 6.93339 8.26652 6.66476 8.26652 6.33339C8.26652 6.00202 7.99789 5.73339 7.66652 5.73339H6.99986Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.06636 6.33339C9.06636 6.00202 9.33499 5.73339 9.66636 5.73339H11.9997C12.3311 5.73339 12.5997 6.00202 12.5997 6.33339C12.5997 6.66476 12.3311 6.93339 11.9997 6.93339H9.66636C9.33499 6.93339 9.06636 6.66476 9.06636 6.33339Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.99986 8.73339C3.66849 8.73339 3.39986 9.00202 3.39986 9.33339C3.39986 9.66476 3.66849 9.93339 3.99986 9.93339H11.9999C12.3312 9.93339 12.5999 9.66476 12.5999 9.33339C12.5999 9.00202 12.3312 8.73339 11.9999 8.73339H3.99986Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.33338 1.73345L12.6667 1.7334C14.1026 1.73339 15.2667 2.89745 15.2667 4.3334V11C15.2667 12.4359 14.1027 13.6 12.6667 13.6H3.33355C1.89763 13.6 0.733583 12.4359 0.73355 11L0.733398 4.33351C0.733366 2.89755 1.89742 1.73346 3.33338 1.73345ZM12.6667 2.9334L3.33339 2.93345C2.56018 2.93346 1.93338 3.56028 1.9334 4.33348L1.93355 11C1.93357 11.7732 2.56036 12.4 3.33355 12.4H12.6667C13.4399 12.4 14.0667 11.7732 14.0667 11V4.3334C14.0667 3.5602 13.4399 2.93339 12.6667 2.9334Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},$p=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`keyboard-icon`,ref:t,icon:Qp}))});$p.displayName=`KeyboardIcon`;let em={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 5.56641C1.66853 5.56641 1.3999 5.83504 1.3999 6.16641C1.3999 6.49778 1.66853 6.76641 1.9999 6.76641H11.3332C11.6646 6.76641 11.9332 6.49778 11.9332 6.16641C11.9332 5.83504 11.6646 5.56641 11.3332 5.56641H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 12.9004C1.66853 12.9004 1.3999 13.169 1.3999 13.5004C1.3999 13.8318 1.66853 14.1004 1.9999 14.1004H11.3332C11.6646 14.1004 11.9332 13.8318 11.9332 13.5004C11.9332 13.169 11.6646 12.9004 11.3332 12.9004H1.9999Z`}}]},tm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`left-justifying-icon`,ref:t,icon:em}))});tm.displayName=`LeftJustifyingIcon`;let nm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.1 2.5H13.9M7.1 5.8H13.9M7.1 9.1H13.9M2.1 12.4H13.9`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 5.6L2.4 8L5 10.4`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.4 8H5.1`,strokeLinecap:`round`,strokeWidth:1.3}}]},rm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`line-indent-decrease-icon`,ref:t,icon:nm}))});rm.displayName=`LineIndentDecreaseIcon`;let im={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.1 2.5H13.9M7.1 5.8H13.9M7.1 9.1H13.9M2.1 12.4H13.9`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.4 5.6L5 8L2.4 10.4`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.3 8H5`,strokeLinecap:`round`,strokeWidth:1.3}}]},am=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`line-indent-increase-icon`,ref:t,icon:im}))});am.displayName=`LineIndentIncreaseIcon`;let om={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.66504 2.8666C1.66504 2.53523 1.93367 2.2666 2.26504 2.2666H13.735C14.0664 2.2666 14.335 2.53523 14.335 2.8666C14.335 3.19797 14.0664 3.4666 13.735 3.4666H2.26504C1.93367 3.4666 1.66504 3.19797 1.66504 2.8666Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.66504 8.00002C1.66504 7.66865 1.93367 7.40002 2.26504 7.40002H13.735C14.0664 7.40002 14.335 7.66865 14.335 8.00002C14.335 8.3314 14.0664 8.60002 13.735 8.60002H2.26504C1.93367 8.60002 1.66504 8.3314 1.66504 8.00002Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.26504 12.5334C1.93367 12.5334 1.66504 12.8021 1.66504 13.1334C1.66504 13.4648 1.93367 13.7334 2.26504 13.7334H13.735C14.0664 13.7334 14.335 13.4648 14.335 13.1334C14.335 12.8021 14.0664 12.5334 13.735 12.5334H2.26504Z`}}]},sm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`menu-icon`,ref:t,icon:om}))});sm.displayName=`MenuIcon`;let cm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3 9C3.55228 9 4 8.55228 4 8C4 7.44772 3.55228 7 3 7C2.44772 7 2 7.44772 2 8C2 8.55228 2.44772 9 3 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13 9C13.5523 9 14 8.55228 14 8C14 7.44772 13.5523 7 13 7C12.4477 7 12 7.44772 12 8C12 8.55228 12.4477 9 13 9Z`}}]},lm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-horizontal-icon`,ref:t,icon:cm}))});lm.displayName=`MoreHorizontalIcon`;let um={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3536 12.3536C10.1583 12.5488 9.84171 12.5488 9.64645 12.3536L6.64645 9.35355C6.45118 9.15829 6.45118 8.84171 6.64645 8.64645L9.64645 5.64645C9.84171 5.45118 10.1583 5.45118 10.3536 5.64645C10.5488 5.84171 10.5488 6.15829 10.3536 6.35355L7.70711 9L10.3536 11.6464C10.5488 11.8417 10.5488 12.1583 10.3536 12.3536Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},dm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-left-icon`,ref:t,icon:um}))});dm.displayName=`MoreLeftIcon`;let fm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.14645 4.64645C6.34171 4.45118 6.65829 4.45118 6.85355 4.64645L9.85355 7.64645C10.0488 7.84171 10.0488 8.15829 9.85355 8.35355L6.85355 11.3536C6.65829 11.5488 6.34171 11.5488 6.14645 11.3536C5.95118 11.1583 5.95118 10.8417 6.14645 10.6464L8.79289 8L6.14645 5.35355C5.95118 5.15829 5.95118 4.84171 6.14645 4.64645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},pm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`more-right-icon`,ref:t,icon:fm}))});pm.displayName=`MoreRightIcon`;let mm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.65465 3.96697V2.9942C1.65465 2.9188 1.64353 2.86563 1.62465 2.83387C1.61052 2.81011 1.58943 2.79243 1.53852 2.79243H1.44483C1.23836 2.79243 1.07099 2.62506 1.07099 2.41859C1.07099 2.23956 1.19714 2.09152 1.36369 2.04728C1.4425 2.02634 1.51336 2.00423 1.57642 1.98104C1.65529 1.94986 1.73286 1.91381 1.80913 1.87285C1.8974 1.82544 1.99768 1.79517 2.10303 1.79517C2.41692 1.79517 2.67137 2.04962 2.67137 2.36351V4.02047C2.67137 4.12385 2.75517 4.20765 2.85855 4.20765C3.0614 4.20765 3.22585 4.3721 3.22585 4.57495V4.63332C3.22585 4.86842 3.03527 5.059 2.80018 5.059H1.41884C1.1829 5.059 0.993164 4.86511 0.993164 4.63087C0.993164 4.39932 1.18072 4.20765 1.41398 4.20765C1.5469 4.20765 1.65465 4.09989 1.65465 3.96697Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M0.949709 9.2145C1.14957 9.02907 1.33226 8.85497 1.49677 8.69321C1.6914 8.50496 1.84244 8.33306 1.95136 8.17747C2.05826 8.02476 2.10492 7.89219 2.10492 7.77781C2.10492 7.65255 2.07293 7.57986 2.02759 7.53865L2.0245 7.5357C1.97641 7.48761 1.9103 7.46013 1.81635 7.46013C1.71986 7.46013 1.6383 7.47348 1.5822 7.51611L1.58034 7.51749C1.42279 7.63092 1.19425 7.67086 1.03149 7.50811L1.02187 7.49849C0.868433 7.34505 0.852261 7.07998 1.03819 6.93364C1.12802 6.86293 1.21897 6.8051 1.31109 6.76081C1.48788 6.67257 1.69616 6.63037 1.93278 6.63037C2.15191 6.63037 2.34929 6.67491 2.52246 6.76665C2.69563 6.85514 2.83257 6.98323 2.93172 7.14966C3.03175 7.31758 3.08022 7.51184 3.08022 7.72929C3.08022 7.91104 3.03028 8.09333 2.93429 8.27521C2.84374 8.45283 2.72797 8.62691 2.58859 8.79616C2.51109 8.88842 2.43304 8.97759 2.35442 9.06369C2.34919 9.06941 2.34388 9.07573 2.33892 9.08228C2.34542 9.08201 2.35268 9.08151 2.36075 9.08073C2.46266 9.07087 2.54985 9.06576 2.62168 9.06576H2.78662C3.02915 9.06576 3.22576 9.26237 3.22576 9.5049C3.22576 9.74742 3.02915 9.94403 2.78662 9.94403H1.23472C1.00261 9.94403 0.814453 9.75587 0.814453 9.52376C0.814453 9.40615 0.86379 9.29421 0.949709 9.2145Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.2579 14.674C1.45109 14.7553 1.67487 14.7946 1.92711 14.7946C2.1451 14.7946 2.34841 14.7599 2.53619 14.6895L2.53746 14.689C2.7264 14.6148 2.88145 14.5071 2.99952 14.3647L3.00018 14.3639C3.12167 14.2138 3.18089 14.0326 3.18089 13.8252C3.18089 13.6181 3.12169 13.4411 2.99737 13.3022C2.91596 13.2112 2.81864 13.1388 2.70642 13.0846C2.80611 13.023 2.88805 12.9505 2.95017 12.8661C3.04138 12.7422 3.08609 12.5977 3.08609 12.4365C3.08609 12.1403 2.97594 11.9041 2.7521 11.7404C2.53645 11.5772 2.25212 11.5002 1.90815 11.5002C1.7136 11.5002 1.52963 11.5372 1.35712 11.6115C1.28512 11.6418 1.21426 11.6776 1.14456 11.7188C0.938688 11.8404 0.928034 12.1099 1.06649 12.2774C1.21291 12.4544 1.46028 12.4561 1.63989 12.363C1.70891 12.3286 1.78521 12.3109 1.87023 12.3109C1.96356 12.3109 2.01717 12.3317 2.04691 12.3578C2.07449 12.3821 2.09529 12.4231 2.09529 12.4981C2.09529 12.5709 2.0658 12.6284 1.99667 12.6764C1.96042 12.6999 1.8978 12.7216 1.80025 12.7355C1.61051 12.7625 1.44118 12.9145 1.44118 13.1237C1.44118 13.3319 1.60937 13.4885 1.80489 13.5068C1.87785 13.5136 1.93575 13.5234 1.97985 13.5355C2.07997 13.562 2.12905 13.596 2.14927 13.6246C2.17519 13.6614 2.19008 13.7078 2.19008 13.7684C2.19008 13.8334 2.16583 13.8754 2.1142 13.9064C2.05357 13.9428 1.96521 13.965 1.84179 13.965C1.749 13.965 1.6547 13.9433 1.55817 13.8981C1.363 13.7983 1.08846 13.8083 0.942801 14.01L0.936366 14.0189C0.827321 14.1699 0.821861 14.401 0.994678 14.5262C1.07406 14.5836 1.16225 14.633 1.2579 14.674Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.13037 2.827C4.799 2.827 4.53037 3.09563 4.53037 3.427C4.53037 3.75837 4.799 4.027 5.13037 4.027H15.1489C15.4803 4.027 15.7489 3.75837 15.7489 3.427C15.7489 3.09563 15.4803 2.827 15.1489 2.827H5.13037Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53037 8.28711C4.53037 7.95574 4.799 7.68711 5.13037 7.68711H15.1489C15.4803 7.68711 15.7489 7.95574 15.7489 8.28711C15.7489 8.61848 15.4803 8.88711 15.1489 8.88711H5.13037C4.799 8.88711 4.53037 8.61848 4.53037 8.28711Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.13037 12.5475C4.799 12.5475 4.53037 12.8161 4.53037 13.1475C4.53037 13.4788 4.799 13.7475 5.13037 13.7475H15.1489C15.4803 13.7475 15.7489 13.4788 15.7489 13.1475C15.7489 12.8161 15.4803 12.5475 15.1489 12.5475H5.13037Z`}}]},hm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`order-icon`,ref:t,icon:mm}))});hm.displayName=`OrderIcon`;let gm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M7.5 2H4.5C2.84315 2 1.5 3.34315 1.5 5C1.5 6.65685 2.84315 8 4.5 8H5M5 2V13.5M7.5 2V13.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.8 9H12.7L14.5 11.5L12.7 14H10.8L9 11.5L10.8 9Z`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.75 11.5H11.7501`,strokeLinecap:`round`,strokeWidth:1.8}}]},_m=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paragraph-setting-icon`,ref:t,icon:gm}))});_m.displayName=`ParagraphSettingIcon`;let vm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.518 3.816a.51.51 0 0 1 0 .72l-.798.797.797.798a.51.51 0 0 1-.72.72L12 6.054l-.797.797a.51.51 0 0 1-.72-.72l.797-.798-.798-.797a.51.51 0 0 1 .72-.72l.798.797.797-.797a.51.51 0 0 1 .72 0M9.25 8.25a1 1 0 0 0-1 1v5.5a1 1 0 0 0 1 1h5.5a1 1 0 0 0 1-1v-5.5a1 1 0 0 0-1-1zm4.268 9.62a.51.51 0 0 0-.72-.72l-.798.797-.797-.798a.51.51 0 0 0-.72.72l.797.798-.798.797a.51.51 0 0 0 .72.72l.798-.797.797.797a.51.51 0 0 0 .72-.72l-.797-.797zM6.85 10.482a.51.51 0 0 1 0 .72L6.053 12l.798.797a.51.51 0 0 1-.72.72l-.798-.797-.797.798a.51.51 0 1 1-.72-.72L4.613 12l-.797-.797a.51.51 0 1 1 .72-.72l.797.797.798-.797a.51.51 0 0 1 .72 0m13.333.72a.51.51 0 1 0-.72-.72l-.797.797-.798-.797a.51.51 0 1 0-.72.72l.797.797-.797.797a.51.51 0 1 0 .72.72l.798-.797.797.798a.51.51 0 1 0 .72-.72L19.387 12zM9.75 9.75v4.5h4.5v-4.5z`,transform:`scale(.83333)`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ym=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`quick-add-icon`,ref:t,icon:vm}))});ym.displayName=`QuickAddIcon`;let bm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.9999 7.9999H13.9999`,strokeLinecap:`round`,strokeWidth:1.2}}]},xm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`reduce-icon`,ref:t,icon:bm}))});xm.displayName=`ReduceIcon`;let Sm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.9999 1.89941C1.66853 1.89941 1.3999 2.16804 1.3999 2.49941C1.3999 2.83078 1.66853 3.09941 1.9999 3.09941H13.9999C14.3313 3.09941 14.5999 2.83078 14.5999 2.49941C14.5999 2.16804 14.3313 1.89941 13.9999 1.89941H1.9999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.66665 5.56641C4.33528 5.56641 4.06665 5.83504 4.06665 6.16641C4.06665 6.49778 4.33528 6.76641 4.66665 6.76641H14C14.3314 6.76641 14.6 6.49778 14.6 6.16641C14.6 5.83504 14.3314 5.56641 14 5.56641H4.66665Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 9.8334C1.3999 9.50203 1.66853 9.2334 1.9999 9.2334H13.9999C14.3313 9.2334 14.5999 9.50203 14.5999 9.8334C14.5999 10.1648 14.3313 10.4334 13.9999 10.4334H1.9999C1.66853 10.4334 1.3999 10.1648 1.3999 9.8334Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.66665 12.9004C4.33528 12.9004 4.06665 13.169 4.06665 13.5004C4.06665 13.8318 4.33528 14.1004 4.66665 14.1004H14C14.3314 14.1004 14.6 13.8318 14.6 13.5004C14.6 13.169 14.3314 12.9004 14 12.9004H4.66665Z`}}]},Cm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`right-justifying-icon`,ref:t,icon:Sm}))});Cm.displayName=`RightJustifyingIcon`;let wm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M6.5 14H3.5C2.67157 14 2 13.3284 2 12.5V3C2 2.17157 2.67157 1.5 3.5 1.5H11C11.8284 1.5 12.5 2.17157 12.5 3V6.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 4H10M4.5 10H6.5M2 7H3M5.25 7H6.25M8.5 7H9.5M11.75 7H12.5`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.8 9H12.7L14.5 11.5L12.7 14H10.8L9 11.5L10.8 9Z`,strokeLinejoin:`round`,strokeWidth:1.3}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.75 11.5H11.7501`,strokeLinecap:`round`,strokeWidth:1.8}}]},Tm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`section-setting-icon`,ref:t,icon:wm}))});Tm.displayName=`SectionSettingIcon`;let Em={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M14.35 5.3V4A2.35 2.35 0 0 0 12 1.65H4A2.35 2.35 0 0 0 1.65 4V12A2.35 2.35 0 0 0 4 14.35H5.3`,strokeLinecap:`round`,strokeWidth:1.3}},{tag:`circle`,attrs:{cx:12.5,cy:12.5,r:5.85,stroke:`currentColor`,strokeWidth:1.3}}]},Dm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`shape-icon`,ref:t,icon:Em}))});Dm.displayName=`ShapeIcon`;let Om={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:8,cy:8,r:6.4,stroke:`currentColor`,strokeWidth:1.2}},{tag:`circle`,attrs:{cx:5.75,cy:6.3,r:.75,fill:`currentColor`}},{tag:`circle`,attrs:{cx:10.25,cy:6.3,r:.75,fill:`currentColor`}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 9.3C5.65 10.65 6.65 11.35 8 11.35C9.35 11.35 10.35 10.65 11 9.3`,strokeLinecap:`round`,strokeWidth:1.2}}]},km=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`smile-icon`,ref:t,icon:Om}))});km.displayName=`SmileIcon`;let Am={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:11.2,height:13.2,x:2.4,y:1.4,stroke:`currentColor`,rx:1.6,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M5 12H11M5.5 9.7V7.8M8 9.7V5M10.5 9.7V6.5M5 9.7H11`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},jm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`statistical-function-icon`,ref:t,icon:Am}))});jm.displayName=`StatisticalFunctionIcon`;let Mm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z`}}]},Nm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`strikethrough-icon`,ref:t,icon:Mm}))});Nm.displayName=`StrikethroughIcon`;let Pm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.08596 14.1387L10.3379 2.66873`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.3379 14.1387L2.08596 2.66873`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M12.8098 10.0174C13.4565 9.45285 14.781 9.44507 15.0272 10.5759C15.2798 11.736 13.8101 13.2515 12.7376 14.1033C12.7227 14.1151 12.7315 14.1389 12.7505 14.1388L15.2251 14.1388`,strokeLinecap:`round`,strokeWidth:1.2}}]},Fm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`subscript-icon`,ref:t,icon:Pm}))});Fm.displayName=`SubscriptIcon`;let Im={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M11.5 4.5C10.75 3.5 9.5 3 8 3C6 3 4.5 4 4.5 5.5C4.5 9 11.5 7 11.5 10.5C11.5 12 10 13 8 13C6.5 13 5.25 12.5 4.5 11.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},Lm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`subtitle-type-icon`,ref:t,icon:Im}))});Lm.displayName=`SubtitleTypeIcon`;let Rm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 17`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.10904 14.4537L10.299 3.06987`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M10.2989 14.4537L2.10899 3.06987`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M12.7525 3.35933C13.3943 2.79901 14.7089 2.79129 14.9533 3.91363C15.204 5.06487 13.7456 6.56876 12.6812 7.41429C12.6663 7.4261 12.6751 7.44982 12.6941 7.44982L15.1497 7.44977`,strokeLinecap:`round`,strokeWidth:1.2}}]},zm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`superscript-icon`,ref:t,icon:Rm}))});zm.displayName=`SuperscriptIcon`;let Bm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M3 20H7.5A.5.5 0 0 0 8 19.5V19.218A.52.52 0 0 0 7.753 18.781A8 8 0 1 1 16.247 18.78A.52.52 0 0 0 16 19.218V19.5A.5.5 0 0 0 16.5 20H21`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2}}]},Vm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`symbols-icon`,ref:t,icon:Bm}))});Vm.displayName=`SymbolsIcon`;let Hm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M2.22891 2.67227H11.5622M6.89541 2.67227V14.0056M10.2289 7.00552H15.5622M12.8954 7.00552V14.0055`,strokeLinecap:`round`,strokeWidth:1.2}}]},Um=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-icon`,ref:t,icon:Hm}))});Um.displayName=`TextIcon`;let Wm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.06641 1.9999C2.06641 1.66853 2.33504 1.3999 2.66641 1.3999H13.3331C13.6644 1.3999 13.9331 1.66853 13.9331 1.9999V3.64434C13.9331 3.97571 13.6644 4.24434 13.3331 4.24434C13.0017 4.24434 12.7331 3.97571 12.7331 3.64434V2.5999H8.59966V13.3999H10.6665C10.9979 13.3999 11.2665 13.6685 11.2665 13.9999C11.2665 14.3313 10.9979 14.5999 10.6665 14.5999L7.99966 14.5999L5.33315 14.5999C5.00178 14.5999 4.73315 14.3313 4.73315 13.9999C4.73315 13.6685 5.00178 13.3999 5.33315 13.3999H7.39966V2.5999H3.26641V3.64434C3.26641 3.97571 2.99778 4.24434 2.66641 4.24434C2.33504 4.24434 2.06641 3.97571 2.06641 3.64434V1.9999Z`}}]},Gm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-type-icon`,ref:t,icon:Wm}))});Gm.displayName=`TextTypeIcon`;let Km={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.75 4H9.25M5.5 4V12.5M10.25 7.5H14.25M11.75 5.5V11C11.75 12 12.25 12.5 13.25 12.5H14.25`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},qm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`title-type-icon`,ref:t,icon:Km}))});qm.displayName=`TitleTypeIcon`;let Jm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z`}}]},Ym=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`underline-icon`,ref:t,icon:Jm}))});Ym.displayName=`UnderlineIcon`;let Xm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M3.03012 3.14006C3.03012 3.59845 2.65851 3.97006 2.20012 3.97006C1.74172 3.97006 1.37012 3.59845 1.37012 3.14006C1.37012 2.68166 1.74172 2.31006 2.20012 2.31006C2.65851 2.31006 3.03012 2.68166 3.03012 3.14006Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 2.54014C4.1989 2.54014 3.93027 2.80877 3.93027 3.14014C3.93027 3.47151 4.1989 3.74014 4.53027 3.74014H14.5488C14.8802 3.74014 15.1488 3.47151 15.1488 3.14014C15.1488 2.80877 14.8802 2.54014 14.5488 2.54014H4.53027Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.20012 8.82992C2.65851 8.82992 3.03012 8.45832 3.03012 7.99992C3.03012 7.54153 2.65851 7.16992 2.20012 7.16992C1.74172 7.16992 1.37012 7.54153 1.37012 7.99992C1.37012 8.45832 1.74172 8.82992 2.20012 8.82992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 7.4C4.1989 7.4 3.93027 7.66863 3.93027 8C3.93027 8.33137 4.1989 8.6 4.53027 8.6H14.5488C14.8802 8.6 15.1488 8.33137 15.1488 8C15.1488 7.66863 14.8802 7.4 14.5488 7.4H4.53027Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.20012 13.6905C2.65851 13.6905 3.03012 13.3189 3.03012 12.8605C3.03012 12.4021 2.65851 12.0305 2.20012 12.0305C1.74172 12.0305 1.37012 12.4021 1.37012 12.8605C1.37012 13.3189 1.74172 13.6905 2.20012 13.6905Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.53027 12.2604C4.1989 12.2604 3.93027 12.529 3.93027 12.8604C3.93027 13.1917 4.1989 13.4604 4.53027 13.4604H14.5488C14.8802 13.4604 15.1488 13.1917 15.1488 12.8604C15.1488 12.529 14.8802 12.2604 14.5488 12.2604H4.53027Z`}}]},Zm=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`unorder-icon`,ref:t,icon:Xm}))});Zm.displayName=`UnorderIcon`;let Qm={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z`}}]},$m=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`write-icon`,ref:t,icon:Qm}))});$m.displayName=`WriteIcon`;let eh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:10,cy:10,r:9,fill:`#F5F5F5`}},{tag:`path`,attrs:{fill:`#6646E8`,d:`M10 10L10 1A9 9 0 0 1 19 10Z`}},{tag:`path`,attrs:{fill:`#55B144`,d:`M10 10L19 10A9 9 0 0 1 10 19Z`}},{tag:`path`,attrs:{fill:`#CBC443`,d:`M10 10L10 19A9 9 0 0 1 1 10Z`}},{tag:`path`,attrs:{fill:`#E8433D`,d:`M10 10L1 10A9 9 0 0 1 10 1Z`}},{tag:`circle`,attrs:{cx:10,cy:10,r:9,fill:`url(#color-wheel-multi-icon_color-wheel-multi-icon-radial)`}},{tag:`defs`,attrs:{},children:[{tag:`radialGradient`,attrs:{id:`color-wheel-multi-icon_color-wheel-multi-icon-radial`,cx:0,cy:0,r:1,gradientTransform:`matrix(0 9 -9 0 10 10)`,gradientUnits:`userSpaceOnUse`},children:[{tag:`stop`,attrs:{stopColor:`white`,stopOpacity:.82}},{tag:`stop`,attrs:{offset:1,stopColor:`#F5F5F5`,stopOpacity:.01}}]}]}],defIds:[`color-wheel-multi-icon_color-wheel-multi-icon-radial`]},th=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`color-wheel-multi-icon`,ref:t,icon:eh}))});th.displayName=`ColorWheelMultiIcon`;let nh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`#0B9EFB`,d:`M8.79993 14.0166C8.79993 14.4585 8.44176 14.8166 7.99993 14.8166C4.23529 14.8166 1.18345 11.7648 1.18345 8.00017C1.18345 4.23554 4.23529 1.18369 7.99993 1.1837C11.7646 1.1837 14.8164 4.23554 14.8164 8.00017C14.8164 8.442 14.4582 8.80017 14.0164 8.80017C13.5746 8.80017 13.2164 8.442 13.2164 8.00017C13.2164 5.11919 10.8809 2.7837 7.99993 2.7837C5.11895 2.7837 2.78345 5.11919 2.78345 8.00017C2.78345 10.8812 5.11895 13.2166 7.99993 13.2166C8.44176 13.2166 8.79993 13.5748 8.79993 14.0166Z`,fillOpacity:.2,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`#0B9EFB`,d:`M7.20007 1.98384C7.20007 1.54201 7.55824 1.18384 8.00007 1.18384C11.7647 1.18384 14.8165 4.23568 14.8165 8.00032C14.8165 11.765 11.7647 14.8168 8.00007 14.8168C4.23543 14.8168 1.18359 11.765 1.18359 8.00032C1.18359 7.55849 1.54177 7.20031 1.98359 7.20031C2.42542 7.20031 2.78359 7.55849 2.78359 8.00032C2.78359 10.8813 5.11909 13.2168 8.00007 13.2168C10.8811 13.2168 13.2165 10.8813 13.2165 8.00032C13.2165 5.11933 10.8811 2.78384 8.00007 2.78384C7.55824 2.78384 7.20007 2.42567 7.20007 1.98384Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},rh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`loading-multi-icon`,ref:t,icon:nh}))});rh.displayName=`LoadingMultiIcon`;let ih={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M5.4004 2.60213C5.25792 2.60213 5.14241 2.71763 5.14241 2.86011V4.32679C5.14241 4.67752 4.85809 4.96184 4.50736 4.96184C4.15663 4.96184 3.87231 4.67752 3.87231 4.32679V2.86011C3.87231 2.01618 4.55646 1.33203 5.4004 1.33203H13.14C13.984 1.33203 14.6681 2.01618 14.6681 2.86011V10.5998C14.6681 11.4437 13.984 12.1278 13.14 12.1278H11.6568C11.3061 12.1278 11.0218 11.8435 11.0218 11.4928C11.0218 11.1421 11.3061 10.8577 11.6568 10.8577H13.14C13.2825 10.8577 13.398 10.7422 13.398 10.5998V2.86011C13.398 2.71763 13.2825 2.60213 13.14 2.60213H5.4004Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.33203 5.40015C1.33203 4.55622 2.01618 3.87207 2.86011 3.87207H10.5998C11.4437 3.87207 12.1278 4.55622 12.1278 5.40015V13.1398C12.1278 13.9837 11.4437 14.6679 10.5998 14.6679H2.86011C2.01618 14.6679 1.33203 13.9837 1.33203 13.1398V5.40015ZM2.86011 5.14217C2.71763 5.14217 2.60213 5.25767 2.60213 5.40015V13.1398C2.60213 13.2823 2.71763 13.3978 2.86011 13.3978H10.5998C10.7422 13.3978 10.8577 13.2823 10.8577 13.1398V5.40015C10.8577 5.25767 10.7422 5.14217 10.5998 5.14217H2.86011Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ah=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`copy-double-icon`,ref:t,icon:ih}))});ah.displayName=`CopyDoubleIcon`;let oh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.9503 1.33317C12.6866 1.33317 13.2836 1.9301 13.2836 2.6665V13.3332C13.2836 14.0695 12.6866 14.6665 11.9503 14.6665H9.28359C8.54721 14.6665 7.95026 14.0696 7.95026 13.3332L7.95026 2.6665C7.95026 1.9301 8.54721 1.33317 9.28359 1.33317H11.9503ZM11.9503 2.6665V13.3332H9.28359V2.6665H11.9503Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M3.8542 6.29716C3.59385 6.03681 3.17174 6.03681 2.91139 6.29716C2.65104 6.55751 2.65104 6.97962 2.91139 7.23997L3.67157 8.00014L2.9114 8.76031C2.65105 9.02066 2.65105 9.44277 2.9114 9.70312C3.17175 9.96347 3.59387 9.96347 3.85421 9.70312L4.61437 8.94296L5.37459 9.70318C5.63494 9.96352 6.05705 9.96353 6.31741 9.70318C6.57775 9.44283 6.57775 9.02072 6.31741 8.76036L5.55718 8.00014L6.31742 7.23991C6.57777 6.97956 6.57777 6.55745 6.31742 6.2971C6.05707 6.03675 5.63496 6.03675 5.37461 6.2971L4.61437 7.05734L3.8542 6.29716Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},sh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-column-double-icon`,ref:t,icon:oh}))});sh.displayName=`DeleteColumnDoubleIcon`;let ch={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.6666 11.9502C14.6666 12.6866 14.0697 13.2835 13.3333 13.2835H2.66665C1.93027 13.2835 1.33331 12.6866 1.33331 11.9502V9.28353C1.33331 8.54715 1.93027 7.9502 2.66665 7.9502L13.3333 7.9502C14.0697 7.9502 14.6666 8.54715 14.6666 9.28353V11.9502ZM13.3333 11.9502H2.66665V9.28353H13.3333V11.9502Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M9.60134 3.85438C9.86169 3.59403 9.86169 3.17192 9.60134 2.91157C9.34099 2.65122 8.91888 2.65122 8.65853 2.91157L7.89835 3.67175L7.13819 2.91159C6.87784 2.65124 6.45573 2.65124 6.19538 2.91159C5.93503 3.17194 5.93503 3.59405 6.19538 3.8544L6.95554 4.61456L6.19532 5.37478C5.93497 5.63513 5.93497 6.05724 6.19532 6.31759C6.45567 6.57794 6.87778 6.57794 7.13813 6.31759L7.89835 5.55737L8.65859 6.3176C8.91893 6.57796 9.34105 6.57796 9.60139 6.3176C9.86175 6.05726 9.86175 5.63514 9.60139 5.3748L8.84116 4.61456L9.60134 3.85438Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},lh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-row-double-icon`,ref:t,icon:ch}))});lh.displayName=`DeleteRowDoubleIcon`;let uh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 1.5H13.5M1.5 1.5V13.5M5.5 1.5V13.5M9.5 1.5V8M1.5 5.5H13.5M1.5 9.5H8M13.5 1.5V8M1.5 13.5H8`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`colorChannel1`,d:`M9.7 9.7L14.5 14.5M14.5 9.7L9.7 14.5`,strokeLinecap:`round`,strokeWidth:1.3}}]},dh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`delete-table-double-icon`,ref:t,icon:uh}))});dh.displayName=`DeleteTableDoubleIcon`;let fh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},ph=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`font-color-double-icon`,ref:t,icon:fh}))});ph.displayName=`FontColorDoubleIcon`;let mh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.53337 14C2.35658 14 2.18704 13.9297 2.06203 13.8047C1.93703 13.6797 1.86681 13.5101 1.86681 13.3333C1.86681 13.1565 1.93703 12.987 2.06203 12.862C2.18704 12.7369 2.35658 12.6667 2.53337 12.6667L13.4667 12.6667C13.6435 12.6667 13.813 12.7369 13.938 12.862C14.063 12.987 14.1333 13.1565 14.1333 13.3333C14.1333 13.5101 14.063 13.6797 13.938 13.8047C13.813 13.9297 13.6435 14 13.4667 14L2.53337 14ZM2.53337 3.33333C2.35658 3.33331 2.18703 3.26306 2.06203 3.13804C1.93703 3.01301 1.86681 2.84346 1.86681 2.66667C1.86681 2.48987 1.93703 2.32032 2.06203 2.1953C2.18703 2.07028 2.35658 2.00003 2.53337 2L13.4667 2C13.6435 2.00003 13.813 2.07028 13.938 2.1953C14.063 2.32032 14.1333 2.48987 14.1333 2.66667C14.1333 2.84346 14.063 3.01301 13.938 3.13803C13.813 3.26306 13.6435 3.33331 13.4667 3.33333L2.53337 3.33333Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M11.0573 7.33327L10.1953 6.47127C10.0703 6.34627 10.0001 6.17672 10.0001 5.99994C10.0001 5.82315 10.0703 5.65361 10.1953 5.52861C10.3203 5.4036 10.4899 5.33337 10.6667 5.33337C10.8434 5.33337 11.013 5.4036 11.138 5.52861L13.138 7.5286C13.2 7.59046 13.2491 7.66393 13.2827 7.74481C13.3162 7.82569 13.3335 7.91238 13.3335 7.99994C13.3335 8.08749 13.3162 8.17419 13.2827 8.25507C13.2491 8.33594 13.2 8.40941 13.138 8.47127L11.138 10.4713C11.0761 10.5332 11.0026 10.5823 10.9217 10.6158C10.8409 10.6493 10.7542 10.6665 10.6667 10.6665C10.5791 10.6665 10.4925 10.6493 10.4116 10.6158C10.3307 10.5823 10.2572 10.5332 10.1953 10.4713C10.1334 10.4094 10.0843 10.3359 10.0508 10.255C10.0173 10.1742 10.0001 10.0875 10.0001 9.99994C10.0001 9.9124 10.0173 9.82573 10.0508 9.74486C10.0843 9.66398 10.1334 9.5905 10.1953 9.52861L11.0573 8.6666L3.33333 8.66661C3.15652 8.66661 2.98695 8.59637 2.86193 8.47134C2.7369 8.34632 2.66666 8.17675 2.66666 7.99994C2.66666 7.82313 2.7369 7.65356 2.86193 7.52853C2.98695 7.40351 3.15652 7.33327 3.33333 7.33327L11.0573 7.33327Z`}}]},hh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-double-icon`,ref:t,icon:mh}))});hh.displayName=`InsertDoubleIcon`;let gh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.3333 13.4087C14.0697 13.4087 14.6666 12.8117 14.6666 12.0754L14.6666 9.40869C14.6666 8.67231 14.0697 8.07536 13.3333 8.07536L2.66663 8.07536C1.93023 8.07536 1.33329 8.67231 1.33329 9.40869L1.33329 12.0754C1.33329 12.8117 1.93023 13.4087 2.66663 13.4087L13.3333 13.4087ZM2.66663 12.0754L13.3333 12.0754L13.3333 9.40869L2.66663 9.40869L2.66663 12.0754Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M7.74168 2.59137C8.10987 2.59137 8.40835 2.88984 8.40835 3.25804L8.40835 4.33309L9.48348 4.33309C9.85167 4.33309 10.1501 4.63156 10.1501 4.99976C10.1501 5.36794 9.85167 5.66642 9.48348 5.66642L8.40835 5.66642L8.40835 6.74154C8.40835 7.10973 8.10987 7.4082 7.74168 7.4082C7.37349 7.4082 7.07501 7.10973 7.07501 6.74154L7.07501 5.66642L5.99998 5.66642C5.63179 5.66642 5.33331 5.36794 5.33331 4.99976C5.33331 4.63156 5.63179 4.33309 5.99998 4.33309L7.07501 4.33309L7.07501 3.25804C7.07501 2.88984 7.37349 2.59137 7.74168 2.59137Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},_h=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-row-above-double-icon`,ref:t,icon:gh}))});_h.displayName=`InsertRowAboveDoubleIcon`;let vh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.66671 2.59131C1.93033 2.59131 1.33337 3.18826 1.33337 3.92464L1.33337 6.59131C1.33337 7.32769 1.93033 7.92464 2.66671 7.92464L13.3334 7.92464C14.0698 7.92464 14.6667 7.32769 14.6667 6.59131L14.6667 3.92464C14.6667 3.18826 14.0698 2.59131 13.3334 2.59131L2.66671 2.59131ZM13.3334 3.92464L2.66671 3.92464L2.66671 6.59131L13.3334 6.59131L13.3334 3.92464Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M8.25838 13.4086C7.8902 13.4086 7.59172 13.1102 7.59172 12.742L7.59172 11.6669L6.51658 11.6669C6.14839 11.6669 5.84992 11.3684 5.84991 11.0002C5.84991 10.6321 6.14839 10.3336 6.51658 10.3336L7.59172 10.3336L7.59171 9.25846C7.59171 8.89027 7.89019 8.5918 8.25838 8.5918C8.62657 8.5918 8.92505 8.89027 8.92505 9.25846L8.92505 10.3336L10.0001 10.3336C10.3683 10.3336 10.6667 10.6321 10.6667 11.0002C10.6667 11.3684 10.3683 11.6669 10.0001 11.6669L8.92505 11.6669L8.92505 12.742C8.92505 13.1102 8.62658 13.4086 8.25838 13.4086Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},yh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`insert-row-below-double-icon`,ref:t,icon:vh}))});yh.displayName=`InsertRowBelowDoubleIcon`;let bh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M13.4322 2.66683C13.4322 1.93045 12.8352 1.3335 12.0989 1.3335H9.43219C8.69581 1.3335 8.09886 1.93045 8.09886 2.66683V13.3335C8.09886 14.0699 8.69581 14.6668 9.43219 14.6668H12.0989C12.8352 14.6668 13.4322 14.0699 13.4322 13.3335V2.66683ZM12.0989 13.3335V2.66683H9.43219V13.3335H12.0989Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M2.56769 7.99978C2.56769 7.63159 2.86616 7.33311 3.23435 7.33311H4.30941V6.25798C4.30941 5.88979 4.60788 5.59131 4.97607 5.59131C5.34426 5.59131 5.64274 5.88979 5.64274 6.25798V7.33311H6.71785C7.08604 7.33311 7.38452 7.63159 7.38452 7.99978C7.38452 8.36797 7.08604 8.66644 6.71785 8.66644H5.64274V9.74148C5.64274 10.1097 5.34426 10.4081 4.97607 10.4081C4.60788 10.4081 4.30941 10.1097 4.30941 9.74148V8.66644H3.23435C2.86616 8.66644 2.56769 8.36797 2.56769 7.99978Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},xh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`left-insert-column-double-icon`,ref:t,icon:bh}))});xh.displayName=`LeftInsertColumnDoubleIcon`;let Sh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.665 2.66496H3.33496C2.96493 2.66496 2.66496 2.96493 2.66496 3.33496V12.665C2.66496 13.035 2.96493 13.335 3.33496 13.335H12.665C13.035 13.335 13.335 13.035 13.335 12.665V3.33496C13.335 2.96493 13.035 2.66496 12.665 2.66496ZM3.33496 1.33496C2.23039 1.33496 1.33496 2.23039 1.33496 3.33496V12.665C1.33496 13.7695 2.23039 14.665 3.33496 14.665H12.665C13.7695 14.665 14.665 13.7695 14.665 12.665V3.33496C14.665 2.23039 13.7695 1.33496 12.665 1.33496H3.33496Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M13.2559 14.1963L1.64941 2.58984L2.58987 1.64939L14.1963 13.2558L13.2559 14.1963Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Ch=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`no-color-double-icon`,ref:t,icon:Sh}))});Ch.displayName=`NoColorDoubleIcon`;let wh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z`}}]},Th=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paint-bucket-double-icon`,ref:t,icon:wh}))});Th.displayName=`PaintBucketDoubleIcon`;let Eh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`colorChannel1`,d:`M7.74692 9.12463C7.74692 9.46018 8.01893 9.73219 8.35448 9.73219H11.4933C11.8288 9.73219 12.1009 9.46018 12.1009 9.12463C12.1009 8.78909 11.8288 8.51707 11.4933 8.51707H8.35448C8.01893 8.51707 7.74692 8.78909 7.74692 9.12463Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M10.8636 10.8523C10.8636 11.1879 10.5915 11.4599 10.256 11.4599H8.35448C8.01893 11.4599 7.74692 11.1879 7.74692 10.8523C7.74692 10.5168 8.01893 10.2447 8.35448 10.2447H10.256C10.5915 10.2447 10.8636 10.5168 10.8636 10.8523Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M5.4791 1.98268C5.47913 1.71529 5.87912 1.49854 6.37252 1.49854C6.86593 1.49854 7.26592 1.71529 7.26595 1.98268H7.62187C8.22277 1.98268 8.72459 2.39534 8.84412 2.9452H9.39563C10.0856 2.9452 10.6449 3.48923 10.6449 4.16032V6.00569H12.1261C13.161 6.00569 14 6.82174 14 7.82838V11.334C14 11.8174 13.8025 12.281 13.4511 12.6228L12.0693 13.9647C11.7179 14.3065 11.2412 14.4985 10.7442 14.4985H7.91116C7.05024 14.4985 6.32492 14.0431 6.10535 13.2737H3.34925C2.6593 13.2737 2.09998 12.7297 2.09998 12.0586V4.16032C2.09998 3.48923 2.6593 2.9452 3.34925 2.9452H3.90107C4.0206 2.39534 4.52241 1.98268 5.12332 1.98268H5.4791ZM3.97249 4.16032H3.24925L3.24925 12.0586H6.03725V7.82838C6.03725 6.82174 6.87623 6.00569 7.91116 6.00569H9.49563V4.16032H8.7727C8.58289 4.59611 8.13909 4.90183 7.62187 4.90183H5.12332C4.6061 4.90183 4.1623 4.59611 3.97249 4.16032ZM5.12332 2.89403H7.62187C7.79436 2.89403 7.93419 3.03003 7.93419 3.19781V3.68671C7.93419 3.85448 7.79436 3.99049 7.62187 3.99049H5.12332C4.95083 3.99049 4.811 3.85448 4.811 3.68671V3.19781C4.811 3.03003 4.95083 2.89403 5.12332 2.89403ZM7.91116 7.11157C7.56618 7.11157 7.28652 7.38359 7.28652 7.71913V12.7851C7.28652 13.1206 7.56618 13.3927 7.91116 13.3927H10.7442C10.8401 13.3927 10.9337 13.3712 11.0182 13.3311C11.1373 13.2746 11.1859 13.1423 11.1859 13.0134V12.0066C11.1859 11.8724 11.2978 11.7636 11.4358 11.7636H12.4709C12.6034 11.7636 12.7394 11.7163 12.7975 11.6004C12.8388 11.5182 12.8608 11.4272 12.8608 11.334V7.71913C12.8608 7.38359 12.5811 7.11157 12.2362 7.11157H7.91116Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Dh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`paste-special-double-icon`,ref:t,icon:Eh}))});Dh.displayName=`PasteSpecialDoubleIcon`;let Oh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.53331 14C2.35652 14 2.18697 13.9297 2.06197 13.8047C1.93697 13.6797 1.86675 13.5101 1.86675 13.3333C1.86675 13.1565 1.93697 12.987 2.06197 12.862C2.18697 12.7369 2.35652 12.6667 2.53331 12.6667L13.4666 12.6667C13.6434 12.6667 13.813 12.7369 13.938 12.862C14.063 12.987 14.1332 13.1565 14.1332 13.3333C14.1332 13.5101 14.063 13.6797 13.938 13.8047C13.813 13.9297 13.6434 14 13.4666 14L2.53331 14ZM2.53331 3.33333C2.35652 3.33331 2.18697 3.26306 2.06197 3.13804C1.93697 3.01301 1.86675 2.84346 1.86675 2.66667C1.86675 2.48987 1.93697 2.32032 2.06197 2.1953C2.18697 2.07028 2.35652 2.00003 2.53331 2L13.4666 2C13.6434 2.00003 13.813 2.07028 13.938 2.1953C14.063 2.32032 14.1332 2.48987 14.1332 2.66667C14.1332 2.84346 14.063 3.01301 13.938 3.13803C13.813 3.26306 13.6434 3.33331 13.4666 3.33333L2.53331 3.33333Z`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M10.8142 10.8141C10.5588 11.0695 10.1447 11.0695 9.88929 10.8141L7.97868 8.90354L6.14021 10.742C5.89652 10.9857 5.50142 10.9857 5.25774 10.742C5.01405 10.4983 5.01405 10.1032 5.25774 9.85955L7.09621 8.02107L5.18561 6.11047C4.93021 5.85507 4.93021 5.44098 5.18561 5.18557C5.44101 4.93017 5.8551 4.93017 6.11051 5.18557L8.02111 7.09618L9.85959 5.2577C10.1033 5.01401 10.4984 5.01401 10.7421 5.2577C10.9857 5.50139 10.9857 5.89648 10.7421 6.14017L8.90358 7.97865L10.8142 9.88925C11.0696 10.1447 11.0696 10.5587 10.8142 10.8141Z`}}]},kh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`reduce-double-icon`,ref:t,icon:Oh}))});kh.displayName=`ReduceDoubleIcon`;let Ah={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M2.56781 13.3332C2.56781 14.0695 3.16476 14.6665 3.90114 14.6665L6.56781 14.6665C7.30419 14.6665 7.90114 14.0695 7.90114 13.3332L7.90114 2.6665C7.90114 1.9301 7.30419 1.33317 6.56781 1.33317L3.90114 1.33317C3.16476 1.33317 2.56781 1.9301 2.56781 2.6665L2.56781 13.3332ZM3.90114 2.6665L3.90114 13.3332L6.56781 13.3332L6.56781 2.6665L3.90114 2.6665Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`colorChannel1`,d:`M13.4323 8.00022C13.4323 8.36841 13.1338 8.66689 12.7656 8.66689L11.6906 8.66689L11.6906 9.74202C11.6906 10.1102 11.3921 10.4087 11.0239 10.4087C10.6557 10.4087 10.3573 10.1102 10.3573 9.74202L10.3573 8.66689L9.28215 8.66689C8.91396 8.66689 8.61548 8.36841 8.61548 8.00022C8.61548 7.63203 8.91396 7.33356 9.28214 7.33356L10.3573 7.33356L10.3573 6.25852C10.3573 5.89033 10.6557 5.59186 11.0239 5.59186C11.3921 5.59186 11.6906 5.89033 11.6906 6.25852L11.6906 7.33356L12.7656 7.33356C13.1338 7.33356 13.4323 7.63203 13.4323 8.00022Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},jh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`right-insert-column-double-icon`,ref:t,icon:Ah}))});jh.displayName=`RightInsertColumnDoubleIcon`;let Mh={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:14,height:14,x:1,y:1,stroke:`currentColor`,rx:1.75,strokeOpacity:.12}},{tag:`path`,attrs:{stroke:`colorChannel1`,d:`M4.75 11.5L8 4.5L11.25 11.5M6 9H10`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.33}}]},Nh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`text-color-swatch-double-icon`,ref:t,icon:Mh}))});Nh.displayName=`TextColorSwatchDoubleIcon`;let Ph={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.96372 2.59116C5.19803 2.35684 5.19803 1.97695 4.96372 1.74263C4.7294 1.50832 4.3495 1.50832 4.11519 1.74263L2.53945 3.31837L1.96372 2.74263C1.7294 2.50832 1.3495 2.50832 1.11519 2.74263C0.880874 2.97695 0.880874 3.35684 1.11519 3.59116L2.11519 4.59116C2.3495 4.82547 2.7294 4.82547 2.96372 4.59116L4.96372 2.59116Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.4605 2.56689H6.8981C6.56672 2.56689 6.2981 2.83552 6.2981 3.16689C6.2981 3.49827 6.56672 3.76689 6.8981 3.76689H14.4605C14.7918 3.76689 15.0605 3.49827 15.0605 3.16689C15.0605 2.83552 14.7918 2.56689 14.4605 2.56689Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.8981 7.2334C6.56672 7.2334 6.2981 7.50203 6.2981 7.8334C6.2981 8.16477 6.56672 8.4334 6.8981 8.4334H14.4605C14.7918 8.4334 15.0605 8.16477 15.0605 7.8334C15.0605 7.50203 14.7918 7.2334 14.4605 7.2334H6.8981Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.2981 12.4999C6.2981 12.1685 6.56672 11.8999 6.8981 11.8999H14.4605C14.7918 11.8999 15.0605 12.1685 15.0605 12.4999C15.0605 12.8313 14.7918 13.0999 14.4605 13.0999H6.8981C6.56672 13.0999 6.2981 12.8313 6.2981 12.4999Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M2.87279 5.8999C1.80504 5.8999 0.939453 6.76549 0.939453 7.83324C0.939453 8.90099 1.80504 9.76657 2.87279 9.76657C3.94054 9.76657 4.80612 8.90099 4.80612 7.83324C4.80612 6.76549 3.94054 5.8999 2.87279 5.8999ZM2.13945 7.83324C2.13945 7.42823 2.46778 7.0999 2.87279 7.0999C3.2778 7.0999 3.60612 7.42823 3.60612 7.83324C3.60612 8.23824 3.2778 8.56657 2.87279 8.56657C2.46778 8.56657 2.13945 8.23824 2.13945 7.83324Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M0.939453 12.5002C0.939453 11.4325 1.80504 10.5669 2.87279 10.5669C3.94054 10.5669 4.80612 11.4325 4.80612 12.5002C4.80612 13.568 3.94054 14.4336 2.87279 14.4336C1.80504 14.4336 0.939453 13.568 0.939453 12.5002ZM2.87279 11.7669C2.46778 11.7669 2.13945 12.0952 2.13945 12.5002C2.13945 12.9052 2.46778 13.2336 2.87279 13.2336C3.2778 13.2336 3.60612 12.9052 3.60612 12.5002C3.60612 12.0952 3.2778 11.7669 2.87279 11.7669Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Fh=(0,l.forwardRef)(function(e,t){return(0,l.createElement)($,Object.assign({},e,{id:`todo-list-double-icon`,ref:t,icon:Ph}))});Fh.displayName=`TodoListDoubleIcon`;let Ih={currentPage:null,totalPages:null,dragTooltip:null};function Lh(e,t,n,r,i){let a=i==null||i.complete?e.length:null,o=i==null||i.complete?e.length:Math.min(i.publishedPageCount,e.length),s=0;for(let i=0;i<o;i++){let o=e[i],c=r?o.pageHeight:o.pageWidth;if(t<=s+c)return{currentPage:!o.isLayoutPlaceholder&&!o.isMaterializationPlaceholder?i+1:null,totalPages:a};s+=c+n}return{currentPage:null,totalPages:a}}function Rh(){let e=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useObservable)((0,l.useMemo)(()=>e.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[e])),d=c?s.getRenderUnitById(c.getUnitId()):null,f=d==null?void 0:d.with(n.DocSkeletonManagerService),p=(0,a.useObservable)((f==null?void 0:f.currentSkeleton$)??null,(f==null?void 0:f.getSkeleton())??null,!1,[f]),m=(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL&&d!=null&&p!=null&&d.mainComponent instanceof r.Documents,[h,g]=(0,l.useState)(Ih),_=(0,l.useRef)(null),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{let e=d==null?void 0:d.scene.getViewport(`viewMain`),n=d==null?void 0:d.mainComponent;if(!m||d==null||p==null||e==null||!(n instanceof r.Documents))return;let i=()=>{var t;let i=((t=p.getSkeletonData())==null?void 0:t.pages)??[],a=e.calcViewportInfo().viewBound,{docsLeft:o,docsTop:s,pageLayoutType:c=r.PageLayoutType.VERTICAL,pageMarginLeft:l,pageMarginTop:u}=n.getOffsetConfig(),d=c!==r.PageLayoutType.HORIZONTAL;return Lh(i,d?(a.top+a.bottom)/2-s:(a.left+a.right)/2-o,d?u:l,d,p.getLayoutProgress()??null)},a=()=>{let e=i();g(t=>t.currentPage===e.currentPage&&t.totalPages===e.totalPages?t:{...t,...e})},o=()=>{_.current!=null&&clearTimeout(_.current),_.current=setTimeout(a,120)},s=(t,n)=>{let r=e.getScrollBar(),i=r==null?void 0:r.verticalThumbRect,a=d.engine.getCanvasElement();if(!(r!=null&&r.hasVerticalThumb())||i==null||a==null)return null;let o=a.getBoundingClientRect(),s=d.engine.width>0?o.width/d.engine.width:1,c=d.engine.height>0?o.height/d.engine.height:1;return{page:t,left:o.left+(e.left+i.left)*s-8,top:o.top+(e.top+n+r.verticalThumbSize/2)*c}},c=e=>{let t=i().currentPage,n=t==null?null:s(t,e.scrollY);g(e=>({...e,dragTooltip:n}))},l=()=>{v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{g(e=>e.dragTooltip==null?e:{...e,dragTooltip:null})},500)},u=new t.DisposableCollection,f=()=>{u.dispose(),_.current!=null&&(clearTimeout(_.current),_.current=null),v.current!=null&&(clearTimeout(v.current),v.current=null)};return u.add((0,t.fromEventSubject)(n.onDispose$).subscribe(()=>{f(),g(Ih)})),o(),u.add((0,t.fromEventSubject)(e.onScrollAfter$).subscribe(e=>{if(e.isBarDragging||e.isBarDragEnd){v.current!=null&&(clearTimeout(v.current),v.current=null),c(e),e.isBarDragEnd&&(l(),o());return}o()})),u.add(p.layoutProgress$.subscribe(a)),u.add(p.layoutPageMaterialized$.subscribe(a)),f},[m,d,p]),!m)return null;let y=null;return h.currentPage!=null&&(y=h.totalPages==null?o.t(`docs-ui.statistics.currentPage`,String(h.currentPage)):o.t(`docs-ui.statistics.currentPageOfTotal`,String(h.currentPage),String(h.totalPages))),(0,u.jsxs)(u.Fragment,{children:[y&&(0,u.jsx)(`span`,{className:`univer-tabular-nums`,children:y}),h.dragTooltip&&(0,u.jsx)(i.Popup,{visible:!0,overflowVisible:!0,offset:[h.dragTooltip.left,h.dragTooltip.top],children:(0,u.jsx)(`div`,{"data-testid":`doc-scroll-page-tooltip`,className:`univer-pointer-events-none univer-absolute univer-whitespace-nowrap univer-rounded univer-border univer-border-gray-300 univer-bg-white univer-px-2 univer-py-1 univer-text-xs univer-font-medium univer-tabular-nums univer-text-gray-700 univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-800 dark:!univer-text-gray-200`,style:{transform:`translate(-100%, -50%)`},children:o.t(`docs-ui.statistics.currentPage`,String(h.dragTooltip.page))})})]})}let zh={words:0,charactersWithoutSpaces:0,charactersWithSpaces:0,paragraphs:0,nonAsianWords:0,asianCharactersAndKoreanWords:0},Bh={pages:0,lines:0};function Vh(e){return(e.getTextRanges()??[]).filter(e=>!e.collapsed&&!e.segmentId).map(({collapsed:e,direction:t,endOffset:n,isActive:r,rangeType:i,segmentId:a,segmentPage:o,startOffset:s})=>({collapsed:e,direction:t,endOffset:n,isActive:r,rangeType:i,segmentId:a,segmentPage:o,startOffset:s}))}function Hh(e,t,n){let r=Math.min(e.startOffset,e.endOffset),i=Math.max(e.startOffset,e.endOffset);return r<n&&i>t}function Uh(e,t=[],n=!0){var i;let a=(e==null||(i=e.getSkeletonData())==null?void 0:i.pages)??[];if(t.length===0){let e=0;return(0,r.documentSkeletonLineIterator)(a,{},()=>e++),{lines:e,pages:n?a.length:0}}let o=0,s=n?new Set:null;return(0,r.documentSkeletonLineIterator)(a,{},({line:e,pageIndex:n})=>{t.some(t=>Hh(t,e.st,e.ed))&&(o+=1,s==null||s.add(n))}),{lines:o,pages:(s==null?void 0:s.size)??0}}async function Wh({calculateLayout:e,calculatePages:t,documentDataModel:n,cachedStatistics:r,locale:i,selectionRanges:a,signal:o,skeleton:s}){let c=e?Uh(s,[],t):Bh,l=e&&a.length>0?Uh(s,a,t):Bh,[u,d]=await Promise.all([r??n.getStatistics({locale:i,signal:o}),a.length>0?n.getStatistics({locale:i,ranges:a,signal:o}):null]);return{document:{...u,...c},selection:d?{...d,...l}:null}}function Gh(e,t,n,r,i){e.current={documentDataModel:t,locale:n,revision:r,statistics:{words:i.words,charactersWithoutSpaces:i.charactersWithoutSpaces,charactersWithSpaces:i.charactersWithSpaces,paragraphs:i.paragraphs,nonAsianWords:i.nonAsianWords,asianCharactersAndKoreanWords:i.asianCharactersAndKoreanWords}}}function Kh(e,t){return(0,a.useObservable)(e?()=>(0,s.combineLatest)([t.textSelection$.pipe((0,s.startWith)(void 0)),e.change$]).pipe((0,s.map)(([,e])=>({ranges:Vh(t),revision:e}))):null,{ranges:[],revision:0},!1,[e,t])}function qh(e,t){var r;let i=e?(r=t.getRenderUnitById(e.getUnitId()))==null?void 0:r.with(n.DocSkeletonManagerService):null;return(0,a.useObservable)(i?i.currentSkeleton$.pipe((0,s.map)(e=>({value:e}))):null,{value:(i==null?void 0:i.getSkeleton())??null},!1,[i]).value}function Jh(e=!1){let i=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useDependency)(n.DocSelectionManagerService),u=(0,l.useRef)(null),d=(0,a.useObservable)((0,l.useMemo)(()=>i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[i])),f=Kh(d,c),p=(0,a.useObservable)(o.currentLocale$,o.getCurrentLocale()),m=(d==null?void 0:d.getDocumentStyle().documentFlavor)!==t.DocumentFlavor.MODERN,h=qh(e?d:null,s),[g,_]=(0,l.useState)({document:{...zh,lines:0,pages:0},selection:null,loading:!0}),v=f.ranges;return(0,l.useEffect)(()=>{if(!(d!=null&&d.getBody()))return;let t=d,n=u.current,r=(n==null?void 0:n.documentDataModel)===t&&n.locale===p&&n.revision===f.revision,i=new AbortController,a=setTimeout(async()=>{_(e=>({...e,loading:!0}));try{let a=await Wh({calculateLayout:e,calculatePages:m,documentDataModel:t,cachedStatistics:r?n.statistics:void 0,locale:p,selectionRanges:v,signal:i.signal,skeleton:h??null});r||Gh(u,t,p,f.revision,a.document),_({...a,loading:!1})}catch{i.signal.aborted||_(e=>({...e,loading:!1}))}},200);return()=>{clearTimeout(a),i.abort()}},[e,d,p,v,f,m,h]),{...g,showPages:m}}let Yh=[[{key:`pages`,label:`docs-ui.statistics.pages`},{key:`words`,label:`docs-ui.statistics.words`}],[{key:`charactersWithoutSpaces`,label:`docs-ui.statistics.charactersWithoutSpaces`},{key:`charactersWithSpaces`,label:`docs-ui.statistics.charactersWithSpaces`}],[{key:`paragraphs`,label:`docs-ui.statistics.paragraphs`},{key:`lines`,label:`docs-ui.statistics.lines`}],[{key:`nonAsianWords`,label:`docs-ui.statistics.nonAsianWords`},{key:`asianCharactersAndKoreanWords`,label:`docs-ui.statistics.asianCharactersAndKoreanWords`}]];function Xh({statistics:e,selection:n,showPages:r,loading:o}){let s=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(t.RegionService),l=(0,a.useObservable)(s.direction$,s.getDirection()),d=(0,a.useObservable)(c.currentRegion$,c.getCurrentRegion()),f=t.LOCALE_META[d].tag,p=Yh.map(e=>e.filter(({key:e})=>r||e!==`pages`)).filter(e=>e.length>0),m=o&&p.flat().every(({key:t})=>e[t]===0);return(0,u.jsxs)(`div`,{className:`univer-w-full`,dir:l,children:[(0,u.jsxs)(`header`,{className:`univer-flex univer-items-center univer-gap-3 univer-px-4 univer-py-3`,children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-flex-1 rtl:univer-text-right`,children:[(0,u.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-semibold univer-leading-5`,children:s.t(`docs-ui.statistics.title`)}),(0,u.jsx)(`div`,{className:`univer-truncate univer-text-xs univer-leading-4 univer-text-gray-500 dark:!univer-text-gray-400`,children:s.t(n?`docs-ui.statistics.selection`:`docs-ui.statistics.document`)})]}),o&&(0,u.jsx)(rh,{"aria-hidden":`true`,className:`univer-size-4 univer-shrink-0 univer-animate-spin univer-text-primary-600`})]}),(0,u.jsx)(i.Separator,{}),(0,u.jsx)(`dl`,{className:`univer-m-0 univer-p-2`,children:p.map((t,n)=>(0,u.jsxs)(`div`,{children:[n>0&&(0,u.jsx)(i.Separator,{className:`univer-my-1`}),t.map(({key:t,label:n})=>(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-between univer-gap-4 univer-rounded-md univer-px-2 univer-py-1`,children:[(0,u.jsx)(`dt`,{className:`univer-min-w-0 univer-flex-1 univer-text-sm univer-leading-5 univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-300`,children:s.t(n)}),(0,u.jsx)(`dd`,{className:`univer-m-0 univer-min-w-12 univer-shrink-0 univer-text-right univer-text-sm univer-font-semibold univer-tabular-nums univer-leading-5 univer-text-gray-900 rtl:univer-text-left dark:!univer-text-gray-0`,children:m?`—`:e[t].toLocaleString(f)})]},t))]},t[0].key))})]})}function Zh(){let e=(0,a.useDependency)(t.LocaleService),n=(0,a.useDependency)(t.RegionService),[r,o]=(0,l.useState)(!1),{document:s,selection:c,loading:d,showPages:f}=Jh(r),p=(0,a.useObservable)(n.currentRegion$,n.getCurrentRegion()),m=t.LOCALE_META[p].tag,h=c??s,g=e.t(`docs-ui.statistics.open`),_=e.t(`docs-ui.statistics.title`),v=c?e.t(`docs-ui.statistics.selectedWords`,c.words.toLocaleString(m),s.words.toLocaleString(m)):e.t(`docs-ui.statistics.wordCount`,s.words.toLocaleString(m));return(0,u.jsx)(i.Dropdown,{align:`start`,className:`univer-w-80 univer-shadow-xl`,side:`top`,open:r,"aria-busy":d,"aria-label":_,onOpenChange:o,overlay:(0,u.jsx)(Xh,{statistics:h,selection:c!=null,showPages:f,loading:d}),children:(0,u.jsx)(`span`,{title:r?void 0:g,children:(0,u.jsx)(a.ToolbarButton,{noIcon:!0,active:r,className:`!univer-h-7 univer-px-2 univer-text-xs !univer-text-gray-600 focus-visible:univer-ring-2 focus-visible:univer-ring-primary-500 dark:!univer-text-gray-300`,"aria-expanded":r,"aria-haspopup":`dialog`,"aria-label":g,children:(0,u.jsxs)(`span`,{className:`univer-flex univer-items-center univer-gap-1.5`,children:[(0,u.jsx)(jm,{className:`univer-size-4`}),(0,u.jsx)(Rh,{}),(0,u.jsx)(`span`,{children:v}),d&&(0,u.jsx)(rh,{className:`univer-size-3.5 univer-animate-spin`})]})})})})}let Qh=class extends t.RxDisposable{constructor(e){super(),this._univerInstanceService=e,R(this,`_progressByUnit$`,new s.BehaviorSubject(new Map)),R(this,`currentProgress$`,void 0),this.currentProgress$=(0,s.combineLatest)([this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),this._progressByUnit$]).pipe((0,s.map)(([e,t])=>{if(!e)return null;let n=e.getUnitId(),r=t.get(n);return r==null?null:{progress:r,unitId:n}}),(0,s.distinctUntilChanged)((e,t)=>(e==null?void 0:e.unitId)===(t==null?void 0:t.unitId)&&(e==null?void 0:e.progress)===(t==null?void 0:t.progress)),(0,s.takeUntil)(this.dispose$))}setProgress(e,t){let n=this._progressByUnit$.value;n.get(e)!==t&&this._progressByUnit$.next(new Map(n).set(e,t))}clearProgress(e){let t=this._progressByUnit$.value;if(!t.has(e))return;let n=new Map(t);n.delete(e),this._progressByUnit$.next(n)}dispose(){this._progressByUnit$.complete(),super.dispose()}};Qh=B([z(0,t.IUniverInstanceService)],Qh);function $h(){let e=(0,a.useDependency)(t.LocaleService),n=(0,a.useObservable)((0,a.useDependency)(Qh).currentProgress$,null);if(n==null)return null;let{progress:r}=n,i=e.t(`docs-ui.layout.progress`);return(0,u.jsxs)(`div`,{className:`univer-pointer-events-none univer-absolute univer-left-1/2 univer-top-1/2 univer-flex -univer-translate-x-1/2 -univer-translate-y-1/2 univer-items-center univer-gap-2 univer-text-xs univer-text-gray-600 dark:univer-text-gray-300`,children:[(0,u.jsx)(`span`,{className:`univer-whitespace-nowrap`,children:i}),(0,u.jsx)(`div`,{"aria-label":i,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":r,className:`univer-h-1 univer-w-32 univer-overflow-hidden univer-rounded-full univer-bg-gray-200 dark:univer-bg-gray-700`,role:`progressbar`,children:(0,u.jsx)(`div`,{className:`univer-h-full univer-rounded-full univer-bg-primary-600 univer-transition-[width]`,style:{width:`${r}%`}})}),(0,u.jsxs)(`span`,{className:`univer-w-8 univer-tabular-nums`,children:[r,`%`]})]})}function eg(){let e=(0,a.useConfigValue)(as);return((e==null?void 0:e.footer)??!0)&&(0,u.jsxs)(`div`,{className:`univer-relative univer-box-border univer-flex univer-items-center univer-justify-between univer-px-5 univer-py-1.5`,children:[(e==null?void 0:e.wordCount)!==!1&&(0,u.jsx)(Zh,{}),(0,u.jsx)($h,{}),(0,u.jsx)(rp,{})]})}function tg(){let e=(0,a.useDependency)(a.IWorkbenchService);return(0,a.useObservable)(e.rootUnitType$,null,!0)===t.UniverInstanceType.UNIVER_DOC?(0,u.jsx)(eg,{}):null}let ng=(0,l.forwardRef)((e,t)=>{let{label:n,menus:r,onClick:a,className:o,style:s,mode:c,maxHeight:d,activeId:f,open:p,onOpenChange:m,maxWidth:h,wrapperClass:g,wrapperStyle:_,iconClass:v,iconStyle:y}=e,b=(0,l.useId)(),x=(0,l.useRef)(null),S=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useRef)(new Map),T=Math.min(256,h??256),E=(0,l.useMemo)(()=>({scrollTo:e=>{let t=S.current,n=w.current.get(e);if(!t||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<t.scrollTop?t.scrollTo({top:r}):i>t.scrollTop+t.clientHeight&&t.scrollTo({top:i-t.clientHeight})}}),[]);(0,l.useImperativeHandle)(t,()=>E),(0,l.useEffect)(()=>{p&&f&&E.scrollTo(f)},[f,E,p]),(0,l.useEffect)(()=>{if(!p||c!==`float`)return;let e=e=>{var t;e.target instanceof Node&&!((t=x.current)!=null&&t.contains(e.target))&&(m==null||m(!1))};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[c,m,p]);let D=e=>{var t;if(e.key===`Escape`&&p){var n;e.preventDefault(),e.stopPropagation(),m==null||m(!1),(n=C.current)==null||n.focus();return}let r=Array.from(w.current.values()),i=r.indexOf(e.target);if(i===-1)return;let a;switch(e.key){case`ArrowDown`:a=Math.min(i+1,r.length-1);break;case`ArrowUp`:a=Math.max(i-1,0);break;case`Home`:a=0;break;case`End`:a=r.length-1;break;default:return}e.preventDefault(),e.stopPropagation(),(t=r[a])==null||t.focus()};return(0,u.jsxs)(`div`,{ref:x,className:(0,i.clsx)(`univer-relative univer-ml-3`,g),style:{width:T,..._},onKeyDown:D,children:[(0,u.jsx)(`button`,{ref:C,type:`button`,"aria-label":n,"aria-expanded":!!p,"aria-controls":p?b:void 0,title:n,onClick:()=>m==null?void 0:m(!p),className:(0,i.clsx)(`univer-absolute univer-top-1.5 univer-z-10 univer-flex univer-size-8 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md univer-border-0 univer-bg-gray-0 univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 hover:univer-text-gray-900 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:univer-outline-primary-600 dark:univer-bg-gray-900 dark:univer-text-gray-400 dark:hover:univer-bg-gray-800`,!p&&`univer-shadow-sm`,v),style:{left:p?T-40:0,...y},children:p?(0,u.jsx)(dm,{"aria-hidden":`true`}):(0,u.jsx)(_p,{"aria-hidden":`true`})}),p&&(0,u.jsxs)(`nav`,{id:b,"aria-label":n,className:(0,i.clsx)(`univer-box-border univer-flex univer-w-full univer-flex-col univer-overflow-hidden univer-rounded-lg univer-border univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-text-gray-700 dark:univer-border-gray-700 dark:univer-bg-gray-900 dark:univer-text-gray-200`,c===`float`?`univer-shadow-md`:`univer-shadow-sm`,o),style:{maxHeight:d,...s},children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-h-11 univer-shrink-0 univer-items-center univer-gap-2 univer-px-3 univer-pr-12 univer-text-xs univer-font-medium univer-text-gray-500 dark:univer-text-gray-400`,children:[(0,u.jsx)(_p,{"aria-hidden":`true`,className:`univer-shrink-0 univer-text-sm`}),(0,u.jsx)(`span`,{className:`univer-truncate`,children:n})]}),(0,u.jsx)(`div`,{ref:S,className:(0,i.clsx)(`univer-relative univer-min-h-0 univer-overflow-y-auto univer-overscroll-contain univer-px-2 univer-pb-2`,i.scrollbarClassName),children:(0,u.jsx)(`ol`,{className:`univer-m-0 univer-list-none univer-p-0`,children:r==null?void 0:r.map(e=>(0,u.jsx)(`li`,{className:e.isTitle?`univer-mb-1 univer-pb-1`:void 0,children:(0,u.jsxs)(`button`,{ref:t=>{t?w.current.set(e.id,t):w.current.delete(e.id)},type:`button`,"aria-current":e.id===f?`location`:void 0,title:e.text,className:(0,i.clsx)(`univer-relative univer-box-border univer-flex univer-min-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded univer-border-0 univer-bg-transparent univer-py-1.5 univer-pr-2 univer-text-left univer-text-sm univer-leading-5 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline focus-visible:univer-outline-2 focus-visible:-univer-outline-offset-2 focus-visible:univer-outline-primary-600 dark:hover:univer-bg-gray-800`,e.isTitle?`univer-font-semibold`:`univer-font-normal`,{"univer-bg-primary-50 univer-text-primary-700 hover:univer-bg-primary-50 dark:univer-bg-gray-700 dark:univer-text-primary-200 dark:hover:univer-bg-gray-700":e.id===f,"univer-text-gray-900 dark:univer-text-gray-100":e.isTitle&&e.id!==f,"univer-text-gray-600 dark:univer-text-gray-300":!e.isTitle&&e.id!==f}),style:{paddingLeft:10+Math.max(0,e.level-1)*12},onClick:()=>{if(a==null||a(e),c===`float`){var t;m==null||m(!1),(t=C.current)==null||t.focus()}},children:[e.level>1&&(0,u.jsx)(`span`,{"aria-hidden":`true`,className:`univer-absolute univer-bottom-0 univer-top-0 univer-w-px univer-bg-gray-200 dark:univer-bg-gray-700`,style:{left:14+Math.max(0,e.level-2)*12}}),e.id===f&&(0,u.jsx)(`span`,{"aria-hidden":`true`,className:`univer-absolute univer-bottom-2 univer-left-0 univer-top-2 univer-w-0.5 univer-rounded-full univer-bg-primary-600 dark:univer-bg-primary-400`}),(0,u.jsx)(`span`,{className:e.isTitle?`univer-line-clamp-2 univer-break-words`:`univer-truncate`,children:e.text})]})},e.id))})})]})]})}),rg=e=>{switch(e){case t.NamedStyleType.HEADING_1:return 1;case t.NamedStyleType.HEADING_2:return 2;case t.NamedStyleType.HEADING_3:return 3;case t.NamedStyleType.HEADING_4:return 4;case t.NamedStyleType.HEADING_5:return 5;case t.NamedStyleType.TITLE:return 1;default:return 1}};function ig(e,t,n,r){if(!e)return;let i=Array.from(e.values()),a=i.findIndex(e=>e.paragraphStart!==e.paragraphEnd&&e.rect.top<r&&e.rect.bottom>n);if(a===-1)return;let o=i==null?void 0:i.findLastIndex(e=>e.paragraphStart!==e.paragraphEnd&&e.rect.top<r&&e.rect.bottom>n);for(let e=a;e<=o;e++){var s;let n=i[e],r=t.get(n.startIndex);if(r!=null&&(s=r.paragraphStyle)!=null&&s.headingId)return r.paragraphStyle.headingId}for(let e=a;e>=0;e--){var c;let n=i[e],r=t.get(n.startIndex);if(r!=null&&(c=r.paragraphStyle)!=null&&c.headingId)return r.paragraphStyle.headingId}}let ag=`__title`;function og(){let e=(0,a.useConfigValue)(as),n=(0,a.useDependency)(a.IWorkbenchService);return(0,a.useObservable)(n.rootUnitType$,null,!0)===t.UniverInstanceType.UNIVER_DOC&&e!=null&&e.toc?(0,u.jsx)(sg,{}):null}function sg(){var e,n;let i=(0,a.useDependency)(t.IUniverInstanceService),o=(0,a.useDependency)(t.LocaleService),c=(0,a.useObservable)(()=>i.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),void 0,!1,[i]),d=(0,a.useDependency)(r.IRenderManagerService),f=(0,a.useObservable)(c?()=>c.change$.pipe((0,s.debounceTime)(100),(0,s.map)(()=>c.getSnapshot())):null,c==null?void 0:c.getSnapshot(),!1,[c]),p=(f==null||(e=f.body)==null?void 0:e.dataStream)??``,[m,h]=(0,l.useState)(void 0),g=(c==null?void 0:c.getUnitId())??``,_=d.getRenderUnitById(g),v=f==null?void 0:f.title,y=_==null?void 0:_.with(rl),b=y==null?void 0:y.paragraphBounds,x=()=>{var e;return{left:(_==null||(e=_.mainComponent)==null?void 0:e.left)??0,canvasHeight:(_==null?void 0:_.engine.height)??0,canvasWidth:(_==null?void 0:_.engine.width)??0,scaleY:(_==null?void 0:_.scene.scaleY)??1}},{left:S,canvasHeight:C,canvasWidth:w,scaleY:T}=(0,a.useObservable)(_!=null&&_.engine.onTransformChange$?()=>(0,s.merge)((0,t.fromEventSubject)(_.engine.onTransformChange$),..._.mainComponent?[(0,t.fromEventSubject)(_.mainComponent.onTransformChange$)]:[]).pipe((0,s.auditTime)(33),(0,s.map)(x),(0,s.startWith)(x())):null,x(),!1,[_]),E=(0,l.useMemo)(()=>{var e;return(f==null||(e=f.body)==null?void 0:e.paragraphs)??[]},[f==null||(n=f.body)==null?void 0:n.paragraphs]),D=(0,l.useMemo)(()=>(0,t.getParagraphContentStartOffsets)({dataStream:p,paragraphs:E}),[p,E]),O=(0,l.useMemo)(()=>{let e=new Map;return E.forEach(t=>{e.set(t.startIndex,t)}),e},[E]),k=S<240?`float`:`side-bar`,A=E==null?void 0:E.filter(e=>{var n;return((n=e.paragraphStyle)==null?void 0:n.namedStyleType)!==void 0&&e.paragraphStyle.namedStyleType!==t.NamedStyleType.SUBTITLE&&e.paragraphStyle.namedStyleType!==t.NamedStyleType.NORMAL_TEXT}).map(e=>{var n;let r=rg(e.paragraphStyle.namedStyleType);return{id:e.paragraphStyle.headingId,text:(0,t.getPlainText)(p.slice(D.get(e.startIndex),e.startIndex)),level:r,isTitle:((n=e.paragraphStyle)==null?void 0:n.namedStyleType)===t.NamedStyleType.TITLE}}).filter(e=>e==null?void 0:e.text),j=(0,a.useEvent)(e=>{let t=e.viewportScrollY,n=t+C/T,r=ig(b,O,t,n);r&&h(r)}),M=A!=null&&A.find(e=>e.isTitle)?A:[...v?[{id:ag,text:v,level:1,isTitle:!0}]:[],...A??[]].filter(Boolean),[N,ee]=(0,l.useState)(!0);(0,l.useEffect)(()=>{let e=_==null?void 0:_.scene.getViewport(`viewMain`);if(!e)return;let n=(0,t.fromEventSubject)(e.onScrollAfter$).pipe((0,s.throttleTime)(33)).subscribe(j);return()=>{n.unsubscribe()}},[j,_]);let P=(0,a.useEvent)(e=>{let t=_==null?void 0:_.scene.getViewport(`viewMain`);if(!t)return;if(e.id===ag){t.scrollToViewportPos({viewportScrollY:0}),h(e.id);return}let n=E.find(t=>{var n;return((n=t.paragraphStyle)==null?void 0:n.headingId)===e.id});if(!n)return;let r=b==null?void 0:b.get(n.startIndex);r&&(t.scrollToViewportPos({viewportScrollY:r.rect.top}),h(e.id))});return!c||(0,t.isInternalEditorID)(g)||!(M!=null&&M.length)?null:(0,u.jsx)(`div`,{className:`univer-absolute univer-bottom-0 univer-left-0 univer-top-0 univer-z-[100] univer-w-[0px]`,children:(0,u.jsx)(ng,{label:o.t(`docs-ui.outline.title`),menus:M,open:N,onOpenChange:ee,mode:k,maxWidth:Math.max(0,Math.floor(k===`float`?w:S)-24),wrapperClass:`univer-mt-4`,activeId:m,onClick:P,maxHeight:Math.max(0,C-32)})})}let cg=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._injector=e,this._commandService=t,this._layoutService=n,this._menuManagerService=r,this._uiPartsService=i,this._univerInstanceService=a,this._shortcutService=o,this._configService=s,this._embedRuntimeFocusCoordinator=l,this._init()}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.FOOTER,()=>(0,a.connectInjector)(tg,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.CONTENT,()=>(0,a.connectInjector)(og,this._injector)))}_initMenus(){this._menuManagerService.appendRootMenu(Lf),this._menuManagerService.mergeMenu(Rf)}_initShortCut(){[Hf,Uf,Wf,Gf,Kf,qf,Xf,Zf,Yf,Jf,Qf,$f,Bf].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_init(){this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts(),this._initShortCut()}_initCommands(){[ll,cl,jc,Mc,kc].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(t.UniverInstanceType.UNIVER_DOC,e=>{if(this._shouldPreserveEmbedFocus(e))return;let t=this._injector.get(r.IRenderManagerService).getRenderUnitById(e);t&&t.with(q).focus()}))}_shouldPreserveEmbedFocus(e){var t;return!!((t=this._embedRuntimeFocusCoordinator)!=null&&t.shouldSuppressHostInteraction(e))}};cg=B([z(0,(0,t.Inject)(t.Injector)),z(1,t.ICommandService),z(2,a.ILayoutService),z(3,a.IMenuManagerService),z(4,a.IUIPartsService),z(5,t.IUniverInstanceService),z(6,a.IShortcutService),z(7,t.IConfigService),z(8,(0,t.Optional)(Ie)),z(9,(0,t.Optional)(Le))],cg);function lg(){if(typeof window>`u`)return{bleedLeft:0,bleedRight:0,bleedWidth:1,contentWidth:1,virtualWidth:1};let e=Math.max(1,window.innerWidth-20);return{bleedLeft:0,bleedRight:0,bleedWidth:e,contentWidth:1,virtualWidth:e}}function ug(e,t,n){let r=e.getBoundingClientRect(),i=n==null?void 0:n.viewScale,a=typeof i==`number`&&Number.isFinite(i)&&i>0?i:1,o=Math.max(1,r.width/a),s=Math.max(1,t),c=n==null?void 0:n.bleedLeft,l=n==null?void 0:n.bleedWidth,u=Number.isFinite(l)&&(l??0)>0;if(s<=o&&(n!=null&&n.authoritativeContentWidth||!u))return{bleedLeft:0,bleedRight:0,bleedWidth:o,contentWidth:s,virtualWidth:o};if(u){let e=Math.max(0,c??0),t=Math.max(1,l);return{bleedLeft:e,bleedRight:Math.max(0,t-e-o),bleedWidth:t,contentWidth:s,virtualWidth:Math.max(t,e+s)}}let d=pg(e),f=d.left+10,p=Math.max(1,d.width-20),m=Math.max(0,(r.left-f)/a),h=Math.max(0,(f+p-r.right)/a),g=p/a;return{bleedLeft:m,bleedRight:h,bleedWidth:g,contentWidth:s,virtualWidth:Math.max(g,m+s)}}function dg(e,t){return Number.isFinite(e)&&(e??0)>0?e:Math.max(1,t)}function fg(e,t){return Number.isFinite(e)&&(e??0)>0?e:Math.max(1,t)}function pg(e){let t=mg(e);if(t){let e=t.getBoundingClientRect();if(Number.isFinite(e.width)&&e.width>0)return{left:e.left,width:e.width}}return{left:0,width:typeof window>`u`?1:Math.max(1,window.innerWidth)}}function mg(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){if(hg(t))return t;t=t.parentElement}return null}function hg(e){let t=window.getComputedStyle(e);return gg(t.overflow)||gg(t.overflowX)||gg(t.overflowY)}function gg(e){return e===`hidden`||e===`auto`||e===`scroll`||e===`clip`}function _g(e,t){let r=new Set;return Object.values(e??{}).forEach(e=>{let i=vg(e),a=i?(t==null?void 0:t(i))??(typeof i.childUnitId==`string`?i.childUnitId:void 0):void 0,o=typeof(i==null?void 0:i.childType)==`number`?i.childType:void 0;a&&(0,n.isSheetLikeDocsCustomBlockChildType)(o)&&r.add(a)}),r}function vg(e){if(!e||typeof e!=`object`)return;let t=e.data;return t&&typeof t==`object`?t:void 0}function yg(e){if(!e||typeof e!=`object`)return;let t=e;return typeof t.unitId==`string`?t.unitId:typeof t.unitID==`string`?t.unitID:void 0}function bg(e){if(e.commandId&&Sg(e.commandId))return!1;let t=yg(e.commandParams);return!!(t&&t!==e.hostUnitId&&e.childUnitIds.has(t))}let xg=new Set([`sheet.command.expand-selection`,`sheet.command.move-selection`,`sheet.operation.scroll-to-cell`,`sheet.operation.scroll-to-range`,`sheet.operation.set-activate-cell-edit`,`sheet.operation.set-cell-edit-visible`,`sheet.operation.set-cell-edit-visible-arrow`,`sheet.operation.set-cell-edit-visible-f2`,`sheet.operation.set-format-painter`,`sheet.operation.set-scroll`,`sheet.operation.set-selections`,`sheet.operation.set-zoom-ratio`]);function Sg(e){return xg.has(e)}function Cg(e){let t;return{dispose:()=>{t!=null&&(window.cancelAnimationFrame(t),t=void 0)},schedule:()=>{t??=window.requestAnimationFrame(()=>{t=void 0,e()})}}}function wg(e,t,n={}){if(e.defaultPrevented||e.ctrlKey||e.metaKey)return!1;let r=e.deltaX||(e.shiftKey?e.deltaY:0),i=e.shiftKey?0:e.deltaY,a=t.scrollLeft,o=t.scrollTop,s=Og(t,n.maxScrollLeft);return r&&Tg(t,r,s)&&(t.scrollLeft=Dg(a+r,0,s)),i&&Eg(t,i)&&(t.scrollTop=Dg(o+i,0,t.scrollHeight-t.clientHeight)),t.scrollLeft!==a||t.scrollTop!==o}function Tg(e,t,n){return e.scrollWidth>e.clientWidth&&(t<0?e.scrollLeft>0:e.scrollLeft<n)}function Eg(e,t){return e.scrollHeight>e.clientHeight&&(t<0?e.scrollTop>0:e.scrollTop+e.clientHeight<e.scrollHeight)}function Dg(e,t,n){return Math.max(t,Math.min(n,e))}function Og(e,t){let n=Math.max(0,e.scrollWidth-e.clientWidth);return Number.isFinite(t)?Dg(t??n,0,n):n}function kg(e){let r=(0,n.resolveDocsCustomBlockSize)(e.childType),i=e.fallbackWidth??r.width,a=e.fallbackHeight??r.height,o=(0,n.isSheetLikeDocsCustomBlockChildType)(e.childType),s=Number.isFinite(e.contentHeight)&&(e.contentHeight??0)>0?e.contentHeight:a,c=Number.isFinite(e.visibleCanvasHeight)&&(e.visibleCanvasHeight??0)>0?e.visibleCanvasHeight:void 0,l=o?s:a,u=o&&c!=null?Math.min(s,c):l,d=e.scale&&e.scale>0?e.scale:1;if(!o)return{height:l,width:i};let f=e.pageWidth,p=e.pageMarginLeft??0,m=e.pageMarginRight??0,h=Number.isFinite(f)?Math.max(0,f-p-m):i,g=Number.isFinite(e.contentWidth)&&(e.contentWidth??0)>0?e.contentWidth:i;if(e.documentFlavor!==t.DocumentFlavor.MODERN||!Number.isFinite(f)){let e=Math.min(g,h||g);return{contentHeight:s,contentWidth:g,height:l,layoutWidth:e,offsetLeft:0,pageContentWidth:h,viewScale:d,visibleCanvasHeight:c,viewportHeight:u,width:e}}let _=10/d,v=e.docsLeft??0,y=v+_,b=Math.max(0,f-_*2),x=Number.isFinite(e.visibleCanvasLeft)&&Number.isFinite(e.visibleCanvasWidth)&&(e.visibleCanvasWidth??0)>0,S=x?e.visibleCanvasLeft+_:y,C=x?Math.max(0,e.visibleCanvasWidth-_*2):b,w=v+p,T=Math.max(0,w-S),E=Math.min(g,h||g);return{bleedLeft:T,bleedWidth:C,contentHeight:s,contentWidth:g,height:l,layoutWidth:E,offsetLeft:0,pageContentWidth:h,viewScale:d,visibleCanvasHeight:c,viewportHeight:u,width:E}}var Ag=`@univerjs/docs-ui`,jg=`1.0.2`;let Mg={id:`doc-paragraph-setting.command`,type:t.CommandType.COMMAND,handler:async(e,r)=>{let i=e.get(n.DocSelectionManagerService),a=e.get(t.IUniverInstanceService),o=e.get(t.ICommandService),s=a.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),c=i.getDocRanges();if(!s||c.length===0||!r)return!1;let l=c[0].segmentId,u=s.getUnitId(),d=s.getSelfOrHeaderFooterModel(l),f=d==null?void 0:d.getBody(),p=(f==null?void 0:f.paragraphs)??[],m=(f==null?void 0:f.dataStream)??``,h=t.BuildTextUtils.range.getParagraphsInRanges(c,p,m)??[],g={id:n.RichTextEditingMutation.id,params:{unitId:u,historyAction:n.DocHistoryAction.FormatParagraph,actions:[],textRanges:c}};if(!r.paragraph||Object.keys(r.paragraph).length===0)return!1;let _=new t.MemoryCursor;_.reset();let v=new t.TextX,y=t.JSONX.getInstance();for(let e of h){let{startIndex:n}=e;v.push({t:t.TextXActionType.RETAIN,len:n-_.cursor}),v.push({t:t.TextXActionType.RETAIN,len:1,body:{dataStream:``,paragraphs:[{...e,paragraphStyle:{...e.paragraphStyle,...r.paragraph},startIndex:0}]},coverType:t.UpdateDocsAttributeType.REPLACE}),_.moveCursorTo(n+1)}let b=(0,t.getRichTextEditPath)(s,l);return g.params.actions=y.editOp(v.serialize(),b),!!o.syncExecuteCommand(g.id,g.params)}};function Ng(e){return Object.prototype.hasOwnProperty.call(t.QuickListTypeMap,e)}function Pg(e){return Object.prototype.hasOwnProperty.call(wo,e)}let Fg=class extends t.Disposable{constructor(e,t){super(),this._docAutoFormatService=e,this._renderManagerService=t,this._initListTabAutoFormat(),this._initSpaceAutoFormat(),this._initDefaultEnterFormat(),this._initExitListAutoFormat()}_initListTabAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:te.id,match:e=>{let{selection:t,paragraphs:n,unit:r}=e;if(n.length===1&&t.startOffset===n[0].paragraphStart&&n[0].bullet){var i;let e=(i=r.getBody())==null?void 0:i.paragraphs,t=e==null?void 0:e.filter(e=>{var t;return((t=e.bullet)==null?void 0:t.listId)===n[0].bullet.listId});return(t==null?void 0:t.findIndex(e=>e.startIndex===n[0].startIndex))!==0}return!!(n.length>1&&n.some(e=>e.bullet))},getMutations(e){let t=e.commandParams;return[{id:to.id,params:{type:t!=null&&t.shift?-1:1}}]},priority:100})),this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:te.id,match:e=>{let{selection:t,unit:r}=e,{startNodePosition:i,endNodePosition:a}=t,o=this._renderManagerService.getRenderUnitById(r.getUnitId()),s=o==null?void 0:o.with(n.DocSkeletonManagerService).getSkeleton();return s!=null&&!!(i&&a&&ot(s,i,a)||i&&!a&&i.path.indexOf(`cells`)>-1)},getMutations(e){let t=e.commandParams;return[{id:$o.id,params:{shift:!!(t!=null&&t.shift)}}]},priority:99}))}_initSpaceAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:ne.id,match:e=>{var t;let{selection:n,paragraphs:r,unit:i}=e;if(!n.collapsed||r.length!==1||!n.collapsed)return!1;let a=(t=i.getBody())==null?void 0:t.dataStream.slice(r[0].paragraphStart,n.startOffset-1);return!!(a&&(Ng(a)||Pg(a)))},getMutations(e){var n;let{paragraphs:r,unit:i,selection:a}=e,o=(n=i.getBody())==null?void 0:n.dataStream.slice(r[0].paragraphStart,a.startOffset-1);if(o&&Ng(o)){let e=t.QuickListTypeMap[o];return[{id:oo.id,params:{listType:e,paragraph:r[0]}}]}if(o&&Pg(o)){let e=wo[o];return[{id:Co.id,params:{value:e}}]}return[]}}))}_initExitListAutoFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:re.id,match:e=>{let{paragraphs:t}=e;return!!(t.length===1&&t[0].bullet&&t[0].paragraphStart===t[0].paragraphEnd)},getMutations:e=>{let t=e.paragraphs[0].bullet;return t?t.nestingLevel>0?[{id:to.id,params:{type:-1}}]:[{id:Qa.id,params:{listType:e.paragraphs[0].bullet.listType}}]:[]}}))}_initDefaultEnterFormat(){this.disposeWithMe(this._docAutoFormatService.registerAutoFormat({id:re.id,match:()=>!0,getMutations(){return[{id:W.id}]},priority:-9999}))}};Fg=B([z(0,(0,t.Inject)(V)),z(1,r.IRenderManagerService)],Fg);var Ig=class extends r.BaseObject{constructor(e,t,n){super(e),this._documents=t,this._scene=n,R(this,`color`,``),this.evented=!1}render(e,n){let i=this._documents.getSkeleton(),a=i==null?void 0:i.getViewModel(),o=i==null?void 0:i.getSkeletonData();if(!o||!a||!this.color||a.getEditArea()!==r.DocumentEditArea.BODY||a.getDataModel().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let s=[];if(this._collectStoryBounds(o,s,n),this._collectDrawingBounds(a.getSnapshot(),s,n==null?void 0:n.viewBound),s.length!==0){e.save(),e.fillStyle=this.color,e.beginPath();for(let t of s)e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top);e.fill(),e.restore(),this.makeDirty(!1)}}_collectStoryBounds(e,t,n){let{pageLayoutType:i,pageMarginTop:a,pageMarginLeft:o}=this._documents.getOffsetConfig(),s=0,c=0;for(let d of e.pages){if(!d.isLayoutPlaceholder&&!d.isMaterializationPlaceholder&&!this._documents.isSkipByDiffBounds(d,c,s,n)){var l,u;let n=this._transformBounds({left:s,top:c,right:s+d.pageWidth,bottom:c+d.pageHeight}),r=(l=e.skeHeaders.get(d.headerId))==null?void 0:l.get(d.pageWidth),i=(u=e.skeFooters.get(d.footerId))==null?void 0:u.get(d.pageWidth),a=[];r&&this._collectTextAndTables(r,s+d.marginLeft,c+r.marginTop,a),i&&this._collectTextAndTables(i,s+d.marginLeft,c+d.pageHeight-i.height-i.marginBottom,a);for(let e of a)this._appendClipped(t,this._transformBounds(e),n)}i===r.PageLayoutType.HORIZONTAL?s+=d.pageWidth+o:c+=d.pageHeight+a}}_collectDrawingBounds(e,n,i){let a=e.id,o=(0,d.getDrawingShapeKeyByDrawingSearch)({unitId:a,subUnitId:a,drawingId:``});for(let a of this._scene.getAllObjects()){var s;if(!a.visible||a.classType===r.RENDER_CLASS_TYPE.GROUP||!a.oKey.startsWith(o))continue;let c=a.oKey.slice(o.length).split(`#-#`,1)[0],l=(s=e.drawings)==null?void 0:s[c];if((l==null?void 0:l.isMultiTransform)!==t.BooleanNumber.TRUE)continue;let u=l.effectExtent,d=this._transformBounds({left:-((u==null?void 0:u.left)??0),top:-((u==null?void 0:u.top)??0),right:a.width+((u==null?void 0:u.right)??0),bottom:a.height+((u==null?void 0:u.bottom)??0)},a.ancestorTransform),f=a.clipBounds,p=[];this._appendClipped(p,d,f?{left:f.left,top:f.top,right:f.left+f.width,bottom:f.top+f.height}:void 0);for(let e of p)this._appendClipped(n,e,i)}}_transformBounds(e,t=this._documents.getOffsetConfig().documentTransform){let n=[[e.left,e.top],[e.right,e.top],[e.right,e.bottom],[e.left,e.bottom]].map(([e,n])=>t.applyPoint(new r.Vector2(e,n)));return{left:Math.min(...n.map(e=>e.x)),right:Math.max(...n.map(e=>e.x)),top:Math.min(...n.map(e=>e.y)),bottom:Math.max(...n.map(e=>e.y))}}_appendClipped(e,t,n){let r=n?{left:Math.max(t.left,n.left),right:Math.min(t.right,n.right),top:Math.max(t.top,n.top),bottom:Math.min(t.bottom,n.bottom)}:t;Object.values(r).every(Number.isFinite)&&r.right>r.left&&r.bottom>r.top&&e.push(r)}_collectTextAndTables(e,t,n,r){for(let i of e.sections)for(let e of i.columns)for(let a of e.lines){let o=n+i.top+a.top+a.marginTop+a.paddingTop;for(let n of a.divides)for(let i of n.glyphGroup){if(!Array.from(i.content).some(e=>e.charCodeAt(0)>32&&e.trim())||i.width<=0)continue;let s=t+e.left+n.left+n.paddingLeft+i.left+i.xOffset,c=o+a.asc;r.push({left:s-1,right:s+Math.max(i.width,i.bBox.width)+1,top:Math.min(o,c-i.bBox.aba)-1,bottom:Math.max(o+a.lineHeight,c+i.bBox.abd)+1})}(a.borderTop||a.borderBottom||a.borderLeft||a.borderRight||a.borderBetween)&&r.push({left:t+e.left,right:t+e.left+e.width,top:o-2,bottom:o+a.lineHeight+2})}for(let i of e.skeTables.values())r.push({left:t+i.left-1,right:t+i.left+i.width+1,top:n+i.top-1,bottom:n+i.top+i.height+1})}};function Lg(e,t){let{radius:n,width:r,height:i}=t;n??=0,r??=30,i??=30;let a=0;a=Math.min(n,r/2,i/2),e.beginPath(),e.moveTo(0,0),e.lineTo(r,0),e.lineTo(r,i-a),e.arc(r-a,i-a,a,0,Math.PI/2,!1),e.lineTo(0,i),e.lineTo(0,0),e.closePath(),t.fill&&(e.save(),e.fillStyle=t.fill,t.fillRule===`evenodd`?e.fill(`evenodd`):e.fill(),e.restore())}var Rg=class e extends r.Shape{constructor(e,t){super(e,t),R(this,`color`,void 0),R(this,`text`,void 0),this.color=t==null?void 0:t.color,this.text=t==null?void 0:t.text}static drawWith(e,t){let{text:n,color:r}=t;e.save(),e.font=`13px Source Han Sans CN`;let i=e.measureText(n).width;if(Lg(e,{height:18,width:Math.min(i+12,200),radius:4,fill:r,evented:!1}),e.fillStyle=`rgba(58, 96, 247, 1)`,i>188){let t=``,r=0;for(let i of n){let n=e.measureText(i).width;if(r+n<=188-e.measureText(`...`).width)t+=i,r+=n;else{t+=`...`;break}}e.fillText(t,6,14)}else e.fillText(n,6,14);e.restore()}_draw(t){e.drawWith(t,this)}};let zg=.5,Bg=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._commandService=t,this._editorService=n,this._docSkeletonManagerService=r,this._docSelectionRenderService=i,this._localeService=a,this._themeService=o,R(this,`_loadedMap`,new WeakSet),R(this,`_contentCover`,void 0),R(this,`_headerFooterColors`,{primary:``,cover:``,label:``}),this._initialize()}_initialize(){this._initThemeColors(),this._init(),this._drawHeaderFooterLabel(),this._listenSwitchMode()}_initThemeColors(){this.disposeWithMe(this._themeService.currentTheme$.subscribe(()=>{let e=this._themeService.getColorFromTheme(`primary.600`);this._headerFooterColors={primary:e,cover:new t.ColorKit(this._themeService.getColorFromTheme(`gray.0`)).setAlpha(zg).toRgbString(),label:new t.ColorKit(e).setAlpha(.08).toRgbString()},this._contentCover&&(this._contentCover.color=this._headerFooterColors.cover,this._contentCover.makeDirty(!0))}))}dispose(){super.dispose()}_listenSwitchMode(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(n.RichTextEditingMutation.id===e.id){let e=this._context.unit,n=this._docSkeletonManagerService.getViewModel().getEditArea(),i=e.getSnapshot().documentStyle.documentFlavor;n!==r.DocumentEditArea.BODY&&i===t.DocumentFlavor.MODERN&&this._commandService.executeCommand(Nc.id,{unitId:this._context.unitId})}}))}_init(){let{unitId:e}=this._context,t=x(this._context);t!=null&&t.document!=null&&(this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document)))}_initialMain(e){let{document:n}=x(this._context);this.disposeWithMe(n.onDblclick$.subscribeEvent(async i=>{var a;if(this._isEditorReadOnly(e)||!this._isTraditionalMode())return;let{offsetX:o,offsetY:s}=i,{pageLayoutType:c=r.PageLayoutType.VERTICAL,pageMarginLeft:l,pageMarginTop:u}=n.getOffsetConfig(),d=this._getTransformCoordForDocumentOffset(o,s);if(d==null)return;let f=this._docSkeletonManagerService.getViewModel(),p=this._docSkeletonManagerService.getSkeleton(),m=f.getEditArea(),{editArea:h,pageNumber:g}=p.findEditAreaByCoord(d,c,l,u);if(m===h&&(h===r.DocumentEditArea.BODY||this._docSelectionRenderService.getSegmentPage()===g))return;f.setEditArea(h);let{createType:_,headerFooterId:v,sectionId:y}=Dc(f,h,g,(a=p.getSkeletonData())==null?void 0:a.pages[g]);if(h===r.DocumentEditArea.BODY)this._docSelectionRenderService.setSegment(``),this._docSelectionRenderService.setSegmentPage(-1),this._docSelectionRenderService.setCursorManually(o,s);else if(_!=null){let n=(0,t.generateRandomId)(6);this._docSelectionRenderService.setSegment(n),this._docSelectionRenderService.setSegmentPage(g),await this._commandService.executeCommand(jc.id,{unitId:e,createType:_,segmentId:n,sectionId:y})}else v!=null&&(this._docSelectionRenderService.setSegment(v),this._docSelectionRenderService.setSegmentPage(g),this._docSelectionRenderService.setCursorManually(o,s))}))}_getTransformCoordForDocumentOffset(e,t){let{document:n,scene:i}=x(this._context),{documentTransform:a}=n.getOffsetConfig(),o=i.getViewports()[0];if(o==null)return;let s=o.transformVector2SceneCoord(r.Vector2.FromArray([e,t]));return a.clone().invert().applyPoint(s)}_drawHeaderFooterLabel(){let{unitId:e,mainComponent:n}=this._context;if(this._editorService.isEditor(e)||n==null)return;let i=n,a=new Ig(`${e}-header-footer-cover`,i,this._context.scene);a.color=this._headerFooterColors.cover,this._contentCover=a,this._context.scene.addObject(a,r.DRAWING_OBJECT_UPPER_LAYER_INDEX),this.disposeWithMe(a),this.disposeWithMe((0,t.toDisposable)(()=>{this._contentCover=void 0})),i.setInactiveAreaOpacity(zg),this.disposeWithMe((0,t.toDisposable)(()=>i.setInactiveAreaOpacity(1))),this.disposeWithMe(this._docSkeletonManagerService.getViewModel().editAreaChange$.subscribe(()=>{i.makeDirty(!0)})),this.disposeWithMe(i.pageRender$.subscribe(t=>this._drawHeaderFooterPage(t,e)))}_drawHeaderFooterPage(e,t){if(this._editorService.isEditor(t)||!this._isTraditionalMode()||this._docSkeletonManagerService.getViewModel().getEditArea()===r.DocumentEditArea.BODY)return;let{pageLeft:n,pageTop:i,ctx:a}=e;a.save(),a.translate(n-.5,i-.5),this._drawHeaderFooterGuides(e),a.restore()}_drawHeaderFooterGuides({page:e,ctx:t}){let{pageWidth:n,pageHeight:i,marginTop:a,marginBottom:o}=e,s={dataArray:[{command:`M`,points:[0,a]},{command:`L`,points:[n,a]}],strokeWidth:1,stroke:this._headerFooterColors.primary},c={dataArray:[{command:`M`,points:[0,i-o]},{command:`L`,points:[n,i-o]}],strokeWidth:1,stroke:this._headerFooterColors.primary};r.Path.drawWith(t,s),r.Path.drawWith(t,c),t.translate(0,a+1),Rg.drawWith(t,{text:this._localeService.t(`docs-ui.headerFooter.header`),color:this._headerFooterColors.label}),t.translate(0,i-a-o),Rg.drawWith(t,{text:this._localeService.t(`docs-ui.headerFooter.footer`),color:this._headerFooterColors.label})}_isEditorReadOnly(e){let t=this._editorService.getEditor(e);return t?t.isReadOnly():!1}_isTraditionalMode(){return this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.TRADITIONAL}};Bg=B([z(1,t.ICommandService),z(2,J),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(t.LocaleService)),z(6,(0,t.Inject)(t.ThemeService))],Bg);function Vg(e,t){let{ed:n}=e,{skeTables:r}=t,i=null;for(let e of r.values())if(e.st===n+1){i=e;break}return i}function Hg(e,t){let{st:n}=e,{skeTables:r}=t,i=null;for(let e of r.values())if(e.ed===n-1){i=e;break}return i}function Ug(e){return e.sections[0].columns[0].lines[0]}function Wg(e){let t=(0,r.getLastColumn)(e);return t.lines[t.lines.length-1]}let Gg=class extends t.Disposable{constructor(e,t,n,r){super(),this._univerInstanceService=e,this._renderManagerService=t,this._textSelectionManagerService=n,this._commandService=r,R(this,`_onInputSubscription`,void 0),this._commandExecutedListener()}dispose(){var e;super.dispose(),(e=this._onInputSubscription)==null||e.unsubscribe()}_commandExecutedListener(){let e=[rs.id,is.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(!e.includes(t.id))return;let n=t.params;switch(t.id){case rs.id:return this._handleMoveCursor(n.direction,n.granularity??`character`);case is.id:return this._handleShiftMoveSelection(n.direction,n.granularity??`character`);default:throw Error(`Unknown command`)}}))}_handleShiftMoveSelection(e,r=`character`){var i;let a=this._textSelectionManagerService.getActiveTextRange(),o=this._textSelectionManagerService.getTextRanges(),s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(s==null)return;let c=this._renderManagerService.getRenderUnitById(s.getUnitId()),l=c==null?void 0:c.with(n.DocSkeletonManagerService).getSkeleton(),u=c?x(c):null;if(a==null||l==null||u==null)return;let{startOffset:d,endOffset:f,style:p,collapsed:m,direction:h,segmentId:g,startNodePosition:_,endNodePosition:v,segmentPage:y}=a,b=g??``,S=y??-1;if(o.length>1){let n=1/0,r=-1/0;for(let e of o)n=Math.min(n,e.startOffset),r=Math.max(r,e.endOffset);this._textSelectionManagerService.replaceDocRanges([{startOffset:e===t.Direction.LEFT||e===t.Direction.UP?r:n,endOffset:e===t.Direction.LEFT||e===t.Direction.UP?n:r,style:p}],void 0,!1);return}let C=m||h===t.RANGE_DIRECTION.FORWARD?d:f,w=m||h===t.RANGE_DIRECTION.FORWARD?f:d,T=(i=s.getSelfOrHeaderFooterModel(b))==null?void 0:i.getBody();if(T==null)return;let E=T.dataStream.length??1/0,D=s.getCustomRanges()??[];if(r!==`character`){let t=this._getCursorOffsetByGranularity(l,w,e,r,b,S,E,T.dataStream);if(t==null||t===w)return;let n=this._normalizeRenderableCursorOffset(l,T.dataStream,D,t,e,b,S);if(n==null||n===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:n,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),n);return}if(e===t.Direction.LEFT||e===t.Direction.RIGHT){let n=l.findNodeByCharIndex(w-1,g,y),r=l.findNodeByCharIndex(w,g,y);w=e===t.Direction.RIGHT?w+((r==null?void 0:r.count)??1):w-((n==null?void 0:n.count)??1),w=this._normalizeCursorOffset(T.dataStream,D,w,e),w=Math.min(E-2,Math.max(0,w));let i=this._normalizeRenderableCursorOffset(l,T.dataStream,D,w,e,b,S);if(i==null)return;w=i,this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:w,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),w)}else{let n=l.findNodeByCharIndex(w,g,y),r=u.document.getOffsetConfig(),i=m?_:h===t.RANGE_DIRECTION.FORWARD?v:_,a=this._getTopOrBottomPosition(l,n,i,e===t.Direction.DOWN,!0);if(a==null){let n=this._normalizeRenderableCursorOffset(l,T.dataStream,D,e===t.Direction.UP?0:E-2,e,b,S);if(n==null||n===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:n,style:p}],void 0,!1);return}let o=new Ze(r,l).getRangePointData(a,a).cursorList[0],c=this._normalizeRenderableCursorOffset(l,T.dataStream,D,o.endOffset,e,b,S);if(c==null||c===w)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:C,endOffset:c,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),c)}}_handleMoveCursor(e,r=`character`){var i;let a=this._textSelectionManagerService.getActiveTextRange(),o=this._textSelectionManagerService.getTextRanges(),s=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(s==null)return!1;let c=this._renderManagerService.getRenderUnitById(s.getUnitId()),l=c==null?void 0:c.with(n.DocSkeletonManagerService).getSkeleton(),u=c?x(c):null;if(a==null||l==null||u==null||o==null)return;let{startOffset:d,endOffset:f,style:p,collapsed:m,segmentId:h,startNodePosition:g,endNodePosition:_,segmentPage:v}=a,y=h??``,b=v??-1,S=(i=s.getSelfOrHeaderFooterModel(y))==null?void 0:i.getBody();if(S==null)return;let C=S.dataStream.length??1/0,w=s.getCustomRanges()??[];if(r!==`character`){let n;if(!a.collapsed||o.length>1){let r=1/0,i=-1/0;for(let e of o)r=Math.min(r,e.startOffset),i=Math.max(i,e.endOffset);n=e===t.Direction.LEFT||e===t.Direction.UP?r:i}else n=e===t.Direction.LEFT||e===t.Direction.UP?d:f;let i=this._getCursorOffsetByGranularity(l,n,e,r,y,b,C,S.dataStream);if(i==null||this._deferUnmaterializedCursorMove(s,l,i,y,()=>this._handleMoveCursor(e,r))||(i=this._normalizeRenderableCursorOffset(l,S.dataStream,w,i,e,y,b),i==null))return;this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:i,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),i);return}if(e===t.Direction.LEFT||e===t.Direction.RIGHT){let n;if(!a.collapsed||o.length>1){let r=1/0,i=-1/0;for(let e of o)r=Math.min(r,e.startOffset),i=Math.max(i,e.endOffset);n=e===t.Direction.LEFT?r:i}else{let r=l.findNodeByCharIndex(d-1,h,v),i=l.findNodeByCharIndex(d,h,v),a=l.findNodeByCharIndex(d+1,h,v);n=e===t.Direction.LEFT?Math.max(0,d-((r==null?void 0:r.count)??1)):Math.min(C-2,f+i.count+ +((a==null?void 0:a.streamType)===t.DataStreamTreeTokenType.SECTION_BREAK))}let r=[...this._getCursorSkipTokens()];if(e===t.Direction.LEFT)for(;r.includes(S.dataStream[n]);)n--;else for(;r.includes(S.dataStream[n]);)n++;n=this._normalizeCursorOffset(S.dataStream,w,n,e);let i=this._normalizeRenderableCursorOffset(l,S.dataStream,w,n,e,y,b);if(i==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:i,endOffset:i,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),i)}else{let n=l.findNodeByCharIndex(d,h,v),r=l.findNodeByCharIndex(f,h,v),i=u.document.getOffsetConfig(),a=this._getTopOrBottomPosition(l,e===t.Direction.UP||m?n:r,e===t.Direction.UP||m?g:_,e===t.Direction.DOWN);if(a==null){let n;if(n=m?this._normalizeRenderableCursorOffset(l,S.dataStream,w,e===t.Direction.UP?0:C-2,e,y,b):this._normalizeRenderableCursorOffset(l,S.dataStream,w,e===t.Direction.UP?d:f,e,y,b),n==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:n,endOffset:n,style:p}],void 0,!1);return}let o=new Ze(i,l).getRangePointData(a,a).cursorList[0],c=this._normalizeRenderableCursorOffset(l,S.dataStream,w,o.endOffset,e,y,b);if(c==null)return;this._textSelectionManagerService.replaceDocRanges([{startOffset:c,endOffset:c,style:p}],void 0,!1),this._scrollToFocusNodePosition(s.getUnitId(),c)}}_deferUnmaterializedCursorMove(e,n,r,i,a){var o,s,c;if(i!==``)return!1;let l=n.findBodyPageIndexByCharIndex(r),u=(o=n.getSkeletonData())==null?void 0:o.pages[l];if(l>=0&&!(u!=null&&u.isMaterializationPlaceholder))return!1;let d=this._renderManagerService.getRenderUnitById(e.getUnitId());if(!(d!=null&&(s=d.getInjector)!=null&&s.call(d).has(ds)))return!1;let f=this._textSelectionManagerService.getActiveTextRange(),p=(c=e.getBody())==null?void 0:c.dataStream;return d.with(ds).scrollToRange({startOffset:r,endOffset:r,collapsed:!0},()=>{var n,r;let i=this._textSelectionManagerService.getActiveTextRange();((n=e.getBody())==null?void 0:n.dataStream)===p&&(i==null?void 0:i.startOffset)===(f==null?void 0:f.startOffset)&&(i==null?void 0:i.endOffset)===(f==null?void 0:f.endOffset)&&(i==null?void 0:i.segmentId)===(f==null?void 0:f.segmentId)&&((r=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC))==null?void 0:r.getUnitId())===e.getUnitId()&&a()}),!0}_getCursorOffsetByGranularity(e,n,r,i,a,o,s,c=``){switch(i){case`document`:return r===t.Direction.LEFT||r===t.Direction.UP?0:s-2;case`paragraph`:return this._getParagraphBoundaryOffset(c,n,r);case`line`:return this._getLineBoundaryOffset(e,n,r,a,o,s);case`word`:return this._getWordBoundaryOffset(e,n,r,a,o,s);default:return null}}_getParagraphBoundaryOffset(e,n,r){if(r!==t.Direction.UP&&r!==t.Direction.DOWN)return;if(e.length===0)return 0;let i=Math.min(Math.max(0,n),e.length-1);if(r===t.Direction.UP){let t=this._getCurrentParagraphStartOffset(e,i);return i>t?t:this._getCurrentParagraphStartOffset(e,Math.max(0,t-1))}let a=e.indexOf(t.DataStreamTreeTokenType.PARAGRAPH,i);return a===-1?e.length-1:a+1}_getCurrentParagraphStartOffset(e,n){for(let r=Math.min(n-1,e.length-1);r>=0;r--){let n=e[r];if(n===t.DataStreamTreeTokenType.PARAGRAPH||n===t.DataStreamTreeTokenType.SECTION_BREAK)return r+1}return 0}_getWordBoundaryOffset(e,n,r,i,a,o){if(r!==t.Direction.LEFT&&r!==t.Direction.RIGHT)return;let s=e.findNodeByCharIndex(n,i,a)??e.findNodeByCharIndex(Math.max(0,n-1),i,a);if(s==null)return r===t.Direction.LEFT?0:o-2;let c=Rt(s);if(c==null)return;let l=Math.min(Math.max(0,n-c.st),c.content.length),u=Ut(c.content,l,c.st,r);if(u!=null)return Math.min(o-2,Math.max(0,u))}_getLineBoundaryOffset(e,n,r,i,a,o){var s;if(r!==t.Direction.LEFT&&r!==t.Direction.RIGHT)return;let c=e.findNodeByCharIndex(n,i,a)??e.findNodeByCharIndex(Math.max(0,n-1),i,a),l=c==null||(s=c.parent)==null?void 0:s.parent;if(l==null)return r===t.Direction.LEFT?0:o-2;let u=r===t.Direction.LEFT?this._getFirstCursorGlyphInLine(l):this._getLastCursorGlyphInLine(l),d=u==null?void 0:e.findPositionByGlyph(u,a);if(d==null)return r===t.Direction.LEFT?0:o-2;let f=e.findCharIndexByPosition({...d,isBack:r===t.Direction.LEFT});if(f!=null)return Math.min(o-2,Math.max(0,f))}_getFirstCursorGlyphInLine(e){for(let t of e.divides)for(let e of t.glyphGroup)if(this._isCursorAddressableGlyph(e))return e}_getLastCursorGlyphInLine(e){for(let t=e.divides.length-1;t>=0;t--){let n=e.divides[t];for(let e=n.glyphGroup.length-1;e>=0;e--){let t=n.glyphGroup[e];if(this._isCursorAddressableGlyph(t))return t}}}_isCursorAddressableGlyph(e){return e.count>0&&!this._getCursorSkipTokens(!0).includes(e.streamType)}_normalizeCursorOffset(e,n,r,i){r=Math.max(0,r);let a=this._getCursorSkipTokens();if(i===t.Direction.LEFT||i===t.Direction.UP)for(;r>0&&a.includes(e[r]);)r--;else for(;r<e.length-1&&a.includes(e[r]);)r++;return this._normalizeWholeEntityRanges(n,r,i)}_normalizeRenderableCursorOffset(e,n,r,i,a,o,s){let c=Math.min(Math.max(0,i),Math.max(0,n.length-1)),l=this._findNearestRenderableCursorOffset(e,n,r,c,a,o,s);if(l!=null)return l;let u=a===t.Direction.LEFT||a===t.Direction.UP?t.Direction.DOWN:t.Direction.UP;return this._findNearestRenderableCursorOffset(e,n,r,c,u,o,s)}_findNearestRenderableCursorOffset(e,n,r,i,a,o,s){let c=a===t.Direction.LEFT||a===t.Direction.UP?-1:1,l=Math.min(Math.max(0,i),Math.max(0,n.length-1)),u=new Set;for(;l>=0&&l<n.length&&!u.has(l);){u.add(l);let t=this._normalizeCursorOffset(n,r,l,a);if(t<0||t>=n.length)return;if(this._isRenderableCursorOffset(e,n,t,o,s))return t;l=t+c}}_isRenderableCursorOffset(e,t,n,r,i){return n<0||n>=t.length||this._getNonRenderableCursorTokens().includes(t[n])?!1:e.findNodePositionByCharIndex(n,!0,r,i)!=null}_normalizeWholeEntityRanges(e,n,r){return e.filter(e=>e.wholeEntity&&e.startIndex<n&&e.endIndex>=n).forEach(e=>{n=r===t.Direction.LEFT||r===t.Direction.UP?Math.min(e.startIndex,n):Math.max(e.endIndex+1,n)}),n}_getCursorSkipTokens(e=!1){let n=[t.DataStreamTreeTokenType.TABLE_START,t.DataStreamTreeTokenType.TABLE_END,t.DataStreamTreeTokenType.TABLE_ROW_START,t.DataStreamTreeTokenType.TABLE_ROW_END,t.DataStreamTreeTokenType.TABLE_CELL_START,t.DataStreamTreeTokenType.TABLE_CELL_END,t.DataStreamTreeTokenType.SECTION_BREAK,t.DataStreamTreeTokenType.BLOCK_START,t.DataStreamTreeTokenType.BLOCK_END,t.DataStreamTreeTokenType.CUSTOM_RANGE_START,t.DataStreamTreeTokenType.CUSTOM_RANGE_END];return e&&n.push(t.DataStreamTreeTokenType.PARAGRAPH),n}_getNonRenderableCursorTokens(){return[...this._getCursorSkipTokens(),t.DataStreamTreeTokenType.COLUMN_GROUP_START,t.DataStreamTreeTokenType.COLUMN_GROUP_END,t.DataStreamTreeTokenType.COLUMN_START,t.DataStreamTreeTokenType.COLUMN_END]}_getTopOrBottomPosition(e,t,n,r,i=!1){if(t==null||n==null)return;let a=this._getGlyphLeftOffsetInLine(t),o=this._getNextOrPrevLineTarget(t,r,a,i);if(o==null)return;let s=this._matchPositionByLeftOffset(e,o.line,o.offsetLeft,n);if(s!=null)return{...s,isBack:!0}}_getGlyphLeftOffsetInLine(e){let t=e.parent;if(t==null)return-1/0;let n=t.left,{left:r}=e;return n+r}_matchPositionByLeftOffset(e,n,r,i){let a={distance:1/0},o={distance:1/0};for(let e of n.divides){let n=e.left;for(let i of e.glyphGroup){if(!this._isCursorAddressableGlyph(i)){if(i.streamType===t.DataStreamTreeTokenType.PARAGRAPH&&i.count>0){let{left:e}=i,t=n+e,a=Math.abs(r-t);a<o.distance&&(o.glyph=i,o.distance=a)}continue}let{left:e}=i,s=n+e,c=Math.abs(r-s);c<a.distance&&(a.glyph=i,a.distance=c)}}let s=a.glyph??o.glyph;if(s==null)return;let{segmentPage:c}=i;return e.findPositionByGlyph(s,c)}_getNextOrPrevLineTarget(e,t,n,r=!1){let i=e.parent,a=i==null?void 0:i.parent,o=a==null?void 0:a.parent,s=o==null?void 0:o.parent,c=s==null?void 0:s.parent;if(i==null||a==null||o==null||s==null||c==null)return;let l=o.lines.indexOf(a);if(l===-1)return;let u;if(this._isTableCellContentPage(c)&&r){let e=this._getAdjacentTableCellLineTarget(c,t,n);if(e!=null)return e}if(t===!0){u=o.lines[l+1];let e=this._getTableLineTargetFromPageLine(a,c,t,n);if(e!=null)return e}else{u=o.lines[l-1];let e=this._getTableLineTargetFromPageLine(a,c,t,n);if(e!=null)return e}let d=this._getColumnGroupLineTargetFromBlockLine(u,c,t,n);if(d!=null)return d;if(u!=null)return{line:u,offsetLeft:n};let f=s.columns.indexOf(o);if(f===-1)return;if(t===!0){var p;u=(p=s.columns[f+1])==null?void 0:p.lines[0]}else{var m;let e=(m=s.columns)==null||(m=m[f-1])==null?void 0:m.lines;u=e==null?void 0:e[e.length-1]}if(u!=null)return{line:u,offsetLeft:n};let h=c.sections.indexOf(s);if(h===-1)return;if(t===!0){var g;u=(g=c.sections[h-1])==null||(g=g.columns[0])==null?void 0:g.lines[0]}else{var _;let e=(_=c.sections)==null||(_=_[h-1])==null?void 0:_.columns,t=e==null?void 0:e[e.length-1],n=t==null?void 0:t.lines;u=n==null?void 0:n[n.length-1]}if(u!=null)return{line:u,offsetLeft:n};if(this._isColumnGroupContentPage(c))return this._getColumnGroupExitLineTarget(c,t,n);if(this._isTableCellContentPage(c))return this._getAdjacentTableCellLineTarget(c,t,n);let v=c.parent;if((v==null?void 0:v.pages)==null)return;let y=v.pages.indexOf(c);if(y!==-1){if(t===!0){var b;u=(b=v.pages[y+1])==null||(b=b.sections[0])==null||(b=b.columns[0])==null?void 0:b.lines[0]}else{var x,S;let e=(x=v.pages[y-1])==null?void 0:x.sections;if(e==null)return;let t=(S=e[e.length-1])==null?void 0:S.columns,n=t[t.length-1],r=n==null?void 0:n.lines;u=r[r.length-1]}if(u!=null)return{line:u,offsetLeft:n}}}_getTableLineTargetFromPageLine(e,t,n,r){let i=n?Vg(e,t):Hg(e,t);if(i!=null)return this._getTableBoundaryLineTarget(i,n,r)}_getTableBoundaryLineTarget(e,t,n){let r=t?e.rows:[...e.rows].reverse();for(let e of r){if(e.isRepeatRow)continue;let r=this._getNearestTableCellLineTarget(e.cells,t,n);if(r!=null)return r}}_getAdjacentTableCellLineTarget(e,t,n){let r=e.parent,i=r==null?void 0:r.parent;if(r==null||i==null)return;let a=this._getTableCellHostOffsetLeft(e)+n,o=this._findAdjacentTableRow(i,r,t);if(o!=null)return this._getNearestTableCellLineTarget(o.cells,t,a);let s=this._findLineAroundTable(i,t);if(s!=null)return{line:s,offsetLeft:a}}_findAdjacentTableRow(e,t,n){let r=e.rows.indexOf(t);if(r===-1)return;let i=n?1:-1,a=r+i;for(;a>=0&&a<e.rows.length;){let t=e.rows[a];if(!t.isRepeatRow)return t;a+=i}return this._findAdjacentTableSliceRow(e,n)}_findAdjacentTableSliceRow(e,t){if(!e.tableId.includes(`#-#`))return;let[n,r]=e.tableId.split(`#-#`),i=Number.parseInt(r),a=e.parent,o=a==null?void 0:a.parent;if(!Number.isFinite(i)||(o==null?void 0:o.pages)==null)return;let s=`${n}#-#${i+(t?1:-1)}`;for(let e of o.pages){var c;let n=(c=e.skeTables)==null?void 0:c.get(s),r=(n==null?[]:t?n.rows:[...n.rows].reverse()).find(e=>!e.isRepeatRow);if(r!=null)return r}}_getNearestTableCellLineTarget(e,t,n){let r=e.filter(e=>!e.isMergedCellCovered).map(e=>({cell:e,distance:this._getDistanceToTableCell(e,n)})).sort((e,t)=>e.distance-t.distance);for(let e of r){let r=t?Ug(e.cell):Wg(e.cell);if(r!=null)return{line:r,offsetLeft:n-this._getTableCellHostOffsetLeft(e.cell)}}}_findLineAroundTable(e,t){var n;let r=e.parent;if(r==null)return;let i=((n=r.parent)==null?void 0:n.pages)??[r],a=t?t=>t.st===e.ed+1:t=>t.ed===e.st-1;for(let e of i)for(let n of e.sections)for(let e of n.columns){let n=(t?e.lines:[...e.lines].reverse()).find(a);if(n!=null)return n}}_getDistanceToTableCell(e,t){let n=this._getTableCellHostOffsetLeft(e),r=n+this._getTableCellContentWidth(e);return t>=n&&t<=r?0:Math.min(Math.abs(t-n),Math.abs(t-r))}_getTableCellHostOffsetLeft(e){let t=e.parent,n=t==null?void 0:t.parent;return((n==null?void 0:n.left)??0)+(e.left??0)+(e.marginLeft??0)}_getTableCellContentWidth(e){return Math.max(0,(e.pageWidth??0)-(e.marginLeft??0)-(e.marginRight??0))}_isTableCellContentPage(e){var t;let n=e.parent,i=n==null?void 0:n.parent;return e.type===r.DocumentSkeletonPageType.CELL&&n!=null&&(i==null||(t=i.rows)==null?void 0:t.includes(n))===!0&&n.cells.includes(e)}_getColumnGroupLineTargetFromBlockLine(e,t,n,i){if(e==null||e.type!==r.LineType.BLOCK)return;let a=this._findColumnGroupByBlockLine(t,e);if(a!=null)return this._getColumnGroupContentLineTarget(a,n,i)}_getColumnGroupContentLineTarget(e,t,n){let r=e.columns.map(e=>({column:e,distance:this._getDistanceToColumnGroupColumn(e,n)})).sort((e,t)=>e.distance-t.distance);for(let e of r){let r=this._getColumnGroupColumnBoundaryLine(e.column,t);if(r!=null)return{line:r,offsetLeft:n-e.column.left}}}_getColumnGroupExitLineTarget(e,t,n){let r=e.parent,i=r==null?void 0:r.parent,a=i==null?void 0:i.parent;if(r==null||i==null||a==null)return;let o=this._findColumnGroupBlockLine(i),s=o==null?void 0:this._getAdjacentLineAroundBlockLine(o,t);if(s!=null)return{line:s,offsetLeft:r.left+n}}_findColumnGroupByBlockLine(e,t){var n;for(let r of((n=e.skeColumnGroups)==null?void 0:n.values())??[])if(t.paragraphIndex===r.ed||t.st<=r.ed&&t.ed>=r.st)return r}_findColumnGroupBlockLine(e){let t=e.parent;if(t!=null){for(let n of t.sections)for(let i of n.columns)for(let n of i.lines)if(n.type===r.LineType.BLOCK&&this._findColumnGroupByBlockLine(t,n)===e)return n}}_getAdjacentLineAroundBlockLine(e,t){var n;let r=e.parent,i=r==null?void 0:r.parent,a=i==null?void 0:i.parent;if(r==null||i==null||a==null)return;let o=r.lines.indexOf(e);if(o===-1)return;let s=r.lines[t?o+1:o-1];if(s!=null)return s;let c=i.columns.indexOf(r);if(c===-1)return;if(t){var l;return(l=i.columns[c+1])==null?void 0:l.lines[0]}let u=(n=i.columns[c-1])==null?void 0:n.lines;return u==null?void 0:u[u.length-1]}_getColumnGroupColumnBoundaryLine(e,t){let n=t?e.page.sections:[...e.page.sections].reverse();for(let e of n){let n=t?e.columns:[...e.columns].reverse();for(let e of n){let n=(t?e.lines:[...e.lines].reverse()).find(e=>e.type!==r.LineType.BLOCK);if(n!=null)return n}}}_getDistanceToColumnGroupColumn(e,t){return t>=e.left&&t<=e.left+e.width?0:Math.min(Math.abs(t-e.left),Math.abs(t-e.left-e.width))}_isColumnGroupContentPage(e){var t;let n=e.parent;return(n==null?void 0:n.page)===e&&((t=n.parent)==null||(t=t.columns)==null?void 0:t.includes(n))===!0}_scrollToFocusNodePosition(e,t){var n;let r=(n=this._renderManagerService.getRenderUnitById(e))==null?void 0:n.with(ds);r!=null&&r.scrollToRange({startOffset:t,endOffset:t,collapsed:!0})}};Gg=B([z(0,t.IUniverInstanceService),z(1,r.IRenderManagerService),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,t.ICommandService)],Gg);let Kg=class extends t.Disposable{constructor(e){super(),this._commandService=e,this._initialize()}_initialize(){this._init(),this._registerCommands()}_registerCommands(){[ns].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}_init(){}};Kg=B([z(0,t.ICommandService)],Kg);let qg=`DOC_LAYOUT_RECOVERY_COMPONENT`;function Jg(){let e=(0,a.useDependency)(t.LocaleService);return(0,u.jsxs)(`div`,{"aria-live":`polite`,className:`univer-flex univer-items-center univer-gap-2 univer-rounded-lg univer-bg-white univer-px-4 univer-py-3 univer-text-sm univer-text-gray-700 univer-shadow-lg dark:univer-bg-gray-800 dark:univer-text-gray-200`,role:`status`,children:[(0,u.jsx)(rh,{"aria-hidden":!0,className:`univer-size-5 univer-animate-spin univer-text-violet-500`}),(0,u.jsx)(`span`,{children:e.t(`docs-ui.layout.recovering`)})]})}let Yg=`docs-ui.paste-options`;function Xg(){let e=(0,a.useDependency)(ea),n=(0,a.useDependency)(t.ICommandService),r=(0,a.useDependency)(t.LocaleService),o=(0,a.useDependency)(a.ILayoutService),s=(0,a.useObservable)(e.pasteOptions$,null),[c,d]=(0,l.useState)(!1),[f,p]=(0,l.useState)(!1),m=async e=>{d(!0);try{await n.executeCommand(fa.id,{value:e})}finally{d(!1),o.focus()}};return s?(0,u.jsx)(i.DropdownMenu,{align:`start`,open:f,onOpenChange:p,onCloseAutoFocus:e=>{e.preventDefault(),o.focus()},onEscapeKeyDown:()=>e.dismissPasteOptions(),items:gi.map(e=>({type:`checkbox`,value:e.value,label:r.t(e.label),checked:s.mode===e.value,disabled:c,onSelect:()=>m(e.value)})),children:(0,u.jsxs)(i.Button,{size:`small`,disabled:c,"aria-label":r.t(`docs-ui.pasteOptions.title`),title:r.t(`docs-ui.pasteOptions.title`),onMouseDown:e=>e.preventDefault(),onKeyDown:t=>{t.key===`Escape`&&(e.dismissPasteOptions(),o.focus())},className:`univer-shadow-sm`,children:[(0,u.jsx)(kp,{className:`!univer-size-5`,"aria-hidden":`true`}),(0,u.jsx)(`svg`,{className:`!univer-size-2`,width:`8`,height:`8`,viewBox:`0 0 8 8`,"aria-hidden":`true`,children:(0,u.jsx)(`path`,{d:`m1 2 3 4 3-4Z`,fill:`currentColor`})})]})}):null}function Zg({className:e,style:t,onClick:n,color:r}){return(0,u.jsx)(`svg`,{className:e,style:t,viewBox:`0 0 24 24`,width:`1em`,height:`1em`,fill:`none`,"aria-hidden":`true`,onClick:n,children:(0,u.jsx)(`rect`,{x:3,y:3,width:18,height:18,rx:3,fill:r,stroke:`currentColor`,strokeOpacity:.12})})}function Qg({className:e,style:t,onClick:n,extend:r}){let i=(r==null?void 0:r.colorChannel1)??`currentColor`;return(0,u.jsx)(Nh,{className:e,style:t,onClick:n,extend:{colorChannel1:i},"aria-hidden":`true`})}function $g({className:e,style:t,onClick:n}){return(0,u.jsx)(Nh,{className:e,style:t,onClick:n,extend:{colorChannel1:`#000000`},"aria-hidden":`true`})}function e_(e){return function(t){return(0,u.jsx)(Nh,{...t,extend:{colorChannel1:e},"aria-hidden":`true`})}}function t_(e){return function(n){let r=(0,a.useDependency)(t.ThemeService),i=(0,a.useObservable)(()=>r.currentTheme$.pipe((0,s.map)(()=>Cd(r,e))),Cd(r,e),!1,[e,r]);return(0,u.jsx)(Zg,{...n,color:i})}}let n_=e_(`#FE4B4B`),r_=e_(`#FF8C51`),i_=e_(`#A4DC16`),a_=e_(`#2DAEFF`),o_=e_(`#3A60F7`),s_=e_(`#9E6DE3`),c_=e_(`#F248A6`),l_=t_(0),u_=t_(1),d_=t_(2),f_=t_(3),p_=t_(4),m_=t_(5),h_=t_(6),g_=t_(7),__=t_(8),v_=t_(9),y_=t_(10),b_=t_(11),x_=t_(12),S_=t_(13),C_=t_(14),w_=t_(15),T_=`docs-ui.mobile-element-menu`,E_=[{key:`edit`,order:0,item:{id:`edit`,type:a.MenuItemType.BUTTON,title:`docs-ui.mobile.edit`}},{key:`delete`,order:1,item:{id:`delete`,type:a.MenuItemType.BUTTON,title:`docs-ui.rightClick.delete`}}];function D_(e){return(0,u.jsx)(a.MobileMenu,{schemas:E_,presentation:`context-bar`,onOptionSelect:async({id:t})=>{t===`edit`?await e.onEdit():t===`delete`&&await e.onDelete()}})}function O_({popup:e}){return(0,u.jsx)(D_,{...e.extraProps})}function k_({popup:e}){var n;let{unitId:o}=e.extraProps,s=(0,a.useDependency)(ea),c=(0,a.useDependency)(t.ICommandService),d=(0,a.useDependency)(t.LocaleService),f=(n=(0,a.useDependency)(r.IRenderManagerService).getRenderUnitById(o))==null?void 0:n.with(q),p=(0,a.useObservable)(s.pasteOptions$,null),m=(0,a.useObservable)(f==null?void 0:f.mobileKeyboardState$,{visible:!1,inset:0});(0,a.useObservable)(d.currentLocale$);let[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(`compact`),x=async e=>{v(!0);try{await c.executeCommand(fa.id,{value:e}),g(!1)}finally{v(!1)}};return!p||p.unitId!==o?null:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(i.Button,{"aria-label":d.t(`docs-ui.pasteOptions.title`),className:`univer-min-h-11 univer-min-w-11 univer-shadow-sm [&_svg]:!univer-size-6`,style:m.visible?{position:`fixed`,bottom:m.inset+56,insetInlineEnd:12}:void 0,onClick:()=>{f==null||f.suspendMobileEditingInput(),g(!0)},children:(0,u.jsx)(kp,{"aria-hidden":`true`})}),h&&(0,u.jsx)(`div`,{className:`univer-pointer-events-none univer-fixed univer-inset-x-0 univer-top-0`,style:{bottom:m.inset},children:(0,u.jsx)(a.MobileDrawer,{componentName:`mobile-doc-paste-options`,panelClassName:`univer-max-h-full`,snap:y,onSnapChange:b,onClose:()=>g(!1),expandLabel:d.t(`docs-ui.mobile.expand`),collapseLabel:d.t(`docs-ui.mobile.collapse`),ariaLabel:d.t(`docs-ui.pasteOptions.title`),header:(0,u.jsxs)(`div`,{className:`univer-flex univer-w-full univer-items-center univer-justify-between univer-gap-2 univer-px-4`,children:[(0,u.jsx)(`span`,{children:d.t(`docs-ui.pasteOptions.title`)}),(0,u.jsx)(i.Button,{variant:`text`,className:`univer-min-h-11`,onClick:()=>g(!1),children:d.t(`docs-ui.mobile.done`)})]}),children:(0,u.jsx)(`div`,{role:`menu`,"aria-label":d.t(`docs-ui.pasteOptions.title`),className:`univer-flex univer-flex-col univer-gap-1 univer-p-3`,children:gi.map(e=>(0,u.jsxs)(i.Button,{role:`menuitemradio`,"aria-checked":p.mode===e.value,disabled:_,variant:`text`,className:`!univer-h-auto univer-min-h-11 univer-justify-start univer-whitespace-normal univer-py-3 univer-text-start`,onClick:()=>x(e.value),children:[(0,u.jsx)(`span`,{className:`univer-inline-flex univer-size-5 univer-shrink-0 univer-items-center`,children:p.mode===e.value&&(0,u.jsx)(yp,{})}),d.t(e.label)]},e.value))})})})]})}function A_(e,n,i,a){let{useFirstPageHeaderFooter:o,evenAndOddHeaders:s,defaultHeaderId:c,defaultFooterId:l,firstPageHeaderId:u,firstPageFooterId:d,evenPageHeaderId:f,evenPageFooterId:p}=e,m=a?a.pageNumber===a.pageNumberStart:i===0,h=a?a.pageNumber%2==0:i%2==1;return n===r.DocumentEditArea.HEADER?o===t.BooleanNumber.TRUE&&m?u:s===t.BooleanNumber.TRUE&&h?f:c:o===t.BooleanNumber.TRUE&&m?d:s===t.BooleanNumber.TRUE&&h?p:l}function j_(e){var i,o;let s=(0,a.useDependency)(t.IUniverInstanceService),c=(0,a.useDependency)(r.IRenderManagerService),u=(0,a.useDependency)(t.ICommandService),d=(0,a.useDependency)(a.ILayoutService),f=c.getRenderUnitById(e).with(q),p=s.getUnit(e,t.UniverInstanceType.UNIVER_DOC),m=()=>{var t,r;let i=p==null?void 0:p.getSnapshot(),a=(t=c.getRenderUnitById(e))==null?void 0:t.with(n.DocSkeletonManagerService),o=a==null||(r=a.getSkeleton)==null||(r=r.call(a))==null||(r=r.getSkeletonData())==null?void 0:r.pages[f.getSegmentPage()];return i==null?void 0:{...Ec(i,o),page:o}},[h,g]=(0,l.useState)(()=>{var e;let n=(e=m())==null?void 0:e.config;return{marginHeader:(n==null?void 0:n.marginHeader)??0,marginFooter:(n==null?void 0:n.marginFooter)??0,useFirstPageHeaderFooter:(n==null?void 0:n.useFirstPageHeaderFooter)??t.BooleanNumber.FALSE,evenAndOddHeaders:(n==null?void 0:n.evenAndOddHeaders)??t.BooleanNumber.FALSE}}),_=m(),v=((i=c.getRenderUnitById(e))==null||(i=i.with(n.DocSkeletonManagerService))==null||(i=i.getViewModel())==null?void 0:i.getEditArea())===r.DocumentEditArea.FOOTER?`footer`:`header`,y=M_((_==null?void 0:_.config)??{},f.getSegmentPage(),_==null?void 0:_.page),b=(0,t.getSectionHeaderFooterReferenceKey)(v,y),x=((_==null?void 0:_.sectionIndex)??-1)>0,[S,C]=(0,l.useState)(x&&!(_!=null&&(o=_.section)!=null&&o[b]));return{canLinkToPrevious:x,linkedToPrevious:S,options:h,handleLinkToPreviousChange:async i=>{var a;let o=m();if(!(o!=null&&o.sectionId)||o.sectionIndex<=0||!p)return;let s=((a=c.getRenderUnitById(e))==null||(a=a.with(n.DocSkeletonManagerService))==null||(a=a.getViewModel())==null?void 0:a.getEditArea())===r.DocumentEditArea.FOOTER?`footer`:`header`,l=M_(o.config,f.getSegmentPage(),o.page),h=(0,t.getSectionHeaderFooterReferenceKey)(s,l),g=(0,t.generateRandomId)(6),_=(0,t.resolveSectionHeaderFooterReference)(p.getDocumentStyle(),o.sections,o.sectionIndex-1,h).segmentId;await u.executeCommand(n.SetSectionHeaderFooterLinkCommand.id,{unitId:e,sectionId:o.sectionId,kind:s,variant:l,linkedToPrevious:i,...i?{}:{segmentId:g}})&&(C(i),f.setSegment(i?_??``:g),d.focus())},handleCheckboxChange:(i,a)=>{var o;g(e=>({...e,[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE}));let s=m(),l=s==null?void 0:s.config,p=(o=c.getRenderUnitById(e))==null?void 0:o.with(n.DocSkeletonManagerService),h=p==null?void 0:p.getViewModel();if(l==null||h==null)return;let _=h.getEditArea(),v=!1,y=f.getSegmentPage(),b=s!=null&&s.page?s.page.pageNumber===s.page.pageNumberStart:y===0,x=s!=null&&s.page?s.page.pageNumber%2==0:y%2==1,S=!1;if(a===`useFirstPageHeaderFooter`&&i===!0&&((_===r.DocumentEditArea.HEADER&&!l.firstPageHeaderId||_===r.DocumentEditArea.FOOTER&&!l.firstPageFooterId)&&(v=!0),v&&b&&(S=!0)),a===`evenAndOddHeaders`&&i===!0&&((_===r.DocumentEditArea.HEADER&&!l.evenPageHeaderId||_===r.DocumentEditArea.FOOTER&&!l.evenPageFooterId)&&(v=!0),v&&x&&(S=!0)),v){let n=(0,t.generateRandomId)(6);S&&f.setSegment(n),u.executeCommand(Ac,{unitId:e,segmentId:n,headerFooterProps:{[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},sectionId:s==null?void 0:s.sectionId})}else{let n=f.getSegmentPage(),r=f.getSegment(),o=A_({...l,[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},_,n,s==null?void 0:s.page);o&&o!==r&&f.setSegment(o),u.executeCommand(Ac,{unitId:e,headerFooterProps:{[a]:i?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE},sectionId:s==null?void 0:s.sectionId})}d.focus()},handleMarginChange:async(t,n)=>{var r;g(e=>({...e,[n]:t})),await u.executeCommand(Ac,{unitId:e,headerFooterProps:{[n]:t},sectionId:(r=m())==null?void 0:r.sectionId}),f.removeAllRanges(),f.blur()},closeHeaderFooter:()=>{u.executeCommand(Nc.id,{unitId:e})}}}function M_(e,n,r){let i=r?r.pageNumber===r.pageNumberStart:n===0,a=r?r.pageNumber%2==0:n%2==1;return e.useFirstPageHeaderFooter===t.BooleanNumber.TRUE&&i?`first`:e.evenAndOddHeaders===t.BooleanNumber.TRUE&&a?`even`:`default`}let N_=e=>{let t=(0,a.useDependency)(r.IRenderManagerService).getRenderUnitById(e.unitId).with(q),n=(0,a.useObservable)(t.segmentContext$,{segmentId:t.getSegment(),segmentPage:t.getSegmentPage()}),i=e.ContentComponent??P_;return(0,u.jsx)(i,{...e},`${(n==null?void 0:n.segmentId)??``}:${(n==null?void 0:n.segmentPage)??-1}`)};function P_({unitId:e}){let n=(0,a.useDependency)(t.LocaleService),{canLinkToPrevious:r,linkedToPrevious:o,options:s,handleLinkToPreviousChange:c,handleCheckboxChange:l,handleMarginChange:d,closeHeaderFooter:f}=j_(e);return(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-4`,children:[r&&(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:o,onChange:e=>{c(!!e)},children:n.t(`docs-ui.headerFooter.linkToPrevious`)})}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-2`,children:[(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:s.useFirstPageHeaderFooter===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`useFirstPageHeaderFooter`)},children:n.t(`docs-ui.headerFooter.firstPageCheckBox`)})}),(0,u.jsx)(`div`,{children:(0,u.jsx)(i.Checkbox,{checked:s.evenAndOddHeaders===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`evenAndOddHeaders`)},children:n.t(`docs-ui.headerFooter.oddEvenCheckBox`)})})]}),(0,u.jsxs)(`div`,{className:`univer-mb-1 univer-flex`,children:[(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.headerTopMargin`)}),(0,u.jsx)(i.InputNumber,{className:`univer-mt-1.5 univer-w-4/5`,min:0,max:200,precision:1,value:s.marginHeader,onChange:e=>{d(e??0,`marginHeader`)}})]}),(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.footerBottomMargin`)}),(0,u.jsx)(i.InputNumber,{className:`univer-mt-1.5 univer-w-4/5`,min:0,max:200,precision:1,value:s.marginFooter,onChange:e=>{d(e??0,`marginFooter`)}})]})]}),(0,u.jsx)(`div`,{className:`univer-flex univer-justify-end`,children:(0,u.jsx)(i.Button,{onClick:f,children:n.t(`docs-ui.headerFooter.closeHeaderFooter`)})})]})}let F_=e=>{var i;let o=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(r.IRenderManagerService),l=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC).getUnitId(),d=((i=c.getRenderUnitById(l))==null?void 0:i.with(n.DocSkeletonManagerService)).getViewModel(),f=(0,a.useObservable)(()=>d.editAreaChange$.pipe((0,s.filter)(e=>e!=null),(0,s.map)(e=>e!==r.DocumentEditArea.BODY)),d.getEditArea()!==r.DocumentEditArea.BODY,!1,[d]);return(0,u.jsx)(`div`,{className:`univer-text-sm`,children:f?(0,u.jsx)(N_,{...e,unitId:l}):(0,u.jsx)(`div`,{className:`univer-text-gray-400`,children:o.t(`docs-ui.headerFooter.disableText`)})})},I_={min:1,max:5,step:.1},L_={min:1,max:100};function R_(e,t){let n=10**t;return Math.round(e*n)/n}function z_(e,t,n){return Math.min(n,Math.max(t,e))}let B_=[{label:`docs-ui.doc.paragraphSetting.multiSpace`,value:`${t.SpacingRule.AUTO}`},{label:`docs-ui.doc.paragraphSetting.atLeast`,value:`${t.SpacingRule.AT_LEAST}`},{label:`docs-ui.doc.paragraphSetting.exactly`,value:`${t.SpacingRule.EXACT}`}];function V_(e){return e===t.SpacingRule.AUTO?I_:L_}function H_(e,n){return n===t.SpacingRule.AUTO?e:R_(e,2)}function U_(e,n){return n===t.SpacingRule.AUTO?e:R_(e,4)}function W_(e){if(!e)return null;let t=Math.max(0,...(e.divides??[]).flatMap(e=>(e.glyphGroup??[]).map(e=>{var t,n;return(((t=e.bBox)==null?void 0:t.ba)??0)+(((n=e.bBox)==null?void 0:n.bd)??0)})))||e.contentHeight||0;return t?{glyphLineHeight:t,renderedLineHeight:(e.paddingTop??0)+(e.contentHeight??t)+(e.paddingBottom??0)||t}:null}function G_(e,n,r,i){return n===r?e:r===t.SpacingRule.AUTO?i!=null&&i.glyphLineHeight&&i.renderedLineHeight?R_(z_(i.renderedLineHeight/i.glyphLineHeight,I_.min,I_.max),2):t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING:i!=null&&i.renderedLineHeight?R_(i.renderedLineHeight,4):R_(t.DEFAULT_STYLES.fs*e,4)}let K_=new Set([t.DocumentBlockRangeType.CALLOUT,t.DocumentBlockRangeType.CODE,t.DocumentBlockRangeType.QUOTE]);function q_(e,n,r){return e.map(e=>{var i;let a=((i=n.blockRanges)==null?void 0:i.some(t=>K_.has(t.blockType)&&e.startIndex>t.startIndex&&e.startIndex<t.endIndex))??!1;return{...e,paragraphStyle:(0,t.resolveDocumentParagraphStyle)(r,e.paragraphStyle,{excludeDocumentOuterSpacing:a})}})}let J_=()=>{let e=(0,a.useDependency)(n.DocSelectionManagerService),t=(0,a.useDependency)(ul),r=(0,l.useMemo)(()=>e.getDocRanges(),[]);return(0,l.useEffect)(()=>{r.length||t.closePanel()},[r]),r},Y_=()=>{let e=(0,a.useDependency)(t.IUniverInstanceService).getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),n=J_();if(!e||n.length===0)return[];let r=n[0].segmentId,i=e.getSelfOrHeaderFooterModel(r),o=i==null?void 0:i.getBody(),s=(o==null?void 0:o.paragraphs)??[],c=(o==null?void 0:o.dataStream)??``,l=t.BuildTextUtils.range.getParagraphsInRanges(n,s,c)??[];return o==null?l:q_(l,o,e.getDocumentStyle())},X_=(e,n)=>{let r=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let r=e[0];return r?String(((t=r.paragraphStyle)==null?void 0:t.horizontalAlign)??n):n});return[i,e=>(o(e),r.executeCommand(Mg.id,{paragraph:{horizontalAlign:Number(e)}}))]},Z_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentStart,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentStart:{v:e}}}))]},Q_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentEnd,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentEnd:{v:e}}}))]},$_=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.indentFirstLine,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{indentFirstLine:{v:e}}}))]},ev=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var t;let n=e[0];return n?(0,r.getNumberUnitValue)((t=n.paragraphStyle)==null?void 0:t.hanging,0):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{hanging:{v:e}}}))]},tv=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var n;let i=e[0];return i?(0,r.getNumberUnitValue)((n=i.paragraphStyle)==null?void 0:n.spaceAbove,t.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_ABOVE):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{spaceAbove:{v:e}}}))]},nv=e=>{let n=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>{var n;let i=e[0];return i?(0,r.getNumberUnitValue)((n=i.paragraphStyle)==null?void 0:n.spaceBelow,t.DEFAULT_DOCUMENT_PARAGRAPH_SPACE_BELOW):0});return[i,e=>(o(e),n.executeCommand(Mg.id,{paragraph:{spaceBelow:{v:e}}}))]},rv=e=>{let i=(0,a.useDependency)(t.ICommandService),o=(0,a.useDependency)(r.IRenderManagerService),u=(0,a.useDependency)(t.IUniverInstanceService),d=(0,l.useMemo)(()=>{var e;let r=u.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(r)return(e=o.getRenderUnitById(r==null?void 0:r.getUnitId()))==null?void 0:e.with(n.DocSkeletonManagerService).getSkeleton()},[]),f=(0,l.useMemo)(()=>new s.BehaviorSubject({}),[]),[p,m]=(0,l.useState)(()=>{var n;let r=e[0];return r?((n=r.paragraphStyle)==null?void 0:n.spacingRule)??t.SpacingRule.AUTO:t.SpacingRule.AUTO}),[h,g]=(0,l.useState)(()=>{var n,r;let i=e[0];if(!i)return t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING;let a=((n=i.paragraphStyle)==null?void 0:n.spacingRule)??t.SpacingRule.AUTO;return H_(((r=i.paragraphStyle)==null?void 0:r.lineSpacing)??t.DEFAULT_DOCUMENT_PARAGRAPH_LINE_SPACING,a)});return(0,l.useEffect)(()=>{let e=f.pipe((0,c.filter)(e=>!!Object.keys(e).length),(0,c.bufferTime)(16),(0,c.filter)(e=>!!e.length),(0,c.map)(e=>e.reduce((e,t)=>(Object.keys(t).forEach(n=>{e[n]=t[n]}),e),{}))).subscribe(e=>i.executeCommand(Mg.id,{paragraph:{...e}}));return()=>e.unsubscribe()},[]),{lineSpacing:[h,async e=>{g(e),f.next({lineSpacing:U_(e,p),spacingRule:p})}],spacingRule:[p,async t=>{if(t!==p){let n=d==null?void 0:d.findNodeByCharIndex(e[0].startIndex),r=n==null?void 0:n.parent,i=W_(r==null?void 0:r.parent),a=G_(U_(h,p),p,t,i),o=H_(a,t);g(o),m(t),f.next({spacingRule:t,lineSpacing:a})}}]}},iv=[{label:`docs-ui.toolbar.alignLeft`,value:String(t.HorizontalAlign.LEFT),icon:(0,u.jsx)(tm,{})},{label:`docs-ui.toolbar.alignCenter`,value:String(t.HorizontalAlign.CENTER),icon:(0,u.jsx)(Yp,{})},{label:`docs-ui.toolbar.alignRight`,value:String(t.HorizontalAlign.RIGHT),icon:(0,u.jsx)(Cm,{})},{label:`docs-ui.toolbar.alignJustify`,value:String(t.HorizontalAlign.JUSTIFIED),icon:(0,u.jsx)(pp,{})}],av=e=>{let{title:t,children:n,first:r=!1}=e;return(0,u.jsxs)(`section`,{className:(0,i.clsx)(!r&&`univer-mt-5`),children:[(0,u.jsx)(`div`,{className:`univer-text-sm univer-font-medium univer-leading-5`,children:t}),(0,u.jsx)(`div`,{className:`univer-mt-3`,children:n})]})},ov=e=>{let{label:t,unit:n,children:r}=e;return(0,u.jsxs)(`div`,{className:`univer-grid univer-min-h-8 univer-items-center univer-gap-3`,style:{gridTemplateColumns:`minmax(0, 1fr) minmax(160px, 180px)`},children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100`,children:[t,n]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:r})]})},sv=e=>{let{value:t,onChange:n,className:r=``,min:a=0,max:o=100,step:s=.1,precision:c=1}=e,d=(0,l.useRef)(null);return(0,u.jsx)(i.InputNumber,{step:s,precision:c,ref:d,min:a,max:o,value:t,onChange:e=>{n(e??0).finally(()=>{setTimeout(()=>{var e;(e=d.current)==null||e.focus()},30)})},className:(0,i.clsx)(`univer-w-full`,r)})};function cv({label:e,selected:t,onClick:n,children:r}){return(0,u.jsx)(i.Tooltip,{title:e,placement:`bottom`,children:(0,u.jsx)(i.Button,{type:`button`,variant:`text`,"aria-label":e,className:(0,i.clsx)({"!univer-bg-gray-200 dark:!univer-bg-gray-700":t}),onClick:n,children:(0,u.jsx)(`span`,{className:`univer-flex univer-size-5 univer-items-center univer-justify-center univer-text-lg`,children:r})})})}function lv({RowComponent:e=ov,NumberComponent:n=sv,SelectComponent:r=i.Select,AlignmentButtonComponent:o=cv}){let s=(0,a.useDependency)(t.LocaleService),c=Y_(),[d,f]=X_(c,iv[0].value),[p,m]=Z_(c),[h,g]=Q_(c),[_,v]=$_(c),[y,b]=ev(c),[x,S]=tv(c),[C,w]=nv(c),{lineSpacing:[T,E],spacingRule:[D,O]}=rv(c),k=(0,l.useMemo)(()=>V_(D),[D]),A=B_.map(e=>({...e,label:s.t(e.label)}));return(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full`,children:[(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.alignment`),first:!0,children:(0,u.jsx)(`div`,{className:(0,i.clsx)(`univer-flex univer-grid-cols-4 univer-items-center univer-justify-around univer-gap-2 univer-rounded-lg univer-bg-gray-0 univer-p-1 dark:!univer-bg-gray-900`,i.borderClassName),children:iv.map(e=>(0,u.jsx)(`span`,{className:`univer-flex univer-w-full univer-items-center univer-justify-center`,children:(0,u.jsx)(o,{label:s.t(e.label),selected:d===e.value,onClick:()=>f(e.value),children:e.icon})},e.value))})}),(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.indentation`),children:(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.left`),unit:`(px)`,children:(0,u.jsx)(n,{value:p,onChange:e=>m(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.right`),unit:`(px)`,children:(0,u.jsx)(n,{value:h,onChange:e=>g(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.firstLine`),unit:`(px)`,children:(0,u.jsx)(n,{value:_,onChange:e=>v(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.hanging`),unit:`(px)`,children:(0,u.jsx)(n,{value:y,onChange:e=>b(e??0)})})]})}),(0,u.jsx)(av,{title:s.t(`docs-ui.doc.paragraphSetting.spacing`),children:(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.before`),unit:`(px)`,children:(0,u.jsx)(n,{value:x,onChange:e=>S(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.after`),unit:`(px)`,children:(0,u.jsx)(n,{value:C,onChange:e=>w(e??0)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.paragraphSetting.lineSpace`),children:(0,u.jsxs)(`div`,{className:`univer-flex univer-w-full univer-flex-col univer-gap-2`,children:[(0,u.jsx)(r,{className:`univer-w-full`,value:`${D}`,options:A,onChange:e=>O(Number(e))}),(0,u.jsx)(n,{...k,value:T,onChange:e=>E(e??0)})]})})]})})]})}let uv=(e,t)=>t.length===e.length&&e.some(e=>t.some(t=>t.startOffset===e.startOffset&&t.endOffset===e.endOffset));function dv(e){let r=(0,a.useDependency)(t.ICommandService),i=(0,a.useDependency)(t.LocaleService),o=(0,a.useObservable)(i.currentLocale$),[s,c]=(0,l.useState)(``),u=(0,l.useMemo)(()=>(0,t.debounce)(()=>c((0,t.generateRandomId)(4)),300),[]),d=(0,l.useRef)([]);return(0,l.useEffect)(()=>{let e=r.onCommandExecuted(e=>{if(n.SetTextSelectionsOperation.id===e.id){let n=e.params.ranges;uv(n,d.current)||c((0,t.generateRandomId)(4)),d.current=n}n.RichTextEditingMutation.id===e.id&&e.params.trigger!==Mg.id&&u()});return()=>e.dispose()},[u]),(0,l.useEffect)(()=>{c((0,t.generateRandomId)(4))},[o]),(0,l.useEffect)(()=>()=>u.cancel(),[u]),(0,l.createElement)(lv,{...e,key:s})}function fv({unitId:e,id:r,objectType:s,segmentId:c=``}){let l=(0,a.useInjector)(),d=(0,a.useDependency)(t.IUniverInstanceService),f=(0,a.useDependency)(t.ObjectPermissionService),p=(0,a.useDependency)(t.LocaleService);if((0,a.useObservable)(f.changed$,0),(0,a.useObservable)(p.currentLocale$),!e||!r)return null;let m=s===o.UnitObject.DocumentParagraph,h={unitId:e,objectId:m?(0,n.getDocumentParagraphPermissionObjectId)(c,r):(0,n.getDocumentSectionPermissionObjectId)(c,r),objectType:s},g=()=>{var t,n,i;let a=(t=d.getUnit(e))==null||(t=t.getSelfOrHeaderFooterModel(c))==null?void 0:t.getBody();return m?(a==null||(n=a.paragraphs)==null?void 0:n.some(e=>e.paragraphId===r))===!0:(a==null||(i=a.sectionBreaks)==null?void 0:i.some(e=>e.sectionId===r))===!0};return!f.supports(h)||!g()?null:(0,u.jsxs)(`div`,{className:`univer-mt-5`,children:[(0,u.jsx)(i.Separator,{className:`univer-mb-3`}),(0,u.jsx)(i.Button,{disabled:!f.canView(h),type:`button`,variant:`text`,className:`univer-w-full univer-justify-start`,onClick:()=>(0,a.openObjectPermissionDialog)(l,{target:h,name:p.t(m?`docs-ui.objectPermission.paragraph`:`docs-ui.objectPermission.section`),commandId:n.SetDocumentPermissionCommand.id,exists:g}),children:p.t(`docs-ui.objectPermission.title`)})]})}function pv(e){let t=e[0];return e.every(e=>e===t)?t:void 0}function mv(e){var t;return((t=e.columnProperties)==null?void 0:t.length)||1}function hv(e){var t;return((t=e.columnProperties)==null||(t=t[0])==null?void 0:t.paddingEnd)??18}function gv(e,n){return{columnCount:pv(e.map(mv)),columnGap:pv(e.map(hv)),separatorType:pv(e.map(e=>e.columnSeparatorType??t.ColumnSeparatorType.NONE)),sectionType:pv(e.map(e=>e.sectionType??t.SectionType.SECTION_TYPE_UNSPECIFIED)),pageWidth:pv(e.map(e=>{var t,r;return((t=e.pageSize)==null?void 0:t.width)??((r=n.pageSize)==null?void 0:r.width)})),pageHeight:pv(e.map(e=>{var t,r;return((t=e.pageSize)==null?void 0:t.height)??((r=n.pageSize)==null?void 0:r.height)})),pageOrient:pv(e.map(e=>e.pageOrient??n.pageOrient)),marginTop:pv(e.map(e=>e.marginTop??n.marginTop??0)),marginBottom:pv(e.map(e=>e.marginBottom??n.marginBottom??0)),marginLeft:pv(e.map(e=>e.marginLeft??n.marginLeft??0)),marginRight:pv(e.map(e=>e.marginRight??n.marginRight??0)),pageNumberStart:pv(e.map(e=>e.pageNumberStart??n.pageNumberStart??1))}}function _v(e,t,r){return e.map(e=>{let i=`columnCount`in r?r.columnCount:mv(e),a=`columnGap`in r?r.columnGap:hv(e);return{sectionId:e.sectionId,config:{columnProperties:(0,n.createSectionColumnProperties)(t,e,i,a)}}})}function vv(e,n,r){return e.map(e=>{let i=e.pageOrient??n.pageOrient??t.PageOrientType.PORTRAIT,a=e.pageSize??n.pageSize;return{sectionId:e.sectionId,config:{pageOrient:r,...i!==r&&(a==null?void 0:a.width)!=null&&a.height!=null?{pageSize:{width:a.height,height:a.width}}:{}}}})}function yv(e,t){let r=e.getBody();if(!r||t.length===0||t.some(e=>!!e.segmentId))return[];let i=(0,n.getTopLevelSectionBreaks)(r);return i.filter((e,n)=>{let r=n===0?0:i[n-1].startIndex+1;return t.some(t=>{let n=Math.min(t.startOffset,t.endOffset),i=Math.max(t.startOffset,t.endOffset);return n<=e.startIndex&&i>=r})})}function bv(e,t,n,r){let i=n.findIndex(e=>e.sectionId===r);!t||i<0||e.navigateToSectionEnd(t.getUnitId(),i===0?0:n[i-1].startIndex+1,n[i].startIndex)}function xv(){let e=(0,a.useDependency)(t.ICommandService),r=(0,a.useDependency)(t.IUniverInstanceService),i=(0,a.useDependency)(n.DocSelectionManagerService),o=(0,a.useDependency)(pl),c=(0,a.useObservable)((0,l.useMemo)(()=>r.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),[r])),u=()=>(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL?yv(c,i.getDocRanges()):[],d=(0,a.useObservable)(c?()=>(0,s.combineLatest)([i.textSelection$.pipe((0,s.startWith)(void 0)),c.change$.pipe((0,s.startWith)(void 0))]).pipe((0,s.map)(u)):null,u(),!1,[c,i]),f=(c==null?void 0:c.getDocumentStyle())??{},p=gv(d,f),m=c==null?void 0:c.getBody(),h=(c==null?void 0:c.getDocumentStyle().documentFlavor)===t.DocumentFlavor.TRADITIONAL&&m?(0,n.getTopLevelSectionBreaks)(m):[],g=t=>!c||t.length===0?Promise.resolve(!1):e.executeCommand(n.UpdateDocumentSectionCommand.id,{unitId:c.getUnitId(),updates:t}),_=e=>g(d.map(t=>({sectionId:t.sectionId,config:e})));return{unitId:c==null?void 0:c.getUnitId(),valid:!!(c&&d.length>0),selectedCount:d.length,sectionOptions:h.map((e,t)=>({label:`#${t+1}`,value:e.sectionId})),selectedSectionId:d.length===1?d[0].sectionId:void 0,...p,selectSection(e){bv(o,c??void 0,h,e)},setColumnCount(e){let t=Math.max(1,Math.round(e));return g(c?_v(d,c.getDocumentStyle(),{columnCount:t}):[])},setColumnGap(e){let t=Math.max(0,e);return g(c?_v(d,c.getDocumentStyle(),{columnGap:t}):[])},setSeparatorType(e){return _({columnSeparatorType:e})},setSectionType(e){return _({sectionType:e})},setPageWidth(e){return g(d.map(t=>({sectionId:t.sectionId,config:{pageSize:{...f.pageSize,...t.pageSize,width:Math.max(1,e)}}})))},setPageHeight(e){return g(d.map(t=>({sectionId:t.sectionId,config:{pageSize:{...f.pageSize,...t.pageSize,height:Math.max(1,e)}}})))},setPageOrient(e){return g(vv(d,f,e))},setMarginTop(e){return _({marginTop:Math.max(0,e)})},setMarginBottom(e){return _({marginBottom:Math.max(0,e)})},setMarginLeft(e){return _({marginLeft:Math.max(0,e)})},setMarginRight(e){return _({marginRight:Math.max(0,e)})},setPageNumberStart(e){return _({pageNumberStart:Math.max(1,Math.round(e))})}}}function Sv(e){return(0,u.jsxs)(`div`,{className:`univer-grid univer-min-h-8 univer-items-center univer-gap-3`,style:{gridTemplateColumns:`minmax(0, 1fr) minmax(140px, 160px)`},children:[(0,u.jsxs)(`div`,{className:`univer-min-w-0 univer-text-xs univer-leading-5 univer-text-gray-900 dark:!univer-text-gray-100`,children:[e.label,e.unit]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:e.children})]})}function Cv({RowComponent:e=Sv,InputNumberComponent:n=i.InputNumber,SelectComponent:r=i.Select}){let s=(0,a.useDependency)(t.LocaleService),c=(0,a.useDependency)(pl),d=xv();return(0,a.useObservable)(s.currentLocale$),(0,l.useEffect)(()=>{d.valid||c.closePanel()},[c,d.valid]),d.valid?(0,u.jsxs)(`div`,{className:`univer-box-border univer-w-full`,children:[d.selectedCount>1&&(0,u.jsx)(`div`,{className:`univer-mb-4 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-300`,children:s.t(`docs-ui.doc.sectionSetting.selectedSections`,`${d.selectedCount}`)}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-3`,children:[(0,u.jsx)(e,{label:s.t(`docs-ui.doc.slider.sectionSetting`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.selectedSectionId??``,options:[...d.selectedSectionId==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],...d.sectionOptions],onChange:d.selectSection})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnCount`),children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.columnCount`),className:`univer-w-full`,min:1,max:12,step:1,precision:0,value:d.columnCount,onChange:e=>e!=null&&d.setColumnCount(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnGap`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.columnGap`),className:`univer-w-full`,min:0,max:1e3,step:1,precision:1,value:d.columnGap,onChange:e=>e!=null&&d.setColumnGap(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.columnSeparator`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.separatorType==null?``:`${d.separatorType}`,options:[...d.separatorType==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.doc.sectionSetting.none`),value:`${t.ColumnSeparatorType.NONE}`},{label:s.t(`docs-ui.doc.sectionSetting.betweenColumns`),value:`${t.ColumnSeparatorType.BETWEEN_EACH_COLUMN}`}],onChange:e=>d.setSeparatorType(Number(e))})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.sectionStart`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.sectionType==null?``:`${d.sectionType}`,options:[...d.sectionType==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.doc.sectionSetting.unspecified`),value:`${t.SectionType.SECTION_TYPE_UNSPECIFIED}`},{label:s.t(`docs-ui.doc.sectionSetting.continuous`),value:`${t.SectionType.CONTINUOUS}`},{label:s.t(`docs-ui.doc.sectionSetting.nextColumn`),value:`${t.SectionType.NEXT_COLUMN}`},{label:s.t(`docs-ui.doc.sectionSetting.nextPage`),value:`${t.SectionType.NEXT_PAGE}`},{label:s.t(`docs-ui.doc.sectionSetting.evenPage`),value:`${t.SectionType.EVEN_PAGE}`},{label:s.t(`docs-ui.doc.sectionSetting.oddPage`),value:`${t.SectionType.ODD_PAGE}`}],onChange:e=>d.setSectionType(Number(e))})}),(0,u.jsx)(`div`,{className:`univer-pt-2 univer-text-sm univer-font-medium`,children:s.t(`docs-ui.doc.sectionSetting.pageSetup`)}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageWidth`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageWidth`),className:`univer-w-full`,min:1,step:1,precision:1,value:d.pageWidth,onChange:e=>e!=null&&d.setPageWidth(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageHeight`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageHeight`),className:`univer-w-full`,min:1,step:1,precision:1,value:d.pageHeight,onChange:e=>e!=null&&d.setPageHeight(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.orientation`),children:(0,u.jsx)(r,{className:`univer-w-full`,value:d.pageOrient==null?``:`${d.pageOrient}`,options:[...d.pageOrient==null?[{label:s.t(`docs-ui.doc.sectionSetting.multipleValues`),value:``,disabled:!0}]:[],{label:s.t(`docs-ui.page-settings.portrait`),value:`${t.PageOrientType.PORTRAIT}`},{label:s.t(`docs-ui.page-settings.landscape`),value:`${t.PageOrientType.LANDSCAPE}`}],onChange:e=>d.setPageOrient(Number(e))})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.top`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.top`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginTop,onChange:e=>e!=null&&d.setMarginTop(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.bottom`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.bottom`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginBottom,onChange:e=>e!=null&&d.setMarginBottom(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.left`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.left`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginLeft,onChange:e=>e!=null&&d.setMarginLeft(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.page-settings.right`),unit:` (px)`,children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.page-settings.right`),className:`univer-w-full`,min:0,step:1,precision:1,value:d.marginRight,onChange:e=>e!=null&&d.setMarginRight(e)})}),(0,u.jsx)(e,{label:s.t(`docs-ui.doc.sectionSetting.pageNumberStart`),children:(0,u.jsx)(n,{"aria-label":s.t(`docs-ui.doc.sectionSetting.pageNumberStart`),className:`univer-w-full`,min:1,step:1,precision:0,value:d.pageNumberStart,onChange:e=>e!=null&&d.setPageNumberStart(e)})})]}),(0,u.jsx)(fv,{unitId:d.unitId,id:d.selectedSectionId,objectType:o.UnitObject.DocumentSection})]}):null}function wv(e){let r=(0,a.useDependency)(t.ICommandService),[i,o]=(0,l.useState)(()=>(0,t.generateRandomId)(4));return(0,l.useEffect)(()=>{let e=r.onCommandExecuted(e=>{e.id===n.SetTextSelectionsOperation.id?e.params.ranges.length>0&&o((0,t.generateRandomId)(4)):e.id===n.RichTextEditingMutation.id&&o((0,t.generateRandomId)(4))});return()=>e.dispose()},[r]),(0,l.createElement)(Cv,{...e,key:i})}function Tv({label:e,unit:t,children:n}){return(0,u.jsxs)(`div`,{className:`univer-flex univer-min-h-12 univer-flex-col univer-gap-2`,children:[(0,u.jsxs)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-gray-100`,children:[e,t]}),(0,u.jsx)(`div`,{className:`univer-w-full univer-min-w-0`,children:n})]})}let Ev=(0,l.forwardRef)((e,t)=>(0,u.jsx)(i.InputNumber,{...e,ref:t,className:(0,i.clsx)(e.className,`univer-h-12 univer-w-full`),inputClassName:(0,i.clsx)(e.inputClassName,`univer-text-base`)}));function Dv(e){return(0,u.jsx)(i.MobileSelect,{...e,className:(0,i.clsx)(e.className,`univer-h-12 univer-w-full`)})}function Ov({min:e=0,max:t=100,step:n=.1,precision:r=1,onChange:i,...a}){return(0,u.jsx)(Ev,{...a,min:e,max:t,step:n,precision:r,onChange:e=>i(e??0)})}function kv({label:e,selected:t,onClick:n,children:r}){return(0,u.jsx)(i.Button,{type:`button`,variant:`text`,"aria-label":e,"aria-pressed":t,className:(0,i.clsx)(`univer-h-12 univer-w-full`,{"!univer-bg-gray-200 dark:!univer-bg-gray-700":t}),onClick:n,children:(0,u.jsx)(`span`,{className:`univer-flex univer-size-5 univer-items-center univer-justify-center univer-text-lg`,children:r})})}function Av(e){return(0,u.jsx)(Sl,{...e,InputNumberComponent:Ev,SelectComponent:Dv})}function jv(){return(0,u.jsx)(dv,{RowComponent:Tv,NumberComponent:Ov,SelectComponent:Dv,AlignmentButtonComponent:kv})}function Mv(){return(0,u.jsx)(wv,{RowComponent:Tv,InputNumberComponent:Ev,SelectComponent:Dv})}function Nv(){return(0,u.jsx)(F_,{ContentComponent:Pv})}function Pv({unitId:e}){let n=(0,a.useDependency)(t.LocaleService),{canLinkToPrevious:r,linkedToPrevious:o,options:s,handleLinkToPreviousChange:c,handleCheckboxChange:l,handleMarginChange:d,closeHeaderFooter:f}=j_(e);return(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-4`,children:[r&&(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:o,onChange:e=>{c(!!e)},children:n.t(`docs-ui.headerFooter.linkToPrevious`)})}),(0,u.jsxs)(`div`,{className:`univer-grid univer-gap-2`,children:[(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:s.useFirstPageHeaderFooter===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`useFirstPageHeaderFooter`)},children:n.t(`docs-ui.headerFooter.firstPageCheckBox`)})}),(0,u.jsx)(`div`,{className:`univer-flex univer-min-h-12 univer-items-center`,children:(0,u.jsx)(i.Checkbox,{checked:s.evenAndOddHeaders===t.BooleanNumber.TRUE,onChange:e=>{l(!!e,`evenAndOddHeaders`)},children:n.t(`docs-ui.headerFooter.oddEvenCheckBox`)})})]}),(0,u.jsxs)(`div`,{className:`univer-mb-1 univer-flex univer-flex-col univer-gap-3`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.headerTopMargin`)}),(0,u.jsx)(Ev,{className:`univer-h-12 univer-w-full`,min:0,max:200,precision:1,value:s.marginHeader,onChange:e=>{d(e??0,`marginHeader`)}})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-flex-col univer-gap-2`,children:[(0,u.jsx)(`span`,{children:n.t(`docs-ui.headerFooter.footerBottomMargin`)}),(0,u.jsx)(Ev,{className:`univer-h-12 univer-w-full`,min:0,max:200,precision:1,value:s.marginFooter,onChange:e=>{d(e??0,`marginFooter`)}})]})]}),(0,u.jsx)(`div`,{className:`univer-flex`,children:(0,u.jsx)(i.Button,{className:`univer-h-12 univer-w-full`,onClick:f,children:n.t(`docs-ui.headerFooter.closeHeaderFooter`)})})]})}let Fv=({handleRowColChange:e,tableCreateParams:n})=>{let r=(0,a.useDependency)(t.LocaleService),[o,s]=(0,l.useState)(3),[c,d]=(0,l.useState)(5);function f(t,n){s(t),d(n),e(t,n)}return(0,l.useEffect)(()=>{s(n.rowCount),d(n.colCount)},[n]),(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-justify-between univer-gap-2`,children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:[(0,u.jsx)(`span`,{children:r.t(`docs-ui.toolbar.table.rowCount`)}),(0,u.jsx)(i.InputNumber,{className:`univer-w-28`,min:1,max:20,precision:0,value:o,onChange:e=>{f(e,c)}})]}),(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:[(0,u.jsx)(`span`,{children:r.t(`docs-ui.toolbar.table.colCount`)}),(0,u.jsx)(i.InputNumber,{className:`univer-w-28`,min:1,max:20,precision:0,value:c,onChange:e=>{f(o,e)}})]})]})},Iv=class extends t.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerParts(),this._registerIcons()}_registerParts(){let e=this._componentManager;this.disposeWithMe(e.register(es,Fv)),this.disposeWithMe(e.register(Yg,k_))}_registerIcons(){this.disposeWithMe(this._iconManager.register({DocPasteOptionsIcon:kp,AlignTextBothIcon:pp,AddImageIcon:dp,BoldIcon:hp,CopyDoubleIcon:ah,ColumnIcon:Cp,CutIcon:Tp,DeleteColumnDoubleIcon:sh,DeleteIcon:Dp,DeleteRowDoubleIcon:lh,DeleteTableDoubleIcon:dh,DocSettingIcon:jp,FontColorDoubleIcon:ph,GridIcon:Fp,H1Icon:Lp,H2Icon:zp,H3Icon:Vp,H4Icon:Up,H5Icon:Gp,HeaderFooterIcon:qp,HorizontallyIcon:Yp,InsertDoubleIcon:hh,InsertRowAboveDoubleIcon:_h,InsertRowBelowDoubleIcon:yh,ItalicIcon:Zp,KeyboardIcon:$p,LeftInsertColumnDoubleIcon:xh,LeftJustifyingIcon:tm,LineIndentDecreaseIcon:rm,LineIndentIncreaseIcon:am,MenuIcon:sm,TextTypeIcon:Gm,NoColorDoubleIcon:Ch,OrderIcon:hm,PaintBucketDoubleIcon:Th,ParagraphSettingIcon:_m,PasteSpecialDoubleIcon:Dh,ReduceDoubleIcon:kh,ReduceIcon:xm,RightInsertColumnDoubleIcon:jh,RightJustifyingIcon:Cm,SectionSettingIcon:Tm,ShapeIcon:Dm,SmileIcon:km,StrikethroughIcon:Nm,SubscriptIcon:Fm,SuperscriptIcon:zm,SymbolsIcon:Vm,TitleTypeIcon:qm,SubtitleTypeIcon:Lm,TodoListDoubleIcon:Fh,UnderlineIcon:Ym,UnorderIcon:Zm,DefaultTextColorIcon:$g,HeaderTextColorIcon:Qg,MoreRightIcon:pm,MoreLeftIcon:dm,"DocParagraphTextColorSwatchIcon.0":n_,"DocParagraphTextColorSwatchIcon.1":r_,"DocParagraphTextColorSwatchIcon.2":i_,"DocParagraphTextColorSwatchIcon.3":a_,"DocParagraphTextColorSwatchIcon.4":o_,"DocParagraphTextColorSwatchIcon.5":s_,"DocParagraphTextColorSwatchIcon.6":c_,"DocParagraphBackgroundColorSwatchIcon.0":l_,"DocParagraphBackgroundColorSwatchIcon.1":u_,"DocParagraphBackgroundColorSwatchIcon.2":d_,"DocParagraphBackgroundColorSwatchIcon.3":f_,"DocParagraphBackgroundColorSwatchIcon.4":p_,"DocParagraphBackgroundColorSwatchIcon.5":m_,"DocParagraphBackgroundColorSwatchIcon.6":h_,"DocParagraphBackgroundColorSwatchIcon.7":g_,"DocParagraphBackgroundColorSwatchIcon.8":__,"DocParagraphBackgroundColorSwatchIcon.9":v_,"DocParagraphBackgroundColorSwatchIcon.10":y_,"DocParagraphBackgroundColorSwatchIcon.11":b_,"DocParagraphBackgroundColorSwatchIcon.12":x_,"DocParagraphBackgroundColorSwatchIcon.13":S_,"DocParagraphBackgroundColorSwatchIcon.14":C_,"DocParagraphBackgroundColorSwatchIcon.15":w_}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(Oc,Nv)),this.disposeWithMe(this._componentManager.register(`doc_ui_paragraph-setting-panel`,jv)),this.disposeWithMe(this._componentManager.register(fl,Mv)),this.disposeWithMe(this._componentManager.register(Cl,Av)),this.disposeWithMe(this._componentManager.register(T_,O_)),this.disposeWithMe(this._componentManager.register(zl,Ll)),this.disposeWithMe(this._componentManager.register(Rl,Fl)),this.disposeWithMe(this._componentManager.register(qg,Jg))}};Iv=B([z(0,(0,t.Inject)(a.ComponentManager)),z(1,(0,t.Inject)(a.IconManager))],Iv);let Lv=`docs.contextMenu.caret`,Rv=`MOBILE_DOC_PINCH_ZOOMING`,zv={[a.ContextMenuPosition.MAIN_AREA]:{[a.ContextMenuGroup.QUICK]:{[Pa.id]:{order:3,menuItemFactory:od},[Na.id]:{order:4,menuItemFactory:sd}}},[Lv]:{[a.ContextMenuGroup.QUICK]:{quickLayout:`tile`,[da.id]:{order:0,menuItemFactory:ad},[ua.id]:{order:.5,menuItemFactory:Sd},[Pa.id]:{order:1,menuItemFactory:od},[Na.id]:{order:2,menuItemFactory:sd}}}};function Bv(e){let t=e.filter(e=>{var t;return((t=e.gridLayout)==null?void 0:t.row)===2}),n=e.filter(e=>{var t;return((t=e.gridLayout)==null?void 0:t.row)!==2}),r=[];return t.length&&r.push({key:`doc.mobile.format.quick`,order:0,quickLayout:`tile`,quickLayoutVariant:`compact`,quickColumns:4,children:t}),n.length&&r.push({key:`doc.mobile.format.detail`,order:1,children:n}),r}function Vv(e){let t=e.getMenuByPositionKey(a.RibbonStartGroup.FORMAT),n=[...e.getMenuByPositionKey(a.RibbonStartGroup.LAYOUT),...e.getMenuByPositionKey(a.RibbonStartGroup.OTHERS),...e.getMenuByPositionKey(a.RibbonInsertGroup.OTHERS)];return{insert:[{key:`doc.mobile.insert`,order:0,quickLayout:`tile`,quickColumns:4,children:e.getMenuByPositionKey(a.RibbonInsertGroup.MEDIA)}],format:Bv(t),more:[{key:`doc.mobile.more`,order:0,quickLayout:`tile`,quickColumns:4,children:n}]}}function Hv(e){let t=e.commandId??e.id;if(!t)return null;let n=typeof e.params==`function`?e.params(e.value):e.params;return{commandId:t,params:e.value===void 0?n:{value:e.value}}}function Uv(e){return(0,u.jsx)(`button`,{type:`button`,"aria-label":e.label,"aria-pressed":e.active,className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-h-10 univer-min-w-0 univer-flex-1 univer-items-center univer-justify-center univer-rounded-lg univer-text-xl univer-text-gray-700 active:univer-scale-95 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`,e.active&&`univer-bg-primary-50 univer-text-primary-600 dark:!univer-bg-primary-900`),onClick:e.onClick,children:e.icon})}function Wv(){var e,n;let i=(0,a.useDependency)(J),o=(0,a.useDependency)(t.IUniverInstanceService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useObservable)(()=>o.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_DOC),null,!0,[o]),l=c==null?void 0:c.getUnitId(),u=l?(e=s.getRenderUnitById(l))==null?void 0:e.with(q):void 0;return{isEditing:(0,a.useObservable)(u==null?void 0:u.mobileEditMode$,(u==null?void 0:u.isMobileEditMode)??!1),isReadOnly:!l||((n=i.getEditor(l))==null?void 0:n.isReadOnly())===!0,selectionService:u}}function Gv(){let e=(0,a.useDependency)(t.LocaleService),{isEditing:n,isReadOnly:r,selectionService:o}=Wv();return!n||r?null:(0,u.jsx)(`button`,{type:`button`,"aria-label":e.t(`docs-ui.mobile.done`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-10 univer-items-center univer-justify-center univer-rounded-lg univer-text-primary-600 active:univer-bg-primary-50 dark:!univer-text-primary-400 dark:active:!univer-bg-primary-900`),onClick:()=>o==null?void 0:o.exitMobileEditMode(),children:(0,u.jsx)(yp,{className:`univer-size-6`})})}function Kv(){let e=(0,a.useDependency)(t.ICommandService),n=(0,a.useDependency)(t.LocaleService),r=(0,a.useDependency)(a.IMenuManagerService),o=(0,a.useDependency)(a.IWorkbenchService),c=(0,a.useObservable)(o.rootUnitType$,null,!0),{isEditing:d,isReadOnly:f,selectionService:p}=Wv(),m=(0,a.useObservable)(p==null?void 0:p.mobileKeyboardState$,{visible:!1,inset:0}),h=m.visible,[g,_]=(0,l.useState)(null),[v,y]=(0,l.useState)(null),[b,x]=(0,l.useState)(`compact`),[S,C]=(0,l.useState)(null),w=(0,a.useObservable)(()=>r.menuChanged$.pipe((0,s.startWith)(void 0),(0,s.map)(()=>Vv(r))),{insert:[],format:[],more:[]},!1,[r]),T=(0,l.useCallback)(()=>{_(null),x(`compact`),C(null)},[]);(0,l.useEffect)(()=>{let e=p==null?void 0:p.onFocus$.subscribe(()=>{T(),y(null)});return()=>e==null?void 0:e.unsubscribe()},[p,T]);let E=(0,l.useMemo)(()=>g?w[g]:[],[g,w]);if(c!==t.UniverInstanceType.UNIVER_DOC)return null;if(!d)return f?null:(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.edit`),className:(0,i.clsx)(i.resetButtonClassName,`univer-pointer-events-auto univer-absolute univer-bottom-4 univer-z-30 univer-flex univer-size-14 univer-items-center univer-justify-center univer-rounded-full univer-bg-primary-600 univer-text-2xl univer-text-white univer-shadow-lg active:univer-scale-95 active:univer-bg-primary-700 dark:!univer-bg-primary-500 dark:active:!univer-bg-primary-600`),style:{insetInlineEnd:`1rem`,marginBottom:`env(safe-area-inset-bottom, 0px)`},onClick:()=>{T(),y(null),p==null||p.enterMobileEditMode()},children:(0,u.jsx)($m,{})});function D(t){let n=Hv(t);n&&e.executeCommand(n.commandId,n.params).catch(()=>void 0)}function O(e){if(g===e){T();return}document.activeElement instanceof HTMLElement&&document.activeElement.blur(),y(null),C(null),x(`compact`),_(e)}function k(e){T(),y(t=>t===e?null:e)}function A(){T(),y(null),p==null||p.enterMobileEditMode(!0)}function j(){T(),y(null),p==null||p.suspendMobileEditingInput()}let M=(S==null?void 0:S.title)??n.t(g===`insert`?`docs-ui.mobile.insert`:g===`format`?`docs-ui.mobile.format`:`docs-ui.mobile.more`),N=v===`block`?af:sf;return(0,u.jsxs)(u.Fragment,{children:[h&&v&&(0,u.jsx)(`div`,{className:`univer-pointer-events-auto univer-absolute univer-inset-x-3 univer-z-30 univer-overflow-hidden`,style:{bottom:`${m.inset+48}px`},children:(0,u.jsx)(a.MobileMenu,{menuType:N,presentation:`context-bar`,onOptionSelect:D})}),h&&!g&&(0,u.jsxs)(`div`,{className:`univer-pointer-events-auto univer-absolute univer-inset-x-0 univer-z-30 univer-box-border univer-flex univer-h-12 univer-items-center univer-gap-0.5 univer-border-0 univer-border-t univer-border-solid univer-border-gray-200 univer-bg-gray-0 univer-px-1 dark:!univer-border-gray-700 dark:!univer-bg-gray-800`,style:{bottom:`${m.inset}px`,paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:[(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.insert`),icon:(0,u.jsx)(ym,{}),onClick:()=>O(`insert`)}),(0,u.jsx)(Uv,{active:v===`block`,label:n.t(`docs-ui.toolbar.heading.tooltip`),icon:(0,u.jsx)(Gm,{}),onClick:()=>k(`block`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.format`),icon:(0,u.jsx)(Um,{}),onClick:()=>O(`format`)}),(0,u.jsx)(Uv,{active:v===`align`,label:n.t(`docs-ui.paragraphMenu.alignAndIndent`),icon:(0,u.jsx)(pp,{}),onClick:()=>k(`align`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.more`),icon:(0,u.jsx)(lm,{}),onClick:()=>O(`more`)}),(0,u.jsx)(Uv,{active:!1,label:n.t(`docs-ui.mobile.hideKeyboard`),icon:(0,u.jsx)(xp,{}),onClick:j})]}),g&&(0,u.jsx)(a.MobileDrawer,{componentName:`mobile-doc-toolbar-drawer`,snap:b,expandLabel:n.t(`docs-ui.mobile.expand`),collapseLabel:n.t(`docs-ui.mobile.collapse`),onSnapChange:x,onClose:T,header:(0,u.jsxs)(`div`,{className:`univer-grid univer-h-12 univer-flex-1 univer-grid-cols-[56px_minmax(0,1fr)_56px] univer-items-center univer-px-2`,children:[(0,u.jsx)(`div`,{children:S&&(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.back`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-lg univer-text-2xl univer-text-gray-700 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`),onClick:S.onBack,children:(0,u.jsx)(dm,{})})}),(0,u.jsx)(`div`,{className:`univer-truncate univer-text-center univer-text-base univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-100`,children:M}),(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.close`),className:(0,i.clsx)(i.resetButtonClassName,`univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-lg univer-text-2xl univer-text-gray-700 active:univer-bg-gray-100 dark:!univer-text-gray-200 dark:active:!univer-bg-gray-700`),onClick:T,children:(0,u.jsx)(xp,{})})]}),floatingActions:(0,u.jsx)(`button`,{type:`button`,"aria-label":n.t(`docs-ui.mobile.keyboard`),className:(0,i.clsx)(i.resetButtonClassName,`univer-pointer-events-auto univer-flex univer-size-12 univer-items-center univer-justify-center univer-rounded-full univer-bg-gray-0 univer-text-xl univer-text-primary-600 univer-shadow-lg active:univer-bg-gray-100 dark:!univer-bg-gray-800 dark:!univer-text-primary-400 dark:active:!univer-bg-gray-700`),onClick:A,children:(0,u.jsx)($p,{})}),children:(0,u.jsx)(a.MobileMenu,{schemas:E,menuManagerService:r,showHeader:!1,onNavigationChange:C,onOptionSelect:D})})]})}let qv=class extends t.Disposable{constructor(e,n){super(),this._popupService=e,R(this,`_pending`,null),R(this,`_editingBounds`,null),R(this,`_popup`,null),R(this,`_unitId`,null),this.disposeWithMe(n.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).subscribe(e=>{var t,n;this._unitId===e.getUnitId()&&this.close(),((t=this._pending)==null?void 0:t.unitId)===e.getUnitId()&&(this._pending=null),((n=this._editingBounds)==null?void 0:n.unitId)===e.getUnitId()&&(this._editingBounds=null)}))}capture(e){return this._pending=e,queueMicrotask(()=>{this._pending===e&&(this._pending=null)}),!0}takeTarget(e){let t=this._pending;this._pending=null;let n=(t==null?void 0:t.unitId)===e?t:null;return this._editingBounds=n,n}setEditingBounds(e,t){this._editingBounds={unitId:e,rect:t}}getEditingBounds(e){var t;return((t=this._editingBounds)==null?void 0:t.unitId)===e?this._editingBounds.rect:null}show(e){this.close(),this.setEditingBounds(e.unitId,e.rect),this._unitId=e.unitId,this._popup=this._popupService.attachPopupToRect(e.rect,{componentKey:T_,direction:`top-center`,onClickOutside:()=>this.close(),extraProps:{onEdit:()=>(this.close(),e.onEdit()),onDelete:()=>(this.close(),e.onDelete())}},e.unitId)}close(){var e;(e=this._popup)==null||e.dispose(),this._popup=null,this._unitId=null}dispose(){this._pending=null,this._editingBounds=null,this.close(),super.dispose()}};qv=B([z(0,(0,t.Inject)(Rc)),z(1,t.IUniverInstanceService)],qv);function Jv({containerRef:e,canvasRef:i}){let o=(0,a.useDependency)(t.IUniverInstanceService),s=(0,a.useDependency)(r.IRenderManagerService),c=(0,a.useDependency)(qv),l=(0,a.useDependency)(n.DocSelectionManagerService),u=(0,a.useDependency)(a.IWorkbenchService),d=(0,a.useObservable)(u.rootUnitType$,null,!0);return(0,a.useMobileCanvasViewport)({containerRef:e,canvasRef:i,enabled:d===t.UniverInstanceType.UNIVER_DOC,panelsOnly:!0,onReveal:()=>{var e,n;let r=o.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),u=r&&s.getRenderUnitById(r.getUnitId()),d=u==null?void 0:u.scene.getViewport(`viewMain`);if(!u||!d)return;let f=(e=u.scene.getTransformer())==null?void 0:e.getSelectedObjectMap().values().next().value,p=c.getEditingBounds(u.unitId),m=p?Pc(p,u.scene):f&&Pc({left:f.left,top:f.top,right:f.left+f.width,bottom:f.top+f.height},u.scene);if(!m){var h;let e=l.getActiveTextRange(),t=e&&((h=Lc(e,u))==null?void 0:h[0]);if(t){let e=u.engine.getCanvasElement().getBoundingClientRect();m={left:t.left-e.left,top:t.top-e.top,right:t.right-e.left,bottom:t.bottom-e.top}}}let g=(n=i.current)==null?void 0:n.getBoundingClientRect();if(!m||!g)return;let _=(0,a.getMobileCanvasPanDelta)({left:m.left,top:m.top,width:m.right-m.left,height:m.bottom-m.top},g);if(_.x===0&&_.y===0)return;let v=u.scene.getAncestorScale();d.scrollToViewportPos({viewportScrollX:d.viewportScrollX-_.x/v.scaleX,viewportScrollY:d.viewportScrollY-_.y/v.scaleY})}}),null}let Yv=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._commandService=t,this._layoutService=n,this._menuManagerService=r,this._uiPartsService=i,this._initMenus(),this._initFocusHandler(),this._initCommands(),this._initUiParts()}_initUiParts(){this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.CONTENT,()=>(0,a.connectInjector)(Jv,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.FOOTER,()=>(0,a.connectInjector)(Kv,this._injector))),this.disposeWithMe(this._uiPartsService.registerComponent(a.BuiltInUIPart.HEADER_MENU,()=>(0,a.connectInjector)(Gv,this._injector)))}_initMenus(){this._menuManagerService.mergeMenu(Rf),this._menuManagerService.appendRootMenu(zv)}_initFocusHandler(){this.disposeWithMe(this._layoutService.registerFocusHandler(t.UniverInstanceType.UNIVER_DOC,()=>{}))}_initCommands(){[ll,cl,jc,Mc,kc].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}};Yv=B([z(0,(0,t.Inject)(t.Injector)),z(1,t.ICommandService),z(2,a.ILayoutService),z(3,a.IMenuManagerService),z(4,a.IUIPartsService)],Yv);let Xv=class extends t.Disposable{constructor(e,t,n){super(),this._context=e,this._canvasPopupManagerService=t,this._docLayoutInteractionService=n,R(this,`_layoutInteraction`,null),this.disposeWithMe(this._canvasPopupManagerService.popupUnits$.subscribe(e=>{e.has(this._context.unitId)?this._layoutInteraction??=this._docLayoutInteractionService.beginInteraction():this._endInteraction()}))}dispose(){this._endInteraction(),super.dispose()}_endInteraction(){var e;(e=this._layoutInteraction)==null||e.dispose(),this._layoutInteraction=null}};Xv=B([z(1,(0,t.Inject)(Rc)),z(2,(0,t.Inject)(Ps))],Xv);let Zv=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._context=e,this._docSkeletonManagerService=t,this._commandService=n,this._docEventManagerService=r,this._textSelectionManagerService=i,this._initPointerDownObserver(),this._initHoverCursor()}_initPointerDownObserver(){this._docEventManagerService.clickBullets$.subscribe(e=>{let t=this._textSelectionManagerService.getTextRanges();this._commandService.executeCommand(io.id,{index:e.paragraph.startIndex,segmentId:e.segmentId,textRanges:t})})}_initHoverCursor(){this.disposeWithMe(this._docEventManagerService.hoverBullet$.subscribe(e=>{e?this._context.mainComponent.setCursor(r.CURSOR_TYPE.POINTER):this._context.mainComponent.setCursor(r.CURSOR_TYPE.TEXT)}))}_getTransformCoordForDocumentOffset(e,t,n,i){let{documentTransform:a}=e.getOffsetConfig(),o=t.transformVector2SceneCoord(r.Vector2.FromArray([n,i]));if(o)return a.clone().invert().applyPoint(o)}};Zv=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService)),z(2,t.ICommandService),z(3,(0,t.Inject)(rl)),z(4,(0,t.Inject)(n.DocSelectionManagerService))],Zv);let Qv=class extends t.RxDisposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._commandService=t,this._docClipboardService=n,this._docSelectionRenderService=r,this._contextService=i,this._editorService=a,this._init()}_init(){this._initLegacyPasteCommand()}_initLegacyPasteCommand(){var e;(e=this._docSelectionRenderService)==null||e.onPaste$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{var t,n,r,i;if(!aa(this._contextService))return;e.event.preventDefault();let o=e.event,s=(t=o.clipboardData)==null?void 0:t.getData(a.HTML_CLIPBOARD_MIME_TYPE),c=(n=o.clipboardData)==null?void 0:n.getData(`application/x-doc-fragment+json`),l=(r=o.clipboardData)==null?void 0:r.getData(a.PLAIN_TEXT_CLIPBOARD_MIME_TYPE),u=[...((i=o.clipboardData)==null?void 0:i.items)||[]].filter(e=>a.imageMimeTypeSet.has(e.type)).map(e=>e.getAsFile()).filter(e=>!!e);this._editorService.getEditor(this._context.unitId)&&(s??``).indexOf(`</table>`)>-1&&(s=``),this._docClipboardService.legacyPaste({html:s,internalJson:c,text:l,files:u,unitId:this._context.unitId}).catch(()=>void 0)})}};Qv=B([z(1,t.ICommandService),z(2,ea),z(3,(0,t.Inject)(q)),z(4,t.IContextService),z(5,J)],Qv);let $v=[t.DEFAULT_EMPTY_DOCUMENT_VALUE,t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY],ey=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._contextMenuService=t,this._commandService=n,this._docEventManagerService=r,this._docSelectionManagerService=i,this._contextService=a,this._univerInstanceService=o,$v.includes(this._context.unitId)||(this._initPointerDown(),this._initEditChange())}_initPointerDown(){var e;let n=((e=this._context)==null||(e=e.mainComponent)==null?void 0:e.onPointerDown$).subscribeEvent(e=>{if(e.button===2){var n;if(this._docEventManagerService.isPointerOnNonChecklistBullet(e.offsetX,e.offsetY)||this._isSelectionInCodeBlock())return;let r=this._docEventManagerService.getParagraphByOffset(e.offsetX,e.offsetY),i=this._univerInstanceService.getUnit(this._context.unitId),o=(r==null?void 0:r.segmentId)??``,s=r&&(i==null||(n=i.getSelfOrHeaderFooterModel(o))==null||(n=n.getBody())==null||(n=n.paragraphs)==null?void 0:n.find(e=>e.startIndex===r.startIndex));this._docEventManagerService.contextMenuParagraph=s!=null&&s.paragraphId?{unitId:this._context.unitId,segmentId:o,paragraphId:s.paragraphId}:null;let c=this._contextService.getContextValue(t.FOCUSING_COMMON_DRAWINGS)?a.ContextMenuPosition.DRAWING:a.ContextMenuPosition.MAIN_AREA;this._contextMenuService.triggerContextMenu(e,c)}});this.disposeWithMe(n)}_initEditChange(){this.disposeWithMe(this._commandService.onCommandExecuted(e=>{e.id===n.RichTextEditingMutation.id&&this._contextMenuService.visible&&this._contextMenuService.hideContextMenu()}))}_isSelectionInCodeBlock(){var e;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC),r=(n==null||(e=n.getBody())==null||(e=e.blockRanges)==null?void 0:e.filter(e=>e.blockType===t.DocumentBlockRangeType.CODE))??[],i=this._docSelectionManagerService.getTextRanges()??[];return!r.length||!i.length?!1:r.some(e=>i.some(t=>ty(t,e.startIndex,e.endIndex)))}};ey=B([z(1,a.IContextMenuService),z(2,t.ICommandService),z(3,(0,t.Inject)(rl)),z(4,(0,t.Inject)(n.DocSelectionManagerService)),z(5,t.IContextService),z(6,(0,t.Inject)(t.IUniverInstanceService))],ey);function ty(e,t,n){return Math.max(e.startOffset,t)<=Math.min(e.endOffset,n)}let ny=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._univerInstanceService=t,this._editorService=n,this._commandService=r,this._docSelectionRenderService=i,this._docSkeletonManagerService=a,this._renderManagerService=o,R(this,`_initialEditors`,new Set),this._initialize()}_initialize(){this._editorService.getAllEditor().forEach(e=>{let t=e.getEditorId();t===this._context.unitId&&(this._initialEditors.has(t)||(this._initialEditors.add(t),this._resize(t)))}),this._commandExecutedListener(),this._initialBlur(),this._initialFocus()}_resize(e){if(e==null)return;let n=this._editorService.getEditor(e);if((n==null?void 0:n.cancelDefaultResizeListener)===!0)return;let r=this._univerInstanceService.getUnit(e,t.UniverInstanceType.UNIVER_DOC);if(!r)return;let i=this._docSkeletonManagerService.getSkeleton();if(n==null||n.render==null||i==null||r==null)return;i.calculate();let{marginTop:a=0,marginBottom:o=0,marginLeft:s=0,marginRight:c=0}=r.getSnapshot().documentStyle,{scene:l,mainComponent:u}=n.render,{actualHeight:d,actualWidth:f}=i.getActualSize();d+=a+o,f+=s+c;let{width:p,height:m}=n.getBoundingClientRect(),h=Math.max(f,p),g=Math.max(d,m);l.transformByState({width:h,height:g}),u==null||u.resize(h,g)}_initialBlur(){this.disposeWithMe(this._editorService.blur$.subscribe(()=>{this._docSelectionRenderService.blur()})),this.disposeWithMe(this._docSelectionRenderService.onBlur$.subscribe(()=>{let{unitId:e}=this._context,t=this._editorService.getEditor(e),n=this._editorService.getFocusEditor();t==null||t.isSheetEditor()||n&&n.getEditorId()===e||e.includes(`range_selector`)||e.includes(`embedding_formula_editor`)||this._editorService.blur()}))}_initialFocus(){let e=[`univer-formula-search`,`univer-formula-help`,`formula-help-decorator`,`univer-formula-help-param`];this.disposeWithMe((0,s.fromEvent)(window,`mousedown`).subscribe(n=>{let r=n.target.classList[0]||``;(0,t.checkForSubstrings)(r,e)&&n.stopPropagation()}));let n=new t.DisposableCollection;this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(n.dispose(),!e)return;let t=e.getUnitId(),r=this._renderManagerService.getRenderUnitById(t),i=r==null?void 0:r.engine.getCanvas().getCanvasEle();if(i==null)return;let a=(0,s.fromEvent)(i,`mousedown`).subscribe(e=>{e.stopPropagation()});n.add(a)})),this.disposeWithMe(()=>n.dispose())}_commandExecutedListener(){let e=[n.RichTextEditingMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){let{unitId:e}=t.params;if(this._editorService.isSheetEditor(e)||e!==this._context.unitId)return;let n=this._editorService.getEditorRenderConfig(e);n&&!n.scrollBar&&this._resize(e)}}))}};ny=B([z(1,t.IUniverInstanceService),z(2,J),z(3,t.ICommandService),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(n.DocSkeletonManagerService)),z(6,r.IRenderManagerService)],ny);let ry=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docSelectionRenderService=t,this._docImeInputManagerService=n,this._docSkeletonManagerService=r,this._docStateEmitService=i,this._docSelectionManagerService=a,this._commandService=o,R(this,`_previousIMEContent`,``),R(this,`_isCompositionStart`,!0),R(this,`_onStartSubscription`,void 0),R(this,`_onUpdateSubscription`,void 0),R(this,`_onEndSubscription`,void 0),this._initialize()}dispose(){var e,t,n;(e=this._onStartSubscription)==null||e.unsubscribe(),(t=this._onUpdateSubscription)==null||t.unsubscribe(),(n=this._onEndSubscription)==null||n.unsubscribe()}_initialize(){this._initialOnCompositionstart(),this._initialOnCompositionUpdate(),this._initialOnCompositionend()}_initialOnCompositionstart(){this._onStartSubscription=this._docSelectionRenderService.onCompositionstart$.subscribe(e=>{var n;if(e==null)return;this._resetIME();let{activeRange:r,rangeList:i=[]}=e;r!=null&&(this._docImeInputManagerService.setActiveRange(t.Tools.deepClone(r)),this._docImeInputManagerService.setPreviousDocRanges(t.Tools.deepClone([...i,...this._docSelectionRenderService.getAllRectRanges()])),this._docImeInputManagerService.setPreviousSelectionOptions(t.Tools.deepClone(((n=this._docSelectionManagerService.getSelectionInfo())==null?void 0:n.options)??null)))})}_initialOnCompositionUpdate(){this._onUpdateSubscription=this._docSelectionRenderService.onCompositionupdate$.subscribe(e=>{this._updateContent(e,!0)})}_initialOnCompositionend(){this._onEndSubscription=this._docSelectionRenderService.onCompositionend$.subscribe(e=>{this._updateContent(e,!1)})}async _updateContent(e,t){if(e==null)return;let n=this._context.unitId,r=this._docSkeletonManagerService.getSkeleton(),{event:i,activeRange:a}=e;if(r==null||a==null)return;let o=i.data;if(!(t&&o===``)){if(!t&&o===``){this._previousIMEContent!==``&&await this._commandService.executeCommand(Ya.id,{unitId:n,newText:``,oldTextLen:this._previousIMEContent.length,isCompositionStart:!1,isCompositionEnd:!0,isCompositionCanceled:!0}),this._resetIME();return}if(!(o===this._previousIMEContent&&t)){if(!t&&o===this._previousIMEContent){this._finalizeComposition(),this._resetIME();return}await this._commandService.executeCommand(Ya.id,{unitId:n,newText:o,oldTextLen:this._previousIMEContent.length,isCompositionStart:this._isCompositionStart,isCompositionEnd:!t}),t?(this._isCompositionStart&&=!1,this._previousIMEContent=o):this._resetIME()}}}_finalizeComposition(){let e=this._docImeInputManagerService.getActiveRange();e!=null&&this._docStateEmitService.emitStateChangeInfo({commandId:n.RichTextEditingMutation.id,unitId:this._context.unitId,segmentId:e.segmentId,trigger:Ya.id,redoState:{actions:[],textRanges:this._docImeInputManagerService.getPreviousDocRanges().length?this._docImeInputManagerService.getPreviousDocRanges():[e]},undoState:{actions:[],textRanges:this._docImeInputManagerService.getPreviousDocRanges().length?this._docImeInputManagerService.getPreviousDocRanges():[e],options:this._docImeInputManagerService.getPreviousSelectionOptions()??void 0},isCompositionEnd:!0})}_resetIME(){this._previousIMEContent=``,this._isCompositionStart=!0,this._docImeInputManagerService.clearUndoRedoMutationParamsCache(),this._docImeInputManagerService.setActiveRange(null),this._docImeInputManagerService.setPreviousDocRanges([]),this._docImeInputManagerService.setPreviousSelectionOptions(null)}};ry=B([z(1,(0,t.Inject)(q)),z(2,(0,t.Inject)(Ja)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,(0,t.Inject)(n.DocStateEmitService)),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,t.ICommandService)],ry);let iy=class extends t.Disposable{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._docSelectionRenderService=t,this._docSkeletonManagerService=n,this._commandService=r,this._docMenuStyleService=i,this._embedRuntimeFocusCoordinator=o,R(this,`_onInputSubscription`,void 0),this._init()}dispose(){var e;super.dispose(),(e=this._onInputSubscription)==null||e.unsubscribe()}_init(){this._initialNormalInput()}_initialNormalInput(){this._onInputSubscription=this._docSelectionRenderService.onInput$.subscribe(async e=>{var r,i,a,o,s,c;if(e==null)return;let{unitId:l}=this._context,{event:u,content:d=``,activeRange:f,rangeList:p=[]}=e,m=u;if(m.defaultPrevented||!t.SHEET_EDITOR_UNITS.includes(l)&&this._isEmbedChildInputActive(l,m))return;let h=this._docSkeletonManagerService.getSkeleton();if(m.data==null||h==null||f==null)return;let{segmentId:g}=f,_=this._context.unit,v=(r=_.getSelfOrHeaderFooterModel(g))==null?void 0:r.getBody();if(!v)return;let y=this._docMenuStyleService.getDefaultStyle(),b=this._docMenuStyleService.getStyleCache(),x=ee((v==null?void 0:v.customRanges)??[],f.endOffset,t.SHEET_EDITOR_UNITS.includes(l)),S=N(v,f,y,b,t.SHEET_EDITOR_UNITS.includes(l),((i=Be(_))==null?void 0:i.inheritParagraphStartStyle)===!0),C=P((v==null?void 0:v.customDecorations)??[],f.endOffset),w={dataStream:d,textRuns:S?[{...S,st:0,ed:d.length}]:[],customRanges:x?[{...x,startIndex:0,endIndex:d.length-1}]:[],customDecorations:C.map(e=>({...e,startIndex:0,endIndex:d.length-1}))};!f.collapsed&&((a=v.blockRanges)!=null&&a.length||(o=v.columnGroups)!=null&&o.length||(s=v.customBlocks)!=null&&s.length||(c=v.tables)!=null&&c.length)||p.length>1||this._docSelectionRenderService.getAllRectRanges().length>0?await this._commandService.executeCommand(Ne.id,{unitId:l,body:w,segmentId:g}):await this._commandService.executeCommand(n.InsertTextCommand.id,{unitId:l,body:w,range:f,segmentId:g}),d===` `&&await this._commandService.executeCommand(ne.id)})}_isEmbedChildInputActive(e,t){var n,r,i;return(n=this._embedRuntimeFocusCoordinator)!=null&&n.isChildUnitRuntimeEvent(e,t.target,t)||(r=this._embedRuntimeFocusCoordinator)!=null&&r.isChildUnitInActiveSession(e)?!1:!!((i=this._embedRuntimeFocusCoordinator)!=null&&i.shouldSuppressHostInteraction(e,t.target,t))}};iy=B([z(1,(0,t.Inject)(q)),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.ICommandService),z(4,(0,t.Inject)(U)),z(5,(0,t.Optional)(Ie)),z(6,(0,t.Optional)(Le))],iy);function ay(e){if(e.complete)return 100;let t=e.totalBlockCount>0?e.processedBlockCount/e.totalBlockCount:0,n=Math.max(e.estimatedPageCount,e.pageCount),r=e.mode===`paginated`&&n>0?e.publishedPageCount/n:0,i=e.reason===`initial`&&e.totalBlockCount>0?t:Math.max(t,r);return Math.min(99,Math.max(0,Math.floor(i*100)))}let oy=class extends t.RxDisposable{constructor(e,t,n){super(),this._context=e,this._docSkeletonManagerService=t,this._docLayoutProgressService=n,R(this,`_visible`,!1),R(this,`_delayTimer`,null),R(this,`_cancelTimer`,null),R(this,`_latestProgress`,null),R(this,`_layoutStartedAt`,null),R(this,`_maxProgress`,0),this._docSkeletonManagerService.currentSkeleton$.pipe((0,s.switchMap)(e=>(this._reset(),(e==null?void 0:e.layoutProgress$)??s.EMPTY)),(0,s.takeUntil)(this.dispose$)).subscribe(e=>this._handleProgress(e))}dispose(){this._reset(),super.dispose()}_handleProgress(e){if(e.cancelled){this._latestProgress=null,this._scheduleCancelledClear();return}if(this._clearCancelTimer(),e.complete){this._reset();return}this._latestProgress=e,this._layoutStartedAt??=Date.now(),this._maxProgress=Math.max(this._maxProgress,ay(e)),this._visible&&this._docLayoutProgressService.setProgress(this._context.unitId,this._maxProgress),this._scheduleShow()}_scheduleShow(){if(this._visible||this._delayTimer!=null||this._layoutStartedAt==null)return;let e=Math.max(0,2e3-(Date.now()-this._layoutStartedAt));if(e===0){this._show();return}this._delayTimer=setTimeout(()=>{this._delayTimer=null,this._show()},e)}_show(){this._visible||this._latestProgress==null||this._latestProgress.complete||(this._visible=!0,this._docLayoutProgressService.setProgress(this._context.unitId,this._maxProgress))}_scheduleCancelledClear(){this._cancelTimer??=setTimeout(()=>{this._cancelTimer=null,this._latestProgress??this._reset()},1e3)}_clearCancelTimer(){this._cancelTimer!=null&&(clearTimeout(this._cancelTimer),this._cancelTimer=null)}_reset(){this._delayTimer!=null&&(clearTimeout(this._delayTimer),this._delayTimer=null),this._clearCancelTimer(),this._docLayoutProgressService.clearProgress(this._context.unitId),this._visible=!1,this._latestProgress=null,this._layoutStartedAt=null,this._maxProgress=0}};oy=B([z(1,(0,t.Inject)(n.DocSkeletonManagerService)),z(2,(0,t.Inject)(Qh))],oy);function sy(e,n,r){let i=e.style.pointerEvents,a=e.style.opacity,o=e.getAttribute(`aria-busy`),s=n.forceDisable();return r(),e.style.pointerEvents=`none`,e.style.opacity=`0.55`,e.setAttribute(`aria-busy`,`true`),(0,t.toDisposable)(()=>{s.dispose(),e.style.pointerEvents=i,e.style.opacity=a,o==null?e.removeAttribute(`aria-busy`):e.setAttribute(`aria-busy`,o)})}let cy=class extends t.RxDisposable{constructor(e,t,r,i,a){super(),this._context=e,this._layoutExecutorService=t,this._docPopupManagerService=r,this._docSelectionRenderService=i,this._shortcutService=a,R(this,`_popup`,null),R(this,`_interactionLock`,null),R(this,`_visible`,!1),this._layoutExecutorService.executorStatus$.pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>{e.state===n.DocLayoutExecutorState.RECOVERING&&e.recoveryUnitId===this._context.unitId?this._show():this._hide()})}dispose(){this._hide(),super.dispose()}_show(){if(this._visible)return;let e=this._context.engine.getCanvasElement();this._visible=!0;try{this._interactionLock=sy(e,this._shortcutService,()=>this._docSelectionRenderService.blur()),this._popup=this._docPopupManagerService.attachPopupToRect(()=>({left:this._context.scene.width/2,right:this._context.scene.width/2,top:this._context.scene.height/2,bottom:this._context.scene.height/2}),{componentKey:qg,customActive:!0,direction:`vertical-center`,zIndex:1021},this._context.unitId)}catch{this._restoreInteraction()}}_hide(){var e;this._visible&&((e=this._popup)==null||e.dispose(),this._popup=null,this._restoreInteraction())}_restoreInteraction(){var e;(e=this._interactionLock)==null||e.dispose(),this._interactionLock=null,this._visible=!1}};cy=B([z(1,(0,t.Inject)(n.DocLayoutExecutorService)),z(2,(0,t.Inject)(Rc)),z(3,(0,t.Inject)(q)),z(4,a.IShortcutService)],cy);let ly=class extends t.Disposable{constructor(e,n,r,i,o){if(super(),this._context=e,this._clipboard=n,R(this,`_popup`,void 0),(0,t.isInternalEditorID)(e.unitId))return;let s=o.getContextValue(a.MOBILE_UI_MODE)===!0;this.disposeWithMe(r.onKeydown$.subscribe(({event:e})=>{let t=e;(t.ctrlKey||t.metaKey)&&t.shiftKey&&t.key.toLowerCase()===`v`?this._clipboard.setNextPasteMode(`text`):[`Control`,`Meta`,`Shift`,`Alt`].includes(t.key)||(this._clipboard.setNextPasteMode(`source`),this._clipboard.dismissPasteOptions())})),this.disposeWithMe(r.onInputBefore$.subscribe(()=>this._clipboard.dismissPasteOptions())),this.disposeWithMe(r.onPointerDown$.subscribe(()=>{this._clipboard.setNextPasteMode(`source`),s||this._clipboard.dismissPasteOptions()})),this.disposeWithMe(r.onBlur$.subscribe(()=>this._clipboard.setNextPasteMode(`source`))),this.disposeWithMe(this._clipboard.pasteOptions$.subscribe(e=>{var t;(t=this._popup)==null||t.dispose(),this._popup=void 0,(e==null?void 0:e.unitId)===this._context.unitId&&(this._popup=i.attachPopupToRange(e.range,{componentKey:Yg,direction:`bottom-left`,rangeAnchor:`selection-end`,requiresStableLayout:!1,hideOnInvisible:!s,extraProps:{unitId:e.unitId},offset:[0,6],onClickOutside:s?void 0:()=>this._clipboard.dismissPasteOptions()},e.unitId))})),this.disposeWithMe(()=>{var e;(e=this._popup)==null||e.dispose(),this._clipboard.dismissPasteOptions()})}};ly=B([z(1,ea),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(Rc)),z(4,t.IContextService)],ly);function uy(e){if(typeof e!=`object`||!e||!(`getSkeleton`in e)||typeof e.getSkeleton!=`function`)return!1;let t=e.getSkeleton();if(typeof t!=`object`||!t||!(`getSkeletonData`in t)||typeof t.getSkeletonData!=`function`)return!1;let n=t.getSkeletonData();return typeof n==`object`&&!!n&&`pages`in n&&Array.isArray(n.pages)&&n.pages.length>0}let dy=class extends t.Disposable{constructor(e,n,r,i){super(),this._context=e,this._docPageLayoutService=n,this._textSelectionManagerService=r,this._sidebarService=i;let a=this._context.unitId;if((0,t.isInternalEditorID)(a))return this;this._initResize()}_initResize(){this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler)).subscribe(()=>this._refreshLayoutAndSelection())),this.disposeWithMe(this._sidebarService.sidebarOptions$.pipe((0,s.observeOn)(s.animationFrameScheduler)).subscribe(()=>this._refreshLayoutAndSelection()))}_refreshLayoutAndSelection(){if(this._disposed||!uy(this._context.mainComponent))return;this._docPageLayoutService.calculatePagePosition();let e=this._context.unitId;this._textSelectionManagerService.refreshSelection({unitId:e,subUnitId:e})}};dy=B([z(1,(0,t.Inject)(Hs)),z(2,(0,t.Inject)(n.DocSelectionManagerService)),z(3,a.ISidebarService)],dy);let fy=class extends ds{constructor(e,t,n,r,i,a){super(e,t,r,i),this._docSelectionRenderService=n,this._docPageLayoutService=a,R(this,`_mobileKeyboardInset`,0),this.disposeWithMe(this._docSelectionRenderService.mobileKeyboardState$.subscribe(({visible:e,inset:t})=>{let n=this._mobileKeyboardInset;this._mobileKeyboardInset=e?t+48:0,this._docPageLayoutService.setBottomReserve(e?this._mobileKeyboardInset+32:0),this._mobileKeyboardInset>n&&(this._cancelPendingSelectionScroll(),this._scrollToSelection())}))}dispose(){this._docPageLayoutService.setBottomReserve(0),super.dispose()}_getVerticalScrollDelta(e,t,n,r,i){let a=Math.max(this._context.scene.getAncestorScale().scaleY,.01),o=r-this._mobileKeyboardInset/a;if(e>=n&&e+t<=o)return 0;let s=Math.max(0,o-n-t)*.4;return e-n-s}};fy=B([z(1,(0,t.Inject)(n.DocSelectionManagerService)),z(2,(0,t.Inject)(q)),z(3,J),z(4,(0,t.Inject)(n.DocSkeletonManagerService)),z(5,(0,t.Inject)(Hs))],fy);function py(e){var t;let n=e.target;if(typeof Element<`u`&&n instanceof Element&&n.closest(`[data-embed-interaction-boundary-owner]`)!=null)return!0;if(typeof document>`u`)return!1;let r=my(e,n),i=r==null?void 0:r.clientX,a=r==null?void 0:r.clientY;return typeof i!=`number`||typeof a!=`number`||!Number.isFinite(i)||!Number.isFinite(a)||typeof document.elementFromPoint!=`function`?!1:((t=document.elementFromPoint(i,a))==null?void 0:t.closest(`[${Fe}]`))!=null}function my(e,t){if(Number.isFinite(e.clientX)&&Number.isFinite(e.clientY))return{clientX:e.clientX,clientY:e.clientY};if(typeof Element<`u`&&t instanceof Element&&Number.isFinite(e.offsetX)&&Number.isFinite(e.offsetY)){let n=t.getBoundingClientRect();return{clientX:n.left+e.offsetX,clientY:n.top+e.offsetY}}if(Number.isFinite(e.x)&&Number.isFinite(e.y))return{clientX:e.x,clientY:e.y}}let hy=.22,gy=class extends t.Disposable{constructor(e,t,n,r,i,a,o,s,c,l,u,d){super(),this._context=e,this._commandService=t,this._editorService=n,this._instanceSrv=r,this._docSelectionRenderService=i,this._docSkeletonManagerService=a,this._docSelectionManagerService=o,this._contextService=s,this._contextMenuService=c,this._mobileElementMenuService=l,this._embedRuntimeFocusCoordinator=d,R(this,`_loadedMap`,new WeakSet),R(this,`_deferredEditorFocusTimer`,null),R(this,`_gestureTimer`,null),R(this,`_gestureDisposables`,[]),R(this,`_lastTap`,null),R(this,`_inertiaAnimationId`,null),R(this,`_inertiaLastFrameTime`,0),R(this,`_inertiaVelocity`,{x:0,y:0}),R(this,`_initialSelectionReady`,!1),this._initialize()}_initialize(){this._init(),this._refreshListener(),this._syncSelection(),this._skeletonListener(),this._commandExecutedListener()}_init(){let{unitId:e}=this._context,t=x(this._context);t!=null&&t.document!=null&&(this._loadedMap.has(t.document)||(this._initialMain(e),this._loadedMap.add(t.document)))}_refreshListener(){this.disposeWithMe(this._docSelectionManagerService.refreshSelection$.subscribe(e=>{if(e==null)return;let{unitId:t,docRanges:n,isEditing:r,options:i}=e;t===this._context.unitId&&this._docSelectionRenderService.replaceDocRanges(n,r,i)}))}_syncSelection(){this.disposeWithMe(this._docSelectionRenderService.textSelectionInner$.subscribe(e=>{e!=null&&((0,t.isInternalEditorID)(this._context.unitId)||!this._isEmbedChildInteractionActive(this._context.unitId))&&this._docSelectionManagerService.__replaceTextRangesWithNoRefresh(e,{unitId:this._context.unitId,subUnitId:this._context.unitId})}))}_initialMain(e){if(this.disposeWithMe((0,s.fromEvent)(this._context.engine.getCanvasElement(),`mousedown`).subscribe(e=>{e.button===0&&this._docSelectionRenderService.isFocusing&&e.preventDefault()})),(0,t.isInternalEditorID)(e)){this._initialEditor(e);return}let{document:n,scene:r}=x(this._context);this._docSelectionRenderService.exitMobileEditMode(),this.disposeWithMe(r.onPointerDown$.subscribeEvent((e,t)=>{e.cancelable&&e.preventDefault(),this._startGesture(e,this._docSelectionRenderService.isMobileEditMode,this._getDocumentOffset(e),!1),t.stopPropagation()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((n,r)=>{var i;if(this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(n,e))return;let a=this._instanceSrv.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(a==null?void 0:a.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e),(i=this._editorService.getEditorRenderConfig(e))!=null&&i.preserveHostFocus||this._instanceSrv.focusUnit(e);let o=this._getDocumentOffset(n);this._syncEditArea(o.offsetX,o.offsetY),n.cancelable&&n.preventDefault(),this._startGesture(n,this._docSelectionRenderService.isMobileEditMode,o),n.button!==2&&r.stopPropagation()}))}_initialEditor(e){let{document:n,scene:i}=x(this._context);this.disposeWithMe(n.onPointerEnter$.subscribeEvent(()=>{this._isEditorReadOnly(e)||(n.cursor=r.CURSOR_TYPE.TEXT)})),this.disposeWithMe(n.onPointerLeave$.subscribeEvent(()=>{n.cursor=r.CURSOR_TYPE.DEFAULT,i.resetCursor()})),this.disposeWithMe(n.onPointerDown$.subscribeEvent((n,r)=>{var i;if(this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(n,e))return;let a=this._instanceSrv.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);(a==null?void 0:a.getUnitId())!==e&&this._instanceSrv.setCurrentUnitForType(e),e!==t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&e!==t.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&!((i=this._editorService.getEditorRenderConfig(e))!=null&&i.preserveHostFocus)&&this._instanceSrv.focusUnit(e);let{offsetX:o,offsetY:s}=n;this._syncEditArea(o,s),this._docSelectionRenderService.__onPointDown(n,!0),this._editorService.getEditor(e)&&(this._setEditorFocus(e),this._deferredEditorFocusTimer!=null&&clearTimeout(this._deferredEditorFocusTimer),this._deferredEditorFocusTimer=setTimeout(()=>{this._deferredEditorFocusTimer=null,!(e===this._editorService.getFocusId()||this._docSelectionRenderService.isOnPointerEvent)&&(this._setEditorFocus(e),this._docSelectionRenderService.setCursorManually(o,s))},0)),n.button!==2&&r.stopPropagation()})),this.disposeWithMe(n.onDblclick$.subscribeEvent(t=>{this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(t,e)||(this._editorService.getEditor(e)&&this._setEditorFocus(e),this._docSelectionRenderService.__handleDblClick(t))})),this.disposeWithMe(n.onTripleClick$.subscribeEvent(t=>{this._isEditorReadOnly(e)||this._isEmbedInteractionEvent(t,e)||this._docSelectionRenderService.__handleTripleClick(t)}))}dispose(){this._clearGesture(),this._stopInertia(),this._deferredEditorFocusTimer!=null&&(clearTimeout(this._deferredEditorFocusTimer),this._deferredEditorFocusTimer=null),super.dispose()}_syncEditArea(e,t){let n=this._getTransformCoordForDocumentOffset(e,t);if(n==null)return;let{document:i}=x(this._context),{pageLayoutType:a=r.PageLayoutType.VERTICAL,pageMarginLeft:o,pageMarginTop:s}=i.getOffsetConfig(),{editArea:c}=this._docSkeletonManagerService.getSkeleton().findEditAreaByCoord(n,a,o,s),l=this._docSkeletonManagerService.getViewModel(),u=l.getEditArea();u!==r.DocumentEditArea.BODY&&c!==r.DocumentEditArea.BODY&&c!==u&&l.setEditArea(c)}_startGesture(e,n,r,i=!0){this._clearGesture(),this._stopInertia();let a=i?this._mobileElementMenuService.takeTarget(this._context.unitId):null;this._mobileElementMenuService.close(),this._contextMenuService.visible&&this._contextMenuService.hideContextMenu();let o=this._context.scene,s=o.getViewport(`viewMain`)??o.getViewports()[0],c=this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.MODERN,{x:l,y:u}=_y(e),[d,f]=[l,u],p=!1,m=!1,h=yy(c),g=this._docSelectionRenderService.getActiveTextRange(),_=g!=null&&g.collapsed?g.startOffset??null:null,v=this._docSelectionRenderService.isFocusing;i&&!(a!=null&&a.onTap)&&!(a!=null&&a.onDrag)&&(this._gestureTimer=setTimeout(()=>{this._gestureTimer=null,!this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)&&(m=!0,this._selectWord(e,n))},420));let y=o.onPointerMove$.subscribeEvent(e=>{if(m||this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`))return;let{x:t,y:n}=_y(e),r=t-d,i=n-f;!p&&Math.hypot(t-l,n-u)<12||(p=!0,this._lastTap=null,this._clearGestureTimer(),a!=null&&a.onDrag?a.onDrag(e):(this._scrollDocument(s,c,r,i),h.track(r,i)),d=t,f=n)}),b=o.onPointerUp$.subscribeEvent(()=>{if(this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)){this._clearGesture();return}i&&!p&&!m&&(a?a.onTap?a.onTap(r):this._mobileElementMenuService.show(a):this._handleTap(e,r,n,v,_)),p&&!(a!=null&&a.onDrag)&&this._startInertia(s,h.getVelocity()),this._clearGesture()}),x=o.onPointerCancel$.subscribeEvent(()=>this._clearGesture());this._gestureDisposables=[y,b,x]}_handleTap(e,t,n,r,i){var a;let{offsetX:o,offsetY:s}=t;if((a=this._context.scene.getTransformer())==null||a.clearSelectedObjects(),n){this._docSelectionRenderService.setCursorManually(o,s,!0,!0,{strict:!1});let t=this._docSelectionRenderService.getActiveTextRange();r&&i!=null&&t!=null&&t.collapsed&&t.startOffset===i&&this._showCaretMenu(e);return}let c=Date.now(),l=this._lastTap;l!=null&&c-l.time<=450&&Math.hypot(o-l.x,s-l.y)<=28?(this._lastTap=null,this._enterEditing(this._context.unitId,e)):this._lastTap={x:o,y:s,time:c}}_selectWord(e,t){var n;(n=this._context.scene.getTransformer())==null||n.clearSelectedObjects(),this._lastTap=null,this._docSelectionRenderService.__handleDblClick(e,!1,!1),t&&this._docSelectionRenderService.suspendMobileEditingInput()}_scrollDocument(e,t,n,r){let{scaleX:i,scaleY:a}=this._context.scene;e==null||e.scrollByViewportDeltaVal({viewportScrollX:t?0:vy(-n,i),viewportScrollY:vy(-r,a)})}_startInertia(e,t){if(this._inertiaVelocity={x:Math.max(-12,Math.min(12,t.x)),y:Math.max(-12,Math.min(12,t.y))},Math.hypot(this._inertiaVelocity.x,this._inertiaVelocity.y)<=hy*2)return;this._inertiaLastFrameTime=0;let n=t=>{if(this._inertiaLastFrameTime===0){this._inertiaLastFrameTime=t,this._inertiaAnimationId=requestAnimationFrame(n);return}let r=t-this._inertiaLastFrameTime;this._inertiaLastFrameTime=t;let i=.992,a=i**r;this._inertiaVelocity.x*=a,this._inertiaVelocity.y*=a;let o=-Math.log(i),{scaleX:s,scaleY:c}=this._context.scene;e==null||e.scrollByViewportDeltaVal({viewportScrollX:vy(this._inertiaVelocity.x*(1-a)/o,s),viewportScrollY:vy(this._inertiaVelocity.y*(1-a)/o,c)}),Math.hypot(this._inertiaVelocity.x,this._inertiaVelocity.y)>hy?this._inertiaAnimationId=requestAnimationFrame(n):(this._inertiaAnimationId=null,this._inertiaLastFrameTime=0)};this._inertiaAnimationId=requestAnimationFrame(n)}_stopInertia(){this._inertiaAnimationId!=null&&cancelAnimationFrame(this._inertiaAnimationId),this._inertiaAnimationId=null,this._inertiaLastFrameTime=0,this._inertiaVelocity={x:0,y:0}}_enterEditing(e,t){this._editorService.getEditor(e)&&this._setEditorFocus(e),this._docSelectionRenderService.enterMobileEditMode();let{offsetX:n,offsetY:r}=this._getDocumentOffset(t);this._docSelectionRenderService.setCursorManually(n,r,!0,!0,{strict:!1})}_getDocumentOffset(e){let t=this._context.scene.getEngine(),n=t==null?void 0:t.getCanvasElement();if(!t||!n||!Number.isFinite(e.clientX)||!Number.isFinite(e.clientY))return{offsetX:e.offsetX,offsetY:e.offsetY};let r=n.getBoundingClientRect();return r.width<=0||r.height<=0?{offsetX:e.offsetX,offsetY:e.offsetY}:{offsetX:(e.clientX-r.left)*t.width/r.width,offsetY:(e.clientY-r.top)*t.height/r.height}}_showCaretMenu(e){let t=my(e,null);this._contextMenuService.triggerContextMenu({clientX:(t==null?void 0:t.clientX)??e.offsetX,clientY:(t==null?void 0:t.clientY)??e.offsetY,stopPropagation(){}},Lv,{caretAnchor:!0,unitId:this._context.unitId,subUnitId:this._context.unitId})}_clearGestureTimer(){this._gestureTimer!=null&&(clearTimeout(this._gestureTimer),this._gestureTimer=null)}_clearGesture(){this._clearGestureTimer(),this._gestureDisposables.forEach(e=>e.unsubscribe()),this._gestureDisposables=[]}_getTransformCoordForDocumentOffset(e,t){let{document:n,scene:i}=x(this._context),{documentTransform:a}=n.getOffsetConfig(),o=i.getViewports()[0];if(o==null)return;let s=o.transformVector2SceneCoord(r.Vector2.FromArray([e,t]));return a.clone().invert().applyPoint(s)}_isEditorReadOnly(e){var t;return((t=this._editorService.getEditor(e))==null?void 0:t.isReadOnly())??!1}_setEditorFocus(e){this._editorService.focus(e)}_isEmbedInteractionEvent(e,n){var r,i,a;if((0,t.isInternalEditorID)(n))return!1;let o=e.target;return(r=this._embedRuntimeFocusCoordinator)!=null&&r.isChildUnitRuntimeEvent(n,o,e)||(i=this._embedRuntimeFocusCoordinator)!=null&&i.isChildUnitInActiveSession(n)?!1:(a=this._embedRuntimeFocusCoordinator)!=null&&a.shouldSuppressHostInteraction(n,o,e)?!0:py(e)}_isEmbedChildInteractionActive(e){var t;return((t=this._embedRuntimeFocusCoordinator)==null?void 0:t.shouldSuppressHostInteraction(e))===!0}_commandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{var n;if(!e.includes(t.id))return;let{unitId:r}=t.params;this._contextService.getContextValue(`MOBILE_DOC_PINCH_ZOOMING`)||r!==((n=this._docSelectionManagerService.__getCurrentSelection())==null?void 0:n.unitId)||this._isEmbedChildInteractionActive(r)||this._docSelectionManagerService.refreshSelection()}))}_skeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(!e||this._initialSelectionReady)return;let{unitId:n}=this._context;if((0,t.isInternalEditorID)(n)||this._isEmbedChildInteractionActive(n))return;this._initialSelectionReady=!0;let i=Tc(this._context.unit.getSnapshot()),a={unitId:n,subUnitId:n};this._docSelectionManagerService.replaceSelectionInfoWithoutRefresh({textRanges:[{startOffset:i,endOffset:i,collapsed:!0,isActive:!0}],rectRanges:[],segmentId:``,segmentPage:-1,isEditing:!1,style:r.NORMAL_TEXT_SELECTION_PLUGIN_STYLE},a),this._docSelectionManagerService.refreshSelection(a,!1),this._docSelectionRenderService.getActiveTextRange()??this.disposeWithMe(e.layoutProgress$.pipe((0,s.filter)(e=>(e==null?void 0:e.anchorReady)===!0||(e==null?void 0:e.complete)===!0),(0,s.take)(1)).subscribe(()=>this._docSelectionManagerService.refreshSelection(a,!1)))}))}};gy=B([z(1,t.ICommandService),z(2,J),z(3,t.IUniverInstanceService),z(4,(0,t.Inject)(q)),z(5,(0,t.Inject)(n.DocSkeletonManagerService)),z(6,(0,t.Inject)(n.DocSelectionManagerService)),z(7,t.IContextService),z(8,a.IContextMenuService),z(9,(0,t.Inject)(qv)),z(10,(0,t.Optional)(Ie)),z(11,(0,t.Optional)(Le))],gy);function _y(e){let t=my(e,null);return{x:(t==null?void 0:t.clientX)??e.offsetX,y:(t==null?void 0:t.clientY)??e.offsetY}}function vy(e,t){return e/(Number.isFinite(t)&&t>0?t:1)}function yy(e){let t=performance.now(),n=t,r=[],i={x:0,y:0};return{track(t,a){let o=performance.now(),s=o-n;if(n=o,s<=0)return;let c=e?0:-t,l=-a;r.push({x:c/s*16,y:l/s*16}),r.length>5&&r.shift(),i.x+=Math.abs(c),i.y+=Math.abs(l)},getVelocity:()=>by(r,performance.now()-t,i)}}function by(e,t,n){if(e.length===0)return{x:0,y:0};let r=0,i=0,a=0;e.forEach((e,t)=>{let n=(t+1)**2;r+=n,i+=e.x*n,a+=e.y*n}),i/=r,a/=r;let o=Math.hypot(n.x,n.y),s=Math.hypot(i,a),c=t>0?o/t:0,l=t<240&&o>30,u=.05*(.5+Math.min(s/5,1)*.5);return l&&(u=.05+(.26-.05)*Math.min(c/2,1),t<150&&s>3&&(u*=1.3)),u=Math.max(.025,Math.min(.39,u)),n.x>n.y?{x:i*u,y:0}:{x:0,y:a*u}}let xy=class extends Cc{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(e,t,n,r,i,a,o,s,c,l,u,d,f,p),R(this,`_mobileModernPageWidth`,void 0),this._mobileModernPageWidth=this._getMobileModernLayoutOptions().modernPageWidth,this._initResponsiveLayout()}_scheduleLayout(e,t,n,r=!0,i=!1){let a={...n,...this._getMobileModernLayoutOptions()};this._mobileModernPageWidth=a.modernPageWidth,super._scheduleLayout(e,t,a,r,i)}_shouldEnableHorizontalScrollBar(){return this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN&&super._shouldEnableHorizontalScrollBar()}_getMobileModernLayoutOptions(){var e;if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.MODERN)return{};let n=(e=this._context.scene.getParent())==null?void 0:e.width,r=n!=null&&n>1?n:this._context.engine.width;return!Number.isFinite(r)||r<=24?{}:{modernPageWidth:r-24,modernHorizontalMargin:super._getHorizontalPageMargin()}}_initResponsiveLayout(){this._context.unit.getSnapshot().documentStyle.documentFlavor===t.DocumentFlavor.MODERN&&this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler),(0,s.takeUntil)(this.dispose$)).subscribe(()=>{let e=this._getMobileModernLayoutOptions().modernPageWidth;if(e==null||Math.abs(e-(this._mobileModernPageWidth??0))<1)return;let t=this._docSkeletonManagerService.getSkeleton();t&&this._scheduleLayout(this._context.unitId,t,{reason:`initial`})}))}_getHorizontalPageMargin(){return 12}};xy=B([z(1,t.ICommandService),z(2,(0,t.Inject)(q)),z(3,(0,t.Inject)(n.DocSkeletonManagerService)),z(4,J),z(5,r.IRenderManagerService),z(6,t.IUniverInstanceService),z(7,(0,t.Inject)(Hs)),z(8,(0,t.Inject)(n.DocSelectionManagerService)),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Inject)(t.ThemeService)),z(11,(0,t.Inject)(n.DocLayoutExecutorService)),z(12,(0,t.Inject)(Ps)),z(13,t.ILogService)],xy);function Sy(e,t,n){return t&&(e.ctrlKey||e.metaKey)}let Cy=class extends t.Disposable{constructor(e,n,r,i,a,o,s,c,l,u,d){super(),this._context=e,this._contextService=n,this._docSkeletonManagerService=r,this._univerInstanceService=i,this._commandService=a,this._textSelectionManagerService=o,this._editorService=s,this._docPageLayoutService=c,this._renderManagerService=l,this._docViewScaleService=u,this._embedInteractionBoundaryService=d,R(this,`_isSheetEditor`,!1),R(this,`_initTimer`,void 0),R(this,`_updateTimer`,void 0),R(this,`_fitToWidthAvailableWidth`,0),this._initSkeletonListener(),this._initCommandExecutedListener(),this._initFitToWidthResizeListener(),this._isSheetEditor=this._context.unitId===t.DOCS_NORMAL_EDITOR_UNIT_ID_KEY;let f=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),p=f&&this._renderManagerService.getRenderUnitById(f.getUnitId());this._initTimer=window.setTimeout(()=>{let e=p&&this._isSheetEditor?p.scene.scaleX:Fs(this._context.unit);this.updateViewZoom(e,!0)},20),(0,t.isInternalEditorID)(this._context.unitId)||this._initZoomEventListener()}dispose(){window.clearTimeout(this._initTimer),window.clearTimeout(this._updateTimer),super.dispose()}_initSkeletonListener(){this.disposeWithMe(this._docSkeletonManagerService.currentSkeleton$.subscribe(e=>{if(e==null)return;let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);n&&(this._updateTimer=window.setTimeout(()=>{let e=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e&&this._renderManagerService.getRenderUnitById(e.getUnitId()),i=this._isSheetEditor?(r==null?void 0:r.scene.scaleX)||1:Fs(n);this.updateViewZoom(i,!1)}))}))}_initCommandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)&&t.params.unitId===this._context.unitId){let e=this._context.unit,t=Fs(e);this.updateViewZoom(t)}})),this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{var n;(e.id===No.id||e.id===kl.id&&((n=e.params)==null?void 0:n.documentFlavor)===t.DocumentFlavor.MODERN)&&this._commandService.executeCommand(yo.id,{zoomRatio:1,documentId:this._context.unitId})}))}_initFitToWidthResizeListener(){this.disposeWithMe((0,t.fromEventSubject)(this._context.engine.onTransformChange$).pipe((0,s.throttleTime)(0,s.animationFrameScheduler)).subscribe(()=>{if(this._docViewScaleService.getOptions().mode!==`fit-width`)return;let e=this._docViewScaleService.getAvailableWidth();e<=1||Math.abs(e-this._fitToWidthAvailableWidth)<1||(this._fitToWidthAvailableWidth=e,this.updateViewZoom(Fs(this._context.unit),!1))}))}updateViewZoom(e,n=!0){var r;let i=x(this._context),a=this._docViewScaleService.getViewScale(e),o=i.scene.scaleX!==a||i.scene.scaleY!==a;if(i.scene.scale(a,a),this._editorService.isEditor(this._context.unitId)||this._docPageLayoutService.calculatePagePosition(),n&&!this._editorService.isEditor(this._context.unitId)&&!((r=this._embedInteractionBoundaryService)!=null&&r.hasRecentInteraction())&&this._textSelectionManagerService.refreshSelection(),n&&o&&!(0,t.isInternalEditorID)(this._context.unitId)){var s;(s=i.scene.getTransformer())==null||s.clearSelectedObjects()}let c=this._univerInstanceService.getUnitCreateOptions(this._context.unitId);((c==null?void 0:c.embeddedRender)===!0||(c==null?void 0:c.skipAutoRender)===!0)&&(this._context.scene.makeDirty(),this._context.scene.render())}_initZoomEventListener(){let e=this._context.scene;this.disposeWithMe(e.onMouseWheel$.subscribeEvent(e=>{let n=this._univerInstanceService.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_DOC);if(!n)return;let{documentFlavor:i}=n.getSnapshot().documentStyle;if(!Sy(e,!!this._contextService.getContextValue(t.FOCUSING_DOC),i))return;let a=Fs(n),o=(0,r.getNextWheelZoomRatio)(a,e);this._commandService.executeCommand(yo.id,{zoomRatio:o,documentId:n.getUnitId()}),e.preventDefault()}))}};Cy=B([z(1,t.IContextService),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.IUniverInstanceService),z(4,t.ICommandService),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,J),z(7,(0,t.Inject)(Hs)),z(8,r.IRenderManagerService),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Optional)(Ie))],Cy);function wy(e,t,n){if(t<=0||!Number.isFinite(n))return e;let r=e*n/t;return Math.round(Math.max(.5,Math.min(3,r))*100)/100}var Ty=class extends t.Disposable{constructor(e){super(),this._options=e,R(this,`_zoomIndicator`,void 0),R(this,`_gestureOwned`,!1),R(this,`_pinchZooming`,!1),R(this,`_initialDistance`,0),R(this,`_initialZoomRatio`,1),R(this,`_anchor`,r.Vector2.Zero()),R(this,`_handleTouchStart`,e=>{let{contextService:t,docViewScaleService:n,scene:r,viewport:i}=this._options;if(e.touches.length!==2||r.objectsEvented===!1)return;this._gestureOwned=!0,this._pinchZooming=!0,t.setContextValue(Rv,!0);let[a,o]=e.touches;this._initialDistance=this._getTouchDistance(a,o),this._initialZoomRatio=n.getUserZoomRatio(),this._anchor=i.transformVector2SceneCoord(this._getPinchCenter(a,o)),this._zoomIndicator.show(Math.round(this._initialZoomRatio*100)),e.preventDefault()}),R(this,`_handleTouchMove`,e=>{if(!this._gestureOwned||!this._pinchZooming||e.touches.length!==2)return;let{commandService:t,docViewScaleService:n,unitId:r,viewport:i}=this._options,[a,o]=e.touches,s=wy(this._initialZoomRatio,this._initialDistance,this._getTouchDistance(a,o));Math.abs(s-n.getUserZoomRatio())>=.01&&t.syncExecuteCommand(vo.id,{unitId:r,zoomRatio:s});let c=i.transformVector2SceneCoord(this._getPinchCenter(a,o));i.scrollByViewportDeltaVal({viewportScrollX:this._anchor.x-c.x,viewportScrollY:this._anchor.y-c.y}),this._zoomIndicator.show(Math.round(s*100)),e.preventDefault()}),R(this,`_handleTouchEnd`,e=>{this._gestureOwned&&(e.touches.length<2&&this._pinchZooming&&(this._pinchZooming=!1,this._zoomIndicator.hide()),e.touches.length===0&&this._finishPinch())}),R(this,`_handleTouchCancel`,()=>this._finishPinch());let{canvasElement:n}=e;this._zoomIndicator=new a.MobileZoomIndicator(n),this.disposeWithMe(this._zoomIndicator),n.addEventListener(`touchstart`,this._handleTouchStart,{passive:!1}),n.addEventListener(`touchmove`,this._handleTouchMove,{passive:!1}),n.addEventListener(`touchend`,this._handleTouchEnd,{passive:!1}),n.addEventListener(`touchcancel`,this._handleTouchCancel,{passive:!1}),this.disposeWithMe((0,t.toDisposable)(()=>{n.removeEventListener(`touchstart`,this._handleTouchStart),n.removeEventListener(`touchmove`,this._handleTouchMove),n.removeEventListener(`touchend`,this._handleTouchEnd),n.removeEventListener(`touchcancel`,this._handleTouchCancel),this._finishPinch()}))}_getTouchPoint(e){let{canvasElement:t,engine:n}=this._options,i=t.getBoundingClientRect();return i.width<=0||i.height<=0?r.Vector2.FromArray([e.clientX-i.left,e.clientY-i.top]):r.Vector2.FromArray([(e.clientX-i.left)*n.width/i.width,(e.clientY-i.top)*n.height/i.height])}_getPinchCenter(e,t){let n=this._getTouchPoint(e),i=this._getTouchPoint(t);return r.Vector2.FromArray([(n.x+i.x)/2,(n.y+i.y)/2])}_getTouchDistance(e,t){let n=this._getTouchPoint(e),r=this._getTouchPoint(t);return Math.hypot(n.x-r.x,n.y-r.y)}_finishPinch(){this._gestureOwned&&(this._gestureOwned=!1,this._pinchZooming=!1,this._options.contextService.setContextValue(Rv,!1),this._zoomIndicator.hide(),this._options.textSelectionManagerService.refreshSelection())}};let Ey=class extends Cy{constructor(e,n,r,i,a,o,s,c,l,u,d){super(e,n,r,i,a,o,s,c,l,u,d),(0,t.isInternalEditorID)(e.unitId)||this._initGestureZoom()}_initCommandExecutedListener(){let e=[vo.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)&&t.params.unitId===this._context.unitId){let e=Fs(this._context.unit);this.updateViewZoom(e,!this._contextService.getContextValue(Rv))}})),this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{var n;(e.id===No.id||e.id===kl.id&&((n=e.params)==null?void 0:n.documentFlavor)===t.DocumentFlavor.MODERN)&&this._commandService.executeCommand(yo.id,{zoomRatio:1,documentId:this._context.unitId})}))}_initGestureZoom(){if(this._context.unit.getSnapshot().documentStyle.documentFlavor!==t.DocumentFlavor.TRADITIONAL)return;let e=this._context.scene,n=e.getEngine(),r=n==null?void 0:n.getCanvasElement(),i=e.getViewport(`viewMain`);n!=null&&r!=null&&i!=null&&this.disposeWithMe(new Ty({canvasElement:r,commandService:this._commandService,contextService:this._contextService,docViewScaleService:this._docViewScaleService,engine:n,scene:e,textSelectionManagerService:this._textSelectionManagerService,unitId:this._context.unitId,viewport:i}))}};Ey=B([z(1,t.IContextService),z(2,(0,t.Inject)(n.DocSkeletonManagerService)),z(3,t.IUniverInstanceService),z(4,t.ICommandService),z(5,(0,t.Inject)(n.DocSelectionManagerService)),z(6,J),z(7,(0,t.Inject)(Hs)),z(8,r.IRenderManagerService),z(9,(0,t.Inject)(Vs)),z(10,(0,t.Optional)(Ie))],Ey);let Dy=class{constructor(e){this._renderManagerService=e}transformChangeStateInfo(e){var t;let{isCompositionEnd:n,isSync:r,syncer:i}=e;if(!n)return e;let a=(t=this._renderManagerService.getRenderUnitById(r?i:e.unitId))==null?void 0:t.with(Ja);if(a==null)return null;let o=a.fetchComposedUndoRedoMutationParams();if(o==null)throw Error(`historyParams is null in RichTextEditingMutation`);let{undoMutationParams:s,redoMutationParams:c,previousActiveRange:l,previousDocRanges:u,previousSelectionOptions:d}=o;return{...e,redoState:{...e.redoState,...c.layoutState===void 0?{}:{layoutState:c.layoutState},actions:c.actions,textRanges:c.textRanges,options:c.options,isEditing:c.isEditing},undoState:{...e.undoState,...s.layoutState===void 0?{}:{layoutState:s.layoutState},actions:s.actions,textRanges:u.length?u:[l],options:d??void 0}}}};Dy=B([z(0,r.IRenderManagerService)],Dy);let Oy=(0,t.createInterceptorKey)(`PRINTING_COMPONENT_COLLECT`),ky=(0,t.createInterceptorKey)(`PRINTING_DOM_COLLECT`);var Ay=class extends t.Disposable{constructor(){super(),R(this,`_printComponentMap`,new Map),R(this,`_printPreparationHandlers`,new Set),R(this,`interceptor`,new t.InterceptorManager({PRINTING_COMPONENT_COLLECT:Oy,PRINTING_DOM_COLLECT:ky})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{priority:-1,handler:e=>e})),this.disposeWithMe(this.interceptor.intercept(this.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{priority:-1,handler:e=>e}))}registerPrintComponent(e,t){this._printComponentMap.set(e,t)}getPrintComponent(e){return this._printComponentMap.get(e)}getPageDrawingIds(e,t){var n,r;let i=e.getSkeletonData();if(!i||i.pages.length<=1||t==null)return null;let a=new Set,o=i.pages[t];if(!o)return a;jy(o,a);let s=(n=i.skeHeaders.get(o.headerId))==null?void 0:n.get(o.pageWidth),c=(r=i.skeFooters.get(o.footerId))==null?void 0:r.get(o.pageWidth);return s&&jy(s,a),c&&jy(c,a),a}registerPrintPreparation(e){return this._printPreparationHandlers.add(e),()=>this._printPreparationHandlers.delete(e)}async preparePrint(e){await Promise.all([...this._printPreparationHandlers].map(t=>t(e)))}dispose(){this._printPreparationHandlers.clear(),super.dispose()}};function jy(e,t){var n;for(let n of e.skeDrawings.keys())t.add(n);for(let n of e.notes??[])jy(n.page,t);for(let r of((n=e.skeColumnGroups)==null?void 0:n.values())??[])for(let e of r.columns)jy(e.page,t);for(let n of e.skeTables.values())for(let e of n.rows)for(let n of e.cells)jy(n,t)}let My=`univer-doc-main-canvas`;function Ny(e,t,n,r){return Se({documentFlavor:e,canvasColorService:t,editorBackgroundColor:n,isEditor:r}).canvasElementBackgroundColor}let Py=class extends t.RxDisposable{constructor(e,t){super(),this._instanceSrv=e,this._renderManagerService=t,this._init()}_init(){this._instanceSrv.getAllUnitsForType(t.UniverInstanceType.UNIVER_DOC).forEach(e=>this._createRenderer(e,this._instanceSrv.getUnitCreateOptions(e.getUnitId())??void 0)),this._instanceSrv.getTypeOfUnitAdded$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>this._createRenderer(e.unit,e.options)),this._instanceSrv.getTypeOfUnitDisposed$(t.UniverInstanceType.UNIVER_DOC).pipe((0,s.takeUntil)(this.dispose$)).subscribe(e=>this._disposeRenderer(e))}_createRenderer(e,t){if(t!=null&&t.skipAutoRender)return;let n=e.getUnitId();if(!this._renderManagerService.has(n)){this._createRenderWithId(n,e);return}let r=this._renderManagerService.getRenderUnitById(n);r&&this._syncRendererCanvas(r,e)}_createRenderWithId(e,t){let n=this._renderManagerService.createRender(e);t&&this._syncRendererCanvas(n,t)}_syncRendererCanvas(e,n){let r=n.getUnitId(),i=n.getSnapshot().documentStyle.documentFlavor,a=e.engine.getCanvas();a.setId(My),a.getContext().setId(My),a.getCanvasEle().style.backgroundColor=Ny(i,e.engine.canvasColorService,void 0,(0,t.isInternalEditorID)(r))}_disposeRenderer(e){let t=e.getUnitId();this._renderManagerService.removeRender(t)}};Py=B([z(0,t.IUniverInstanceService),z(1,r.IRenderManagerService)],Py);let Fy=`univer.doc.float-menu`,Iy=[ou,ur.id,Qn.id,er.id,nr.id,ir.id,or.id,cr.id,mr.id,{id:br.id,iconColor:`var(--univer-primary-600)`}];function Ly(e,t){let n=e.getMenuByPositionKey(su),r=[...e.getFlatMenuByPositionKey(su),...e.getFlatMenuByPositionKey(a.MenuManagerPosition.RIBBON)],i=[],o=t.map(e=>typeof e==`string`?e:e.id);for(let e of t){let t=typeof e==`string`?e:e.id,n=r.find(e=>e.key===t);n&&i.push(typeof e==`string`?n:{...n,iconColor:e.iconColor})}return{menus:i,extraMenus:n.filter(e=>e.item&&!o.includes(e.key))}}function Ry(e){var t,n;let{avaliableMenus:r=Iy}=e,o=(t=e.popup)==null||(t=t.extraProps)==null?void 0:t.onDismiss,s=(n=e.popup)==null||(n=n.extraProps)==null?void 0:n.onMount;(0,l.useEffect)(()=>s==null?void 0:s(),[s]);let c=(0,a.useDependency)(a.IMenuManagerService),d=(0,l.useRef)(null),f=(0,l.useRef)(!1),p=(0,l.useRef)(!1),[m,h]=(0,l.useState)([]),[g,_]=(0,l.useState)([]);(0,l.useEffect)(()=>{function e(){let{menus:e,extraMenus:t}=Ly(c,r);h(e),_(t)}e();let t=c.menuChanged$.subscribe(e);return()=>{t.unsubscribe()}},[r,c]),(0,l.useEffect)(()=>{let e=d.current;if(e)return(0,a.preventBrowserZoomInContainers)([e])},[]),(0,l.useEffect)(()=>{let e=d.current;if(!e||!o)return;let t=t=>{if(f.current||p.current||t.pointerType===`touch`)return;let n=e.getBoundingClientRect(),r=Math.max(n.left-t.clientX,t.clientX-n.right,n.top-t.clientY,t.clientY-n.bottom,0),i=Math.max(0,1-Math.max(0,r-10)/80);e.style.opacity=String(i),i===0&&(p.current=!0,o())};return e.ownerDocument.addEventListener(`pointermove`,t),()=>e.ownerDocument.removeEventListener(`pointermove`,t)},[o]);let v=()=>{f.current=!0,d.current&&(d.current.style.opacity=`1`)},y=m.filter(e=>e.key===`doc.menu.float-text-style`||e.key===ur.id),b=m.filter(e=>!y.includes(e));return(0,u.jsxs)(`div`,{ref:d,"data-doc-float-toolbar":!0,onPointerEnter:v,onFocusCapture:v,className:(0,i.clsx)(`univer-box-border univer-flex univer-flex-col univer-gap-1 univer-rounded univer-bg-gray-0 univer-p-1 univer-shadow-sm dark:!univer-border-gray-700 dark:!univer-bg-gray-900`,i.borderClassName),children:[(0,u.jsxs)(`div`,{className:`univer-flex univer-items-center univer-gap-1 [&_.univer-toolbar-selector-root]:univer-text-xs`,children:[y.map(e=>e.item&&(0,u.jsx)(`div`,{className:e.key===`doc.menu.float-text-style`?`
42
42
  univer-min-w-0 univer-flex-1
43
43
  [&_.univer-toolbar-selector-root]:univer-box-border
44
44
  [&_.univer-toolbar-selector-root]:univer-w-full