@univerjs/ui 0.20.0 → 0.20.1

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/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{BaselineOffset as e,BorderStyleTypes as t,ColorKit as n,CommandType as r,DependentOn as i,Disposable as a,DocumentDataModel as o,DocumentFlavor as s,EDITOR_ACTIVATED as c,ErrorService as l,FOCUSING_FX_BAR_EDITOR as u,FOCUSING_UNIVER_EDITOR as d,ICommandService as f,IConfigService as p,IConfirmService as m,IContextService as h,ILocalStorageService as g,ILogService as _,IUndoRedoService as v,IUniverInstanceService as y,Inject as b,Injector as x,LifecycleService as ee,LifecycleStages as te,LifecycleUnreachableError as S,LocaleService as C,NAMED_STYLE_MAP as ne,NamedStyleType as w,Optional as re,Plugin as T,RedoCommand as ie,SlideDataModel as ae,ThemeService as oe,Tools as se,UndoCommand as ce,UniverInstanceType as le,Workbook as ue,convertObservableToBehaviorSubject as de,createIdentifier as E,dedupeBy as fe,generateRandomId as pe,getBorderStyleType as me,isInternalEditorID as he,isRealNum as ge,merge as _e,mergeOverrideWithDependencies as ve,registerDependencies as ye,remove as be,throttle as xe,toDisposable as D,touchDependencies as Se}from"@univerjs/core";import{BehaviorSubject as O,Observable as Ce,ReplaySubject as we,Subject as Te,animationFrameScheduler as Ee,combineLatest as De,debounceTime as Oe,distinctUntilChanged as ke,filter as Ae,first as je,fromEvent as Me,isObservable as Ne,map as Pe,merge as Fe,of as Ie,scan as Le,startWith as Re,switchMap as ze,throttleTime as Be}from"rxjs";import{AddDigitsIcon as Ve,AddImageIcon as He,AdditionAndSubtractionIcon as Ue,AdjustHeightDoubleIcon as We,AdjustWidthDoubleIcon as Ge,AlignBottomIcon as Ke,AlignTextBothIcon as qe,AlignTopIcon as Je,AllBorderIcon as Ye,AmplifyIcon as Xe,AutoHeightDoubleIcon as Ze,AutoWidthDoubleIcon as Qe,AutowrapIcon as $e,AvgIcon as et,BackSlashDoubleIcon as tt,BoldIcon as nt,BrushIcon as rt,CancelFreezeIcon as it,CancelMergeIcon as at,CheckMarkIcon as ot,ClearFormatDoubleIcon as st,CloseIcon as ct,CntIcon as lt,CodeIcon as ut,ConditionsDoubleIcon as dt,CopyDoubleIcon as ft,CutIcon as pt,DatabaseIcon as mt,DeleteCellMoveDownDoubleIcon as ht,DeleteCellShiftLeftDoubleIcon as gt,DeleteCellShiftRightDoubleIcon as _t,DeleteCellShiftUpDoubleIcon as vt,DeleteColumnDoubleIcon as yt,DeleteRowDoubleIcon as bt,DirectExportIcon as xt,DollarIcon as St,DownBorderDoubleIcon as Ct,DownloadImageIcon as wt,EuroIcon as Tt,ExportIcon as Et,EyeIcon as Dt,EyeOutlineIcon as Ot,FolderIcon as kt,FontColorDoubleIcon as At,FontSizeIncreaseIcon as jt,FontSizeReduceIcon as Mt,FreezeColumnIcon as Nt,FreezeRowIcon as Pt,FreezeToSelectedIcon as Ft,FunctionIcon as It,GridIcon as Lt,HeaderFooterIcon as Rt,HideDoubleIcon as zt,HomeIcon as Bt,HorizontalBorderDoubleIcon as Vt,HorizontalMergeIcon as Ht,HorizontallyIcon as Ut,IncreaseIcon as Wt,InfoIcon as Gt,InnerBorderDoubleIcon as Kt,InsertCellDownDoubleIcon as qt,InsertCellShiftRightDoubleIcon as Jt,InsertDoubleIcon as Yt,InsertIcon as Xt,InsertRowAboveDoubleIcon as Zt,InsertRowBelowDoubleIcon as Qt,ItalicIcon as $t,KeyboardIcon as en,LeftBorderDoubleIcon as tn,LeftDoubleDiagonalDoubleIcon as nn,LeftInsertColumnDoubleIcon as rn,LeftJustifyingIcon as an,LeftRotationFortyFiveDegreesIcon as on,LeftRotationNinetyDegreesIcon as sn,LeftTridiagonalDoubleIcon as cn,MaxIcon as ln,MenuIcon as un,MergeAllIcon as dn,MinIcon as fn,MoreDownIcon as pn,MoreFunctionIcon as mn,MoreIcon as hn,MoreLeftIcon as gn,MoreRightIcon as _n,NoBorderIcon as vn,NoColorDoubleIcon as yn,NoRotationIcon as bn,OrderIcon as xn,OuterBorderDoubleIcon as Sn,OverflowIcon as Cn,PaintBucketDoubleIcon as wn,PasteSpecialDoubleIcon as Tn,PercentIcon as En,PipingIcon as Dn,RedoIcon as On,ReduceDigitsIcon as kn,ReduceDoubleIcon as An,ReduceIcon as jn,RightBorderDoubleIcon as Mn,RightDoubleDiagonalDoubleIcon as Nn,RightInsertColumnDoubleIcon as Pn,RightJustifyingIcon as Fn,RightRotationFortyFiveDegreesIcon as In,RightRotationNinetyDegreesIcon as Ln,RmbIcon as Rn,RoubleIcon as zn,ShortcutIcon as Bn,SlashDoubleIcon as Vn,StrikethroughIcon as Hn,SubscriptIcon as Un,SumIcon as Wn,SuperscriptIcon as Gn,TruncationIcon as Kn,UnderlineIcon as qn,UndoIcon as Jn,UnorderIcon as Yn,UpBorderDoubleIcon as Xn,VerticalBorderDoubleIcon as Zn,VerticalCenterIcon as Qn,VerticalIntegrationIcon as $n,VerticalTextIcon as er}from"@univerjs/icons";import{Fragment as tr,cloneElement as nr,createContext as rr,createElement as ir,forwardRef as ar,memo as or,useCallback as sr,useContext as cr,useEffect as k,useImperativeHandle as lr,useLayoutEffect as ur,useMemo as A,useRef as j,useState as M}from"react";import{RediConsumer as dr,RediContext as fr,RediProvider as pr,WithDependency as mr,connectDependencies as hr,connectInjector as N,useDependency as P,useDependency as gr,useInjector as _r,useObservable as F,useUpdateBinder as vr}from"@wendellhu/redi/react-bindings";import{Fragment as yr,jsx as I,jsxs as L}from"react/jsx-runtime";import{Button as br,ColorPicker as xr,ConfigContext as Sr,ConfigProvider as Cr,Confirm as wr,Dialog as Tr,Dropdown as Er,DropdownMenu as Dr,Gallery as Or,HoverCard as kr,InputNumber as Ar,KBD as jr,MessageType as Mr,Messager as Nr,Popup as Pr,Toaster as Fr,Tooltip as Ir,borderBottomClassName as Lr,borderClassName as Rr,borderLeftBottomClassName as zr,borderRightClassName as Br,clsx as R,divideXClassName as Vr,divideYClassName as Hr,isBrowser as Ur,message as Wr,removeMessage as Gr,render as Kr,resizeObserverCtor as qr,scrollbarClassName as Jr,toast as Yr,unmount as Xr}from"@univerjs/design";import{IRenderManagerService as Zr,UniverRenderEnginePlugin as Qr,ptToPx as $r}from"@univerjs/engine-render";import{map as ei,scan as ti,startWith as ni}from"rxjs/operators";import{createPortal as ri}from"react-dom";import ii from"localforage";function ai(e){"@babel/helpers - typeof";return ai=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ai(e)}function oi(e,t){if(ai(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ai(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function si(e){var t=oi(e,`string`);return ai(t)==`symbol`?t:t+``}function z(e,t,n){return(t=si(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ci=class extends a{constructor(...e){super(...e),z(this,`_open$`,new O(!1)),z(this,`open$`,this._open$.pipe(ke()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};const li=E(`ui.left-sidebar.service`),ui=E(`ui.sidebar.service`),di=`ShortcutPanel`,fi={id:`base-ui.operation.toggle-shortcut-panel`,type:r.OPERATION,handler:e=>{let t=e.get(ci),n=e.get(ui);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:`shortcut-panel.title`},children:{label:di}})),!0}},pi={AddDigitsIcon:Ve,AddImageIcon:He,AdditionAndSubtractionIcon:Ue,AdjustHeightDoubleIcon:We,AdjustWidthDoubleIcon:Ge,AlignBottomIcon:Ke,AlignTextBothIcon:qe,AlignTopIcon:Je,AllBorderIcon:Ye,AmplifyIcon:Xe,AutoHeightDoubleIcon:Ze,AutoWidthDoubleIcon:Qe,AutowrapIcon:$e,AvgIcon:et,BackSlashDoubleIcon:tt,BoldIcon:nt,BrushIcon:rt,CancelFreezeIcon:it,CancelMergeIcon:at,ClearFormatDoubleIcon:st,CntIcon:lt,CodeIcon:ut,ConditionsDoubleIcon:dt,CopyDoubleIcon:ft,CutIcon:pt,DeleteCellMoveDownDoubleIcon:ht,DeleteCellShiftLeftDoubleIcon:gt,DeleteCellShiftRightDoubleIcon:_t,DeleteCellShiftUpDoubleIcon:vt,DeleteColumnDoubleIcon:yt,DeleteRowDoubleIcon:bt,DirectExportIcon:xt,DollarIcon:St,DownBorderDoubleIcon:Ct,DownloadImageIcon:wt,EuroIcon:Tt,ExportIcon:Et,EyeOutlineIcon:Ot,FolderIcon:kt,FontColorDoubleIcon:At,FontSizeIncreaseIcon:jt,FontSizeReduceIcon:Mt,FreezeColumnIcon:Nt,FreezeRowIcon:Pt,FreezeToSelectedIcon:Ft,FunctionIcon:It,GridIcon:Lt,HeaderFooterIcon:Rt,HideDoubleIcon:zt,HorizontalBorderDoubleIcon:Vt,HorizontallyIcon:Ut,HorizontalMergeIcon:Ht,IncreaseIcon:Wt,InnerBorderDoubleIcon:Kt,InsertCellDownDoubleIcon:qt,InsertCellShiftRightDoubleIcon:Jt,InsertDoubleIcon:Yt,InsertRowAboveDoubleIcon:Zt,InsertRowBelowDoubleIcon:Qt,ItalicIcon:$t,KeyboardIcon:en,LeftBorderDoubleIcon:tn,LeftDoubleDiagonalDoubleIcon:nn,LeftInsertColumnDoubleIcon:rn,LeftJustifyingIcon:an,LeftRotationFortyFiveDegreesIcon:on,LeftRotationNinetyDegreesIcon:sn,LeftTridiagonalDoubleIcon:cn,MaxIcon:ln,MenuIcon:un,MergeAllIcon:dn,MinIcon:fn,MoreDownIcon:pn,NoBorderIcon:vn,NoColorDoubleIcon:yn,NoRotationIcon:bn,OrderIcon:xn,OuterBorderDoubleIcon:Sn,OverflowIcon:Cn,PaintBucketDoubleIcon:wn,PasteSpecialDoubleIcon:Tn,PercentIcon:En,PipingIcon:Dn,RedoIcon:On,ReduceDigitsIcon:kn,ReduceDoubleIcon:An,ReduceIcon:jn,RightBorderDoubleIcon:Mn,RightDoubleDiagonalDoubleIcon:Nn,RightInsertColumnDoubleIcon:Pn,RightJustifyingIcon:Fn,RightRotationFortyFiveDegreesIcon:In,RightRotationNinetyDegreesIcon:Ln,RmbIcon:Rn,RoubleIcon:zn,ShortcutIcon:Bn,SlashDoubleIcon:Vn,StrikethroughIcon:Hn,SubscriptIcon:Un,SumIcon:Wn,SuperscriptIcon:Gn,TruncationIcon:Kn,UnderlineIcon:qn,UndoIcon:Jn,UnorderIcon:Yn,UpBorderDoubleIcon:Xn,VerticalBorderDoubleIcon:Zn,VerticalCenterIcon:Qn,VerticalIntegrationIcon:$n,VerticalTextIcon:er};var B=class extends a{constructor(){super(),z(this,`_components`,new Map),z(this,`_componentsReverse`,new Map),z(this,`reactUtils`,{createElement:ir,useEffect:k,useRef:j}),z(this,`_handler`,{react:e=>e});for(let e in pi)this.register(e,pi[e]);this.disposeWithMe(D(()=>{for(let e in pi)this._components.delete(e),this._componentsReverse.delete(pi[e])}))}register(e,t,n){let{framework:r=`react`}=n||{};if(r===`vue3`&&!this._handler.vue3)throw Error(`[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.`);return this._components.has(e)&&console.warn(`Component ${e} already exists.`),this._components.set(e,{framework:r,component:t}),this._componentsReverse.set(t,e),D(()=>{this._components.delete(e),this._componentsReverse.delete(t)})}getKey(e){return this._componentsReverse.get(e)}setHandler(e,t){this._handler[e]=t}get(e){if(!e)return;let t=this._components.get(e);if(!t)return;let n=this._handler[t.framework];if(!n)throw Error(`[ComponentManager] No handler found for framework: ${t.framework}`);return n(t.component,e)}delete(e){this._components.delete(e)}},mi=class{constructor(){z(this,`_list`,new Map)}setIndex(e,t){this._list.set(e,t)}getIndex(e){return this._list.get(e)}removeIndex(e){this._list.delete(e)}getMaxIndex(){let e=-9999999;return this._list.forEach(t=>{+t>e&&(e=+t)}),e}};function hi(e,t,n,r){let i=e.get(y);return new Ce(e=>{let a=i.focused$.subscribe(a=>{if(a==null||n&&n!==a||r&&(Array.isArray(r)?r.includes(a):r===a))return e.next(!0);let o=i.getUnitType(a);e.next(o!==t)}),o=i.getFocusedUnit();if(o==null)return e.next(!0);let s=i.getUnitType(o.getUnitId());return e.next(s!==t),()=>a.unsubscribe()})}function gi(e){let t=e.get(y);return new Ce(e=>{let n=t.focused$.subscribe(n=>{if(n==null)return e.next(!0);let r=t.getUniverDocInstance(n),i=r==null?void 0:r.getSnapshot().documentStyle.documentFlavor;e.next(i!==s.TRADITIONAL)}),r=t.getCurrentUniverDocInstance();if(r==null)return e.next(!0);let i=r==null?void 0:r.getSnapshot().documentStyle.documentFlavor;return e.next(i!==s.TRADITIONAL),()=>n.unsubscribe()})}function _i(e,t){return!t||!e?e:([`type`,`icon`,`title`,`tooltip`].forEach(n=>{t[n]!==void 0&&(e[n]=t[n])}),[`hidden`,`disabled`,`activated`].forEach(n=>{vi(e,`${n}$`,t[n])}),e)}function vi(e,t,n){n!==void 0&&(e[t]?e[t]=e[t].pipe(ze(()=>new O(n))):e[t]=new Ce(e=>{e.next(n)}))}function yi(e){return typeof e==`function`?e():e}function bi(e,t){let n=j(t);return k(()=>{if(e){let t=yi(e).subscribe(e=>{n.current=e});return()=>t.unsubscribe()}},[e]),n}const xi=e=>{let{value:t,selections:n}=e,r=P(C);return I(`div`,{className:`univer-truncate univer-text-sm`,children:A(()=>{var e,i;return t==null?``:r.t((e=(i=n.find(e=>e.value===t))==null?void 0:i.label)==null?``:e)},[t,n])})},Si=`UI_PLUGIN_COMMON_LABEL_COMPONENT`;function V(e){let{className:t,title:r,icon:i,label:a,value:o,value$:s}=e,c=P(C),l=P(B),[u,d]=M(o),[f,p]=M(``),m=[],h=0;k(()=>{if(s){let e=s.subscribe(e=>{d(e)});return()=>{e.unsubscribe()}}},[s]);let g=A(()=>o==null?u:o,[u,o]);k(()=>{let e=null;return Ne(i)?e=i.subscribe(e=>{p(e)}):p(i==null?``:i),()=>{e==null||e.unsubscribe()}},[i]);let _=A(()=>g&&typeof g==`string`?new n(g).isValid:!1,[g]);if(i){let e=l.get(f==null?``:f);e&&m.push(I(e,{className:`univer-text-base`,extend:{colorChannel1:_?g:`var(--univer-primary-600)`}},h++))}if(a){let n=typeof a==`string`,r=n?{...e}:{...a==null?void 0:a.props,...e},i=n?a:a==null?void 0:a.name,o=l.get(i);o?m.push(I(o,{...r,className:t,value:g},h++)):m.push(I(`span`,{className:t,children:c.t(i)},h++))}return r&&m.push(I(`span`,{className:t,children:typeof r==`string`?c.t(r):r},h++)),I(yr,{children:m})}const Ci=e=>{var t,n;let{value:r,text:i}=e,a=ne[r],o=P(C);return I(`span`,{className:R(`univer-text-sm`,{"univer-font-bold":a==null?void 0:a.bl}),style:{fontSize:a==null?void 0:a.fs,color:(t=a==null||(n=a.cl)==null?void 0:n.rgb)==null?void 0:t},children:o.t(i)})},wi=`UI_COMPONENT_HEADING_ITEM`;function Ti(e){let t=j(e);return t.current=e,sr(((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}function Ei(e,t){let n=Ti(()=>{if(!e||!t)return;let n=e.style,{y:r,height:i}=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=e.scrollHeight>i,s=r<0||r+i>a.height;if(!s&&!o){n.overflowY=``,n.maxHeight=``;return}s&&(n.overflowY=`auto`,n.maxHeight=r<0?`${e.scrollHeight+r}px`:`${a.height-r}px`)});k(()=>{if(!Ur()||!e||!t)return;n();let r=qr(n);return r.observe(e),()=>{r.unobserve(e)}},[e,t])}function Di(e){let t=P(p);return F(A(()=>t.subscribeConfigValue$(e),[t]),t.getConfig(e))}function Oi(e){P(C);let t=P(B),{value:n,min:r=0,max:i=400,disabled:a=!1,resetPoint:o=100,shortcuts:s,onChange:c}=e,l=j(null),[u,d]=M(!1);function f(){a||c&&c(o)}function p(e){if(a)return;let t=n+e;n+e<=r?t=r:n+e>=i&&(t=i),c&&c(t)}let m=A(()=>{if(n<=o){let e=50/(o-r);return(n-r)*e}if(n<=i)return o*.5+(n-o)/(i-o)*50},[r,i,o,n]);function h(e){if(a)return;e.preventDefault();let t=l.current,n=!0;function s(e){if(n){let n=e.clientX-t.getBoundingClientRect().x;n<=0?n=0:n>=116&&(n=116);let a=n/116,s=0;s=a<=.5?r+a*(o-r)*2:o+(a-.5)*(i-o)*2,c&&c(Math.ceil(s))}}function u(){n=!1,document.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,u)}function d(e){e.relatedTarget===null&&u()}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,u),window.addEventListener(`pointerout`,d)}function g(e){a||(d(!1),c&&c(e))}let _=[{type:`radio`,value:n.toString(),options:s.map(e=>({value:e.toString(),label:`${e}%`})),onSelect:e=>g(+e)}],v=t.get(`ReduceIcon`),y=t.get(`IncreaseIcon`);return L(`div`,{className:R(`univer-flex univer-select-none univer-items-center univer-gap-1`,{"univer-cursor-not-allowed":a}),children:[I(br,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n<=r||a,onClick:()=>p(-10),children:I(v,{})}),I(`div`,{className:`univer-relative univer-hidden univer-h-0.5 univer-rounded-2xl univer-bg-gray-400 univer-px-1.5 sm:!univer-block`,style:{width:`116px`},children:L(`div`,{ref:l,role:`track`,className:`univer-relative univer-h-0.5`,children:[I(`a`,{className:`univer-absolute univer-left-1/2 univer-top-1/2 univer-box-border univer-block univer-size-0.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-cursor-pointer univer-rounded-full univer-bg-white`,role:`button`,onClick:f},`reset-button`),I(`button`,{className:R(`univer-absolute univer-top-[calc(50%-6px)] univer-size-3 -univer-translate-x-1/2 univer-rounded-full univer-border-none univer-bg-white univer-shadow univer-transition-colors`,{"hover:univer-gray-200 univer-cursor-pointer":!a,"univer-cursor-not-allowed":a}),role:`handle`,type:`button`,style:{left:`${m}%`},onPointerDown:h})]})}),I(br,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n>=i||a,onClick:()=>p(10),children:I(y,{})}),I(Dr,{align:`end`,items:_,open:u,onOpenChange:d,children:L(br,{size:`small`,variant:`text`,children:[n,`%`]})})]})}const ki=`UI_COLOR_PICKER_COMPONENT`,Ai=`ui.config`;Symbol(Ai);const ji={};function H(e,t){return function(n,r){t(n,r,e)}}function U(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const Mi=E(`univer.font-service`),Ni=[{value:`Arial`,label:`fontFamily.arial`,category:`sans-serif`},{value:`Times New Roman`,label:`fontFamily.times-new-roman`,category:`serif`},{value:`Tahoma`,label:`fontFamily.tahoma`,category:`sans-serif`},{value:`Verdana`,label:`fontFamily.verdana`,category:`sans-serif`},{value:`Microsoft YaHei`,label:`fontFamily.microsoft-yahei`,category:`sans-serif`},{value:`SimSun`,label:`fontFamily.simsun`,category:`serif`},{value:`SimHei`,label:`fontFamily.simhei`,category:`sans-serif`},{value:`Kaiti`,label:`fontFamily.kaiti`,category:`serif`},{value:`FangSong`,label:`fontFamily.fangsong`,category:`serif`},{value:`NSimSun`,label:`fontFamily.nsimsun`,category:`serif`},{value:`STXinwei`,label:`fontFamily.stxinwei`,category:`serif`},{value:`STXingkai`,label:`fontFamily.stxingkai`,category:`serif`},{value:`STLiti`,label:`fontFamily.stliti`,category:`serif`}];let Pi=class{constructor(e){this._configService=e,z(this,`fonts$`,new O([]));let t=this._configService.getConfig(Ai),{customFontFamily:n}=t==null?{}:t,r=[];r=n?Array.isArray(n)?[...Ni,...n]:n.override?[...n.list]:[...Ni,...n.list]:[...Ni],this.fonts$.next(r)}dispose(){this.resetToDefaults(),this.fonts$.complete()}getFonts(){return this.fonts$.getValue()}getFontByValue(e){return this.getFonts().find(t=>t.value===e)}isFontSupported(e){let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return!1;let n=`abcdefghijklmnopqrstuvwxyz0123456789`,r=`72px`,i=[`monospace`,`serif`,`sans-serif`],a={};return i.forEach(e=>{t.font=`${r} ${e}`,a[e]=t.measureText(n).width}),i.some(i=>(t.font=`${r} "${e}", ${i}`,t.measureText(n).width!==a[i]))}addFont(e){if(this.getFontByValue(e.value))throw Error(`[FontService]: Font with value "${e.value}" already exists.`);let t=[...this.getFonts(),e].sort();this.fonts$.next(t)}updateFont(e,t){let n=this.getFonts(),r=n.findIndex(t=>t.value===e);if(r===-1)throw Error(`Font with value "${e}" not found.`);let i={...n[r],...t},a=[...n];a[r]=i,this.fonts$.next(a)}removeFont(e){let t=this.getFonts();if(t.findIndex(t=>t.value===e)===-1)return!1;let n=t.filter(t=>t.value!==e);return this.fonts$.next(n),!0}resetToDefaults(){this.fonts$.next([...Ni])}};Pi=U([H(0,p)],Pi);const Fi=({id:e,value:t,disabled$:n})=>{let r=F(n),i=P(f),a=P(C),o=P(Mi),[s,c]=M(``),[l,u]=M([]);k(()=>{let e=o.fonts$.subscribe(e=>{u(e)});return()=>{e.unsubscribe()}},[]);let d=A(()=>{if(t==null)return``;let e=`${t==null?``:t}`.replace(/\s/g,``),n=l.find(t=>t.value===e);return n?a.t(n.label):a.t(t)},[t,l]);A(()=>{c(d)},[t]);function p(){c(t)}function m(e){c(e.target.value)}function h(e){e.stopPropagation(),!r&&(e.key===`Enter`?_():e.key===`Escape`&&(e.preventDefault(),p()))}function g(){s!==t&&p()}function _(){if(s.toLowerCase()===t.toLowerCase()){p();return}let e=l.find(e=>e.value.toLowerCase()===s.trim().toLowerCase());if(!e){p();return}v(e.value)}function v(t){i.executeCommand(e,{value:t})}return I(`div`,{className:`univer-w-32 univer-truncate univer-text-sm`,style:{fontFamily:t},children:I(`input`,{className:`univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 focus:univer-outline-none dark:!univer-text-white [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm`,type:`text`,value:s,onChange:m,onKeyDown:h,onBlur:g,disabled:r})})},Ii=({id:e,value:t})=>{let n=P(f),r=P(Mi),[i,a]=M([]);k(()=>{let e=r.fonts$.subscribe(e=>{a(e)});return()=>{e.unsubscribe()}},[]);let o=P(C);function s(t){n.executeCommand(e,{value:t})}return I(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-sm`,style:{fontFamily:t},children:i.map(e=>I(`li`,{children:L(`button`,{className:`univer-flex univer-h-7 univer-w-full univer-appearance-none univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-border-none univer-bg-transparent univer-px-2 hover:univer-bg-gray-100 dark:!univer-text-white dark:hover:!univer-bg-gray-700`,style:{fontFamily:e.value},type:`button`,onClick:()=>s(e.value),children:[o.t(e.label),!r.isFontSupported(e.value)&&I(Ir,{title:o.t(`fontFamily.not-supported`),children:I(Gt,{className:`univer-text-gray-300 dark:!univer-text-gray-400`})})]})},e.value))})},Li=`UI_FONT_FAMILY_COMPONENT`,Ri=`UI_FONT_FAMILY_ITEM_COMPONENT`,zi=e=>{let{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=F(a),[s,c]=M(Number(t==null?0:t)),l=A(()=>Number(t==null?s:t),[t]);function u(e){e!==null&&c(e)}function d(e){e.stopPropagation(),e.code===`Enter`&&i(s)}return I(`div`,{className:`univer-h-6 univer-w-7 univer-text-sm`,children:I(Ar,{className:`univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm`,value:l,controls:!1,min:n,max:r,onKeyDown:d,onChange:u,disabled:o})})},Bi=[{label:`9`,value:9},{label:`10`,value:10},{label:`11`,value:11},{label:`12`,value:12},{label:`14`,value:14},{label:`16`,value:16},{label:`18`,value:18},{label:`20`,value:20},{label:`22`,value:22},{label:`24`,value:24},{label:`26`,value:26},{label:`28`,value:28},{label:`36`,value:36},{label:`48`,value:48},{label:`72`,value:72}],Vi=[{label:`toolbar.heading.normal`,value:w.NORMAL_TEXT},{label:`toolbar.heading.title`,value:w.TITLE},{label:`toolbar.heading.subTitle`,value:w.SUBTITLE},{label:`toolbar.heading.1`,value:w.HEADING_1},{label:`toolbar.heading.2`,value:w.HEADING_2},{label:`toolbar.heading.3`,value:w.HEADING_3},{label:`toolbar.heading.4`,value:w.HEADING_4},{label:`toolbar.heading.5`,value:w.HEADING_5}],Hi=`UI_FONT_SIZE_COMPONENT`,Ui=(e,t)=>{let n=j(!1);k(()=>{if(n.current)return e();n.current=!0},t)};function Wi(e,t){let n=Ti(t.handler);k(()=>{let t=t=>{e.current&&t.target&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`mousedown`,t)}},[n,e])}function Gi(e,t=300){let n=j(null);return sr((...r)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(...r)},t)},[e,t])}const Ki=e=>typeof e==`number`;function qi(e){let t=j(e);return t.current=e,t}const Ji=(e,t)=>{let{containerTarget:n,itemHeight:r,overscan:i=5}=t,a=qi(r),[o,s]=M(null),c=j(!1),[l,u]=M([]),[d,f]=M({height:void 0,marginTop:void 0}),p=(t,n)=>{if(typeof a.current==`number`)return Math.ceil(t/a.current);let r=0,i=0;for(let o=n;o<e.length;o++){let n=a.current(o,e[o]);if(r+=n,i=o,r>=t)break}return i-n},m=t=>{if(Ki(a.current))return Math.floor(t/a.current);let n=0,r=0;for(let i=0;i<e.length;i++){let o=a.current(i,e[i]);if(n+=o,n>=t){r=i;break}}return r+1},h=t=>typeof a.current==`number`?t*a.current:e.slice(0,t).reduce((t,n,r)=>t+a.current(r,e[r]),0),g=A(()=>Ki(a.current)?e.length*a.current:e.reduce((t,n,r)=>t+a.current(r,e[r]),0),[e]),_=()=>{let t=n.current;if(t){let{scrollTop:n,clientHeight:r}=t,a=m(n),o=p(r,a),s=Math.max(0,a-i),c=Math.min(e.length,a+o+i),l=h(s);f({height:`${g-l}px`,marginTop:`${l}px`}),u(e.slice(s,c).map((e,t)=>({data:e,index:t+s})))}};return k(()=>{if(n.current){let e=()=>{let e=n.current.clientWidth,t=n.current.clientHeight;(e!==(o==null?void 0:o.width)||t!==(o==null?void 0:o.height))&&s({width:e,height:t})};e();let t=new ResizeObserver(e);return t.observe(n.current),()=>{t.disconnect()}}},[]),k(()=>{!(o!=null&&o.width)||!(o!=null&&o.height)||_()},[o==null?void 0:o.width,o==null?void 0:o.height,e]),[l,{wrapperStyle:d,scrollTo:Ti(e=>{let t=n.current;t&&(c.current=!0,t.scrollTop=h(e),_())}),containerProps:{onScroll:e=>{if(c.current){c.current=!1;return}e.preventDefault(),_()}}}]};function Yi(e,t,...n){return e.t(t)}function Xi(e){let{barColor:t,progress:n,onTerminate:r,onClearProgress:i}=e,{count:a,done:o,label:s=``}=n,c=j(null),[l,u]=M(!1);return k(()=>{let e=c.current;if(a===0&&o===0){u(!1),e.style.width=`0%`;return}else if(a>0){u(!0);let t=Math.floor(o/a*100);o===a?requestAnimationFrame(()=>{e.style.width=`${t-1}%`,requestAnimationFrame(()=>{e.style.width=`${t}%`})}):e.style.width=`${t}%`}let t=()=>{o===a&&(u(!1),i&&i())};return e.addEventListener(`transitionend`,t),()=>{e.removeEventListener(`transitionend`,t)}},[a,o]),L(`div`,{className:R(`univer-mx-2 univer-flex univer-items-center univer-gap-2`,{"univer-flex":l,"univer-hidden univer-w-0":!l}),children:[I(Ir,{showIfEllipsis:!0,title:s,children:I(`span`,{className:`univer-w-24 univer-truncate univer-text-right univer-text-xs`,children:s})}),I(`div`,{className:`univer-h-1 univer-w-40 univer-overflow-hidden univer-rounded-lg univer-bg-gray-200`,children:I(`div`,{ref:c,className:`univer-h-full univer-bg-primary-600 univer-transition-[width]`,style:{backgroundColor:t}})}),I(`button`,{className:`univer-flex univer-size-4 univer-cursor-pointer univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 hover:univer-opacity-50`,type:`button`,onClick:r,children:I(ct,{className:`univer-size-3.5 dark:!univer-text-white`})})]})}const Zi=`UNI_DISABLE_CHANGING_FOCUS`,Qi=E(`ui.message.service`);let $i=class extends a{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(this._errorService.error$.subscribe(e=>{this._messageService.show({content:e.errorKey,type:Mr.Error})}))}};$i=U([H(0,b(l)),H(1,Qi)],$i);const ea=`univer.command.copy`,ta={id:ea,name:ea,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:()=>!0},na=`univer.command.cut`,ra={id:na,name:na,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:async()=>!0},ia=`univer.command.paste`,aa={id:ia,name:ia,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:()=>!0},oa=`sheet.command.paste-by-short-key`;let W=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.BACKSPACE=8]=`BACKSPACE`,e[e.TAB=9]=`TAB`,e[e.ENTER=13]=`ENTER`,e[e.SHIFT=16]=`SHIFT`,e[e.CTRL=17]=`CTRL`,e[e.ESC=27]=`ESC`,e[e.SPACE=32]=`SPACE`,e[e.ARROW_LEFT=37]=`ARROW_LEFT`,e[e.ARROW_UP=38]=`ARROW_UP`,e[e.ARROW_RIGHT=39]=`ARROW_RIGHT`,e[e.ARROW_DOWN=40]=`ARROW_DOWN`,e[e.INSERT=45]=`INSERT`,e[e.DELETE=46]=`DELETE`,e[e.Digit0=48]=`Digit0`,e[e.Digit1=49]=`Digit1`,e[e.Digit2=50]=`Digit2`,e[e.Digit3=51]=`Digit3`,e[e.Digit4=52]=`Digit4`,e[e.Digit5=53]=`Digit5`,e[e.Digit6=54]=`Digit6`,e[e.Digit7=55]=`Digit7`,e[e.Digit8=56]=`Digit8`,e[e.Digit9=57]=`Digit9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.NUM_LOCK=144]=`NUM_LOCK`,e[e.SCROLL_LOCK=145]=`SCROLL_LOCK`,e[e.EQUAL=187]=`EQUAL`,e[e.COMMA=188]=`COMMA`,e[e.MINUS=189]=`MINUS`,e[e.PERIOD=190]=`PERIOD`,e[e.BACK_SLASH=220]=`BACK_SLASH`,e}({});const sa={[W.BACKSPACE]:`Backspace`,[W.TAB]:`Tab`,[W.ENTER]:`Enter`,[W.DELETE]:`Del`,[W.ESC]:`Esc`,[W.SPACE]:`Space`,[W.ARROW_LEFT]:`←`,[W.ARROW_RIGHT]:`→`,[W.ARROW_UP]:`↑`,[W.ARROW_DOWN]:`↓`,[W.Digit0]:`0`,[W.Digit1]:`1`,[W.Digit2]:`2`,[W.Digit3]:`3`,[W.Digit4]:`4`,[W.Digit5]:`5`,[W.Digit6]:`6`,[W.Digit7]:`7`,[W.Digit8]:`8`,[W.Digit9]:`9`,[W.A]:`A`,[W.B]:`B`,[W.C]:`C`,[W.D]:`D`,[W.E]:`E`,[W.F]:`F`,[W.G]:`G`,[W.H]:`H`,[W.I]:`I`,[W.J]:`J`,[W.K]:`K`,[W.L]:`L`,[W.M]:`M`,[W.N]:`N`,[W.O]:`O`,[W.P]:`P`,[W.Q]:`Q`,[W.R]:`R`,[W.S]:`S`,[W.T]:`T`,[W.U]:`U`,[W.V]:`V`,[W.W]:`W`,[W.X]:`X`,[W.Y]:`Y`,[W.Z]:`Z`,[W.F1]:`F1`,[W.F2]:`F2`,[W.F3]:`F3`,[W.F4]:`F4`,[W.F5]:`F5`,[W.F6]:`F6`,[W.F7]:`F7`,[W.F8]:`F8`,[W.F9]:`F9`,[W.F10]:`F10`,[W.F11]:`F11`,[W.F12]:`F12`,[W.MINUS]:`-`,[W.EQUAL]:`=`,[W.PERIOD]:`.`,[W.COMMA]:`,`,[W.BACK_SLASH]:`\\`};let G=function(e){return e[e.SHIFT=1024]=`SHIFT`,e[e.ALT=2048]=`ALT`,e[e.CTRL_COMMAND=4096]=`CTRL_COMMAND`,e[e.MAC_CTRL=8192]=`MAC_CTRL`,e}({});function ca(e,t,n){return window.addEventListener(e,t,n),D(()=>window.removeEventListener(e,t,n))}const la=[`app-layout`,`button`,`sheet-bar-append-button`,`render-canvas`,`workbench-layout`],ua=E(`ui.layout-service`);let da=class extends a{get isFocused(){return this._isFocused}constructor(e,t){super(),this._contextService=e,this._univerInstanceService=t,z(this,`_rootContainerElement`,null),z(this,`_isFocused`,!1),z(this,`_focusHandlers`,new Map),z(this,`_contentElements`,[]),z(this,`_allContainers`,[]),this._initUniverFocusListener(),this._initEditorStatus()}get rootContainerElement(){return this._rootContainerElement}focus(){let e=this._univerInstanceService.getFocusedUnit();if(!e)return;let t;e instanceof ue?t=this._focusHandlers.get(le.UNIVER_SHEET):e instanceof o?t=this._focusHandlers.get(le.UNIVER_DOC):e instanceof ae&&(t=this._focusHandlers.get(le.UNIVER_SLIDE)),t&&t(e.getUnitId())}registerFocusHandler(e,t){if(this._focusHandlers.has(e))throw Error(`[DesktopLayoutService]: handler of type ${e} bas been registered!`);return this._focusHandlers.set(e,t),D(()=>this._focusHandlers.delete(e))}registerContentElement(e){if(this._contentElements.indexOf(e)===-1)return this._contentElements.push(e),D(()=>be(this._contentElements,e));throw Error(`[DesktopLayoutService]: content container already registered!`)}getContentElement(){return this._contentElements[0]}registerRootContainerElement(e){if(this._rootContainerElement)throw Error(`[DesktopLayoutService]: root container already registered!`);this._rootContainerElement=e;let t=this.registerContainerElement(e);return D(()=>{this._rootContainerElement=null,t.dispose()})}registerContainerElement(e){if(this._allContainers.indexOf(e)===-1)return this._allContainers.push(e),D(()=>be(this._allContainers,e));throw Error(`[LayoutService]: container already registered!`)}checkElementInCurrentContainers(e){return this._allContainers.some(t=>t.contains(e))}checkContentIsFocused(){return this._contentElements.some(e=>e===document.activeElement||e.contains(document.activeElement))}_initUniverFocusListener(){this.disposeWithMe(Me(window,`focusin`).subscribe(e=>{var t;let n=e.target;if((t=this._rootContainerElement)!=null&&t.contains(n)&&la.some(e=>n.dataset.uComp===e)){queueMicrotask(()=>this.focus());return}n&&this.checkElementInCurrentContainers(n)?this._isFocused=!0:this._isFocused=!1,this._contextService.setContextValue(`FOCUSING_UNIVER`,this._isFocused),this._contextService.setContextValue(d,fa())}))}_initEditorStatus(){this._contextService.setContextValue(d,fa())}};da=U([H(0,h),H(1,y)],da);function fa(){var e;return((e=document.activeElement)==null?void 0:e.dataset.uComp)===`editor`}const pa=E(`ui.platform.service`);var ma=class{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}};const ha=E(`ui.shortcut.service`);let ga=class extends a{constructor(e,t,n,r){super(),this._commandService=e,this._platformService=t,this._contextService=n,this._layoutService=r,z(this,`_shortCutMapping`,new Map),z(this,`_commandIDMapping`,new Map),z(this,`_shortcutChanged$`,new Te),z(this,`shortcutChanged$`,this._shortcutChanged$.asObservable()),z(this,`_forceEscaped`,!1),z(this,`_forceDisabled`,!1),this.disposeWithMe(ca(`keydown`,e=>{this._resolveKeyboardEvent(e)},{capture:!0}))}getAllShortcuts(){return Array.from(this._shortCutMapping.values()).map(e=>Array.from(e.values())).flat()}registerShortcut(e){let t=this._getBindingFromItem(e);if(!t)return D(()=>{});let n=this._shortCutMapping.get(t);n?n.add(e):this._shortCutMapping.set(t,new Set([e]));let r=e.id,i=this._commandIDMapping.get(r);return i?i.add(e):this._commandIDMapping.set(r,new Set([e])),this._emitShortcutChanged(),D(()=>{var n,i,a,o;(n=this._shortCutMapping.get(t))==null||n.delete(e),((i=this._shortCutMapping.get(t))==null?void 0:i.size)===0&&this._shortCutMapping.delete(t),(a=this._commandIDMapping.get(r))==null||a.delete(e),((o=this._commandIDMapping.get(r))==null?void 0:o.size)===0&&this._commandIDMapping.delete(r),this._emitShortcutChanged()})}getShortcutDisplayOfCommand(e){let t=this._commandIDMapping.get(e);if(!t)return null;let n=t.values().next().value;return n?this.getShortcutDisplay(n):null}getShortcutDisplay(e){var t;let n=this._getBindingFromItem(e);if(!n)return null;let r=n&G.CTRL_COMMAND,i=n&G.SHIFT,a=n&G.ALT,o=n&G.MAC_CTRL,s=(t=sa[n&255])==null?`<->`:t;return this._platformService.isMac?`${r?`⌘+`:``}${i?`⇧+`:``}${a?`⌥+`:``}${o?`⌃+`:``}${s}`:`${r?`Ctrl+`:``}${i?`Shift+`:``}${a?`Alt+`:``}${s}`}_emitShortcutChanged(){this._shortcutChanged$.next()}forceEscape(){return this._forceEscaped=!0,D(()=>this._forceEscaped=!1)}forceDisable(){return this._forceDisabled=!0,D(()=>{this._forceDisabled=!1})}_resolveKeyboardEvent(e){let t=this.dispatch(e);t&&(this._commandService.executeCommand(t.id,t.staticParameters),e.preventDefault())}dispatch(e){if(this._forceEscaped||this._forceDisabled||this._layoutService&&!this._layoutService.checkElementInCurrentContainers(e.target))return;let t=this._deriveBindingFromEvent(e);if(t===null)return;let n=this._shortCutMapping.get(t);if(n!==void 0)return Array.from(n).sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)}).find(e=>{var t,n;return(t=(n=e.preconditions)==null?void 0:n.call(e,this._contextService))==null?!0:t})}_getBindingFromItem(e){return this._platformService.isMac&&e.mac?e.mac:this._platformService.isWindows&&e.win?e.win:this._platformService.isLinux&&e.linux?e.linux:e.binding}_deriveBindingFromEvent(e){let{shiftKey:t,metaKey:n,altKey:r,keyCode:i}=e,a=i;return t&&(a|=G.SHIFT),r&&(a|=G.ALT),(this._platformService.isMac?n:e.ctrlKey)&&(a|=G.CTRL_COMMAND),this._platformService.isMac&&e.ctrlKey&&(a|=G.MAC_CTRL),a}};ga=U([H(0,f),H(1,pa),H(2,h),H(3,re(ua))],ga);function _a(e){return e.getContextValue(d)}function va(e){return e.getContextValue(d)&&!(e.getContextValue(c)||e.getContextValue(u))}const ya={id:ta.id,description:`shortcut.copy`,group:`1_common-edit`,binding:W.C|G.CTRL_COMMAND,preconditions:_a},ba={id:ra.id,description:`shortcut.cut`,group:`1_common-edit`,binding:W.X|G.CTRL_COMMAND,preconditions:_a},xa={id:aa.id,description:`shortcut.paste`,group:`1_common-edit`,binding:W.V|G.CTRL_COMMAND,preconditions:()=>!1},Sa={id:ce.id,description:`shortcut.undo`,group:`1_common-edit`,binding:W.Z|G.CTRL_COMMAND,preconditions:va},Ca={id:ie.id,description:`shortcut.redo`,group:`1_common-edit`,binding:W.Y|G.CTRL_COMMAND,preconditions:va};let wa=class extends a{constructor(e,t){super(),this._shortcutService=e,this._commandService=t,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts()}_registerCommands(){[ra,ta,aa].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e)))}_registerShortcuts(){let e=[Sa,Ca];e.push(ba,ya,xa),e.forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}};wa=U([H(0,ha),H(1,f)],wa);let Ta=function(e){return e.RIBBON=`ribbon`,e.CONTEXT_MENU=`contextMenu`,e}({}),K=function(e){return e.START=`ribbon.start`,e.INSERT=`ribbon.insert`,e.FORMULAS=`ribbon.formulas`,e.DATA=`ribbon.data`,e.VIEW=`ribbon.view`,e.OTHERS=`ribbon.others`,e}({}),Ea=function(e){return e.HISTORY=`ribbon.start.history`,e.FORMAT=`ribbon.start.format`,e.LAYOUT=`ribbon.start.layout`,e.OTHERS=`ribbon.start.others`,e}({}),Da=function(e){return e.EDIT=`ribbon.insert.edit`,e.MEDIA=`ribbon.insert.media`,e.OTHERS=`ribbon.insert.others`,e}({}),Oa=function(e){return e.BASIC=`ribbon.formulas.basic`,e.OTHERS=`ribbon.formulas.others`,e}({}),ka=function(e){return e.FORMULAS=`ribbon.data.formulas`,e.RULES=`ribbon.data.rules`,e.ORGANIZATION=`ribbon.data.organization`,e.OTHERS=`ribbon.data.others`,e}({}),Aa=function(e){return e.DISPLAY=`ribbon.view.display`,e.VISIBILITY=`ribbon.view.Visibility`,e.OTHERS=`ribbon.view.others`,e}({}),ja=function(e){return e.OTHERS=`ribbon.others.others`,e}({}),Ma=function(e){return e.MAIN_AREA=`contextMenu.mainArea`,e.COL_HEADER=`contextMenu.colHeader`,e.ROW_HEADER=`contextMenu.rowHeader`,e.FOOTER_TABS=`contextMenu.footerTabs`,e.FOOTER_MENU=`contextMenu.footerMenu`,e.PARAGRAPH=`contextMenu.paragraph`,e.DRAWING=`contextMenu.drawing`,e}({}),q=function(e){return e.QUICK=`contextMenu.quick`,e.FORMAT=`contextMenu.format`,e.LAYOUT=`contextMenu.layout`,e.DATA=`contextMenu.data`,e.OTHERS=`contextMenu.others`,e}({});const J=E(`univer.menu-manager-service`);let Na=class extends a{constructor(e,t){super(),this._injector=e,this._configService=t,z(this,`menuChanged$`,new Te),z(this,`_menu`,{[Ta.RIBBON]:{[K.START]:{order:0,[Ea.HISTORY]:{order:0},[Ea.FORMAT]:{order:1},[Ea.LAYOUT]:{order:2},[Ea.OTHERS]:{order:3}},[K.INSERT]:{order:1,[Da.EDIT]:{order:0},[Da.MEDIA]:{order:1},[Da.OTHERS]:{order:2}},[K.FORMULAS]:{order:2,[Oa.BASIC]:{order:0},[Oa.OTHERS]:{order:1}},[K.DATA]:{order:3,[ka.FORMULAS]:{order:0},[ka.RULES]:{order:1},[ka.ORGANIZATION]:{order:2},[ka.OTHERS]:{order:3}},[K.VIEW]:{order:4,[Aa.DISPLAY]:{order:0},[Aa.VISIBILITY]:{order:0},[Aa.OTHERS]:{order:0}},[K.OTHERS]:{order:5,[ja.OTHERS]:{order:0}}},[Ta.CONTEXT_MENU]:{[Ma.MAIN_AREA]:{order:0,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.PARAGRAPH]:{order:0,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.COL_HEADER]:{order:1,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.ROW_HEADER]:{order:2,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.FOOTER_TABS]:{order:3,[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.FOOTER_MENU]:{order:4,[q.OTHERS]:{order:3}},[Ma.DRAWING]:{order:5,[q.OTHERS]:{order:3}}}})}dispose(){this.menuChanged$.complete()}mergeMenu(e,t){let n=t==null?this._menu:t;for(let[t,r]of Object.entries(n))if(t in e){let r=t;n[r]=_e({},n[r],e[r]),this.menuChanged$.next()}else typeof r==`object`&&this.mergeMenu(e,r)}appendRootMenu(e){this._menu=_e({},this._menu,e),this.menuChanged$.next()}_buildMenuSchema(e){let t=[];for(let[n,r]of Object.entries(e)){let e={key:n,order:r.order,title:r.title,quickLayout:r.quickLayout};if(r.menuItemFactory){let t=this._injector.invoke(r.menuItemFactory);if(t){let n=this._configService.getConfig(`menu`);if(n&&t.id in n){let r=t.id;e.item=_i(t,n[r])}else e.item=t}}if(typeof r==`object`){let n=this._buildMenuSchema(r);n.length>0&&(e.children=n.sort((e,t)=>e.order-t.order)),(e.item||e.children)&&t.push(e)}}return t}getMenuByPositionKey(e){let t=n=>{if(e in n)return this._buildMenuSchema(n[e]);for(let r in n){if(r===e)return this._buildMenuSchema(n[r]);if(typeof n[r]==`object`){let e=t(n[r]);if(e)return e}}};return t(this._menu)}getFlatMenuByPositionKey(e){let t=this.getMenuByPositionKey(e);function n(e){return e.reduce((e,t)=>t.children?[...e,t,...n(t.children)]:[...e,t],[])}return n(t)}};Na=U([H(0,b(x)),H(1,p)],Na);function Pa(){let e=P(ha),t=P(C),n=F(t.currentLocale$),[r,i]=M([]),a=sr(()=>{let n=new Map,r=e.getAllShortcuts().filter(e=>!!e.group);for(let i of r){var a;let r=i.group,o={title:t.t((a=i.description)==null?i.id:a),shortcut:e.getShortcutDisplay(i)};if(!/\d+_[a-zA-Z0-9]/.test(r))throw Error(`[ShortcutPanel]: Invalid shortcut group: ${r}!`);n.has(r)||n.set(r,[]),n.get(r).push(o)}i(Array.from(n.entries()).map(([e,n])=>{let r=e.split(`_`)[0],i=e.slice(r.length+1);return{sequence:+r,name:t.t(i),items:fe(n,e=>e.title+e.shortcut)}}).sort((e,t)=>e.sequence-t.sequence))},[e,t,n]);return k(()=>{a();let t=e.shortcutChanged$.subscribe(()=>a());return()=>t.unsubscribe()},[e,a]),I(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-gray-900 dark:!univer-text-white`,children:r.map(e=>L(`li`,{children:[I(`div`,{className:`univer-flex univer-h-10 univer-items-center univer-text-sm univer-font-semibold`,children:e.name}),I(`ul`,{className:R(`univer-list-none univer-p-0`,Hr),children:e.items.map(e=>L(`li`,{className:`univer-flex univer-h-10 univer-items-center univer-justify-between univer-py-0.5 univer-text-sm last:univer-border-b-0`,children:[I(`span`,{className:`univer-line-clamp-2`,children:e.title}),e.shortcut&&I(jr,{keyboard:e.shortcut})]},`${e.title}-${e.shortcut}`))})]},e.name))})}const Fa={id:fi.id,binding:G.CTRL_COMMAND|W.BACK_SLASH,description:`shortcut.shortcut-panel`,group:`10_global-shortcut`};let Ia=class extends a{constructor(e,t,n,r,i){super(),this._menuManagerService=r,this.disposeWithMe(t.register(di,Pa)),this.disposeWithMe(i.registerCommand(fi)),this.disposeWithMe(n.registerShortcut(Fa))}};Ia=U([H(0,b(x)),H(1,b(B)),H(2,ha),H(3,J),H(4,f)],Ia);let Y=function(e){return e[e.BUTTON=0]=`BUTTON`,e[e.SELECTOR=1]=`SELECTOR`,e[e.BUTTON_SELECTOR=2]=`BUTTON_SELECTOR`,e[e.SUBITEMS=3]=`SUBITEMS`,e}({});function La(e){return e.type===Y.BUTTON_SELECTOR}const Ra=(e,t)=>{let n=e.get(v),r=e.get(h);return De([n.undoRedoStatus$.pipe(ei(e=>t?e.undos<=0:e.redos<=0)),Fe([Ie({}),r.contextChanged$])]).pipe(ei(([e])=>e||r.getContextValue(c)||r.getContextValue(u)))};function za(e){return{id:ce.id,type:Y.BUTTON,icon:`UndoIcon`,title:`Undo`,tooltip:`toolbar.undo`,disabled$:Ra(e,!0)}}function Ba(e){return{id:ie.id,type:Y.BUTTON,icon:`RedoIcon`,title:`Redo`,tooltip:`toolbar.redo`,disabled$:Ra(e,!1)}}function Va(){return{id:fi.id,title:`toggle-shortcut-panel`,tooltip:`toggle-shortcut-panel`,icon:`ShortcutIcon`,type:Y.BUTTON}}const Ha={[Ea.HISTORY]:{[ce.id]:{order:0,menuItemFactory:za},[ie.id]:{order:1,menuItemFactory:Ba}},[Ea.OTHERS]:{[fi.id]:{order:1,menuItemFactory:Va}}};let X=function(e){return e.GLOBAL=`global`,e.HEADER=`header`,e.HEADER_MENU=`header-menu`,e.CONTENT=`content`,e.FOOTER=`footer`,e.LEFT_SIDEBAR=`left-sidebar`,e.FLOATING=`floating`,e.UNIT=`unit`,e.CUSTOM_HEADER=`custom-header`,e.CUSTOM_LEFT=`custom-left`,e.CUSTOM_RIGHT=`custom-right`,e.CUSTOM_FOOTER=`custom-footer`,e.TOOLBAR=`toolbar`,e}({});const Z=E(`ui.parts.service`);var Ua=class extends a{constructor(...e){super(...e),z(this,`_componentsByPart`,new Map),z(this,`_componentRegistered$`,new Te),z(this,`componentRegistered$`,this._componentRegistered$.asObservable()),z(this,`_uiVisible`,new Map),z(this,`_uiVisibleChange$`,new Te),z(this,`uiVisibleChange$`,this._uiVisibleChange$.asObservable())}dispose(){super.dispose(),this._componentsByPart.clear(),this._uiVisible.clear(),this._componentRegistered$.complete(),this._uiVisibleChange$.complete()}setUIVisible(e,t){this._uiVisible.set(e,t),this._uiVisibleChange$.next({ui:e,visible:t})}isUIVisible(e){var t;return(t=this._uiVisible.get(e))==null?!0:t}registerComponent(e,t){let n=t(),r=(this._componentsByPart.get(e)||this._componentsByPart.set(e,new Set).get(e)).add(n);return this._componentRegistered$.next(e),D(()=>{r.delete(n),r.size===0&&this._componentsByPart.delete(e),this._componentRegistered$.next(e)})}getComponents(e){return new Set([...this._componentsByPart.get(e)||new Set])}},Wa=class{constructor(){z(this,`_domLayerMap`,new Map),z(this,`_domLayers$`,new O([])),z(this,`domLayers$`,this._domLayers$.asObservable())}get domLayers(){return Array.from(this._domLayerMap.entries())}_notice(){this._domLayers$.next(Array.from(this._domLayerMap.entries()))}updateFloatDom(e,t){let n=this._domLayerMap.get(e);n&&(this._domLayerMap.set(e,{...n,...t}),this._notice())}addFloatDom(e){this._domLayerMap.set(e.id,e),this._notice()}removeFloatDom(e){this._domLayerMap.delete(e)&&this._notice()}removeAll(){this._domLayerMap.clear(),this._notice()}};const Ga=or(e=>{var t,n;let{layer:r,id:i}=e,a=A(()=>r.position$.pipe(ke((e,t)=>e.absolute.left===t.absolute.left&&e.absolute.top===t.absolute.top&&e.endX-e.startX===t.endX-t.startX&&e.endY-e.startY===t.endY-t.startY)),[r.position$]),s=P(y),c=F(A(()=>r.position$.pipe(je()),[r.position$])),l=j(null),u=j(null),d=j(`transform: rotate(${c==null?void 0:c.rotate}deg) translate(${c==null?void 0:c.startX}px, ${c==null?void 0:c.startY}px)`),f=j((t=c==null?void 0:c.startY)==null?0:t),p=j((n=c==null?void 0:c.startX)==null?0:n),m=j({}),h=typeof r.componentKey==`string`?P(B).get(r.componentKey):r.componentKey,g=A(()=>({data:r.data,...r.props}),[r.data,r.props]);k(()=>{let e=r.position$.subscribe(e=>{if(d.current=`rotate(${e.rotate}deg)`,f.current=e.startY,p.current=e.startX,l.current){var t;l.current.style.transform=d.current,l.current.style.top=`${f.current}px`,l.current.style.left=`${p.current}px`,l.current.style.opacity=`${(t=e.opacity)==null?1:t}`}}),t=a.subscribe(e=>{if(l.current&&(l.current.style.width=`${Math.max(e.endX-e.startX-2,0)}px`,l.current.style.height=`${Math.max(e.endY-e.startY-2,0)}px`),u.current){let t={width:`${e.width-4}px`,height:`${e.height-4}px`,left:`${e.absolute.left?0:`auto`}`,top:`${e.absolute.top?0:`auto`}`,right:`${e.absolute.left?`auto`:0}`,bottom:`${e.absolute.top?`auto`:0}`};u.current.style.width=t.width,u.current.style.height=t.height,u.current.style.left=t.left,u.current.style.top=t.top,u.current.style.right=t.right,u.current.style.bottom=t.bottom,m.current=t}});return()=>{e.unsubscribe(),t.unsubscribe()}},[r.position$,a]);let _=s.getUnit(r.unitId),v=_ instanceof o?_.getDisabled():void 0,b=A(()=>h?I(h,{...g,unitId:r.unitId,unit:_,floatDomId:r.id,context:{docDisabled:v,root:u}}):null,[h,g]);return c?I(`div`,{ref:l,className:`univer-z-10`,style:{position:`absolute`,top:f.current,left:p.current,width:Math.max(c.endX-c.startX-2,0),height:Math.max(c.endY-c.startY-2,0),transform:d.current,overflow:`hidden`,transformOrigin:`center center`},onPointerMove:e=>{r.onPointerMove(e.nativeEvent)},onPointerDown:e=>{r.onPointerDown(e.nativeEvent)},onPointerUp:e=>{r.onPointerUp(e.nativeEvent)},onWheel:e=>{r.onWheel(e.nativeEvent)},children:I(`div`,{id:i,ref:u,className:`univer-absolute univer-overflow-hidden`,style:{...m.current},children:b})}):null}),Ka=({unitId:e})=>{var t;let n=P(y),r=F(P(Wa).domLayers$),i=F(n.focused$),a=e||i;return r==null||(t=r.filter(e=>e[1].unitId===a))==null?void 0:t.map(e=>{var t;return I(Ga,{id:(t=e[1].domId)==null?e[0]:t,layer:e[1]},e[0])})},qa=E(`ui.popup.service`);var Ja=class extends a{constructor(...e){super(...e),z(this,`_popupMap`,new Map),z(this,`_popups$`,new O([])),z(this,`popups$`,this._popups$.asObservable()),z(this,`_activePopupId`,null)}get popups(){return Array.from(this._popupMap.entries())}get activePopupId(){return this._activePopupId}_update(){this._popups$.next(Array.from(this._popupMap.entries()))}dispose(){super.dispose(),this._popups$.next([]),this._popups$.complete(),this._popupMap.clear()}addPopup(e){let t=pe();return this._popupMap.set(t,{...e,onActiveChange:e=>{e?this._activePopupId=t:this._activePopupId===t&&(this._activePopupId=null)}}),this._update(),t}removePopup(e){this._popupMap.delete(e)&&this._update()}removeAll(){this._popupMap.clear(),this._update()}};const Ya=rr({current:void 0});function Xa(e){let{position:t,width:n,height:r,containerHeight:i,containerWidth:a,direction:o=`vertical`,noPushMinimumGap:s=!1}=e,c=s?-1/0:8,l=s?1/0:i-r-8,u=s?-1/0:8,d=s?1/0:a-n-8;if(o===`vertical`||o.indexOf(`top`)===0||o.indexOf(`bottom`)===0){let{left:e,top:i,right:s,bottom:f}=t,p=o===`vertical`&&f>l||o.indexOf(`top`)>-1?{top:Math.max(Math.min(i-r,l),c)}:{top:Math.max(Math.min(f,l),c)},m;if(o.includes(`center`)){let t=(s-e-n)/2;m=Math.max(e+t,u)+n>a?{left:Math.max(Math.min(d,s-n-t),u)}:{left:Math.max(u,Math.min(e+t,d))}}else m=o.includes(`right`)?{left:Math.max(Math.min(s-n,d),u)}:o.includes(`left`)?{left:Math.max(Math.min(e,d),u)}:e+n>a?Math.max(s-n,u)<8?{left:Math.max(Math.min(e,d),u)}:{left:Math.max(Math.min(s-n,d),u)}:{left:Math.max(Math.min(e,d),u)};return{...p,...m}}let{left:f,top:p,right:m,bottom:h}=t,g=o.includes(`left`)?{left:Math.max(Math.min(f-n,d),u)}:{left:Math.max(Math.min(m,d),u)},_;if(o.includes(`center`)){let e=(h-p-r)/2;_=Math.max(p+e,c)+r>i?{top:Math.max(Math.min(l,h-r-e),c)}:{top:Math.max(c,Math.min(p+e,l))}}else _=o.includes(`top`)?{top:Math.max(Math.min(p,l),c)}:o.includes(`bottom`)?{top:Math.max(Math.min(h-r,l),c)}:p+r>i?Math.max(h-r,c)<8?{top:Math.max(Math.min(p,l),c)}:{top:Math.max(Math.min(h-r,l),c)}:{top:Math.max(Math.min(p,l),c)};return{..._,...g}}function Za(e){var t;let{mask:n,portal:r,children:i,anchorRect$:a,direction:o=`vertical`,onClickOutside:s,excludeOutside:c,excludeRects:l,onPointerEnter:u,onPointerLeave:d,onClick:f,hidden:m,onContextMenu:h,zIndex:g=1020,maskZIndex:_=100,onMaskClick:v,noPushMinimumGap:y,autoRelayout:b=!0}=e,x=j(null),ee=Ti(s==null?(()=>{}):s),te=Ti(h==null?(()=>{}):h),S=j({top:-9999,left:-9999}),C=l,ne=P(p),w=j(void 0),re=ne.getConfig(Ai),T=(t=re==null?void 0:re.popupRootId)==null?`univer-popup-portal`:t,ie=Ti(e=>{requestAnimationFrame(()=>{if(!x.current)return;let{clientWidth:t,clientHeight:n}=x.current,r=window.innerWidth,i=window.innerHeight;S.current=Xa({position:e,width:t,height:n,containerWidth:r,containerHeight:i,direction:o,noPushMinimumGap:y}),x.current.style.top=`${S.current.top}px`,x.current.style.left=`${S.current.left}px`})});k(()=>{let e;return x.current&&(e=new ResizeObserver(()=>{b&&w.current&&ie(w.current)}),e.observe(x.current)),()=>{e==null||e.disconnect()}},[x.current,b]),k(()=>{let e=a.subscribe(e=>{w.current=e,ie(e)});return()=>e.unsubscribe()},[a,o]),k(()=>{let e=e=>{var t;if(c&&(c.indexOf(e.target)>-1||c.some(t=>t.contains(e.target))))return;let n=e.clientX,r=e.clientY,i=[...(t=C==null?void 0:C.current)==null?[]:t];w.current&&i.push(w.current);for(let e of i)if(n<=e.right&&n>=e.left&&r<=e.bottom&&r>=e.top)return;ee(e)};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[ee,c,C]),k(()=>{let e=e=>{e.ctrlKey&&e.button===0||te()};return window.addEventListener(`contextmenu`,e),()=>{window.removeEventListener(`contextmenu`,e)}},[te]);let ae=L(yr,{children:[n&&I(`div`,{"data-u-comp":`rect-popup-mask`,className:`univer-fixed univer-inset-0 univer-z-[100]`,style:{zIndex:_},onClick:v}),I(`section`,{"data-u-comp":`rect-popup`,ref:x,className:R(`univer-pointer-events-auto univer-fixed univer-left-[-9999px] univer-top-[-9999px] univer-z-[1020]`,{"univer-hidden":m,"univer-animate-in univer-fade-in-70":!m}),style:{...S.current,zIndex:g},onPointerDown:e=>e.stopPropagation(),onClick:f,onPointerEnter:u,onPointerLeave:d,children:I(Ya.Provider,{value:w,children:i})})]});return r?document.getElementById(T)?ri(ae,document.getElementById(T)):null:ae}Za.calcPopupPosition=Xa,Za.useContext=()=>cr(Ya);const Qa=({popup:e,children:t})=>{let[n,r]=M(!1),i=A(()=>e.anchorRect$.pipe(Be(0,Ee),Pe(t=>{var n;let{bottom:r,left:i,right:a,top:o}=t,[s=0,c=0]=(n=e.offset)==null?[]:n;return{left:i-s,right:a+s,top:o-c,bottom:r+c}})),[e.anchorRect$,e.offset]),a=A(()=>{var t,n;return(t=(n=e.hiddenRects$)==null?void 0:n.pipe(Be(0,Ee)))==null?Ie([]):t},[e.hiddenRects$]),o=bi(A(()=>{var t;return(t=e.excludeRects$)==null?void 0:t.pipe(Be(0,Ee))},[e.excludeRects$]),e.excludeRects),{canvasElement:s,hideOnInvisible:c=!0,hiddenType:l=`destroy`}=e;return k(()=>{if(!c)return;let e=De([i,a]).subscribe(([e,t])=>{let{top:n,left:i,bottom:a,right:o}=s.getBoundingClientRect(),c=e.bottom-e.top,l=e.right-e.left,u=t.some(t=>{let n=Math.min(.5*c,10),r=Math.min(.5*l,10);return e.top>=t.top-n&&e.bottom<=t.bottom+n&&e.left>=t.left-r&&e.right<=t.right+r});e.bottom<n||e.top>a||e.right<i||e.left>o||u?r(!0):r(!1)});return()=>e.unsubscribe()},[s,c,i,a]),n&&l===`destroy`?null:I(Za,{...e,hidden:n,anchorRect$:i,direction:e.direction,onClickOutside:e.onClickOutside,excludeOutside:e.excludeOutside,excludeRects:o,...e.customActive?null:{onPointerEnter:()=>{var t;return(t=e.onActiveChange)==null?void 0:t.call(e,!0)},onPointerLeave:()=>{var t;return(t=e.onActiveChange)==null?void 0:t.call(e,!1)}},onClick:e.onClick,onContextMenu:e.onContextMenu,children:t})};function $a(){let e=P(qa),t=P(B);return F(e.popups$,void 0,!0).map(e=>{let[n,r]=e,i=t.get(r.componentKey);return I(Qa,{popup:r,children:i?I(i,{popup:r}):null},n)})}const eo=E(`univer.ribbon-service`);let to=class extends a{constructor(e,t){super(),this._menuManagerService=e,this._univerInstanceService=t,z(this,`_ribbon$`,new O([])),z(this,`ribbon$`,this._ribbon$.asObservable()),z(this,`_activatedTab$`,new O(K.START)),z(this,`activatedTab$`,this._activatedTab$.asObservable()),z(this,`_collapsedIds$`,new O([])),z(this,`collapsedIds$`,this._collapsedIds$.asObservable()),z(this,`_fakeToolbarVisible$`,new O(!1)),z(this,`fakeToolbarVisible$`,this._fakeToolbarVisible$.asObservable()),this._initRibbonSubscription()}setActivatedTab(e){this._activatedTab$.next(e)}setCollapsedIds(e){this._collapsedIds$.next(e)}setFakeToolbarVisible(e){this._fakeToolbarVisible$.next(e)}_initRibbonSubscription(){this.disposeWithMe(De([this._menuManagerService.menuChanged$.pipe(ni(void 0)),this._univerInstanceService.focused$.pipe(ni(void 0))]).subscribe(()=>{this._updateRibbon()}))}_updateRibbon(){let e=this._menuManagerService.getMenuByPositionKey(Ta.RIBBON),t=[],n=[];for(let i of e)if(i.children){for(let e of i.children)if(e.children)for(let i of e.children){var r;(r=i.item)!=null&&r.hidden$&&(t.push(i.item.hidden$),n.push(i.key))}}if(t.length===0){this._ribbon$.next(e);return}De(t).pipe(ni(Array(t.length).fill(!1))).subscribe(t=>{let r=[],i=t.map((e,t)=>e?n[t]:null).filter(e=>!!e);for(let t of e){var a,o;let e={...t,children:[]};if((a=t.children)!=null&&a.length)for(let n of t.children){var s;let t={...n,children:[]},r=!0;if((s=n.children)!=null&&s.length){var c;for(let e of n.children)if(!i.includes(e.key)){var l;(l=t.children)==null||l.push(e)}(c=t.children)!=null&&c.every(e=>{var t;return((t=e.children)==null?void 0:t.length)===0})&&(r=!1)}if(r){var u;(u=e.children)==null||u.push(t)}}(o=e.children)!=null&&o.length&&e.children.every(e=>{var t;return(t=e.children)==null?void 0:t.length})&&r.push(e)}this._ribbon$.next(r)}).unsubscribe()}};to=U([H(0,J),H(1,y)],to);function Q(e){let{components:t,fallback:n,sharedProps:r}=e;return!t||t.size===0?n==null?null:n:Array.from(t.values()).map((e,t)=>{var n;return ir(e,{key:`${(n=e.displayName)==null?t:n}`,...r})})}function $(e,t){var n;let r=(n=t==null?void 0:t.get(Z))==null?P(Z):n,i=F(A(()=>r.uiVisibleChange$.pipe(Ae(t=>t.ui===e)),[e,r])),a=j(0);return A(()=>r.isUIVisible(e)?r.getComponents(e):new Set,[F(()=>r.componentRegistered$.pipe(Ae(t=>t===e),Oe(200),Pe(()=>a.current+=1),Re(a.current+=1)),void 0,void 0,[r,e,i])])}function no({ribbon:e,activatedTab:t,onSelectTab:n}){let r=P(C);return I(`div`,{className:`univer-flex univer-size-full univer-items-center univer-justify-center univer-gap-1 univer-overflow-x-auto univer-rounded-md univer-bg-gray-50 univer-px-3 dark:!univer-bg-gray-900`,role:`tablist`,"aria-label":r.t(`ribbon.menu`),children:e.map(e=>{let i=t===e.key;return I(`button`,{type:`button`,role:`tab`,"aria-selected":i,title:r.t(e.key),onClick:()=>n(e),className:R(`univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500 dark:!univer-focus:ring-primary-300 univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors`,i?`
1
+ import{BaselineOffset as e,BorderStyleTypes as t,ColorKit as n,CommandType as r,DependentOn as i,Disposable as a,DocumentDataModel as o,DocumentFlavor as s,EDITOR_ACTIVATED as c,ErrorService as l,FOCUSING_FX_BAR_EDITOR as u,FOCUSING_UNIVER_EDITOR as d,ICommandService as f,IConfigService as p,IConfirmService as m,IContextService as h,ILocalStorageService as g,ILogService as _,IUndoRedoService as v,IUniverInstanceService as y,Inject as b,Injector as x,LifecycleService as ee,LifecycleStages as te,LifecycleUnreachableError as S,LocaleService as C,NAMED_STYLE_MAP as ne,NamedStyleType as w,Optional as re,Plugin as T,RedoCommand as ie,SlideDataModel as ae,ThemeService as oe,Tools as se,UndoCommand as ce,UniverInstanceType as le,Workbook as ue,convertObservableToBehaviorSubject as de,createIdentifier as E,dedupeBy as fe,generateRandomId as pe,getBorderStyleType as me,isInternalEditorID as he,isRealNum as ge,merge as _e,mergeOverrideWithDependencies as ve,registerDependencies as ye,remove as be,throttle as xe,toDisposable as D,touchDependencies as Se}from"@univerjs/core";import{BehaviorSubject as O,Observable as Ce,ReplaySubject as we,Subject as Te,animationFrameScheduler as Ee,combineLatest as De,debounceTime as Oe,distinctUntilChanged as ke,filter as Ae,first as je,fromEvent as Me,isObservable as Ne,map as Pe,merge as Fe,of as Ie,scan as Le,startWith as Re,switchMap as ze,throttleTime as Be}from"rxjs";import{AddDigitsIcon as Ve,AddImageIcon as He,AdditionAndSubtractionIcon as Ue,AdjustHeightDoubleIcon as We,AdjustWidthDoubleIcon as Ge,AlignBottomIcon as Ke,AlignTextBothIcon as qe,AlignTopIcon as Je,AllBorderIcon as Ye,AmplifyIcon as Xe,AutoHeightDoubleIcon as Ze,AutoWidthDoubleIcon as Qe,AutowrapIcon as $e,AvgIcon as et,BackSlashDoubleIcon as tt,BoldIcon as nt,BrushIcon as rt,CancelFreezeIcon as it,CancelMergeIcon as at,CheckMarkIcon as ot,ClearFormatDoubleIcon as st,CloseIcon as ct,CntIcon as lt,CodeIcon as ut,ConditionsDoubleIcon as dt,CopyDoubleIcon as ft,CutIcon as pt,DatabaseIcon as mt,DeleteCellMoveDownDoubleIcon as ht,DeleteCellShiftLeftDoubleIcon as gt,DeleteCellShiftRightDoubleIcon as _t,DeleteCellShiftUpDoubleIcon as vt,DeleteColumnDoubleIcon as yt,DeleteRowDoubleIcon as bt,DirectExportIcon as xt,DollarIcon as St,DownBorderDoubleIcon as Ct,DownloadImageIcon as wt,EuroIcon as Tt,ExportIcon as Et,EyeIcon as Dt,EyeOutlineIcon as Ot,FolderIcon as kt,FontColorDoubleIcon as At,FontSizeIncreaseIcon as jt,FontSizeReduceIcon as Mt,FreezeColumnIcon as Nt,FreezeRowIcon as Pt,FreezeToSelectedIcon as Ft,FunctionIcon as It,GridIcon as Lt,HeaderFooterIcon as Rt,HideDoubleIcon as zt,HomeIcon as Bt,HorizontalBorderDoubleIcon as Vt,HorizontalMergeIcon as Ht,HorizontallyIcon as Ut,IncreaseIcon as Wt,InfoIcon as Gt,InnerBorderDoubleIcon as Kt,InsertCellDownDoubleIcon as qt,InsertCellShiftRightDoubleIcon as Jt,InsertDoubleIcon as Yt,InsertIcon as Xt,InsertRowAboveDoubleIcon as Zt,InsertRowBelowDoubleIcon as Qt,ItalicIcon as $t,KeyboardIcon as en,LeftBorderDoubleIcon as tn,LeftDoubleDiagonalDoubleIcon as nn,LeftInsertColumnDoubleIcon as rn,LeftJustifyingIcon as an,LeftRotationFortyFiveDegreesIcon as on,LeftRotationNinetyDegreesIcon as sn,LeftTridiagonalDoubleIcon as cn,MaxIcon as ln,MenuIcon as un,MergeAllIcon as dn,MinIcon as fn,MoreDownIcon as pn,MoreFunctionIcon as mn,MoreIcon as hn,MoreLeftIcon as gn,MoreRightIcon as _n,NoBorderIcon as vn,NoColorDoubleIcon as yn,NoRotationIcon as bn,OrderIcon as xn,OuterBorderDoubleIcon as Sn,OverflowIcon as Cn,PaintBucketDoubleIcon as wn,PasteSpecialDoubleIcon as Tn,PercentIcon as En,PipingIcon as Dn,RedoIcon as On,ReduceDigitsIcon as kn,ReduceDoubleIcon as An,ReduceIcon as jn,RightBorderDoubleIcon as Mn,RightDoubleDiagonalDoubleIcon as Nn,RightInsertColumnDoubleIcon as Pn,RightJustifyingIcon as Fn,RightRotationFortyFiveDegreesIcon as In,RightRotationNinetyDegreesIcon as Ln,RmbIcon as Rn,RoubleIcon as zn,ShortcutIcon as Bn,SlashDoubleIcon as Vn,StrikethroughIcon as Hn,SubscriptIcon as Un,SumIcon as Wn,SuperscriptIcon as Gn,TruncationIcon as Kn,UnderlineIcon as qn,UndoIcon as Jn,UnorderIcon as Yn,UpBorderDoubleIcon as Xn,VerticalBorderDoubleIcon as Zn,VerticalCenterIcon as Qn,VerticalIntegrationIcon as $n,VerticalTextIcon as er}from"@univerjs/icons";import{Fragment as tr,cloneElement as nr,createContext as rr,createElement as ir,forwardRef as ar,memo as or,useCallback as sr,useContext as cr,useEffect as k,useImperativeHandle as lr,useLayoutEffect as ur,useMemo as A,useRef as j,useState as M}from"react";import{RediConsumer as dr,RediContext as fr,RediProvider as pr,WithDependency as mr,connectDependencies as hr,connectInjector as N,useDependency as P,useDependency as gr,useInjector as _r,useObservable as F,useUpdateBinder as vr}from"@wendellhu/redi/react-bindings";import{Fragment as yr,jsx as I,jsxs as L}from"react/jsx-runtime";import{Button as br,ColorPicker as xr,ConfigContext as Sr,ConfigProvider as Cr,Confirm as wr,Dialog as Tr,Dropdown as Er,DropdownMenu as Dr,Gallery as Or,HoverCard as kr,InputNumber as Ar,KBD as jr,MessageType as Mr,Messager as Nr,Popup as Pr,Toaster as Fr,Tooltip as Ir,borderBottomClassName as Lr,borderClassName as Rr,borderLeftBottomClassName as zr,borderRightClassName as Br,clsx as R,divideXClassName as Vr,divideYClassName as Hr,isBrowser as Ur,message as Wr,removeMessage as Gr,render as Kr,resizeObserverCtor as qr,scrollbarClassName as Jr,toast as Yr,unmount as Xr}from"@univerjs/design";import{IRenderManagerService as Zr,UniverRenderEnginePlugin as Qr,ptToPx as $r}from"@univerjs/engine-render";import{map as ei,scan as ti,startWith as ni}from"rxjs/operators";import{createPortal as ri}from"react-dom";import ii from"localforage";function ai(e){"@babel/helpers - typeof";return ai=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},ai(e)}function oi(e,t){if(ai(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(ai(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function si(e){var t=oi(e,`string`);return ai(t)==`symbol`?t:t+``}function z(e,t,n){return(t=si(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ci=class extends a{constructor(...e){super(...e),z(this,`_open$`,new O(!1)),z(this,`open$`,this._open$.pipe(ke()))}get isOpen(){return this._open$.getValue()}dispose(){super.dispose(),this._open$.next(!1),this._open$.complete()}open(){this._open$.next(!0)}close(){this._open$.next(!1)}};const li=E(`ui.left-sidebar.service`),ui=E(`ui.sidebar.service`),di=`ShortcutPanel`,fi={id:`base-ui.operation.toggle-shortcut-panel`,type:r.OPERATION,handler:e=>{let t=e.get(ci),n=e.get(ui);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:`shortcut-panel.title`},children:{label:di}})),!0}},pi={AddDigitsIcon:Ve,AddImageIcon:He,AdditionAndSubtractionIcon:Ue,AdjustHeightDoubleIcon:We,AdjustWidthDoubleIcon:Ge,AlignBottomIcon:Ke,AlignTextBothIcon:qe,AlignTopIcon:Je,AllBorderIcon:Ye,AmplifyIcon:Xe,AutoHeightDoubleIcon:Ze,AutoWidthDoubleIcon:Qe,AutowrapIcon:$e,AvgIcon:et,BackSlashDoubleIcon:tt,BoldIcon:nt,BrushIcon:rt,CancelFreezeIcon:it,CancelMergeIcon:at,ClearFormatDoubleIcon:st,CntIcon:lt,CodeIcon:ut,ConditionsDoubleIcon:dt,CopyDoubleIcon:ft,CutIcon:pt,DeleteCellMoveDownDoubleIcon:ht,DeleteCellShiftLeftDoubleIcon:gt,DeleteCellShiftRightDoubleIcon:_t,DeleteCellShiftUpDoubleIcon:vt,DeleteColumnDoubleIcon:yt,DeleteRowDoubleIcon:bt,DirectExportIcon:xt,DollarIcon:St,DownBorderDoubleIcon:Ct,DownloadImageIcon:wt,EuroIcon:Tt,ExportIcon:Et,EyeOutlineIcon:Ot,FolderIcon:kt,FontColorDoubleIcon:At,FontSizeIncreaseIcon:jt,FontSizeReduceIcon:Mt,FreezeColumnIcon:Nt,FreezeRowIcon:Pt,FreezeToSelectedIcon:Ft,FunctionIcon:It,GridIcon:Lt,HeaderFooterIcon:Rt,HideDoubleIcon:zt,HorizontalBorderDoubleIcon:Vt,HorizontallyIcon:Ut,HorizontalMergeIcon:Ht,IncreaseIcon:Wt,InnerBorderDoubleIcon:Kt,InsertCellDownDoubleIcon:qt,InsertCellShiftRightDoubleIcon:Jt,InsertDoubleIcon:Yt,InsertRowAboveDoubleIcon:Zt,InsertRowBelowDoubleIcon:Qt,ItalicIcon:$t,KeyboardIcon:en,LeftBorderDoubleIcon:tn,LeftDoubleDiagonalDoubleIcon:nn,LeftInsertColumnDoubleIcon:rn,LeftJustifyingIcon:an,LeftRotationFortyFiveDegreesIcon:on,LeftRotationNinetyDegreesIcon:sn,LeftTridiagonalDoubleIcon:cn,MaxIcon:ln,MenuIcon:un,MergeAllIcon:dn,MinIcon:fn,MoreDownIcon:pn,NoBorderIcon:vn,NoColorDoubleIcon:yn,NoRotationIcon:bn,OrderIcon:xn,OuterBorderDoubleIcon:Sn,OverflowIcon:Cn,PaintBucketDoubleIcon:wn,PasteSpecialDoubleIcon:Tn,PercentIcon:En,PipingIcon:Dn,RedoIcon:On,ReduceDigitsIcon:kn,ReduceDoubleIcon:An,ReduceIcon:jn,RightBorderDoubleIcon:Mn,RightDoubleDiagonalDoubleIcon:Nn,RightInsertColumnDoubleIcon:Pn,RightJustifyingIcon:Fn,RightRotationFortyFiveDegreesIcon:In,RightRotationNinetyDegreesIcon:Ln,RmbIcon:Rn,RoubleIcon:zn,ShortcutIcon:Bn,SlashDoubleIcon:Vn,StrikethroughIcon:Hn,SubscriptIcon:Un,SumIcon:Wn,SuperscriptIcon:Gn,TruncationIcon:Kn,UnderlineIcon:qn,UndoIcon:Jn,UnorderIcon:Yn,UpBorderDoubleIcon:Xn,VerticalBorderDoubleIcon:Zn,VerticalCenterIcon:Qn,VerticalIntegrationIcon:$n,VerticalTextIcon:er};var B=class extends a{constructor(){super(),z(this,`_components`,new Map),z(this,`_componentsReverse`,new Map),z(this,`reactUtils`,{createElement:ir,useEffect:k,useRef:j}),z(this,`_handler`,{react:e=>e});for(let e in pi)this.register(e,pi[e]);this.disposeWithMe(D(()=>{for(let e in pi)this._components.delete(e),this._componentsReverse.delete(pi[e])}))}register(e,t,n){let{framework:r=`react`}=n||{};if(r===`vue3`&&!this._handler.vue3)throw Error(`[ComponentManager] Vue3 support is no longer built-in since v0.9.0, please install @univerjs/ui-adapter-vue3 plugin.`);return this._components.has(e)&&console.warn(`Component ${e} already exists.`),this._components.set(e,{framework:r,component:t}),this._componentsReverse.set(t,e),D(()=>{this._components.delete(e),this._componentsReverse.delete(t)})}getKey(e){return this._componentsReverse.get(e)}setHandler(e,t){this._handler[e]=t}get(e){if(!e)return;let t=this._components.get(e);if(!t)return;let n=this._handler[t.framework];if(!n)throw Error(`[ComponentManager] No handler found for framework: ${t.framework}`);return n(t.component,e)}delete(e){this._components.delete(e)}},mi=class{constructor(){z(this,`_list`,new Map)}setIndex(e,t){this._list.set(e,t)}getIndex(e){return this._list.get(e)}removeIndex(e){this._list.delete(e)}getMaxIndex(){let e=-9999999;return this._list.forEach(t=>{+t>e&&(e=+t)}),e}};function hi(e,t,n,r){let i=e.get(y);return new Ce(e=>{let a=i.focused$.subscribe(a=>{if(a==null||n&&n!==a||r&&(Array.isArray(r)?r.includes(a):r===a))return e.next(!0);let o=i.getUnitType(a);e.next(o!==t)}),o=i.getFocusedUnit();if(o==null)return e.next(!0);let s=i.getUnitType(o.getUnitId());return e.next(s!==t),()=>a.unsubscribe()})}function gi(e){let t=e.get(y);return new Ce(e=>{let n=t.focused$.subscribe(n=>{if(n==null)return e.next(!0);let r=t.getUniverDocInstance(n),i=r==null?void 0:r.getSnapshot().documentStyle.documentFlavor;e.next(i!==s.TRADITIONAL)}),r=t.getCurrentUniverDocInstance();if(r==null)return e.next(!0);let i=r==null?void 0:r.getSnapshot().documentStyle.documentFlavor;return e.next(i!==s.TRADITIONAL),()=>n.unsubscribe()})}function _i(e,t){return!t||!e?e:([`type`,`icon`,`title`,`tooltip`].forEach(n=>{t[n]!==void 0&&(e[n]=t[n])}),[`hidden`,`disabled`,`activated`].forEach(n=>{vi(e,`${n}$`,t[n])}),e)}function vi(e,t,n){n!==void 0&&(e[t]?e[t]=e[t].pipe(ze(()=>new O(n))):e[t]=new Ce(e=>{e.next(n)}))}function yi(e){return typeof e==`function`?e():e}function bi(e,t){let n=j(t);return k(()=>{if(e){let t=yi(e).subscribe(e=>{n.current=e});return()=>t.unsubscribe()}},[e]),n}const xi=e=>{let{value:t,selections:n}=e,r=P(C);return I(`div`,{className:`univer-truncate univer-text-sm`,children:A(()=>{var e,i;return t==null?``:r.t((e=(i=n.find(e=>e.value===t))==null?void 0:i.label)==null?``:e)},[t,n])})},Si=`UI_PLUGIN_COMMON_LABEL_COMPONENT`;function V(e){let{className:t,title:r,icon:i,label:a,value:o,value$:s}=e,c=P(C),l=P(B),[u,d]=M(o),[f,p]=M(``),m=[],h=0;k(()=>{if(s){let e=s.subscribe(e=>{d(e)});return()=>{e.unsubscribe()}}},[s]);let g=A(()=>o==null?u:o,[u,o]);k(()=>{let e=null;return Ne(i)?e=i.subscribe(e=>{p(e)}):p(i==null?``:i),()=>{e==null||e.unsubscribe()}},[i]);let _=A(()=>g&&typeof g==`string`?new n(g).isValid:!1,[g]);if(i){let e=l.get(f==null?``:f);e&&m.push(I(e,{className:`univer-text-base`,extend:{colorChannel1:_?g:`var(--univer-primary-600)`}},h++))}if(a){let n=typeof a==`string`,r=n?{...e}:{...a==null?void 0:a.props,...e},i=n?a:a==null?void 0:a.name,o=l.get(i);o?m.push(I(o,{...r,className:t,value:g},h++)):m.push(I(`span`,{className:t,children:c.t(i)},h++))}return r&&m.push(I(`span`,{className:t,children:typeof r==`string`?c.t(r):r},h++)),I(yr,{children:m})}const Ci=e=>{var t,n;let{value:r,text:i}=e,a=ne[r],o=P(C);return I(`span`,{className:R(`univer-text-sm`,{"univer-font-bold":a==null?void 0:a.bl}),style:{fontSize:a==null?void 0:a.fs,color:(t=a==null||(n=a.cl)==null?void 0:n.rgb)==null?void 0:t},children:o.t(i)})},wi=`UI_COMPONENT_HEADING_ITEM`;function Ti(e){let t=j(e);return t.current=e,sr(((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}function Ei(e,t){let n=Ti(()=>{if(!e||!t)return;let n=e.style,{y:r,height:i}=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=e.scrollHeight>i,s=r<0||r+i>a.height;if(!s&&!o){n.overflowY=``,n.maxHeight=``;return}s&&(n.overflowY=`auto`,n.maxHeight=r<0?`${e.scrollHeight+r}px`:`${a.height-r}px`)});k(()=>{if(!Ur()||!e||!t)return;n();let r=qr(n);return r.observe(e),()=>{r.unobserve(e)}},[e,t])}function Di(e){let t=P(p);return F(A(()=>t.subscribeConfigValue$(e),[t]),t.getConfig(e))}function Oi(e){P(C);let t=P(B),{value:n,min:r=0,max:i=400,disabled:a=!1,resetPoint:o=100,shortcuts:s,onChange:c}=e,l=j(null),[u,d]=M(!1);function f(){a||c&&c(o)}function p(e){if(a)return;let t=n+e;n+e<=r?t=r:n+e>=i&&(t=i),c&&c(t)}let m=A(()=>{if(n<=o){let e=50/(o-r);return(n-r)*e}if(n<=i)return o*.5+(n-o)/(i-o)*50},[r,i,o,n]);function h(e){if(a)return;e.preventDefault();let t=l.current,n=!0;function s(e){if(n){let n=e.clientX-t.getBoundingClientRect().x;n<=0?n=0:n>=116&&(n=116);let a=n/116,s=0;s=a<=.5?r+a*(o-r)*2:o+(a-.5)*(i-o)*2,c&&c(Math.ceil(s))}}function u(){n=!1,document.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,u)}function d(e){e.relatedTarget===null&&u()}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,u),window.addEventListener(`pointerout`,d)}function g(e){a||(d(!1),c&&c(e))}let _=[{type:`radio`,value:n.toString(),options:s.map(e=>({value:e.toString(),label:`${e}%`})),onSelect:e=>g(+e)}],v=t.get(`ReduceIcon`),y=t.get(`IncreaseIcon`);return L(`div`,{className:R(`univer-flex univer-select-none univer-items-center univer-gap-1`,{"univer-cursor-not-allowed":a}),children:[I(br,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n<=r||a,onClick:()=>p(-10),children:I(v,{})}),I(`div`,{className:`univer-relative univer-hidden univer-h-0.5 univer-rounded-2xl univer-bg-gray-400 univer-px-1.5 sm:!univer-block`,style:{width:`116px`},children:L(`div`,{ref:l,role:`track`,className:`univer-relative univer-h-0.5`,children:[I(`a`,{className:`univer-absolute univer-left-1/2 univer-top-1/2 univer-box-border univer-block univer-size-0.5 -univer-translate-x-1/2 -univer-translate-y-1/2 univer-cursor-pointer univer-rounded-full univer-bg-white`,role:`button`,onClick:f},`reset-button`),I(`button`,{className:R(`univer-absolute univer-top-[calc(50%-6px)] univer-size-3 -univer-translate-x-1/2 univer-rounded-full univer-border-none univer-bg-white univer-shadow univer-transition-colors`,{"hover:univer-gray-200 univer-cursor-pointer":!a,"univer-cursor-not-allowed":a}),role:`handle`,type:`button`,style:{left:`${m}%`},onPointerDown:h})]})}),I(br,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n>=i||a,onClick:()=>p(10),children:I(y,{})}),I(Dr,{align:`end`,items:_,open:u,onOpenChange:d,children:L(br,{size:`small`,variant:`text`,children:[n,`%`]})})]})}const ki=`UI_COLOR_PICKER_COMPONENT`,Ai=`ui.config`;Symbol(Ai);const ji={};function H(e,t){return function(n,r){t(n,r,e)}}function U(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const Mi=E(`univer.font-service`),Ni=[{value:`Arial`,label:`fontFamily.arial`,category:`sans-serif`},{value:`Times New Roman`,label:`fontFamily.times-new-roman`,category:`serif`},{value:`Tahoma`,label:`fontFamily.tahoma`,category:`sans-serif`},{value:`Verdana`,label:`fontFamily.verdana`,category:`sans-serif`},{value:`Microsoft YaHei`,label:`fontFamily.microsoft-yahei`,category:`sans-serif`},{value:`SimSun`,label:`fontFamily.simsun`,category:`serif`},{value:`SimHei`,label:`fontFamily.simhei`,category:`sans-serif`},{value:`Kaiti`,label:`fontFamily.kaiti`,category:`serif`},{value:`FangSong`,label:`fontFamily.fangsong`,category:`serif`},{value:`NSimSun`,label:`fontFamily.nsimsun`,category:`serif`},{value:`STXinwei`,label:`fontFamily.stxinwei`,category:`serif`},{value:`STXingkai`,label:`fontFamily.stxingkai`,category:`serif`},{value:`STLiti`,label:`fontFamily.stliti`,category:`serif`}];let Pi=class{constructor(e){this._configService=e,z(this,`fonts$`,new O([]));let t=this._configService.getConfig(Ai),{customFontFamily:n}=t==null?{}:t,r=[];r=n?Array.isArray(n)?[...Ni,...n]:n.override?[...n.list]:[...Ni,...n.list]:[...Ni],this.fonts$.next(r)}dispose(){this.resetToDefaults(),this.fonts$.complete()}getFonts(){return this.fonts$.getValue()}getFontByValue(e){return this.getFonts().find(t=>t.value===e)}isFontSupported(e){let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return!1;let n=`abcdefghijklmnopqrstuvwxyz0123456789`,r=`72px`,i=[`monospace`,`serif`,`sans-serif`],a={};return i.forEach(e=>{t.font=`${r} ${e}`,a[e]=t.measureText(n).width}),i.some(i=>(t.font=`${r} "${e}", ${i}`,t.measureText(n).width!==a[i]))}addFont(e){if(this.getFontByValue(e.value))throw Error(`[FontService]: Font with value "${e.value}" already exists.`);let t=[...this.getFonts(),e].sort();this.fonts$.next(t)}updateFont(e,t){let n=this.getFonts(),r=n.findIndex(t=>t.value===e);if(r===-1)throw Error(`Font with value "${e}" not found.`);let i={...n[r],...t},a=[...n];a[r]=i,this.fonts$.next(a)}removeFont(e){let t=this.getFonts();if(t.findIndex(t=>t.value===e)===-1)return!1;let n=t.filter(t=>t.value!==e);return this.fonts$.next(n),!0}resetToDefaults(){this.fonts$.next([...Ni])}};Pi=U([H(0,p)],Pi);const Fi=({id:e,value:t,disabled$:n})=>{let r=F(n),i=P(f),a=P(C),o=P(Mi),[s,c]=M(``),[l,u]=M([]);k(()=>{let e=o.fonts$.subscribe(e=>{u(e)});return()=>{e.unsubscribe()}},[]);let d=A(()=>{if(t==null)return``;let e=l.find(e=>e.value===t);return e?a.t(e.label):a.t(t)},[t,l,a]);A(()=>{c(d)},[t]);function p(){c(d)}function m(e){c(e.target.value)}function h(e){e.stopPropagation(),!r&&(e.key===`Enter`?_():e.key===`Escape`&&(e.preventDefault(),p()))}function g(){s!==t&&p()}function _(){let e=l.find(e=>a.t(e.label).toLowerCase().includes(s.trim().toLowerCase()));if(!e){p();return}v(e.value)}function v(t){i.executeCommand(e,{value:t})}return I(`div`,{className:`univer-w-32 univer-truncate univer-text-sm`,style:{fontFamily:t},children:I(`input`,{className:`univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 focus:univer-outline-none dark:!univer-text-white [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm`,type:`text`,value:s,onChange:m,onKeyDown:h,onBlur:g,disabled:r})})},Ii=[`app-layout`,`button`,`sheet-bar-append-button`,`render-canvas`,`workbench-layout`],Li=E(`ui.layout-service`);let Ri=class extends a{get isFocused(){return this._isFocused}constructor(e,t){super(),this._contextService=e,this._univerInstanceService=t,z(this,`_rootContainerElement`,null),z(this,`_isFocused`,!1),z(this,`_focusHandlers`,new Map),z(this,`_contentElements`,[]),z(this,`_allContainers`,[]),this._initUniverFocusListener(),this._initEditorStatus()}get rootContainerElement(){return this._rootContainerElement}focus(){let e=this._univerInstanceService.getFocusedUnit();if(!e)return;let t;e instanceof ue?t=this._focusHandlers.get(le.UNIVER_SHEET):e instanceof o?t=this._focusHandlers.get(le.UNIVER_DOC):e instanceof ae&&(t=this._focusHandlers.get(le.UNIVER_SLIDE)),t&&t(e.getUnitId())}registerFocusHandler(e,t){if(this._focusHandlers.has(e))throw Error(`[DesktopLayoutService]: handler of type ${e} bas been registered!`);return this._focusHandlers.set(e,t),D(()=>this._focusHandlers.delete(e))}registerContentElement(e){if(this._contentElements.indexOf(e)===-1)return this._contentElements.push(e),D(()=>be(this._contentElements,e));throw Error(`[DesktopLayoutService]: content container already registered!`)}getContentElement(){return this._contentElements[0]}registerRootContainerElement(e){if(this._rootContainerElement)throw Error(`[DesktopLayoutService]: root container already registered!`);this._rootContainerElement=e;let t=this.registerContainerElement(e);return D(()=>{this._rootContainerElement=null,t.dispose()})}registerContainerElement(e){if(this._allContainers.indexOf(e)===-1)return this._allContainers.push(e),D(()=>be(this._allContainers,e));throw Error(`[LayoutService]: container already registered!`)}checkElementInCurrentContainers(e){return this._allContainers.some(t=>t.contains(e))}checkContentIsFocused(){return this._contentElements.some(e=>e===document.activeElement||e.contains(document.activeElement))}_initUniverFocusListener(){this.disposeWithMe(Me(window,`focusin`).subscribe(e=>{var t;let n=e.target;if((t=this._rootContainerElement)!=null&&t.contains(n)&&Ii.some(e=>n.dataset.uComp===e)){queueMicrotask(()=>this.focus());return}n&&this.checkElementInCurrentContainers(n)?this._isFocused=!0:this._isFocused=!1,this._contextService.setContextValue(`FOCUSING_UNIVER`,this._isFocused),this._contextService.setContextValue(d,zi())}))}_initEditorStatus(){this._contextService.setContextValue(d,zi())}};Ri=U([H(0,h),H(1,y)],Ri);function zi(){var e;return((e=document.activeElement)==null?void 0:e.dataset.uComp)===`editor`}const Bi=({id:e,value:t})=>{let n=P(f),r=P(Mi),i=P(Li),[a,o]=M([]);k(()=>{let e=r.fonts$.subscribe(e=>{o(e)});return()=>{e.unsubscribe()}},[]);let s=P(C);function c(t){i.focus(),n.executeCommand(e,{value:t})}return I(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-sm`,style:{fontFamily:t},children:a.map(e=>I(`li`,{children:L(`button`,{className:`univer-flex univer-h-7 univer-w-full univer-appearance-none univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-border-none univer-bg-transparent univer-px-2 hover:univer-bg-gray-100 dark:!univer-text-white dark:hover:!univer-bg-gray-700`,style:{fontFamily:e.value},type:`button`,onClick:()=>c(e.value),children:[s.t(e.label),!r.isFontSupported(e.value)&&I(Ir,{title:s.t(`fontFamily.not-supported`),children:I(Gt,{className:`univer-text-gray-300 dark:!univer-text-gray-400`})})]})},e.value))})},Vi=`UI_FONT_FAMILY_COMPONENT`,Hi=`UI_FONT_FAMILY_ITEM_COMPONENT`,Ui=e=>{let{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=F(a),[s,c]=M(Number(t==null?0:t)),l=A(()=>Number(t==null?s:t),[t]);function u(e){e!==null&&c(e)}function d(e){e.stopPropagation(),e.code===`Enter`&&i(s)}return I(`div`,{className:`univer-h-6 univer-w-7 univer-text-sm`,children:I(Ar,{className:`univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6 [&_input:focus]:!univer-ring-0 [&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none [&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm`,value:l,controls:!1,min:n,max:r,onKeyDown:d,onChange:u,disabled:o})})},Wi=[{label:`9`,value:9},{label:`10`,value:10},{label:`11`,value:11},{label:`12`,value:12},{label:`14`,value:14},{label:`16`,value:16},{label:`18`,value:18},{label:`20`,value:20},{label:`22`,value:22},{label:`24`,value:24},{label:`26`,value:26},{label:`28`,value:28},{label:`36`,value:36},{label:`48`,value:48},{label:`72`,value:72}],Gi=[{label:`toolbar.heading.normal`,value:w.NORMAL_TEXT},{label:`toolbar.heading.title`,value:w.TITLE},{label:`toolbar.heading.subTitle`,value:w.SUBTITLE},{label:`toolbar.heading.1`,value:w.HEADING_1},{label:`toolbar.heading.2`,value:w.HEADING_2},{label:`toolbar.heading.3`,value:w.HEADING_3},{label:`toolbar.heading.4`,value:w.HEADING_4},{label:`toolbar.heading.5`,value:w.HEADING_5}],Ki=`UI_FONT_SIZE_COMPONENT`,qi=(e,t)=>{let n=j(!1);k(()=>{if(n.current)return e();n.current=!0},t)};function Ji(e,t){let n=Ti(t.handler);k(()=>{let t=t=>{e.current&&t.target&&!e.current.contains(t.target)&&n()};return document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`mousedown`,t)}},[n,e])}function Yi(e,t=300){let n=j(null);return sr((...r)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(...r)},t)},[e,t])}const Xi=e=>typeof e==`number`;function Zi(e){let t=j(e);return t.current=e,t}const Qi=(e,t)=>{let{containerTarget:n,itemHeight:r,overscan:i=5}=t,a=Zi(r),[o,s]=M(null),c=j(!1),[l,u]=M([]),[d,f]=M({height:void 0,marginTop:void 0}),p=(t,n)=>{if(typeof a.current==`number`)return Math.ceil(t/a.current);let r=0,i=0;for(let o=n;o<e.length;o++){let n=a.current(o,e[o]);if(r+=n,i=o,r>=t)break}return i-n},m=t=>{if(Xi(a.current))return Math.floor(t/a.current);let n=0,r=0;for(let i=0;i<e.length;i++){let o=a.current(i,e[i]);if(n+=o,n>=t){r=i;break}}return r+1},h=t=>typeof a.current==`number`?t*a.current:e.slice(0,t).reduce((t,n,r)=>t+a.current(r,e[r]),0),g=A(()=>Xi(a.current)?e.length*a.current:e.reduce((t,n,r)=>t+a.current(r,e[r]),0),[e]),_=()=>{let t=n.current;if(t){let{scrollTop:n,clientHeight:r}=t,a=m(n),o=p(r,a),s=Math.max(0,a-i),c=Math.min(e.length,a+o+i),l=h(s);f({height:`${g-l}px`,marginTop:`${l}px`}),u(e.slice(s,c).map((e,t)=>({data:e,index:t+s})))}};return k(()=>{if(n.current){let e=()=>{let e=n.current.clientWidth,t=n.current.clientHeight;(e!==(o==null?void 0:o.width)||t!==(o==null?void 0:o.height))&&s({width:e,height:t})};e();let t=new ResizeObserver(e);return t.observe(n.current),()=>{t.disconnect()}}},[]),k(()=>{!(o!=null&&o.width)||!(o!=null&&o.height)||_()},[o==null?void 0:o.width,o==null?void 0:o.height,e]),[l,{wrapperStyle:d,scrollTo:Ti(e=>{let t=n.current;t&&(c.current=!0,t.scrollTop=h(e),_())}),containerProps:{onScroll:e=>{if(c.current){c.current=!1;return}e.preventDefault(),_()}}}]};function $i(e,t,...n){return e.t(t)}function ea(e){let{barColor:t,progress:n,onTerminate:r,onClearProgress:i}=e,{count:a,done:o,label:s=``}=n,c=j(null),[l,u]=M(!1);return k(()=>{let e=c.current;if(a===0&&o===0){u(!1),e.style.width=`0%`;return}else if(a>0){u(!0);let t=Math.floor(o/a*100);o===a?requestAnimationFrame(()=>{e.style.width=`${t-1}%`,requestAnimationFrame(()=>{e.style.width=`${t}%`})}):e.style.width=`${t}%`}let t=()=>{o===a&&(u(!1),i&&i())};return e.addEventListener(`transitionend`,t),()=>{e.removeEventListener(`transitionend`,t)}},[a,o]),L(`div`,{className:R(`univer-mx-2 univer-flex univer-items-center univer-gap-2`,{"univer-flex":l,"univer-hidden univer-w-0":!l}),children:[I(Ir,{showIfEllipsis:!0,title:s,children:I(`span`,{className:`univer-w-24 univer-truncate univer-text-right univer-text-xs`,children:s})}),I(`div`,{className:`univer-h-1 univer-w-40 univer-overflow-hidden univer-rounded-lg univer-bg-gray-200`,children:I(`div`,{ref:c,className:`univer-h-full univer-bg-primary-600 univer-transition-[width]`,style:{backgroundColor:t}})}),I(`button`,{className:`univer-flex univer-size-4 univer-cursor-pointer univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-p-0 hover:univer-opacity-50`,type:`button`,onClick:r,children:I(ct,{className:`univer-size-3.5 dark:!univer-text-white`})})]})}const ta=`UNI_DISABLE_CHANGING_FOCUS`,na=E(`ui.message.service`);let ra=class extends a{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(this._errorService.error$.subscribe(e=>{this._messageService.show({content:e.errorKey,type:Mr.Error})}))}};ra=U([H(0,b(l)),H(1,na)],ra);const ia=`univer.command.copy`,aa={id:ia,name:ia,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:()=>!0},oa=`univer.command.cut`,sa={id:oa,name:oa,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:async()=>!0},ca=`univer.command.paste`,la={id:ca,name:ca,multi:!0,priority:0,type:r.COMMAND,preconditions:()=>!1,handler:()=>!0},ua=`sheet.command.paste-by-short-key`;let W=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.BACKSPACE=8]=`BACKSPACE`,e[e.TAB=9]=`TAB`,e[e.ENTER=13]=`ENTER`,e[e.SHIFT=16]=`SHIFT`,e[e.CTRL=17]=`CTRL`,e[e.ESC=27]=`ESC`,e[e.SPACE=32]=`SPACE`,e[e.ARROW_LEFT=37]=`ARROW_LEFT`,e[e.ARROW_UP=38]=`ARROW_UP`,e[e.ARROW_RIGHT=39]=`ARROW_RIGHT`,e[e.ARROW_DOWN=40]=`ARROW_DOWN`,e[e.INSERT=45]=`INSERT`,e[e.DELETE=46]=`DELETE`,e[e.Digit0=48]=`Digit0`,e[e.Digit1=49]=`Digit1`,e[e.Digit2=50]=`Digit2`,e[e.Digit3=51]=`Digit3`,e[e.Digit4=52]=`Digit4`,e[e.Digit5=53]=`Digit5`,e[e.Digit6=54]=`Digit6`,e[e.Digit7=55]=`Digit7`,e[e.Digit8=56]=`Digit8`,e[e.Digit9=57]=`Digit9`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.F1=112]=`F1`,e[e.F2=113]=`F2`,e[e.F3=114]=`F3`,e[e.F4=115]=`F4`,e[e.F5=116]=`F5`,e[e.F6=117]=`F6`,e[e.F7=118]=`F7`,e[e.F8=119]=`F8`,e[e.F9=120]=`F9`,e[e.F10=121]=`F10`,e[e.F11=122]=`F11`,e[e.F12=123]=`F12`,e[e.NUM_LOCK=144]=`NUM_LOCK`,e[e.SCROLL_LOCK=145]=`SCROLL_LOCK`,e[e.EQUAL=187]=`EQUAL`,e[e.COMMA=188]=`COMMA`,e[e.MINUS=189]=`MINUS`,e[e.PERIOD=190]=`PERIOD`,e[e.BACK_SLASH=220]=`BACK_SLASH`,e}({});const da={[W.BACKSPACE]:`Backspace`,[W.TAB]:`Tab`,[W.ENTER]:`Enter`,[W.DELETE]:`Del`,[W.ESC]:`Esc`,[W.SPACE]:`Space`,[W.ARROW_LEFT]:`←`,[W.ARROW_RIGHT]:`→`,[W.ARROW_UP]:`↑`,[W.ARROW_DOWN]:`↓`,[W.Digit0]:`0`,[W.Digit1]:`1`,[W.Digit2]:`2`,[W.Digit3]:`3`,[W.Digit4]:`4`,[W.Digit5]:`5`,[W.Digit6]:`6`,[W.Digit7]:`7`,[W.Digit8]:`8`,[W.Digit9]:`9`,[W.A]:`A`,[W.B]:`B`,[W.C]:`C`,[W.D]:`D`,[W.E]:`E`,[W.F]:`F`,[W.G]:`G`,[W.H]:`H`,[W.I]:`I`,[W.J]:`J`,[W.K]:`K`,[W.L]:`L`,[W.M]:`M`,[W.N]:`N`,[W.O]:`O`,[W.P]:`P`,[W.Q]:`Q`,[W.R]:`R`,[W.S]:`S`,[W.T]:`T`,[W.U]:`U`,[W.V]:`V`,[W.W]:`W`,[W.X]:`X`,[W.Y]:`Y`,[W.Z]:`Z`,[W.F1]:`F1`,[W.F2]:`F2`,[W.F3]:`F3`,[W.F4]:`F4`,[W.F5]:`F5`,[W.F6]:`F6`,[W.F7]:`F7`,[W.F8]:`F8`,[W.F9]:`F9`,[W.F10]:`F10`,[W.F11]:`F11`,[W.F12]:`F12`,[W.MINUS]:`-`,[W.EQUAL]:`=`,[W.PERIOD]:`.`,[W.COMMA]:`,`,[W.BACK_SLASH]:`\\`};let G=function(e){return e[e.SHIFT=1024]=`SHIFT`,e[e.ALT=2048]=`ALT`,e[e.CTRL_COMMAND=4096]=`CTRL_COMMAND`,e[e.MAC_CTRL=8192]=`MAC_CTRL`,e}({});function fa(e,t,n){return window.addEventListener(e,t,n),D(()=>window.removeEventListener(e,t,n))}const pa=E(`ui.platform.service`);var ma=class{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}};const ha=E(`ui.shortcut.service`);let ga=class extends a{constructor(e,t,n,r){super(),this._commandService=e,this._platformService=t,this._contextService=n,this._layoutService=r,z(this,`_shortCutMapping`,new Map),z(this,`_commandIDMapping`,new Map),z(this,`_shortcutChanged$`,new Te),z(this,`shortcutChanged$`,this._shortcutChanged$.asObservable()),z(this,`_forceEscaped`,!1),z(this,`_forceDisabled`,!1),this.disposeWithMe(fa(`keydown`,e=>{this._resolveKeyboardEvent(e)},{capture:!0}))}getAllShortcuts(){return Array.from(this._shortCutMapping.values()).map(e=>Array.from(e.values())).flat()}registerShortcut(e){let t=this._getBindingFromItem(e);if(!t)return D(()=>{});let n=this._shortCutMapping.get(t);n?n.add(e):this._shortCutMapping.set(t,new Set([e]));let r=e.id,i=this._commandIDMapping.get(r);return i?i.add(e):this._commandIDMapping.set(r,new Set([e])),this._emitShortcutChanged(),D(()=>{var n,i,a,o;(n=this._shortCutMapping.get(t))==null||n.delete(e),((i=this._shortCutMapping.get(t))==null?void 0:i.size)===0&&this._shortCutMapping.delete(t),(a=this._commandIDMapping.get(r))==null||a.delete(e),((o=this._commandIDMapping.get(r))==null?void 0:o.size)===0&&this._commandIDMapping.delete(r),this._emitShortcutChanged()})}getShortcutDisplayOfCommand(e){let t=this._commandIDMapping.get(e);if(!t)return null;let n=t.values().next().value;return n?this.getShortcutDisplay(n):null}getShortcutDisplay(e){var t;let n=this._getBindingFromItem(e);if(!n)return null;let r=n&G.CTRL_COMMAND,i=n&G.SHIFT,a=n&G.ALT,o=n&G.MAC_CTRL,s=(t=da[n&255])==null?`<->`:t;return this._platformService.isMac?`${r?`⌘+`:``}${i?`⇧+`:``}${a?`⌥+`:``}${o?`⌃+`:``}${s}`:`${r?`Ctrl+`:``}${i?`Shift+`:``}${a?`Alt+`:``}${s}`}_emitShortcutChanged(){this._shortcutChanged$.next()}forceEscape(){return this._forceEscaped=!0,D(()=>this._forceEscaped=!1)}forceDisable(){return this._forceDisabled=!0,D(()=>{this._forceDisabled=!1})}_resolveKeyboardEvent(e){let t=this.dispatch(e);t&&(this._commandService.executeCommand(t.id,t.staticParameters),e.preventDefault())}dispatch(e){if(this._forceEscaped||this._forceDisabled||this._layoutService&&!this._layoutService.checkElementInCurrentContainers(e.target))return;let t=this._deriveBindingFromEvent(e);if(t===null)return;let n=this._shortCutMapping.get(t);if(n!==void 0)return Array.from(n).sort((e,t)=>{var n,r;return((n=t.priority)==null?0:n)-((r=e.priority)==null?0:r)}).find(e=>{var t,n;return(t=(n=e.preconditions)==null?void 0:n.call(e,this._contextService))==null?!0:t})}_getBindingFromItem(e){return this._platformService.isMac&&e.mac?e.mac:this._platformService.isWindows&&e.win?e.win:this._platformService.isLinux&&e.linux?e.linux:e.binding}_deriveBindingFromEvent(e){let{shiftKey:t,metaKey:n,altKey:r,keyCode:i}=e,a=i;return t&&(a|=G.SHIFT),r&&(a|=G.ALT),(this._platformService.isMac?n:e.ctrlKey)&&(a|=G.CTRL_COMMAND),this._platformService.isMac&&e.ctrlKey&&(a|=G.MAC_CTRL),a}};ga=U([H(0,f),H(1,pa),H(2,h),H(3,re(Li))],ga);function _a(e){return e.getContextValue(d)}function va(e){return e.getContextValue(d)&&!(e.getContextValue(c)||e.getContextValue(u))}const ya={id:aa.id,description:`shortcut.copy`,group:`1_common-edit`,binding:W.C|G.CTRL_COMMAND,preconditions:_a},ba={id:sa.id,description:`shortcut.cut`,group:`1_common-edit`,binding:W.X|G.CTRL_COMMAND,preconditions:_a},xa={id:la.id,description:`shortcut.paste`,group:`1_common-edit`,binding:W.V|G.CTRL_COMMAND,preconditions:()=>!1},Sa={id:ce.id,description:`shortcut.undo`,group:`1_common-edit`,binding:W.Z|G.CTRL_COMMAND,preconditions:va},Ca={id:ie.id,description:`shortcut.redo`,group:`1_common-edit`,binding:W.Y|G.CTRL_COMMAND,preconditions:va};let wa=class extends a{constructor(e,t){super(),this._shortcutService=e,this._commandService=t,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts()}_registerCommands(){[sa,aa,la].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e)))}_registerShortcuts(){let e=[Sa,Ca];e.push(ba,ya,xa),e.forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}};wa=U([H(0,ha),H(1,f)],wa);let Ta=function(e){return e.RIBBON=`ribbon`,e.CONTEXT_MENU=`contextMenu`,e}({}),K=function(e){return e.START=`ribbon.start`,e.INSERT=`ribbon.insert`,e.FORMULAS=`ribbon.formulas`,e.DATA=`ribbon.data`,e.VIEW=`ribbon.view`,e.OTHERS=`ribbon.others`,e}({}),Ea=function(e){return e.HISTORY=`ribbon.start.history`,e.FORMAT=`ribbon.start.format`,e.LAYOUT=`ribbon.start.layout`,e.OTHERS=`ribbon.start.others`,e}({}),Da=function(e){return e.EDIT=`ribbon.insert.edit`,e.MEDIA=`ribbon.insert.media`,e.OTHERS=`ribbon.insert.others`,e}({}),Oa=function(e){return e.BASIC=`ribbon.formulas.basic`,e.OTHERS=`ribbon.formulas.others`,e}({}),ka=function(e){return e.FORMULAS=`ribbon.data.formulas`,e.RULES=`ribbon.data.rules`,e.ORGANIZATION=`ribbon.data.organization`,e.OTHERS=`ribbon.data.others`,e}({}),Aa=function(e){return e.DISPLAY=`ribbon.view.display`,e.VISIBILITY=`ribbon.view.Visibility`,e.OTHERS=`ribbon.view.others`,e}({}),ja=function(e){return e.OTHERS=`ribbon.others.others`,e}({}),Ma=function(e){return e.MAIN_AREA=`contextMenu.mainArea`,e.COL_HEADER=`contextMenu.colHeader`,e.ROW_HEADER=`contextMenu.rowHeader`,e.FOOTER_TABS=`contextMenu.footerTabs`,e.FOOTER_MENU=`contextMenu.footerMenu`,e.PARAGRAPH=`contextMenu.paragraph`,e.DRAWING=`contextMenu.drawing`,e}({}),q=function(e){return e.QUICK=`contextMenu.quick`,e.FORMAT=`contextMenu.format`,e.LAYOUT=`contextMenu.layout`,e.DATA=`contextMenu.data`,e.OTHERS=`contextMenu.others`,e}({});const J=E(`univer.menu-manager-service`);let Na=class extends a{constructor(e,t){super(),this._injector=e,this._configService=t,z(this,`menuChanged$`,new Te),z(this,`_menu`,{[Ta.RIBBON]:{[K.START]:{order:0,[Ea.HISTORY]:{order:0},[Ea.FORMAT]:{order:1},[Ea.LAYOUT]:{order:2},[Ea.OTHERS]:{order:3}},[K.INSERT]:{order:1,[Da.EDIT]:{order:0},[Da.MEDIA]:{order:1},[Da.OTHERS]:{order:2}},[K.FORMULAS]:{order:2,[Oa.BASIC]:{order:0},[Oa.OTHERS]:{order:1}},[K.DATA]:{order:3,[ka.FORMULAS]:{order:0},[ka.RULES]:{order:1},[ka.ORGANIZATION]:{order:2},[ka.OTHERS]:{order:3}},[K.VIEW]:{order:4,[Aa.DISPLAY]:{order:0},[Aa.VISIBILITY]:{order:0},[Aa.OTHERS]:{order:0}},[K.OTHERS]:{order:5,[ja.OTHERS]:{order:0}}},[Ta.CONTEXT_MENU]:{[Ma.MAIN_AREA]:{order:0,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.PARAGRAPH]:{order:0,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.COL_HEADER]:{order:1,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.ROW_HEADER]:{order:2,[q.QUICK]:{order:-1,quickLayout:`icon`},[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.FOOTER_TABS]:{order:3,[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[Ma.FOOTER_MENU]:{order:4,[q.OTHERS]:{order:3}},[Ma.DRAWING]:{order:5,[q.OTHERS]:{order:3}}}})}dispose(){this.menuChanged$.complete()}mergeMenu(e,t){let n=t==null?this._menu:t;for(let[t,r]of Object.entries(n))if(t in e){let r=t;n[r]=_e({},n[r],e[r]),this.menuChanged$.next()}else typeof r==`object`&&this.mergeMenu(e,r)}appendRootMenu(e){this._menu=_e({},this._menu,e),this.menuChanged$.next()}_buildMenuSchema(e){let t=[];for(let[n,r]of Object.entries(e)){let e={key:n,order:r.order,title:r.title,quickLayout:r.quickLayout};if(r.menuItemFactory){let t=this._injector.invoke(r.menuItemFactory);if(t){let n=this._configService.getConfig(`menu`);if(n&&t.id in n){let r=t.id;e.item=_i(t,n[r])}else e.item=t}}if(typeof r==`object`){let n=this._buildMenuSchema(r);n.length>0&&(e.children=n.sort((e,t)=>e.order-t.order)),(e.item||e.children)&&t.push(e)}}return t}getMenuByPositionKey(e){let t=n=>{if(e in n)return this._buildMenuSchema(n[e]);for(let r in n){if(r===e)return this._buildMenuSchema(n[r]);if(typeof n[r]==`object`){let e=t(n[r]);if(e)return e}}};return t(this._menu)}getFlatMenuByPositionKey(e){let t=this.getMenuByPositionKey(e);function n(e){return e.reduce((e,t)=>t.children?[...e,t,...n(t.children)]:[...e,t],[])}return n(t)}};Na=U([H(0,b(x)),H(1,p)],Na);function Pa(){let e=P(ha),t=P(C),n=F(t.currentLocale$),[r,i]=M([]),a=sr(()=>{let n=new Map,r=e.getAllShortcuts().filter(e=>!!e.group);for(let i of r){var a;let r=i.group,o={title:t.t((a=i.description)==null?i.id:a),shortcut:e.getShortcutDisplay(i)};if(!/\d+_[a-zA-Z0-9]/.test(r))throw Error(`[ShortcutPanel]: Invalid shortcut group: ${r}!`);n.has(r)||n.set(r,[]),n.get(r).push(o)}i(Array.from(n.entries()).map(([e,n])=>{let r=e.split(`_`)[0],i=e.slice(r.length+1);return{sequence:+r,name:t.t(i),items:fe(n,e=>e.title+e.shortcut)}}).sort((e,t)=>e.sequence-t.sequence))},[e,t,n]);return k(()=>{a();let t=e.shortcutChanged$.subscribe(()=>a());return()=>t.unsubscribe()},[e,a]),I(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-gray-900 dark:!univer-text-white`,children:r.map(e=>L(`li`,{children:[I(`div`,{className:`univer-flex univer-h-10 univer-items-center univer-text-sm univer-font-semibold`,children:e.name}),I(`ul`,{className:R(`univer-list-none univer-p-0`,Hr),children:e.items.map(e=>L(`li`,{className:`univer-flex univer-h-10 univer-items-center univer-justify-between univer-py-0.5 univer-text-sm last:univer-border-b-0`,children:[I(`span`,{className:`univer-line-clamp-2`,children:e.title}),e.shortcut&&I(jr,{keyboard:e.shortcut})]},`${e.title}-${e.shortcut}`))})]},e.name))})}const Fa={id:fi.id,binding:G.CTRL_COMMAND|W.BACK_SLASH,description:`shortcut.shortcut-panel`,group:`10_global-shortcut`};let Ia=class extends a{constructor(e,t,n,r,i){super(),this._menuManagerService=r,this.disposeWithMe(t.register(di,Pa)),this.disposeWithMe(i.registerCommand(fi)),this.disposeWithMe(n.registerShortcut(Fa))}};Ia=U([H(0,b(x)),H(1,b(B)),H(2,ha),H(3,J),H(4,f)],Ia);let Y=function(e){return e[e.BUTTON=0]=`BUTTON`,e[e.SELECTOR=1]=`SELECTOR`,e[e.BUTTON_SELECTOR=2]=`BUTTON_SELECTOR`,e[e.SUBITEMS=3]=`SUBITEMS`,e}({});function La(e){return e.type===Y.BUTTON_SELECTOR}const Ra=(e,t)=>{let n=e.get(v),r=e.get(h);return De([n.undoRedoStatus$.pipe(ei(e=>t?e.undos<=0:e.redos<=0)),Fe([Ie({}),r.contextChanged$])]).pipe(ei(([e])=>e||r.getContextValue(c)||r.getContextValue(u)))};function za(e){return{id:ce.id,type:Y.BUTTON,icon:`UndoIcon`,title:`Undo`,tooltip:`toolbar.undo`,disabled$:Ra(e,!0)}}function Ba(e){return{id:ie.id,type:Y.BUTTON,icon:`RedoIcon`,title:`Redo`,tooltip:`toolbar.redo`,disabled$:Ra(e,!1)}}function Va(){return{id:fi.id,title:`toggle-shortcut-panel`,tooltip:`toggle-shortcut-panel`,icon:`ShortcutIcon`,type:Y.BUTTON}}const Ha={[Ea.HISTORY]:{[ce.id]:{order:0,menuItemFactory:za},[ie.id]:{order:1,menuItemFactory:Ba}},[Ea.OTHERS]:{[fi.id]:{order:1,menuItemFactory:Va}}};let X=function(e){return e.GLOBAL=`global`,e.HEADER=`header`,e.HEADER_MENU=`header-menu`,e.CONTENT=`content`,e.FOOTER=`footer`,e.LEFT_SIDEBAR=`left-sidebar`,e.FLOATING=`floating`,e.UNIT=`unit`,e.CUSTOM_HEADER=`custom-header`,e.CUSTOM_LEFT=`custom-left`,e.CUSTOM_RIGHT=`custom-right`,e.CUSTOM_FOOTER=`custom-footer`,e.TOOLBAR=`toolbar`,e}({});const Z=E(`ui.parts.service`);var Ua=class extends a{constructor(...e){super(...e),z(this,`_componentsByPart`,new Map),z(this,`_componentRegistered$`,new Te),z(this,`componentRegistered$`,this._componentRegistered$.asObservable()),z(this,`_uiVisible`,new Map),z(this,`_uiVisibleChange$`,new Te),z(this,`uiVisibleChange$`,this._uiVisibleChange$.asObservable())}dispose(){super.dispose(),this._componentsByPart.clear(),this._uiVisible.clear(),this._componentRegistered$.complete(),this._uiVisibleChange$.complete()}setUIVisible(e,t){this._uiVisible.set(e,t),this._uiVisibleChange$.next({ui:e,visible:t})}isUIVisible(e){var t;return(t=this._uiVisible.get(e))==null?!0:t}registerComponent(e,t){let n=t(),r=(this._componentsByPart.get(e)||this._componentsByPart.set(e,new Set).get(e)).add(n);return this._componentRegistered$.next(e),D(()=>{r.delete(n),r.size===0&&this._componentsByPart.delete(e),this._componentRegistered$.next(e)})}getComponents(e){return new Set([...this._componentsByPart.get(e)||new Set])}},Wa=class{constructor(){z(this,`_domLayerMap`,new Map),z(this,`_domLayers$`,new O([])),z(this,`domLayers$`,this._domLayers$.asObservable())}get domLayers(){return Array.from(this._domLayerMap.entries())}_notice(){this._domLayers$.next(Array.from(this._domLayerMap.entries()))}updateFloatDom(e,t){let n=this._domLayerMap.get(e);n&&(this._domLayerMap.set(e,{...n,...t}),this._notice())}addFloatDom(e){this._domLayerMap.set(e.id,e),this._notice()}removeFloatDom(e){this._domLayerMap.delete(e)&&this._notice()}removeAll(){this._domLayerMap.clear(),this._notice()}};const Ga=or(e=>{var t,n;let{layer:r,id:i}=e,a=A(()=>r.position$.pipe(ke((e,t)=>e.absolute.left===t.absolute.left&&e.absolute.top===t.absolute.top&&e.endX-e.startX===t.endX-t.startX&&e.endY-e.startY===t.endY-t.startY)),[r.position$]),s=P(y),c=F(A(()=>r.position$.pipe(je()),[r.position$])),l=j(null),u=j(null),d=j(`transform: rotate(${c==null?void 0:c.rotate}deg) translate(${c==null?void 0:c.startX}px, ${c==null?void 0:c.startY}px)`),f=j((t=c==null?void 0:c.startY)==null?0:t),p=j((n=c==null?void 0:c.startX)==null?0:n),m=j({}),h=typeof r.componentKey==`string`?P(B).get(r.componentKey):r.componentKey,g=A(()=>({data:r.data,...r.props}),[r.data,r.props]);k(()=>{let e=r.position$.subscribe(e=>{if(d.current=`rotate(${e.rotate}deg)`,f.current=e.startY,p.current=e.startX,l.current){var t;l.current.style.transform=d.current,l.current.style.top=`${f.current}px`,l.current.style.left=`${p.current}px`,l.current.style.opacity=`${(t=e.opacity)==null?1:t}`}}),t=a.subscribe(e=>{if(l.current&&(l.current.style.width=`${Math.max(e.endX-e.startX-2,0)}px`,l.current.style.height=`${Math.max(e.endY-e.startY-2,0)}px`),u.current){let t={width:`${e.width-4}px`,height:`${e.height-4}px`,left:`${e.absolute.left?0:`auto`}`,top:`${e.absolute.top?0:`auto`}`,right:`${e.absolute.left?`auto`:0}`,bottom:`${e.absolute.top?`auto`:0}`};u.current.style.width=t.width,u.current.style.height=t.height,u.current.style.left=t.left,u.current.style.top=t.top,u.current.style.right=t.right,u.current.style.bottom=t.bottom,m.current=t}});return()=>{e.unsubscribe(),t.unsubscribe()}},[r.position$,a]);let _=s.getUnit(r.unitId),v=_ instanceof o?_.getDisabled():void 0,b=A(()=>h?I(h,{...g,unitId:r.unitId,unit:_,floatDomId:r.id,context:{docDisabled:v,root:u}}):null,[h,g]);return c?I(`div`,{ref:l,className:`univer-z-10`,style:{position:`absolute`,top:f.current,left:p.current,width:Math.max(c.endX-c.startX-2,0),height:Math.max(c.endY-c.startY-2,0),transform:d.current,overflow:`hidden`,transformOrigin:`center center`},onPointerMove:e=>{r.onPointerMove(e.nativeEvent)},onPointerDown:e=>{r.onPointerDown(e.nativeEvent)},onPointerUp:e=>{r.onPointerUp(e.nativeEvent)},onWheel:e=>{r.onWheel(e.nativeEvent)},children:I(`div`,{id:i,ref:u,className:`univer-absolute univer-overflow-hidden`,style:{...m.current},children:b})}):null}),Ka=({unitId:e})=>{var t;let n=P(y),r=F(P(Wa).domLayers$),i=F(n.focused$),a=e||i;return r==null||(t=r.filter(e=>e[1].unitId===a))==null?void 0:t.map(e=>{var t;return I(Ga,{id:(t=e[1].domId)==null?e[0]:t,layer:e[1]},e[0])})},qa=E(`ui.popup.service`);var Ja=class extends a{constructor(...e){super(...e),z(this,`_popupMap`,new Map),z(this,`_popups$`,new O([])),z(this,`popups$`,this._popups$.asObservable()),z(this,`_activePopupId`,null)}get popups(){return Array.from(this._popupMap.entries())}get activePopupId(){return this._activePopupId}_update(){this._popups$.next(Array.from(this._popupMap.entries()))}dispose(){super.dispose(),this._popups$.next([]),this._popups$.complete(),this._popupMap.clear()}addPopup(e){let t=pe();return this._popupMap.set(t,{...e,onActiveChange:e=>{e?this._activePopupId=t:this._activePopupId===t&&(this._activePopupId=null)}}),this._update(),t}removePopup(e){this._popupMap.delete(e)&&this._update()}removeAll(){this._popupMap.clear(),this._update()}};const Ya=rr({current:void 0});function Xa(e){let{position:t,width:n,height:r,containerHeight:i,containerWidth:a,direction:o=`vertical`,noPushMinimumGap:s=!1}=e,c=s?-1/0:8,l=s?1/0:i-r-8,u=s?-1/0:8,d=s?1/0:a-n-8;if(o===`vertical`||o.indexOf(`top`)===0||o.indexOf(`bottom`)===0){let{left:e,top:i,right:s,bottom:f}=t,p=o===`vertical`&&f>l||o.indexOf(`top`)>-1?{top:Math.max(Math.min(i-r,l),c)}:{top:Math.max(Math.min(f,l),c)},m;if(o.includes(`center`)){let t=(s-e-n)/2;m=Math.max(e+t,u)+n>a?{left:Math.max(Math.min(d,s-n-t),u)}:{left:Math.max(u,Math.min(e+t,d))}}else m=o.includes(`right`)?{left:Math.max(Math.min(s-n,d),u)}:o.includes(`left`)?{left:Math.max(Math.min(e,d),u)}:e+n>a?Math.max(s-n,u)<8?{left:Math.max(Math.min(e,d),u)}:{left:Math.max(Math.min(s-n,d),u)}:{left:Math.max(Math.min(e,d),u)};return{...p,...m}}let{left:f,top:p,right:m,bottom:h}=t,g=o.includes(`left`)?{left:Math.max(Math.min(f-n,d),u)}:{left:Math.max(Math.min(m,d),u)},_;if(o.includes(`center`)){let e=(h-p-r)/2;_=Math.max(p+e,c)+r>i?{top:Math.max(Math.min(l,h-r-e),c)}:{top:Math.max(c,Math.min(p+e,l))}}else _=o.includes(`top`)?{top:Math.max(Math.min(p,l),c)}:o.includes(`bottom`)?{top:Math.max(Math.min(h-r,l),c)}:p+r>i?Math.max(h-r,c)<8?{top:Math.max(Math.min(p,l),c)}:{top:Math.max(Math.min(h-r,l),c)}:{top:Math.max(Math.min(p,l),c)};return{..._,...g}}function Za(e){var t;let{mask:n,portal:r,children:i,anchorRect$:a,direction:o=`vertical`,onClickOutside:s,excludeOutside:c,excludeRects:l,onPointerEnter:u,onPointerLeave:d,onClick:f,hidden:m,onContextMenu:h,zIndex:g=1020,maskZIndex:_=100,onMaskClick:v,noPushMinimumGap:y,autoRelayout:b=!0}=e,x=j(null),ee=Ti(s==null?(()=>{}):s),te=Ti(h==null?(()=>{}):h),S=j({top:-9999,left:-9999}),C=l,ne=P(p),w=j(void 0),re=ne.getConfig(Ai),T=(t=re==null?void 0:re.popupRootId)==null?`univer-popup-portal`:t,ie=Ti(e=>{requestAnimationFrame(()=>{if(!x.current)return;let{clientWidth:t,clientHeight:n}=x.current,r=window.innerWidth,i=window.innerHeight;S.current=Xa({position:e,width:t,height:n,containerWidth:r,containerHeight:i,direction:o,noPushMinimumGap:y}),x.current.style.top=`${S.current.top}px`,x.current.style.left=`${S.current.left}px`})});k(()=>{let e;return x.current&&(e=new ResizeObserver(()=>{b&&w.current&&ie(w.current)}),e.observe(x.current)),()=>{e==null||e.disconnect()}},[x.current,b]),k(()=>{let e=a.subscribe(e=>{w.current=e,ie(e)});return()=>e.unsubscribe()},[a,o]),k(()=>{let e=e=>{var t;if(c&&(c.indexOf(e.target)>-1||c.some(t=>t.contains(e.target))))return;let n=e.clientX,r=e.clientY,i=[...(t=C==null?void 0:C.current)==null?[]:t];w.current&&i.push(w.current);for(let e of i)if(n<=e.right&&n>=e.left&&r<=e.bottom&&r>=e.top)return;ee(e)};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[ee,c,C]),k(()=>{let e=e=>{e.ctrlKey&&e.button===0||te()};return window.addEventListener(`contextmenu`,e),()=>{window.removeEventListener(`contextmenu`,e)}},[te]);let ae=L(yr,{children:[n&&I(`div`,{"data-u-comp":`rect-popup-mask`,className:`univer-fixed univer-inset-0 univer-z-[100]`,style:{zIndex:_},onClick:v}),I(`section`,{"data-u-comp":`rect-popup`,ref:x,className:R(`univer-pointer-events-auto univer-fixed univer-left-[-9999px] univer-top-[-9999px] univer-z-[1020]`,{"univer-hidden":m,"univer-animate-in univer-fade-in-70":!m}),style:{...S.current,zIndex:g},onPointerDown:e=>e.stopPropagation(),onClick:f,onPointerEnter:u,onPointerLeave:d,children:I(Ya.Provider,{value:w,children:i})})]});return r?document.getElementById(T)?ri(ae,document.getElementById(T)):null:ae}Za.calcPopupPosition=Xa,Za.useContext=()=>cr(Ya);const Qa=({popup:e,children:t})=>{let[n,r]=M(!1),i=A(()=>e.anchorRect$.pipe(Be(0,Ee),Pe(t=>{var n;let{bottom:r,left:i,right:a,top:o}=t,[s=0,c=0]=(n=e.offset)==null?[]:n;return{left:i-s,right:a+s,top:o-c,bottom:r+c}})),[e.anchorRect$,e.offset]),a=A(()=>{var t,n;return(t=(n=e.hiddenRects$)==null?void 0:n.pipe(Be(0,Ee)))==null?Ie([]):t},[e.hiddenRects$]),o=bi(A(()=>{var t;return(t=e.excludeRects$)==null?void 0:t.pipe(Be(0,Ee))},[e.excludeRects$]),e.excludeRects),{canvasElement:s,hideOnInvisible:c=!0,hiddenType:l=`destroy`}=e;return k(()=>{if(!c)return;let e=De([i,a]).subscribe(([e,t])=>{let{top:n,left:i,bottom:a,right:o}=s.getBoundingClientRect(),c=e.bottom-e.top,l=e.right-e.left,u=t.some(t=>{let n=Math.min(.5*c,10),r=Math.min(.5*l,10);return e.top>=t.top-n&&e.bottom<=t.bottom+n&&e.left>=t.left-r&&e.right<=t.right+r});e.bottom<n||e.top>a||e.right<i||e.left>o||u?r(!0):r(!1)});return()=>e.unsubscribe()},[s,c,i,a]),n&&l===`destroy`?null:I(Za,{...e,hidden:n,anchorRect$:i,direction:e.direction,onClickOutside:e.onClickOutside,excludeOutside:e.excludeOutside,excludeRects:o,...e.customActive?null:{onPointerEnter:()=>{var t;return(t=e.onActiveChange)==null?void 0:t.call(e,!0)},onPointerLeave:()=>{var t;return(t=e.onActiveChange)==null?void 0:t.call(e,!1)}},onClick:e.onClick,onContextMenu:e.onContextMenu,children:t})};function $a(){let e=P(qa),t=P(B);return F(e.popups$,void 0,!0).map(e=>{let[n,r]=e,i=t.get(r.componentKey);return I(Qa,{popup:r,children:i?I(i,{popup:r}):null},n)})}const eo=E(`univer.ribbon-service`);let to=class extends a{constructor(e,t){super(),this._menuManagerService=e,this._univerInstanceService=t,z(this,`_ribbon$`,new O([])),z(this,`ribbon$`,this._ribbon$.asObservable()),z(this,`_activatedTab$`,new O(K.START)),z(this,`activatedTab$`,this._activatedTab$.asObservable()),z(this,`_collapsedIds$`,new O([])),z(this,`collapsedIds$`,this._collapsedIds$.asObservable()),z(this,`_fakeToolbarVisible$`,new O(!1)),z(this,`fakeToolbarVisible$`,this._fakeToolbarVisible$.asObservable()),this._initRibbonSubscription()}setActivatedTab(e){this._activatedTab$.next(e)}setCollapsedIds(e){this._collapsedIds$.next(e)}setFakeToolbarVisible(e){this._fakeToolbarVisible$.next(e)}_initRibbonSubscription(){this.disposeWithMe(De([this._menuManagerService.menuChanged$.pipe(ni(void 0)),this._univerInstanceService.focused$.pipe(ni(void 0))]).subscribe(()=>{this._updateRibbon()}))}_updateRibbon(){let e=this._menuManagerService.getMenuByPositionKey(Ta.RIBBON),t=[],n=[];for(let i of e)if(i.children){for(let e of i.children)if(e.children)for(let i of e.children){var r;(r=i.item)!=null&&r.hidden$&&(t.push(i.item.hidden$),n.push(i.key))}}if(t.length===0){this._ribbon$.next(e);return}De(t).pipe(ni(Array(t.length).fill(!1))).subscribe(t=>{let r=[],i=t.map((e,t)=>e?n[t]:null).filter(e=>!!e);for(let t of e){var a,o;let e={...t,children:[]};if((a=t.children)!=null&&a.length)for(let n of t.children){var s;let t={...n,children:[]},r=!0;if((s=n.children)!=null&&s.length){var c;for(let e of n.children)if(!i.includes(e.key)){var l;(l=t.children)==null||l.push(e)}(c=t.children)!=null&&c.every(e=>{var t;return((t=e.children)==null?void 0:t.length)===0})&&(r=!1)}if(r){var u;(u=e.children)==null||u.push(t)}}(o=e.children)!=null&&o.length&&e.children.every(e=>{var t;return(t=e.children)==null?void 0:t.length})&&r.push(e)}this._ribbon$.next(r)}).unsubscribe()}};to=U([H(0,J),H(1,y)],to);function Q(e){let{components:t,fallback:n,sharedProps:r}=e;return!t||t.size===0?n==null?null:n:Array.from(t.values()).map((e,t)=>{var n;return ir(e,{key:`${(n=e.displayName)==null?t:n}`,...r})})}function $(e,t){var n;let r=(n=t==null?void 0:t.get(Z))==null?P(Z):n,i=F(A(()=>r.uiVisibleChange$.pipe(Ae(t=>t.ui===e)),[e,r])),a=j(0);return A(()=>r.isUIVisible(e)?r.getComponents(e):new Set,[F(()=>r.componentRegistered$.pipe(Ae(t=>t===e),Oe(200),Pe(()=>a.current+=1),Re(a.current+=1)),void 0,void 0,[r,e,i])])}function no({ribbon:e,activatedTab:t,onSelectTab:n}){let r=P(C);return I(`div`,{className:`univer-flex univer-size-full univer-items-center univer-justify-center univer-gap-1 univer-overflow-x-auto univer-rounded-md univer-bg-gray-50 univer-px-3 dark:!univer-bg-gray-900`,role:`tablist`,"aria-label":r.t(`ribbon.menu`),children:e.map(e=>{let i=t===e.key;return I(`button`,{type:`button`,role:`tab`,"aria-selected":i,title:r.t(e.key),onClick:()=>n(e),className:R(`univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500 dark:!univer-focus:ring-primary-300 univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1 univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm univer-transition-colors`,i?`
2
2
  univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm
3
3
  dark:!univer-bg-primary-900 dark:!univer-text-primary-300
4
4
  `:`
@@ -13,7 +13,7 @@ univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate
13
13
  dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
14
14
  disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
15
15
  hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
16
- `;function oo(e){let{children:t,className:n,style:r,disabled:i=!1,active:a=!1,noIcon:o,onClick:s,onDoubleClick:c,...l}=e,u=e=>{if(i){e.preventDefault();return}s&&s(e)},d=e=>{if(i){e.preventDefault();return}c&&c(e)};return I(`button`,{type:`button`,className:R(ao,n,{"univer-px-2":o,"!univer-bg-gray-200 dark:!univer-bg-gray-500":a}),style:r,disabled:i,onClick:u,onDoubleClick:d,...l,children:t})}function so(e){let{disabled$:t,hidden$:n,activated$:r,value$:i}=e,a;if(La(e)){let{selections:t}=e;if(Array.isArray(t)){var o;a=t==null||(o=t[0])==null?void 0:o.value$}}let[s,c]=M(),[l,u]=M(!1),[d,f]=M(!1),[p,m]=M(!1),[h,g]=M();return k(()=>{let e=[];return t&&e.push(t.subscribe(e=>u(e))),n&&e.push(n.subscribe(e=>m(e))),r&&e.push(r.subscribe(e=>f(e))),i&&e.push(i.subscribe(e=>c(e))),a&&e.push(a.subscribe(e=>g(e))),()=>e.forEach(e=>e.unsubscribe())},[r,t,n,i,a]),{disabled:l,value:s,activated:d,hidden:p,selectionsValue:h}}const co=rr({dropdownVisible:!1,setDropdownVisible:e=>{}}),lo=ar((e,t)=>{let{children:n,...r}=e,i=j(null),[a,o]=M(!1),[s,c]=M(!1);function l(e){o(s?!1:e)}function u(e){c(e),o(!1)}let d=A(()=>({dropdownVisible:s,setDropdownVisible:u}),[s]);return lr(t,()=>({el:i.current})),r.title?I(Ir,{visible:a,onVisibleChange:l,...r,children:I(`span`,{ref:i,children:I(co.Provider,{value:d,children:n})})}):I(`span`,{ref:i,children:n})});function uo(e){let{children:t,overlay:n,disabled:r,align:i=`start`}=e,{dropdownVisible:a,setDropdownVisible:o}=cr(co);function s(e){o(e)}return I(Er,{align:i,overlay:I(`div`,{className:`univer-grid univer-gap-2`,children:n}),disabled:r,open:a,onOpenChange:s,children:I(`div`,{className:`univer-h-full`,onClick:e=>e.stopPropagation(),children:t})})}function fo({icon:e,value:t,option:n,onOptionSelect:r}){var i;let a=e=>{r==null||r({value:e,label:n==null?void 0:n.label,commandId:n==null?void 0:n.commandId})},o=typeof n.label==`string`||typeof n.label==`object`&&((i=n.label)==null?void 0:i.selectable)!==!1;return L(`div`,{className:R(`univer-relative univer-flex univer-items-center univer-gap-2`,{"univer-pl-6":o}),children:[o&&String(t)===String(n.value)&&I(ot,{className:`univer-absolute univer-left-1 univer-top-0.5 univer-text-primary-600`}),I(V,{className:`univer-text-sm`,icon:e,value$:n.value$,value:n.value,label:n.label,onChange:a})]})}function po({menuId:e,slot:t,value:n,options:r,children:i,disabled:a,onOptionSelect:o}){let{dropdownVisible:s,setDropdownVisible:c}=cr(co),l=P(J),[u,d]=M({}),f=A(()=>e?l.getMenuByPositionKey(e):[],[e]),p=A(()=>f.filter(e=>{var t;return e.children?!u[((t=e.key)==null?void 0:t.toString())||``]:!u[e.key]}),[f,u]);function m(e){c(e)}if(k(()=>{let e=[];return f.forEach(t=>{if(t.children){let n=De(t.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t})).subscribe(e=>{let n=e.every(e=>e===!0);d(e=>({...e,[t.key]:n}))});e.push(n)}else{var n;if((n=t.item)!=null&&n.hidden$){let n=t.item.hidden$.subscribe(e=>{d(n=>({...n,[t.key]:e}))});e.push(n)}}}),()=>{e.forEach(e=>e==null?void 0:e.unsubscribe()),d({})}},[f]),t)return I(uo,{disabled:a,overlay:r.map((e,t)=>I(fo,{value:n,option:e,onOptionSelect:o},t)),children:i});if(r!=null&&r.length){let e=r.map(e=>{var t;return{type:`item`,className:R({"focus:univer-bg-white":typeof e.label!=`string`&&((t=e.label)==null?void 0:t.hoverable)===!1}),children:I(fo,{icon:e.icon,value:n,option:e,onOptionSelect:o}),disabled:e.disabled,onSelect:()=>{e.value!==void 0&&(o==null||o({...e}))}}});for(let t of p){if(!t.item)continue;let{title:r,id:i,commandId:a,icon:s}=t.item;if(!r)throw Error(`Menu item title is required`);e.push({type:`item`,children:I(fo,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}return I(Dr,{align:`start`,items:e,disabled:a,open:s,onOpenChange:m,children:i})}else{let e=[];for(let t of p){var h;if(t.item){let{title:r,id:i,commandId:a,icon:s}=t.item;if(!r)throw Error(`Menu item title is required`);e.push({type:`item`,children:I(fo,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}else (h=t.children)!=null&&h.length}return I(Dr,{align:`start`,items:e,disabled:a,open:s,onOpenChange:m,children:i})}}const mo=ar((e,t)=>{let n=P(C),r=P(f),i=P(ua),a=P(B),{value:o,hidden:s,disabled:c,activated:l,selectionsValue:u}=so(e),d=(e,t)=>{i.focus(),r.executeCommand(e,t)},{tooltip:p,shortcut:m,icon:h,title:g,label:_,id:v,commandId:y,type:b,slot:x,params:ee}=e,te=n.t(p==null?``:p)+(m?` (${m})`:``),{selections:S}=e,ne=F(A(()=>Ne(S)?S:new Ce(e=>{e.next(S)}),[S])),w=F(A(()=>Ne(h)?h:new Ce(e=>{var t,n;let r=(t=ne==null||(n=ne.find(e=>e.value===o))==null?void 0:n.icon)==null?h:t;e.next(r)}),[h,ne,o]),void 0,!0);function re(t){var n;let r=e.selectionsCommandId,i=y==null?v:y,a=(n=r==null?y:r)==null?v:n;function s(e){if(c)return;let t=a;e.id&&(t=e.id),d(t,{value:e.value})}function f(e){c||d(a,{value:e})}function p(){c||t===Y.BUTTON_SELECTOR&&d(i,{value:o})}return t===Y.BUTTON_SELECTOR?L(`div`,{"data-u-command":v,"data-disabled":c,className:R(`univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-gray-900 dark:!univer-text-white":!c,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c}),children:[I(`div`,{className:R(`univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600`,{"univer-bg-gray-200 dark:!univer-bg-gray-500":l,"univer-bg-gray-100":l&&c}),onClick:p,children:I(V,{icon:w,title:g,value:u==null?o:u,label:_,onChange:f})}),I(po,{menuId:v,slot:x,value:o,options:ne,disabled:c,onOptionSelect:s,children:I(`div`,{className:R(`univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c,"univer-bg-gray-200 dark:!univer-bg-gray-500":l,"univer-bg-gray-100":l&&c}),"data-disabled":c,children:I(pn,{})})})]}):I(po,{menuId:v,slot:x,value:o,options:ne,disabled:c,onOptionSelect:s,children:L(`div`,{"data-u-command":v,className:R(`univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-gap-2 univer-whitespace-nowrap univer-rounded univer-px-1 univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-gray-900 dark:!univer-text-white":!c,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c,"univer-bg-gray-200":l,"univer-bg-gray-100":l&&c}),children:[I(V,{icon:w,title:g,value:o,label:_,onChange:f}),I(`div`,{className:R(`univer-toolbar-selector-trigger univer-flex univer-h-full univer-items-center`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c}),children:I(pn,{})})]})})}function T(){var t;let n=a.get(typeof _==`string`?_:(t=_==null?void 0:_.name)==null?``:t),r=(o==null?typeof ee==`function`:o)?ee():ee;return I(oo,{"data-u-command":v,className:`univer-text-sm`,noIcon:!h,active:l,disabled:c,onClick:()=>{var t;return d((t=e.commandId)==null?e.id:t,r)},onDoubleClick:()=>e.subId&&d(e.subId),children:n?I(V,{title:g,value:o,label:_}):h?I(V,{icon:h}):I(V,{title:g})})}function ie(){switch(b){case Y.BUTTON_SELECTOR:case Y.SELECTOR:case Y.SUBITEMS:return re(b);case Y.BUTTON:default:return T()}}return!s&&I(lo,{ref:t,title:te,placement:`bottom`,children:ie()})});function ho(e){let{ribbonType:t,headerMenuComponents:n,headerMenu:r=!0}=e,i=P(eo),a=P(C),o=j(null),s=j({}),c=F(i.ribbon$,[]),l=F(i.activatedTab$,K.START),u=F(i.collapsedIds$,[]),d=F(i.fakeToolbarVisible$,!1),f=A(()=>{if(t===`simple`){let e=[{key:K.START,children:[],order:0}];return c.forEach(t=>{var n;(n=t.children)==null||n.forEach(t=>{var n;(n=e[0].children)==null||n.push(t)})}),e}return c},[t,c]),p=sr(e=>{s.current={},i.setActivatedTab(e.key)},[]),m=A(()=>{var e,t;let n=(e=(t=f.find(e=>e.key===l))==null?void 0:t.children)==null?[]:e,r=[],i=[];for(let e of n)if(e.children){let t=e.children.filter(e=>!u.includes(e.key));t.length>0&&r.push({...e,children:t}),t.length<e.children.length&&i.push({...e,children:e.children.filter(e=>u.includes(e.key))})}return{allGroups:n,visibleGroups:r,hiddenGroups:i}},[u,f,l]);k(()=>{let e=null,t=new ResizeObserver(xe(t=>{for(let n of t)i.setFakeToolbarVisible(!0),e=requestAnimationFrame(()=>{var e,t;let{width:r}=n.contentRect,a=Object.values(s.current).sort((e,t)=>e.order-t.order||e.groupOrder-t.groupOrder||e.itemOrder-t.itemOrder),o=[],c=32,u=(((e=(t=f.find(e=>e.key===l))==null?void 0:t.children)==null?[]:e).length-1)*8;c+=u;for(let{el:e,key:t}of a){let{width:n}=e.getBoundingClientRect();c+=n+8,c>r&&o.push(t)}i.setCollapsedIds(o),i.setFakeToolbarVisible(!1)})},10));return t.observe(o.current),()=>{e&&cancelAnimationFrame(e),t.disconnect()}},[f,l]);let h=A(()=>I(`div`,{"aria-hidden":`true`,className:R(`univer-invisible univer-absolute -univer-left-[99999] -univer-top-[99999] univer-box-border univer-flex univer-h-10 univer-min-w-min univer-items-center univer-px-3 univer-opacity-0`,{"univer-hidden":!d},Vr,Lr),children:m.allGroups.map((e,t)=>{var n,r;return(((n=e.children)==null?void 0:n.length)||e.item)&&I(tr,{children:I(`div`,{className:`univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2`,children:e.children&&((r=e.children)==null?void 0:r.map(n=>n.item&&I(mo,{...n.item,ref:r=>{r!=null&&r.el&&(s.current[n.key]={el:r.el,key:n.key,order:t,groupOrder:e.order,itemOrder:n.order})}},n.key)))})},e.key)})}),[m.allGroups,d]);return L(yr,{children:[L(`div`,{"data-u-comp":`ribbon-header-menu`,className:R(`univer-relative univer-select-none`,{"univer-h-9":t===`classic`||n&&n.size>0}),children:[t===`classic`&&f.length>1&&I(no,{ribbon:f,activatedTab:l,onSelectTab:p}),r&&n&&n.size>0&&I(`div`,{className:`univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100`,children:I(Q,{components:n})})]}),L(`div`,{className:R(`univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm`,{"univer-grid-cols-[1fr] univer-justify-center":t===`classic`,"univer-grid-cols-[auto,1fr]":f.length>1&&t!==`classic`,"univer-grid-cols-none":f.length===1},Lr),children:[t===`collapsed`&&f.length>1&&I(io,{ribbon:f,activatedTab:l,onSelectTab:p}),L(`div`,{"data-u-comp":`ribbon-toolbar`,ref:o,className:R(`univer-flex univer-overflow-hidden`,Vr,{"univer-justify-center":t===`classic`}),role:`toolbar`,"aria-label":a.t(l),children:[m.visibleGroups.map(e=>{var t,n;return(((t=e.children)==null?void 0:t.length)||e.item)&&I(tr,{children:I(`div`,{className:`univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2`,children:e.children&&((n=e.children)==null?void 0:n.map(e=>e.item&&I(mo,{...e.item},e.key)))})},e.key)}),u.length>0&&I(`div`,{"data-u-comp":`ribbon-toolbar-more`,className:`univer-pl-2 rtl:univer-pr-2`,children:I(Er,{collisionPadding:{right:12,left:12},onOpenAutoFocus:e=>e.preventDefault(),overlay:I(`div`,{className:`univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2`,children:m.hiddenGroups.map(e=>{var t;return I(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:I(`div`,{className:`univer-flex univer-flex-wrap univer-gap-2`,children:e.children?(t=e.children)==null?void 0:t.map(e=>e.item&&I(mo,{...e.item},e.key)):e.item&&I(mo,{...e.item},e.key)})},e.key)})}),children:I(`button`,{type:`button`,className:ao,"aria-label":a.t(`ribbon.more`),"aria-haspopup":`true`,children:I(mn,{})})})})]})]}),h]})}var go=class extends a{constructor(...e){super(...e),z(this,`_styleSheetId`,`univer-theme-css-variables`)}injectThemeToHead(e){function t(e,t=`--univer`){let n=[];function r(e,i=``){for(let a in e){let o=e[a],s=i?`${i}-${a}`:a;typeof o==`object`&&o?r(o,s):n.push(`${t}-${s}: ${o};`)}}return r(e),n.join(`
16
+ `;function oo(e){let{children:t,className:n,style:r,disabled:i=!1,active:a=!1,noIcon:o,onClick:s,onDoubleClick:c,...l}=e,u=e=>{if(i){e.preventDefault();return}s&&s(e)},d=e=>{if(i){e.preventDefault();return}c&&c(e)};return I(`button`,{type:`button`,className:R(ao,n,{"univer-px-2":o,"!univer-bg-gray-200 dark:!univer-bg-gray-500":a}),style:r,disabled:i,onClick:u,onDoubleClick:d,...l,children:t})}function so(e){let{disabled$:t,hidden$:n,activated$:r,value$:i}=e,a;if(La(e)){let{selections:t}=e;if(Array.isArray(t)){var o;a=t==null||(o=t[0])==null?void 0:o.value$}}let[s,c]=M(),[l,u]=M(!1),[d,f]=M(!1),[p,m]=M(!1),[h,g]=M();return k(()=>{let e=[];return t&&e.push(t.subscribe(e=>u(e))),n&&e.push(n.subscribe(e=>m(e))),r&&e.push(r.subscribe(e=>f(e))),i&&e.push(i.subscribe(e=>c(e))),a&&e.push(a.subscribe(e=>g(e))),()=>e.forEach(e=>e.unsubscribe())},[r,t,n,i,a]),{disabled:l,value:s,activated:d,hidden:p,selectionsValue:h}}const co=rr({dropdownVisible:!1,setDropdownVisible:e=>{}}),lo=ar((e,t)=>{let{children:n,...r}=e,i=j(null),[a,o]=M(!1),[s,c]=M(!1);function l(e){o(s?!1:e)}function u(e){c(e),o(!1)}let d=A(()=>({dropdownVisible:s,setDropdownVisible:u}),[s]);return lr(t,()=>({el:i.current})),r.title?I(Ir,{visible:a,onVisibleChange:l,...r,children:I(`span`,{ref:i,children:I(co.Provider,{value:d,children:n})})}):I(`span`,{ref:i,children:n})});function uo(e){let{children:t,overlay:n,disabled:r,align:i=`start`}=e,{dropdownVisible:a,setDropdownVisible:o}=cr(co);function s(e){o(e)}return I(Er,{align:i,overlay:I(`div`,{className:`univer-grid univer-gap-2`,children:n}),disabled:r,open:a,onOpenChange:s,children:I(`div`,{className:`univer-h-full`,onClick:e=>e.stopPropagation(),children:t})})}function fo({icon:e,value:t,option:n,onOptionSelect:r}){var i;let a=e=>{r==null||r({value:e,label:n==null?void 0:n.label,commandId:n==null?void 0:n.commandId})},o=typeof n.label==`string`||typeof n.label==`object`&&((i=n.label)==null?void 0:i.selectable)!==!1;return L(`div`,{className:R(`univer-relative univer-flex univer-items-center univer-gap-2`,{"univer-pl-6":o}),children:[o&&String(t)===String(n.value)&&I(ot,{className:`univer-absolute univer-left-1 univer-top-0.5 univer-text-primary-600`}),I(V,{className:`univer-text-sm`,icon:e,value$:n.value$,value:n.value,label:n.label,onChange:a})]})}function po({menuId:e,slot:t,value:n,options:r,children:i,disabled:a,onOptionSelect:o}){let{dropdownVisible:s,setDropdownVisible:c}=cr(co),l=P(J),[u,d]=M({}),f=A(()=>e?l.getMenuByPositionKey(e):[],[e]),p=A(()=>f.filter(e=>{var t;return e.children?!u[((t=e.key)==null?void 0:t.toString())||``]:!u[e.key]}),[f,u]);function m(e){c(e)}if(k(()=>{let e=[];return f.forEach(t=>{if(t.children){let n=De(t.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t})).subscribe(e=>{let n=e.every(e=>e===!0);d(e=>({...e,[t.key]:n}))});e.push(n)}else{var n;if((n=t.item)!=null&&n.hidden$){let n=t.item.hidden$.subscribe(e=>{d(n=>({...n,[t.key]:e}))});e.push(n)}}}),()=>{e.forEach(e=>e==null?void 0:e.unsubscribe()),d({})}},[f]),t)return I(uo,{disabled:a,overlay:r.map((e,t)=>I(fo,{value:n,option:e,onOptionSelect:o},t)),children:i});if(r!=null&&r.length){let e=r.map(e=>{var t;return{type:`item`,className:R({"focus:univer-bg-white":typeof e.label!=`string`&&((t=e.label)==null?void 0:t.hoverable)===!1}),children:I(fo,{icon:e.icon,value:n,option:e,onOptionSelect:o}),disabled:e.disabled,onSelect:()=>{e.value!==void 0&&(o==null||o({...e}))}}});for(let t of p){if(!t.item)continue;let{title:r,id:i,commandId:a,icon:s}=t.item;if(!r)throw Error(`Menu item title is required`);e.push({type:`item`,children:I(fo,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}return I(Dr,{align:`start`,items:e,disabled:a,open:s,onOpenChange:m,children:i})}else{let e=[];for(let t of p){var h;if(t.item){let{title:r,id:i,commandId:a,icon:s}=t.item;if(!r)throw Error(`Menu item title is required`);e.push({type:`item`,children:I(fo,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}else (h=t.children)!=null&&h.length}return I(Dr,{align:`start`,items:e,disabled:a,open:s,onOpenChange:m,children:i})}}const mo=ar((e,t)=>{let n=P(C),r=P(f),i=P(Li),a=P(B),{value:o,hidden:s,disabled:c,activated:l,selectionsValue:u}=so(e),d=(e,t)=>{i.focus(),r.executeCommand(e,t)},{tooltip:p,shortcut:m,icon:h,title:g,label:_,id:v,commandId:y,type:b,slot:x,params:ee}=e,te=n.t(p==null?``:p)+(m?` (${m})`:``),{selections:S}=e,ne=F(A(()=>Ne(S)?S:new Ce(e=>{e.next(S)}),[S])),w=F(A(()=>Ne(h)?h:new Ce(e=>{var t,n;let r=(t=ne==null||(n=ne.find(e=>e.value===o))==null?void 0:n.icon)==null?h:t;e.next(r)}),[h,ne,o]),void 0,!0);function re(t){var n;let r=e.selectionsCommandId,i=y==null?v:y,a=(n=r==null?y:r)==null?v:n;function s(e){if(c)return;let t=a;e.id&&(t=e.id),d(t,{value:e.value})}function f(e){c||d(a,{value:e})}function p(){c||t===Y.BUTTON_SELECTOR&&d(i,{value:o})}return t===Y.BUTTON_SELECTOR?L(`div`,{"data-u-command":v,"data-disabled":c,className:R(`univer-toolbar-button-selector-root univer-animate-in univer-fade-in univer-group univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5 univer-text-sm univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-gray-900 dark:!univer-text-white":!c,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c}),children:[I(`div`,{className:R(`univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full univer-items-center univer-rounded-l univer-px-1 univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600`,{"univer-bg-gray-200 dark:!univer-bg-gray-500":l,"univer-bg-gray-100":l&&c}),onClick:p,children:I(V,{icon:w,title:g,value:u==null?o:u,label:_,onChange:f})}),I(po,{menuId:v,slot:x,value:o,options:ne,disabled:c,onOptionSelect:s,children:I(`div`,{className:R(`univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0 univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center univer-justify-center univer-rounded-r univer-transition-colors hover:univer-bg-gray-200 dark:hover:!univer-bg-gray-600`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c,"univer-bg-gray-200 dark:!univer-bg-gray-500":l,"univer-bg-gray-100":l&&c}),"data-disabled":c,children:I(pn,{})})})]}):I(po,{menuId:v,slot:x,value:o,options:ne,disabled:c,onOptionSelect:s,children:L(`div`,{"data-u-command":v,className:R(`univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-gap-2 univer-whitespace-nowrap univer-rounded univer-px-1 univer-transition-colors hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,{"univer-text-gray-900 dark:!univer-text-white":!c,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c,"univer-bg-gray-200":l,"univer-bg-gray-100":l&&c}),children:[I(V,{icon:w,title:g,value:o,label:_,onChange:f}),I(`div`,{className:R(`univer-toolbar-selector-trigger univer-flex univer-h-full univer-items-center`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":c}),children:I(pn,{})})]})})}function T(){var t;let n=a.get(typeof _==`string`?_:(t=_==null?void 0:_.name)==null?``:t),r=(o==null?typeof ee==`function`:o)?ee():ee;return I(oo,{"data-u-command":v,className:`univer-text-sm`,noIcon:!h,active:l,disabled:c,onClick:()=>{var t;return d((t=e.commandId)==null?e.id:t,r)},onDoubleClick:()=>e.subId&&d(e.subId),children:n?I(V,{title:g,value:o,label:_}):h?I(V,{icon:h}):I(V,{title:g})})}function ie(){switch(b){case Y.BUTTON_SELECTOR:case Y.SELECTOR:case Y.SUBITEMS:return re(b);case Y.BUTTON:default:return T()}}return!s&&I(lo,{ref:t,title:te,placement:`bottom`,children:ie()})});function ho(e){let{ribbonType:t,headerMenuComponents:n,headerMenu:r=!0}=e,i=P(eo),a=P(C),o=j(null),s=j({}),c=F(i.ribbon$,[]),l=F(i.activatedTab$,K.START),u=F(i.collapsedIds$,[]),d=F(i.fakeToolbarVisible$,!1),f=A(()=>{if(t===`simple`){let e=[{key:K.START,children:[],order:0}];return c.forEach(t=>{var n;(n=t.children)==null||n.forEach(t=>{var n;(n=e[0].children)==null||n.push(t)})}),e}return c},[t,c]),p=sr(e=>{s.current={},i.setActivatedTab(e.key)},[]),m=A(()=>{var e,t;let n=(e=(t=f.find(e=>e.key===l))==null?void 0:t.children)==null?[]:e,r=[],i=[];for(let e of n)if(e.children){let t=e.children.filter(e=>!u.includes(e.key));t.length>0&&r.push({...e,children:t}),t.length<e.children.length&&i.push({...e,children:e.children.filter(e=>u.includes(e.key))})}return{allGroups:n,visibleGroups:r,hiddenGroups:i}},[u,f,l]);k(()=>{let e=null,t=new ResizeObserver(xe(t=>{for(let n of t)i.setFakeToolbarVisible(!0),e=requestAnimationFrame(()=>{var e,t;let{width:r}=n.contentRect,a=Object.values(s.current).sort((e,t)=>e.order-t.order||e.groupOrder-t.groupOrder||e.itemOrder-t.itemOrder),o=[],c=32,u=(((e=(t=f.find(e=>e.key===l))==null?void 0:t.children)==null?[]:e).length-1)*8;c+=u;for(let{el:e,key:t}of a){let{width:n}=e.getBoundingClientRect();c+=n+8,c>r&&o.push(t)}i.setCollapsedIds(o),i.setFakeToolbarVisible(!1)})},10));return t.observe(o.current),()=>{e&&cancelAnimationFrame(e),t.disconnect()}},[f,l]);let h=A(()=>I(`div`,{"aria-hidden":`true`,className:R(`univer-invisible univer-absolute -univer-left-[99999] -univer-top-[99999] univer-box-border univer-flex univer-h-10 univer-min-w-min univer-items-center univer-px-3 univer-opacity-0`,{"univer-hidden":!d},Vr,Lr),children:m.allGroups.map((e,t)=>{var n,r;return(((n=e.children)==null?void 0:n.length)||e.item)&&I(tr,{children:I(`div`,{className:`univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2`,children:e.children&&((r=e.children)==null?void 0:r.map(n=>n.item&&I(mo,{...n.item,ref:r=>{r!=null&&r.el&&(s.current[n.key]={el:r.el,key:n.key,order:t,groupOrder:e.order,itemOrder:n.order})}},n.key)))})},e.key)})}),[m.allGroups,d]);return L(yr,{children:[L(`div`,{"data-u-comp":`ribbon-header-menu`,className:R(`univer-relative univer-select-none`,{"univer-h-9":t===`classic`||n&&n.size>0}),children:[t===`classic`&&f.length>1&&I(no,{ribbon:f,activatedTab:l,onSelectTab:p}),r&&n&&n.size>0&&I(`div`,{className:`univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center univer-gap-2 [&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded [&>*]:univer-px-1 [&>*]:univer-transition-colors hover:[&>*]:univer-bg-gray-100`,children:I(Q,{components:n})})]}),L(`div`,{className:R(`univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3 univer-text-sm`,{"univer-grid-cols-[1fr] univer-justify-center":t===`classic`,"univer-grid-cols-[auto,1fr]":f.length>1&&t!==`classic`,"univer-grid-cols-none":f.length===1},Lr),children:[t===`collapsed`&&f.length>1&&I(io,{ribbon:f,activatedTab:l,onSelectTab:p}),L(`div`,{"data-u-comp":`ribbon-toolbar`,ref:o,className:R(`univer-flex univer-overflow-hidden`,Vr,{"univer-justify-center":t===`classic`}),role:`toolbar`,"aria-label":a.t(l),children:[m.visibleGroups.map(e=>{var t,n;return(((t=e.children)==null?void 0:t.length)||e.item)&&I(tr,{children:I(`div`,{className:`univer-grid univer-shrink-0 univer-grid-flow-col univer-gap-2 univer-px-2`,children:e.children&&((n=e.children)==null?void 0:n.map(e=>e.item&&I(mo,{...e.item},e.key)))})},e.key)}),u.length>0&&I(`div`,{"data-u-comp":`ribbon-toolbar-more`,className:`univer-pl-2 rtl:univer-pr-2`,children:I(Er,{collisionPadding:{right:12,left:12},onOpenAutoFocus:e=>e.preventDefault(),overlay:I(`div`,{className:`univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2`,children:m.hiddenGroups.map(e=>{var t;return I(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:I(`div`,{className:`univer-flex univer-flex-wrap univer-gap-2`,children:e.children?(t=e.children)==null?void 0:t.map(e=>e.item&&I(mo,{...e.item},e.key)):e.item&&I(mo,{...e.item},e.key)})},e.key)})}),children:I(`button`,{type:`button`,className:ao,"aria-label":a.t(`ribbon.more`),"aria-haspopup":`true`,children:I(mn,{})})})})]})]}),h]})}var go=class extends a{constructor(...e){super(...e),z(this,`_styleSheetId`,`univer-theme-css-variables`)}injectThemeToHead(e){function t(e,t=`--univer`){let n=[];function r(e,i=``){for(let a in e){let o=e[a],s=i?`${i}-${a}`:a;typeof o==`object`&&o?r(o,s):n.push(`${t}-${s}: ${o};`)}}return r(e),n.join(`
17
17
  `)}let n=t(e),r=document.getElementById(this._styleSheetId);r&&r.remove();let i=document.createElement(`style`);i.setAttribute(`id`,this._styleSheetId),i.textContent=`:root {\n${n}\n}`,document.head.appendChild(i)}dispose(){super.dispose()}};const _o=E(`ui.contextmenu.service`);var vo=class extends a{constructor(...e){super(...e),z(this,`_currentHandler`,null),z(this,`disabled`,!1)}get visible(){var e,t;return(e=(t=this._currentHandler)==null?void 0:t.visible)==null?!1:e}disable(){this.disabled=!0}enable(){this.disabled=!1}triggerContextMenu(e,t){var n;e.stopPropagation(),!this.disabled&&((n=this._currentHandler)==null||n.handleContextMenu(e,t))}hideContextMenu(){var e;(e=this._currentHandler)==null||e.hideContextMenu()}registerContextMenuHandler(e){if(this._currentHandler)throw Error(`There is already a context menu handler!`);return this._currentHandler=e,D(()=>this._currentHandler=null)}};const yo=E(`ui.contextmenu.host.service`);var bo=class extends a{constructor(...e){super(...e),z(this,`_menuMap`,new Map),z(this,`_activeMenuId`,null)}get activeMenuId(){return this._activeMenuId}registerMenu(e,t){return this._menuMap.set(e,t),D(()=>{this._menuMap.delete(e),this._activeMenuId===e&&(this._activeMenuId=null)})}activateMenu(e){this.hideActiveMenu(e),this._activeMenuId=e}deactivateMenu(e){this._activeMenuId===e&&(this._activeMenuId=null)}hideActiveMenu(e){if(!this._activeMenuId||this._activeMenuId===e)return;let t=this._menuMap.get(this._activeMenuId);this._activeMenuId=null,t==null||t()}};function xo({items:e}){return I(`div`,{className:`univer-menu-item-group univer-flex univer-flex-wrap univer-gap-2.5 univer-p-1 univer-px-0`,children:e.map(e=>{let t=I(`div`,{className:R(`univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-md hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-900`,{"univer-bg-gray-50 dark:!univer-bg-gray-900":e.active},e.className),onClick:()=>e.onClick(),children:I(e.Icon,{className:`univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200`})},e.key);return e.tooltip?I(Ir,{title:e.tooltip,children:t},e.key):t})})}function So(e){let{menuSchema:t,onOptionSelect:n}=e,r=P(B),i=P(C),a=t.item,o=F(a==null?void 0:a.disabled$,!1),s=F(a==null?void 0:a.hidden$,!1),c=F(a==null?void 0:a.activated$,!1);if(!a||s)return null;let l=a.icon?r.get(a.icon):null;return L(`button`,{type:`button`,className:R(`univer-relative univer-box-border univer-flex univer-size-12 univer-w-full univer-appearance-none univer-flex-col univer-items-center univer-justify-center univer-gap-0.5 univer-rounded-lg univer-border-none univer-bg-white univer-p-0 univer-font-medium univer-text-gray-700 univer-outline-none univer-transition-all focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-700 dark:!univer-text-gray-100`,o?`univer-cursor-not-allowed univer-opacity-60`:`
18
18
  univer-cursor-pointer
19
19
  hover:univer-bg-gray-50
@@ -21,7 +21,7 @@ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
21
21
  `,c&&`
22
22
  univer-bg-primary-50 univer-text-primary-700 univer-ring-1 univer-ring-primary-600
23
23
  dark:!univer-bg-primary-900 dark:!univer-text-primary-100
24
- `),disabled:o,onClick:()=>{var e;o||n==null||n({label:(e=a.id)==null?t.key:e,commandId:a.commandId,id:a.id,tooltip:a.tooltip&&i.t(a.tooltip)})},children:[l&&I(l,{className:`univer-text-base`,extend:{colorChannel1:`var(--univer-primary-600)`}}),I(`span`,{className:`univer-break-words univer-text-center univer-text-xs univer-leading-4`,children:a.title?i.t(a.title):t.key})]})}function Co(e){let{item:t,onOptionSelect:n}=e,[r,i]=M([]),a=P(B),o=P(C);return k(()=>{if(!t.children)return;let e=t.children.map(e=>{var t,n;return de((t=(n=e.item)==null?void 0:n.activated$)==null?Ie(!1):t,!1)}),n=De(e).subscribe(e=>{let n=e.map((e,n)=>({actived:e,item:t.children[n].item.id})).filter(e=>e.actived);n.length===0?i([]):i(n.map(e=>e.item))});return()=>{n.unsubscribe(),e.forEach(e=>{e.complete()})}},[t]),t.children?I(xo,{items:t.children.map(e=>{var t,i;return{key:e.key,onClick:()=>{var t,r,i,a,s,c;n==null||n({label:(t=(r=e.item)==null?void 0:r.id)==null?e.key:t,commandId:(i=e.item)==null?void 0:i.commandId,id:(a=e.item)==null?void 0:a.id,tooltip:((s=e.item)==null?void 0:s.tooltip)&&o.t((c=e.item)==null?void 0:c.tooltip)})},className:``,Icon:a.get(e.item.icon),active:r.includes((t=(i=e.item)==null?void 0:i.id)==null?``:t)}})}):null}function wo(e){var t;let{item:n,onOptionSelect:r}=e;return(t=n.children)!=null&&t.length?I(`div`,{className:`univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1`,children:n.children.map(e=>I(So,{menuSchema:e,onOptionSelect:r},e.key))}):null}const To=`univer-inline-flex univer-items-center univer-gap-2`;function Eo(e){return typeof e==`object`&&(e==null?void 0:e.selectable)===!1}function Do(e){return typeof e==`object`&&(e==null?void 0:e.hoverable)===!1}function Oo(e){var t,n;let{menuType:r,menuSessionVersion:i=0,className:a,onOptionSelect:o}=e,s=P(J),c=P(ua),[l,u]=M(null),[d,f]=M(()=>typeof window>`u`?240:Math.max(120,window.innerHeight-16)),p=A(()=>r?s.getMenuByPositionKey(r):[],[s,r,F(A(()=>s.menuChanged$.pipe(Re(void 0),Le(e=>e+1,0)),[s]),0),i]),m=(t=(n=c.rootContainerElement)==null||(n=n.ownerDocument)==null?void 0:n.body)==null?typeof document<`u`?document.body:null:t;return Ei(l,c.rootContainerElement),k(()=>{var e,t;let n=(e=(t=c.rootContainerElement)==null||(t=t.ownerDocument)==null?void 0:t.defaultView)==null?typeof window<`u`?window:null:e;if(!n)return;let r=0,i=()=>{r&&n.cancelAnimationFrame(r),r=n.requestAnimationFrame(()=>{f(Math.max(120,n.innerHeight-16))})};return i(),n.addEventListener(`resize`,i),()=>{r&&n.cancelAnimationFrame(r),n.removeEventListener(`resize`,i)}},[c.rootContainerElement]),r?I(`div`,{ref:u,className:R(`univer-box-border univer-grid univer-min-w-52 univer-max-w-full univer-gap-1 univer-overflow-y-auto univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white`,Rr,Jr,a),style:{maxHeight:d},onWheel:e=>e.stopPropagation(),children:I(ko,{menuSchemas:p,submenuPortalContainer:m,onOptionSelect:o,maxMenuHeight:d})}):null}function ko(e){let{menuSchemas:t,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i}=e,a=P(C),o=jo(t),s=A(()=>t.filter(e=>e.children?!o[e.key]:!0),[o,t]);return I(yr,{children:s.map((e,t)=>{var o;let c=t!==s.length-1;return e.item?I(Ao,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key):(o=e.children)!=null&&o.length?e.quickLayout?I(`div`,{className:R(`univer-py-1`,c&&Lr),children:e.quickLayout===`tile`?I(wo,{item:e,onOptionSelect:r}):I(Co,{item:e,onOptionSelect:r})},e.key):L(`div`,{className:R(`univer-grid univer-gap-1 univer-py-1`,c&&Lr),children:[e.title&&I(`strong`,{className:`univer-px-2 univer-text-xs univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-300`,children:a.t(e.title)}),e.children.map(e=>e.item&&I(Ao,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key))]},e.key):null})})}function Ao(e){let{menuKey:t,menuItem:n,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a}=e,o=P(J),s=F(n.disabled$,!1),c=F(n.activated$,!1),l=F(n.hidden$,!1),u=F(n.value$),d=n,f=F(Ne(d.selections)?d.selections:void 0),[p,m]=M(u),[h,g]=M(!1),[_,v]=M({left:0,top:0}),[y,b]=M(!1),[x,ee]=M(`right`),te=j(null),S=j(null),C=A(()=>n.type!==Y.SELECTOR&&n.type!==Y.BUTTON_SELECTOR?[]:f||(Array.isArray(d.selections)?d.selections:[]),[n.type,f,d.selections]),ne=A(()=>n.type!==Y.SUBITEMS||!n.id?[]:o.getMenuByPositionKey(n.id),[n.id,n.type,o]),w=C.length>0,re=ne.length>0,T=w||re;if(k(()=>{m(u)},[u]),k(()=>{if(!h){b(!1);return}let e=()=>{let e=te.current,t=S.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.right-2,a=n.left-r.width+2,o=i+r.width+8>window.innerWidth&&a>=8,s=o?a:i;ee(o?`left`:`right`);let c=window.innerHeight-8-r.height;v({left:s,top:c<8?8:Math.min(Math.max(n.top,8),c)}),b(!0)},t=window.requestAnimationFrame(e);return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[h,w,re]),l)return null;let ie=e=>{m(ge(e)&&typeof e==`string`?Number.parseInt(e):e)},ae=R(`univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white`,s?`univer-cursor-not-allowed univer-opacity-60`:`
24
+ `),disabled:o,onClick:()=>{var e;o||n==null||n({label:(e=a.id)==null?t.key:e,commandId:a.commandId,id:a.id,tooltip:a.tooltip&&i.t(a.tooltip)})},children:[l&&I(l,{className:`univer-text-base`,extend:{colorChannel1:`var(--univer-primary-600)`}}),I(`span`,{className:`univer-break-words univer-text-center univer-text-xs univer-leading-4`,children:a.title?i.t(a.title):t.key})]})}function Co(e){let{item:t,onOptionSelect:n}=e,[r,i]=M([]),a=P(B),o=P(C);return k(()=>{if(!t.children)return;let e=t.children.map(e=>{var t,n;return de((t=(n=e.item)==null?void 0:n.activated$)==null?Ie(!1):t,!1)}),n=De(e).subscribe(e=>{let n=e.map((e,n)=>({actived:e,item:t.children[n].item.id})).filter(e=>e.actived);n.length===0?i([]):i(n.map(e=>e.item))});return()=>{n.unsubscribe(),e.forEach(e=>{e.complete()})}},[t]),t.children?I(xo,{items:t.children.map(e=>{var t,i;return{key:e.key,onClick:()=>{var t,r,i,a,s,c;n==null||n({label:(t=(r=e.item)==null?void 0:r.id)==null?e.key:t,commandId:(i=e.item)==null?void 0:i.commandId,id:(a=e.item)==null?void 0:a.id,tooltip:((s=e.item)==null?void 0:s.tooltip)&&o.t((c=e.item)==null?void 0:c.tooltip)})},className:``,Icon:a.get(e.item.icon),active:r.includes((t=(i=e.item)==null?void 0:i.id)==null?``:t)}})}):null}function wo(e){var t;let{item:n,onOptionSelect:r}=e;return(t=n.children)!=null&&t.length?I(`div`,{className:`univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1`,children:n.children.map(e=>I(So,{menuSchema:e,onOptionSelect:r},e.key))}):null}const To=`univer-inline-flex univer-items-center univer-gap-2`;function Eo(e){return typeof e==`object`&&(e==null?void 0:e.selectable)===!1}function Do(e){return typeof e==`object`&&(e==null?void 0:e.hoverable)===!1}function Oo(e){var t,n;let{menuType:r,menuSessionVersion:i=0,className:a,onOptionSelect:o}=e,s=P(J),c=P(Li),[l,u]=M(null),[d,f]=M(()=>typeof window>`u`?240:Math.max(120,window.innerHeight-16)),p=A(()=>r?s.getMenuByPositionKey(r):[],[s,r,F(A(()=>s.menuChanged$.pipe(Re(void 0),Le(e=>e+1,0)),[s]),0),i]),m=(t=(n=c.rootContainerElement)==null||(n=n.ownerDocument)==null?void 0:n.body)==null?typeof document<`u`?document.body:null:t;return Ei(l,c.rootContainerElement),k(()=>{var e,t;let n=(e=(t=c.rootContainerElement)==null||(t=t.ownerDocument)==null?void 0:t.defaultView)==null?typeof window<`u`?window:null:e;if(!n)return;let r=0,i=()=>{r&&n.cancelAnimationFrame(r),r=n.requestAnimationFrame(()=>{f(Math.max(120,n.innerHeight-16))})};return i(),n.addEventListener(`resize`,i),()=>{r&&n.cancelAnimationFrame(r),n.removeEventListener(`resize`,i)}},[c.rootContainerElement]),r?I(`div`,{ref:u,className:R(`univer-box-border univer-grid univer-min-w-52 univer-max-w-full univer-gap-1 univer-overflow-y-auto univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm univer-text-gray-900 univer-shadow-md dark:!univer-bg-gray-700 dark:!univer-text-white`,Rr,Jr,a),style:{maxHeight:d},onWheel:e=>e.stopPropagation(),children:I(ko,{menuSchemas:p,submenuPortalContainer:m,onOptionSelect:o,maxMenuHeight:d})}):null}function ko(e){let{menuSchemas:t,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i}=e,a=P(C),o=jo(t),s=A(()=>t.filter(e=>e.children?!o[e.key]:!0),[o,t]);return I(yr,{children:s.map((e,t)=>{var o;let c=t!==s.length-1;return e.item?I(Ao,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key):(o=e.children)!=null&&o.length?e.quickLayout?I(`div`,{className:R(`univer-py-1`,c&&Lr),children:e.quickLayout===`tile`?I(wo,{item:e,onOptionSelect:r}):I(Co,{item:e,onOptionSelect:r})},e.key):L(`div`,{className:R(`univer-grid univer-gap-1 univer-py-1`,c&&Lr),children:[e.title&&I(`strong`,{className:`univer-px-2 univer-text-xs univer-font-semibold univer-text-gray-600 dark:!univer-text-gray-300`,children:a.t(e.title)}),e.children.map(e=>e.item&&I(Ao,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key))]},e.key):null})})}function Ao(e){let{menuKey:t,menuItem:n,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a}=e,o=P(J),s=F(n.disabled$,!1),c=F(n.activated$,!1),l=F(n.hidden$,!1),u=F(n.value$),d=n,f=F(Ne(d.selections)?d.selections:void 0),[p,m]=M(u),[h,g]=M(!1),[_,v]=M({left:0,top:0}),[y,b]=M(!1),[x,ee]=M(`right`),te=j(null),S=j(null),C=A(()=>n.type!==Y.SELECTOR&&n.type!==Y.BUTTON_SELECTOR?[]:f||(Array.isArray(d.selections)?d.selections:[]),[n.type,f,d.selections]),ne=A(()=>n.type!==Y.SUBITEMS||!n.id?[]:o.getMenuByPositionKey(n.id),[n.id,n.type,o]),w=C.length>0,re=ne.length>0,T=w||re;if(k(()=>{m(u)},[u]),k(()=>{if(!h){b(!1);return}let e=()=>{let e=te.current,t=S.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.right-2,a=n.left-r.width+2,o=i+r.width+8>window.innerWidth&&a>=8,s=o?a:i;ee(o?`left`:`right`);let c=window.innerHeight-8-r.height;v({left:s,top:c<8?8:Math.min(Math.max(n.top,8),c)}),b(!0)},t=window.requestAnimationFrame(e);return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.cancelAnimationFrame(t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[h,w,re]),l)return null;let ie=e=>{m(ge(e)&&typeof e==`string`?Number.parseInt(e):e)},ae=R(`univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white`,s?`univer-cursor-not-allowed univer-opacity-60`:`
25
25
  univer-cursor-pointer
26
26
  hover:univer-bg-gray-50
27
27
  dark:hover:!univer-bg-gray-600
@@ -40,7 +40,7 @@ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
40
40
  univer-text-primary-600
41
41
  `}),I(`span`,{className:R(To,c&&s&&`
42
42
  univer-pl-4
43
- `),children:I(V,{value$:e.value$,value:e.value,label:e.label,icon:e.icon,onChange:r=>{i==null||i({...e,value:r,id:n.id,label:t,commandId:e.commandId})}})})]});return c?I(`button`,{type:`button`,className:u,disabled:e.disabled,onClick:()=>{i==null||i({...e,id:n.id,label:t,commandId:e.commandId})},children:d},o):I(`div`,{className:u,"aria-disabled":e.disabled,children:d},o)})}),re&&I(ko,{menuSchemas:ne,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a})]})}),r):null)]})}function jo(e){let[t,n]=M({});return k(()=>{let t=e.map(e=>{var t;return(t=e.children)!=null&&t.length?De(e.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t})).subscribe(t=>{let r=t.every(e=>e===!0);n(t=>({...t,[e.key]:r}))}):null});return()=>{t.forEach(e=>e==null?void 0:e.unsubscribe()),n({})}},[e]),t}function Mo(e){let{hostId:t,visible:n,anchorRect:r,menuType:i,anchorVertical:a=`bottom`,menuOffset:o=0,onRequestClose:s,onOptionSelect:c}=e,l=j(null),u=P(yo),d=j(s),f=j(0),p=j(n),m=j(i);k(()=>{d.current=s},[s]),n&&(!p.current||i!==m.current)&&(f.current+=1),p.current=n,m.current=i,k(()=>{let e=u.registerMenu(t,()=>{d.current()});return()=>{e.dispose(),u.deactivateMenu(t)}},[u,t]),ur(()=>{if(n){u.activateMenu(t);return}u.deactivateMenu(t)},[u,t,n]),k(()=>{if(!n)return;let e=e=>e instanceof Element&&e.closest(`[data-u-context-menu-submenu]`),t=t=>{e(t.target)||l.current&&!l.current.contains(t.target)&&d.current()},r=e=>{e.key===`Escape`&&d.current()},i=t=>{var n;if(e(t.target)){t.stopPropagation();return}if((n=l.current)!=null&&n.contains(t.target)){t.stopPropagation();return}t.preventDefault(),t.stopPropagation()};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,r),document.addEventListener(`wheel`,i,{capture:!0,passive:!1}),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,r),document.removeEventListener(`wheel`,i,!0)}},[n]);let h=A(()=>{if(!r)return[0,0];let e=a===`top`?r.top:r.bottom,t=a===`top`?e-o:e+o;return[r.left,t]},[r,a,o]);return I(Pr,{visible:n&&!!r,offset:h,overflowVisible:!0,placementY:a===`top`?`above`:`below`,children:I(`section`,{ref:l,children:i&&I(Oo,{menuType:i,menuSessionVersion:f.current,onOptionSelect:c})})})}function No(){let[e,t]=M(!1),[n,r]=M(``),[i,a]=M(null),o=j(e),s=P(_o),c=P(f),l=_r();o.current=e,k(()=>{let e=s.registerContextMenuHandler({handleContextMenu:u,hideContextMenu(){d()},get visible(){return o.current}});return()=>{e.dispose()}},[s]);function u(e,n){t(!1),requestAnimationFrame(()=>{r(n),a({left:e.clientX,top:e.clientY,bottom:e.clientY}),t(!0)})}function d(){t(!1)}return I(Mo,{hostId:`desktop-context-menu`,visible:e,anchorRect:i,menuType:n,onRequestClose:d,onOptionSelect:e=>{let{label:t,commandId:n,value:r}=e;c&&c.executeCommand(n==null?t:n,{value:r}),l.get(ua).focus(),d()}})}const Po=E(`univer.global-zone-service`);function Fo(){let e=P(Po),[t,n]=M(!1),r=F(e.componentKey$,e.componentKey),i=P(B),a=A(()=>{let e=i.get(r==null?``:r);if(e)return e},[r,i]);return k(()=>{let t=e.visible$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[e.visible$]),t?I(`section`,{className:R(`univer-absolute univer-bg-gray-100`,{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&I(a,{})}):null}function Io(){let e=P(ui),t=F(e.sidebarOptions$),n=j(null),r=A(()=>{if(!t)return null;let e={...t};for(let n of[`children`,`header`,`footer`]){let r=n;if(t[r]){let{key:n,...i}=t[r];i&&(e[r]=I(V,{...i},n))}}return e},[t]);k(()=>(n.current&&e.setContainer(n.current),()=>{e.setContainer(void 0)}),[e]),k(()=>{let t=t=>{e.scrollEvent$.next(t)},r=n.current;return r&&r.addEventListener(`scroll`,t),()=>{r==null||r.removeEventListener(`scroll`,t)}},[e]);let i=A(()=>r!=null&&r.visible?typeof r.width==`number`?`${r.width}px`:r.width:0,[r]);function a(){var n;let r={...t,visible:!1};e.options.visible=!1,e.sidebarOptions$.next(r),r==null||(n=r.onClose)==null||n.call(r)}return I(`section`,{"data-u-comp":`sidebar`,className:R(`univer-relative univer-h-full univer-bg-white univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-white`,{"univer-w-96 univer-translate-x-0":r==null?void 0:r.visible,"univer-w-0 univer-translate-x-full":!(r!=null&&r.visible)}),style:{width:i},children:L(`section`,{ref:n,className:R(`univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto] univer-overflow-y-auto`,zr,Jr),children:[L(`header`,{className:`univer-sticky univer-top-0 univer-z-10 univer-box-border univer-flex univer-cursor-default univer-items-center univer-justify-between univer-bg-white univer-p-4 univer-pb-2 univer-text-base univer-font-medium univer-text-gray-800 dark:!univer-bg-gray-900 dark:!univer-text-white`,children:[r==null?void 0:r.header,I(`a`,{className:`univer-cursor-pointer univer-text-gray-500 dark:!univer-text-gray-300`,onClick:a,children:I(ct,{})})]}),I(`section`,{className:`univer-box-border univer-cursor-default univer-px-4`,style:r==null?void 0:r.bodyStyle,children:r==null?void 0:r.children}),(r==null?void 0:r.footer)&&I(`footer`,{className:`univer-sticky univer-bottom-0 univer-box-border univer-bg-white univer-p-4 dark:!univer-bg-gray-900`,children:r.footer})]})})}const Lo=E(`univer.zen-zone-service`);function Ro(){let e=P(Lo),[t,n]=M(!1),[r,i]=M(),a=F(e.temporaryHidden$),o=P(B);k(()=>{let t=[e.visible$.subscribe(e=>{n(e)}),e.componentKey$.subscribe(e=>{i(e)})];return()=>{t.forEach(e=>{e.unsubscribe()})}},[]);let s=A(()=>{let e=o.get(r==null?``:r);if(e)return e},[r]);return I(`section`,{className:R(`univer-absolute univer-z-[-1] univer-flex`,{"univer-animate-in univer-fade-in univer-inset-0 univer-z-[100] univer-bg-gray-100":t,"univer-hidden":a}),children:I(`div`,{className:`univer-relative univer-flex-1`,children:s&&I(s,{})})})}function zo(e){let t=Di(Ai);return I(Bo,{...e,...t})}function Bo(e){var t;let{header:n=!0,toolbar:r=!0,footer:i=!0,headerMenu:a=!0,contextMenu:o=!0,ribbonType:s=`classic`,mountContainer:c,onRendered:l}=e,u=P(C),d=P(oe),f=P(go),m=j(null),h=P(p).getConfig(Ai),g=$(X.CUSTOM_HEADER),_=$(X.FOOTER),v=$(X.HEADER),y=$(X.HEADER_MENU),b=$(X.CONTENT),x=$(X.LEFT_SIDEBAR),ee=$(X.GLOBAL),te=$(X.TOOLBAR),S=(t=h==null?void 0:h.popupRootId)==null?`univer-popup-portal`:t;ur(()=>{let e=d.currentTheme$.subscribe(e=>{f.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]);let[ne,w]=M(!1);ur(()=>{let e=d.darkMode$.subscribe(e=>{w(e),e?document.documentElement.classList.add(`univer-dark`):document.documentElement.classList.remove(`univer-dark`)});return()=>{e.unsubscribe()}},[]),k(()=>{m.current&&(l==null||l(m.current))},[l]);let[re,T]=M(u.getLocales()),ie=A(()=>document.createElement(`div`),[]);return k(()=>{document.body.appendChild(ie);let e=[u.localeChanged$.subscribe(()=>{T(u.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(ie)}},[u,c,ie]),L(Cr,{locale:re==null?void 0:re.design,mountContainer:ie,children:[L(`div`,{"data-u-comp":`workbench-layout`,className:R(`univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":ne}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[I(`div`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,children:I(Q,{components:g},`custom-header`)}),n&&r&&I(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:I(Q,{components:te,sharedProps:{ribbonType:s,headerMenuComponents:y,headerMenu:a}},`toolbar`)}),L(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[L(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[I(`aside`,{"data-u-comp":`left-sidebar`,className:`univer-h-full`,children:I(Q,{components:x},`left-sidebar`)}),L(`section`,{className:R(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,Lr),children:[I(`header`,{children:n&&I(Q,{components:v},`header`)}),I(`section`,{className:`univer-relative univer-overflow-hidden dark:!univer-bg-gray-900`,ref:m,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:I(Q,{components:b},`content`)})]}),I(`aside`,{"data-u-comp":`right-sidebar`,className:`univer-z-[100] univer-h-full`,children:I(Io,{})})]}),i&&I(`footer`,{children:I(Q,{components:_,sharedProps:{contextMenu:o}},`footer`)}),I(Ro,{})]})]}),I(Q,{components:ee},`global`),I(Fo,{}),o&&I(No,{}),I(Vo,{}),I(`div`,{id:S})]})}function Vo(){let{mountContainer:e}=cr(Sr);return ri(I(Q,{components:$(X.FLOATING)},`floating`),e)}var Ho=class extends a{constructor(e,t,n,r,i){super(),this._injector=e,this._instanceService=t,this._layoutService=n,this._lifecycleService=r,this._renderManagerService=i,z(this,`_steadyTimeout`,void 0),z(this,`_renderTimeout`,void 0),z(this,`_currentRenderId`,null)}dispose(){super.dispose(),clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),delete this._instanceService,delete this._layoutService,delete this._lifecycleService,delete this._renderManagerService}_bootstrapWorkbench(){this.disposeWithMe(this.bootstrap(async(e,t)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(t)),this.disposeWithMe(this._layoutService.registerContentElement(e)));try{await this._lifecycleService.onStage(te.Ready),this._renderTimeout=window.setTimeout(()=>{let t=this._renderManagerService.getRenderAll();for(let[n]of t)if(this._changeRenderUnit(n,e))break;this.disposeWithMe(this._instanceService.focused$.subscribe(t=>{t&&this._changeRenderUnit(t,e)})),this.disposeWithMe(this._renderManagerService.created$.subscribe(t=>{var n;t.unitId===((n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId())&&this._changeRenderUnit(t.unitId,e)})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{this._currentRenderId===e&&(this._currentRenderId=null)})),this._lifecycleService.stage=te.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=te.Steady},3e3)},300)}catch(e){if(clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),e instanceof S)return;throw e}}))}_changeRenderUnit(e,t){if(this._currentRenderId===e)return!1;let n=this._renderManagerService.getRenderById(e);if(!n||!n.unitId||he(n.unitId))return!1;let r=this._currentRenderId?this._renderManagerService.getRenderById(this._currentRenderId):null;return r==null||r.deactivate(),r==null||r.engine.unmount(),n.engine.mount(t),n.activate(),this._currentRenderId=e,!0}};let Uo=class extends Ho{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(Ha),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[Si,xi],[wi,Ci],[Li,Fi],[Ri,Ii],[Hi,zi],[ki,xr]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return Wo(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.FLOATING,()=>N($a,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N(Ka,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>N(ho,this._injector)))}};Uo=U([H(1,b(x)),H(2,b(ee)),H(3,Zr),H(4,ua),H(5,y),H(6,J),H(7,Z),H(8,b(B))],Uo);function Wo(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||Go(i):i instanceof HTMLElement?i:Go(`univer`);let a=N(zo,e),o=e=>n(e,r);function s(){Kr(I(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),D(()=>{Xr(r)})}function Go(e){let t=document.createElement(`div`);return t.id=e,t}const Ko=E(`univer.ui.ui-controller`);var qo=`@univerjs/ui`,Jo=`0.20.0`;const Yo=`
43
+ `),children:I(V,{value$:e.value$,value:e.value,label:e.label,icon:e.icon,onChange:r=>{i==null||i({...e,value:r,id:n.id,label:t,commandId:e.commandId})}})})]});return c?I(`button`,{type:`button`,className:u,disabled:e.disabled,onClick:()=>{i==null||i({...e,id:n.id,label:t,commandId:e.commandId})},children:d},o):I(`div`,{className:u,"aria-disabled":e.disabled,children:d},o)})}),re&&I(ko,{menuSchemas:ne,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a})]})}),r):null)]})}function jo(e){let[t,n]=M({});return k(()=>{let t=e.map(e=>{var t;return(t=e.children)!=null&&t.length?De(e.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t})).subscribe(t=>{let r=t.every(e=>e===!0);n(t=>({...t,[e.key]:r}))}):null});return()=>{t.forEach(e=>e==null?void 0:e.unsubscribe()),n({})}},[e]),t}function Mo(e){let{hostId:t,visible:n,anchorRect:r,menuType:i,anchorVertical:a=`bottom`,menuOffset:o=0,onRequestClose:s,onOptionSelect:c}=e,l=j(null),u=P(yo),d=j(s),f=j(0),p=j(n),m=j(i);k(()=>{d.current=s},[s]),n&&(!p.current||i!==m.current)&&(f.current+=1),p.current=n,m.current=i,k(()=>{let e=u.registerMenu(t,()=>{d.current()});return()=>{e.dispose(),u.deactivateMenu(t)}},[u,t]),ur(()=>{if(n){u.activateMenu(t);return}u.deactivateMenu(t)},[u,t,n]),k(()=>{if(!n)return;let e=e=>e instanceof Element&&e.closest(`[data-u-context-menu-submenu]`),t=t=>{e(t.target)||l.current&&!l.current.contains(t.target)&&d.current()},r=e=>{e.key===`Escape`&&d.current()},i=t=>{var n;if(e(t.target)){t.stopPropagation();return}if((n=l.current)!=null&&n.contains(t.target)){t.stopPropagation();return}t.preventDefault(),t.stopPropagation()};return document.addEventListener(`pointerdown`,t),document.addEventListener(`keydown`,r),document.addEventListener(`wheel`,i,{capture:!0,passive:!1}),()=>{document.removeEventListener(`pointerdown`,t),document.removeEventListener(`keydown`,r),document.removeEventListener(`wheel`,i,!0)}},[n]);let h=A(()=>{if(!r)return[0,0];let e=a===`top`?r.top:r.bottom,t=a===`top`?e-o:e+o;return[r.left,t]},[r,a,o]);return I(Pr,{visible:n&&!!r,offset:h,overflowVisible:!0,placementY:a===`top`?`above`:`below`,children:I(`section`,{ref:l,children:i&&I(Oo,{menuType:i,menuSessionVersion:f.current,onOptionSelect:c})})})}function No(){let[e,t]=M(!1),[n,r]=M(``),[i,a]=M(null),o=j(e),s=P(_o),c=P(f),l=_r();o.current=e,k(()=>{let e=s.registerContextMenuHandler({handleContextMenu:u,hideContextMenu(){d()},get visible(){return o.current}});return()=>{e.dispose()}},[s]);function u(e,n){t(!1),requestAnimationFrame(()=>{r(n),a({left:e.clientX,top:e.clientY,bottom:e.clientY}),t(!0)})}function d(){t(!1)}return I(Mo,{hostId:`desktop-context-menu`,visible:e,anchorRect:i,menuType:n,onRequestClose:d,onOptionSelect:e=>{let{label:t,commandId:n,value:r}=e;c&&c.executeCommand(n==null?t:n,{value:r}),l.get(Li).focus(),d()}})}const Po=E(`univer.global-zone-service`);function Fo(){let e=P(Po),[t,n]=M(!1),r=F(e.componentKey$,e.componentKey),i=P(B),a=A(()=>{let e=i.get(r==null?``:r);if(e)return e},[r,i]);return k(()=>{let t=e.visible$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[e.visible$]),t?I(`section`,{className:R(`univer-absolute univer-bg-gray-100`,{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&I(a,{})}):null}function Io(){let e=P(ui),t=F(e.sidebarOptions$),n=j(null),r=A(()=>{if(!t)return null;let e={...t};for(let n of[`children`,`header`,`footer`]){let r=n;if(t[r]){let{key:n,...i}=t[r];i&&(e[r]=I(V,{...i},n))}}return e},[t]);k(()=>(n.current&&e.setContainer(n.current),()=>{e.setContainer(void 0)}),[e]),k(()=>{let t=t=>{e.scrollEvent$.next(t)},r=n.current;return r&&r.addEventListener(`scroll`,t),()=>{r==null||r.removeEventListener(`scroll`,t)}},[e]);let i=A(()=>r!=null&&r.visible?typeof r.width==`number`?`${r.width}px`:r.width:0,[r]);function a(){e.close(t==null?void 0:t.id)}return I(`section`,{"data-u-comp":`sidebar`,className:R(`univer-relative univer-h-full univer-bg-white univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-white`,{"univer-w-96 univer-translate-x-0":r==null?void 0:r.visible,"univer-w-0 univer-translate-x-full":!(r!=null&&r.visible)}),style:{width:i},children:L(`section`,{ref:n,className:R(`univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto] univer-overflow-y-auto`,zr,Jr),children:[L(`header`,{className:`univer-sticky univer-top-0 univer-z-10 univer-box-border univer-flex univer-cursor-default univer-items-center univer-justify-between univer-bg-white univer-p-4 univer-pb-2 univer-text-base univer-font-medium univer-text-gray-800 dark:!univer-bg-gray-900 dark:!univer-text-white`,children:[r==null?void 0:r.header,I(`a`,{className:`univer-cursor-pointer univer-text-gray-500 dark:!univer-text-gray-300`,onClick:a,children:I(ct,{})})]}),I(`section`,{className:`univer-box-border univer-cursor-default univer-px-4`,style:r==null?void 0:r.bodyStyle,children:r==null?void 0:r.children}),(r==null?void 0:r.footer)&&I(`footer`,{className:`univer-sticky univer-bottom-0 univer-box-border univer-bg-white univer-p-4 dark:!univer-bg-gray-900`,children:r.footer})]})})}const Lo=E(`univer.zen-zone-service`);function Ro(){let e=P(Lo),[t,n]=M(!1),[r,i]=M(),a=F(e.temporaryHidden$),o=P(B);k(()=>{let t=[e.visible$.subscribe(e=>{n(e)}),e.componentKey$.subscribe(e=>{i(e)})];return()=>{t.forEach(e=>{e.unsubscribe()})}},[]);let s=A(()=>{let e=o.get(r==null?``:r);if(e)return e},[r]);return I(`section`,{className:R(`univer-absolute univer-z-[-1] univer-flex`,{"univer-animate-in univer-fade-in univer-inset-0 univer-z-[100] univer-bg-gray-100":t,"univer-hidden":a}),children:I(`div`,{className:`univer-relative univer-flex-1`,children:s&&I(s,{})})})}function zo(e){let t=Di(Ai);return I(Bo,{...e,...t})}function Bo(e){var t;let{header:n=!0,toolbar:r=!0,footer:i=!0,headerMenu:a=!0,contextMenu:o=!0,ribbonType:s=`classic`,mountContainer:c,onRendered:l}=e,u=P(C),d=P(oe),f=P(go),m=j(null),h=P(p).getConfig(Ai),g=$(X.CUSTOM_HEADER),_=$(X.FOOTER),v=$(X.HEADER),y=$(X.HEADER_MENU),b=$(X.CONTENT),x=$(X.LEFT_SIDEBAR),ee=$(X.GLOBAL),te=$(X.TOOLBAR),S=(t=h==null?void 0:h.popupRootId)==null?`univer-popup-portal`:t;ur(()=>{let e=d.currentTheme$.subscribe(e=>{f.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]);let[ne,w]=M(!1);ur(()=>{let e=d.darkMode$.subscribe(e=>{w(e),e?document.documentElement.classList.add(`univer-dark`):document.documentElement.classList.remove(`univer-dark`)});return()=>{e.unsubscribe()}},[]),k(()=>{m.current&&(l==null||l(m.current))},[l]);let[re,T]=M(u.getLocales()),ie=A(()=>document.createElement(`div`),[]);return k(()=>{document.body.appendChild(ie);let e=[u.localeChanged$.subscribe(()=>{T(u.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(ie)}},[u,c,ie]),L(Cr,{locale:re==null?void 0:re.design,mountContainer:ie,children:[L(`div`,{"data-u-comp":`workbench-layout`,className:R(`univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":ne}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[I(`div`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,children:I(Q,{components:g},`custom-header`)}),n&&r&&I(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:I(Q,{components:te,sharedProps:{ribbonType:s,headerMenuComponents:y,headerMenu:a}},`toolbar`)}),L(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[L(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[I(`aside`,{"data-u-comp":`left-sidebar`,className:`univer-h-full`,children:I(Q,{components:x},`left-sidebar`)}),L(`section`,{className:R(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,Lr),children:[I(`header`,{children:n&&I(Q,{components:v},`header`)}),I(`section`,{className:`univer-relative univer-overflow-hidden dark:!univer-bg-gray-900`,ref:m,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:I(Q,{components:b},`content`)})]}),I(`aside`,{"data-u-comp":`right-sidebar`,className:`univer-z-[100] univer-h-full`,children:I(Io,{})})]}),i&&I(`footer`,{children:I(Q,{components:_,sharedProps:{contextMenu:o}},`footer`)}),I(Ro,{})]})]}),I(Q,{components:ee},`global`),I(Fo,{}),o&&I(No,{}),I(Vo,{}),I(`div`,{id:S})]})}function Vo(){let{mountContainer:e}=cr(Sr);return ri(I(Q,{components:$(X.FLOATING)},`floating`),e)}var Ho=class extends a{constructor(e,t,n,r,i){super(),this._injector=e,this._instanceService=t,this._layoutService=n,this._lifecycleService=r,this._renderManagerService=i,z(this,`_steadyTimeout`,void 0),z(this,`_renderTimeout`,void 0),z(this,`_currentRenderId`,null)}dispose(){super.dispose(),clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),delete this._instanceService,delete this._layoutService,delete this._lifecycleService,delete this._renderManagerService}_bootstrapWorkbench(){this.disposeWithMe(this.bootstrap(async(e,t)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(t)),this.disposeWithMe(this._layoutService.registerContentElement(e)));try{await this._lifecycleService.onStage(te.Ready),this._renderTimeout=window.setTimeout(()=>{let t=this._renderManagerService.getRenderAll();for(let[n]of t)if(this._changeRenderUnit(n,e))break;this.disposeWithMe(this._instanceService.focused$.subscribe(t=>{t&&this._changeRenderUnit(t,e)})),this.disposeWithMe(this._renderManagerService.created$.subscribe(t=>{var n;t.unitId===((n=this._instanceService.getFocusedUnit())==null?void 0:n.getUnitId())&&this._changeRenderUnit(t.unitId,e)})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(e=>{this._currentRenderId===e&&(this._currentRenderId=null)})),this._lifecycleService.stage=te.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=te.Steady},3e3)},300)}catch(e){if(clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),e instanceof S)return;throw e}}))}_changeRenderUnit(e,t){if(this._currentRenderId===e)return!1;let n=this._renderManagerService.getRenderById(e);if(!n||!n.unitId||he(n.unitId))return!1;let r=this._currentRenderId?this._renderManagerService.getRenderById(this._currentRenderId):null;return r==null||r.deactivate(),r==null||r.engine.unmount(),n.engine.mount(t),n.activate(),this._currentRenderId=e,!0}};let Uo=class extends Ho{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(Ha),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[Si,xi],[wi,Ci],[Vi,Fi],[Hi,Bi],[Ki,Ui],[ki,xr]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return Wo(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.FLOATING,()=>N($a,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N(Ka,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>N(ho,this._injector)))}};Uo=U([H(1,b(x)),H(2,b(ee)),H(3,Zr),H(4,Li),H(5,y),H(6,J),H(7,Z),H(8,b(B))],Uo);function Wo(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||Go(i):i instanceof HTMLElement?i:Go(`univer`);let a=N(zo,e),o=e=>n(e,r);function s(){Kr(I(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),D(()=>{Xr(r)})}function Go(e){let t=document.createElement(`div`);return t.id=e,t}const Ko=E(`univer.ui.ui-controller`);var qo=`@univerjs/ui`,Jo=`0.20.1`;const Yo=`
44
44
  univer-m-0 univer-flex univer-appearance-none univer-items-center univer-justify-center
45
45
  univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outline-none
46
46
  `;function Xo(e){var t;let{headerMenuComponents:n,headerMenu:r=!0}=e,i=P(C),a=P(eo),o=F(a.ribbon$,[]),s=F(a.activatedTab$,K.START),c=A(()=>{let e=o.findIndex(e=>e.key===s);return e===-1?0:e},[s,o]),l=o[c],u=(t=l==null?void 0:l.children)==null?[]:t,d=!!(r&&n&&n.size>0),f=j(null),[p,m]=M(!1),[h,g]=M(!1);if(k(()=>{!l&&o.length>0&&a.setActivatedTab(o[0].key)},[l,o,a]),k(()=>{let e=f.current;if(!e)return;let t=()=>{let{scrollLeft:t,clientWidth:n,scrollWidth:r}=e;m(t>4),g(t+n<r-4)};t();let n=new ResizeObserver(t);return n.observe(e),e.addEventListener(`scroll`,t,{passive:!0}),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[l]),o.length===0&&!d)return null;function _(e){let t=o[e];t&&a.setActivatedTab(t.key)}function v(e){let t=f.current;t&&t.scrollBy({left:e===`left`?-168:168,behavior:`smooth`})}return L(`div`,{"data-u-comp":`mobile-ribbon`,className:R(`univer-flex univer-flex-col univer-gap-1.5 univer-bg-gray-50 univer-px-3 univer-py-1.5 univer-text-sm dark:!univer-bg-gray-900`,Lr),children:[L(`div`,{className:`
@@ -114,7 +114,7 @@ univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outl
114
114
  univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-3 univer-text-gray-900
115
115
  [&>span]:univer-truncate [&>span]:univer-text-sm [&>span]:univer-font-medium
116
116
  [&>svg]:univer-shrink-0 [&>svg]:univer-text-lg [&>svg]:univer-text-gray-700
117
- `,children:I(V,{value$:n.value$,value:l,label:n.label,icon:n.icon})}),u&&I(ot,{className:`univer-shrink-0 univer-text-base univer-text-primary-600`})]})}function ns(e){var t;let{schema:n,menuType:r,onOpenView:i}=e,a=P(J),o=P(C),s=n.item,c=s,l=F(s==null?void 0:s.disabled$,!1),u=F(s==null?void 0:s.hidden$,!1),d=F(s==null?void 0:s.value$),f=F(c&&Ne(c.selections)?c.selections:void 0),p=A(()=>!c||(s==null?void 0:s.type)!==Y.SELECTOR&&(s==null?void 0:s.type)!==Y.BUTTON_SELECTOR?[]:f||(Array.isArray(c.selections)?c.selections:[]),[s==null?void 0:s.type,f,c]),m=A(()=>!s||s.type!==Y.SUBITEMS||!s.id?[]:a.getMenuByPositionKey(s.id),[s,a]);if(!s)return null;let h=(t=n.children)==null?[]:t,g=h.length>0||p.length>0||m.length>0;return{menuItem:s,disabled:l,hidden:u,value:d,currentValueText:typeof d==`string`||typeof d==`number`?String(d):``,hasSubmenu:g,onPress:e=>{if(h.length>0){i({kind:`schema`,title:rs(n,o),schemas:h});return}if(p.length>0&&c){i({kind:`options`,title:rs(n,o),options:p,menuItem:c,menuKey:n.key,currentValue:d});return}if(m.length>0){i({kind:`schema`,title:rs(n,o),schemas:m});return}if(s.type!==Y.BUTTON&&s.type!==Y.BUTTON_SELECTOR)return;let t=s;e==null||e({commandId:t.commandId,value:d,id:t.id,label:n.key,params:t.params})}}}function rs(e,t){let n=e.item;return typeof(n==null?void 0:n.title)==`string`?t.t(n.title):typeof(n==null?void 0:n.label)==`string`?t.t(n.label):typeof e.title==`string`?t.t(e.title):e.key}function is(e){let[t,n]=M({});return k(()=>{let t=e.map(e=>{var t;if(!((t=e.children)!=null&&t.length))return null;let r=as(e.children).map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t});return r.length?De(r).subscribe(t=>{let r=t.every(e=>e===!0);n(t=>({...t,[e.key]:r}))}):null});return()=>{t.forEach(e=>e==null?void 0:e.unsubscribe()),n({})}},[e]),t}function as(e){return e.reduce((e,t)=>{var n;return(n=t.children)!=null&&n.length?[...e,...as(t.children)]:t.item?[...e,t]:e},[])}const os=`mobile-context-menu`;function ss(){let[e,t]=M(!1),[n,r]=M(``),i=j(e),a=P(yo),o=P(_o),s=P(f),c=P(ua),l=P(C),{mountContainer:u}=cr(Sr);i.current=e,k(()=>{let e=a.registerMenu(os,()=>{t(!1)}),n=o.registerContextMenuHandler({handleContextMenu:d,hideContextMenu(){p()},get visible(){return i.current}});return()=>{n.dispose(),e.dispose(),a.deactivateMenu(os)}},[a,o]);function d(e,n){a.activateMenu(os),r(n),t(!0)}function p(){t(!1),a.deactivateMenu(os)}let m=A(()=>{switch(n){case Ma.ROW_HEADER:return l.t(`row`);case Ma.COL_HEADER:return l.t(`column`);default:return``}},[l,n]);return!u||!e?null:ri(L(`div`,{className:`univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end`,children:[I(`button`,{type:`button`,"aria-label":l.t(`rangeSelector.cancel`),className:`univer-absolute univer-inset-0 univer-bg-[rgba(15,23,42,0.32)] univer-backdrop-blur-[2px]`,onClick:p}),L(`section`,{role:`dialog`,"aria-modal":`true`,className:`
117
+ `,children:I(V,{value$:n.value$,value:l,label:n.label,icon:n.icon})}),u&&I(ot,{className:`univer-shrink-0 univer-text-base univer-text-primary-600`})]})}function ns(e){var t;let{schema:n,menuType:r,onOpenView:i}=e,a=P(J),o=P(C),s=n.item,c=s,l=F(s==null?void 0:s.disabled$,!1),u=F(s==null?void 0:s.hidden$,!1),d=F(s==null?void 0:s.value$),f=F(c&&Ne(c.selections)?c.selections:void 0),p=A(()=>!c||(s==null?void 0:s.type)!==Y.SELECTOR&&(s==null?void 0:s.type)!==Y.BUTTON_SELECTOR?[]:f||(Array.isArray(c.selections)?c.selections:[]),[s==null?void 0:s.type,f,c]),m=A(()=>!s||s.type!==Y.SUBITEMS||!s.id?[]:a.getMenuByPositionKey(s.id),[s,a]);if(!s)return null;let h=(t=n.children)==null?[]:t,g=h.length>0||p.length>0||m.length>0;return{menuItem:s,disabled:l,hidden:u,value:d,currentValueText:typeof d==`string`||typeof d==`number`?String(d):``,hasSubmenu:g,onPress:e=>{if(h.length>0){i({kind:`schema`,title:rs(n,o),schemas:h});return}if(p.length>0&&c){i({kind:`options`,title:rs(n,o),options:p,menuItem:c,menuKey:n.key,currentValue:d});return}if(m.length>0){i({kind:`schema`,title:rs(n,o),schemas:m});return}if(s.type!==Y.BUTTON&&s.type!==Y.BUTTON_SELECTOR)return;let t=s;e==null||e({commandId:t.commandId,value:d,id:t.id,label:n.key,params:t.params})}}}function rs(e,t){let n=e.item;return typeof(n==null?void 0:n.title)==`string`?t.t(n.title):typeof(n==null?void 0:n.label)==`string`?t.t(n.label):typeof e.title==`string`?t.t(e.title):e.key}function is(e){let[t,n]=M({});return k(()=>{let t=e.map(e=>{var t;if(!((t=e.children)!=null&&t.length))return null;let r=as(e.children).map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?Ie(!1):t});return r.length?De(r).subscribe(t=>{let r=t.every(e=>e===!0);n(t=>({...t,[e.key]:r}))}):null});return()=>{t.forEach(e=>e==null?void 0:e.unsubscribe()),n({})}},[e]),t}function as(e){return e.reduce((e,t)=>{var n;return(n=t.children)!=null&&n.length?[...e,...as(t.children)]:t.item?[...e,t]:e},[])}const os=`mobile-context-menu`;function ss(){let[e,t]=M(!1),[n,r]=M(``),i=j(e),a=P(yo),o=P(_o),s=P(f),c=P(Li),l=P(C),{mountContainer:u}=cr(Sr);i.current=e,k(()=>{let e=a.registerMenu(os,()=>{t(!1)}),n=o.registerContextMenuHandler({handleContextMenu:d,hideContextMenu(){p()},get visible(){return i.current}});return()=>{n.dispose(),e.dispose(),a.deactivateMenu(os)}},[a,o]);function d(e,n){a.activateMenu(os),r(n),t(!0)}function p(){t(!1),a.deactivateMenu(os)}let m=A(()=>{switch(n){case Ma.ROW_HEADER:return l.t(`row`);case Ma.COL_HEADER:return l.t(`column`);default:return``}},[l,n]);return!u||!e?null:ri(L(`div`,{className:`univer-fixed univer-inset-0 univer-z-[1080] univer-flex univer-items-end`,children:[I(`button`,{type:`button`,"aria-label":l.t(`rangeSelector.cancel`),className:`univer-absolute univer-inset-0 univer-bg-[rgba(15,23,42,0.32)] univer-backdrop-blur-[2px]`,onClick:p}),L(`section`,{role:`dialog`,"aria-modal":`true`,className:`
118
118
  univer-relative univer-z-[1] univer-mx-auto univer-flex univer-max-h-[80vh] univer-w-full
119
119
  univer-max-w-[560px] univer-flex-col univer-overflow-hidden univer-rounded-t-[28px] univer-bg-gray-50
120
120
  univer-shadow-[0_-16px_48px_rgba(15,23,42,0.18)]
@@ -125,9 +125,9 @@ univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outl
125
125
  univer-ring-0 univer-transition-colors
126
126
  hover:univer-bg-gray-100
127
127
  active:univer-bg-gray-200
128
- `,style:{margin:0},onClick:p,children:I(ct,{className:`univer-size-4 univer-text-current`})})]})]}),n&&I(Zo,{menuType:n,onOptionSelect:e=>{var t,n;let r=(t=(n=e.commandId)==null?e.id:n)==null?e.label:t,i=typeof e.params==`function`?e.params():e.params,a=e.value===void 0?i:{value:e.value};r&&(c.focus(),s.executeCommand(r,a),p())}})]})]}),u)}function cs(e){let{header:t=!0,toolbar:n=!0,footer:r=!0,headerMenu:i=!0,ribbonType:a=`classic`,contextMenu:o=!0,mountContainer:s,onRendered:c}=e,l=P(C),u=P(oe),d=P(go),f=j(null),p=$(X.FOOTER),m=$(X.HEADER),h=$(X.HEADER_MENU),g=$(X.CONTENT),_=$(X.LEFT_SIDEBAR),v=$(X.GLOBAL),y=$(X.TOOLBAR),[b,x]=M(!1);k(()=>{let e=u.darkMode$.subscribe(e=>{x(e)});return()=>{e.unsubscribe()}},[]),k(()=>{f.current&&(c==null||c(f.current))},[c]);let[ee,te]=M(l.getLocales()),S=A(()=>document.createElement(`div`),[]);return ur(()=>{let e=u.currentTheme$.subscribe(e=>{d.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]),k(()=>{document.body.appendChild(S);let e=[l.localeChanged$.subscribe(()=>{te(l.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(S)}},[l,s,S]),L(Cr,{locale:ee==null?void 0:ee.design,mountContainer:S,children:[L(`div`,{"data-u-comp":`app-layout`,className:R(`univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":b}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[t&&n&&I(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:I(Q,{components:y,sharedProps:{ribbonType:a,headerMenuComponents:h,headerMenu:i}},`toolbar`)}),L(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[L(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[I(`aside`,{className:`univer-h-full`,children:I(Q,{components:_},`left-sidebar`)}),L(`section`,{className:R(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,Lr),children:[I(`header`,{className:`univer-w-screen`,children:t&&I(Q,{components:m},`header`)}),I(`section`,{ref:f,className:`univer-relative univer-overflow-hidden`,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:I(Q,{components:g},`content`)})]}),I(`aside`,{className:`univer-h-full`,children:I(Io,{})})]}),r&&I(`footer`,{children:I(Q,{components:p},`footer`)}),I(Fo,{}),I(Ro,{})]})]}),I(Q,{components:v},`global`),o&&I(ss,{})]})}let ls=class extends Ho{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(Ha),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return us(this._injector,this._config,e)}_registerComponents(){[[Si,xi],[wi,Ci],[Li,Fi],[Ri,Ii],[Hi,zi],[ki,xr]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N($a,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N(Ka,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>N(Xo,this._injector)))}};ls=U([H(1,b(x)),H(2,b(ee)),H(3,Zr),H(4,ua),H(5,y),H(6,J),H(7,Z),H(8,b(B))],ls);function us(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||ds(i):i instanceof HTMLElement?i:ds(`univer`);let a=N(cs,e),o=e=>n(e,r);function s(){Kr(I(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),D(()=>{Xr(r)})}function ds(e){let t=document.createElement(`div`);return t.id=e,t}const fs=E(`ui.notification.service`),ps=E(`univer.ui.before-close-service`);let ms=class{constructor(e){this._notificationService=e,z(this,`_beforeUnloadCallbacks`,[]),z(this,`_onCloseCallbacks`,[]),this._init()}registerBeforeClose(e){return this._beforeUnloadCallbacks.push(e),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(t=>t!==e)}}}registerOnClose(e){return this._onCloseCallbacks.push(e),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(t=>t!==e)}}}_init(){window.addEventListener(`beforeunload`,e=>{let t=e,n=this._beforeUnloadCallbacks.map(e=>e()).filter(e=>!!e).join(`
129
- `);if(n)return this._notificationService.show({type:`error`,title:`Some changes are not saved`,content:n}),t===void 0&&(t=window.event),t.returnValue=n,n}),window.addEventListener(`unload`,()=>{this._onCloseCallbacks.forEach(e=>e())})}};ms=U([H(0,fs)],ms);function hs(e,t){e.querySelectorAll(t.strippedSelector).forEach(e=>e.remove()),e.querySelectorAll(`*`).forEach(e=>{for(let{name:t}of Array.from(e.attributes))t.startsWith(`on`)&&e.removeAttribute(t)})}function gs(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return hs(n,t),n.body}function _s(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return hs(n,t),n}function vs(){return navigator.clipboard!==void 0&&navigator.clipboard.readText!==void 0}const ys=`text/plain`,bs=`text/html`,xs=`image/png`,Ss=`image/jpeg`,Cs=`image/bmp`,ws=`image/webp`,Ts=`image/svg+xml`,Es=new Set([Cs,Ss,ws,xs]),Ds=new Set([`base`,`button`,`embed`,`form`,`frame`,`frameset`,`head`,`iframe`,`input`,`link`,`meta`,`object`,`script`,`select`,`style`,`template`,`textarea`]),Os=new Set(`a.b.blockquote.br.caption.code.col.colgroup.dd.div.dl.dt.em.font.h1.h2.h3.h4.h5.h6.hr.i.img.li.ol.p.pre.s.span.strike.strong.sub.sup.table.tbody.td.tfoot.th.thead.tr.u.ul`.split(`.`)),ks=new Set(`align.alt.aria-colindex.aria-colspan.aria-label.aria-labelledby.aria-rowindex.aria-rowspan.bgcolor.border.cellpadding.cellspacing.class.colspan.color.dir.face.headers.height.href.lang.rel.role.rowspan.size.src.style.target.title.valign.width`.split(`.`)),As=E(`univer.clipboard-interface-service`);let js=class extends a{get supportClipboard(){return vs()}constructor(e,t,n){super(),this._localeService=e,this._logService=t,this._notificationService=n}async write(e,t){if(!this.supportClipboard)return this._legacyCopyHtml(t);try{return await navigator.clipboard.write([new ClipboardItem({[ys]:new Blob([e],{type:ys}),[bs]:new Blob([t],{type:bs})})])}catch(e){this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification()}}async writeText(e){if(!this.supportClipboard)return this._legacyCopyText(e);try{return await navigator.clipboard.writeText(e)}catch(e){this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification()}}async read(){if(!this.supportClipboard)throw Error(`[BrowserClipboardService] read() is not supported on this platform.`);try{return navigator.clipboard.read()}catch(e){return this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification(),[]}}async readText(){if(!this.supportClipboard)throw Error(`[BrowserClipboardService] read() is not supported on this platform.`);try{return await navigator.clipboard.readText()}catch(e){return this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification(),``}}_legacyCopyHtml(e){let t=document.activeElement,n=Ns();document.body.appendChild(n),n.replaceChildren(Ps(e));try{Bs(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_legacyCopyText(e){let t=document.activeElement,n=Ms();document.body.appendChild(n),n.value=e;try{Bs(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_showClipboardAuthenticationNotification(){var e;(e=this._notificationService)==null||e.show({type:`warning`,title:this._localeService.t(`clipboard.authentication.title`),content:this._localeService.t(`clipboard.authentication.content`)})}};js=U([H(0,b(C)),H(1,_),H(2,re(fs))],js);function Ms(){let e=document.createElement(`textarea`);return e.style.position=`absolute`,e.style.height=`1px`,e.style.width=`1px`,e.style.opacity=`0`,e.readOnly=!0,e}function Ns(){let e=document.createElement(`div`);return e.contentEditable=`true`,e.style.position=`absolute`,e.style.opacity=`0`,e.style.height=`1px`,e.style.width=`1px`,e}function Ps(e){let t=new DOMParser().parseFromString(e,bs);hs(t,{strippedSelector:`script, iframe, object, embed`});let n=document.createDocumentFragment();return Array.from(t.body.childNodes).forEach(e=>{let t=Fs(e);t&&n.appendChild(t)}),n}function Fs(e){if(e.nodeType===Node.TEXT_NODE){var t;return document.createTextNode((t=e.textContent)==null?``:t)}if(e.nodeType!==Node.ELEMENT_NODE)return null;let n=e,r=n.tagName.toLowerCase();if(Ds.has(r))return null;if(!Os.has(r)){let e=document.createDocumentFragment();return Array.from(n.childNodes).forEach(t=>{let n=Fs(t);n&&e.appendChild(n)}),e}let i=document.createElement(r);return Is(n,i),Array.from(n.childNodes).forEach(e=>{let t=Fs(e);t&&i.appendChild(t)}),i}function Is(e,t){Array.from(e.attributes).forEach(e=>{let n=e.name.toLowerCase();if(!n.startsWith(`on`)){if(n.startsWith(`data-`)||n.startsWith(`aria-`)){t.setAttribute(e.name,e.value);return}if(ks.has(n)){if(n===`href`||n===`src`){let r=Ls(e.value,n===`src`);r&&t.setAttribute(e.name,r);return}if(n===`style`){let n=Rs(e.value);n&&t.setAttribute(e.name,n);return}t.setAttribute(e.name,e.value)}}})}function Ls(e,t){let n=e.trim();return n&&(n.startsWith(`#`)||/^(?:https?:|mailto:|tel:)/i.test(n)||t&&/^data:image\/[a-z0-9.+-]+;base64,/i.test(n)||/^(?:\/|\.\/|\.\.\/)/.test(n))?n:null}function Rs(e){let t=document.createElement(`div`);t.style.cssText=e;let n=[];return Array.from(t.style).forEach(e=>{let r=t.style.getPropertyValue(e).trim();!r||zs(r)||n.push(`${e}: ${r}`)}),n.join(`; `)}function zs(e){return/(expression\s*\(|url\s*\(|javascript:|vbscript:|mocha:|-moz-binding|behavior\s*:|@import)/i.test(e)}function Bs(e){if(e instanceof HTMLTextAreaElement){let t=e.hasAttribute(`readonly`);return t||e.setAttribute(`readonly`,``),e.select(),e.setSelectionRange(0,e.value.length),t||e.removeAttribute(`readonly`),e.value}e.hasAttribute(`contenteditable`)&&e.focus();let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();if(!n)throw Error();return n.removeAllRanges(),n.addRange(t),n.toString()}const Vs=e=>{let{children:t,onClose:n,onConfirm:r}=e,[i]=M({}),a=t?nr(t,{hooks:i}):null;return I(wr,{...e,children:a,onClose:()=>{let e=i.beforeClose;if(e){let t=e();if(t.cancel)return;n==null||n(t);return}n==null||n()},onConfirm:()=>{let e=i.beforeConfirm;if(e){let t=e();if(t.cancel)return;r==null||r(t);return}r==null||r()}})};function Hs(){let e=P(m),[t,n]=M([]);k(()=>{let t=e.confirmOptions$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[]);let r=t.map(e=>{let{children:t,title:n,...r}=e,i=r;for(let t of[`children`,`title`]){let n=t,r=e[n];r&&(i[n]=I(V,{...r}))}return i});return r==null?void 0:r.map((e,t)=>I(Vs,{...e,children:e.children},t))}let Us=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`_confirmOptions`,[]),z(this,`confirmOptions$`,new O([])),this._initUIPart()}open(e){return this._confirmOptions.find(t=>t.id===e.id)?this._confirmOptions=this._confirmOptions.map(t=>({...t.id===e.id?e:t,visible:t.id===e.id?!0:t.visible})):this._confirmOptions.push({...e,visible:!0}),this.confirmOptions$.next(this._confirmOptions),D(()=>{this._confirmOptions=[],this.confirmOptions$.next([])})}confirm(e){return new Promise(t=>{let n=this.open({...e,onConfirm:()=>{n.dispose(),t(!0)},onClose:()=>{n.dispose(),t(!1)}})})}close(e){this._confirmOptions=this._confirmOptions.map(t=>({...t,visible:t.id===e?!1:t.visible})),this.confirmOptions$.next([...this._confirmOptions])}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Hs,this._injector)))}};Us=U([H(0,b(x)),H(1,Z)],Us);const Ws=E(`univer.ui.dialog-service`);function Gs(){let e=P(Ws),[t,n]=M([]);k(()=>{let t=e.getDialogs$().subscribe(e=>{n(e)});return()=>t.unsubscribe()},[]);let r=A(()=>t.map(e=>{let{children:t,title:n,footer:r,...i}=e,a=i;for(let t of[`children`,`title`,`footer`]){let n=t,r=e[n];r&&(a[n]=I(V,{...r}))}return a}),[t]);return r==null?void 0:r.map(e=>I(Tr,{...e},e.id))}let Ks=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`_dialogOptions`,[]),z(this,`_dialogOptions$`,new Te),this._initUIPart()}dispose(){super.dispose(),this._dialogOptions=[],this._dialogOptions$.complete()}open(e){return this._dialogOptions.find(t=>t.id===e.id)?this._dialogOptions=this._dialogOptions.map(t=>({...t.id===e.id?e:t,open:t.id===e.id?!0:t.open})):this._dialogOptions.push({...e,open:!0}),this._dialogOptions$.next(this._dialogOptions),D(()=>{this._dialogOptions=[],this._dialogOptions$.next([])})}close(e){this._dialogOptions=this._dialogOptions.map(t=>({...t,open:t.id===e?!1:t.open})),this._dialogOptions$.next([...this._dialogOptions])}closeAll(e){let t=new Set(e);this._dialogOptions=this._dialogOptions.map(e=>({...e,open:t.has(e.id)?e.open:!1})),this._dialogOptions$.next([...this._dialogOptions])}getDialogs$(){return this._dialogOptions$.asObservable()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Gs,this._injector)))}};Ks=U([H(0,b(x)),H(1,Z)],Ks);const qs=E(`univer.ui.gallery-service`);function Js(){let e=F(P(qs).gallery$);return e?I(Or,{...e}):null}let Ys=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`gallery$`,new Te),this._initUIPart()}dispose(){super.dispose()}open(e){return this.gallery$.next({open:!0,...e}),D(()=>{this.gallery$.complete()})}close(){this.gallery$.next({open:!1,images:[]})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Js,this._injector)))}};Ys=U([H(0,b(x)),H(1,Z)],Ys);let Xs=class{constructor(e){this._componentManager=e,z(this,`visible$`,new Te),z(this,`componentKey$`,new Te),z(this,`_componentKey`,``)}get componentKey(){return this._componentKey}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),this._componentKey=e,D(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};Xs=U([H(0,b(B))],Xs);var Zs=class extends a{openFile(e){return new Promise(t=>{var n,r;let i=document.createElement(`input`);i.type=`file`,i.accept=(n=e==null?void 0:e.accept)==null?``:n,i.multiple=(r=e==null?void 0:e.multiple)==null?!1:r,i.onchange=e=>{let n=e.target.files;n&&t(Array.from(n))},i.click()})}downloadFile(e,t){let n=document.createElement(`a`);n.download=t,n.href=window.URL.createObjectURL(e),n.click()}};const Qs=E(`univer-ui.local-file.service`);var $s=class{getItem(e){return ii.getItem(e)}setItem(e,t){return ii.setItem(e,t)}removeItem(e){return ii.removeItem(e)}clear(){return ii.clear()}key(e){return ii.key(e)}keys(){return ii.keys()}iterate(e){return ii.iterate(e)}};function ec(){return I(Nr,{theme:F(P(oe).darkMode$)?`dark`:`light`})}let tc=0,nc=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(ec,this._injector)))}dispose(){super.dispose(),Gr()}show(e){var t;let n=(t=e.id)==null?`message-${Date.now()}-${tc}`:t;return tc+=1,Wr(Object.assign({},e,{id:n})),D(()=>Gr(n))}remove(e){Gr(e)}removeAll(){Gr()}};nc=U([H(0,b(x)),H(1,Z)],nc);function rc(){return I(Fr,{theme:F(P(oe).darkMode$)?`dark`:`light`})}const ic={show:e=>{let{type:t=`message`,title:n,content:r,duration:i,closable:a=!0,position:o=`top-right`}=e;Yr[t](n,{position:o,description:r,duration:i,closeButton:a})}};let ac=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}show(e){return ic.show(e),D(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(rc,this._injector)))}};ac=U([H(0,b(x)),H(1,Z)],ac);var oc=class{constructor(){z(this,`_sidebarOptions`,{}),z(this,`sidebarOptions$`,new Te),z(this,`scrollEvent$`,new Te),z(this,`_container`,void 0)}get visible(){return this._sidebarOptions.visible||!1}get options(){return this._sidebarOptions}open(e){return this._sidebarOptions={...e,id:e.id,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),D(()=>{this.close()})}close(e){e&&this._sidebarOptions.id!==e||(this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),this._sidebarOptions.onClose&&this._sidebarOptions.onClose())}getContainer(){return this._container}setContainer(e){this._container=e}};let sc=class{get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}constructor(e){this._componentManager=e,z(this,`visible$`,new O(!1)),z(this,`componentKey$`,new we),z(this,`_temporaryHidden$`,new O(!1)),z(this,`temporaryHidden$`,this._temporaryHidden$.asObservable()),z(this,`_visible`,!1)}dispose(){this.visible$.next(!1),this.visible$.complete(),this.componentKey$.complete()}hide(){this._temporaryHidden$.next(!0)}show(){this._temporaryHidden$.next(!1)}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),D(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this._visible=!0,this.visible$.next(!0)}close(){this._visible=!1,this.visible$.next(!1)}};sc=U([H(0,b(B))],sc);let cc=class extends T{constructor(e=ji,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=_e({popupRootId:`univer-popup-portal-${pe(6)}`},ji,this._config);a.disableAutoFocus&&this._contextService.setContextValue(`DISABLE_AUTO_FOCUS`,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Ai,a)}onStarting(){ye(this._injector,ve([[B],[go],[mi],[ci],[Z,{useClass:Ua}],[ua,{useClass:da}],[eo,{useClass:to}],[ha,{useClass:ga}],[pa,{useClass:ma}],[J,{useClass:Na}],[yo,{useClass:bo}],[_o,{useClass:vo}],[As,{useClass:js,lazy:!0}],[fs,{useClass:ac,lazy:!0}],[qs,{useClass:Ys,lazy:!0}],[Ws,{useClass:Ks,lazy:!0}],[m,{useClass:Us,lazy:!0}],[ui,{useClass:oc,lazy:!0}],[Lo,{useClass:sc,lazy:!0}],[Po,{useClass:Xs,lazy:!0}],[Qi,{useClass:nc,lazy:!0}],[g,{useClass:$s,lazy:!0}],[ps,{useClass:ms}],[Qs,{useClass:Zs}],[qa,{useClass:Ja}],[Mi,{useClass:Pi}],[Wa],[Ko,{useFactory:e=>e.createInstance(ls,this._config),deps:[x]}],[wa],[$i],[Ia]],this._config.override)),Se(this._injector,[[Ko],[$i]])}onReady(){Se(this._injector,[[wa]])}onSteady(){Se(this._injector,[[Ia]])}};z(cc,`pluginName`,`UNIVER_MOBILE_UI_PLUGIN`),z(cc,`packageName`,qo),z(cc,`version`,Jo),cc=U([i(Qr),H(1,h),H(2,b(x)),H(3,p)],cc);const lc=`DISABLE_AUTO_FOCUS`;let uc=class extends T{constructor(e=ji,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=_e({popupRootId:`univer-popup-portal-${pe(6)}`},ji,this._config);a.disableAutoFocus&&this._contextService.setContextValue(lc,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Ai,a)}onStarting(){ye(this._injector,ve([[B],[go],[mi],[ci],[Z,{useClass:Ua}],[ua,{useClass:da}],[eo,{useClass:to}],[ha,{useClass:ga}],[pa,{useClass:ma}],[J,{useClass:Na}],[yo,{useClass:bo}],[_o,{useClass:vo}],[As,{useClass:js,lazy:!0}],[fs,{useClass:ac,lazy:!0}],[qs,{useClass:Ys,lazy:!0}],[Ws,{useClass:Ks,lazy:!0}],[m,{useClass:Us,lazy:!0}],[ui,{useClass:oc,lazy:!0}],[Lo,{useClass:sc,lazy:!0}],[Po,{useClass:Xs,lazy:!0}],[Qi,{useClass:nc,lazy:!0}],[g,{useClass:$s,lazy:!0}],[ps,{useClass:ms}],[Qs,{useClass:Zs}],[qa,{useClass:Ja}],[Mi,{useClass:Pi}],[Wa],[Ko,{useFactory:e=>e.createInstance(Uo,this._config),deps:[x]}],[wa],[$i],[Ia]],this._config.override)),Se(this._injector,[[Ko],[$i]])}onReady(){Se(this._injector,[[wa]])}onSteady(){Se(this._injector,[[Ia]])}};z(uc,`pluginName`,`UNIVER_UI_PLUGIN`),z(uc,`packageName`,qo),z(uc,`version`,Jo),uc=U([i(Qr),H(1,h),H(2,b(x)),H(3,p)],uc);var dc=class{show(e){return D(()=>{})}remove(e){}removeAll(){}setContainer(){}getContainer(){}};const fc=e=>{let t=P(ui).getContainer();k(()=>{if(t)return t.addEventListener(`mousedown`,e),()=>{t.removeEventListener(`mousedown`,e)}},[e,t])};function pc(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,``)}const mc={strippedSelector:`script, iframe, object, embed`};function hc(e){let t=e.childNodes;if(t.length===0)return e.textContent;if(t[0].nodeName===`DIV`&&(t=t[0].childNodes),t.length===1&&t[0].nodeName===`#text`)return t[0].textContent;let n=[],r=0,i=0,a=e.textContent||``;a+=`\r
128
+ `,style:{margin:0},onClick:p,children:I(ct,{className:`univer-size-4 univer-text-current`})})]})]}),n&&I(Zo,{menuType:n,onOptionSelect:e=>{var t,n;let r=(t=(n=e.commandId)==null?e.id:n)==null?e.label:t,i=typeof e.params==`function`?e.params():e.params,a=e.value===void 0?i:{value:e.value};r&&(c.focus(),s.executeCommand(r,a),p())}})]})]}),u)}function cs(e){let{header:t=!0,toolbar:n=!0,footer:r=!0,headerMenu:i=!0,ribbonType:a=`classic`,contextMenu:o=!0,mountContainer:s,onRendered:c}=e,l=P(C),u=P(oe),d=P(go),f=j(null),p=$(X.FOOTER),m=$(X.HEADER),h=$(X.HEADER_MENU),g=$(X.CONTENT),_=$(X.LEFT_SIDEBAR),v=$(X.GLOBAL),y=$(X.TOOLBAR),[b,x]=M(!1);k(()=>{let e=u.darkMode$.subscribe(e=>{x(e)});return()=>{e.unsubscribe()}},[]),k(()=>{f.current&&(c==null||c(f.current))},[c]);let[ee,te]=M(l.getLocales()),S=A(()=>document.createElement(`div`),[]);return ur(()=>{let e=u.currentTheme$.subscribe(e=>{d.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]),k(()=>{document.body.appendChild(S);let e=[l.localeChanged$.subscribe(()=>{te(l.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(S)}},[l,s,S]),L(Cr,{locale:ee==null?void 0:ee.design,mountContainer:S,children:[L(`div`,{"data-u-comp":`app-layout`,className:R(`univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":b}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[t&&n&&I(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:I(Q,{components:y,sharedProps:{ribbonType:a,headerMenuComponents:h,headerMenu:i}},`toolbar`)}),L(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[L(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[I(`aside`,{className:`univer-h-full`,children:I(Q,{components:_},`left-sidebar`)}),L(`section`,{className:R(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,Lr),children:[I(`header`,{className:`univer-w-screen`,children:t&&I(Q,{components:m},`header`)}),I(`section`,{ref:f,className:`univer-relative univer-overflow-hidden`,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:I(Q,{components:g},`content`)})]}),I(`aside`,{className:`univer-h-full`,children:I(Io,{})})]}),r&&I(`footer`,{children:I(Q,{components:p},`footer`)}),I(Fo,{}),I(Ro,{})]})]}),I(Q,{components:v},`global`),o&&I(ss,{})]})}let ls=class extends Ho{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(Ha),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return us(this._injector,this._config,e)}_registerComponents(){[[Si,xi],[wi,Ci],[Vi,Fi],[Hi,Bi],[Ki,Ui],[ki,xr]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N($a,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>N(Ka,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>N(Xo,this._injector)))}};ls=U([H(1,b(x)),H(2,b(ee)),H(3,Zr),H(4,Li),H(5,y),H(6,J),H(7,Z),H(8,b(B))],ls);function us(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||ds(i):i instanceof HTMLElement?i:ds(`univer`);let a=N(cs,e),o=e=>n(e,r);function s(){Kr(I(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),D(()=>{Xr(r)})}function ds(e){let t=document.createElement(`div`);return t.id=e,t}const fs=E(`ui.notification.service`),ps=E(`univer.ui.before-close-service`);let ms=class{constructor(e){this._notificationService=e,z(this,`_beforeUnloadCallbacks`,[]),z(this,`_onCloseCallbacks`,[]),this._init()}registerBeforeClose(e){return this._beforeUnloadCallbacks.push(e),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(t=>t!==e)}}}registerOnClose(e){return this._onCloseCallbacks.push(e),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(t=>t!==e)}}}_init(){window.addEventListener(`beforeunload`,e=>{let t=e,n=this._beforeUnloadCallbacks.map(e=>e()).filter(e=>!!e).join(`
129
+ `);if(n)return this._notificationService.show({type:`error`,title:`Some changes are not saved`,content:n}),t===void 0&&(t=window.event),t.returnValue=n,n}),window.addEventListener(`unload`,()=>{this._onCloseCallbacks.forEach(e=>e())})}};ms=U([H(0,fs)],ms);function hs(e,t){e.querySelectorAll(t.strippedSelector).forEach(e=>e.remove()),e.querySelectorAll(`*`).forEach(e=>{for(let{name:t}of Array.from(e.attributes))t.startsWith(`on`)&&e.removeAttribute(t)})}function gs(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return hs(n,t),n.body}function _s(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return hs(n,t),n}function vs(){return navigator.clipboard!==void 0&&navigator.clipboard.readText!==void 0}const ys=`text/plain`,bs=`text/html`,xs=`image/png`,Ss=`image/jpeg`,Cs=`image/bmp`,ws=`image/webp`,Ts=`image/svg+xml`,Es=new Set([Cs,Ss,ws,xs]),Ds=new Set([`base`,`button`,`embed`,`form`,`frame`,`frameset`,`head`,`iframe`,`input`,`link`,`meta`,`object`,`script`,`select`,`style`,`template`,`textarea`]),Os=new Set(`a.b.blockquote.br.caption.code.col.colgroup.dd.div.dl.dt.em.font.h1.h2.h3.h4.h5.h6.hr.i.img.li.ol.p.pre.s.span.strike.strong.sub.sup.table.tbody.td.tfoot.th.thead.tr.u.ul`.split(`.`)),ks=new Set(`align.alt.aria-colindex.aria-colspan.aria-label.aria-labelledby.aria-rowindex.aria-rowspan.bgcolor.border.cellpadding.cellspacing.class.colspan.color.dir.face.headers.height.href.lang.rel.role.rowspan.size.src.style.target.title.valign.width`.split(`.`)),As=E(`univer.clipboard-interface-service`);let js=class extends a{get supportClipboard(){return vs()}constructor(e,t,n){super(),this._localeService=e,this._logService=t,this._notificationService=n}async write(e,t){if(!this.supportClipboard)return this._legacyCopyHtml(t);try{return await navigator.clipboard.write([new ClipboardItem({[ys]:new Blob([e],{type:ys}),[bs]:new Blob([t],{type:bs})})])}catch(e){this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification()}}async writeText(e){if(!this.supportClipboard)return this._legacyCopyText(e);try{return await navigator.clipboard.writeText(e)}catch(e){this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification()}}async read(){if(!this.supportClipboard)throw Error(`[BrowserClipboardService] read() is not supported on this platform.`);try{return navigator.clipboard.read()}catch(e){return this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification(),[]}}async readText(){if(!this.supportClipboard)throw Error(`[BrowserClipboardService] read() is not supported on this platform.`);try{return await navigator.clipboard.readText()}catch(e){return this._logService.error(`[BrowserClipboardService]`,e),this._showClipboardAuthenticationNotification(),``}}_legacyCopyHtml(e){let t=document.activeElement,n=Ns();document.body.appendChild(n),n.replaceChildren(Ps(e));try{Bs(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_legacyCopyText(e){let t=document.activeElement,n=Ms();document.body.appendChild(n),n.value=e;try{Bs(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_showClipboardAuthenticationNotification(){var e;(e=this._notificationService)==null||e.show({type:`warning`,title:this._localeService.t(`clipboard.authentication.title`),content:this._localeService.t(`clipboard.authentication.content`)})}};js=U([H(0,b(C)),H(1,_),H(2,re(fs))],js);function Ms(){let e=document.createElement(`textarea`);return e.style.position=`absolute`,e.style.height=`1px`,e.style.width=`1px`,e.style.opacity=`0`,e.readOnly=!0,e}function Ns(){let e=document.createElement(`div`);return e.contentEditable=`true`,e.style.position=`absolute`,e.style.opacity=`0`,e.style.height=`1px`,e.style.width=`1px`,e}function Ps(e){let t=new DOMParser().parseFromString(e,bs);hs(t,{strippedSelector:`script, iframe, object, embed`});let n=document.createDocumentFragment();return Array.from(t.body.childNodes).forEach(e=>{let t=Fs(e);t&&n.appendChild(t)}),n}function Fs(e){if(e.nodeType===Node.TEXT_NODE){var t;return document.createTextNode((t=e.textContent)==null?``:t)}if(e.nodeType!==Node.ELEMENT_NODE)return null;let n=e,r=n.tagName.toLowerCase();if(Ds.has(r))return null;if(!Os.has(r)){let e=document.createDocumentFragment();return Array.from(n.childNodes).forEach(t=>{let n=Fs(t);n&&e.appendChild(n)}),e}let i=document.createElement(r);return Is(n,i),Array.from(n.childNodes).forEach(e=>{let t=Fs(e);t&&i.appendChild(t)}),i}function Is(e,t){Array.from(e.attributes).forEach(e=>{let n=e.name.toLowerCase();if(!n.startsWith(`on`)){if(n.startsWith(`data-`)||n.startsWith(`aria-`)){t.setAttribute(e.name,e.value);return}if(ks.has(n)){if(n===`href`||n===`src`){let r=Ls(e.value,n===`src`);r&&t.setAttribute(e.name,r);return}if(n===`style`){let n=Rs(e.value);n&&t.setAttribute(e.name,n);return}t.setAttribute(e.name,e.value)}}})}function Ls(e,t){let n=e.trim();return n&&(n.startsWith(`#`)||/^(?:https?:|mailto:|tel:)/i.test(n)||t&&/^data:image\/[a-z0-9.+-]+;base64,/i.test(n)||/^(?:\/|\.\/|\.\.\/)/.test(n))?n:null}function Rs(e){let t=document.createElement(`div`);t.style.cssText=e;let n=[];return Array.from(t.style).forEach(e=>{let r=t.style.getPropertyValue(e).trim();!r||zs(r)||n.push(`${e}: ${r}`)}),n.join(`; `)}function zs(e){return/(expression\s*\(|url\s*\(|javascript:|vbscript:|mocha:|-moz-binding|behavior\s*:|@import)/i.test(e)}function Bs(e){if(e instanceof HTMLTextAreaElement){let t=e.hasAttribute(`readonly`);return t||e.setAttribute(`readonly`,``),e.select(),e.setSelectionRange(0,e.value.length),t||e.removeAttribute(`readonly`),e.value}e.hasAttribute(`contenteditable`)&&e.focus();let t=document.createRange();t.selectNodeContents(e);let n=window.getSelection();if(!n)throw Error();return n.removeAllRanges(),n.addRange(t),n.toString()}const Vs=e=>{let{children:t,onClose:n,onConfirm:r}=e,[i]=M({}),a=t?nr(t,{hooks:i}):null;return I(wr,{...e,children:a,onClose:()=>{let e=i.beforeClose;if(e){let t=e();if(t.cancel)return;n==null||n(t);return}n==null||n()},onConfirm:()=>{let e=i.beforeConfirm;if(e){let t=e();if(t.cancel)return;r==null||r(t);return}r==null||r()}})};function Hs(){let e=P(m),[t,n]=M([]);k(()=>{let t=e.confirmOptions$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[]);let r=t.map(e=>{let{children:t,title:n,...r}=e,i=r;for(let t of[`children`,`title`]){let n=t,r=e[n];r&&(i[n]=I(V,{...r}))}return i});return r==null?void 0:r.map((e,t)=>I(Vs,{...e,children:e.children},t))}let Us=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`_confirmOptions`,[]),z(this,`confirmOptions$`,new O([])),this._initUIPart()}open(e){return this._confirmOptions.find(t=>t.id===e.id)?this._confirmOptions=this._confirmOptions.map(t=>({...t.id===e.id?e:t,visible:t.id===e.id?!0:t.visible})):this._confirmOptions.push({...e,visible:!0}),this.confirmOptions$.next(this._confirmOptions),D(()=>{this._confirmOptions=[],this.confirmOptions$.next([])})}confirm(e){return new Promise(t=>{let n=this.open({...e,onConfirm:()=>{n.dispose(),t(!0)},onClose:()=>{n.dispose(),t(!1)}})})}close(e){this._confirmOptions=this._confirmOptions.map(t=>({...t,visible:t.id===e?!1:t.visible})),this.confirmOptions$.next([...this._confirmOptions])}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Hs,this._injector)))}};Us=U([H(0,b(x)),H(1,Z)],Us);const Ws=E(`univer.ui.dialog-service`);function Gs(){let e=P(Ws),[t,n]=M([]);k(()=>{let t=e.getDialogs$().subscribe(e=>{n(e)});return()=>t.unsubscribe()},[]);let r=A(()=>t.map(e=>{let{children:t,title:n,footer:r,...i}=e,a=i;for(let t of[`children`,`title`,`footer`]){let n=t,r=e[n];r&&(a[n]=I(V,{...r}))}return a}),[t]);return r==null?void 0:r.map(e=>I(Tr,{...e},e.id))}let Ks=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`_dialogOptions`,[]),z(this,`_dialogOptions$`,new Te),this._initUIPart()}dispose(){super.dispose(),this._dialogOptions=[],this._dialogOptions$.complete()}open(e){return this._dialogOptions.find(t=>t.id===e.id)?this._dialogOptions=this._dialogOptions.map(t=>({...t.id===e.id?e:t,open:t.id===e.id?!0:t.open})):this._dialogOptions.push({...e,open:!0}),this._dialogOptions$.next(this._dialogOptions),D(()=>{this._dialogOptions=[],this._dialogOptions$.next([])})}close(e){this._dialogOptions=this._dialogOptions.map(t=>({...t,open:t.id===e?!1:t.open})),this._dialogOptions$.next([...this._dialogOptions])}closeAll(e){let t=new Set(e);this._dialogOptions=this._dialogOptions.map(e=>({...e,open:t.has(e.id)?e.open:!1})),this._dialogOptions$.next([...this._dialogOptions])}getDialogs$(){return this._dialogOptions$.asObservable()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Gs,this._injector)))}};Ks=U([H(0,b(x)),H(1,Z)],Ks);const qs=E(`univer.ui.gallery-service`);function Js(){let e=F(P(qs).gallery$);return e?I(Or,{...e}):null}let Ys=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,z(this,`gallery$`,new Te),this._initUIPart()}dispose(){super.dispose()}open(e){return this.gallery$.next({open:!0,...e}),D(()=>{this.gallery$.complete()})}close(){this.gallery$.next({open:!1,images:[]})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(Js,this._injector)))}};Ys=U([H(0,b(x)),H(1,Z)],Ys);let Xs=class{constructor(e){this._componentManager=e,z(this,`visible$`,new Te),z(this,`componentKey$`,new Te),z(this,`_componentKey`,``)}get componentKey(){return this._componentKey}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),this._componentKey=e,D(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};Xs=U([H(0,b(B))],Xs);var Zs=class extends a{openFile(e){return new Promise(t=>{var n,r;let i=document.createElement(`input`);i.type=`file`,i.accept=(n=e==null?void 0:e.accept)==null?``:n,i.multiple=(r=e==null?void 0:e.multiple)==null?!1:r,i.onchange=e=>{let n=e.target.files;n&&t(Array.from(n))},i.click()})}downloadFile(e,t){let n=document.createElement(`a`);n.download=t,n.href=window.URL.createObjectURL(e),n.click()}};const Qs=E(`univer-ui.local-file.service`);var $s=class{getItem(e){return ii.getItem(e)}setItem(e,t){return ii.setItem(e,t)}removeItem(e){return ii.removeItem(e)}clear(){return ii.clear()}key(e){return ii.key(e)}keys(){return ii.keys()}iterate(e){return ii.iterate(e)}};function ec(){return I(Nr,{theme:F(P(oe).darkMode$)?`dark`:`light`})}let tc=0,nc=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(ec,this._injector)))}dispose(){super.dispose(),Gr()}show(e){var t;let n=(t=e.id)==null?`message-${Date.now()}-${tc}`:t;return tc+=1,Wr(Object.assign({},e,{id:n})),D(()=>Gr(n))}remove(e){Gr(e)}removeAll(){Gr()}};nc=U([H(0,b(x)),H(1,Z)],nc);function rc(){return I(Fr,{theme:F(P(oe).darkMode$)?`dark`:`light`})}const ic={show:e=>{let{type:t=`message`,title:n,content:r,duration:i,closable:a=!0,position:o=`top-right`}=e;Yr[t](n,{position:o,description:r,duration:i,closeButton:a})}};let ac=class extends a{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}show(e){return ic.show(e),D(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>N(rc,this._injector)))}};ac=U([H(0,b(x)),H(1,Z)],ac);var oc=class extends a{constructor(...e){super(...e),z(this,`_sidebarOptions`,{}),z(this,`sidebarOptions$`,new Te),z(this,`scrollEvent$`,new Te),z(this,`_container`,void 0),z(this,`_openAnimationFrameId`,null)}get visible(){return this._sidebarOptions.visible||!1}get options(){return this._sidebarOptions}dispose(){super.dispose(),this.close(),this.sidebarOptions$.complete(),this.scrollEvent$.complete()}_clearPendingOpenFrame(){this._openAnimationFrameId!==null&&(cancelAnimationFrame(this._openAnimationFrameId),this._openAnimationFrameId=null)}open(e){return this._sidebarOptions={...e,id:e.id,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),this._clearPendingOpenFrame(),this._openAnimationFrameId=requestAnimationFrame(()=>{this._openAnimationFrameId=null,this._sidebarOptions.onOpen&&this._sidebarOptions.onOpen()}),D(()=>{this.close()})}close(e){var t,n;e&&this._sidebarOptions.id!==e||(this._clearPendingOpenFrame(),this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),(t=(n=this._sidebarOptions).onClose)==null||t.call(n))}getContainer(){return this._container}setContainer(e){this._container=e}};let sc=class{get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}constructor(e){this._componentManager=e,z(this,`visible$`,new O(!1)),z(this,`componentKey$`,new we),z(this,`_temporaryHidden$`,new O(!1)),z(this,`temporaryHidden$`,this._temporaryHidden$.asObservable()),z(this,`_visible`,!1)}dispose(){this.visible$.next(!1),this.visible$.complete(),this.componentKey$.complete()}hide(){this._temporaryHidden$.next(!0)}show(){this._temporaryHidden$.next(!1)}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),D(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this._visible=!0,this.visible$.next(!0)}close(){this._visible=!1,this.visible$.next(!1)}};sc=U([H(0,b(B))],sc);let cc=class extends T{constructor(e=ji,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=_e({popupRootId:`univer-popup-portal-${pe(6)}`},ji,this._config);a.disableAutoFocus&&this._contextService.setContextValue(`DISABLE_AUTO_FOCUS`,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Ai,a)}onStarting(){ye(this._injector,ve([[B],[go],[mi],[ci],[Z,{useClass:Ua}],[Li,{useClass:Ri}],[eo,{useClass:to}],[ha,{useClass:ga}],[pa,{useClass:ma}],[J,{useClass:Na}],[yo,{useClass:bo}],[_o,{useClass:vo}],[As,{useClass:js,lazy:!0}],[fs,{useClass:ac,lazy:!0}],[qs,{useClass:Ys,lazy:!0}],[Ws,{useClass:Ks,lazy:!0}],[m,{useClass:Us,lazy:!0}],[ui,{useClass:oc,lazy:!0}],[Lo,{useClass:sc,lazy:!0}],[Po,{useClass:Xs,lazy:!0}],[na,{useClass:nc,lazy:!0}],[g,{useClass:$s,lazy:!0}],[ps,{useClass:ms}],[Qs,{useClass:Zs}],[qa,{useClass:Ja}],[Mi,{useClass:Pi}],[Wa],[Ko,{useFactory:e=>e.createInstance(ls,this._config),deps:[x]}],[wa],[ra],[Ia]],this._config.override)),Se(this._injector,[[Ko],[ra]])}onReady(){Se(this._injector,[[wa]])}onSteady(){Se(this._injector,[[Ia]])}};z(cc,`pluginName`,`UNIVER_MOBILE_UI_PLUGIN`),z(cc,`packageName`,qo),z(cc,`version`,Jo),cc=U([i(Qr),H(1,h),H(2,b(x)),H(3,p)],cc);const lc=`DISABLE_AUTO_FOCUS`;let uc=class extends T{constructor(e=ji,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=_e({popupRootId:`univer-popup-portal-${pe(6)}`},ji,this._config);a.disableAutoFocus&&this._contextService.setContextValue(lc,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(Ai,a)}onStarting(){ye(this._injector,ve([[B],[go],[mi],[ci],[Z,{useClass:Ua}],[Li,{useClass:Ri}],[eo,{useClass:to}],[ha,{useClass:ga}],[pa,{useClass:ma}],[J,{useClass:Na}],[yo,{useClass:bo}],[_o,{useClass:vo}],[As,{useClass:js,lazy:!0}],[fs,{useClass:ac,lazy:!0}],[qs,{useClass:Ys,lazy:!0}],[Ws,{useClass:Ks,lazy:!0}],[m,{useClass:Us,lazy:!0}],[ui,{useClass:oc,lazy:!0}],[Lo,{useClass:sc,lazy:!0}],[Po,{useClass:Xs,lazy:!0}],[na,{useClass:nc,lazy:!0}],[g,{useClass:$s,lazy:!0}],[ps,{useClass:ms}],[Qs,{useClass:Zs}],[qa,{useClass:Ja}],[Mi,{useClass:Pi}],[Wa],[Ko,{useFactory:e=>e.createInstance(Uo,this._config),deps:[x]}],[wa],[ra],[Ia]],this._config.override)),Se(this._injector,[[Ko],[ra]])}onReady(){Se(this._injector,[[wa]])}onSteady(){Se(this._injector,[[Ia]])}};z(uc,`pluginName`,`UNIVER_UI_PLUGIN`),z(uc,`packageName`,qo),z(uc,`version`,Jo),uc=U([i(Qr),H(1,h),H(2,b(x)),H(3,p)],uc);var dc=class{show(e){return D(()=>{})}remove(e){}removeAll(){}setContainer(){}getContainer(){}};const fc=e=>{let t=P(ui).getContainer();k(()=>{if(t)return t.addEventListener(`mousedown`,e),()=>{t.removeEventListener(`mousedown`,e)}},[e,t])};function pc(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,``)}const mc={strippedSelector:`script, iframe, object, embed`};function hc(e){let t=e.childNodes;if(t.length===0)return e.textContent;if(t[0].nodeName===`DIV`&&(t=t[0].childNodes),t.length===1&&t[0].nodeName===`#text`)return t[0].textContent;let n=[],r=0,i=0,a=e.textContent||``;a+=`\r
130
130
  `;for(let e=0;e<t.length;e++){let a=t[`${e}`],s;if(a.nodeName===`#text`){var o;s=(o=a.textContent)==null?``:o,a=a.parentElement}else s=a.innerText;let c=gc(a);vc(s).forEach(e=>{let t=e.length;i+=t,r=i-t;let a=pe(6);n.push({sId:a,st:r,ed:i-1,ts:c})})}return{id:pe(6),body:{dataStream:a,textRuns:n},documentStyle:{}}}function gc(r,i=``){var a,o;let s=(a=r==null||(o=r.style)==null?void 0:o.cssText)==null?``:a;if(s+=i,s=s.replace(/[\r\n]+/g,``),s.length===0)return{};let c=s.split(`;`),l={},u={t:``,r:``,b:``,l:``};return c.forEach(i=>{let a=i.toLowerCase(),o=pc(a.substr(0,a.indexOf(`:`))),c=pc(a.substr(a.indexOf(`:`)+1));if(o===`font-weight`)c===`bold`||c===`700`?l.bl=1:l.bl=0;else if(o===`font-style`)c===`italic`?l.it=1:l.it=0;else if(o===`font-family`)l.ff=Oc(pc(i));else if(o===`font-size`){let e=Number.parseInt(c);s.indexOf(`vertical-align`)>-1&&(s.indexOf(`sub`)>-1||s.indexOf(`sup`)>-1)&&(e*=2),c.indexOf(`px`)!==-1&&(e=Dc(Number.parseInt(c,10))),l.fs=e}else if(o===`color`){let e=new n(c);l.cl={rgb:e.isValid?e.toRgbString():`rgb(0,0,0)`}}else if(o===`background`||o===`background-color`){let e=new n(c);e.isValid&&(l.bg={rgb:e.toRgbString()})}else if(o===`text-decoration-line`)c===`underline`?(l.ul||(l.ul={s:1}),l.ul.s=1):c===`line-through`?(l.st||(l.st={s:1}),l.st.s=1):c===`overline`&&(l.ol||(l.ol={s:1}),l.ol.s=1);else if(o===`text-decoration-color`)l.hasOwnProperty(`ul`)&&(l.ul||(l.ul={s:1,cl:{rgb:c}}),l.ul.cl={rgb:c}),l.hasOwnProperty(`st`)&&(l.st||(l.st={s:1,cl:{rgb:c}}),l.st.cl={rgb:c}),l.hasOwnProperty(`ol`)&&(l.ol||(l.ol={s:1,cl:{rgb:c}}),l.ol.cl={rgb:c});else if(o===`text-decoration-style`)l.hasOwnProperty(`ul`)&&(l.ul||(l.ul={s:1,t:Number(c)}),l.ul.t=Number(c)),l.hasOwnProperty(`st`)&&(l.st||(l.st={s:1,t:Number(c)}),l.st.t=Number(c)),l.hasOwnProperty(`ol`)&&(l.ol||(l.ol={s:1,t:Number(c)}),l.ol.t=Number(c));else if(o===`text-decoration`||o===`univer-strike`){var d;let e=(d=c.split(` `))==null?void 0:d[0];e===`underline`?(l.ul||(l.ul={s:1}),l.ul.s=1):e===`line-through`?(l.st||(l.st={s:1}),l.st.s=1):e===`overline`&&(l.ol||(l.ol={s:1}),l.ol.s=1)}if(o===`univer-underline`&&(l.ul={s:1}),o===`vertical-align`&&(c===`sub`?l.va=e.SUBSCRIPT:c===`super`?l.va=e.SUPERSCRIPT:c===`top`?l.vt=1:c===`middle`?l.vt=2:c===`bottom`?l.vt=3:l.va=e.NORMAL),o===`transform`){let e=c.split(`)`),t=e.findIndex(e=>e.includes(`rotate`));if(t>-1){let n=e[t].match(/\d+/g),i=0,a=0;n!=null&&n.length&&(i=+n[0]),r!=null&&r.dataset.vertical&&(a=+r.dataset.vertical),l.tr={a:i,v:a}}}if(o===`text-align`&&(c===`left`?l.ht=1:c===`center`?l.ht=2:c===`right`?l.ht=3:c===`justify`?l.ht=4:l.ht=0),l.tb!==1&&(o===`overflow-wrap`||o===`word-wrap`?c===`break-word`&&(l.tb=3):o===`text-overflow`?c===`clip`&&(l.tb=2):o===`text-break`&&c===`overflow`&&(l.tb=1)),o===`white-space`&&(c===`nowrap`?l.tb=1:c===`normal`?l.tb=3:c===`clip`&&(l.tb=2)),o===`border-color`){let e=_c(c,`)`);if(l.bd)for(let t in e)l.bd[t].cl.rgb=e[t];else{l.bd={b:{cl:{rgb:`#000`},s:0},t:{cl:{rgb:`#000`},s:0},l:{cl:{rgb:`#000`},s:0},r:{cl:{rgb:`#000`},s:0}};for(let t in e)l.bd[t].cl.rgb=e[t]}}if(o===`border-width`||o===`border-style`){let e=_c(c,` `);for(let t in e)u[t]+=` ${e[t]}`;l.bd?(l.bd.b.s=me(u.b),l.bd.t.s=me(u.t),l.bd.l.s=me(u.l),l.bd.r.s=me(u.r)):l.bd={b:{cl:{rgb:`#000`},s:me(u.b)},t:{cl:{rgb:`#000`},s:me(u.t)},l:{cl:{rgb:`#000`},s:me(u.l)},r:{cl:{rgb:`#000`},s:me(u.r)}}}if(o===`border-bottom`||o===`border-top`||o===`border-left`||o===`border-right`||o===`border`){l.bd||(l.bd={});let e=c.split(` `),n=`${e[0]} ${e[1]}`;e.splice(0,2);let r=e.join(``);if(me(n)!==t.NONE&&r){let e={cl:{rgb:r},s:me(n)};o===`border-bottom`?l.bd.b=c===`none`?null:e:o===`border-top`?l.bd.t=c===`none`?null:e:o===`border-left`?l.bd.l=c===`none`?null:e:o===`border-right`?l.bd.r=c===`none`?null:e:o===`border`&&(l.bd={r:c===`none`?null:e,t:c===`none`?null:e,b:c===`none`?null:e,l:c===`none`?null:e})}}else if(o===`--data-rotate`){let e=c.match(/[+-]?\d+/);c===`(0deg ,1)`?l.tr={a:0,v:1}:e&&(l.tr={a:Number(e[0])})}}),Object.keys(l).forEach(e=>{typeof l[e]==`object`&&!Object.keys(l[e]).length&&delete l[e]}),l}function _c(e,t){let n;n=t===` `?e.trim().split(t):e.trim().split(t).slice(0,-1),n.forEach(e=>`${e.trim()})`);let r={};return n.length===1?r={t:n[0],r:n[0],b:n[0],l:n[0]}:n.length===2?r={t:n[0],r:n[1],b:n[0],l:n[1]}:n.length===3?r={t:n[0],r:n[1],b:n[2],l:n[1]}:n.length===4&&(r={t:n[0],r:n[1],b:n[2],l:n[3]}),r}function vc(e){return e===``?[e]:e.match(/(?:(\n+.+)|(.+))/g).map(e=>e.replace(/\n/g,`\r
131
131
  `))}function yc(e){let t=gs(e,mc),n=[],r=t.querySelectorAll(`table col`);if(!r.length)return[];for(let e=0;e<r.length;e++){let t=r[e],i=t.getAttribute(`span`);if(i&&+i>1)for(let e=0;e<+i;e++){let e=bc(t.getAttribute(`width`),72);n.push(e)}else{let e=bc(t.getAttribute(`width`),72);n.push(e)}}return n}function bc(e,t){if(!e)return t;let n;return n=e.includes(`pt`)?$r(Number.parseFloat(e)):e.includes(`px`)?Number.parseFloat(e):Number.parseFloat(e)*72/96,n}function xc(e){let t=gs(e,mc),n=[],r=t.querySelectorAll(`table tr`);if(!r.length)return[];for(let e=0;e<r.length;e++){let t=r[e].querySelectorAll(`td`),i=bc(t[0].style.height,19);for(let e=0;e<t.length;e++){let n=t[e].getAttribute(`rowSpan`);if(!(n&&+n>1)){i=bc(t[e].style.height,19);break}}n.push(i)}return n}function Sc(e){let t=[],n=gs(e,mc);if(t=Array(n.querySelectorAll(`table tr`).length),!t.length)return[];let r=0,i=n.querySelectorAll(`table tr`);i[0].querySelectorAll(`td`).forEach(e=>{let t=0,n=e.getAttribute(`colSpan`);t=n===null?1:+n,r+=t});for(let e=0;e<t.length;e++)t[e]=Array(r);let a=0;return i.forEach(e=>{let n=0;e.querySelectorAll(`td`).forEach(e=>{let i={};if(e.querySelectorAll(`span`).length||e.querySelectorAll(`font`).length){let t=hc(e);typeof t!=`string`&&(i.p=t)}let o=e.innerText;o.trim().length===0?i.v=``:i.v=o;let s=gc(e);for(se.isPlainObject(s)&&(i.s=s);n<r&&t[a][n]!=null;)n++;if(n!==r){if(t[a][n]==null){var c,l;t[a][n]=i;let r=(c=Number(e.getAttribute(`rowSpan`)))==null?1:c,o=(l=Number(e.getAttribute(`colSpan`)))==null?1:l;if(r>1||o>1){let e={rs:r-1,cs:o-1,r:a,c:n};t[a][n].mc=e;for(let e=0;e<r;e++)for(let r=0;r<o;r++)e===0&&r===0||(t[a+e][n+r]={mc:null})}}n++}}),a++}),t}function Cc(e){let t=[],n=e.replace(/\r/g,``).split(`
132
132
  `),r=n[0].split(` `).length;for(let e=0;e<n.length;e++)n[e].split(` `).length<r||t.push(n[e].split(` `));for(let e=0;e<t.length;e++)for(let n=0;n<t[e].length;n++)t[e][n].length?t[e][n]={v:t[e][n]||``,m:t[e][n]||``}:t[e][n]=null;return t}function wc(e,t){let n=e.length,r=e[0].length,i=0;i+n-1;let a=0;a+r-1,t&&(i=t.startRow,i+n-1,a=t.startColumn,a+r-1);let o=[];for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)if(e[t][n]&&typeof e[t][n]==`object`&&`mc`in e[t][n])if(e[t][n].mc){let r=e[t][n].mc,s=r.r+i,c=s+r.rs,l=r.c+a,u=l+r.cs;o.push({startRow:s,endRow:c,startColumn:l,endColumn:u}),delete e[t][n].mc}else e[t][n]=null;return{data:e,mergeData:o}}function Tc(e){var t;let n=[],r=_s(e,mc),i=(t=r.querySelector(`style`))==null?void 0:t.innerText;if(!i)return;let a=Ec(i);if(n=Array(r.querySelectorAll(`table tr`).length),!n.length)return[];let o=0,s=r.querySelectorAll(`table tr`);s[0].querySelectorAll(`td`).forEach(e=>{let t=0,n=e.getAttribute(`colSpan`);t=n===null?1:+n,o+=t});for(let e=0;e<n.length;e++)n[e]=Array(o);let c=0;return s.forEach(e=>{let t=0;e.querySelectorAll(`td`).forEach(e=>{let r={};if(e.querySelectorAll(`span`).length||e.querySelectorAll(`font`).length){let t=hc(e);typeof t!=`string`&&(r.p=t)}let i=e.innerText;i.trim().length===0?r.v=``:r.v=i;let s=``;for(let t in a)e.classList.contains(t)&&(s+=a[t]);let l=gc(e,s);for(se.isPlainObject(l)&&(r.s=l);t<o&&n[c][t]!=null;)t++;if(t!==o){if(n[c][t]==null){var u,d;n[c][t]=r;let i=(u=Number(e.getAttribute(`rowSpan`)))==null?1:u,a=(d=Number(e.getAttribute(`colSpan`)))==null?1:d;if(i>1||a>1){let e={rs:i-1,cs:a-1,r:c,c:t};n[c][t].mc=e;for(let e=0;e<i;e++)for(let r=0;r<a;r++)e===0&&r===0||(n[c+e][t+r]={mc:null})}}t++}}),c++}),n}function Ec(e){let t={},n=e.replaceAll(`<!--`,``).replaceAll(`-->`,``).trim(),r=n==null?void 0:n.replaceAll(` `,``).replaceAll(`
133
- `,``).split(`}`);for(let e=0;e<r.length;e++){if(!r[e])continue;let n=r[e].split(`{`)[0].trim();n.includes(`.`)&&(n=n.slice(1)),t[n]=r[e].split(`{`)[1].trim()}return t}function Dc(e){let t=Math.round(e*.75);return t<9?9:t>78?78:t}function Oc(e){let t=e.match(/font-family:\s*(?:"([^"]+)"|'([^']+)'|([^;]+))/i);return t?(t[1]||t[2]||t[3]).trim():null}const kc=or(e=>{var t,n;let{layer:r,id:i,position:a}=e,o=gr(y),s=j(null),c=j(null),l=j(`transform: rotate(${a==null?void 0:a.rotate}deg) translate(${a==null?void 0:a.startX}px, ${a==null?void 0:a.startY}px)`),u=j((t=a==null?void 0:a.startY)==null?0:t),d=j((n=a==null?void 0:a.startX)==null?0:n),f=typeof r.componentKey==`string`?gr(B).get(r.componentKey):r.componentKey,p=A(()=>({data:r.data,...r.props}),[r.data,r.props]),m={width:`${a.width-4}px`,height:`${a.height-4}px`,left:`${a.absolute.left?0:`auto`}`,top:`${a.absolute.top?0:`auto`}`,right:`${a.absolute.left?`auto`:0}`,bottom:`${a.absolute.top?`auto`:0}`};l.current=`rotate(${a.rotate}deg)`,u.current=a.startY,d.current=a.startX;let h=o.getUnit(r.unitId),g=A(()=>f?I(f,{...p,unitId:r.unitId,unit:h,floatDomId:r.id,context:{root:c}}):null,[f,p]);return a?I(`div`,{ref:s,className:`univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden`,style:{top:u.current,left:d.current,width:Math.max(a.endX-a.startX-2,0),height:Math.max(a.endY-a.startY-2,0),transform:l.current},onPointerMove:e=>{r.onPointerMove(e.nativeEvent)},onPointerDown:e=>{r.onPointerDown(e.nativeEvent)},onPointerUp:e=>{r.onPointerUp(e.nativeEvent)},onWheel:e=>{r.onWheel(e.nativeEvent)},children:I(`div`,{ref:c,id:i,className:`univer-absolute univer-overflow-hidden`,style:{...m},children:g})}):null});export{Mo as AnchoredContextMenu,js as BrowserClipboardService,X as BuiltInUIPart,ki as COLOR_PICKER_COMPONENT,Si as COMMON_LABEL_COMPONENT,Wa as CanvasFloatDomService,$a as CanvasPopup,Ja as CanvasPopupService,xi as CommonLabel,Q as ComponentContainer,B as ComponentManager,No as ContextMenu,q as ContextMenuGroup,bo as ContextMenuHostService,Oo as ContextMenuPanel,Ma as ContextMenuPosition,vo as ContextMenuService,ta as CopyCommand,ya as CopyShortcutItem,V as CustomLabel,ra as CutCommand,ba as CutShortcutItem,lc as DISABLE_AUTO_FOCUS_KEY,ms as DesktopBeforeCloseService,Us as DesktopConfirmService,Ks as DesktopDialogService,Ys as DesktopGalleryService,Xs as DesktopGlobalZoneService,da as DesktopLayoutService,Zs as DesktopLocalFileService,$s as DesktopLocalStorageService,nc as DesktopMessageService,ac as DesktopNotificationService,to as DesktopRibbonService,oc as DesktopSidebarService,Uo as DesktopUIController,sc as DesktopZenZoneService,$i as ErrorController,xs as FILE_PNG_CLIPBOARD_MIME_TYPE,Ts as FILE_SVG_XML_CLIPBOARD_MIME_TYPE,Cs as FILE__BMP_CLIPBOARD_MIME_TYPE,Ss as FILE__JPEG_CLIPBOARD_MIME_TYPE,ws as FILE__WEBP_CLIPBOARD_MIME_TYPE,Li as FONT_FAMILY_COMPONENT,Ri as FONT_FAMILY_ITEM_COMPONENT,Hi as FONT_SIZE_COMPONENT,Bi as FONT_SIZE_LIST,Ka as FloatDom,Ga as FloatDomSingle,Fi as FontFamily,Ii as FontFamilyItem,zi as FontSize,Fo as GlobalZone,wi as HEADING_ITEM_COMPONENT,Vi as HEADING_LIST,bs as HTML_CLIPBOARD_MIME_TYPE,Ci as HeadingItem,ps as IBeforeCloseService,qa as ICanvasPopupService,As as IClipboardInterfaceService,yo as IContextMenuHostService,_o as IContextMenuService,Ws as IDialogService,Mi as IFontService,qs as IGalleryService,Po as IGlobalZoneService,ua as ILayoutService,li as ILeftSidebarService,Qs as ILocalFileService,J as IMenuManagerService,Qi as IMessageService,fs as INotificationService,pa as IPlatformService,eo as IRibbonService,ha as IShortcutService,ui as ISidebarService,Ko as IUIController,Z as IUIPartsService,Lo as IZenZoneService,W as KeyCode,Y as MenuItemType,Ta as MenuManagerPosition,Na as MenuManagerService,G as MetaKeys,ss as MobileContextMenu,dc as MockMessageService,ys as PLAIN_TEXT_CLIPBOARD_MIME_TYPE,aa as PasteCommand,ma as PlatformService,kc as PrintFloatDomSingle,Xi as ProgressBar,Za as RectPopup,dr as RediConsumer,fr as RediContext,pr as RediProvider,Ca as RedoShortcutItem,ho as Ribbon,ka as RibbonDataGroup,Oa as RibbonFormulasGroup,Da as RibbonInsertGroup,ja as RibbonOthersGroup,K as RibbonPosition,Ea as RibbonStartGroup,Aa as RibbonViewGroup,wa as SharedController,oa as SheetPasteShortKeyCommandName,Ia as ShortcutPanelController,ci as ShortcutPanelService,ga as ShortcutService,Io as Sidebar,Qa as SingleCanvasPopup,Ho as SingleUnitUIController,Oi as Slider,go as ThemeSwitcherService,fi as ToggleShortcutPanelOperation,oo as ToolbarButton,mo as ToolbarItem,Ha as UIMenuSchema,Ua as UIPartsService,Ai as UI_PLUGIN_CONFIG_KEY,Zi as UNI_DISABLE_CHANGING_FOCUS_KEY,Sa as UndoShortcutItem,cc as UniverMobileUIPlugin,uc as UniverUIPlugin,mr as WithDependency,mi as ZIndexManager,Ro as ZenZone,hr as connectDependencies,N as connectInjector,gi as getHeaderFooterMenuHiddenObservable,hi as getMenuHiddenObservable,Tc as handelExcelToJson,Sc as handelTableToJson,hc as handleDomToJson,Cc as handlePlainToJson,gc as handleStringToStyle,yc as handleTableColgroup,wc as handleTableMergeData,xc as handleTableRowGroup,Es as imageMimeTypeSet,_i as mergeMenuConfigs,_s as parseHtmlDocument,gs as parseHtmlFragment,hs as sanitizeParsedHtml,vc as splitSpanText,vs as supportClipboardAPI,Yi as t,pc as textTrim,Wi as useClickOutSide,$ as useComponentsOfPart,Di as useConfigValue,Gi as useDebounceFn,P as useDependency,Ti as useEvent,_r as useInjector,F as useObservable,bi as useObservableRef,Ei as useScrollYOverContainer,fc as useSidebarClick,so as useToolbarItemStatus,vr as useUpdateBinder,Ui as useUpdateEffect,Ji as useVirtualList};
133
+ `,``).split(`}`);for(let e=0;e<r.length;e++){if(!r[e])continue;let n=r[e].split(`{`)[0].trim();n.includes(`.`)&&(n=n.slice(1)),t[n]=r[e].split(`{`)[1].trim()}return t}function Dc(e){let t=Math.round(e*.75);return t<9?9:t>78?78:t}function Oc(e){let t=e.match(/font-family:\s*(?:"([^"]+)"|'([^']+)'|([^;]+))/i);return t?(t[1]||t[2]||t[3]).trim():null}const kc=or(e=>{var t,n;let{layer:r,id:i,position:a}=e,o=gr(y),s=j(null),c=j(null),l=j(`transform: rotate(${a==null?void 0:a.rotate}deg) translate(${a==null?void 0:a.startX}px, ${a==null?void 0:a.startY}px)`),u=j((t=a==null?void 0:a.startY)==null?0:t),d=j((n=a==null?void 0:a.startX)==null?0:n),f=typeof r.componentKey==`string`?gr(B).get(r.componentKey):r.componentKey,p=A(()=>({data:r.data,...r.props}),[r.data,r.props]),m={width:`${a.width-4}px`,height:`${a.height-4}px`,left:`${a.absolute.left?0:`auto`}`,top:`${a.absolute.top?0:`auto`}`,right:`${a.absolute.left?`auto`:0}`,bottom:`${a.absolute.top?`auto`:0}`};l.current=`rotate(${a.rotate}deg)`,u.current=a.startY,d.current=a.startX;let h=o.getUnit(r.unitId),g=A(()=>f?I(f,{...p,unitId:r.unitId,unit:h,floatDomId:r.id,context:{root:c}}):null,[f,p]);return a?I(`div`,{ref:s,className:`univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden`,style:{top:u.current,left:d.current,width:Math.max(a.endX-a.startX-2,0),height:Math.max(a.endY-a.startY-2,0),transform:l.current},onPointerMove:e=>{r.onPointerMove(e.nativeEvent)},onPointerDown:e=>{r.onPointerDown(e.nativeEvent)},onPointerUp:e=>{r.onPointerUp(e.nativeEvent)},onWheel:e=>{r.onWheel(e.nativeEvent)},children:I(`div`,{ref:c,id:i,className:`univer-absolute univer-overflow-hidden`,style:{...m},children:g})}):null});export{Mo as AnchoredContextMenu,js as BrowserClipboardService,X as BuiltInUIPart,ki as COLOR_PICKER_COMPONENT,Si as COMMON_LABEL_COMPONENT,Wa as CanvasFloatDomService,$a as CanvasPopup,Ja as CanvasPopupService,xi as CommonLabel,Q as ComponentContainer,B as ComponentManager,No as ContextMenu,q as ContextMenuGroup,bo as ContextMenuHostService,Oo as ContextMenuPanel,Ma as ContextMenuPosition,vo as ContextMenuService,aa as CopyCommand,ya as CopyShortcutItem,V as CustomLabel,sa as CutCommand,ba as CutShortcutItem,lc as DISABLE_AUTO_FOCUS_KEY,ms as DesktopBeforeCloseService,Us as DesktopConfirmService,Ks as DesktopDialogService,Ys as DesktopGalleryService,Xs as DesktopGlobalZoneService,Ri as DesktopLayoutService,Zs as DesktopLocalFileService,$s as DesktopLocalStorageService,nc as DesktopMessageService,ac as DesktopNotificationService,to as DesktopRibbonService,oc as DesktopSidebarService,Uo as DesktopUIController,sc as DesktopZenZoneService,ra as ErrorController,xs as FILE_PNG_CLIPBOARD_MIME_TYPE,Ts as FILE_SVG_XML_CLIPBOARD_MIME_TYPE,Cs as FILE__BMP_CLIPBOARD_MIME_TYPE,Ss as FILE__JPEG_CLIPBOARD_MIME_TYPE,ws as FILE__WEBP_CLIPBOARD_MIME_TYPE,Vi as FONT_FAMILY_COMPONENT,Hi as FONT_FAMILY_ITEM_COMPONENT,Ki as FONT_SIZE_COMPONENT,Wi as FONT_SIZE_LIST,Ka as FloatDom,Ga as FloatDomSingle,Fi as FontFamily,Bi as FontFamilyItem,Ui as FontSize,Fo as GlobalZone,wi as HEADING_ITEM_COMPONENT,Gi as HEADING_LIST,bs as HTML_CLIPBOARD_MIME_TYPE,Ci as HeadingItem,ps as IBeforeCloseService,qa as ICanvasPopupService,As as IClipboardInterfaceService,yo as IContextMenuHostService,_o as IContextMenuService,Ws as IDialogService,Mi as IFontService,qs as IGalleryService,Po as IGlobalZoneService,Li as ILayoutService,li as ILeftSidebarService,Qs as ILocalFileService,J as IMenuManagerService,na as IMessageService,fs as INotificationService,pa as IPlatformService,eo as IRibbonService,ha as IShortcutService,ui as ISidebarService,Ko as IUIController,Z as IUIPartsService,Lo as IZenZoneService,W as KeyCode,Y as MenuItemType,Ta as MenuManagerPosition,Na as MenuManagerService,G as MetaKeys,ss as MobileContextMenu,dc as MockMessageService,ys as PLAIN_TEXT_CLIPBOARD_MIME_TYPE,la as PasteCommand,ma as PlatformService,kc as PrintFloatDomSingle,ea as ProgressBar,Za as RectPopup,dr as RediConsumer,fr as RediContext,pr as RediProvider,Ca as RedoShortcutItem,ho as Ribbon,ka as RibbonDataGroup,Oa as RibbonFormulasGroup,Da as RibbonInsertGroup,ja as RibbonOthersGroup,K as RibbonPosition,Ea as RibbonStartGroup,Aa as RibbonViewGroup,wa as SharedController,ua as SheetPasteShortKeyCommandName,Ia as ShortcutPanelController,ci as ShortcutPanelService,ga as ShortcutService,Io as Sidebar,Qa as SingleCanvasPopup,Ho as SingleUnitUIController,Oi as Slider,go as ThemeSwitcherService,fi as ToggleShortcutPanelOperation,oo as ToolbarButton,mo as ToolbarItem,Ha as UIMenuSchema,Ua as UIPartsService,Ai as UI_PLUGIN_CONFIG_KEY,ta as UNI_DISABLE_CHANGING_FOCUS_KEY,Sa as UndoShortcutItem,cc as UniverMobileUIPlugin,uc as UniverUIPlugin,mr as WithDependency,mi as ZIndexManager,Ro as ZenZone,hr as connectDependencies,N as connectInjector,gi as getHeaderFooterMenuHiddenObservable,hi as getMenuHiddenObservable,Tc as handelExcelToJson,Sc as handelTableToJson,hc as handleDomToJson,Cc as handlePlainToJson,gc as handleStringToStyle,yc as handleTableColgroup,wc as handleTableMergeData,xc as handleTableRowGroup,Es as imageMimeTypeSet,_i as mergeMenuConfigs,_s as parseHtmlDocument,gs as parseHtmlFragment,hs as sanitizeParsedHtml,vc as splitSpanText,vs as supportClipboardAPI,$i as t,pc as textTrim,Ji as useClickOutSide,$ as useComponentsOfPart,Di as useConfigValue,Yi as useDebounceFn,P as useDependency,Ti as useEvent,_r as useInjector,F as useObservable,bi as useObservableRef,Ei as useScrollYOverContainer,fc as useSidebarClick,so as useToolbarItemStatus,vr as useUpdateBinder,qi as useUpdateEffect,Qi as useVirtualList};