@univerjs/ui 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +19 -295
- package/lib/es/index.js +19 -295
- package/lib/index.js +19 -295
- package/lib/types/utils/html.d.ts +21 -0
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/umd/index.js +21 -297
- package/package.json +8 -8
package/lib/cjs/index.js
CHANGED
|
@@ -1,62 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@univerjs/core`),l=require(`rxjs`),u=require(`@univerjs/icons`),d=require(`react`);d=s(d);let f=require(`@wendellhu/redi/react-bindings`),p=require(`react/jsx-runtime`),m=require(`@univerjs/design`),h=require(`@univerjs/engine-render`),g=require(`rxjs/operators`),_=require(`react-dom`),v=require(`localforage`);v=s(v);function y(e){"@babel/helpers - typeof";return y=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},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C=class extends c.Disposable{constructor(...e){super(...e),S(this,`_open$`,new l.BehaviorSubject(!1)),S(this,`open$`,this._open$.pipe((0,l.distinctUntilChanged)()))}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 w=(0,c.createIdentifier)(`ui.left-sidebar.service`),T=(0,c.createIdentifier)(`ui.sidebar.service`),E=`ShortcutPanel`,D={id:`base-ui.operation.toggle-shortcut-panel`,type:c.CommandType.OPERATION,handler:e=>{let t=e.get(C),n=e.get(T);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:`shortcut-panel.title`},children:{label:E}})),!0}},O={AddDigitsIcon:u.AddDigitsIcon,AddImageIcon:u.AddImageIcon,AdditionAndSubtractionIcon:u.AdditionAndSubtractionIcon,AdjustHeightDoubleIcon:u.AdjustHeightDoubleIcon,AdjustWidthDoubleIcon:u.AdjustWidthDoubleIcon,AlignBottomIcon:u.AlignBottomIcon,AlignTextBothIcon:u.AlignTextBothIcon,AlignTopIcon:u.AlignTopIcon,AllBorderIcon:u.AllBorderIcon,AmplifyIcon:u.AmplifyIcon,AutoHeightDoubleIcon:u.AutoHeightDoubleIcon,AutoWidthDoubleIcon:u.AutoWidthDoubleIcon,AutowrapIcon:u.AutowrapIcon,AvgIcon:u.AvgIcon,BackSlashDoubleIcon:u.BackSlashDoubleIcon,BoldIcon:u.BoldIcon,BrushIcon:u.BrushIcon,CancelFreezeIcon:u.CancelFreezeIcon,CancelMergeIcon:u.CancelMergeIcon,ClearFormatDoubleIcon:u.ClearFormatDoubleIcon,CntIcon:u.CntIcon,CodeIcon:u.CodeIcon,ConditionsDoubleIcon:u.ConditionsDoubleIcon,CopyDoubleIcon:u.CopyDoubleIcon,CutIcon:u.CutIcon,DeleteCellMoveDownDoubleIcon:u.DeleteCellMoveDownDoubleIcon,DeleteCellShiftLeftDoubleIcon:u.DeleteCellShiftLeftDoubleIcon,DeleteCellShiftRightDoubleIcon:u.DeleteCellShiftRightDoubleIcon,DeleteCellShiftUpDoubleIcon:u.DeleteCellShiftUpDoubleIcon,DeleteColumnDoubleIcon:u.DeleteColumnDoubleIcon,DeleteRowDoubleIcon:u.DeleteRowDoubleIcon,DirectExportIcon:u.DirectExportIcon,DollarIcon:u.DollarIcon,DownBorderDoubleIcon:u.DownBorderDoubleIcon,DownloadImageIcon:u.DownloadImageIcon,EuroIcon:u.EuroIcon,ExportIcon:u.ExportIcon,EyeOutlineIcon:u.EyeOutlineIcon,FolderIcon:u.FolderIcon,FontColorDoubleIcon:u.FontColorDoubleIcon,FontSizeIncreaseIcon:u.FontSizeIncreaseIcon,FontSizeReduceIcon:u.FontSizeReduceIcon,FreezeColumnIcon:u.FreezeColumnIcon,FreezeRowIcon:u.FreezeRowIcon,FreezeToSelectedIcon:u.FreezeToSelectedIcon,FunctionIcon:u.FunctionIcon,GridIcon:u.GridIcon,HeaderFooterIcon:u.HeaderFooterIcon,HideDoubleIcon:u.HideDoubleIcon,HorizontalBorderDoubleIcon:u.HorizontalBorderDoubleIcon,HorizontallyIcon:u.HorizontallyIcon,HorizontalMergeIcon:u.HorizontalMergeIcon,IncreaseIcon:u.IncreaseIcon,InnerBorderDoubleIcon:u.InnerBorderDoubleIcon,InsertCellDownDoubleIcon:u.InsertCellDownDoubleIcon,InsertCellShiftRightDoubleIcon:u.InsertCellShiftRightDoubleIcon,InsertDoubleIcon:u.InsertDoubleIcon,InsertRowAboveDoubleIcon:u.InsertRowAboveDoubleIcon,InsertRowBelowDoubleIcon:u.InsertRowBelowDoubleIcon,ItalicIcon:u.ItalicIcon,KeyboardIcon:u.KeyboardIcon,LeftBorderDoubleIcon:u.LeftBorderDoubleIcon,LeftDoubleDiagonalDoubleIcon:u.LeftDoubleDiagonalDoubleIcon,LeftInsertColumnDoubleIcon:u.LeftInsertColumnDoubleIcon,LeftJustifyingIcon:u.LeftJustifyingIcon,LeftRotationFortyFiveDegreesIcon:u.LeftRotationFortyFiveDegreesIcon,LeftRotationNinetyDegreesIcon:u.LeftRotationNinetyDegreesIcon,LeftTridiagonalDoubleIcon:u.LeftTridiagonalDoubleIcon,MaxIcon:u.MaxIcon,MenuIcon:u.MenuIcon,MergeAllIcon:u.MergeAllIcon,MinIcon:u.MinIcon,MoreDownIcon:u.MoreDownIcon,NoBorderIcon:u.NoBorderIcon,NoColorDoubleIcon:u.NoColorDoubleIcon,NoRotationIcon:u.NoRotationIcon,OrderIcon:u.OrderIcon,OuterBorderDoubleIcon:u.OuterBorderDoubleIcon,OverflowIcon:u.OverflowIcon,PaintBucketDoubleIcon:u.PaintBucketDoubleIcon,PasteSpecialDoubleIcon:u.PasteSpecialDoubleIcon,PercentIcon:u.PercentIcon,PipingIcon:u.PipingIcon,RedoIcon:u.RedoIcon,ReduceDigitsIcon:u.ReduceDigitsIcon,ReduceDoubleIcon:u.ReduceDoubleIcon,ReduceIcon:u.ReduceIcon,RightBorderDoubleIcon:u.RightBorderDoubleIcon,RightDoubleDiagonalDoubleIcon:u.RightDoubleDiagonalDoubleIcon,RightInsertColumnDoubleIcon:u.RightInsertColumnDoubleIcon,RightJustifyingIcon:u.RightJustifyingIcon,RightRotationFortyFiveDegreesIcon:u.RightRotationFortyFiveDegreesIcon,RightRotationNinetyDegreesIcon:u.RightRotationNinetyDegreesIcon,RmbIcon:u.RmbIcon,RoubleIcon:u.RoubleIcon,ShortcutIcon:u.ShortcutIcon,SlashDoubleIcon:u.SlashDoubleIcon,StrikethroughIcon:u.StrikethroughIcon,SubscriptIcon:u.SubscriptIcon,SumIcon:u.SumIcon,SuperscriptIcon:u.SuperscriptIcon,TruncationIcon:u.TruncationIcon,UnderlineIcon:u.UnderlineIcon,UndoIcon:u.UndoIcon,UnorderIcon:u.UnorderIcon,UpBorderDoubleIcon:u.UpBorderDoubleIcon,VerticalBorderDoubleIcon:u.VerticalBorderDoubleIcon,VerticalCenterIcon:u.VerticalCenterIcon,VerticalIntegrationIcon:u.VerticalIntegrationIcon,VerticalTextIcon:u.VerticalTextIcon};var k=class extends c.Disposable{constructor(){super(),S(this,`_components`,new Map),S(this,`_componentsReverse`,new Map),S(this,`reactUtils`,{createElement:d.createElement,useEffect:d.useEffect,useRef:d.useRef}),S(this,`_handler`,{react:e=>e});for(let e in O)this.register(e,O[e]);this.disposeWithMe((0,c.toDisposable)(()=>{for(let e in O)this._components.delete(e),this._componentsReverse.delete(O[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),(0,c.toDisposable)(()=>{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)}},A=class{constructor(){S(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 j(e,t,n,r){let i=e.get(c.IUniverInstanceService);return new l.Observable(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 M(e){let t=e.get(c.IUniverInstanceService);return new l.Observable(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!==c.DocumentFlavor.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!==c.DocumentFlavor.TRADITIONAL),()=>n.unsubscribe()})}function N(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=>{ee(e,`${n}$`,t[n])}),e)}function ee(e,t,n){n!==void 0&&(e[t]?e[t]=e[t].pipe((0,l.switchMap)(()=>new l.BehaviorSubject(n))):e[t]=new l.Observable(e=>{e.next(n)}))}function te(e){return typeof e==`function`?e():e}function P(e,t){let n=(0,d.useRef)(t);return(0,d.useEffect)(()=>{if(e){let t=te(e).subscribe(e=>{n.current=e});return()=>t.unsubscribe()}},[e]),n}const F=e=>{let{value:t,selections:n}=e,r=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`div`,{className:`univer-truncate univer-text-sm`,children:(0,d.useMemo)(()=>{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])})},ne=`UI_PLUGIN_COMMON_LABEL_COMPONENT`;function I(e){let{className:t,title:n,icon:r,label:i,value:a,value$:o}=e,s=(0,f.useDependency)(c.LocaleService),u=(0,f.useDependency)(k),[m,h]=(0,d.useState)(a),[g,_]=(0,d.useState)(``),v=[],y=0;(0,d.useEffect)(()=>{if(o){let e=o.subscribe(e=>{h(e)});return()=>{e.unsubscribe()}}},[o]);let b=(0,d.useMemo)(()=>a==null?m:a,[m,a]);(0,d.useEffect)(()=>{let e=null;return(0,l.isObservable)(r)?e=r.subscribe(e=>{_(e)}):_(r==null?``:r),()=>{e==null||e.unsubscribe()}},[r]);let x=(0,d.useMemo)(()=>b&&typeof b==`string`?new c.ColorKit(b).isValid:!1,[b]);if(r){let e=u.get(g==null?``:g);e&&v.push((0,p.jsx)(e,{className:`univer-text-base`,extend:{colorChannel1:x?b:`var(--univer-primary-600)`}},y++))}if(i){let n=typeof i==`string`,r=n?{...e}:{...i==null?void 0:i.props,...e},a=n?i:i==null?void 0:i.name,o=u.get(a);o?v.push((0,p.jsx)(o,{...r,className:t,value:b},y++)):v.push((0,p.jsx)(`span`,{className:t,children:s.t(a)},y++))}return n&&v.push((0,p.jsx)(`span`,{className:t,children:typeof n==`string`?s.t(n):n},y++)),(0,p.jsx)(p.Fragment,{children:v})}const re=e=>{var t,n;let{value:r,text:i}=e,a=c.NAMED_STYLE_MAP[r],o=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`span`,{className:(0,m.clsx)(`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)})},ie=`UI_COMPONENT_HEADING_ITEM`;function L(e){let t=(0,d.useRef)(e);return t.current=e,(0,d.useCallback)(((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}function ae(e,t){let n=L(()=>{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`)});(0,d.useEffect)(()=>{if(!(0,m.isBrowser)()||!e||!t)return;n();let r=(0,m.resizeObserverCtor)(n);return r.observe(e),()=>{r.unobserve(e)}},[e,t])}function oe(e){let t=(0,f.useDependency)(c.IConfigService);return(0,f.useObservable)((0,d.useMemo)(()=>t.subscribeConfigValue$(e),[t]),t.getConfig(e))}function se(e){(0,f.useDependency)(c.LocaleService);let t=(0,f.useDependency)(k),{value:n,min:r=0,max:i=400,disabled:a=!1,resetPoint:o=100,shortcuts:s,onChange:l}=e,u=(0,d.useRef)(null),[h,g]=(0,d.useState)(!1);function _(){a||l&&l(o)}function v(e){if(a)return;let t=n+e;n+e<=r?t=r:n+e>=i&&(t=i),l&&l(t)}let y=(0,d.useMemo)(()=>{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 b(e){if(a)return;e.preventDefault();let t=u.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,l&&l(Math.ceil(s))}}function c(){n=!1,document.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c)}function d(e){e.relatedTarget===null&&c()}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointerout`,d)}function x(e){a||(g(!1),l&&l(e))}let S=[{type:`radio`,value:n.toString(),options:s.map(e=>({value:e.toString(),label:`${e}%`})),onSelect:e=>x(+e)}],C=t.get(`ReduceIcon`),w=t.get(`IncreaseIcon`);return(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-flex univer-select-none univer-items-center univer-gap-1`,{"univer-cursor-not-allowed":a}),children:[(0,p.jsx)(m.Button,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n<=r||a,onClick:()=>v(-10),children:(0,p.jsx)(C,{})}),(0,p.jsx)(`div`,{className:`
|
|
2
|
-
univer-relative univer-hidden univer-h-0.5 univer-rounded-2xl univer-bg-gray-400 univer-px-1.5
|
|
3
|
-
sm:!univer-block
|
|
4
|
-
`,style:{width:`116px`},children:(0,p.jsxs)(`div`,{ref:u,role:`track`,className:`univer-relative univer-h-0.5`,children:[(0,p.jsx)(`a`,{className:`
|
|
5
|
-
univer-absolute univer-left-1/2 univer-top-1/2 univer-box-border univer-block univer-size-0.5
|
|
6
|
-
-univer-translate-x-1/2 -univer-translate-y-1/2 univer-cursor-pointer univer-rounded-full
|
|
7
|
-
univer-bg-white
|
|
8
|
-
`,role:`button`,onClick:_},`reset-button`),(0,p.jsx)(`button`,{className:(0,m.clsx)(`
|
|
9
|
-
univer-absolute univer-top-[calc(50%-6px)] univer-size-3 -univer-translate-x-1/2
|
|
10
|
-
univer-rounded-full univer-border-none univer-bg-white univer-shadow univer-transition-colors
|
|
11
|
-
`,{"hover:univer-gray-200 univer-cursor-pointer":!a,"univer-cursor-not-allowed":a}),role:`handle`,type:`button`,style:{left:`${y}%`},onPointerDown:b})]})}),(0,p.jsx)(m.Button,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n>=i||a,onClick:()=>v(10),children:(0,p.jsx)(w,{})}),(0,p.jsx)(m.DropdownMenu,{align:`end`,items:S,open:h,onOpenChange:g,children:(0,p.jsxs)(m.Button,{size:`small`,variant:`text`,children:[n,`%`]})})]})}const ce=`UI_COLOR_PICKER_COMPONENT`,R=`ui.config`;Symbol(R);const le={};function z(e,t){return function(n,r){t(n,r,e)}}function B(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 ue=(0,c.createIdentifier)(`univer.font-service`),de=[{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 fe=class{constructor(e){this._configService=e,S(this,`fonts$`,new l.BehaviorSubject([]));let t=this._configService.getConfig(R),{customFontFamily:n}=t==null?{}:t,r=[];r=n?Array.isArray(n)?[...de,...n]:n.override?[...n.list]:[...de,...n.list]:[...de],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([...de])}};fe=B([z(0,c.IConfigService)],fe);const pe=({id:e,value:t,disabled$:n})=>{let r=(0,f.useObservable)(n),i=(0,f.useDependency)(c.ICommandService),a=(0,f.useDependency)(c.LocaleService),o=(0,f.useDependency)(ue),[s,l]=(0,d.useState)(``),[u,m]=(0,d.useState)([]);(0,d.useEffect)(()=>{let e=o.fonts$.subscribe(e=>{m(e)});return()=>{e.unsubscribe()}},[]);let h=(0,d.useMemo)(()=>{if(t==null)return``;let e=`${t==null?``:t}`.replace(/\s/g,``),n=u.find(t=>t.value===e);return n?a.t(n.label):a.t(t)},[t,u]);(0,d.useMemo)(()=>{l(h)},[t]);function g(){l(t)}function _(e){l(e.target.value)}function v(e){e.stopPropagation(),!r&&(e.key===`Enter`?b():e.key===`Escape`&&(e.preventDefault(),g()))}function y(){s!==t&&g()}function b(){if(s.toLowerCase()===t.toLowerCase()){g();return}let e=u.find(e=>e.value.toLowerCase()===s.trim().toLowerCase());if(!e){g();return}x(e.value)}function x(t){i.executeCommand(e,{value:t})}return(0,p.jsx)(`div`,{className:`univer-w-32 univer-truncate univer-text-sm`,style:{fontFamily:t},children:(0,p.jsx)(`input`,{className:`
|
|
12
|
-
univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6
|
|
13
|
-
focus:univer-outline-none
|
|
14
|
-
dark:!univer-text-white
|
|
15
|
-
[&_input:focus]:!univer-ring-0
|
|
16
|
-
[&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none
|
|
17
|
-
[&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm
|
|
18
|
-
`,type:`text`,value:s,onChange:_,onKeyDown:v,onBlur:y,disabled:r})})},me=({id:e,value:t})=>{let n=(0,f.useDependency)(c.ICommandService),r=(0,f.useDependency)(ue),[i,a]=(0,d.useState)([]);(0,d.useEffect)(()=>{let e=r.fonts$.subscribe(e=>{a(e)});return()=>{e.unsubscribe()}},[]);let o=(0,f.useDependency)(c.LocaleService);function s(t){n.executeCommand(e,{value:t})}return(0,p.jsx)(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-sm`,style:{fontFamily:t},children:i.map(e=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{className:`
|
|
19
|
-
univer-flex univer-h-7 univer-w-full univer-appearance-none univer-items-center
|
|
20
|
-
univer-justify-between univer-gap-6 univer-rounded univer-border-none univer-bg-transparent
|
|
21
|
-
univer-px-2
|
|
22
|
-
hover:univer-bg-gray-100
|
|
23
|
-
dark:!univer-text-white
|
|
24
|
-
dark:hover:!univer-bg-gray-700
|
|
25
|
-
`,style:{fontFamily:e.value},type:`button`,onClick:()=>s(e.value),children:[o.t(e.label),!r.isFontSupported(e.value)&&(0,p.jsx)(m.Tooltip,{title:o.t(`fontFamily.not-supported`),children:(0,p.jsx)(u.InfoIcon,{className:`
|
|
26
|
-
univer-text-gray-300
|
|
27
|
-
dark:!univer-text-gray-400
|
|
28
|
-
`})})]})},e.value))})},he=`UI_FONT_FAMILY_COMPONENT`,ge=`UI_FONT_FAMILY_ITEM_COMPONENT`,_e=e=>{let{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=(0,f.useObservable)(a),[s,c]=(0,d.useState)(Number(t==null?0:t)),l=(0,d.useMemo)(()=>Number(t==null?s:t),[t]);function u(e){e!==null&&c(e)}function h(e){e.stopPropagation(),e.code===`Enter`&&i(s)}return(0,p.jsx)(`div`,{className:`univer-h-6 univer-w-7 univer-text-sm`,children:(0,p.jsx)(m.InputNumber,{className:`
|
|
29
|
-
univer-block univer-h-6 univer-border-none univer-bg-transparent univer-leading-6
|
|
30
|
-
[&_input:focus]:!univer-ring-0
|
|
31
|
-
[&_input]:univer-h-6 [&_input]:univer-w-7 [&_input]:univer-border-none
|
|
32
|
-
[&_input]:!univer-bg-transparent [&_input]:univer-p-0 [&_input]:univer-text-sm
|
|
33
|
-
`,value:l,controls:!1,min:n,max:r,onKeyDown:h,onChange:u,disabled:o})})},ve=[{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}],ye=[{label:`toolbar.heading.normal`,value:c.NamedStyleType.NORMAL_TEXT},{label:`toolbar.heading.title`,value:c.NamedStyleType.TITLE},{label:`toolbar.heading.subTitle`,value:c.NamedStyleType.SUBTITLE},{label:`toolbar.heading.1`,value:c.NamedStyleType.HEADING_1},{label:`toolbar.heading.2`,value:c.NamedStyleType.HEADING_2},{label:`toolbar.heading.3`,value:c.NamedStyleType.HEADING_3},{label:`toolbar.heading.4`,value:c.NamedStyleType.HEADING_4},{label:`toolbar.heading.5`,value:c.NamedStyleType.HEADING_5}],be=`UI_FONT_SIZE_COMPONENT`,xe=(e,t)=>{let n=(0,d.useRef)(!1);(0,d.useEffect)(()=>{if(n.current)return e();n.current=!0},t)};function Se(e,t){let n=L(t.handler);(0,d.useEffect)(()=>{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 Ce(e,t=300){let n=(0,d.useRef)(null);return(0,d.useCallback)((...r)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(...r)},t)},[e,t])}const we=e=>typeof e==`number`;function Te(e){let t=(0,d.useRef)(e);return t.current=e,t}const Ee=(e,t)=>{let{containerTarget:n,itemHeight:r,overscan:i=5}=t,a=Te(r),[o,s]=(0,d.useState)(null),c=(0,d.useRef)(!1),[l,u]=(0,d.useState)([]),[f,p]=(0,d.useState)({height:void 0,marginTop:void 0}),m=(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},h=t=>{if(we(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},g=t=>typeof a.current==`number`?t*a.current:e.slice(0,t).reduce((t,n,r)=>t+a.current(r,e[r]),0),_=(0,d.useMemo)(()=>we(a.current)?e.length*a.current:e.reduce((t,n,r)=>t+a.current(r,e[r]),0),[e]),v=()=>{let t=n.current;if(t){let{scrollTop:n,clientHeight:r}=t,a=h(n),o=m(r,a),s=Math.max(0,a-i),c=Math.min(e.length,a+o+i),l=g(s);p({height:`${_-l}px`,marginTop:`${l}px`}),u(e.slice(s,c).map((e,t)=>({data:e,index:t+s})))}};return(0,d.useEffect)(()=>{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()}}},[]),(0,d.useEffect)(()=>{!(o!=null&&o.width)||!(o!=null&&o.height)||v()},[o==null?void 0:o.width,o==null?void 0:o.height,e]),[l,{wrapperStyle:f,scrollTo:L(e=>{let t=n.current;t&&(c.current=!0,t.scrollTop=g(e),v())}),containerProps:{onScroll:e=>{if(c.current){c.current=!1;return}e.preventDefault(),v()}}}]};function De(e,t,...n){return e.t(t)}function Oe(e){let{barColor:t,progress:n,onTerminate:r,onClearProgress:i}=e,{count:a,done:o,label:s=``}=n,c=(0,d.useRef)(null),[l,f]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let e=c.current;if(a===0&&o===0){f(!1),e.style.width=`0%`;return}else if(a>0){f(!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&&(f(!1),i&&i())};return e.addEventListener(`transitionend`,t),()=>{e.removeEventListener(`transitionend`,t)}},[a,o]),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-mx-2 univer-flex univer-items-center univer-gap-2`,{"univer-flex":l,"univer-hidden univer-w-0":!l}),children:[(0,p.jsx)(m.Tooltip,{showIfEllipsis:!0,title:s,children:(0,p.jsx)(`span`,{className:`univer-w-24 univer-truncate univer-text-right univer-text-xs`,children:s})}),(0,p.jsx)(`div`,{className:`univer-h-1 univer-w-40 univer-overflow-hidden univer-rounded-lg univer-bg-gray-200`,children:(0,p.jsx)(`div`,{ref:c,className:`univer-h-full univer-bg-primary-600 univer-transition-[width]`,style:{backgroundColor:t}})}),(0,p.jsx)(`button`,{className:`
|
|
34
|
-
univer-flex univer-size-4 univer-cursor-pointer univer-items-center univer-justify-center
|
|
35
|
-
univer-border-none univer-bg-transparent univer-p-0
|
|
36
|
-
hover:univer-opacity-50
|
|
37
|
-
`,type:`button`,onClick:r,children:(0,p.jsx)(u.CloseIcon,{className:`
|
|
38
|
-
univer-size-3.5
|
|
39
|
-
dark:!univer-text-white
|
|
40
|
-
`})})]})}const ke=(0,c.createIdentifier)(`ui.message.service`);let Ae=class extends c.Disposable{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(this._errorService.error$.subscribe(e=>{this._messageService.show({content:e.errorKey,type:m.MessageType.Error})}))}};Ae=B([z(0,(0,c.Inject)(c.ErrorService)),z(1,ke)],Ae);const je=`univer.command.copy`,Me={id:je,name:je,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:()=>!0},Ne=`univer.command.cut`,Pe={id:Ne,name:Ne,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Fe=`univer.command.paste`,Ie={id:Fe,name:Fe,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:()=>!0};let V=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 Le={[V.BACKSPACE]:`Backspace`,[V.TAB]:`Tab`,[V.ENTER]:`Enter`,[V.DELETE]:`Del`,[V.ESC]:`Esc`,[V.SPACE]:`Space`,[V.ARROW_LEFT]:`←`,[V.ARROW_RIGHT]:`→`,[V.ARROW_UP]:`↑`,[V.ARROW_DOWN]:`↓`,[V.Digit0]:`0`,[V.Digit1]:`1`,[V.Digit2]:`2`,[V.Digit3]:`3`,[V.Digit4]:`4`,[V.Digit5]:`5`,[V.Digit6]:`6`,[V.Digit7]:`7`,[V.Digit8]:`8`,[V.Digit9]:`9`,[V.A]:`A`,[V.B]:`B`,[V.C]:`C`,[V.D]:`D`,[V.E]:`E`,[V.F]:`F`,[V.G]:`G`,[V.H]:`H`,[V.I]:`I`,[V.J]:`J`,[V.K]:`K`,[V.L]:`L`,[V.M]:`M`,[V.N]:`N`,[V.O]:`O`,[V.P]:`P`,[V.Q]:`Q`,[V.R]:`R`,[V.S]:`S`,[V.T]:`T`,[V.U]:`U`,[V.V]:`V`,[V.W]:`W`,[V.X]:`X`,[V.Y]:`Y`,[V.Z]:`Z`,[V.F1]:`F1`,[V.F2]:`F2`,[V.F3]:`F3`,[V.F4]:`F4`,[V.F5]:`F5`,[V.F6]:`F6`,[V.F7]:`F7`,[V.F8]:`F8`,[V.F9]:`F9`,[V.F10]:`F10`,[V.F11]:`F11`,[V.F12]:`F12`,[V.MINUS]:`-`,[V.EQUAL]:`=`,[V.PERIOD]:`.`,[V.COMMA]:`,`,[V.BACK_SLASH]:`\\`};let H=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 Re(e,t,n){return window.addEventListener(e,t,n),(0,c.toDisposable)(()=>window.removeEventListener(e,t,n))}const ze=[`app-layout`,`button`,`sheet-bar-append-button`,`render-canvas`,`workbench-layout`],U=(0,c.createIdentifier)(`ui.layout-service`);let Be=class extends c.Disposable{get isFocused(){return this._isFocused}constructor(e,t){super(),this._contextService=e,this._univerInstanceService=t,S(this,`_rootContainerElement`,null),S(this,`_isFocused`,!1),S(this,`_focusHandlers`,new Map),S(this,`_contentElements`,[]),S(this,`_allContainers`,[]),this._initUniverFocusListener(),this._initEditorStatus()}get rootContainerElement(){return this._rootContainerElement}focus(){let e=this._univerInstanceService.getFocusedUnit();if(!e)return;let t;e instanceof c.Workbook?t=this._focusHandlers.get(c.UniverInstanceType.UNIVER_SHEET):e instanceof c.DocumentDataModel?t=this._focusHandlers.get(c.UniverInstanceType.UNIVER_DOC):e instanceof c.SlideDataModel&&(t=this._focusHandlers.get(c.UniverInstanceType.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),(0,c.toDisposable)(()=>this._focusHandlers.delete(e))}registerContentElement(e){if(this._contentElements.indexOf(e)===-1)return this._contentElements.push(e),(0,c.toDisposable)(()=>(0,c.remove)(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(0,c.toDisposable)(()=>{this._rootContainerElement=null,t.dispose()})}registerContainerElement(e){if(this._allContainers.indexOf(e)===-1)return this._allContainers.push(e),(0,c.toDisposable)(()=>(0,c.remove)(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((0,l.fromEvent)(window,`focusin`).subscribe(e=>{var t;let n=e.target;if((t=this._rootContainerElement)!=null&&t.contains(n)&&ze.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(c.FOCUSING_UNIVER_EDITOR,Ve())}))}_initEditorStatus(){this._contextService.setContextValue(c.FOCUSING_UNIVER_EDITOR,Ve())}};Be=B([z(0,c.IContextService),z(1,c.IUniverInstanceService)],Be);function Ve(){var e;return((e=document.activeElement)==null?void 0:e.dataset.uComp)===`editor`}const He=(0,c.createIdentifier)(`ui.platform.service`);var Ue=class{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}};const We=(0,c.createIdentifier)(`ui.shortcut.service`);let Ge=class extends c.Disposable{constructor(e,t,n,r){super(),this._commandService=e,this._platformService=t,this._contextService=n,this._layoutService=r,S(this,`_shortCutMapping`,new Map),S(this,`_commandIDMapping`,new Map),S(this,`_shortcutChanged$`,new l.Subject),S(this,`shortcutChanged$`,this._shortcutChanged$.asObservable()),S(this,`_forceEscaped`,!1),S(this,`_forceDisabled`,!1),this.disposeWithMe(Re(`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(0,c.toDisposable)(()=>{});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(),(0,c.toDisposable)(()=>{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&H.CTRL_COMMAND,i=n&H.SHIFT,a=n&H.ALT,o=n&H.MAC_CTRL,s=(t=Le[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,(0,c.toDisposable)(()=>this._forceEscaped=!1)}forceDisable(){return this._forceDisabled=!0,(0,c.toDisposable)(()=>{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|=H.SHIFT),r&&(a|=H.ALT),(this._platformService.isMac?n:e.ctrlKey)&&(a|=H.CTRL_COMMAND),this._platformService.isMac&&e.ctrlKey&&(a|=H.MAC_CTRL),a}};Ge=B([z(0,c.ICommandService),z(1,He),z(2,c.IContextService),z(3,(0,c.Optional)(U))],Ge);function Ke(e){return e.getContextValue(c.FOCUSING_UNIVER_EDITOR)}function qe(e){return e.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&!(e.getContextValue(c.EDITOR_ACTIVATED)||e.getContextValue(c.FOCUSING_FX_BAR_EDITOR))}const Je={id:Me.id,description:`shortcut.copy`,group:`1_common-edit`,binding:V.C|H.CTRL_COMMAND,preconditions:Ke},Ye={id:Pe.id,description:`shortcut.cut`,group:`1_common-edit`,binding:V.X|H.CTRL_COMMAND,preconditions:Ke},Xe={id:Ie.id,description:`shortcut.paste`,group:`1_common-edit`,binding:V.V|H.CTRL_COMMAND,preconditions:()=>!1},Ze={id:c.UndoCommand.id,description:`shortcut.undo`,group:`1_common-edit`,binding:V.Z|H.CTRL_COMMAND,preconditions:qe},Qe={id:c.RedoCommand.id,description:`shortcut.redo`,group:`1_common-edit`,binding:V.Y|H.CTRL_COMMAND,preconditions:qe};let W=class extends c.Disposable{constructor(e,t){super(),this._shortcutService=e,this._commandService=t,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts()}_registerCommands(){[Pe,Me,Ie].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e)))}_registerShortcuts(){let e=[Ze,Qe];e.push(Ye,Je,Xe),e.forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}};W=B([z(0,We),z(1,c.ICommandService)],W);let $e=function(e){return e.RIBBON=`ribbon`,e.CONTEXT_MENU=`contextMenu`,e}({}),G=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}({}),et=function(e){return e.HISTORY=`ribbon.start.history`,e.FORMAT=`ribbon.start.format`,e.LAYOUT=`ribbon.start.layout`,e.OTHERS=`ribbon.start.others`,e}({}),tt=function(e){return e.EDIT=`ribbon.insert.edit`,e.MEDIA=`ribbon.insert.media`,e.OTHERS=`ribbon.insert.others`,e}({}),nt=function(e){return e.BASIC=`ribbon.formulas.basic`,e.OTHERS=`ribbon.formulas.others`,e}({}),rt=function(e){return e.FORMULAS=`ribbon.data.formulas`,e.RULES=`ribbon.data.rules`,e.ORGANIZATION=`ribbon.data.organization`,e.OTHERS=`ribbon.data.others`,e}({}),it=function(e){return e.DISPLAY=`ribbon.view.display`,e.VISIBILITY=`ribbon.view.Visibility`,e.OTHERS=`ribbon.view.others`,e}({}),at=function(e){return e.OTHERS=`ribbon.others.others`,e}({}),K=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=(0,c.createIdentifier)(`univer.menu-manager-service`);let ot=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._configService=t,S(this,`menuChanged$`,new l.Subject),S(this,`_menu`,{[$e.RIBBON]:{[G.START]:{order:0,[et.HISTORY]:{order:0},[et.FORMAT]:{order:1},[et.LAYOUT]:{order:2},[et.OTHERS]:{order:3}},[G.INSERT]:{order:1,[tt.EDIT]:{order:0},[tt.MEDIA]:{order:1},[tt.OTHERS]:{order:2}},[G.FORMULAS]:{order:2,[nt.BASIC]:{order:0},[nt.OTHERS]:{order:1}},[G.DATA]:{order:3,[rt.FORMULAS]:{order:0},[rt.RULES]:{order:1},[rt.ORGANIZATION]:{order:2},[rt.OTHERS]:{order:3}},[G.VIEW]:{order:4,[it.DISPLAY]:{order:0},[it.VISIBILITY]:{order:0},[it.OTHERS]:{order:0}},[G.OTHERS]:{order:5,[at.OTHERS]:{order:0}}},[$e.CONTEXT_MENU]:{[K.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}},[K.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}},[K.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}},[K.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}},[K.FOOTER_TABS]:{order:3,[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[K.FOOTER_MENU]:{order:4,[q.OTHERS]:{order:3}},[K.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]=(0,c.merge)({},n[r],e[r]),this.menuChanged$.next()}else typeof r==`object`&&this.mergeMenu(e,r)}appendRootMenu(e){this._menu=(0,c.merge)({},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=N(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)}};ot=B([z(0,(0,c.Inject)(c.Injector)),z(1,c.IConfigService)],ot);function st(){let e=(0,f.useDependency)(We),t=(0,f.useDependency)(c.LocaleService),n=(0,f.useObservable)(t.currentLocale$),[r,i]=(0,d.useState)([]),a=(0,d.useCallback)(()=>{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:(0,c.dedupeBy)(n,e=>e.title+e.shortcut)}}).sort((e,t)=>e.sequence-t.sequence))},[e,t,n]);return(0,d.useEffect)(()=>{a();let t=e.shortcutChanged$.subscribe(()=>a());return()=>t.unsubscribe()},[e,a]),(0,p.jsx)(`ul`,{className:`
|
|
41
|
-
univer-m-0 univer-list-none univer-p-0 univer-text-gray-900
|
|
42
|
-
dark:!univer-text-white
|
|
43
|
-
`,children:r.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`div`,{className:`univer-flex univer-h-10 univer-items-center univer-text-sm univer-font-semibold`,children:e.name}),(0,p.jsx)(`ul`,{className:(0,m.clsx)(`univer-list-none univer-p-0`,m.divideYClassName),children:e.items.map(e=>(0,p.jsxs)(`li`,{className:`
|
|
44
|
-
univer-flex univer-h-10 univer-items-center univer-justify-between univer-py-0.5
|
|
45
|
-
univer-text-sm
|
|
46
|
-
last:univer-border-b-0
|
|
47
|
-
`,children:[(0,p.jsx)(`span`,{className:`univer-line-clamp-2`,children:e.title}),e.shortcut&&(0,p.jsx)(m.KBD,{keyboard:e.shortcut})]},`${e.title}-${e.shortcut}`))})]},e.name))})}const ct={id:D.id,binding:H.CTRL_COMMAND|V.BACK_SLASH,description:`shortcut.shortcut-panel`,group:`10_global-shortcut`};let lt=class extends c.Disposable{constructor(e,t,n,r,i){super(),this._menuManagerService=r,this.disposeWithMe(t.register(E,st)),this.disposeWithMe(i.registerCommand(D)),this.disposeWithMe(n.registerShortcut(ct))}};lt=B([z(0,(0,c.Inject)(c.Injector)),z(1,(0,c.Inject)(k)),z(2,We),z(3,J),z(4,c.ICommandService)],lt);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 ut(e){return e.type===Y.BUTTON_SELECTOR}const dt=(e,t)=>{let n=e.get(c.IUndoRedoService),r=e.get(c.IContextService);return(0,l.combineLatest)([n.undoRedoStatus$.pipe((0,g.map)(e=>t?e.undos<=0:e.redos<=0)),(0,l.merge)([(0,l.of)({}),r.contextChanged$])]).pipe((0,g.map)(([e])=>e||r.getContextValue(c.EDITOR_ACTIVATED)||r.getContextValue(c.FOCUSING_FX_BAR_EDITOR)))};function ft(e){return{id:c.UndoCommand.id,type:Y.BUTTON,icon:`UndoIcon`,title:`Undo`,tooltip:`toolbar.undo`,disabled$:dt(e,!0)}}function pt(e){return{id:c.RedoCommand.id,type:Y.BUTTON,icon:`RedoIcon`,title:`Redo`,tooltip:`toolbar.redo`,disabled$:dt(e,!1)}}function mt(){return{id:D.id,title:`toggle-shortcut-panel`,tooltip:`toggle-shortcut-panel`,icon:`ShortcutIcon`,type:Y.BUTTON}}const ht={[et.HISTORY]:{[c.UndoCommand.id]:{order:0,menuItemFactory:ft},[c.RedoCommand.id]:{order:1,menuItemFactory:pt}},[et.OTHERS]:{[D.id]:{order:1,menuItemFactory:mt}}};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=(0,c.createIdentifier)(`ui.parts.service`);var gt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_componentsByPart`,new Map),S(this,`_componentRegistered$`,new l.Subject),S(this,`componentRegistered$`,this._componentRegistered$.asObservable()),S(this,`_uiVisible`,new Map),S(this,`_uiVisibleChange$`,new l.Subject),S(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),(0,c.toDisposable)(()=>{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])}},_t=class{constructor(){S(this,`_domLayerMap`,new Map),S(this,`_domLayers$`,new l.BehaviorSubject([])),S(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 vt=(0,d.memo)(e=>{var t,n;let{layer:r,id:i}=e,a=(0,d.useMemo)(()=>r.position$.pipe((0,l.distinctUntilChanged)((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$]),o=(0,f.useDependency)(c.IUniverInstanceService),s=(0,f.useObservable)((0,d.useMemo)(()=>r.position$.pipe((0,l.first)()),[r.position$])),u=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(`transform: rotate(${s==null?void 0:s.rotate}deg) translate(${s==null?void 0:s.startX}px, ${s==null?void 0:s.startY}px)`),g=(0,d.useRef)((t=s==null?void 0:s.startY)==null?0:t),_=(0,d.useRef)((n=s==null?void 0:s.startX)==null?0:n),v=(0,d.useRef)({}),y=typeof r.componentKey==`string`?(0,f.useDependency)(k).get(r.componentKey):r.componentKey,b=(0,d.useMemo)(()=>({data:r.data,...r.props}),[r.data,r.props]);(0,d.useEffect)(()=>{let e=r.position$.subscribe(e=>{if(h.current=`rotate(${e.rotate}deg)`,g.current=e.startY,_.current=e.startX,u.current){var t;u.current.style.transform=h.current,u.current.style.top=`${g.current}px`,u.current.style.left=`${_.current}px`,u.current.style.opacity=`${(t=e.opacity)==null?1:t}`}}),t=a.subscribe(e=>{if(u.current&&(u.current.style.width=`${Math.max(e.endX-e.startX-2,0)}px`,u.current.style.height=`${Math.max(e.endY-e.startY-2,0)}px`),m.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}`};m.current.style.width=t.width,m.current.style.height=t.height,m.current.style.left=t.left,m.current.style.top=t.top,m.current.style.right=t.right,m.current.style.bottom=t.bottom,v.current=t}});return()=>{e.unsubscribe(),t.unsubscribe()}},[r.position$,a]);let x=o.getUnit(r.unitId),S=x instanceof c.DocumentDataModel?x.getDisabled():void 0,C=(0,d.useMemo)(()=>y?(0,p.jsx)(y,{...b,unitId:r.unitId,unit:x,floatDomId:r.id,context:{docDisabled:S,root:m}}):null,[y,b]);return s?(0,p.jsx)(`div`,{ref:u,className:`univer-z-10`,style:{position:`absolute`,top:g.current,left:_.current,width:Math.max(s.endX-s.startX-2,0),height:Math.max(s.endY-s.startY-2,0),transform:h.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:(0,p.jsx)(`div`,{id:i,ref:m,className:`univer-absolute univer-overflow-hidden`,style:{...v.current},children:C})}):null}),yt=({unitId:e})=>{var t;let n=(0,f.useDependency)(c.IUniverInstanceService),r=(0,f.useObservable)((0,f.useDependency)(_t).domLayers$),i=(0,f.useObservable)(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(0,p.jsx)(vt,{id:(t=e[1].domId)==null?e[0]:t,layer:e[1]},e[0])})},bt=(0,c.createIdentifier)(`ui.popup.service`);var xt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_popupMap`,new Map),S(this,`_popups$`,new l.BehaviorSubject([])),S(this,`popups$`,this._popups$.asObservable()),S(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=(0,c.generateRandomId)();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 St=(0,d.createContext)({current:void 0});function Ct(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 wt(e){var t;let{mask:n,portal:r,children:i,anchorRect$:a,direction:o=`vertical`,onClickOutside:s,excludeOutside:l,excludeRects:u,onPointerEnter:h,onPointerLeave:g,onClick:v,hidden:y,onContextMenu:b,zIndex:x=1020,maskZIndex:S=100,onMaskClick:C,noPushMinimumGap:w,autoRelayout:T=!0}=e,E=(0,d.useRef)(null),D=L(s==null?(()=>{}):s),O=L(b==null?(()=>{}):b),k=(0,d.useRef)({top:-9999,left:-9999}),A=u,j=(0,f.useDependency)(c.IConfigService),M=(0,d.useRef)(void 0),N=j.getConfig(R),ee=(t=N==null?void 0:N.popupRootId)==null?`univer-popup-portal`:t,te=L(e=>{requestAnimationFrame(()=>{if(!E.current)return;let{clientWidth:t,clientHeight:n}=E.current,r=window.innerWidth,i=window.innerHeight;k.current=Ct({position:e,width:t,height:n,containerWidth:r,containerHeight:i,direction:o,noPushMinimumGap:w}),E.current.style.top=`${k.current.top}px`,E.current.style.left=`${k.current.left}px`})});(0,d.useEffect)(()=>{let e;return E.current&&(e=new ResizeObserver(()=>{T&&M.current&&te(M.current)}),e.observe(E.current)),()=>{e==null||e.disconnect()}},[E.current,T]),(0,d.useEffect)(()=>{let e=a.subscribe(e=>{M.current=e,te(e)});return()=>e.unsubscribe()},[a,o]),(0,d.useEffect)(()=>{let e=e=>{var t;if(l&&(l.indexOf(e.target)>-1||l.some(t=>t.contains(e.target))))return;let n=e.clientX,r=e.clientY,i=[...(t=A==null?void 0:A.current)==null?[]:t];M.current&&i.push(M.current);for(let e of i)if(n<=e.right&&n>=e.left&&r<=e.bottom&&r>=e.top)return;D(e)};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[D,l,A]),(0,d.useEffect)(()=>{let e=e=>{e.ctrlKey&&e.button===0||O()};return window.addEventListener(`contextmenu`,e),()=>{window.removeEventListener(`contextmenu`,e)}},[O]);let P=(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsx)(`div`,{"data-u-comp":`rect-popup-mask`,className:`univer-fixed univer-inset-0 univer-z-[100]`,style:{zIndex:S},onClick:C}),(0,p.jsx)(`section`,{"data-u-comp":`rect-popup`,ref:E,className:(0,m.clsx)(`
|
|
48
|
-
univer-pointer-events-auto univer-fixed univer-left-[-9999px] univer-top-[-9999px] univer-z-[1020]
|
|
49
|
-
`,{"univer-hidden":y,"univer-animate-in univer-fade-in-70":!y}),style:{...k.current,zIndex:x},onPointerDown:e=>e.stopPropagation(),onClick:v,onPointerEnter:h,onPointerLeave:g,children:(0,p.jsx)(St.Provider,{value:M,children:i})})]});return r?document.getElementById(ee)?(0,_.createPortal)(P,document.getElementById(ee)):null:P}wt.calcPopupPosition=Ct,wt.useContext=()=>(0,d.useContext)(St);const Tt=({popup:e,children:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,d.useMemo)(()=>e.anchorRect$.pipe((0,l.throttleTime)(0,l.animationFrameScheduler),(0,l.map)(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=(0,d.useMemo)(()=>{var t,n;return(t=(n=e.hiddenRects$)==null?void 0:n.pipe((0,l.throttleTime)(0,l.animationFrameScheduler)))==null?(0,l.of)([]):t},[e.hiddenRects$]),o=P((0,d.useMemo)(()=>{var t;return(t=e.excludeRects$)==null?void 0:t.pipe((0,l.throttleTime)(0,l.animationFrameScheduler))},[e.excludeRects$]),e.excludeRects),{canvasElement:s,hideOnInvisible:c=!0,hiddenType:u=`destroy`}=e;return(0,d.useEffect)(()=>{if(!c)return;let e=(0,l.combineLatest)([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&&u===`destroy`?null:(0,p.jsx)(wt,{...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 Et(){let e=(0,f.useDependency)(bt),t=(0,f.useDependency)(k);return(0,f.useObservable)(e.popups$,void 0,!0).map(e=>{let[n,r]=e,i=t.get(r.componentKey);return(0,p.jsx)(Tt,{popup:r,children:i?(0,p.jsx)(i,{popup:r}):null},n)})}const Dt=(0,c.createIdentifier)(`univer.ribbon-service`);let Ot=class extends c.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._univerInstanceService=t,S(this,`_ribbon$`,new l.BehaviorSubject([])),S(this,`ribbon$`,this._ribbon$.asObservable()),S(this,`_activatedTab$`,new l.BehaviorSubject(G.START)),S(this,`activatedTab$`,this._activatedTab$.asObservable()),S(this,`_collapsedIds$`,new l.BehaviorSubject([])),S(this,`collapsedIds$`,this._collapsedIds$.asObservable()),S(this,`_fakeToolbarVisible$`,new l.BehaviorSubject(!1)),S(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((0,l.combineLatest)([this._menuManagerService.menuChanged$.pipe((0,g.startWith)(void 0)),this._univerInstanceService.focused$.pipe((0,g.startWith)(void 0))]).subscribe(()=>{this._updateRibbon()}))}_updateRibbon(){let e=this._menuManagerService.getMenuByPositionKey($e.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}(0,l.combineLatest)(t).pipe((0,g.startWith)(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()}};Ot=B([z(0,J),z(1,c.IUniverInstanceService)],Ot);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(0,d.createElement)(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?(0,f.useDependency)(Z):n,i=(0,f.useObservable)((0,d.useMemo)(()=>r.uiVisibleChange$.pipe((0,l.filter)(t=>t.ui===e)),[e,r])),a=(0,d.useRef)(0);return(0,d.useMemo)(()=>r.isUIVisible(e)?r.getComponents(e):new Set,[(0,f.useObservable)(()=>r.componentRegistered$.pipe((0,l.filter)(t=>t===e),(0,l.debounceTime)(200),(0,l.map)(()=>a.current+=1),(0,l.startWith)(a.current+=1)),void 0,void 0,[r,e,i])])}function kt({ribbon:e,activatedTab:t,onSelectTab:n}){let r=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`div`,{className:`
|
|
50
|
-
univer-flex univer-size-full univer-items-center univer-justify-center univer-gap-1 univer-overflow-x-auto
|
|
51
|
-
univer-rounded-md univer-bg-gray-50 univer-px-3
|
|
52
|
-
dark:!univer-bg-gray-900
|
|
53
|
-
`,role:`tablist`,"aria-label":r.t(`ribbon.menu`),children:e.map(e=>{let i=t===e.key;return(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i,title:r.t(e.key),onClick:()=>n(e),className:(0,m.clsx)(`
|
|
54
|
-
univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500
|
|
55
|
-
dark:!univer-focus:ring-primary-300
|
|
56
|
-
univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1
|
|
57
|
-
univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-sm
|
|
58
|
-
univer-transition-colors
|
|
59
|
-
`,i?`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@univerjs/core`),l=require(`rxjs`),u=require(`@univerjs/icons`),d=require(`react`);d=s(d);let f=require(`@wendellhu/redi/react-bindings`),p=require(`react/jsx-runtime`),m=require(`@univerjs/design`),h=require(`@univerjs/engine-render`),g=require(`rxjs/operators`),_=require(`react-dom`),v=require(`localforage`);v=s(v);function y(e){"@babel/helpers - typeof";return y=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},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C=class extends c.Disposable{constructor(...e){super(...e),S(this,`_open$`,new l.BehaviorSubject(!1)),S(this,`open$`,this._open$.pipe((0,l.distinctUntilChanged)()))}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 w=(0,c.createIdentifier)(`ui.left-sidebar.service`),T=(0,c.createIdentifier)(`ui.sidebar.service`),E=`ShortcutPanel`,D={id:`base-ui.operation.toggle-shortcut-panel`,type:c.CommandType.OPERATION,handler:e=>{let t=e.get(C),n=e.get(T);return t.isOpen?(t.close(),n.close()):(t.open(),n.open({header:{title:`shortcut-panel.title`},children:{label:E}})),!0}},O={AddDigitsIcon:u.AddDigitsIcon,AddImageIcon:u.AddImageIcon,AdditionAndSubtractionIcon:u.AdditionAndSubtractionIcon,AdjustHeightDoubleIcon:u.AdjustHeightDoubleIcon,AdjustWidthDoubleIcon:u.AdjustWidthDoubleIcon,AlignBottomIcon:u.AlignBottomIcon,AlignTextBothIcon:u.AlignTextBothIcon,AlignTopIcon:u.AlignTopIcon,AllBorderIcon:u.AllBorderIcon,AmplifyIcon:u.AmplifyIcon,AutoHeightDoubleIcon:u.AutoHeightDoubleIcon,AutoWidthDoubleIcon:u.AutoWidthDoubleIcon,AutowrapIcon:u.AutowrapIcon,AvgIcon:u.AvgIcon,BackSlashDoubleIcon:u.BackSlashDoubleIcon,BoldIcon:u.BoldIcon,BrushIcon:u.BrushIcon,CancelFreezeIcon:u.CancelFreezeIcon,CancelMergeIcon:u.CancelMergeIcon,ClearFormatDoubleIcon:u.ClearFormatDoubleIcon,CntIcon:u.CntIcon,CodeIcon:u.CodeIcon,ConditionsDoubleIcon:u.ConditionsDoubleIcon,CopyDoubleIcon:u.CopyDoubleIcon,CutIcon:u.CutIcon,DeleteCellMoveDownDoubleIcon:u.DeleteCellMoveDownDoubleIcon,DeleteCellShiftLeftDoubleIcon:u.DeleteCellShiftLeftDoubleIcon,DeleteCellShiftRightDoubleIcon:u.DeleteCellShiftRightDoubleIcon,DeleteCellShiftUpDoubleIcon:u.DeleteCellShiftUpDoubleIcon,DeleteColumnDoubleIcon:u.DeleteColumnDoubleIcon,DeleteRowDoubleIcon:u.DeleteRowDoubleIcon,DirectExportIcon:u.DirectExportIcon,DollarIcon:u.DollarIcon,DownBorderDoubleIcon:u.DownBorderDoubleIcon,DownloadImageIcon:u.DownloadImageIcon,EuroIcon:u.EuroIcon,ExportIcon:u.ExportIcon,EyeOutlineIcon:u.EyeOutlineIcon,FolderIcon:u.FolderIcon,FontColorDoubleIcon:u.FontColorDoubleIcon,FontSizeIncreaseIcon:u.FontSizeIncreaseIcon,FontSizeReduceIcon:u.FontSizeReduceIcon,FreezeColumnIcon:u.FreezeColumnIcon,FreezeRowIcon:u.FreezeRowIcon,FreezeToSelectedIcon:u.FreezeToSelectedIcon,FunctionIcon:u.FunctionIcon,GridIcon:u.GridIcon,HeaderFooterIcon:u.HeaderFooterIcon,HideDoubleIcon:u.HideDoubleIcon,HorizontalBorderDoubleIcon:u.HorizontalBorderDoubleIcon,HorizontallyIcon:u.HorizontallyIcon,HorizontalMergeIcon:u.HorizontalMergeIcon,IncreaseIcon:u.IncreaseIcon,InnerBorderDoubleIcon:u.InnerBorderDoubleIcon,InsertCellDownDoubleIcon:u.InsertCellDownDoubleIcon,InsertCellShiftRightDoubleIcon:u.InsertCellShiftRightDoubleIcon,InsertDoubleIcon:u.InsertDoubleIcon,InsertRowAboveDoubleIcon:u.InsertRowAboveDoubleIcon,InsertRowBelowDoubleIcon:u.InsertRowBelowDoubleIcon,ItalicIcon:u.ItalicIcon,KeyboardIcon:u.KeyboardIcon,LeftBorderDoubleIcon:u.LeftBorderDoubleIcon,LeftDoubleDiagonalDoubleIcon:u.LeftDoubleDiagonalDoubleIcon,LeftInsertColumnDoubleIcon:u.LeftInsertColumnDoubleIcon,LeftJustifyingIcon:u.LeftJustifyingIcon,LeftRotationFortyFiveDegreesIcon:u.LeftRotationFortyFiveDegreesIcon,LeftRotationNinetyDegreesIcon:u.LeftRotationNinetyDegreesIcon,LeftTridiagonalDoubleIcon:u.LeftTridiagonalDoubleIcon,MaxIcon:u.MaxIcon,MenuIcon:u.MenuIcon,MergeAllIcon:u.MergeAllIcon,MinIcon:u.MinIcon,MoreDownIcon:u.MoreDownIcon,NoBorderIcon:u.NoBorderIcon,NoColorDoubleIcon:u.NoColorDoubleIcon,NoRotationIcon:u.NoRotationIcon,OrderIcon:u.OrderIcon,OuterBorderDoubleIcon:u.OuterBorderDoubleIcon,OverflowIcon:u.OverflowIcon,PaintBucketDoubleIcon:u.PaintBucketDoubleIcon,PasteSpecialDoubleIcon:u.PasteSpecialDoubleIcon,PercentIcon:u.PercentIcon,PipingIcon:u.PipingIcon,RedoIcon:u.RedoIcon,ReduceDigitsIcon:u.ReduceDigitsIcon,ReduceDoubleIcon:u.ReduceDoubleIcon,ReduceIcon:u.ReduceIcon,RightBorderDoubleIcon:u.RightBorderDoubleIcon,RightDoubleDiagonalDoubleIcon:u.RightDoubleDiagonalDoubleIcon,RightInsertColumnDoubleIcon:u.RightInsertColumnDoubleIcon,RightJustifyingIcon:u.RightJustifyingIcon,RightRotationFortyFiveDegreesIcon:u.RightRotationFortyFiveDegreesIcon,RightRotationNinetyDegreesIcon:u.RightRotationNinetyDegreesIcon,RmbIcon:u.RmbIcon,RoubleIcon:u.RoubleIcon,ShortcutIcon:u.ShortcutIcon,SlashDoubleIcon:u.SlashDoubleIcon,StrikethroughIcon:u.StrikethroughIcon,SubscriptIcon:u.SubscriptIcon,SumIcon:u.SumIcon,SuperscriptIcon:u.SuperscriptIcon,TruncationIcon:u.TruncationIcon,UnderlineIcon:u.UnderlineIcon,UndoIcon:u.UndoIcon,UnorderIcon:u.UnorderIcon,UpBorderDoubleIcon:u.UpBorderDoubleIcon,VerticalBorderDoubleIcon:u.VerticalBorderDoubleIcon,VerticalCenterIcon:u.VerticalCenterIcon,VerticalIntegrationIcon:u.VerticalIntegrationIcon,VerticalTextIcon:u.VerticalTextIcon};var k=class extends c.Disposable{constructor(){super(),S(this,`_components`,new Map),S(this,`_componentsReverse`,new Map),S(this,`reactUtils`,{createElement:d.createElement,useEffect:d.useEffect,useRef:d.useRef}),S(this,`_handler`,{react:e=>e});for(let e in O)this.register(e,O[e]);this.disposeWithMe((0,c.toDisposable)(()=>{for(let e in O)this._components.delete(e),this._componentsReverse.delete(O[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),(0,c.toDisposable)(()=>{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)}},A=class{constructor(){S(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 j(e,t,n,r){let i=e.get(c.IUniverInstanceService);return new l.Observable(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 M(e){let t=e.get(c.IUniverInstanceService);return new l.Observable(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!==c.DocumentFlavor.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!==c.DocumentFlavor.TRADITIONAL),()=>n.unsubscribe()})}function N(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=>{ee(e,`${n}$`,t[n])}),e)}function ee(e,t,n){n!==void 0&&(e[t]?e[t]=e[t].pipe((0,l.switchMap)(()=>new l.BehaviorSubject(n))):e[t]=new l.Observable(e=>{e.next(n)}))}function te(e){return typeof e==`function`?e():e}function P(e,t){let n=(0,d.useRef)(t);return(0,d.useEffect)(()=>{if(e){let t=te(e).subscribe(e=>{n.current=e});return()=>t.unsubscribe()}},[e]),n}const F=e=>{let{value:t,selections:n}=e,r=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`div`,{className:`univer-truncate univer-text-sm`,children:(0,d.useMemo)(()=>{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])})},ne=`UI_PLUGIN_COMMON_LABEL_COMPONENT`;function I(e){let{className:t,title:n,icon:r,label:i,value:a,value$:o}=e,s=(0,f.useDependency)(c.LocaleService),u=(0,f.useDependency)(k),[m,h]=(0,d.useState)(a),[g,_]=(0,d.useState)(``),v=[],y=0;(0,d.useEffect)(()=>{if(o){let e=o.subscribe(e=>{h(e)});return()=>{e.unsubscribe()}}},[o]);let b=(0,d.useMemo)(()=>a==null?m:a,[m,a]);(0,d.useEffect)(()=>{let e=null;return(0,l.isObservable)(r)?e=r.subscribe(e=>{_(e)}):_(r==null?``:r),()=>{e==null||e.unsubscribe()}},[r]);let x=(0,d.useMemo)(()=>b&&typeof b==`string`?new c.ColorKit(b).isValid:!1,[b]);if(r){let e=u.get(g==null?``:g);e&&v.push((0,p.jsx)(e,{className:`univer-text-base`,extend:{colorChannel1:x?b:`var(--univer-primary-600)`}},y++))}if(i){let n=typeof i==`string`,r=n?{...e}:{...i==null?void 0:i.props,...e},a=n?i:i==null?void 0:i.name,o=u.get(a);o?v.push((0,p.jsx)(o,{...r,className:t,value:b},y++)):v.push((0,p.jsx)(`span`,{className:t,children:s.t(a)},y++))}return n&&v.push((0,p.jsx)(`span`,{className:t,children:typeof n==`string`?s.t(n):n},y++)),(0,p.jsx)(p.Fragment,{children:v})}const re=e=>{var t,n;let{value:r,text:i}=e,a=c.NAMED_STYLE_MAP[r],o=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`span`,{className:(0,m.clsx)(`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)})},ie=`UI_COMPONENT_HEADING_ITEM`;function L(e){let t=(0,d.useRef)(e);return t.current=e,(0,d.useCallback)(((...e)=>{var n;return(n=t.current)==null?void 0:n.call(t,...e)}),[])}function ae(e,t){let n=L(()=>{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`)});(0,d.useEffect)(()=>{if(!(0,m.isBrowser)()||!e||!t)return;n();let r=(0,m.resizeObserverCtor)(n);return r.observe(e),()=>{r.unobserve(e)}},[e,t])}function oe(e){let t=(0,f.useDependency)(c.IConfigService);return(0,f.useObservable)((0,d.useMemo)(()=>t.subscribeConfigValue$(e),[t]),t.getConfig(e))}function se(e){(0,f.useDependency)(c.LocaleService);let t=(0,f.useDependency)(k),{value:n,min:r=0,max:i=400,disabled:a=!1,resetPoint:o=100,shortcuts:s,onChange:l}=e,u=(0,d.useRef)(null),[h,g]=(0,d.useState)(!1);function _(){a||l&&l(o)}function v(e){if(a)return;let t=n+e;n+e<=r?t=r:n+e>=i&&(t=i),l&&l(t)}let y=(0,d.useMemo)(()=>{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 b(e){if(a)return;e.preventDefault();let t=u.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,l&&l(Math.ceil(s))}}function c(){n=!1,document.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c)}function d(e){e.relatedTarget===null&&c()}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointerout`,d)}function x(e){a||(g(!1),l&&l(e))}let S=[{type:`radio`,value:n.toString(),options:s.map(e=>({value:e.toString(),label:`${e}%`})),onSelect:e=>x(+e)}],C=t.get(`ReduceIcon`),w=t.get(`IncreaseIcon`);return(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-flex univer-select-none univer-items-center univer-gap-1`,{"univer-cursor-not-allowed":a}),children:[(0,p.jsx)(m.Button,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n<=r||a,onClick:()=>v(-10),children:(0,p.jsx)(C,{})}),(0,p.jsx)(`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:(0,p.jsxs)(`div`,{ref:u,role:`track`,className:`univer-relative univer-h-0.5`,children:[(0,p.jsx)(`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:_},`reset-button`),(0,p.jsx)(`button`,{className:(0,m.clsx)(`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:`${y}%`},onPointerDown:b})]})}),(0,p.jsx)(m.Button,{className:`univer-size-6 univer-p-0`,size:`small`,variant:`text`,disabled:n>=i||a,onClick:()=>v(10),children:(0,p.jsx)(w,{})}),(0,p.jsx)(m.DropdownMenu,{align:`end`,items:S,open:h,onOpenChange:g,children:(0,p.jsxs)(m.Button,{size:`small`,variant:`text`,children:[n,`%`]})})]})}const ce=`UI_COLOR_PICKER_COMPONENT`,R=`ui.config`;Symbol(R);const le={};function z(e,t){return function(n,r){t(n,r,e)}}function B(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 ue=(0,c.createIdentifier)(`univer.font-service`),de=[{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 fe=class{constructor(e){this._configService=e,S(this,`fonts$`,new l.BehaviorSubject([]));let t=this._configService.getConfig(R),{customFontFamily:n}=t==null?{}:t,r=[];r=n?Array.isArray(n)?[...de,...n]:n.override?[...n.list]:[...de,...n.list]:[...de],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([...de])}};fe=B([z(0,c.IConfigService)],fe);const pe=({id:e,value:t,disabled$:n})=>{let r=(0,f.useObservable)(n),i=(0,f.useDependency)(c.ICommandService),a=(0,f.useDependency)(c.LocaleService),o=(0,f.useDependency)(ue),[s,l]=(0,d.useState)(``),[u,m]=(0,d.useState)([]);(0,d.useEffect)(()=>{let e=o.fonts$.subscribe(e=>{m(e)});return()=>{e.unsubscribe()}},[]);let h=(0,d.useMemo)(()=>{if(t==null)return``;let e=`${t==null?``:t}`.replace(/\s/g,``),n=u.find(t=>t.value===e);return n?a.t(n.label):a.t(t)},[t,u]);(0,d.useMemo)(()=>{l(h)},[t]);function g(){l(t)}function _(e){l(e.target.value)}function v(e){e.stopPropagation(),!r&&(e.key===`Enter`?b():e.key===`Escape`&&(e.preventDefault(),g()))}function y(){s!==t&&g()}function b(){if(s.toLowerCase()===t.toLowerCase()){g();return}let e=u.find(e=>e.value.toLowerCase()===s.trim().toLowerCase());if(!e){g();return}x(e.value)}function x(t){i.executeCommand(e,{value:t})}return(0,p.jsx)(`div`,{className:`univer-w-32 univer-truncate univer-text-sm`,style:{fontFamily:t},children:(0,p.jsx)(`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:_,onKeyDown:v,onBlur:y,disabled:r})})},me=({id:e,value:t})=>{let n=(0,f.useDependency)(c.ICommandService),r=(0,f.useDependency)(ue),[i,a]=(0,d.useState)([]);(0,d.useEffect)(()=>{let e=r.fonts$.subscribe(e=>{a(e)});return()=>{e.unsubscribe()}},[]);let o=(0,f.useDependency)(c.LocaleService);function s(t){n.executeCommand(e,{value:t})}return(0,p.jsx)(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-sm`,style:{fontFamily:t},children:i.map(e=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`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)&&(0,p.jsx)(m.Tooltip,{title:o.t(`fontFamily.not-supported`),children:(0,p.jsx)(u.InfoIcon,{className:`univer-text-gray-300 dark:!univer-text-gray-400`})})]})},e.value))})},he=`UI_FONT_FAMILY_COMPONENT`,ge=`UI_FONT_FAMILY_ITEM_COMPONENT`,_e=e=>{let{value:t,min:n,max:r,onChange:i,disabled$:a}=e,o=(0,f.useObservable)(a),[s,c]=(0,d.useState)(Number(t==null?0:t)),l=(0,d.useMemo)(()=>Number(t==null?s:t),[t]);function u(e){e!==null&&c(e)}function h(e){e.stopPropagation(),e.code===`Enter`&&i(s)}return(0,p.jsx)(`div`,{className:`univer-h-6 univer-w-7 univer-text-sm`,children:(0,p.jsx)(m.InputNumber,{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:h,onChange:u,disabled:o})})},ve=[{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}],ye=[{label:`toolbar.heading.normal`,value:c.NamedStyleType.NORMAL_TEXT},{label:`toolbar.heading.title`,value:c.NamedStyleType.TITLE},{label:`toolbar.heading.subTitle`,value:c.NamedStyleType.SUBTITLE},{label:`toolbar.heading.1`,value:c.NamedStyleType.HEADING_1},{label:`toolbar.heading.2`,value:c.NamedStyleType.HEADING_2},{label:`toolbar.heading.3`,value:c.NamedStyleType.HEADING_3},{label:`toolbar.heading.4`,value:c.NamedStyleType.HEADING_4},{label:`toolbar.heading.5`,value:c.NamedStyleType.HEADING_5}],be=`UI_FONT_SIZE_COMPONENT`,xe=(e,t)=>{let n=(0,d.useRef)(!1);(0,d.useEffect)(()=>{if(n.current)return e();n.current=!0},t)};function Se(e,t){let n=L(t.handler);(0,d.useEffect)(()=>{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 Ce(e,t=300){let n=(0,d.useRef)(null);return(0,d.useCallback)((...r)=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{e(...r)},t)},[e,t])}const we=e=>typeof e==`number`;function Te(e){let t=(0,d.useRef)(e);return t.current=e,t}const Ee=(e,t)=>{let{containerTarget:n,itemHeight:r,overscan:i=5}=t,a=Te(r),[o,s]=(0,d.useState)(null),c=(0,d.useRef)(!1),[l,u]=(0,d.useState)([]),[f,p]=(0,d.useState)({height:void 0,marginTop:void 0}),m=(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},h=t=>{if(we(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},g=t=>typeof a.current==`number`?t*a.current:e.slice(0,t).reduce((t,n,r)=>t+a.current(r,e[r]),0),_=(0,d.useMemo)(()=>we(a.current)?e.length*a.current:e.reduce((t,n,r)=>t+a.current(r,e[r]),0),[e]),v=()=>{let t=n.current;if(t){let{scrollTop:n,clientHeight:r}=t,a=h(n),o=m(r,a),s=Math.max(0,a-i),c=Math.min(e.length,a+o+i),l=g(s);p({height:`${_-l}px`,marginTop:`${l}px`}),u(e.slice(s,c).map((e,t)=>({data:e,index:t+s})))}};return(0,d.useEffect)(()=>{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()}}},[]),(0,d.useEffect)(()=>{!(o!=null&&o.width)||!(o!=null&&o.height)||v()},[o==null?void 0:o.width,o==null?void 0:o.height,e]),[l,{wrapperStyle:f,scrollTo:L(e=>{let t=n.current;t&&(c.current=!0,t.scrollTop=g(e),v())}),containerProps:{onScroll:e=>{if(c.current){c.current=!1;return}e.preventDefault(),v()}}}]};function De(e,t,...n){return e.t(t)}function Oe(e){let{barColor:t,progress:n,onTerminate:r,onClearProgress:i}=e,{count:a,done:o,label:s=``}=n,c=(0,d.useRef)(null),[l,f]=(0,d.useState)(!1);return(0,d.useEffect)(()=>{let e=c.current;if(a===0&&o===0){f(!1),e.style.width=`0%`;return}else if(a>0){f(!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&&(f(!1),i&&i())};return e.addEventListener(`transitionend`,t),()=>{e.removeEventListener(`transitionend`,t)}},[a,o]),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-mx-2 univer-flex univer-items-center univer-gap-2`,{"univer-flex":l,"univer-hidden univer-w-0":!l}),children:[(0,p.jsx)(m.Tooltip,{showIfEllipsis:!0,title:s,children:(0,p.jsx)(`span`,{className:`univer-w-24 univer-truncate univer-text-right univer-text-xs`,children:s})}),(0,p.jsx)(`div`,{className:`univer-h-1 univer-w-40 univer-overflow-hidden univer-rounded-lg univer-bg-gray-200`,children:(0,p.jsx)(`div`,{ref:c,className:`univer-h-full univer-bg-primary-600 univer-transition-[width]`,style:{backgroundColor:t}})}),(0,p.jsx)(`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:(0,p.jsx)(u.CloseIcon,{className:`univer-size-3.5 dark:!univer-text-white`})})]})}const ke=(0,c.createIdentifier)(`ui.message.service`);let Ae=class extends c.Disposable{constructor(e,t){super(),this._errorService=e,this._messageService=t,this.disposeWithMe(this._errorService.error$.subscribe(e=>{this._messageService.show({content:e.errorKey,type:m.MessageType.Error})}))}};Ae=B([z(0,(0,c.Inject)(c.ErrorService)),z(1,ke)],Ae);const je=`univer.command.copy`,Me={id:je,name:je,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:()=>!0},Ne=`univer.command.cut`,Pe={id:Ne,name:Ne,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:async()=>!0},Fe=`univer.command.paste`,Ie={id:Fe,name:Fe,multi:!0,priority:0,type:c.CommandType.COMMAND,preconditions:()=>!1,handler:()=>!0};let V=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 Le={[V.BACKSPACE]:`Backspace`,[V.TAB]:`Tab`,[V.ENTER]:`Enter`,[V.DELETE]:`Del`,[V.ESC]:`Esc`,[V.SPACE]:`Space`,[V.ARROW_LEFT]:`←`,[V.ARROW_RIGHT]:`→`,[V.ARROW_UP]:`↑`,[V.ARROW_DOWN]:`↓`,[V.Digit0]:`0`,[V.Digit1]:`1`,[V.Digit2]:`2`,[V.Digit3]:`3`,[V.Digit4]:`4`,[V.Digit5]:`5`,[V.Digit6]:`6`,[V.Digit7]:`7`,[V.Digit8]:`8`,[V.Digit9]:`9`,[V.A]:`A`,[V.B]:`B`,[V.C]:`C`,[V.D]:`D`,[V.E]:`E`,[V.F]:`F`,[V.G]:`G`,[V.H]:`H`,[V.I]:`I`,[V.J]:`J`,[V.K]:`K`,[V.L]:`L`,[V.M]:`M`,[V.N]:`N`,[V.O]:`O`,[V.P]:`P`,[V.Q]:`Q`,[V.R]:`R`,[V.S]:`S`,[V.T]:`T`,[V.U]:`U`,[V.V]:`V`,[V.W]:`W`,[V.X]:`X`,[V.Y]:`Y`,[V.Z]:`Z`,[V.F1]:`F1`,[V.F2]:`F2`,[V.F3]:`F3`,[V.F4]:`F4`,[V.F5]:`F5`,[V.F6]:`F6`,[V.F7]:`F7`,[V.F8]:`F8`,[V.F9]:`F9`,[V.F10]:`F10`,[V.F11]:`F11`,[V.F12]:`F12`,[V.MINUS]:`-`,[V.EQUAL]:`=`,[V.PERIOD]:`.`,[V.COMMA]:`,`,[V.BACK_SLASH]:`\\`};let H=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 Re(e,t,n){return window.addEventListener(e,t,n),(0,c.toDisposable)(()=>window.removeEventListener(e,t,n))}const ze=[`app-layout`,`button`,`sheet-bar-append-button`,`render-canvas`,`workbench-layout`],U=(0,c.createIdentifier)(`ui.layout-service`);let Be=class extends c.Disposable{get isFocused(){return this._isFocused}constructor(e,t){super(),this._contextService=e,this._univerInstanceService=t,S(this,`_rootContainerElement`,null),S(this,`_isFocused`,!1),S(this,`_focusHandlers`,new Map),S(this,`_contentElements`,[]),S(this,`_allContainers`,[]),this._initUniverFocusListener(),this._initEditorStatus()}get rootContainerElement(){return this._rootContainerElement}focus(){let e=this._univerInstanceService.getFocusedUnit();if(!e)return;let t;e instanceof c.Workbook?t=this._focusHandlers.get(c.UniverInstanceType.UNIVER_SHEET):e instanceof c.DocumentDataModel?t=this._focusHandlers.get(c.UniverInstanceType.UNIVER_DOC):e instanceof c.SlideDataModel&&(t=this._focusHandlers.get(c.UniverInstanceType.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),(0,c.toDisposable)(()=>this._focusHandlers.delete(e))}registerContentElement(e){if(this._contentElements.indexOf(e)===-1)return this._contentElements.push(e),(0,c.toDisposable)(()=>(0,c.remove)(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(0,c.toDisposable)(()=>{this._rootContainerElement=null,t.dispose()})}registerContainerElement(e){if(this._allContainers.indexOf(e)===-1)return this._allContainers.push(e),(0,c.toDisposable)(()=>(0,c.remove)(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((0,l.fromEvent)(window,`focusin`).subscribe(e=>{var t;let n=e.target;if((t=this._rootContainerElement)!=null&&t.contains(n)&&ze.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(c.FOCUSING_UNIVER_EDITOR,Ve())}))}_initEditorStatus(){this._contextService.setContextValue(c.FOCUSING_UNIVER_EDITOR,Ve())}};Be=B([z(0,c.IContextService),z(1,c.IUniverInstanceService)],Be);function Ve(){var e;return((e=document.activeElement)==null?void 0:e.dataset.uComp)===`editor`}const He=(0,c.createIdentifier)(`ui.platform.service`);var Ue=class{get isMac(){return/Mac/.test(navigator.appVersion)}get isWindows(){return/Windows/.test(navigator.appVersion)}get isLinux(){return/Linux/.test(navigator.appVersion)}};const We=(0,c.createIdentifier)(`ui.shortcut.service`);let Ge=class extends c.Disposable{constructor(e,t,n,r){super(),this._commandService=e,this._platformService=t,this._contextService=n,this._layoutService=r,S(this,`_shortCutMapping`,new Map),S(this,`_commandIDMapping`,new Map),S(this,`_shortcutChanged$`,new l.Subject),S(this,`shortcutChanged$`,this._shortcutChanged$.asObservable()),S(this,`_forceEscaped`,!1),S(this,`_forceDisabled`,!1),this.disposeWithMe(Re(`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(0,c.toDisposable)(()=>{});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(),(0,c.toDisposable)(()=>{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&H.CTRL_COMMAND,i=n&H.SHIFT,a=n&H.ALT,o=n&H.MAC_CTRL,s=(t=Le[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,(0,c.toDisposable)(()=>this._forceEscaped=!1)}forceDisable(){return this._forceDisabled=!0,(0,c.toDisposable)(()=>{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|=H.SHIFT),r&&(a|=H.ALT),(this._platformService.isMac?n:e.ctrlKey)&&(a|=H.CTRL_COMMAND),this._platformService.isMac&&e.ctrlKey&&(a|=H.MAC_CTRL),a}};Ge=B([z(0,c.ICommandService),z(1,He),z(2,c.IContextService),z(3,(0,c.Optional)(U))],Ge);function Ke(e){return e.getContextValue(c.FOCUSING_UNIVER_EDITOR)}function qe(e){return e.getContextValue(c.FOCUSING_UNIVER_EDITOR)&&!(e.getContextValue(c.EDITOR_ACTIVATED)||e.getContextValue(c.FOCUSING_FX_BAR_EDITOR))}const Je={id:Me.id,description:`shortcut.copy`,group:`1_common-edit`,binding:V.C|H.CTRL_COMMAND,preconditions:Ke},Ye={id:Pe.id,description:`shortcut.cut`,group:`1_common-edit`,binding:V.X|H.CTRL_COMMAND,preconditions:Ke},Xe={id:Ie.id,description:`shortcut.paste`,group:`1_common-edit`,binding:V.V|H.CTRL_COMMAND,preconditions:()=>!1},Ze={id:c.UndoCommand.id,description:`shortcut.undo`,group:`1_common-edit`,binding:V.Z|H.CTRL_COMMAND,preconditions:qe},Qe={id:c.RedoCommand.id,description:`shortcut.redo`,group:`1_common-edit`,binding:V.Y|H.CTRL_COMMAND,preconditions:qe};let $e=class extends c.Disposable{constructor(e,t){super(),this._shortcutService=e,this._commandService=t,this.initialize()}initialize(){this._registerCommands(),this._registerShortcuts()}_registerCommands(){[Pe,Me,Ie].forEach(e=>this.disposeWithMe(this._commandService.registerMultipleCommand(e)))}_registerShortcuts(){let e=[Ze,Qe];e.push(Ye,Je,Xe),e.forEach(e=>this.disposeWithMe(this._shortcutService.registerShortcut(e)))}};$e=B([z(0,We),z(1,c.ICommandService)],$e);let et=function(e){return e.RIBBON=`ribbon`,e.CONTEXT_MENU=`contextMenu`,e}({}),W=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}({}),G=function(e){return e.HISTORY=`ribbon.start.history`,e.FORMAT=`ribbon.start.format`,e.LAYOUT=`ribbon.start.layout`,e.OTHERS=`ribbon.start.others`,e}({}),tt=function(e){return e.EDIT=`ribbon.insert.edit`,e.MEDIA=`ribbon.insert.media`,e.OTHERS=`ribbon.insert.others`,e}({}),nt=function(e){return e.BASIC=`ribbon.formulas.basic`,e.OTHERS=`ribbon.formulas.others`,e}({}),rt=function(e){return e.FORMULAS=`ribbon.data.formulas`,e.RULES=`ribbon.data.rules`,e.ORGANIZATION=`ribbon.data.organization`,e.OTHERS=`ribbon.data.others`,e}({}),it=function(e){return e.DISPLAY=`ribbon.view.display`,e.VISIBILITY=`ribbon.view.Visibility`,e.OTHERS=`ribbon.view.others`,e}({}),at=function(e){return e.OTHERS=`ribbon.others.others`,e}({}),K=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=(0,c.createIdentifier)(`univer.menu-manager-service`);let ot=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._configService=t,S(this,`menuChanged$`,new l.Subject),S(this,`_menu`,{[et.RIBBON]:{[W.START]:{order:0,[G.HISTORY]:{order:0},[G.FORMAT]:{order:1},[G.LAYOUT]:{order:2},[G.OTHERS]:{order:3}},[W.INSERT]:{order:1,[tt.EDIT]:{order:0},[tt.MEDIA]:{order:1},[tt.OTHERS]:{order:2}},[W.FORMULAS]:{order:2,[nt.BASIC]:{order:0},[nt.OTHERS]:{order:1}},[W.DATA]:{order:3,[rt.FORMULAS]:{order:0},[rt.RULES]:{order:1},[rt.ORGANIZATION]:{order:2},[rt.OTHERS]:{order:3}},[W.VIEW]:{order:4,[it.DISPLAY]:{order:0},[it.VISIBILITY]:{order:0},[it.OTHERS]:{order:0}},[W.OTHERS]:{order:5,[at.OTHERS]:{order:0}}},[et.CONTEXT_MENU]:{[K.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}},[K.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}},[K.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}},[K.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}},[K.FOOTER_TABS]:{order:3,[q.FORMAT]:{order:0},[q.LAYOUT]:{order:1},[q.DATA]:{order:2},[q.OTHERS]:{order:3}},[K.FOOTER_MENU]:{order:4,[q.OTHERS]:{order:3}},[K.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]=(0,c.merge)({},n[r],e[r]),this.menuChanged$.next()}else typeof r==`object`&&this.mergeMenu(e,r)}appendRootMenu(e){this._menu=(0,c.merge)({},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=N(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)}};ot=B([z(0,(0,c.Inject)(c.Injector)),z(1,c.IConfigService)],ot);function st(){let e=(0,f.useDependency)(We),t=(0,f.useDependency)(c.LocaleService),n=(0,f.useObservable)(t.currentLocale$),[r,i]=(0,d.useState)([]),a=(0,d.useCallback)(()=>{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:(0,c.dedupeBy)(n,e=>e.title+e.shortcut)}}).sort((e,t)=>e.sequence-t.sequence))},[e,t,n]);return(0,d.useEffect)(()=>{a();let t=e.shortcutChanged$.subscribe(()=>a());return()=>t.unsubscribe()},[e,a]),(0,p.jsx)(`ul`,{className:`univer-m-0 univer-list-none univer-p-0 univer-text-gray-900 dark:!univer-text-white`,children:r.map(e=>(0,p.jsxs)(`li`,{children:[(0,p.jsx)(`div`,{className:`univer-flex univer-h-10 univer-items-center univer-text-sm univer-font-semibold`,children:e.name}),(0,p.jsx)(`ul`,{className:(0,m.clsx)(`univer-list-none univer-p-0`,m.divideYClassName),children:e.items.map(e=>(0,p.jsxs)(`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:[(0,p.jsx)(`span`,{className:`univer-line-clamp-2`,children:e.title}),e.shortcut&&(0,p.jsx)(m.KBD,{keyboard:e.shortcut})]},`${e.title}-${e.shortcut}`))})]},e.name))})}const ct={id:D.id,binding:H.CTRL_COMMAND|V.BACK_SLASH,description:`shortcut.shortcut-panel`,group:`10_global-shortcut`};let lt=class extends c.Disposable{constructor(e,t,n,r,i){super(),this._menuManagerService=r,this.disposeWithMe(t.register(E,st)),this.disposeWithMe(i.registerCommand(D)),this.disposeWithMe(n.registerShortcut(ct))}};lt=B([z(0,(0,c.Inject)(c.Injector)),z(1,(0,c.Inject)(k)),z(2,We),z(3,J),z(4,c.ICommandService)],lt);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 ut(e){return e.type===Y.BUTTON_SELECTOR}const dt=(e,t)=>{let n=e.get(c.IUndoRedoService),r=e.get(c.IContextService);return(0,l.combineLatest)([n.undoRedoStatus$.pipe((0,g.map)(e=>t?e.undos<=0:e.redos<=0)),(0,l.merge)([(0,l.of)({}),r.contextChanged$])]).pipe((0,g.map)(([e])=>e||r.getContextValue(c.EDITOR_ACTIVATED)||r.getContextValue(c.FOCUSING_FX_BAR_EDITOR)))};function ft(e){return{id:c.UndoCommand.id,type:Y.BUTTON,icon:`UndoIcon`,title:`Undo`,tooltip:`toolbar.undo`,disabled$:dt(e,!0)}}function pt(e){return{id:c.RedoCommand.id,type:Y.BUTTON,icon:`RedoIcon`,title:`Redo`,tooltip:`toolbar.redo`,disabled$:dt(e,!1)}}function mt(){return{id:D.id,title:`toggle-shortcut-panel`,tooltip:`toggle-shortcut-panel`,icon:`ShortcutIcon`,type:Y.BUTTON}}const ht={[G.HISTORY]:{[c.UndoCommand.id]:{order:0,menuItemFactory:ft},[c.RedoCommand.id]:{order:1,menuItemFactory:pt}},[G.OTHERS]:{[D.id]:{order:1,menuItemFactory:mt}}};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=(0,c.createIdentifier)(`ui.parts.service`);var gt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_componentsByPart`,new Map),S(this,`_componentRegistered$`,new l.Subject),S(this,`componentRegistered$`,this._componentRegistered$.asObservable()),S(this,`_uiVisible`,new Map),S(this,`_uiVisibleChange$`,new l.Subject),S(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),(0,c.toDisposable)(()=>{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])}},_t=class{constructor(){S(this,`_domLayerMap`,new Map),S(this,`_domLayers$`,new l.BehaviorSubject([])),S(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 vt=(0,d.memo)(e=>{var t,n;let{layer:r,id:i}=e,a=(0,d.useMemo)(()=>r.position$.pipe((0,l.distinctUntilChanged)((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$]),o=(0,f.useDependency)(c.IUniverInstanceService),s=(0,f.useObservable)((0,d.useMemo)(()=>r.position$.pipe((0,l.first)()),[r.position$])),u=(0,d.useRef)(null),m=(0,d.useRef)(null),h=(0,d.useRef)(`transform: rotate(${s==null?void 0:s.rotate}deg) translate(${s==null?void 0:s.startX}px, ${s==null?void 0:s.startY}px)`),g=(0,d.useRef)((t=s==null?void 0:s.startY)==null?0:t),_=(0,d.useRef)((n=s==null?void 0:s.startX)==null?0:n),v=(0,d.useRef)({}),y=typeof r.componentKey==`string`?(0,f.useDependency)(k).get(r.componentKey):r.componentKey,b=(0,d.useMemo)(()=>({data:r.data,...r.props}),[r.data,r.props]);(0,d.useEffect)(()=>{let e=r.position$.subscribe(e=>{if(h.current=`rotate(${e.rotate}deg)`,g.current=e.startY,_.current=e.startX,u.current){var t;u.current.style.transform=h.current,u.current.style.top=`${g.current}px`,u.current.style.left=`${_.current}px`,u.current.style.opacity=`${(t=e.opacity)==null?1:t}`}}),t=a.subscribe(e=>{if(u.current&&(u.current.style.width=`${Math.max(e.endX-e.startX-2,0)}px`,u.current.style.height=`${Math.max(e.endY-e.startY-2,0)}px`),m.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}`};m.current.style.width=t.width,m.current.style.height=t.height,m.current.style.left=t.left,m.current.style.top=t.top,m.current.style.right=t.right,m.current.style.bottom=t.bottom,v.current=t}});return()=>{e.unsubscribe(),t.unsubscribe()}},[r.position$,a]);let x=o.getUnit(r.unitId),S=x instanceof c.DocumentDataModel?x.getDisabled():void 0,C=(0,d.useMemo)(()=>y?(0,p.jsx)(y,{...b,unitId:r.unitId,unit:x,floatDomId:r.id,context:{docDisabled:S,root:m}}):null,[y,b]);return s?(0,p.jsx)(`div`,{ref:u,className:`univer-z-10`,style:{position:`absolute`,top:g.current,left:_.current,width:Math.max(s.endX-s.startX-2,0),height:Math.max(s.endY-s.startY-2,0),transform:h.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:(0,p.jsx)(`div`,{id:i,ref:m,className:`univer-absolute univer-overflow-hidden`,style:{...v.current},children:C})}):null}),yt=({unitId:e})=>{var t;let n=(0,f.useDependency)(c.IUniverInstanceService),r=(0,f.useObservable)((0,f.useDependency)(_t).domLayers$),i=(0,f.useObservable)(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(0,p.jsx)(vt,{id:(t=e[1].domId)==null?e[0]:t,layer:e[1]},e[0])})},bt=(0,c.createIdentifier)(`ui.popup.service`);var xt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_popupMap`,new Map),S(this,`_popups$`,new l.BehaviorSubject([])),S(this,`popups$`,this._popups$.asObservable()),S(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=(0,c.generateRandomId)();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 St=(0,d.createContext)({current:void 0});function Ct(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 wt(e){var t;let{mask:n,portal:r,children:i,anchorRect$:a,direction:o=`vertical`,onClickOutside:s,excludeOutside:l,excludeRects:u,onPointerEnter:h,onPointerLeave:g,onClick:v,hidden:y,onContextMenu:b,zIndex:x=1020,maskZIndex:S=100,onMaskClick:C,noPushMinimumGap:w,autoRelayout:T=!0}=e,E=(0,d.useRef)(null),D=L(s==null?(()=>{}):s),O=L(b==null?(()=>{}):b),k=(0,d.useRef)({top:-9999,left:-9999}),A=u,j=(0,f.useDependency)(c.IConfigService),M=(0,d.useRef)(void 0),N=j.getConfig(R),ee=(t=N==null?void 0:N.popupRootId)==null?`univer-popup-portal`:t,te=L(e=>{requestAnimationFrame(()=>{if(!E.current)return;let{clientWidth:t,clientHeight:n}=E.current,r=window.innerWidth,i=window.innerHeight;k.current=Ct({position:e,width:t,height:n,containerWidth:r,containerHeight:i,direction:o,noPushMinimumGap:w}),E.current.style.top=`${k.current.top}px`,E.current.style.left=`${k.current.left}px`})});(0,d.useEffect)(()=>{let e;return E.current&&(e=new ResizeObserver(()=>{T&&M.current&&te(M.current)}),e.observe(E.current)),()=>{e==null||e.disconnect()}},[E.current,T]),(0,d.useEffect)(()=>{let e=a.subscribe(e=>{M.current=e,te(e)});return()=>e.unsubscribe()},[a,o]),(0,d.useEffect)(()=>{let e=e=>{var t;if(l&&(l.indexOf(e.target)>-1||l.some(t=>t.contains(e.target))))return;let n=e.clientX,r=e.clientY,i=[...(t=A==null?void 0:A.current)==null?[]:t];M.current&&i.push(M.current);for(let e of i)if(n<=e.right&&n>=e.left&&r<=e.bottom&&r>=e.top)return;D(e)};return window.addEventListener(`pointerdown`,e),()=>{window.removeEventListener(`pointerdown`,e)}},[D,l,A]),(0,d.useEffect)(()=>{let e=e=>{e.ctrlKey&&e.button===0||O()};return window.addEventListener(`contextmenu`,e),()=>{window.removeEventListener(`contextmenu`,e)}},[O]);let P=(0,p.jsxs)(p.Fragment,{children:[n&&(0,p.jsx)(`div`,{"data-u-comp":`rect-popup-mask`,className:`univer-fixed univer-inset-0 univer-z-[100]`,style:{zIndex:S},onClick:C}),(0,p.jsx)(`section`,{"data-u-comp":`rect-popup`,ref:E,className:(0,m.clsx)(`univer-pointer-events-auto univer-fixed univer-left-[-9999px] univer-top-[-9999px] univer-z-[1020]`,{"univer-hidden":y,"univer-animate-in univer-fade-in-70":!y}),style:{...k.current,zIndex:x},onPointerDown:e=>e.stopPropagation(),onClick:v,onPointerEnter:h,onPointerLeave:g,children:(0,p.jsx)(St.Provider,{value:M,children:i})})]});return r?document.getElementById(ee)?(0,_.createPortal)(P,document.getElementById(ee)):null:P}wt.calcPopupPosition=Ct,wt.useContext=()=>(0,d.useContext)(St);const Tt=({popup:e,children:t})=>{let[n,r]=(0,d.useState)(!1),i=(0,d.useMemo)(()=>e.anchorRect$.pipe((0,l.throttleTime)(0,l.animationFrameScheduler),(0,l.map)(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=(0,d.useMemo)(()=>{var t,n;return(t=(n=e.hiddenRects$)==null?void 0:n.pipe((0,l.throttleTime)(0,l.animationFrameScheduler)))==null?(0,l.of)([]):t},[e.hiddenRects$]),o=P((0,d.useMemo)(()=>{var t;return(t=e.excludeRects$)==null?void 0:t.pipe((0,l.throttleTime)(0,l.animationFrameScheduler))},[e.excludeRects$]),e.excludeRects),{canvasElement:s,hideOnInvisible:c=!0,hiddenType:u=`destroy`}=e;return(0,d.useEffect)(()=>{if(!c)return;let e=(0,l.combineLatest)([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&&u===`destroy`?null:(0,p.jsx)(wt,{...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 Et(){let e=(0,f.useDependency)(bt),t=(0,f.useDependency)(k);return(0,f.useObservable)(e.popups$,void 0,!0).map(e=>{let[n,r]=e,i=t.get(r.componentKey);return(0,p.jsx)(Tt,{popup:r,children:i?(0,p.jsx)(i,{popup:r}):null},n)})}const Dt=(0,c.createIdentifier)(`univer.ribbon-service`);let Ot=class extends c.Disposable{constructor(e,t){super(),this._menuManagerService=e,this._univerInstanceService=t,S(this,`_ribbon$`,new l.BehaviorSubject([])),S(this,`ribbon$`,this._ribbon$.asObservable()),S(this,`_activatedTab$`,new l.BehaviorSubject(W.START)),S(this,`activatedTab$`,this._activatedTab$.asObservable()),S(this,`_collapsedIds$`,new l.BehaviorSubject([])),S(this,`collapsedIds$`,this._collapsedIds$.asObservable()),S(this,`_fakeToolbarVisible$`,new l.BehaviorSubject(!1)),S(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((0,l.combineLatest)([this._menuManagerService.menuChanged$.pipe((0,g.startWith)(void 0)),this._univerInstanceService.focused$.pipe((0,g.startWith)(void 0))]).subscribe(()=>{this._updateRibbon()}))}_updateRibbon(){let e=this._menuManagerService.getMenuByPositionKey(et.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}(0,l.combineLatest)(t).pipe((0,g.startWith)(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()}};Ot=B([z(0,J),z(1,c.IUniverInstanceService)],Ot);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(0,d.createElement)(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?(0,f.useDependency)(Z):n,i=(0,f.useObservable)((0,d.useMemo)(()=>r.uiVisibleChange$.pipe((0,l.filter)(t=>t.ui===e)),[e,r])),a=(0,d.useRef)(0);return(0,d.useMemo)(()=>r.isUIVisible(e)?r.getComponents(e):new Set,[(0,f.useObservable)(()=>r.componentRegistered$.pipe((0,l.filter)(t=>t===e),(0,l.debounceTime)(200),(0,l.map)(()=>a.current+=1),(0,l.startWith)(a.current+=1)),void 0,void 0,[r,e,i])])}function kt({ribbon:e,activatedTab:t,onSelectTab:n}){let r=(0,f.useDependency)(c.LocaleService);return(0,p.jsx)(`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(0,p.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i,title:r.t(e.key),onClick:()=>n(e),className:(0,m.clsx)(`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?`
|
|
60
2
|
univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-sm
|
|
61
3
|
dark:!univer-bg-primary-900 dark:!univer-text-primary-300
|
|
62
4
|
`:`
|
|
@@ -64,115 +6,22 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
64
6
|
dark:!univer-hover:bg-gray-700
|
|
65
7
|
univer-bg-transparent univer-text-gray-700
|
|
66
8
|
dark:!univer-text-gray-200
|
|
67
|
-
`),children:r.t(e.key)},e.key)})})}const At={[
|
|
68
|
-
univer-box-border univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5
|
|
69
|
-
univer-rounded-lg univer-px-2 univer-py-1.5
|
|
70
|
-
hover:univer-bg-gray-100
|
|
71
|
-
dark:hover:!univer-bg-gray-700
|
|
72
|
-
`,role:`button`,onClick:()=>o(e),children:[(0,p.jsx)(`span`,{className:(0,m.clsx)(`
|
|
73
|
-
univer-box-border univer-flex univer-size-9 univer-flex-shrink-0
|
|
74
|
-
univer-items-center univer-justify-center univer-rounded-lg
|
|
75
|
-
`,m.borderClassName),children:(0,p.jsx)(t,{className:`
|
|
76
|
-
univer-text-gray-500
|
|
77
|
-
dark:!univer-text-gray-300
|
|
78
|
-
`})}),(0,p.jsxs)(`span`,{className:`univer-flex univer-flex-col`,children:[(0,p.jsx)(`strong`,{className:`
|
|
79
|
-
univer-text-sm univer-font-semibold univer-text-gray-800
|
|
80
|
-
dark:!univer-text-gray-200
|
|
81
|
-
`,children:r.t(e.key)}),(0,p.jsx)(`span`,{className:`univer-text-xs univer-text-gray-400`,children:r.t(`${e.key}Desc`)})]})]},e.key)})}),onOpenChange:a,children:(0,p.jsxs)(`a`,{className:`
|
|
82
|
-
univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5
|
|
83
|
-
univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2
|
|
84
|
-
univer-text-sm univer-text-white
|
|
85
|
-
dark:!univer-bg-gray-200 dark:!univer-text-gray-800
|
|
86
|
-
`,onClick:()=>a(!0),children:[r.t(t),(0,p.jsx)(u.MoreDownIcon,{className:`
|
|
87
|
-
univer-text-gray-200
|
|
88
|
-
dark:!univer-text-gray-500
|
|
89
|
-
`})]})})}const Mt=`
|
|
9
|
+
`),children:r.t(e.key)},e.key)})})}const At={[W.START]:u.HomeIcon,[W.INSERT]:u.InsertIcon,[W.FORMULAS]:u.FunctionIcon,[W.DATA]:u.DatabaseIcon,[W.VIEW]:u.EyeIcon,[W.OTHERS]:u.MoreFunctionIcon};function jt({ribbon:e,activatedTab:t,onSelectTab:n}){let r=(0,f.useDependency)(c.LocaleService),[i,a]=(0,d.useState)(!1);function o(e){n(e),a(!1)}return(0,p.jsx)(m.HoverCard,{className:`univer-max-w-96 !univer-rounded-xl`,align:`start`,open:i,overlay:(0,p.jsx)(`div`,{className:`univer-grid univer-gap-1 univer-px-2 univer-py-1`,children:e.map(e=>{let t=At[e.key];return(0,p.jsxs)(`a`,{"data-u-comp":`ribbon-group-btn`,className:`univer-box-border univer-flex univer-cursor-pointer univer-items-center univer-gap-2.5 univer-rounded-lg univer-px-2 univer-py-1.5 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,role:`button`,onClick:()=>o(e),children:[(0,p.jsx)(`span`,{className:(0,m.clsx)(`univer-box-border univer-flex univer-size-9 univer-flex-shrink-0 univer-items-center univer-justify-center univer-rounded-lg`,m.borderClassName),children:(0,p.jsx)(t,{className:`univer-text-gray-500 dark:!univer-text-gray-300`})}),(0,p.jsxs)(`span`,{className:`univer-flex univer-flex-col`,children:[(0,p.jsx)(`strong`,{className:`univer-text-sm univer-font-semibold univer-text-gray-800 dark:!univer-text-gray-200`,children:r.t(e.key)}),(0,p.jsx)(`span`,{className:`univer-text-xs univer-text-gray-400`,children:r.t(`${e.key}Desc`)})]})]},e.key)})}),onOpenChange:a,children:(0,p.jsxs)(`a`,{className:`univer-mr-2 univer-flex univer-h-7 univer-cursor-pointer univer-items-center univer-gap-1.5 univer-whitespace-nowrap !univer-rounded-full univer-bg-gray-700 univer-pl-3 univer-pr-2 univer-text-sm univer-text-white dark:!univer-bg-gray-200 dark:!univer-text-gray-800`,onClick:()=>a(!0),children:[r.t(t),(0,p.jsx)(u.MoreDownIcon,{className:`univer-text-gray-200 dark:!univer-text-gray-500`})]})})}const Mt=`
|
|
90
10
|
univer-box-border univer-flex univer-h-6 univer-min-w-6 univer-cursor-pointer univer-items-center
|
|
91
11
|
univer-justify-center univer-rounded univer-border-none univer-bg-transparent univer-p-0
|
|
92
12
|
univer-text-gray-900 univer-outline-none univer-transition-colors univer-animate-in univer-fade-in
|
|
93
13
|
dark:!univer-text-white dark:hover:!univer-bg-gray-700 dark:disabled:!univer-text-gray-600
|
|
94
14
|
disabled:univer-cursor-not-allowed disabled:univer-text-gray-300 disabled:hover:univer-bg-transparent
|
|
95
15
|
hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
96
|
-
`;function Nt(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(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(Mt,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 Pt(e){let{disabled$:t,hidden$:n,activated$:r,value$:i}=e,a;if(ut(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]=(0,d.useState)(),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)();return(0,d.useEffect)(()=>{let e=[];return t&&e.push(t.subscribe(e=>u(e))),n&&e.push(n.subscribe(e=>h(e))),r&&e.push(r.subscribe(e=>p(e))),i&&e.push(i.subscribe(e=>c(e))),a&&e.push(a.subscribe(e=>_(e))),()=>e.forEach(e=>e.unsubscribe())},[r,t,n,i,a]),{disabled:l,value:s,activated:f,hidden:m,selectionsValue:g}}const Ft=(0,d.createContext)({dropdownVisible:!1,setDropdownVisible:e=>{}}),It=(0,d.forwardRef)((e,t)=>{let{children:n,...r}=e,i=(0,d.useRef)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1);function l(e){o(s?!1:e)}function u(e){c(e),o(!1)}let f=(0,d.useMemo)(()=>({dropdownVisible:s,setDropdownVisible:u}),[s]);return(0,d.useImperativeHandle)(t,()=>({el:i.current})),r.title?(0,p.jsx)(m.Tooltip,{visible:a,onVisibleChange:l,...r,children:(0,p.jsx)(`span`,{ref:i,children:(0,p.jsx)(Ft.Provider,{value:f,children:n})})}):(0,p.jsx)(`span`,{ref:i,children:n})});function Lt(e){let{children:t,overlay:n,disabled:r,align:i=`start`}=e,{dropdownVisible:a,setDropdownVisible:o}=(0,d.useContext)(Ft);function s(e){o(e)}return(0,p.jsx)(m.Dropdown,{align:i,overlay:(0,p.jsx)(`div`,{className:`univer-grid univer-gap-2`,children:n}),disabled:r,open:a,onOpenChange:s,children:(0,p.jsx)(`div`,{className:`univer-h-full`,onClick:e=>e.stopPropagation(),children:t})})}function Rt({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(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-relative univer-flex univer-items-center univer-gap-2`,{"univer-pl-6":o}),children:[o&&String(t)===String(n.value)&&(0,p.jsx)(u.CheckMarkIcon,{className:`univer-absolute univer-left-1 univer-top-0.5 univer-text-primary-600`}),(0,p.jsx)(I,{className:`univer-text-sm`,icon:e,value$:n.value$,value:n.value,label:n.label,onChange:a})]})}function zt({menuId:e,slot:t,value:n,options:r,children:i,disabled:a,onOptionSelect:o}){let{dropdownVisible:s,setDropdownVisible:c}=(0,d.useContext)(Ft),u=(0,f.useDependency)(J),[h,g]=(0,d.useState)({}),_=(0,d.useMemo)(()=>e?u.getMenuByPositionKey(e):[],[e]),v=(0,d.useMemo)(()=>_.filter(e=>{var t;return e.children?!h[((t=e.key)==null?void 0:t.toString())||``]:!h[e.key]}),[_,h]);function y(e){c(e)}if((0,d.useEffect)(()=>{let e=[];return _.forEach(t=>{if(t.children){let n=(0,l.combineLatest)(t.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?(0,l.of)(!1):t})).subscribe(e=>{let n=e.every(e=>e===!0);g(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=>{g(n=>({...n,[t.key]:e}))});e.push(n)}}}),()=>{e.forEach(e=>e==null?void 0:e.unsubscribe()),g({})}},[_]),t)return(0,p.jsx)(Lt,{disabled:a,overlay:r.map((e,t)=>(0,p.jsx)(Rt,{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:(0,m.clsx)({"focus:univer-bg-white":typeof e.label!=`string`&&((t=e.label)==null?void 0:t.hoverable)===!1}),children:(0,p.jsx)(Rt,{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 v){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:(0,p.jsx)(Rt,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}return(0,p.jsx)(m.DropdownMenu,{align:`start`,items:e,disabled:a,open:s,onOpenChange:y,children:i})}else{let e=[];for(let t of v){var b;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:(0,p.jsx)(Rt,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}else (b=t.children)!=null&&b.length}return(0,p.jsx)(m.DropdownMenu,{align:`start`,items:e,disabled:a,open:s,onOpenChange:y,children:i})}}const Bt=(0,d.forwardRef)((e,t)=>{let n=(0,f.useDependency)(c.LocaleService),r=(0,f.useDependency)(c.ICommandService),i=(0,f.useDependency)(U),a=(0,f.useDependency)(k),{value:o,hidden:s,disabled:h,activated:g,selectionsValue:_}=Pt(e),v=(e,t)=>{i.focus(),r.executeCommand(e,t)},{tooltip:y,shortcut:b,icon:x,title:S,label:C,id:w,commandId:T,type:E,slot:D,params:O}=e,A=n.t(y==null?``:y)+(b?` (${b})`:``),{selections:j}=e,M=(0,f.useObservable)((0,d.useMemo)(()=>(0,l.isObservable)(j)?j:new l.Observable(e=>{e.next(j)}),[j])),N=(0,f.useObservable)((0,d.useMemo)(()=>(0,l.isObservable)(x)?x:new l.Observable(e=>{var t,n;let r=(t=M==null||(n=M.find(e=>e.value===o))==null?void 0:n.icon)==null?x:t;e.next(r)}),[x,M,o]),void 0,!0);function ee(t){var n;let r=e.selectionsCommandId,i=T==null?w:T,a=(n=r==null?T:r)==null?w:n;function s(e){if(h)return;let t=a;e.id&&(t=e.id),v(t,{value:e.value})}function c(e){h||v(a,{value:e})}function l(){h||t===Y.BUTTON_SELECTOR&&v(i,{value:o})}return t===Y.BUTTON_SELECTOR?(0,p.jsxs)(`div`,{"data-u-command":w,"data-disabled":h,className:(0,m.clsx)(`
|
|
97
|
-
|
|
98
|
-
univer-flex univer-h-6 univer-cursor-pointer univer-items-center univer-rounded univer-pr-5
|
|
99
|
-
univer-text-sm univer-transition-colors
|
|
100
|
-
hover:univer-bg-gray-100
|
|
101
|
-
dark:hover:!univer-bg-gray-700
|
|
102
|
-
`,{"univer-text-gray-900 dark:!univer-text-white":!h,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h}),children:[(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
103
|
-
univer-toolbar-button-selector-main univer-relative univer-z-[1] univer-flex univer-h-full
|
|
104
|
-
univer-items-center univer-rounded-l univer-px-1 univer-transition-colors
|
|
105
|
-
hover:univer-bg-gray-200
|
|
106
|
-
dark:hover:!univer-bg-gray-600
|
|
107
|
-
`,{"univer-bg-gray-200 dark:!univer-bg-gray-500":g,"univer-bg-gray-100":g&&h}),onClick:l,children:(0,p.jsx)(I,{icon:N,title:S,value:_==null?o:_,label:C,onChange:c})}),(0,p.jsx)(zt,{menuId:w,slot:D,value:o,options:M,disabled:h,onOptionSelect:s,children:(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
108
|
-
univer-toolbar-button-selector-trigger univer-absolute univer-right-0 univer-top-0
|
|
109
|
-
univer-box-border univer-flex univer-h-6 univer-w-5 univer-items-center
|
|
110
|
-
univer-justify-center univer-rounded-r univer-transition-colors
|
|
111
|
-
hover:univer-bg-gray-200
|
|
112
|
-
dark:hover:!univer-bg-gray-600
|
|
113
|
-
`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h,"univer-bg-gray-200 dark:!univer-bg-gray-500":g,"univer-bg-gray-100":g&&h}),"data-disabled":h,children:(0,p.jsx)(u.MoreDownIcon,{})})})]}):(0,p.jsx)(zt,{menuId:w,slot:D,value:o,options:M,disabled:h,onOptionSelect:s,children:(0,p.jsxs)(`div`,{"data-u-command":w,className:(0,m.clsx)(`
|
|
114
|
-
univer-toolbar-selector-root univer-animate-in univer-fade-in univer-relative univer-flex
|
|
115
|
-
univer-h-6 univer-cursor-pointer univer-items-center univer-gap-2 univer-whitespace-nowrap
|
|
116
|
-
univer-rounded univer-px-1 univer-transition-colors
|
|
117
|
-
hover:univer-bg-gray-100
|
|
118
|
-
dark:hover:!univer-bg-gray-700
|
|
119
|
-
`,{"univer-text-gray-900 dark:!univer-text-white":!h,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h,"univer-bg-gray-200":g,"univer-bg-gray-100":g&&h}),children:[(0,p.jsx)(I,{icon:N,title:S,value:o,label:C,onChange:c}),(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
120
|
-
univer-toolbar-selector-trigger univer-flex univer-h-full univer-items-center
|
|
121
|
-
`,{"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h}),children:(0,p.jsx)(u.MoreDownIcon,{})})]})})}function te(){var t;let n=a.get(typeof C==`string`?C:(t=C==null?void 0:C.name)==null?``:t),r=(o==null?typeof O==`function`:o)?O():O;return(0,p.jsx)(Nt,{"data-u-command":w,className:`univer-text-sm`,noIcon:!x,active:g,disabled:h,onClick:()=>{var t;return v((t=e.commandId)==null?e.id:t,r)},onDoubleClick:()=>e.subId&&v(e.subId),children:n?(0,p.jsx)(I,{title:S,value:o,label:C}):x?(0,p.jsx)(I,{icon:x}):(0,p.jsx)(I,{title:S})})}function P(){switch(E){case Y.BUTTON_SELECTOR:case Y.SELECTOR:case Y.SUBITEMS:return ee(E);case Y.BUTTON:default:return te()}}return!s&&(0,p.jsx)(It,{ref:t,title:A,placement:`bottom`,children:P()})});function Vt(e){let{ribbonType:t,headerMenuComponents:n,headerMenu:r=!0}=e,i=(0,f.useDependency)(Dt),a=(0,f.useDependency)(c.LocaleService),o=(0,d.useRef)(null),s=(0,d.useRef)({}),l=(0,f.useObservable)(i.ribbon$,[]),h=(0,f.useObservable)(i.activatedTab$,G.START),g=(0,f.useObservable)(i.collapsedIds$,[]),_=(0,f.useObservable)(i.fakeToolbarVisible$,!1),v=(0,d.useMemo)(()=>{if(t===`simple`){let e=[{key:G.START,children:[],order:0}];return l.forEach(t=>{var n;(n=t.children)==null||n.forEach(t=>{var n;(n=e[0].children)==null||n.push(t)})}),e}return l},[t,l]),y=(0,d.useCallback)(e=>{s.current={},i.setActivatedTab(e.key)},[]),b=(0,d.useMemo)(()=>{var e,t;let n=(e=(t=v.find(e=>e.key===h))==null?void 0:t.children)==null?[]:e,r=[],i=[];for(let e of n)if(e.children){let t=e.children.filter(e=>!g.includes(e.key));t.length>0&&r.push({...e,children:t}),t.length<e.children.length&&i.push({...e,children:e.children.filter(e=>g.includes(e.key))})}return{allGroups:n,visibleGroups:r,hiddenGroups:i}},[g,v,h]);(0,d.useEffect)(()=>{let e=null,t=new ResizeObserver((0,c.throttle)(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,l=(((e=(t=v.find(e=>e.key===h))==null?void 0:t.children)==null?[]:e).length-1)*8;c+=l;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()}},[v,h]);let x=(0,d.useMemo)(()=>(0,p.jsx)(`div`,{"aria-hidden":`true`,className:(0,m.clsx)(`
|
|
122
|
-
univer-invisible univer-absolute -univer-left-[99999] -univer-top-[99999] univer-box-border
|
|
123
|
-
univer-flex univer-h-10 univer-min-w-min univer-items-center univer-px-3 univer-opacity-0
|
|
124
|
-
`,{"univer-hidden":!_},m.divideXClassName,m.borderBottomClassName),children:b.allGroups.map((e,t)=>{var n,r;return(((n=e.children)==null?void 0:n.length)||e.item)&&(0,p.jsx)(d.Fragment,{children:(0,p.jsx)(`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&&(0,p.jsx)(Bt,{...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)})}),[b.allGroups,_]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{"data-u-comp":`ribbon-header-menu`,className:(0,m.clsx)(`univer-relative univer-select-none`,{"univer-h-9":t===`classic`||n&&n.size>0}),children:[t===`classic`&&v.length>1&&(0,p.jsx)(kt,{ribbon:v,activatedTab:h,onSelectTab:y}),r&&n&&n.size>0&&(0,p.jsx)(`div`,{className:`
|
|
125
|
-
univer-absolute univer-right-2 univer-top-0 univer-flex univer-h-full univer-items-center
|
|
126
|
-
univer-gap-2
|
|
127
|
-
[&>*]:univer-inline-flex [&>*]:univer-h-6 [&>*]:univer-items-center [&>*]:univer-rounded
|
|
128
|
-
[&>*]:univer-px-1 [&>*]:univer-transition-colors
|
|
129
|
-
hover:[&>*]:univer-bg-gray-100
|
|
130
|
-
`,children:(0,p.jsx)(Q,{components:n})})]}),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`
|
|
131
|
-
univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3
|
|
132
|
-
univer-text-sm
|
|
133
|
-
`,{"univer-grid-cols-[1fr] univer-justify-center":t===`classic`,"univer-grid-cols-[auto,1fr]":v.length>1&&t!==`classic`,"univer-grid-cols-none":v.length===1},m.borderBottomClassName),children:[t===`collapsed`&&v.length>1&&(0,p.jsx)(jt,{ribbon:v,activatedTab:h,onSelectTab:y}),(0,p.jsxs)(`div`,{"data-u-comp":`ribbon-toolbar`,ref:o,className:(0,m.clsx)(`univer-flex univer-overflow-hidden`,m.divideXClassName,{"univer-justify-center":t===`classic`}),role:`toolbar`,"aria-label":a.t(h),children:[b.visibleGroups.map(e=>{var t,n;return(((t=e.children)==null?void 0:t.length)||e.item)&&(0,p.jsx)(d.Fragment,{children:(0,p.jsx)(`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&&(0,p.jsx)(Bt,{...e.item},e.key)))})},e.key)}),g.length>0&&(0,p.jsx)(`div`,{"data-u-comp":`ribbon-toolbar-more`,className:`
|
|
134
|
-
univer-pl-2
|
|
135
|
-
rtl:univer-pr-2
|
|
136
|
-
`,children:(0,p.jsx)(m.Dropdown,{collisionPadding:{right:12,left:12},onOpenAutoFocus:e=>e.preventDefault(),overlay:(0,p.jsx)(`div`,{className:`
|
|
137
|
-
univer-box-border univer-grid univer-max-w-[--radix-popper-available-width]
|
|
138
|
-
univer-gap-2 univer-p-2
|
|
139
|
-
`,children:b.hiddenGroups.map(e=>{var t;return(0,p.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:(0,p.jsx)(`div`,{className:`univer-flex univer-flex-wrap univer-gap-2`,children:e.children?(t=e.children)==null?void 0:t.map(e=>e.item&&(0,p.jsx)(Bt,{...e.item},e.key)):e.item&&(0,p.jsx)(Bt,{...e.item},e.key)})},e.key)})}),children:(0,p.jsx)(`button`,{type:`button`,className:Mt,"aria-label":a.t(`ribbon.more`),"aria-haspopup":`true`,children:(0,p.jsx)(u.MoreFunctionIcon,{})})})})]})]}),x]})}var Ht=class extends c.Disposable{constructor(...e){super(...e),S(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(`
|
|
140
|
-
`)}let n=t(e),r=document.getElementById(this._styleSheetId);r&&r.remove();let i=document.createElement(`style`);i.setAttribute(`id`,this._styleSheetId),i.innerHTML=`:root {\n${n}\n}`,document.head.appendChild(i)}dispose(){super.dispose()}};const Ut=(0,c.createIdentifier)(`ui.contextmenu.service`);var Wt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_currentHandler`,null),S(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,(0,c.toDisposable)(()=>this._currentHandler=null)}};const Gt=(0,c.createIdentifier)(`ui.contextmenu.host.service`);var Kt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_menuMap`,new Map),S(this,`_activeMenuId`,null)}get activeMenuId(){return this._activeMenuId}registerMenu(e,t){return this._menuMap.set(e,t),(0,c.toDisposable)(()=>{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 qt({items:e}){return(0,p.jsx)(`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=(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
141
|
-
univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center
|
|
142
|
-
univer-rounded-md
|
|
143
|
-
hover:univer-bg-gray-50
|
|
144
|
-
dark:hover:!univer-bg-gray-900
|
|
145
|
-
`,{"univer-bg-gray-50 dark:!univer-bg-gray-900":e.active},e.className),onClick:()=>e.onClick(),children:(0,p.jsx)(e.Icon,{className:`
|
|
146
|
-
univer-size-4 univer-text-gray-900
|
|
147
|
-
dark:!univer-text-gray-200
|
|
148
|
-
`})},e.key);return e.tooltip?(0,p.jsx)(m.Tooltip,{title:e.tooltip,children:t},e.key):t})})}function Jt(e){let{menuSchema:t,onOptionSelect:n}=e,r=(0,f.useDependency)(k),i=(0,f.useDependency)(c.LocaleService),a=t.item,o=(0,f.useObservable)(a==null?void 0:a.disabled$,!1),s=(0,f.useObservable)(a==null?void 0:a.hidden$,!1),l=(0,f.useObservable)(a==null?void 0:a.activated$,!1);if(!a||s)return null;let u=a.icon?r.get(a.icon):null;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`
|
|
149
|
-
univer-relative univer-box-border univer-flex univer-size-12 univer-w-full univer-appearance-none
|
|
150
|
-
univer-flex-col univer-items-center univer-justify-center univer-gap-0.5 univer-rounded-lg
|
|
151
|
-
univer-border-none univer-bg-white univer-p-0 univer-font-medium univer-text-gray-700
|
|
152
|
-
univer-outline-none univer-transition-all
|
|
153
|
-
focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0
|
|
154
|
-
dark:!univer-bg-gray-700 dark:!univer-text-gray-100
|
|
155
|
-
`,o?`univer-cursor-not-allowed univer-opacity-60`:`
|
|
16
|
+
`;function Nt(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(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(Mt,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 Pt(e){let{disabled$:t,hidden$:n,activated$:r,value$:i}=e,a;if(ut(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]=(0,d.useState)(),[l,u]=(0,d.useState)(!1),[f,p]=(0,d.useState)(!1),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)();return(0,d.useEffect)(()=>{let e=[];return t&&e.push(t.subscribe(e=>u(e))),n&&e.push(n.subscribe(e=>h(e))),r&&e.push(r.subscribe(e=>p(e))),i&&e.push(i.subscribe(e=>c(e))),a&&e.push(a.subscribe(e=>_(e))),()=>e.forEach(e=>e.unsubscribe())},[r,t,n,i,a]),{disabled:l,value:s,activated:f,hidden:m,selectionsValue:g}}const Ft=(0,d.createContext)({dropdownVisible:!1,setDropdownVisible:e=>{}}),It=(0,d.forwardRef)((e,t)=>{let{children:n,...r}=e,i=(0,d.useRef)(null),[a,o]=(0,d.useState)(!1),[s,c]=(0,d.useState)(!1);function l(e){o(s?!1:e)}function u(e){c(e),o(!1)}let f=(0,d.useMemo)(()=>({dropdownVisible:s,setDropdownVisible:u}),[s]);return(0,d.useImperativeHandle)(t,()=>({el:i.current})),r.title?(0,p.jsx)(m.Tooltip,{visible:a,onVisibleChange:l,...r,children:(0,p.jsx)(`span`,{ref:i,children:(0,p.jsx)(Ft.Provider,{value:f,children:n})})}):(0,p.jsx)(`span`,{ref:i,children:n})});function Lt(e){let{children:t,overlay:n,disabled:r,align:i=`start`}=e,{dropdownVisible:a,setDropdownVisible:o}=(0,d.useContext)(Ft);function s(e){o(e)}return(0,p.jsx)(m.Dropdown,{align:i,overlay:(0,p.jsx)(`div`,{className:`univer-grid univer-gap-2`,children:n}),disabled:r,open:a,onOpenChange:s,children:(0,p.jsx)(`div`,{className:`univer-h-full`,onClick:e=>e.stopPropagation(),children:t})})}function Rt({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(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-relative univer-flex univer-items-center univer-gap-2`,{"univer-pl-6":o}),children:[o&&String(t)===String(n.value)&&(0,p.jsx)(u.CheckMarkIcon,{className:`univer-absolute univer-left-1 univer-top-0.5 univer-text-primary-600`}),(0,p.jsx)(I,{className:`univer-text-sm`,icon:e,value$:n.value$,value:n.value,label:n.label,onChange:a})]})}function zt({menuId:e,slot:t,value:n,options:r,children:i,disabled:a,onOptionSelect:o}){let{dropdownVisible:s,setDropdownVisible:c}=(0,d.useContext)(Ft),u=(0,f.useDependency)(J),[h,g]=(0,d.useState)({}),_=(0,d.useMemo)(()=>e?u.getMenuByPositionKey(e):[],[e]),v=(0,d.useMemo)(()=>_.filter(e=>{var t;return e.children?!h[((t=e.key)==null?void 0:t.toString())||``]:!h[e.key]}),[_,h]);function y(e){c(e)}if((0,d.useEffect)(()=>{let e=[];return _.forEach(t=>{if(t.children){let n=(0,l.combineLatest)(t.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?(0,l.of)(!1):t})).subscribe(e=>{let n=e.every(e=>e===!0);g(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=>{g(n=>({...n,[t.key]:e}))});e.push(n)}}}),()=>{e.forEach(e=>e==null?void 0:e.unsubscribe()),g({})}},[_]),t)return(0,p.jsx)(Lt,{disabled:a,overlay:r.map((e,t)=>(0,p.jsx)(Rt,{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:(0,m.clsx)({"focus:univer-bg-white":typeof e.label!=`string`&&((t=e.label)==null?void 0:t.hoverable)===!1}),children:(0,p.jsx)(Rt,{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 v){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:(0,p.jsx)(Rt,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}return(0,p.jsx)(m.DropdownMenu,{align:`start`,items:e,disabled:a,open:s,onOpenChange:y,children:i})}else{let e=[];for(let t of v){var b;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:(0,p.jsx)(Rt,{icon:s,value:n,option:{label:{name:r,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:a,id:i})}})}else (b=t.children)!=null&&b.length}return(0,p.jsx)(m.DropdownMenu,{align:`start`,items:e,disabled:a,open:s,onOpenChange:y,children:i})}}const Bt=(0,d.forwardRef)((e,t)=>{let n=(0,f.useDependency)(c.LocaleService),r=(0,f.useDependency)(c.ICommandService),i=(0,f.useDependency)(U),a=(0,f.useDependency)(k),{value:o,hidden:s,disabled:h,activated:g,selectionsValue:_}=Pt(e),v=(e,t)=>{i.focus(),r.executeCommand(e,t)},{tooltip:y,shortcut:b,icon:x,title:S,label:C,id:w,commandId:T,type:E,slot:D,params:O}=e,A=n.t(y==null?``:y)+(b?` (${b})`:``),{selections:j}=e,M=(0,f.useObservable)((0,d.useMemo)(()=>(0,l.isObservable)(j)?j:new l.Observable(e=>{e.next(j)}),[j])),N=(0,f.useObservable)((0,d.useMemo)(()=>(0,l.isObservable)(x)?x:new l.Observable(e=>{var t,n;let r=(t=M==null||(n=M.find(e=>e.value===o))==null?void 0:n.icon)==null?x:t;e.next(r)}),[x,M,o]),void 0,!0);function ee(t){var n;let r=e.selectionsCommandId,i=T==null?w:T,a=(n=r==null?T:r)==null?w:n;function s(e){if(h)return;let t=a;e.id&&(t=e.id),v(t,{value:e.value})}function c(e){h||v(a,{value:e})}function l(){h||t===Y.BUTTON_SELECTOR&&v(i,{value:o})}return t===Y.BUTTON_SELECTOR?(0,p.jsxs)(`div`,{"data-u-command":w,"data-disabled":h,className:(0,m.clsx)(`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":!h,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h}),children:[(0,p.jsx)(`div`,{className:(0,m.clsx)(`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":g,"univer-bg-gray-100":g&&h}),onClick:l,children:(0,p.jsx)(I,{icon:N,title:S,value:_==null?o:_,label:C,onChange:c})}),(0,p.jsx)(zt,{menuId:w,slot:D,value:o,options:M,disabled:h,onOptionSelect:s,children:(0,p.jsx)(`div`,{className:(0,m.clsx)(`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":h,"univer-bg-gray-200 dark:!univer-bg-gray-500":g,"univer-bg-gray-100":g&&h}),"data-disabled":h,children:(0,p.jsx)(u.MoreDownIcon,{})})})]}):(0,p.jsx)(zt,{menuId:w,slot:D,value:o,options:M,disabled:h,onOptionSelect:s,children:(0,p.jsxs)(`div`,{"data-u-command":w,className:(0,m.clsx)(`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":!h,"univer-pointer-events-none univer-cursor-not-allowed univer-text-gray-300 dark:!univer-text-gray-600":h,"univer-bg-gray-200":g,"univer-bg-gray-100":g&&h}),children:[(0,p.jsx)(I,{icon:N,title:S,value:o,label:C,onChange:c}),(0,p.jsx)(`div`,{className:(0,m.clsx)(`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":h}),children:(0,p.jsx)(u.MoreDownIcon,{})})]})})}function te(){var t;let n=a.get(typeof C==`string`?C:(t=C==null?void 0:C.name)==null?``:t),r=(o==null?typeof O==`function`:o)?O():O;return(0,p.jsx)(Nt,{"data-u-command":w,className:`univer-text-sm`,noIcon:!x,active:g,disabled:h,onClick:()=>{var t;return v((t=e.commandId)==null?e.id:t,r)},onDoubleClick:()=>e.subId&&v(e.subId),children:n?(0,p.jsx)(I,{title:S,value:o,label:C}):x?(0,p.jsx)(I,{icon:x}):(0,p.jsx)(I,{title:S})})}function P(){switch(E){case Y.BUTTON_SELECTOR:case Y.SELECTOR:case Y.SUBITEMS:return ee(E);case Y.BUTTON:default:return te()}}return!s&&(0,p.jsx)(It,{ref:t,title:A,placement:`bottom`,children:P()})});function Vt(e){let{ribbonType:t,headerMenuComponents:n,headerMenu:r=!0}=e,i=(0,f.useDependency)(Dt),a=(0,f.useDependency)(c.LocaleService),o=(0,d.useRef)(null),s=(0,d.useRef)({}),l=(0,f.useObservable)(i.ribbon$,[]),h=(0,f.useObservable)(i.activatedTab$,W.START),g=(0,f.useObservable)(i.collapsedIds$,[]),_=(0,f.useObservable)(i.fakeToolbarVisible$,!1),v=(0,d.useMemo)(()=>{if(t===`simple`){let e=[{key:W.START,children:[],order:0}];return l.forEach(t=>{var n;(n=t.children)==null||n.forEach(t=>{var n;(n=e[0].children)==null||n.push(t)})}),e}return l},[t,l]),y=(0,d.useCallback)(e=>{s.current={},i.setActivatedTab(e.key)},[]),b=(0,d.useMemo)(()=>{var e,t;let n=(e=(t=v.find(e=>e.key===h))==null?void 0:t.children)==null?[]:e,r=[],i=[];for(let e of n)if(e.children){let t=e.children.filter(e=>!g.includes(e.key));t.length>0&&r.push({...e,children:t}),t.length<e.children.length&&i.push({...e,children:e.children.filter(e=>g.includes(e.key))})}return{allGroups:n,visibleGroups:r,hiddenGroups:i}},[g,v,h]);(0,d.useEffect)(()=>{let e=null,t=new ResizeObserver((0,c.throttle)(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,l=(((e=(t=v.find(e=>e.key===h))==null?void 0:t.children)==null?[]:e).length-1)*8;c+=l;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()}},[v,h]);let x=(0,d.useMemo)(()=>(0,p.jsx)(`div`,{"aria-hidden":`true`,className:(0,m.clsx)(`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":!_},m.divideXClassName,m.borderBottomClassName),children:b.allGroups.map((e,t)=>{var n,r;return(((n=e.children)==null?void 0:n.length)||e.item)&&(0,p.jsx)(d.Fragment,{children:(0,p.jsx)(`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&&(0,p.jsx)(Bt,{...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)})}),[b.allGroups,_]);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{"data-u-comp":`ribbon-header-menu`,className:(0,m.clsx)(`univer-relative univer-select-none`,{"univer-h-9":t===`classic`||n&&n.size>0}),children:[t===`classic`&&v.length>1&&(0,p.jsx)(kt,{ribbon:v,activatedTab:h,onSelectTab:y}),r&&n&&n.size>0&&(0,p.jsx)(`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:(0,p.jsx)(Q,{components:n})})]}),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`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]":v.length>1&&t!==`classic`,"univer-grid-cols-none":v.length===1},m.borderBottomClassName),children:[t===`collapsed`&&v.length>1&&(0,p.jsx)(jt,{ribbon:v,activatedTab:h,onSelectTab:y}),(0,p.jsxs)(`div`,{"data-u-comp":`ribbon-toolbar`,ref:o,className:(0,m.clsx)(`univer-flex univer-overflow-hidden`,m.divideXClassName,{"univer-justify-center":t===`classic`}),role:`toolbar`,"aria-label":a.t(h),children:[b.visibleGroups.map(e=>{var t,n;return(((t=e.children)==null?void 0:t.length)||e.item)&&(0,p.jsx)(d.Fragment,{children:(0,p.jsx)(`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&&(0,p.jsx)(Bt,{...e.item},e.key)))})},e.key)}),g.length>0&&(0,p.jsx)(`div`,{"data-u-comp":`ribbon-toolbar-more`,className:`univer-pl-2 rtl:univer-pr-2`,children:(0,p.jsx)(m.Dropdown,{collisionPadding:{right:12,left:12},onOpenAutoFocus:e=>e.preventDefault(),overlay:(0,p.jsx)(`div`,{className:`univer-box-border univer-grid univer-max-w-[--radix-popper-available-width] univer-gap-2 univer-p-2`,children:b.hiddenGroups.map(e=>{var t;return(0,p.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:(0,p.jsx)(`div`,{className:`univer-flex univer-flex-wrap univer-gap-2`,children:e.children?(t=e.children)==null?void 0:t.map(e=>e.item&&(0,p.jsx)(Bt,{...e.item},e.key)):e.item&&(0,p.jsx)(Bt,{...e.item},e.key)})},e.key)})}),children:(0,p.jsx)(`button`,{type:`button`,className:Mt,"aria-label":a.t(`ribbon.more`),"aria-haspopup":`true`,children:(0,p.jsx)(u.MoreFunctionIcon,{})})})})]})]}),x]})}var Ht=class extends c.Disposable{constructor(...e){super(...e),S(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
|
+
`)}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 Ut=(0,c.createIdentifier)(`ui.contextmenu.service`);var Wt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_currentHandler`,null),S(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,(0,c.toDisposable)(()=>this._currentHandler=null)}};const Gt=(0,c.createIdentifier)(`ui.contextmenu.host.service`);var Kt=class extends c.Disposable{constructor(...e){super(...e),S(this,`_menuMap`,new Map),S(this,`_activeMenuId`,null)}get activeMenuId(){return this._activeMenuId}registerMenu(e,t){return this._menuMap.set(e,t),(0,c.toDisposable)(()=>{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 qt({items:e}){return(0,p.jsx)(`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=(0,p.jsx)(`div`,{className:(0,m.clsx)(`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:(0,p.jsx)(e.Icon,{className:`univer-size-4 univer-text-gray-900 dark:!univer-text-gray-200`})},e.key);return e.tooltip?(0,p.jsx)(m.Tooltip,{title:e.tooltip,children:t},e.key):t})})}function Jt(e){let{menuSchema:t,onOptionSelect:n}=e,r=(0,f.useDependency)(k),i=(0,f.useDependency)(c.LocaleService),a=t.item,o=(0,f.useObservable)(a==null?void 0:a.disabled$,!1),s=(0,f.useObservable)(a==null?void 0:a.hidden$,!1),l=(0,f.useObservable)(a==null?void 0:a.activated$,!1);if(!a||s)return null;let u=a.icon?r.get(a.icon):null;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`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`:`
|
|
156
18
|
univer-cursor-pointer
|
|
157
19
|
hover:univer-bg-gray-50
|
|
158
20
|
dark:hover:!univer-bg-gray-600
|
|
159
21
|
`,l&&`
|
|
160
22
|
univer-bg-primary-50 univer-text-primary-700 univer-ring-1 univer-ring-primary-600
|
|
161
23
|
dark:!univer-bg-primary-900 dark:!univer-text-primary-100
|
|
162
|
-
`),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:[u&&(0,p.jsx)(u,{className:`univer-text-base`,extend:{colorChannel1:`var(--univer-primary-600)`}}),(0,p.jsx)(`span`,{className:`univer-break-words univer-text-center univer-text-xs univer-leading-4`,children:a.title?i.t(a.title):t.key})]})}function Yt(e){let{item:t,onOptionSelect:n}=e,[r,i]=(0,d.useState)([]),a=(0,f.useDependency)(k),o=(0,f.useDependency)(c.LocaleService);return(0,d.useEffect)(()=>{if(!t.children)return;let e=t.children.map(e=>{var t,n;return(0,c.convertObservableToBehaviorSubject)((t=(n=e.item)==null?void 0:n.activated$)==null?(0,l.of)(!1):t,!1)}),n=(0,l.combineLatest)(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?(0,p.jsx)(qt,{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 Xt(e){var t;let{item:n,onOptionSelect:r}=e;return(t=n.children)!=null&&t.length?(0,p.jsx)(`div`,{className:`univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1`,children:n.children.map(e=>(0,p.jsx)(Jt,{menuSchema:e,onOptionSelect:r},e.key))}):null}const Zt=`univer-inline-flex univer-items-center univer-gap-2`;function Qt(e){return typeof e==`object`&&(e==null?void 0:e.selectable)===!1}function $t(e){return typeof e==`object`&&(e==null?void 0:e.hoverable)===!1}function en(e){var t,n;let{menuType:r,menuSessionVersion:i=0,className:a,onOptionSelect:o}=e,s=(0,f.useDependency)(J),c=(0,f.useDependency)(U),[u,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(()=>typeof window>`u`?240:Math.max(120,window.innerHeight-16)),v=(0,d.useMemo)(()=>r?s.getMenuByPositionKey(r):[],[s,r,(0,f.useObservable)((0,d.useMemo)(()=>s.menuChanged$.pipe((0,l.startWith)(void 0),(0,l.scan)(e=>e+1,0)),[s]),0),i]),y=(t=(n=c.rootContainerElement)==null||(n=n.ownerDocument)==null?void 0:n.body)==null?typeof document<`u`?document.body:null:t;return ae(u,c.rootContainerElement),(0,d.useEffect)(()=>{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(()=>{_(Math.max(120,n.innerHeight-16))})};return i(),n.addEventListener(`resize`,i),()=>{r&&n.cancelAnimationFrame(r),n.removeEventListener(`resize`,i)}},[c.rootContainerElement]),r?(0,p.jsx)(`div`,{ref:h,className:(0,m.clsx)(`
|
|
163
|
-
univer-box-border univer-grid univer-min-w-52 univer-max-w-full univer-gap-1 univer-overflow-y-auto
|
|
164
|
-
univer-overscroll-contain univer-rounded-md univer-bg-white univer-px-2 univer-py-1 univer-text-sm
|
|
165
|
-
univer-text-gray-900 univer-shadow-md
|
|
166
|
-
dark:!univer-bg-gray-700 dark:!univer-text-white
|
|
167
|
-
`,m.borderClassName,m.scrollbarClassName,a),style:{maxHeight:g},onWheel:e=>e.stopPropagation(),children:(0,p.jsx)(tn,{menuSchemas:v,submenuPortalContainer:y,onOptionSelect:o,maxMenuHeight:g})}):null}function tn(e){let{menuSchemas:t,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i}=e,a=(0,f.useDependency)(c.LocaleService),o=rn(t),s=(0,d.useMemo)(()=>t.filter(e=>e.children?!o[e.key]:!0),[o,t]);return(0,p.jsx)(p.Fragment,{children:s.map((e,t)=>{var o;let c=t!==s.length-1;return e.item?(0,p.jsx)(nn,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key):(o=e.children)!=null&&o.length?e.quickLayout?(0,p.jsx)(`div`,{className:(0,m.clsx)(`univer-py-1`,c&&m.borderBottomClassName),children:e.quickLayout===`tile`?(0,p.jsx)(Xt,{item:e,onOptionSelect:r}):(0,p.jsx)(Yt,{item:e,onOptionSelect:r})},e.key):(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-grid univer-gap-1 univer-py-1`,c&&m.borderBottomClassName),children:[e.title&&(0,p.jsx)(`strong`,{className:`
|
|
168
|
-
univer-px-2 univer-text-xs univer-font-semibold univer-text-gray-600
|
|
169
|
-
dark:!univer-text-gray-300
|
|
170
|
-
`,children:a.t(e.title)}),e.children.map(e=>e.item&&(0,p.jsx)(nn,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key))]},e.key):null})})}function nn(e){let{menuKey:t,menuItem:n,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a}=e,o=(0,f.useDependency)(J),s=(0,f.useObservable)(n.disabled$,!1),h=(0,f.useObservable)(n.activated$,!1),g=(0,f.useObservable)(n.hidden$,!1),v=(0,f.useObservable)(n.value$),y=n,b=(0,f.useObservable)((0,l.isObservable)(y.selections)?y.selections:void 0),[x,S]=(0,d.useState)(v),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)({left:0,top:0}),[D,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(`right`),j=(0,d.useRef)(null),M=(0,d.useRef)(null),N=(0,d.useMemo)(()=>n.type!==Y.SELECTOR&&n.type!==Y.BUTTON_SELECTOR?[]:b||(Array.isArray(y.selections)?y.selections:[]),[n.type,b,y.selections]),ee=(0,d.useMemo)(()=>n.type!==Y.SUBITEMS||!n.id?[]:o.getMenuByPositionKey(n.id),[n.id,n.type,o]),te=N.length>0,P=ee.length>0,F=te||P;if((0,d.useEffect)(()=>{S(v)},[v]),(0,d.useEffect)(()=>{if(!C){O(!1);return}let e=()=>{let e=j.current,t=M.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;A(o?`left`:`right`);let c=window.innerHeight-8-r.height;E({left:s,top:c<8?8:Math.min(Math.max(n.top,8),c)}),O(!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)}},[C,te,P]),g)return null;let ne=e=>{S((0,c.isRealNum)(e)&&typeof e==`string`?Number.parseInt(e):e)},re=(0,m.clsx)(`
|
|
171
|
-
univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-justify-between
|
|
172
|
-
univer-gap-3 univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left
|
|
173
|
-
univer-text-sm
|
|
174
|
-
dark:!univer-text-white
|
|
175
|
-
`,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:[u&&(0,p.jsx)(u,{className:`univer-text-base`,extend:{colorChannel1:`var(--univer-primary-600)`}}),(0,p.jsx)(`span`,{className:`univer-break-words univer-text-center univer-text-xs univer-leading-4`,children:a.title?i.t(a.title):t.key})]})}function Yt(e){let{item:t,onOptionSelect:n}=e,[r,i]=(0,d.useState)([]),a=(0,f.useDependency)(k),o=(0,f.useDependency)(c.LocaleService);return(0,d.useEffect)(()=>{if(!t.children)return;let e=t.children.map(e=>{var t,n;return(0,c.convertObservableToBehaviorSubject)((t=(n=e.item)==null?void 0:n.activated$)==null?(0,l.of)(!1):t,!1)}),n=(0,l.combineLatest)(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?(0,p.jsx)(qt,{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 Xt(e){var t;let{item:n,onOptionSelect:r}=e;return(t=n.children)!=null&&t.length?(0,p.jsx)(`div`,{className:`univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1`,children:n.children.map(e=>(0,p.jsx)(Jt,{menuSchema:e,onOptionSelect:r},e.key))}):null}const Zt=`univer-inline-flex univer-items-center univer-gap-2`;function Qt(e){return typeof e==`object`&&(e==null?void 0:e.selectable)===!1}function $t(e){return typeof e==`object`&&(e==null?void 0:e.hoverable)===!1}function en(e){var t,n;let{menuType:r,menuSessionVersion:i=0,className:a,onOptionSelect:o}=e,s=(0,f.useDependency)(J),c=(0,f.useDependency)(U),[u,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(()=>typeof window>`u`?240:Math.max(120,window.innerHeight-16)),v=(0,d.useMemo)(()=>r?s.getMenuByPositionKey(r):[],[s,r,(0,f.useObservable)((0,d.useMemo)(()=>s.menuChanged$.pipe((0,l.startWith)(void 0),(0,l.scan)(e=>e+1,0)),[s]),0),i]),y=(t=(n=c.rootContainerElement)==null||(n=n.ownerDocument)==null?void 0:n.body)==null?typeof document<`u`?document.body:null:t;return ae(u,c.rootContainerElement),(0,d.useEffect)(()=>{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(()=>{_(Math.max(120,n.innerHeight-16))})};return i(),n.addEventListener(`resize`,i),()=>{r&&n.cancelAnimationFrame(r),n.removeEventListener(`resize`,i)}},[c.rootContainerElement]),r?(0,p.jsx)(`div`,{ref:h,className:(0,m.clsx)(`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`,m.borderClassName,m.scrollbarClassName,a),style:{maxHeight:g},onWheel:e=>e.stopPropagation(),children:(0,p.jsx)(tn,{menuSchemas:v,submenuPortalContainer:y,onOptionSelect:o,maxMenuHeight:g})}):null}function tn(e){let{menuSchemas:t,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i}=e,a=(0,f.useDependency)(c.LocaleService),o=rn(t),s=(0,d.useMemo)(()=>t.filter(e=>e.children?!o[e.key]:!0),[o,t]);return(0,p.jsx)(p.Fragment,{children:s.map((e,t)=>{var o;let c=t!==s.length-1;return e.item?(0,p.jsx)(nn,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key):(o=e.children)!=null&&o.length?e.quickLayout?(0,p.jsx)(`div`,{className:(0,m.clsx)(`univer-py-1`,c&&m.borderBottomClassName),children:e.quickLayout===`tile`?(0,p.jsx)(Xt,{item:e,onOptionSelect:r}):(0,p.jsx)(Yt,{item:e,onOptionSelect:r})},e.key):(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-grid univer-gap-1 univer-py-1`,c&&m.borderBottomClassName),children:[e.title&&(0,p.jsx)(`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&&(0,p.jsx)(nn,{menuKey:e.key,menuItem:e.item,submenuPortalContainer:n,onOptionSelect:r,maxMenuHeight:i},e.key))]},e.key):null})})}function nn(e){let{menuKey:t,menuItem:n,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a}=e,o=(0,f.useDependency)(J),s=(0,f.useObservable)(n.disabled$,!1),h=(0,f.useObservable)(n.activated$,!1),g=(0,f.useObservable)(n.hidden$,!1),v=(0,f.useObservable)(n.value$),y=n,b=(0,f.useObservable)((0,l.isObservable)(y.selections)?y.selections:void 0),[x,S]=(0,d.useState)(v),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)({left:0,top:0}),[D,O]=(0,d.useState)(!1),[k,A]=(0,d.useState)(`right`),j=(0,d.useRef)(null),M=(0,d.useRef)(null),N=(0,d.useMemo)(()=>n.type!==Y.SELECTOR&&n.type!==Y.BUTTON_SELECTOR?[]:b||(Array.isArray(y.selections)?y.selections:[]),[n.type,b,y.selections]),ee=(0,d.useMemo)(()=>n.type!==Y.SUBITEMS||!n.id?[]:o.getMenuByPositionKey(n.id),[n.id,n.type,o]),te=N.length>0,P=ee.length>0,F=te||P;if((0,d.useEffect)(()=>{S(v)},[v]),(0,d.useEffect)(()=>{if(!C){O(!1);return}let e=()=>{let e=j.current,t=M.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;A(o?`left`:`right`);let c=window.innerHeight-8-r.height;E({left:s,top:c<8?8:Math.min(Math.max(n.top,8),c)}),O(!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)}},[C,te,P]),g)return null;let ne=e=>{S((0,c.isRealNum)(e)&&typeof e==`string`?Number.parseInt(e):e)},re=(0,m.clsx)(`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`:`
|
|
176
25
|
univer-cursor-pointer
|
|
177
26
|
hover:univer-bg-gray-50
|
|
178
27
|
dark:hover:!univer-bg-gray-600
|
|
@@ -182,23 +31,7 @@ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
|
182
31
|
`),ie=(0,p.jsxs)(`span`,{className:Zt,children:[(0,p.jsx)(I,{value:x,title:n.title,label:n.label,icon:n.icon,onChange:ne}),n.shortcut&&` (${n.shortcut})`]}),L=n.type===Y.BUTTON||n.type===Y.BUTTON_SELECTOR,ae=Qt(n.label),oe=(0,m.clsx)(re,$t(n.label)&&`
|
|
183
32
|
hover:univer-bg-transparent
|
|
184
33
|
dark:hover:!univer-bg-transparent
|
|
185
|
-
`);return(0,p.jsxs)(`div`,{ref:j,className:`univer-relative`,onMouseEnter:()=>{F&&!s&&(O(!1),w(!0))},onMouseLeave:e=>{if(F){var t;let n=e.relatedTarget;if(n&&(t=M.current)!=null&&t.contains(n))return;w(!1)}},children:[ae?(0,p.jsxs)(`div`,{className:oe,"aria-disabled":s,children:[ie,F&&(0,p.jsx)(u.MoreIcon,{className:`
|
|
186
|
-
univer-size-3.5 univer-text-gray-400
|
|
187
|
-
dark:!univer-text-gray-200
|
|
188
|
-
`})]}):(0,p.jsxs)(`button`,{type:`button`,className:oe,disabled:s,onClick:()=>{if(F){O(!1),w(!0);return}if(!L)return;let e=n;i==null||i({commandId:e.commandId,value:x,id:e.id,label:t})},children:[ie,F&&(0,p.jsx)(u.MoreIcon,{className:`
|
|
189
|
-
univer-size-3.5 univer-text-gray-400
|
|
190
|
-
dark:!univer-text-gray-200
|
|
191
|
-
`})]}),F&&C&&(r?(0,_.createPortal)((0,p.jsx)(`div`,{ref:M,"data-u-context-menu-submenu":`true`,className:`univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]`,style:{position:`fixed`,left:T.left,top:T.top,paddingLeft:k===`right`?20:0,paddingRight:k===`left`?20:0,maxHeight:a,visibility:D?`visible`:`hidden`,pointerEvents:D?`auto`:`none`},onMouseLeave:e=>{var t;let n=e.relatedTarget;n&&(t=j.current)!=null&&t.contains(n)||w(!1)},onWheel:e=>e.stopPropagation(),children:(0,p.jsxs)(`div`,{className:(0,m.clsx)(`
|
|
192
|
-
univer-overflow-y-auto univer-overscroll-contain univer-rounded-md univer-border
|
|
193
|
-
univer-border-solid univer-border-gray-200 univer-bg-white univer-p-2
|
|
194
|
-
univer-shadow-md
|
|
195
|
-
dark:!univer-border-gray-600 dark:!univer-bg-gray-700
|
|
196
|
-
`,m.scrollbarClassName),style:{maxHeight:a},children:[te&&(0,p.jsx)(`div`,{className:`univer-grid univer-gap-1`,children:N.map((e,r)=>{var a;let o=`${n.id}-${(a=e.label)==null?e.id:a}-${r}`,s=x!==void 0&&String(x)===String(e.value),c=!Qt(e.label),l=!$t(e.label),d=(0,m.clsx)(`
|
|
197
|
-
univer-relative univer-flex univer-min-h-8 univer-w-full
|
|
198
|
-
univer-items-center univer-rounded-md univer-border-none
|
|
199
|
-
univer-bg-transparent univer-px-2 univer-text-left univer-text-sm
|
|
200
|
-
dark:!univer-text-white
|
|
201
|
-
`,e.disabled?`univer-cursor-not-allowed univer-opacity-60`:l&&`
|
|
34
|
+
`);return(0,p.jsxs)(`div`,{ref:j,className:`univer-relative`,onMouseEnter:()=>{F&&!s&&(O(!1),w(!0))},onMouseLeave:e=>{if(F){var t;let n=e.relatedTarget;if(n&&(t=M.current)!=null&&t.contains(n))return;w(!1)}},children:[ae?(0,p.jsxs)(`div`,{className:oe,"aria-disabled":s,children:[ie,F&&(0,p.jsx)(u.MoreIcon,{className:`univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200`})]}):(0,p.jsxs)(`button`,{type:`button`,className:oe,disabled:s,onClick:()=>{if(F){O(!1),w(!0);return}if(!L)return;let e=n;i==null||i({commandId:e.commandId,value:x,id:e.id,label:t})},children:[ie,F&&(0,p.jsx)(u.MoreIcon,{className:`univer-size-3.5 univer-text-gray-400 dark:!univer-text-gray-200`})]}),F&&C&&(r?(0,_.createPortal)((0,p.jsx)(`div`,{ref:M,"data-u-context-menu-submenu":`true`,className:`univer-z-[1080] univer-w-max univer-max-w-[calc(100vw-16px)]`,style:{position:`fixed`,left:T.left,top:T.top,paddingLeft:k===`right`?20:0,paddingRight:k===`left`?20:0,maxHeight:a,visibility:D?`visible`:`hidden`,pointerEvents:D?`auto`:`none`},onMouseLeave:e=>{var t;let n=e.relatedTarget;n&&(t=j.current)!=null&&t.contains(n)||w(!1)},onWheel:e=>e.stopPropagation(),children:(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-overflow-y-auto univer-overscroll-contain univer-rounded-md univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-2 univer-shadow-md dark:!univer-border-gray-600 dark:!univer-bg-gray-700`,m.scrollbarClassName),style:{maxHeight:a},children:[te&&(0,p.jsx)(`div`,{className:`univer-grid univer-gap-1`,children:N.map((e,r)=>{var a;let o=`${n.id}-${(a=e.label)==null?e.id:a}-${r}`,s=x!==void 0&&String(x)===String(e.value),c=!Qt(e.label),l=!$t(e.label),d=(0,m.clsx)(`univer-relative univer-flex univer-min-h-8 univer-w-full univer-items-center univer-rounded-md univer-border-none univer-bg-transparent univer-px-2 univer-text-left univer-text-sm dark:!univer-text-white`,e.disabled?`univer-cursor-not-allowed univer-opacity-60`:l&&`
|
|
202
35
|
univer-cursor-pointer
|
|
203
36
|
hover:univer-bg-gray-50
|
|
204
37
|
dark:hover:!univer-bg-gray-600
|
|
@@ -207,56 +40,13 @@ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
|
|
|
207
40
|
univer-text-primary-600
|
|
208
41
|
`}),(0,p.jsx)(`span`,{className:(0,m.clsx)(Zt,c&&s&&`
|
|
209
42
|
univer-pl-4
|
|
210
|
-
`),children:(0,p.jsx)(I,{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?(0,p.jsx)(`button`,{type:`button`,className:d,disabled:e.disabled,onClick:()=>{i==null||i({...e,id:n.id,label:t,commandId:e.commandId})},children:f},o):(0,p.jsx)(`div`,{className:d,"aria-disabled":e.disabled,children:f},o)})}),P&&(0,p.jsx)(tn,{menuSchemas:ee,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a})]})}),r):null)]})}function rn(e){let[t,n]=(0,d.useState)({});return(0,d.useEffect)(()=>{let t=e.map(e=>{var t;return(t=e.children)!=null&&t.length?(0,l.combineLatest)(e.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?(0,l.of)(!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 an(e){let{hostId:t,visible:n,anchorRect:r,menuType:i,anchorVertical:a=`bottom`,menuOffset:o=0,onRequestClose:s,onOptionSelect:c}=e,l=(0,d.useRef)(null),u=(0,f.useDependency)(Gt),h=(0,d.useRef)(s),g=(0,d.useRef)(0),_=(0,d.useRef)(n),v=(0,d.useRef)(i);(0,d.useEffect)(()=>{h.current=s},[s]),n&&(!_.current||i!==v.current)&&(g.current+=1),_.current=n,v.current=i,(0,d.useEffect)(()=>{let e=u.registerMenu(t,()=>{h.current()});return()=>{e.dispose(),u.deactivateMenu(t)}},[u,t]),(0,d.useLayoutEffect)(()=>{if(n){u.activateMenu(t);return}u.deactivateMenu(t)},[u,t,n]),(0,d.useEffect)(()=>{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)&&h.current()},r=e=>{e.key===`Escape`&&h.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 y=(0,d.useMemo)(()=>{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(0,p.jsx)(m.Popup,{visible:n&&!!r,offset:y,overflowVisible:!0,placementY:a===`top`?`above`:`below`,children:(0,p.jsx)(`section`,{ref:l,children:i&&(0,p.jsx)(en,{menuType:i,menuSessionVersion:g.current,onOptionSelect:c})})})}function on(){let[e,t]=(0,d.useState)(!1),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(null),o=(0,d.useRef)(e),s=(0,f.useDependency)(Ut),l=(0,f.useDependency)(c.ICommandService),u=(0,f.useInjector)();o.current=e,(0,d.useEffect)(()=>{let e=s.registerContextMenuHandler({handleContextMenu:m,hideContextMenu(){h()},get visible(){return o.current}});return()=>{e.dispose()}},[s]);function m(e,n){t(!1),requestAnimationFrame(()=>{r(n),a({left:e.clientX,top:e.clientY,bottom:e.clientY}),t(!0)})}function h(){t(!1)}return(0,p.jsx)(an,{hostId:`desktop-context-menu`,visible:e,anchorRect:i,menuType:n,onRequestClose:h,onOptionSelect:e=>{let{label:t,commandId:n,value:r}=e;l&&l.executeCommand(n==null?t:n,{value:r}),u.get(U).focus(),h()}})}const sn=(0,c.createIdentifier)(`univer.global-zone-service`);function cn(){let e=(0,f.useDependency)(sn),[t,n]=(0,d.useState)(!1),r=(0,f.useObservable)(e.componentKey$,e.componentKey),i=(0,f.useDependency)(k),a=(0,d.useMemo)(()=>{let e=i.get(r==null?``:r);if(e)return e},[r,i]);return(0,d.useEffect)(()=>{let t=e.visible$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[e.visible$]),t?(0,p.jsx)(`section`,{className:(0,m.clsx)(`univer-absolute univer-bg-gray-100`,{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&(0,p.jsx)(a,{})}):null}function ln(){let e=(0,f.useDependency)(T),t=(0,f.useObservable)(e.sidebarOptions$),n=(0,d.useRef)(null),r=(0,d.useMemo)(()=>{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]=(0,p.jsx)(I,{...i},n))}}return e},[t]);(0,d.useEffect)(()=>(n.current&&e.setContainer(n.current),()=>{e.setContainer(void 0)}),[e]),(0,d.useEffect)(()=>{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=(0,d.useMemo)(()=>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(0,p.jsx)(`section`,{"data-u-comp":`sidebar`,className:(0,m.clsx)(`
|
|
211
|
-
univer-relative univer-h-full univer-bg-white univer-text-gray-900
|
|
212
|
-
dark:!univer-bg-gray-900 dark:!univer-text-white
|
|
213
|
-
`,{"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:(0,p.jsxs)(`section`,{ref:n,className:(0,m.clsx)(`
|
|
214
|
-
univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto]
|
|
215
|
-
univer-overflow-y-auto
|
|
216
|
-
`,m.borderLeftBottomClassName,m.scrollbarClassName),children:[(0,p.jsxs)(`header`,{className:`
|
|
217
|
-
univer-sticky univer-top-0 univer-z-10 univer-box-border univer-flex univer-cursor-default
|
|
218
|
-
univer-items-center univer-justify-between univer-bg-white univer-p-4 univer-pb-2 univer-text-base
|
|
219
|
-
univer-font-medium univer-text-gray-800
|
|
220
|
-
dark:!univer-bg-gray-900 dark:!univer-text-white
|
|
221
|
-
`,children:[r==null?void 0:r.header,(0,p.jsx)(`a`,{className:`
|
|
222
|
-
univer-cursor-pointer univer-text-gray-500
|
|
223
|
-
dark:!univer-text-gray-300
|
|
224
|
-
`,onClick:a,children:(0,p.jsx)(u.CloseIcon,{})})]}),(0,p.jsx)(`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)&&(0,p.jsx)(`footer`,{className:`
|
|
225
|
-
univer-sticky univer-bottom-0 univer-box-border univer-bg-white univer-p-4
|
|
226
|
-
dark:!univer-bg-gray-900
|
|
227
|
-
`,children:r.footer})]})})}const un=(0,c.createIdentifier)(`univer.zen-zone-service`);function dn(){let e=(0,f.useDependency)(un),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(),a=(0,f.useObservable)(e.temporaryHidden$),o=(0,f.useDependency)(k);(0,d.useEffect)(()=>{let t=[e.visible$.subscribe(e=>{n(e)}),e.componentKey$.subscribe(e=>{i(e)})];return()=>{t.forEach(e=>{e.unsubscribe()})}},[]);let s=(0,d.useMemo)(()=>{let e=o.get(r==null?``:r);if(e)return e},[r]);return(0,p.jsx)(`section`,{className:(0,m.clsx)(`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:(0,p.jsx)(`div`,{className:`univer-relative univer-flex-1`,children:s&&(0,p.jsx)(s,{})})})}function fn(e){let t=oe(R);return(0,p.jsx)(pn,{...e,...t})}function pn(e){var t;let{header:n=!0,toolbar:r=!0,footer:i=!0,headerMenu:a=!0,contextMenu:o=!0,ribbonType:s=`classic`,mountContainer:l,onRendered:u}=e,h=(0,f.useDependency)(c.LocaleService),g=(0,f.useDependency)(c.ThemeService),_=(0,f.useDependency)(Ht),v=(0,d.useRef)(null),y=(0,f.useDependency)(c.IConfigService).getConfig(R),b=$(X.CUSTOM_HEADER),x=$(X.FOOTER),S=$(X.HEADER),C=$(X.HEADER_MENU),w=$(X.CONTENT),T=$(X.LEFT_SIDEBAR),E=$(X.GLOBAL),D=$(X.TOOLBAR),O=(t=y==null?void 0:y.popupRootId)==null?`univer-popup-portal`:t;(0,d.useLayoutEffect)(()=>{let e=g.currentTheme$.subscribe(e=>{_.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]);let[k,A]=(0,d.useState)(!1);(0,d.useLayoutEffect)(()=>{let e=g.darkMode$.subscribe(e=>{A(e),e?document.documentElement.classList.add(`univer-dark`):document.documentElement.classList.remove(`univer-dark`)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{v.current&&(u==null||u(v.current))},[u]);let[j,M]=(0,d.useState)(h.getLocales()),N=(0,d.useMemo)(()=>document.createElement(`div`),[]);return(0,d.useEffect)(()=>{document.body.appendChild(N);let e=[h.localeChanged$.subscribe(()=>{M(h.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(N)}},[h,l,N]),(0,p.jsxs)(m.ConfigProvider,{locale:j==null?void 0:j.design,mountContainer:N,children:[(0,p.jsxs)(`div`,{"data-u-comp":`workbench-layout`,className:(0,m.clsx)(`
|
|
228
|
-
univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white
|
|
229
|
-
dark:!univer-bg-gray-800
|
|
230
|
-
`,{"univer-dark":k}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[(0,p.jsx)(`div`,{className:`
|
|
231
|
-
univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white
|
|
232
|
-
dark:!univer-bg-gray-800
|
|
233
|
-
`,children:(0,p.jsx)(Q,{components:b},`custom-header`)}),n&&r&&(0,p.jsx)(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:(0,p.jsx)(Q,{components:D,sharedProps:{ribbonType:s,headerMenuComponents:C,headerMenu:a}},`toolbar`)}),(0,p.jsxs)(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[(0,p.jsxs)(`div`,{className:`
|
|
234
|
-
univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%]
|
|
235
|
-
univer-overflow-hidden
|
|
236
|
-
`,children:[(0,p.jsx)(`aside`,{"data-u-comp":`left-sidebar`,className:`univer-h-full`,children:(0,p.jsx)(Q,{components:T},`left-sidebar`)}),(0,p.jsxs)(`section`,{className:(0,m.clsx)(`
|
|
237
|
-
univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr]
|
|
238
|
-
univer-overflow-hidden univer-bg-white
|
|
239
|
-
dark:!univer-bg-gray-800
|
|
240
|
-
`,m.borderBottomClassName),children:[(0,p.jsx)(`header`,{children:n&&(0,p.jsx)(Q,{components:S},`header`)}),(0,p.jsx)(`section`,{className:`
|
|
241
|
-
univer-relative univer-overflow-hidden
|
|
242
|
-
dark:!univer-bg-gray-900
|
|
243
|
-
`,ref:v,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:(0,p.jsx)(Q,{components:w},`content`)})]}),(0,p.jsx)(`aside`,{"data-u-comp":`right-sidebar`,className:`univer-z-[100] univer-h-full`,children:(0,p.jsx)(ln,{})})]}),i&&(0,p.jsx)(`footer`,{children:(0,p.jsx)(Q,{components:x,sharedProps:{contextMenu:o}},`footer`)}),(0,p.jsx)(dn,{})]})]}),(0,p.jsx)(Q,{components:E},`global`),(0,p.jsx)(cn,{}),o&&(0,p.jsx)(on,{}),(0,p.jsx)(mn,{}),(0,p.jsx)(`div`,{id:O})]})}function mn(){let{mountContainer:e}=(0,d.useContext)(m.ConfigContext);return(0,_.createPortal)((0,p.jsx)(Q,{components:$(X.FLOATING)},`floating`),e)}var hn=class extends c.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._instanceService=t,this._layoutService=n,this._lifecycleService=r,this._renderManagerService=i,S(this,`_steadyTimeout`,void 0),S(this,`_renderTimeout`,void 0),S(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(c.LifecycleStages.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=c.LifecycleStages.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=c.LifecycleStages.Steady},3e3)},300)}catch(e){if(clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),e instanceof c.LifecycleUnreachableError)return;throw e}}))}_changeRenderUnit(e,t){if(this._currentRenderId===e)return!1;let n=this._renderManagerService.getRenderById(e);if(!n||!n.unitId||(0,c.isInternalEditorID)(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 gn=class extends hn{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(ht),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[ne,F],[ie,re],[he,pe],[ge,me],[be,_e],[ce,m.ColorPicker]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return _n(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.FLOATING,()=>(0,f.connectInjector)(Et,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(yt,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>(0,f.connectInjector)(Vt,this._injector)))}};gn=B([z(1,(0,c.Inject)(c.Injector)),z(2,(0,c.Inject)(c.LifecycleService)),z(3,h.IRenderManagerService),z(4,U),z(5,c.IUniverInstanceService),z(6,J),z(7,Z),z(8,(0,c.Inject)(k))],gn);function _n(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||vn(i):i instanceof HTMLElement?i:vn(`univer`);let a=(0,f.connectInjector)(fn,e),o=e=>n(e,r);function s(){(0,m.render)((0,p.jsx)(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),(0,c.toDisposable)(()=>{(0,m.unmount)(r)})}function vn(e){let t=document.createElement(`div`);return t.id=e,t}const yn=(0,c.createIdentifier)(`univer.ui.ui-controller`);var bn=`@univerjs/ui`,xn=`0.18.0`;const Sn=`
|
|
43
|
+
`),children:(0,p.jsx)(I,{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?(0,p.jsx)(`button`,{type:`button`,className:d,disabled:e.disabled,onClick:()=>{i==null||i({...e,id:n.id,label:t,commandId:e.commandId})},children:f},o):(0,p.jsx)(`div`,{className:d,"aria-disabled":e.disabled,children:f},o)})}),P&&(0,p.jsx)(tn,{menuSchemas:ee,submenuPortalContainer:r,onOptionSelect:i,maxMenuHeight:a})]})}),r):null)]})}function rn(e){let[t,n]=(0,d.useState)({});return(0,d.useEffect)(()=>{let t=e.map(e=>{var t;return(t=e.children)!=null&&t.length?(0,l.combineLatest)(e.children.map(e=>{var t,n;return(t=(n=e.item)==null?void 0:n.hidden$)==null?(0,l.of)(!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 an(e){let{hostId:t,visible:n,anchorRect:r,menuType:i,anchorVertical:a=`bottom`,menuOffset:o=0,onRequestClose:s,onOptionSelect:c}=e,l=(0,d.useRef)(null),u=(0,f.useDependency)(Gt),h=(0,d.useRef)(s),g=(0,d.useRef)(0),_=(0,d.useRef)(n),v=(0,d.useRef)(i);(0,d.useEffect)(()=>{h.current=s},[s]),n&&(!_.current||i!==v.current)&&(g.current+=1),_.current=n,v.current=i,(0,d.useEffect)(()=>{let e=u.registerMenu(t,()=>{h.current()});return()=>{e.dispose(),u.deactivateMenu(t)}},[u,t]),(0,d.useLayoutEffect)(()=>{if(n){u.activateMenu(t);return}u.deactivateMenu(t)},[u,t,n]),(0,d.useEffect)(()=>{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)&&h.current()},r=e=>{e.key===`Escape`&&h.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 y=(0,d.useMemo)(()=>{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(0,p.jsx)(m.Popup,{visible:n&&!!r,offset:y,overflowVisible:!0,placementY:a===`top`?`above`:`below`,children:(0,p.jsx)(`section`,{ref:l,children:i&&(0,p.jsx)(en,{menuType:i,menuSessionVersion:g.current,onOptionSelect:c})})})}function on(){let[e,t]=(0,d.useState)(!1),[n,r]=(0,d.useState)(``),[i,a]=(0,d.useState)(null),o=(0,d.useRef)(e),s=(0,f.useDependency)(Ut),l=(0,f.useDependency)(c.ICommandService),u=(0,f.useInjector)();o.current=e,(0,d.useEffect)(()=>{let e=s.registerContextMenuHandler({handleContextMenu:m,hideContextMenu(){h()},get visible(){return o.current}});return()=>{e.dispose()}},[s]);function m(e,n){t(!1),requestAnimationFrame(()=>{r(n),a({left:e.clientX,top:e.clientY,bottom:e.clientY}),t(!0)})}function h(){t(!1)}return(0,p.jsx)(an,{hostId:`desktop-context-menu`,visible:e,anchorRect:i,menuType:n,onRequestClose:h,onOptionSelect:e=>{let{label:t,commandId:n,value:r}=e;l&&l.executeCommand(n==null?t:n,{value:r}),u.get(U).focus(),h()}})}const sn=(0,c.createIdentifier)(`univer.global-zone-service`);function cn(){let e=(0,f.useDependency)(sn),[t,n]=(0,d.useState)(!1),r=(0,f.useObservable)(e.componentKey$,e.componentKey),i=(0,f.useDependency)(k),a=(0,d.useMemo)(()=>{let e=i.get(r==null?``:r);if(e)return e},[r,i]);return(0,d.useEffect)(()=>{let t=e.visible$.subscribe(e=>{n(e)});return()=>{t.unsubscribe()}},[e.visible$]),t?(0,p.jsx)(`section`,{className:(0,m.clsx)(`univer-absolute univer-bg-gray-100`,{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&(0,p.jsx)(a,{})}):null}function ln(){let e=(0,f.useDependency)(T),t=(0,f.useObservable)(e.sidebarOptions$),n=(0,d.useRef)(null),r=(0,d.useMemo)(()=>{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]=(0,p.jsx)(I,{...i},n))}}return e},[t]);(0,d.useEffect)(()=>(n.current&&e.setContainer(n.current),()=>{e.setContainer(void 0)}),[e]),(0,d.useEffect)(()=>{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=(0,d.useMemo)(()=>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(0,p.jsx)(`section`,{"data-u-comp":`sidebar`,className:(0,m.clsx)(`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:(0,p.jsxs)(`section`,{ref:n,className:(0,m.clsx)(`univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto] univer-overflow-y-auto`,m.borderLeftBottomClassName,m.scrollbarClassName),children:[(0,p.jsxs)(`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,(0,p.jsx)(`a`,{className:`univer-cursor-pointer univer-text-gray-500 dark:!univer-text-gray-300`,onClick:a,children:(0,p.jsx)(u.CloseIcon,{})})]}),(0,p.jsx)(`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)&&(0,p.jsx)(`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 un=(0,c.createIdentifier)(`univer.zen-zone-service`);function dn(){let e=(0,f.useDependency)(un),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(),a=(0,f.useObservable)(e.temporaryHidden$),o=(0,f.useDependency)(k);(0,d.useEffect)(()=>{let t=[e.visible$.subscribe(e=>{n(e)}),e.componentKey$.subscribe(e=>{i(e)})];return()=>{t.forEach(e=>{e.unsubscribe()})}},[]);let s=(0,d.useMemo)(()=>{let e=o.get(r==null?``:r);if(e)return e},[r]);return(0,p.jsx)(`section`,{className:(0,m.clsx)(`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:(0,p.jsx)(`div`,{className:`univer-relative univer-flex-1`,children:s&&(0,p.jsx)(s,{})})})}function fn(e){let t=oe(R);return(0,p.jsx)(pn,{...e,...t})}function pn(e){var t;let{header:n=!0,toolbar:r=!0,footer:i=!0,headerMenu:a=!0,contextMenu:o=!0,ribbonType:s=`classic`,mountContainer:l,onRendered:u}=e,h=(0,f.useDependency)(c.LocaleService),g=(0,f.useDependency)(c.ThemeService),_=(0,f.useDependency)(Ht),v=(0,d.useRef)(null),y=(0,f.useDependency)(c.IConfigService).getConfig(R),b=$(X.CUSTOM_HEADER),x=$(X.FOOTER),S=$(X.HEADER),C=$(X.HEADER_MENU),w=$(X.CONTENT),T=$(X.LEFT_SIDEBAR),E=$(X.GLOBAL),D=$(X.TOOLBAR),O=(t=y==null?void 0:y.popupRootId)==null?`univer-popup-portal`:t;(0,d.useLayoutEffect)(()=>{let e=g.currentTheme$.subscribe(e=>{_.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]);let[k,A]=(0,d.useState)(!1);(0,d.useLayoutEffect)(()=>{let e=g.darkMode$.subscribe(e=>{A(e),e?document.documentElement.classList.add(`univer-dark`):document.documentElement.classList.remove(`univer-dark`)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{v.current&&(u==null||u(v.current))},[u]);let[j,M]=(0,d.useState)(h.getLocales()),N=(0,d.useMemo)(()=>document.createElement(`div`),[]);return(0,d.useEffect)(()=>{document.body.appendChild(N);let e=[h.localeChanged$.subscribe(()=>{M(h.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(N)}},[h,l,N]),(0,p.jsxs)(m.ConfigProvider,{locale:j==null?void 0:j.design,mountContainer:N,children:[(0,p.jsxs)(`div`,{"data-u-comp":`workbench-layout`,className:(0,m.clsx)(`univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":k}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[(0,p.jsx)(`div`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,children:(0,p.jsx)(Q,{components:b},`custom-header`)}),n&&r&&(0,p.jsx)(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:(0,p.jsx)(Q,{components:D,sharedProps:{ribbonType:s,headerMenuComponents:C,headerMenu:a}},`toolbar`)}),(0,p.jsxs)(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[(0,p.jsxs)(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[(0,p.jsx)(`aside`,{"data-u-comp":`left-sidebar`,className:`univer-h-full`,children:(0,p.jsx)(Q,{components:T},`left-sidebar`)}),(0,p.jsxs)(`section`,{className:(0,m.clsx)(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,m.borderBottomClassName),children:[(0,p.jsx)(`header`,{children:n&&(0,p.jsx)(Q,{components:S},`header`)}),(0,p.jsx)(`section`,{className:`univer-relative univer-overflow-hidden dark:!univer-bg-gray-900`,ref:v,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:(0,p.jsx)(Q,{components:w},`content`)})]}),(0,p.jsx)(`aside`,{"data-u-comp":`right-sidebar`,className:`univer-z-[100] univer-h-full`,children:(0,p.jsx)(ln,{})})]}),i&&(0,p.jsx)(`footer`,{children:(0,p.jsx)(Q,{components:x,sharedProps:{contextMenu:o}},`footer`)}),(0,p.jsx)(dn,{})]})]}),(0,p.jsx)(Q,{components:E},`global`),(0,p.jsx)(cn,{}),o&&(0,p.jsx)(on,{}),(0,p.jsx)(mn,{}),(0,p.jsx)(`div`,{id:O})]})}function mn(){let{mountContainer:e}=(0,d.useContext)(m.ConfigContext);return(0,_.createPortal)((0,p.jsx)(Q,{components:$(X.FLOATING)},`floating`),e)}var hn=class extends c.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._instanceService=t,this._layoutService=n,this._lifecycleService=r,this._renderManagerService=i,S(this,`_steadyTimeout`,void 0),S(this,`_renderTimeout`,void 0),S(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(c.LifecycleStages.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=c.LifecycleStages.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=c.LifecycleStages.Steady},3e3)},300)}catch(e){if(clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout),e instanceof c.LifecycleUnreachableError)return;throw e}}))}_changeRenderUnit(e,t){if(this._currentRenderId===e)return!1;let n=this._renderManagerService.getRenderById(e);if(!n||!n.unitId||(0,c.isInternalEditorID)(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 gn=class extends hn{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(ht),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[ne,F],[ie,re],[he,pe],[ge,me],[be,_e],[ce,m.ColorPicker]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return _n(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.FLOATING,()=>(0,f.connectInjector)(Et,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(yt,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>(0,f.connectInjector)(Vt,this._injector)))}};gn=B([z(1,(0,c.Inject)(c.Injector)),z(2,(0,c.Inject)(c.LifecycleService)),z(3,h.IRenderManagerService),z(4,U),z(5,c.IUniverInstanceService),z(6,J),z(7,Z),z(8,(0,c.Inject)(k))],gn);function _n(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||vn(i):i instanceof HTMLElement?i:vn(`univer`);let a=(0,f.connectInjector)(fn,e),o=e=>n(e,r);function s(){(0,m.render)((0,p.jsx)(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),(0,c.toDisposable)(()=>{(0,m.unmount)(r)})}function vn(e){let t=document.createElement(`div`);return t.id=e,t}const yn=(0,c.createIdentifier)(`univer.ui.ui-controller`);var bn=`@univerjs/ui`,xn=`0.19.0`;const Sn=`
|
|
244
44
|
univer-m-0 univer-flex univer-appearance-none univer-items-center univer-justify-center
|
|
245
45
|
univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outline-none
|
|
246
|
-
`;function Cn(e){var t;let{headerMenuComponents:n,headerMenu:r=!0}=e,i=(0,f.useDependency)(c.LocaleService),a=(0,f.useDependency)(Dt),o=(0,f.useObservable)(a.ribbon$,[]),s=(0,f.useObservable)(a.activatedTab$,
|
|
247
|
-
univer-flex univer-flex-col univer-gap-1.5 univer-bg-gray-50 univer-px-3 univer-py-1.5 univer-text-sm
|
|
248
|
-
dark:!univer-bg-gray-900
|
|
249
|
-
`,m.borderBottomClassName),children:[(0,p.jsxs)(`div`,{className:`
|
|
46
|
+
`;function Cn(e){var t;let{headerMenuComponents:n,headerMenu:r=!0}=e,i=(0,f.useDependency)(c.LocaleService),a=(0,f.useDependency)(Dt),o=(0,f.useObservable)(a.ribbon$,[]),s=(0,f.useObservable)(a.activatedTab$,W.START),l=(0,d.useMemo)(()=>{let e=o.findIndex(e=>e.key===s);return e===-1?0:e},[s,o]),h=o[l],g=(t=h==null?void 0:h.children)==null?[]:t,_=!!(r&&n&&n.size>0),v=(0,d.useRef)(null),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(!1);if((0,d.useEffect)(()=>{!h&&o.length>0&&a.setActivatedTab(o[0].key)},[h,o,a]),(0,d.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{let{scrollLeft:t,clientWidth:n,scrollWidth:r}=e;b(t>4),S(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)}},[h]),o.length===0&&!_)return null;function C(e){let t=o[e];t&&a.setActivatedTab(t.key)}function w(e){let t=v.current;t&&t.scrollBy({left:e===`left`?-168:168,behavior:`smooth`})}return(0,p.jsxs)(`div`,{"data-u-comp":`mobile-ribbon`,className:(0,m.clsx)(`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`,m.borderBottomClassName),children:[(0,p.jsxs)(`div`,{className:`
|
|
250
47
|
univer-grid univer-grid-cols-[28px_minmax(0,1fr)_auto] univer-items-center univer-gap-1.5
|
|
251
48
|
univer-px-0.5 univer-py-0.5
|
|
252
|
-
`,children:[(0,p.jsx)(`div`,{className:`univer-flex univer-items-center`,children:(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(Sn,`
|
|
253
|
-
univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors
|
|
254
|
-
hover:univer-bg-gray-100
|
|
255
|
-
active:univer-bg-gray-200
|
|
256
|
-
dark:!univer-text-gray-300
|
|
257
|
-
dark:hover:!univer-bg-gray-700
|
|
258
|
-
dark:active:!univer-bg-gray-600
|
|
259
|
-
`,{"univer-opacity-40":l===0}),disabled:l===0,"aria-label":`Previous`,onClick:()=>C(l-1),children:(0,p.jsx)(u.MoreIcon,{className:`univer-rotate-180 univer-text-sm`})})}),(0,p.jsx)(`div`,{className:`univer-flex univer-min-w-0 univer-items-center univer-justify-center univer-gap-2.5`,children:o.map((e,t)=>{let n=t===l;return(0,p.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,className:(0,m.clsx)(`
|
|
49
|
+
`,children:[(0,p.jsx)(`div`,{className:`univer-flex univer-items-center`,children:(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(Sn,`univer-size-7 univer-rounded-md univer-text-gray-500 univer-transition-colors hover:univer-bg-gray-100 active:univer-bg-gray-200 dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700 dark:active:!univer-bg-gray-600`,{"univer-opacity-40":l===0}),disabled:l===0,"aria-label":`Previous`,onClick:()=>C(l-1),children:(0,p.jsx)(u.MoreIcon,{className:`univer-rotate-180 univer-text-sm`})})}),(0,p.jsx)(`div`,{className:`univer-flex univer-min-w-0 univer-items-center univer-justify-center univer-gap-2.5`,children:o.map((e,t)=>{let n=t===l;return(0,p.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,className:(0,m.clsx)(`
|
|
260
50
|
${Sn}
|
|
261
51
|
univer-relative univer-shrink-0 univer-px-1 univer-py-1 univer-text-sm
|
|
262
52
|
univer-font-semibold univer-transition-colors
|
|
@@ -284,54 +74,11 @@ univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outl
|
|
|
284
74
|
[&>*]:univer-appearance-none [&>*]:univer-items-center [&>*]:univer-justify-center
|
|
285
75
|
[&>*]:univer-rounded-md [&>*]:univer-border-0 [&>*]:univer-px-1.5
|
|
286
76
|
[&>*]:univer-leading-none [&>*]:univer-outline-none
|
|
287
|
-
`,children:(0,p.jsx)(Q,{components:n})})]})]}),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`
|
|
288
|
-
univer-grid univer-grid-cols-[22px_minmax(0,1fr)_22px] univer-items-center univer-gap-1.5
|
|
289
|
-
univer-rounded-xl univer-bg-white univer-px-2 univer-py-1
|
|
290
|
-
dark:!univer-bg-gray-800
|
|
291
|
-
`,m.borderClassName),children:[(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(`
|
|
77
|
+
`,children:(0,p.jsx)(Q,{components:n})})]})]}),(0,p.jsxs)(`div`,{className:(0,m.clsx)(`univer-grid univer-grid-cols-[22px_minmax(0,1fr)_22px] univer-items-center univer-gap-1.5 univer-rounded-xl univer-bg-white univer-px-2 univer-py-1 dark:!univer-bg-gray-800`,m.borderClassName),children:[(0,p.jsx)(`button`,{type:`button`,className:(0,m.clsx)(`
|
|
292
78
|
${Sn}
|
|
293
79
|
univer-h-8 univer-w-5 univer-text-gray-500 univer-transition-colors
|
|
294
80
|
dark:!univer-text-gray-300
|
|
295
|
-
`,{"univer-opacity-30":!y}),disabled:!y,"aria-label":`Previous`,onClick:()=>w(`left`),children:(0,p.jsx)(u.MoreLeftIcon,{className:`univer-text-sm`})}),(0,p.jsx)(`div`,{ref:v,"data-u-comp":`mobile-ribbon-toolbar`,className:`
|
|
296
|
-
univer-flex univer-min-w-0 univer-items-center univer-gap-1.5 univer-overflow-x-auto
|
|
297
|
-
univer-scroll-smooth univer-px-0.5
|
|
298
|
-
[&::-webkit-scrollbar]:univer-hidden
|
|
299
|
-
`,children:g.map((e,t)=>{var n,r;let i=(n=(r=e.children)==null?void 0:r.filter(e=>!!e.item))==null?[]:n;return i.length?(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
300
|
-
univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5
|
|
301
|
-
rtl:univer-pl-1.5 rtl:univer-pr-0
|
|
302
|
-
`,{[m.borderRightClassName]:t!==g.length-1}),children:i.map(e=>e.item&&(0,p.jsx)(`div`,{className:(0,m.clsx)(`
|
|
303
|
-
[&_button]:!univer-font-inherit
|
|
304
|
-
univer-flex univer-h-8 univer-shrink-0 univer-items-center
|
|
305
|
-
univer-rounded-md
|
|
306
|
-
[&_*]:univer-box-border
|
|
307
|
-
[&_.univer-custom-label]:univer-text-sm
|
|
308
|
-
[&_.univer-custom-label]:univer-leading-none
|
|
309
|
-
[&_.univer-toolbar-button-selector-main]:!univer-h-8
|
|
310
|
-
[&_.univer-toolbar-button-selector-main]:!univer-rounded-none
|
|
311
|
-
[&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md
|
|
312
|
-
[&_.univer-toolbar-button-selector-main]:!univer-px-1.5
|
|
313
|
-
[&_.univer-toolbar-button-selector-root]:!univer-h-8
|
|
314
|
-
[&_.univer-toolbar-button-selector-root]:univer-overflow-hidden
|
|
315
|
-
[&_.univer-toolbar-button-selector-root]:!univer-rounded-md
|
|
316
|
-
[&_.univer-toolbar-button-selector-root]:!univer-pr-0
|
|
317
|
-
[&_.univer-toolbar-button-selector-trigger]:!univer-static
|
|
318
|
-
[&_.univer-toolbar-button-selector-trigger]:!univer-h-8
|
|
319
|
-
[&_.univer-toolbar-button-selector-trigger]:!univer-w-6
|
|
320
|
-
[&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none
|
|
321
|
-
[&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md
|
|
322
|
-
[&_.univer-toolbar-selector-root]:!univer-h-8
|
|
323
|
-
[&_.univer-toolbar-selector-root]:!univer-gap-1
|
|
324
|
-
[&_.univer-toolbar-selector-root]:!univer-rounded-md
|
|
325
|
-
[&_.univer-toolbar-selector-root]:!univer-px-1.5
|
|
326
|
-
[&_.univer-toolbar-selector-trigger]:!univer-pl-0.5
|
|
327
|
-
[&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full
|
|
328
|
-
[&_.univer-tooltip]:univer-items-center
|
|
329
|
-
[&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8
|
|
330
|
-
[&_[data-u-command]]:!univer-rounded-md
|
|
331
|
-
[&_[data-u-command]]:!univer-px-1.5
|
|
332
|
-
[&_button]:!univer-h-8 [&_button]:!univer-min-w-8
|
|
333
|
-
[&_button]:!univer-rounded-md [&_button]:!univer-px-1.5
|
|
334
|
-
`,`
|
|
81
|
+
`,{"univer-opacity-30":!y}),disabled:!y,"aria-label":`Previous`,onClick:()=>w(`left`),children:(0,p.jsx)(u.MoreLeftIcon,{className:`univer-text-sm`})}),(0,p.jsx)(`div`,{ref:v,"data-u-comp":`mobile-ribbon-toolbar`,className:`univer-flex univer-min-w-0 univer-items-center univer-gap-1.5 univer-overflow-x-auto univer-scroll-smooth univer-px-0.5 [&::-webkit-scrollbar]:univer-hidden`,children:g.map((e,t)=>{var n,r;let i=(n=(r=e.children)==null?void 0:r.filter(e=>!!e.item))==null?[]:n;return i.length?(0,p.jsx)(`div`,{className:(0,m.clsx)(`univer-flex univer-shrink-0 univer-items-center univer-gap-0.5 univer-pr-1.5 rtl:univer-pl-1.5 rtl:univer-pr-0`,{[m.borderRightClassName]:t!==g.length-1}),children:i.map(e=>e.item&&(0,p.jsx)(`div`,{className:(0,m.clsx)(`[&_button]:!univer-font-inherit univer-flex univer-h-8 univer-shrink-0 univer-items-center univer-rounded-md [&_*]:univer-box-border [&_.univer-custom-label]:univer-text-sm [&_.univer-custom-label]:univer-leading-none [&_.univer-toolbar-button-selector-main]:!univer-h-8 [&_.univer-toolbar-button-selector-main]:!univer-rounded-none [&_.univer-toolbar-button-selector-main]:!univer-rounded-l-md [&_.univer-toolbar-button-selector-main]:!univer-px-1.5 [&_.univer-toolbar-button-selector-root]:!univer-h-8 [&_.univer-toolbar-button-selector-root]:univer-overflow-hidden [&_.univer-toolbar-button-selector-root]:!univer-rounded-md [&_.univer-toolbar-button-selector-root]:!univer-pr-0 [&_.univer-toolbar-button-selector-trigger]:!univer-static [&_.univer-toolbar-button-selector-trigger]:!univer-h-8 [&_.univer-toolbar-button-selector-trigger]:!univer-w-6 [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-none [&_.univer-toolbar-button-selector-trigger]:!univer-rounded-r-md [&_.univer-toolbar-selector-root]:!univer-h-8 [&_.univer-toolbar-selector-root]:!univer-gap-1 [&_.univer-toolbar-selector-root]:!univer-rounded-md [&_.univer-toolbar-selector-root]:!univer-px-1.5 [&_.univer-toolbar-selector-trigger]:!univer-pl-0.5 [&_.univer-tooltip]:univer-inline-flex [&_.univer-tooltip]:univer-h-full [&_.univer-tooltip]:univer-items-center [&_[data-u-command]]:!univer-h-8 [&_[data-u-command]]:!univer-min-h-8 [&_[data-u-command]]:!univer-rounded-md [&_[data-u-command]]:!univer-px-1.5 [&_button]:!univer-h-8 [&_button]:!univer-min-w-8 [&_button]:!univer-rounded-md [&_button]:!univer-px-1.5`,`
|
|
335
82
|
[&_button]:!univer-m-0 [&_button]:!univer-appearance-none [&_button]:!univer-border-0
|
|
336
83
|
[&_button]:!univer-bg-transparent [&_button]:!univer-p-0 [&_button]:!univer-leading-none
|
|
337
84
|
[&_button]:!univer-outline-none
|
|
@@ -357,26 +104,13 @@ univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outl
|
|
|
357
104
|
`,children:l.title}),(0,p.jsx)(`div`,{className:`univer-size-8`,"aria-hidden":`true`})]}),(0,p.jsxs)(`div`,{className:`univer-flex-1 univer-overflow-y-auto univer-px-4 univer-pb-2 univer-pt-1`,children:[(l==null?void 0:l.kind)!==`options`&&(0,p.jsx)(`div`,{className:`univer-overflow-hidden univer-rounded-2xl univer-bg-white`,children:(0,p.jsx)(Tn,{schemas:(l==null?void 0:l.kind)===`schema`?l.schemas:c,menuType:n,onExecute:r,onOpenView:m})}),(l==null?void 0:l.kind)===`options`&&(0,p.jsx)(`div`,{className:`univer-overflow-hidden univer-rounded-2xl univer-bg-white`,children:(0,p.jsx)(Dn,{menuKey:l.menuKey,menuItem:l.menuItem,options:l.options,currentValue:l.currentValue,onExecute:r})})]})]})}function Tn(e){let{schemas:t,menuType:n,onExecute:r,onOpenView:i}=e,a=(0,f.useDependency)(c.LocaleService),o=jn(t),s=(0,d.useMemo)(()=>t.filter(e=>{var t;return(t=e.children)!=null&&t.length?!o[e.key]:!!e.item}),[o,t]);return(0,p.jsx)(p.Fragment,{children:s.map((e,t)=>{var o;return e.item?(0,p.jsx)(En,{schema:e,menuType:n,onExecute:r,onOpenView:i,bordered:t!==s.length-1},e.key):(o=e.children)!=null&&o.length?(0,p.jsxs)(`section`,{className:(0,m.clsx)(`univer-grid`,t!==s.length-1&&m.borderBottomClassName),children:[e.title&&(0,p.jsx)(`div`,{className:`
|
|
358
105
|
univer-px-4 univer-pb-1 univer-pt-3 univer-text-xs univer-font-medium univer-uppercase
|
|
359
106
|
univer-tracking-[0.08em] univer-text-gray-500
|
|
360
|
-
`,children:a.t(e.title)}),e.children.map((t,a)=>(0,p.jsx)(En,{schema:t,menuType:n,onExecute:r,onOpenView:i,bordered:a!==e.children.length-1},t.key))]},e.key):null})})}function En(e){let{schema:t,menuType:n,onExecute:r,onOpenView:i,bordered:a}=e,o=kn({schema:t,menuType:n,onOpenView:i});if(!o||o.hidden)return null;let{menuItem:s,disabled:c,value:l,currentValueText:d,hasSubmenu:f,onPress:h}=o;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`
|
|
361
|
-
univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none univer-items-center univer-gap-3
|
|
362
|
-
univer-border-0 univer-bg-white univer-px-4 univer-py-3 univer-text-left univer-transition-colors
|
|
363
|
-
enabled:hover:univer-bg-gray-50
|
|
364
|
-
enabled:active:univer-bg-gray-100
|
|
365
|
-
disabled:univer-cursor-not-allowed disabled:univer-opacity-40
|
|
366
|
-
`,a&&m.borderBottomClassName),disabled:c,onClick:()=>h(r),children:[(0,p.jsx)(`div`,{className:`
|
|
107
|
+
`,children:a.t(e.title)}),e.children.map((t,a)=>(0,p.jsx)(En,{schema:t,menuType:n,onExecute:r,onOpenView:i,bordered:a!==e.children.length-1},t.key))]},e.key):null})})}function En(e){let{schema:t,menuType:n,onExecute:r,onOpenView:i,bordered:a}=e,o=kn({schema:t,menuType:n,onOpenView:i});if(!o||o.hidden)return null;let{menuItem:s,disabled:c,value:l,currentValueText:d,hasSubmenu:f,onPress:h}=o;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none univer-items-center univer-gap-3 univer-border-0 univer-bg-white univer-px-4 univer-py-3 univer-text-left univer-transition-colors enabled:hover:univer-bg-gray-50 enabled:active:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40`,a&&m.borderBottomClassName),disabled:c,onClick:()=>h(r),children:[(0,p.jsx)(`div`,{className:`
|
|
367
108
|
univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-3 univer-text-gray-900
|
|
368
109
|
[&>span]:univer-truncate [&>span]:univer-text-sm [&>span]:univer-font-medium
|
|
369
110
|
[&>svg]:univer-shrink-0 [&>svg]:univer-text-lg [&>svg]:univer-text-gray-700
|
|
370
111
|
`,children:(0,p.jsx)(I,{value:l,title:s.title,label:s.label,icon:s.icon})}),d&&(0,p.jsx)(`span`,{className:`
|
|
371
112
|
univer-max-w-[32%] univer-truncate univer-text-xs univer-font-medium univer-text-gray-400
|
|
372
|
-
`,children:d}),f&&(0,p.jsx)(u.MoreIcon,{className:`univer-shrink-0 univer-text-base univer-text-gray-400`})]})}function Dn(e){let{options:t,menuKey:n,menuItem:r,currentValue:i,onExecute:a}=e;return(0,p.jsx)(p.Fragment,{children:t.map((e,o)=>{var s;return(0,p.jsx)(On,{option:e,menuKey:n,menuItem:r,currentValue:i,bordered:o!==t.length-1,onExecute:a},`${n}-${String((s=e.value)==null?o:s)}`)})})}function On(e){var t;let{option:n,menuKey:r,menuItem:i,currentValue:a,bordered:o,onExecute:s}=e,c=(0,f.useObservable)(n.value$),l=(t=n.value)==null?c:t,d=l===a;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`
|
|
373
|
-
univer-relative univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none
|
|
374
|
-
univer-items-center univer-gap-3 univer-border-0 univer-bg-white univer-px-4 univer-py-3
|
|
375
|
-
univer-text-left univer-transition-colors
|
|
376
|
-
enabled:hover:univer-bg-gray-50
|
|
377
|
-
enabled:active:univer-bg-gray-100
|
|
378
|
-
disabled:univer-cursor-not-allowed disabled:univer-opacity-40
|
|
379
|
-
`,o&&m.borderBottomClassName),disabled:n.disabled,onClick:()=>{s==null||s({...n,value:l,id:i.id,label:r,commandId:n.commandId})},children:[(0,p.jsx)(`div`,{className:`
|
|
113
|
+
`,children:d}),f&&(0,p.jsx)(u.MoreIcon,{className:`univer-shrink-0 univer-text-base univer-text-gray-400`})]})}function Dn(e){let{options:t,menuKey:n,menuItem:r,currentValue:i,onExecute:a}=e;return(0,p.jsx)(p.Fragment,{children:t.map((e,o)=>{var s;return(0,p.jsx)(On,{option:e,menuKey:n,menuItem:r,currentValue:i,bordered:o!==t.length-1,onExecute:a},`${n}-${String((s=e.value)==null?o:s)}`)})})}function On(e){var t;let{option:n,menuKey:r,menuItem:i,currentValue:a,bordered:o,onExecute:s}=e,c=(0,f.useObservable)(n.value$),l=(t=n.value)==null?c:t,d=l===a;return(0,p.jsxs)(`button`,{type:`button`,className:(0,m.clsx)(`univer-relative univer-flex univer-min-h-[56px] univer-w-full univer-appearance-none univer-items-center univer-gap-3 univer-border-0 univer-bg-white univer-px-4 univer-py-3 univer-text-left univer-transition-colors enabled:hover:univer-bg-gray-50 enabled:active:univer-bg-gray-100 disabled:univer-cursor-not-allowed disabled:univer-opacity-40`,o&&m.borderBottomClassName),disabled:n.disabled,onClick:()=>{s==null||s({...n,value:l,id:i.id,label:r,commandId:n.commandId})},children:[(0,p.jsx)(`div`,{className:`
|
|
380
114
|
univer-flex univer-min-w-0 univer-flex-1 univer-items-center univer-gap-3 univer-text-gray-900
|
|
381
115
|
[&>span]:univer-truncate [&>span]:univer-text-sm [&>span]:univer-font-medium
|
|
382
116
|
[&>svg]:univer-shrink-0 [&>svg]:univer-text-lg [&>svg]:univer-text-gray-700
|
|
@@ -391,19 +125,9 @@ univer-border-0 univer-bg-transparent univer-p-0 univer-leading-none univer-outl
|
|
|
391
125
|
univer-ring-0 univer-transition-colors
|
|
392
126
|
hover:univer-bg-gray-100
|
|
393
127
|
active:univer-bg-gray-200
|
|
394
|
-
`,style:{margin:0},onClick:y,children:(0,p.jsx)(u.CloseIcon,{className:`univer-size-4 univer-text-current`})})]})]}),n&&(0,p.jsx)(wn,{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&&(l.focus(),s.executeCommand(r,a),y())}})]})]}),g)}function Fn(e){let{header:t=!0,toolbar:n=!0,footer:r=!0,headerMenu:i=!0,ribbonType:a=`classic`,contextMenu:o=!0,mountContainer:s,onRendered:l}=e,u=(0,f.useDependency)(c.LocaleService),h=(0,f.useDependency)(c.ThemeService),g=(0,f.useDependency)(Ht),_=(0,d.useRef)(null),v=$(X.FOOTER),y=$(X.HEADER),b=$(X.HEADER_MENU),x=$(X.CONTENT),S=$(X.LEFT_SIDEBAR),C=$(X.GLOBAL),w=$(X.TOOLBAR),[T,E]=(0,d.useState)(!1);(0,d.useEffect)(()=>{let e=h.darkMode$.subscribe(e=>{E(e)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{_.current&&(l==null||l(_.current))},[l]);let[D,O]=(0,d.useState)(u.getLocales()),k=(0,d.useMemo)(()=>document.createElement(`div`),[]);return(0,d.useLayoutEffect)(()=>{let e=h.currentTheme$.subscribe(e=>{g.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{document.body.appendChild(k);let e=[u.localeChanged$.subscribe(()=>{O(u.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(k)}},[u,s,k]),(0,p.jsxs)(m.ConfigProvider,{locale:D==null?void 0:D.design,mountContainer:k,children:[(0,p.jsxs)(`div`,{"data-u-comp":`app-layout`,className:(0,m.clsx)(`
|
|
395
|
-
univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
`,children:[(0,p.jsx)(`aside`,{className:`univer-h-full`,children:(0,p.jsx)(Q,{components:S},`left-sidebar`)}),(0,p.jsxs)(`section`,{className:(0,m.clsx)(`
|
|
401
|
-
univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr]
|
|
402
|
-
univer-overflow-hidden univer-bg-white
|
|
403
|
-
dark:!univer-bg-gray-800
|
|
404
|
-
`,m.borderBottomClassName),children:[(0,p.jsx)(`header`,{className:`univer-w-screen`,children:t&&(0,p.jsx)(Q,{components:y},`header`)}),(0,p.jsx)(`section`,{ref:_,className:`univer-relative univer-overflow-hidden`,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:(0,p.jsx)(Q,{components:x},`content`)})]}),(0,p.jsx)(`aside`,{className:`univer-h-full`,children:(0,p.jsx)(ln,{})})]}),r&&(0,p.jsx)(`footer`,{children:(0,p.jsx)(Q,{components:v},`footer`)}),(0,p.jsx)(cn,{}),(0,p.jsx)(dn,{})]})]}),(0,p.jsx)(Q,{components:C},`global`),o&&(0,p.jsx)(Pn,{})]})}let In=class extends hn{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(ht),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return Ln(this._injector,this._config,e)}_registerComponents(){[[ne,F],[ie,re],[he,pe],[ge,me],[be,_e],[ce,m.ColorPicker]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(Et,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(yt,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>(0,f.connectInjector)(Cn,this._injector)))}};In=B([z(1,(0,c.Inject)(c.Injector)),z(2,(0,c.Inject)(c.LifecycleService)),z(3,h.IRenderManagerService),z(4,U),z(5,c.IUniverInstanceService),z(6,J),z(7,Z),z(8,(0,c.Inject)(k))],In);function Ln(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||Rn(i):i instanceof HTMLElement?i:Rn(`univer`);let a=(0,f.connectInjector)(Fn,e),o=e=>n(e,r);function s(){(0,m.render)((0,p.jsx)(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),(0,c.toDisposable)(()=>{(0,m.unmount)(r)})}function Rn(e){let t=document.createElement(`div`);return t.id=e,t}const zn=(0,c.createIdentifier)(`ui.notification.service`),Bn=(0,c.createIdentifier)(`univer.ui.before-close-service`);let Vn=class{constructor(e){this._notificationService=e,S(this,`_beforeUnloadCallbacks`,[]),S(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(`
|
|
405
|
-
`);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())})}};Vn=B([z(0,zn)],Vn);function Hn(){return navigator.clipboard!==void 0&&navigator.clipboard.readText!==void 0}const Un=`text/plain`,Wn=`text/html`,Gn=`image/png`,Kn=`image/jpeg`,qn=`image/bmp`,Jn=`image/webp`,Yn=new Set([qn,Kn,Jn,Gn]),Xn=(0,c.createIdentifier)(`univer.clipboard-interface-service`);let Zn=class extends c.Disposable{get supportClipboard(){return Hn()}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({[Un]:new Blob([e],{type:Un}),[Wn]:new Blob([t],{type:Wn})})])}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=$n();document.body.appendChild(n),n.innerHTML=e;try{er(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_legacyCopyText(e){let t=document.activeElement,n=Qn();document.body.appendChild(n),n.value=e;try{er(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`)})}};Zn=B([z(0,(0,c.Inject)(c.LocaleService)),z(1,c.ILogService),z(2,(0,c.Optional)(zn))],Zn);function Qn(){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 $n(){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 er(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 tr=e=>{let{children:t,onClose:n,onConfirm:r}=e,[i]=(0,d.useState)({}),a=t?(0,d.cloneElement)(t,{hooks:i}):null;return(0,p.jsx)(m.Confirm,{...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 nr(){let e=(0,f.useDependency)(c.IConfirmService),[t,n]=(0,d.useState)([]);(0,d.useEffect)(()=>{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]=(0,p.jsx)(I,{...r}))}return i});return r==null?void 0:r.map((e,t)=>(0,p.jsx)(tr,{...e,children:e.children},t))}let rr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`_confirmOptions`,[]),S(this,`confirmOptions$`,new l.BehaviorSubject([])),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),(0,c.toDisposable)(()=>{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,()=>(0,f.connectInjector)(nr,this._injector)))}};rr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],rr);const ir=(0,c.createIdentifier)(`univer.ui.dialog-service`);function ar(){let e=(0,f.useDependency)(ir),[t,n]=(0,d.useState)([]);(0,d.useEffect)(()=>{let t=e.getDialogs$().subscribe(e=>{n(e)});return()=>t.unsubscribe()},[]);let r=(0,d.useMemo)(()=>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]=(0,p.jsx)(I,{...r}))}return a}),[t]);return r==null?void 0:r.map(e=>(0,p.jsx)(m.Dialog,{...e},e.id))}let or=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`_dialogOptions`,[]),S(this,`_dialogOptions$`,new l.Subject),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),(0,c.toDisposable)(()=>{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,()=>(0,f.connectInjector)(ar,this._injector)))}};or=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],or);const sr=(0,c.createIdentifier)(`univer.ui.gallery-service`);function cr(){let e=(0,f.useObservable)((0,f.useDependency)(sr).gallery$);return e?(0,p.jsx)(m.Gallery,{...e}):null}let lr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`gallery$`,new l.Subject),this._initUIPart()}dispose(){super.dispose()}open(e){return this.gallery$.next({open:!0,...e}),(0,c.toDisposable)(()=>{this.gallery$.complete()})}close(){this.gallery$.next({open:!1,images:[]})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(cr,this._injector)))}};lr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],lr);let ur=class{constructor(e){this._componentManager=e,S(this,`visible$`,new l.Subject),S(this,`componentKey$`,new l.Subject),S(this,`_componentKey`,``)}get componentKey(){return this._componentKey}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),this._componentKey=e,(0,c.toDisposable)(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};ur=B([z(0,(0,c.Inject)(k))],ur);var dr=class extends c.Disposable{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 fr=(0,c.createIdentifier)(`univer-ui.local-file.service`);var pr=class{getItem(e){return v.default.getItem(e)}setItem(e,t){return v.default.setItem(e,t)}removeItem(e){return v.default.removeItem(e)}clear(){return v.default.clear()}key(e){return v.default.key(e)}keys(){return v.default.keys()}iterate(e){return v.default.iterate(e)}};function mr(){return(0,p.jsx)(m.Messager,{theme:(0,f.useObservable)((0,f.useDependency)(c.ThemeService).darkMode$)?`dark`:`light`})}let hr=0,gr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(mr,this._injector)))}dispose(){super.dispose(),(0,m.removeMessage)()}show(e){var t;let n=(t=e.id)==null?`message-${Date.now()}-${hr}`:t;return hr+=1,(0,m.message)(Object.assign({},e,{id:n})),(0,c.toDisposable)(()=>(0,m.removeMessage)(n))}remove(e){(0,m.removeMessage)(e)}removeAll(){(0,m.removeMessage)()}};gr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],gr);function _r(){return(0,p.jsx)(m.Toaster,{theme:(0,f.useObservable)((0,f.useDependency)(c.ThemeService).darkMode$)?`dark`:`light`})}const vr={show:e=>{let{type:t=`message`,title:n,content:r,duration:i,closable:a=!0,position:o=`top-right`}=e;m.toast[t](n,{position:o,description:r,duration:i,closeButton:a})}};let yr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}show(e){return vr.show(e),(0,c.toDisposable)(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(_r,this._injector)))}};yr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],yr);var br=class{constructor(){S(this,`_sidebarOptions`,{}),S(this,`sidebarOptions$`,new l.Subject),S(this,`scrollEvent$`,new l.Subject),S(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),(0,c.toDisposable)(()=>{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 xr=class{get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}constructor(e){this._componentManager=e,S(this,`visible$`,new l.BehaviorSubject(!1)),S(this,`componentKey$`,new l.ReplaySubject),S(this,`_temporaryHidden$`,new l.BehaviorSubject(!1)),S(this,`temporaryHidden$`,this._temporaryHidden$.asObservable()),S(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),(0,c.toDisposable)(()=>{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)}};xr=B([z(0,(0,c.Inject)(k))],xr);let Sr=class extends c.Plugin{constructor(e=le,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({popupRootId:`univer-popup-portal-${(0,c.generateRandomId)(6)}`},le,this._config);a.disableAutoFocus&&this._contextService.setContextValue(`DISABLE_AUTO_FOCUS`,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(R,a)}onStarting(){(0,c.registerDependencies)(this._injector,(0,c.mergeOverrideWithDependencies)([[k],[Ht],[A],[C],[Z,{useClass:gt}],[U,{useClass:Be}],[Dt,{useClass:Ot}],[We,{useClass:Ge}],[He,{useClass:Ue}],[J,{useClass:ot}],[Gt,{useClass:Kt}],[Ut,{useClass:Wt}],[Xn,{useClass:Zn,lazy:!0}],[zn,{useClass:yr,lazy:!0}],[sr,{useClass:lr,lazy:!0}],[ir,{useClass:or,lazy:!0}],[c.IConfirmService,{useClass:rr,lazy:!0}],[T,{useClass:br,lazy:!0}],[un,{useClass:xr,lazy:!0}],[sn,{useClass:ur,lazy:!0}],[ke,{useClass:gr,lazy:!0}],[c.ILocalStorageService,{useClass:pr,lazy:!0}],[Bn,{useClass:Vn}],[fr,{useClass:dr}],[bt,{useClass:xt}],[ue,{useClass:fe}],[_t],[yn,{useFactory:e=>e.createInstance(In,this._config),deps:[c.Injector]}],[W],[Ae],[lt]],this._config.override)),(0,c.touchDependencies)(this._injector,[[yn],[Ae]])}onReady(){(0,c.touchDependencies)(this._injector,[[W]])}onSteady(){(0,c.touchDependencies)(this._injector,[[lt]])}};S(Sr,`pluginName`,`UNIVER_MOBILE_UI_PLUGIN`),S(Sr,`packageName`,bn),S(Sr,`version`,xn),Sr=B([(0,c.DependentOn)(h.UniverRenderEnginePlugin),z(1,c.IContextService),z(2,(0,c.Inject)(c.Injector)),z(3,c.IConfigService)],Sr);const Cr=`DISABLE_AUTO_FOCUS`;let wr=class extends c.Plugin{constructor(e=le,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({popupRootId:`univer-popup-portal-${(0,c.generateRandomId)(6)}`},le,this._config);a.disableAutoFocus&&this._contextService.setContextValue(Cr,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(R,a)}onStarting(){(0,c.registerDependencies)(this._injector,(0,c.mergeOverrideWithDependencies)([[k],[Ht],[A],[C],[Z,{useClass:gt}],[U,{useClass:Be}],[Dt,{useClass:Ot}],[We,{useClass:Ge}],[He,{useClass:Ue}],[J,{useClass:ot}],[Gt,{useClass:Kt}],[Ut,{useClass:Wt}],[Xn,{useClass:Zn,lazy:!0}],[zn,{useClass:yr,lazy:!0}],[sr,{useClass:lr,lazy:!0}],[ir,{useClass:or,lazy:!0}],[c.IConfirmService,{useClass:rr,lazy:!0}],[T,{useClass:br,lazy:!0}],[un,{useClass:xr,lazy:!0}],[sn,{useClass:ur,lazy:!0}],[ke,{useClass:gr,lazy:!0}],[c.ILocalStorageService,{useClass:pr,lazy:!0}],[Bn,{useClass:Vn}],[fr,{useClass:dr}],[bt,{useClass:xt}],[ue,{useClass:fe}],[_t],[yn,{useFactory:e=>e.createInstance(gn,this._config),deps:[c.Injector]}],[W],[Ae],[lt]],this._config.override)),(0,c.touchDependencies)(this._injector,[[yn],[Ae]])}onReady(){(0,c.touchDependencies)(this._injector,[[W]])}onSteady(){(0,c.touchDependencies)(this._injector,[[lt]])}};S(wr,`pluginName`,`UNIVER_UI_PLUGIN`),S(wr,`packageName`,bn),S(wr,`version`,xn),wr=B([(0,c.DependentOn)(h.UniverRenderEnginePlugin),z(1,c.IContextService),z(2,(0,c.Inject)(c.Injector)),z(3,c.IConfigService)],wr);var Tr=class{show(e){return(0,c.toDisposable)(()=>{})}remove(e){}removeAll(){}setContainer(){}getContainer(){}};const Er=e=>{let t=(0,f.useDependency)(T).getContainer();(0,d.useEffect)(()=>{if(t)return t.addEventListener(`mousedown`,e),()=>{t.removeEventListener(`mousedown`,e)}},[e,t])};function Dr(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,``)}function Or(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
|
|
406
|
-
`;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 l=kr(a);jr(s).forEach(e=>{let t=e.length;i+=t,r=i-t;let a=(0,c.generateRandomId)(6);n.push({sId:a,st:r,ed:i-1,ts:l})})}return{id:(0,c.generateRandomId)(6),body:{dataStream:a,textRuns:n},documentStyle:{}}}function kr(e,t=``){var n,r;let i=(n=e==null||(r=e.style)==null?void 0:r.cssText)==null?``:n;if(i+=t,i=i.replace(/[\r\n]+/g,``),i.length===0)return{};let a=i.split(`;`),o={},s={t:``,r:``,b:``,l:``};return a.forEach(t=>{let n=t.toLowerCase(),r=Dr(n.substr(0,n.indexOf(`:`))),a=Dr(n.substr(n.indexOf(`:`)+1));if(r===`font-weight`)a===`bold`||a===`700`?o.bl=1:o.bl=0;else if(r===`font-style`)a===`italic`?o.it=1:o.it=0;else if(r===`font-family`)o.ff=Vr(Dr(t));else if(r===`font-size`){let e=Number.parseInt(a);i.indexOf(`vertical-align`)>-1&&(i.indexOf(`sub`)>-1||i.indexOf(`sup`)>-1)&&(e*=2),a.indexOf(`px`)!==-1&&(e=Br(Number.parseInt(a,10))),o.fs=e}else if(r===`color`){let e=new c.ColorKit(a);o.cl={rgb:e.isValid?e.toRgbString():`rgb(0,0,0)`}}else if(r===`background`||r===`background-color`){let e=new c.ColorKit(a);e.isValid&&(o.bg={rgb:e.toRgbString()})}else if(r===`text-decoration-line`)a===`underline`?(o.ul||(o.ul={s:1}),o.ul.s=1):a===`line-through`?(o.st||(o.st={s:1}),o.st.s=1):a===`overline`&&(o.ol||(o.ol={s:1}),o.ol.s=1);else if(r===`text-decoration-color`)o.hasOwnProperty(`ul`)&&(o.ul||(o.ul={s:1,cl:{rgb:a}}),o.ul.cl={rgb:a}),o.hasOwnProperty(`st`)&&(o.st||(o.st={s:1,cl:{rgb:a}}),o.st.cl={rgb:a}),o.hasOwnProperty(`ol`)&&(o.ol||(o.ol={s:1,cl:{rgb:a}}),o.ol.cl={rgb:a});else if(r===`text-decoration-style`)o.hasOwnProperty(`ul`)&&(o.ul||(o.ul={s:1,t:Number(a)}),o.ul.t=Number(a)),o.hasOwnProperty(`st`)&&(o.st||(o.st={s:1,t:Number(a)}),o.st.t=Number(a)),o.hasOwnProperty(`ol`)&&(o.ol||(o.ol={s:1,t:Number(a)}),o.ol.t=Number(a));else if(r===`text-decoration`||r===`univer-strike`){var l;let e=(l=a.split(` `))==null?void 0:l[0];e===`underline`?(o.ul||(o.ul={s:1}),o.ul.s=1):e===`line-through`?(o.st||(o.st={s:1}),o.st.s=1):e===`overline`&&(o.ol||(o.ol={s:1}),o.ol.s=1)}if(r===`univer-underline`&&(o.ul={s:1}),r===`vertical-align`&&(a===`sub`?o.va=c.BaselineOffset.SUBSCRIPT:a===`super`?o.va=c.BaselineOffset.SUPERSCRIPT:a===`top`?o.vt=1:a===`middle`?o.vt=2:a===`bottom`?o.vt=3:o.va=c.BaselineOffset.NORMAL),r===`transform`){let t=a.split(`)`),n=t.findIndex(e=>e.includes(`rotate`));if(n>-1){let r=t[n].match(/\d+/g),i=0,a=0;r!=null&&r.length&&(i=+r[0]),e!=null&&e.dataset.vertical&&(a=+e.dataset.vertical),o.tr={a:i,v:a}}}if(r===`text-align`&&(a===`left`?o.ht=1:a===`center`?o.ht=2:a===`right`?o.ht=3:a===`justify`?o.ht=4:o.ht=0),o.tb!==1&&(r===`overflow-wrap`||r===`word-wrap`?a===`break-word`&&(o.tb=3):r===`text-overflow`?a===`clip`&&(o.tb=2):r===`text-break`&&a===`overflow`&&(o.tb=1)),r===`white-space`&&(a===`nowrap`?o.tb=1:a===`normal`?o.tb=3:a===`clip`&&(o.tb=2)),r===`border-color`){let e=Ar(a,`)`);if(o.bd)for(let t in e)o.bd[t].cl.rgb=e[t];else{o.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)o.bd[t].cl.rgb=e[t]}}if(r===`border-width`||r===`border-style`){let e=Ar(a,` `);for(let t in e)s[t]+=` ${e[t]}`;o.bd?(o.bd.b.s=(0,c.getBorderStyleType)(s.b),o.bd.t.s=(0,c.getBorderStyleType)(s.t),o.bd.l.s=(0,c.getBorderStyleType)(s.l),o.bd.r.s=(0,c.getBorderStyleType)(s.r)):o.bd={b:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.b)},t:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.t)},l:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.l)},r:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.r)}}}if(r===`border-bottom`||r===`border-top`||r===`border-left`||r===`border-right`||r===`border`){o.bd||(o.bd={});let e=a.split(` `),t=`${e[0]} ${e[1]}`;e.splice(0,2);let n=e.join(``);if((0,c.getBorderStyleType)(t)!==c.BorderStyleTypes.NONE&&n){let e={cl:{rgb:n},s:(0,c.getBorderStyleType)(t)};r===`border-bottom`?o.bd.b=a===`none`?null:e:r===`border-top`?o.bd.t=a===`none`?null:e:r===`border-left`?o.bd.l=a===`none`?null:e:r===`border-right`?o.bd.r=a===`none`?null:e:r===`border`&&(o.bd={r:a===`none`?null:e,t:a===`none`?null:e,b:a===`none`?null:e,l:a===`none`?null:e})}}else if(r===`--data-rotate`){let e=a.match(/[+-]?\d+/);a===`(0deg ,1)`?o.tr={a:0,v:1}:e&&(o.tr={a:Number(e[0])})}}),Object.keys(o).forEach(e=>{typeof o[e]==`object`&&!Object.keys(o[e]).length&&delete o[e]}),o}function Ar(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 jr(e){return e===``?[e]:e.match(/(?:(\n+.+)|(.+))/g).map(e=>e.replace(/\n/g,`\r
|
|
407
|
-
`))}function Mr(e){let t=document.createElement(`DIV`),n=[];t.innerHTML=e;let 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=Nr(t.getAttribute(`width`),72);n.push(e)}else{let e=Nr(t.getAttribute(`width`),72);n.push(e)}}return n}function Nr(e,t){if(!e)return t;let n;return n=e.includes(`pt`)?(0,h.ptToPx)(Number.parseFloat(e)):e.includes(`px`)?Number.parseFloat(e):Number.parseFloat(e)*72/96,n}function Pr(e){let t=document.createElement(`DIV`),n=[];t.innerHTML=e;let r=t.querySelectorAll(`table tr`);if(!r.length)return[];for(let e=0;e<r.length;e++){let t=r[e].querySelectorAll(`td`),i=Nr(t[0].style.height,19);for(let e=0;e<t.length;e++){let n=t[e].getAttribute(`rowSpan`);if(!(n&&+n>1)){i=Nr(t[e].style.height,19);break}}n.push(i)}return n}function Fr(e){let t=[],n=document.createElement(`DIV`);if(n.innerHTML=e,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=Or(e);typeof t!=`string`&&(i.p=t)}let o=e.innerText;o.trim().length===0?i.v=``:i.v=o;let s=kr(e);for(c.Tools.isPlainObject(s)&&(i.s=s);n<r&&t[a][n]!=null;)n++;if(n!==r){if(t[a][n]==null){var l,u;t[a][n]=i;let r=(l=Number(e.getAttribute(`rowSpan`)))==null?1:l,o=(u=Number(e.getAttribute(`colSpan`)))==null?1:u;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 Ir(e){let t=[],n=document.createElement(`DIV`);n.innerHTML=e;let r=e.replace(/\r/g,``).split(`
|
|
408
|
-
`),i=r[0].split(` `).length;for(let e=0;e<r.length;e++)r[e].split(` `).length<i||t.push(r[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 Lr(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 Rr(e){var t;let n=[],r=document.createElement(`html`);r.innerHTML=e;let i=(t=r.querySelector(`style`))==null?void 0:t.innerText;if(!i)return;let a=zr(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 l=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=Or(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 u=kr(e,s);for(c.Tools.isPlainObject(u)&&(r.s=u);t<o&&n[l][t]!=null;)t++;if(t!==o){if(n[l][t]==null){var d,f;n[l][t]=r;let i=(d=Number(e.getAttribute(`rowSpan`)))==null?1:d,a=(f=Number(e.getAttribute(`colSpan`)))==null?1:f;if(i>1||a>1){let e={rs:i-1,cs:a-1,r:l,c:t};n[l][t].mc=e;for(let e=0;e<i;e++)for(let r=0;r<a;r++)e===0&&r===0||(n[l+e][t+r]={mc:null})}}t++}}),l++}),n}function zr(e){let t={},n=e.replaceAll(`<!--`,``).replaceAll(`-->`,``).trim(),r=n==null?void 0:n.replaceAll(` `,``).replaceAll(`
|
|
409
|
-
`,``).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 Br(e){let t=Math.round(e*.75);return t<9?9:t>78?78:t}function Vr(e){let t=e.match(/font-family:\s*(?:"([^"]+)"|'([^']+)'|([^;]+))/i);return t?(t[1]||t[2]||t[3]).trim():null}const Hr=(0,d.memo)(e=>{var t,n;let{layer:r,id:i,position:a}=e,o=(0,f.useDependency)(c.IUniverInstanceService),s=(0,d.useRef)(null),l=(0,d.useRef)(null),u=(0,d.useRef)(`transform: rotate(${a==null?void 0:a.rotate}deg) translate(${a==null?void 0:a.startX}px, ${a==null?void 0:a.startY}px)`),m=(0,d.useRef)((t=a==null?void 0:a.startY)==null?0:t),h=(0,d.useRef)((n=a==null?void 0:a.startX)==null?0:n),g=typeof r.componentKey==`string`?(0,f.useDependency)(k).get(r.componentKey):r.componentKey,_=(0,d.useMemo)(()=>({data:r.data,...r.props}),[r.data,r.props]),v={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}`};u.current=`rotate(${a.rotate}deg)`,m.current=a.startY,h.current=a.startX;let y=o.getUnit(r.unitId),b=(0,d.useMemo)(()=>g?(0,p.jsx)(g,{..._,unitId:r.unitId,unit:y,floatDomId:r.id,context:{root:l}}):null,[g,_]);return a?(0,p.jsx)(`div`,{ref:s,className:`univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden`,style:{top:m.current,left:h.current,width:Math.max(a.endX-a.startX-2,0),height:Math.max(a.endY-a.startY-2,0),transform:u.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:(0,p.jsx)(`div`,{ref:l,id:i,className:`univer-absolute univer-overflow-hidden`,style:{...v},children:b})}):null});exports.AnchoredContextMenu=an,Object.defineProperty(exports,`BrowserClipboardService`,{enumerable:!0,get:function(){return Zn}}),exports.BuiltInUIPart=X,exports.COLOR_PICKER_COMPONENT=ce,exports.COMMON_LABEL_COMPONENT=ne,exports.CanvasFloatDomService=_t,exports.CanvasPopup=Et,exports.CanvasPopupService=xt,exports.CommonLabel=F,exports.ComponentContainer=Q,exports.ComponentManager=k,exports.ContextMenu=on,exports.ContextMenuGroup=q,exports.ContextMenuHostService=Kt,exports.ContextMenuPanel=en,exports.ContextMenuPosition=K,exports.ContextMenuService=Wt,exports.CopyCommand=Me,exports.CopyShortcutItem=Je,exports.CustomLabel=I,exports.CutCommand=Pe,exports.CutShortcutItem=Ye,exports.DISABLE_AUTO_FOCUS_KEY=Cr,Object.defineProperty(exports,`DesktopBeforeCloseService`,{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,`DesktopConfirmService`,{enumerable:!0,get:function(){return rr}}),Object.defineProperty(exports,`DesktopDialogService`,{enumerable:!0,get:function(){return or}}),Object.defineProperty(exports,`DesktopGalleryService`,{enumerable:!0,get:function(){return lr}}),Object.defineProperty(exports,`DesktopGlobalZoneService`,{enumerable:!0,get:function(){return ur}}),Object.defineProperty(exports,`DesktopLayoutService`,{enumerable:!0,get:function(){return Be}}),exports.DesktopLocalFileService=dr,exports.DesktopLocalStorageService=pr,Object.defineProperty(exports,`DesktopMessageService`,{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,`DesktopNotificationService`,{enumerable:!0,get:function(){return yr}}),Object.defineProperty(exports,`DesktopRibbonService`,{enumerable:!0,get:function(){return Ot}}),exports.DesktopSidebarService=br,Object.defineProperty(exports,`DesktopUIController`,{enumerable:!0,get:function(){return gn}}),Object.defineProperty(exports,`DesktopZenZoneService`,{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,`ErrorController`,{enumerable:!0,get:function(){return Ae}}),exports.FILE_PNG_CLIPBOARD_MIME_TYPE=Gn,exports.FILE_SVG_XML_CLIPBOARD_MIME_TYPE=`image/svg+xml`,exports.FILE__BMP_CLIPBOARD_MIME_TYPE=qn,exports.FILE__JPEG_CLIPBOARD_MIME_TYPE=Kn,exports.FILE__WEBP_CLIPBOARD_MIME_TYPE=Jn,exports.FONT_FAMILY_COMPONENT=he,exports.FONT_FAMILY_ITEM_COMPONENT=ge,exports.FONT_SIZE_COMPONENT=be,exports.FONT_SIZE_LIST=ve,exports.FloatDom=yt,exports.FloatDomSingle=vt,exports.FontFamily=pe,exports.FontFamilyItem=me,exports.FontSize=_e,exports.GlobalZone=cn,exports.HEADING_ITEM_COMPONENT=ie,exports.HEADING_LIST=ye,exports.HTML_CLIPBOARD_MIME_TYPE=Wn,exports.HeadingItem=re,exports.IBeforeCloseService=Bn,exports.ICanvasPopupService=bt,exports.IClipboardInterfaceService=Xn,exports.IContextMenuHostService=Gt,exports.IContextMenuService=Ut,exports.IDialogService=ir,exports.IFontService=ue,exports.IGalleryService=sr,exports.IGlobalZoneService=sn,exports.ILayoutService=U,exports.ILeftSidebarService=w,exports.ILocalFileService=fr,exports.IMenuManagerService=J,exports.IMessageService=ke,exports.INotificationService=zn,exports.IPlatformService=He,exports.IRibbonService=Dt,exports.IShortcutService=We,exports.ISidebarService=T,exports.IUIController=yn,exports.IUIPartsService=Z,exports.IZenZoneService=un,exports.KeyCode=V,exports.MenuItemType=Y,exports.MenuManagerPosition=$e,Object.defineProperty(exports,`MenuManagerService`,{enumerable:!0,get:function(){return ot}}),exports.MetaKeys=H,exports.MobileContextMenu=Pn,exports.MockMessageService=Tr,exports.PLAIN_TEXT_CLIPBOARD_MIME_TYPE=Un,exports.PasteCommand=Ie,exports.PlatformService=Ue,exports.PrintFloatDomSingle=Hr,exports.ProgressBar=Oe,exports.RectPopup=wt,Object.defineProperty(exports,`RediConsumer`,{enumerable:!0,get:function(){return f.RediConsumer}}),Object.defineProperty(exports,`RediContext`,{enumerable:!0,get:function(){return f.RediContext}}),Object.defineProperty(exports,`RediProvider`,{enumerable:!0,get:function(){return f.RediProvider}}),exports.RedoShortcutItem=Qe,exports.Ribbon=Vt,exports.RibbonDataGroup=rt,exports.RibbonFormulasGroup=nt,exports.RibbonInsertGroup=tt,exports.RibbonOthersGroup=at,exports.RibbonPosition=G,exports.RibbonStartGroup=et,exports.RibbonViewGroup=it,Object.defineProperty(exports,`SharedController`,{enumerable:!0,get:function(){return W}}),exports.SheetPasteShortKeyCommandName=`sheet.command.paste-by-short-key`,Object.defineProperty(exports,`ShortcutPanelController`,{enumerable:!0,get:function(){return lt}}),exports.ShortcutPanelService=C,Object.defineProperty(exports,`ShortcutService`,{enumerable:!0,get:function(){return Ge}}),exports.Sidebar=ln,exports.SingleCanvasPopup=Tt,exports.SingleUnitUIController=hn,exports.Slider=se,exports.ThemeSwitcherService=Ht,exports.ToggleShortcutPanelOperation=D,exports.ToolbarButton=Nt,exports.ToolbarItem=Bt,exports.UIMenuSchema=ht,exports.UIPartsService=gt,exports.UI_PLUGIN_CONFIG_KEY=R,exports.UNI_DISABLE_CHANGING_FOCUS_KEY=`UNI_DISABLE_CHANGING_FOCUS`,exports.UndoShortcutItem=Ze,Object.defineProperty(exports,`UniverMobileUIPlugin`,{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(exports,`UniverUIPlugin`,{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,`WithDependency`,{enumerable:!0,get:function(){return f.WithDependency}}),exports.ZIndexManager=A,exports.ZenZone=dn,Object.defineProperty(exports,`connectDependencies`,{enumerable:!0,get:function(){return f.connectDependencies}}),Object.defineProperty(exports,`connectInjector`,{enumerable:!0,get:function(){return f.connectInjector}}),exports.getHeaderFooterMenuHiddenObservable=M,exports.getMenuHiddenObservable=j,exports.handelExcelToJson=Rr,exports.handelTableToJson=Fr,exports.handleDomToJson=Or,exports.handlePlainToJson=Ir,exports.handleStringToStyle=kr,exports.handleTableColgroup=Mr,exports.handleTableMergeData=Lr,exports.handleTableRowGroup=Pr,exports.imageMimeTypeSet=Yn,exports.mergeMenuConfigs=N,exports.splitSpanText=jr,exports.supportClipboardAPI=Hn,exports.t=De,exports.textTrim=Dr,exports.useClickOutSide=Se,exports.useComponentsOfPart=$,exports.useConfigValue=oe,exports.useDebounceFn=Ce,Object.defineProperty(exports,`useDependency`,{enumerable:!0,get:function(){return f.useDependency}}),exports.useEvent=L,Object.defineProperty(exports,`useInjector`,{enumerable:!0,get:function(){return f.useInjector}}),Object.defineProperty(exports,`useObservable`,{enumerable:!0,get:function(){return f.useObservable}}),exports.useObservableRef=P,exports.useScrollYOverContainer=ae,exports.useSidebarClick=Er,exports.useToolbarItemStatus=Pt,Object.defineProperty(exports,`useUpdateBinder`,{enumerable:!0,get:function(){return f.useUpdateBinder}}),exports.useUpdateEffect=xe,exports.useVirtualList=Ee;
|
|
128
|
+
`,style:{margin:0},onClick:y,children:(0,p.jsx)(u.CloseIcon,{className:`univer-size-4 univer-text-current`})})]})]}),n&&(0,p.jsx)(wn,{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&&(l.focus(),s.executeCommand(r,a),y())}})]})]}),g)}function Fn(e){let{header:t=!0,toolbar:n=!0,footer:r=!0,headerMenu:i=!0,ribbonType:a=`classic`,contextMenu:o=!0,mountContainer:s,onRendered:l}=e,u=(0,f.useDependency)(c.LocaleService),h=(0,f.useDependency)(c.ThemeService),g=(0,f.useDependency)(Ht),_=(0,d.useRef)(null),v=$(X.FOOTER),y=$(X.HEADER),b=$(X.HEADER_MENU),x=$(X.CONTENT),S=$(X.LEFT_SIDEBAR),C=$(X.GLOBAL),w=$(X.TOOLBAR),[T,E]=(0,d.useState)(!1);(0,d.useEffect)(()=>{let e=h.darkMode$.subscribe(e=>{E(e)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{_.current&&(l==null||l(_.current))},[l]);let[D,O]=(0,d.useState)(u.getLocales()),k=(0,d.useMemo)(()=>document.createElement(`div`),[]);return(0,d.useLayoutEffect)(()=>{let e=h.currentTheme$.subscribe(e=>{g.injectThemeToHead(e)});return()=>{e.unsubscribe()}},[]),(0,d.useEffect)(()=>{document.body.appendChild(k);let e=[u.localeChanged$.subscribe(()=>{O(u.getLocales())})];return()=>{e.forEach(e=>e.unsubscribe()),document.body.removeChild(k)}},[u,s,k]),(0,p.jsxs)(m.ConfigProvider,{locale:D==null?void 0:D.design,mountContainer:k,children:[(0,p.jsxs)(`div`,{"data-u-comp":`app-layout`,className:(0,m.clsx)(`univer-relative univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800`,{"univer-dark":T}),tabIndex:-1,onBlur:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:[t&&n&&(0,p.jsx)(`header`,{"data-u-comp":`headerbar`,className:`univer-relative univer-z-10 univer-w-full univer-overflow-hidden`,children:(0,p.jsx)(Q,{components:w,sharedProps:{ribbonType:a,headerMenuComponents:b,headerMenu:i}},`toolbar`)}),(0,p.jsxs)(`section`,{className:`univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col`,children:[(0,p.jsxs)(`div`,{className:`univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden`,children:[(0,p.jsx)(`aside`,{className:`univer-h-full`,children:(0,p.jsx)(Q,{components:S},`left-sidebar`)}),(0,p.jsxs)(`section`,{className:(0,m.clsx)(`univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white dark:!univer-bg-gray-800`,m.borderBottomClassName),children:[(0,p.jsx)(`header`,{className:`univer-w-screen`,children:t&&(0,p.jsx)(Q,{components:y},`header`)}),(0,p.jsx)(`section`,{ref:_,className:`univer-relative univer-overflow-hidden`,"data-range-selector":!0,onContextMenu:e=>e.preventDefault(),children:(0,p.jsx)(Q,{components:x},`content`)})]}),(0,p.jsx)(`aside`,{className:`univer-h-full`,children:(0,p.jsx)(ln,{})})]}),r&&(0,p.jsx)(`footer`,{children:(0,p.jsx)(Q,{components:v},`footer`)}),(0,p.jsx)(cn,{}),(0,p.jsx)(dn,{})]})]}),(0,p.jsx)(Q,{components:C},`global`),o&&(0,p.jsx)(Pn,{})]})}let In=class extends hn{constructor(e,t,n,r,i,a,o,s,c){super(t,a,i,n,r),this._config=e,this._componentManager=c,o.mergeMenu(ht),this._initBuiltinComponents(s),this._registerComponents(),this._bootstrapWorkbench()}dispose(){super.dispose(),this._componentManager.dispose()}bootstrap(e){return Ln(this._injector,this._config,e)}_registerComponents(){[[ne,F],[ie,re],[he,pe],[ge,me],[be,_e],[ce,m.ColorPicker]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(Et,this._injector))),this.disposeWithMe(e.registerComponent(X.CONTENT,()=>(0,f.connectInjector)(yt,this._injector))),this.disposeWithMe(e.registerComponent(X.TOOLBAR,()=>(0,f.connectInjector)(Cn,this._injector)))}};In=B([z(1,(0,c.Inject)(c.Injector)),z(2,(0,c.Inject)(c.LifecycleService)),z(3,h.IRenderManagerService),z(4,U),z(5,c.IUniverInstanceService),z(6,J),z(7,Z),z(8,(0,c.Inject)(k))],In);function Ln(e,t,n){let r,i=t.container;r=typeof i==`string`?document.getElementById(i)||Rn(i):i instanceof HTMLElement?i:Rn(`univer`);let a=(0,f.connectInjector)(Fn,e),o=e=>n(e,r);function s(){(0,m.render)((0,p.jsx)(a,{...t,mountContainer:r,onRendered:o}),r)}return s(),(0,c.toDisposable)(()=>{(0,m.unmount)(r)})}function Rn(e){let t=document.createElement(`div`);return t.id=e,t}const zn=(0,c.createIdentifier)(`ui.notification.service`),Bn=(0,c.createIdentifier)(`univer.ui.before-close-service`);let Vn=class{constructor(e){this._notificationService=e,S(this,`_beforeUnloadCallbacks`,[]),S(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())})}};Vn=B([z(0,zn)],Vn);function Hn(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 Un(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return Hn(n,t),n.body}function Wn(e,t){let n=new DOMParser().parseFromString(e,`text/html`);return Hn(n,t),n}function Gn(){return navigator.clipboard!==void 0&&navigator.clipboard.readText!==void 0}const Kn=`text/plain`,qn=`text/html`,Jn=`image/png`,Yn=`image/jpeg`,Xn=`image/bmp`,Zn=`image/webp`,Qn=new Set([Xn,Yn,Zn,Jn]),$n=new Set([`base`,`button`,`embed`,`form`,`frame`,`frameset`,`head`,`iframe`,`input`,`link`,`meta`,`object`,`script`,`select`,`style`,`template`,`textarea`]),er=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(`.`)),tr=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(`.`)),nr=(0,c.createIdentifier)(`univer.clipboard-interface-service`);let rr=class extends c.Disposable{get supportClipboard(){return Gn()}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({[Kn]:new Blob([e],{type:Kn}),[qn]:new Blob([t],{type:qn})})])}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=ar();document.body.appendChild(n),n.replaceChildren(or(e));try{fr(n),document.execCommand(`copy`)}finally{t instanceof HTMLElement&&t.focus(),document.body.removeChild(n)}}_legacyCopyText(e){let t=document.activeElement,n=ir();document.body.appendChild(n),n.value=e;try{fr(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`)})}};rr=B([z(0,(0,c.Inject)(c.LocaleService)),z(1,c.ILogService),z(2,(0,c.Optional)(zn))],rr);function ir(){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 ar(){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 or(e){let t=new DOMParser().parseFromString(e,qn);Hn(t,{strippedSelector:`script, iframe, object, embed`});let n=document.createDocumentFragment();return Array.from(t.body.childNodes).forEach(e=>{let t=sr(e);t&&n.appendChild(t)}),n}function sr(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($n.has(r))return null;if(!er.has(r)){let e=document.createDocumentFragment();return Array.from(n.childNodes).forEach(t=>{let n=sr(t);n&&e.appendChild(n)}),e}let i=document.createElement(r);return cr(n,i),Array.from(n.childNodes).forEach(e=>{let t=sr(e);t&&i.appendChild(t)}),i}function cr(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(tr.has(n)){if(n===`href`||n===`src`){let r=lr(e.value,n===`src`);r&&t.setAttribute(e.name,r);return}if(n===`style`){let n=ur(e.value);n&&t.setAttribute(e.name,n);return}t.setAttribute(e.name,e.value)}}})}function lr(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 ur(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||dr(r)||n.push(`${e}: ${r}`)}),n.join(`; `)}function dr(e){return/(expression\s*\(|url\s*\(|javascript:|vbscript:|mocha:|-moz-binding|behavior\s*:|@import)/i.test(e)}function fr(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 pr=e=>{let{children:t,onClose:n,onConfirm:r}=e,[i]=(0,d.useState)({}),a=t?(0,d.cloneElement)(t,{hooks:i}):null;return(0,p.jsx)(m.Confirm,{...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 mr(){let e=(0,f.useDependency)(c.IConfirmService),[t,n]=(0,d.useState)([]);(0,d.useEffect)(()=>{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]=(0,p.jsx)(I,{...r}))}return i});return r==null?void 0:r.map((e,t)=>(0,p.jsx)(pr,{...e,children:e.children},t))}let hr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`_confirmOptions`,[]),S(this,`confirmOptions$`,new l.BehaviorSubject([])),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),(0,c.toDisposable)(()=>{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,()=>(0,f.connectInjector)(mr,this._injector)))}};hr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],hr);const gr=(0,c.createIdentifier)(`univer.ui.dialog-service`);function _r(){let e=(0,f.useDependency)(gr),[t,n]=(0,d.useState)([]);(0,d.useEffect)(()=>{let t=e.getDialogs$().subscribe(e=>{n(e)});return()=>t.unsubscribe()},[]);let r=(0,d.useMemo)(()=>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]=(0,p.jsx)(I,{...r}))}return a}),[t]);return r==null?void 0:r.map(e=>(0,p.jsx)(m.Dialog,{...e},e.id))}let vr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`_dialogOptions`,[]),S(this,`_dialogOptions$`,new l.Subject),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),(0,c.toDisposable)(()=>{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,()=>(0,f.connectInjector)(_r,this._injector)))}};vr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],vr);const yr=(0,c.createIdentifier)(`univer.ui.gallery-service`);function br(){let e=(0,f.useObservable)((0,f.useDependency)(yr).gallery$);return e?(0,p.jsx)(m.Gallery,{...e}):null}let xr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,S(this,`gallery$`,new l.Subject),this._initUIPart()}dispose(){super.dispose()}open(e){return this.gallery$.next({open:!0,...e}),(0,c.toDisposable)(()=>{this.gallery$.complete()})}close(){this.gallery$.next({open:!1,images:[]})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(br,this._injector)))}};xr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],xr);let Sr=class{constructor(e){this._componentManager=e,S(this,`visible$`,new l.Subject),S(this,`componentKey$`,new l.Subject),S(this,`_componentKey`,``)}get componentKey(){return this._componentKey}set(e,t){return this._componentManager.register(e,t),this.componentKey$.next(e),this._componentKey=e,(0,c.toDisposable)(()=>{this._componentManager.delete(e),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};Sr=B([z(0,(0,c.Inject)(k))],Sr);var Cr=class extends c.Disposable{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 wr=(0,c.createIdentifier)(`univer-ui.local-file.service`);var Tr=class{getItem(e){return v.default.getItem(e)}setItem(e,t){return v.default.setItem(e,t)}removeItem(e){return v.default.removeItem(e)}clear(){return v.default.clear()}key(e){return v.default.key(e)}keys(){return v.default.keys()}iterate(e){return v.default.iterate(e)}};function Er(){return(0,p.jsx)(m.Messager,{theme:(0,f.useObservable)((0,f.useDependency)(c.ThemeService).darkMode$)?`dark`:`light`})}let Dr=0,Or=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(Er,this._injector)))}dispose(){super.dispose(),(0,m.removeMessage)()}show(e){var t;let n=(t=e.id)==null?`message-${Date.now()}-${Dr}`:t;return Dr+=1,(0,m.message)(Object.assign({},e,{id:n})),(0,c.toDisposable)(()=>(0,m.removeMessage)(n))}remove(e){(0,m.removeMessage)(e)}removeAll(){(0,m.removeMessage)()}};Or=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],Or);function kr(){return(0,p.jsx)(m.Toaster,{theme:(0,f.useObservable)((0,f.useDependency)(c.ThemeService).darkMode$)?`dark`:`light`})}const Ar={show:e=>{let{type:t=`message`,title:n,content:r,duration:i,closable:a=!0,position:o=`top-right`}=e;m.toast[t](n,{position:o,description:r,duration:i,closeButton:a})}};let jr=class extends c.Disposable{constructor(e,t){super(),this._injector=e,this._uiPartsService=t,this._initUIPart()}show(e){return Ar.show(e),(0,c.toDisposable)(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(X.GLOBAL,()=>(0,f.connectInjector)(kr,this._injector)))}};jr=B([z(0,(0,c.Inject)(c.Injector)),z(1,Z)],jr);var Mr=class{constructor(){S(this,`_sidebarOptions`,{}),S(this,`sidebarOptions$`,new l.Subject),S(this,`scrollEvent$`,new l.Subject),S(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),(0,c.toDisposable)(()=>{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 Nr=class{get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}constructor(e){this._componentManager=e,S(this,`visible$`,new l.BehaviorSubject(!1)),S(this,`componentKey$`,new l.ReplaySubject),S(this,`_temporaryHidden$`,new l.BehaviorSubject(!1)),S(this,`temporaryHidden$`,this._temporaryHidden$.asObservable()),S(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),(0,c.toDisposable)(()=>{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)}};Nr=B([z(0,(0,c.Inject)(k))],Nr);let Pr=class extends c.Plugin{constructor(e=le,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({popupRootId:`univer-popup-portal-${(0,c.generateRandomId)(6)}`},le,this._config);a.disableAutoFocus&&this._contextService.setContextValue(`DISABLE_AUTO_FOCUS`,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(R,a)}onStarting(){(0,c.registerDependencies)(this._injector,(0,c.mergeOverrideWithDependencies)([[k],[Ht],[A],[C],[Z,{useClass:gt}],[U,{useClass:Be}],[Dt,{useClass:Ot}],[We,{useClass:Ge}],[He,{useClass:Ue}],[J,{useClass:ot}],[Gt,{useClass:Kt}],[Ut,{useClass:Wt}],[nr,{useClass:rr,lazy:!0}],[zn,{useClass:jr,lazy:!0}],[yr,{useClass:xr,lazy:!0}],[gr,{useClass:vr,lazy:!0}],[c.IConfirmService,{useClass:hr,lazy:!0}],[T,{useClass:Mr,lazy:!0}],[un,{useClass:Nr,lazy:!0}],[sn,{useClass:Sr,lazy:!0}],[ke,{useClass:Or,lazy:!0}],[c.ILocalStorageService,{useClass:Tr,lazy:!0}],[Bn,{useClass:Vn}],[wr,{useClass:Cr}],[bt,{useClass:xt}],[ue,{useClass:fe}],[_t],[yn,{useFactory:e=>e.createInstance(In,this._config),deps:[c.Injector]}],[$e],[Ae],[lt]],this._config.override)),(0,c.touchDependencies)(this._injector,[[yn],[Ae]])}onReady(){(0,c.touchDependencies)(this._injector,[[$e]])}onSteady(){(0,c.touchDependencies)(this._injector,[[lt]])}};S(Pr,`pluginName`,`UNIVER_MOBILE_UI_PLUGIN`),S(Pr,`packageName`,bn),S(Pr,`version`,xn),Pr=B([(0,c.DependentOn)(h.UniverRenderEnginePlugin),z(1,c.IContextService),z(2,(0,c.Inject)(c.Injector)),z(3,c.IConfigService)],Pr);const Fr=`DISABLE_AUTO_FOCUS`;let Ir=class extends c.Plugin{constructor(e=le,t,n,r){super(),this._config=e,this._contextService=t,this._injector=n,this._configService=r;let{menu:i,...a}=(0,c.merge)({popupRootId:`univer-popup-portal-${(0,c.generateRandomId)(6)}`},le,this._config);a.disableAutoFocus&&this._contextService.setContextValue(Fr,!0),i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(R,a)}onStarting(){(0,c.registerDependencies)(this._injector,(0,c.mergeOverrideWithDependencies)([[k],[Ht],[A],[C],[Z,{useClass:gt}],[U,{useClass:Be}],[Dt,{useClass:Ot}],[We,{useClass:Ge}],[He,{useClass:Ue}],[J,{useClass:ot}],[Gt,{useClass:Kt}],[Ut,{useClass:Wt}],[nr,{useClass:rr,lazy:!0}],[zn,{useClass:jr,lazy:!0}],[yr,{useClass:xr,lazy:!0}],[gr,{useClass:vr,lazy:!0}],[c.IConfirmService,{useClass:hr,lazy:!0}],[T,{useClass:Mr,lazy:!0}],[un,{useClass:Nr,lazy:!0}],[sn,{useClass:Sr,lazy:!0}],[ke,{useClass:Or,lazy:!0}],[c.ILocalStorageService,{useClass:Tr,lazy:!0}],[Bn,{useClass:Vn}],[wr,{useClass:Cr}],[bt,{useClass:xt}],[ue,{useClass:fe}],[_t],[yn,{useFactory:e=>e.createInstance(gn,this._config),deps:[c.Injector]}],[$e],[Ae],[lt]],this._config.override)),(0,c.touchDependencies)(this._injector,[[yn],[Ae]])}onReady(){(0,c.touchDependencies)(this._injector,[[$e]])}onSteady(){(0,c.touchDependencies)(this._injector,[[lt]])}};S(Ir,`pluginName`,`UNIVER_UI_PLUGIN`),S(Ir,`packageName`,bn),S(Ir,`version`,xn),Ir=B([(0,c.DependentOn)(h.UniverRenderEnginePlugin),z(1,c.IContextService),z(2,(0,c.Inject)(c.Injector)),z(3,c.IConfigService)],Ir);var Lr=class{show(e){return(0,c.toDisposable)(()=>{})}remove(e){}removeAll(){}setContainer(){}getContainer(){}};const Rr=e=>{let t=(0,f.useDependency)(T).getContainer();(0,d.useEffect)(()=>{if(t)return t.addEventListener(`mousedown`,e),()=>{t.removeEventListener(`mousedown`,e)}},[e,t])};function zr(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,``)}const Br={strippedSelector:`script, iframe, object, embed`};function Vr(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
|
+
`;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 l=Hr(a);Wr(s).forEach(e=>{let t=e.length;i+=t,r=i-t;let a=(0,c.generateRandomId)(6);n.push({sId:a,st:r,ed:i-1,ts:l})})}return{id:(0,c.generateRandomId)(6),body:{dataStream:a,textRuns:n},documentStyle:{}}}function Hr(e,t=``){var n,r;let i=(n=e==null||(r=e.style)==null?void 0:r.cssText)==null?``:n;if(i+=t,i=i.replace(/[\r\n]+/g,``),i.length===0)return{};let a=i.split(`;`),o={},s={t:``,r:``,b:``,l:``};return a.forEach(t=>{let n=t.toLowerCase(),r=zr(n.substr(0,n.indexOf(`:`))),a=zr(n.substr(n.indexOf(`:`)+1));if(r===`font-weight`)a===`bold`||a===`700`?o.bl=1:o.bl=0;else if(r===`font-style`)a===`italic`?o.it=1:o.it=0;else if(r===`font-family`)o.ff=ei(zr(t));else if(r===`font-size`){let e=Number.parseInt(a);i.indexOf(`vertical-align`)>-1&&(i.indexOf(`sub`)>-1||i.indexOf(`sup`)>-1)&&(e*=2),a.indexOf(`px`)!==-1&&(e=$r(Number.parseInt(a,10))),o.fs=e}else if(r===`color`){let e=new c.ColorKit(a);o.cl={rgb:e.isValid?e.toRgbString():`rgb(0,0,0)`}}else if(r===`background`||r===`background-color`){let e=new c.ColorKit(a);e.isValid&&(o.bg={rgb:e.toRgbString()})}else if(r===`text-decoration-line`)a===`underline`?(o.ul||(o.ul={s:1}),o.ul.s=1):a===`line-through`?(o.st||(o.st={s:1}),o.st.s=1):a===`overline`&&(o.ol||(o.ol={s:1}),o.ol.s=1);else if(r===`text-decoration-color`)o.hasOwnProperty(`ul`)&&(o.ul||(o.ul={s:1,cl:{rgb:a}}),o.ul.cl={rgb:a}),o.hasOwnProperty(`st`)&&(o.st||(o.st={s:1,cl:{rgb:a}}),o.st.cl={rgb:a}),o.hasOwnProperty(`ol`)&&(o.ol||(o.ol={s:1,cl:{rgb:a}}),o.ol.cl={rgb:a});else if(r===`text-decoration-style`)o.hasOwnProperty(`ul`)&&(o.ul||(o.ul={s:1,t:Number(a)}),o.ul.t=Number(a)),o.hasOwnProperty(`st`)&&(o.st||(o.st={s:1,t:Number(a)}),o.st.t=Number(a)),o.hasOwnProperty(`ol`)&&(o.ol||(o.ol={s:1,t:Number(a)}),o.ol.t=Number(a));else if(r===`text-decoration`||r===`univer-strike`){var l;let e=(l=a.split(` `))==null?void 0:l[0];e===`underline`?(o.ul||(o.ul={s:1}),o.ul.s=1):e===`line-through`?(o.st||(o.st={s:1}),o.st.s=1):e===`overline`&&(o.ol||(o.ol={s:1}),o.ol.s=1)}if(r===`univer-underline`&&(o.ul={s:1}),r===`vertical-align`&&(a===`sub`?o.va=c.BaselineOffset.SUBSCRIPT:a===`super`?o.va=c.BaselineOffset.SUPERSCRIPT:a===`top`?o.vt=1:a===`middle`?o.vt=2:a===`bottom`?o.vt=3:o.va=c.BaselineOffset.NORMAL),r===`transform`){let t=a.split(`)`),n=t.findIndex(e=>e.includes(`rotate`));if(n>-1){let r=t[n].match(/\d+/g),i=0,a=0;r!=null&&r.length&&(i=+r[0]),e!=null&&e.dataset.vertical&&(a=+e.dataset.vertical),o.tr={a:i,v:a}}}if(r===`text-align`&&(a===`left`?o.ht=1:a===`center`?o.ht=2:a===`right`?o.ht=3:a===`justify`?o.ht=4:o.ht=0),o.tb!==1&&(r===`overflow-wrap`||r===`word-wrap`?a===`break-word`&&(o.tb=3):r===`text-overflow`?a===`clip`&&(o.tb=2):r===`text-break`&&a===`overflow`&&(o.tb=1)),r===`white-space`&&(a===`nowrap`?o.tb=1:a===`normal`?o.tb=3:a===`clip`&&(o.tb=2)),r===`border-color`){let e=Ur(a,`)`);if(o.bd)for(let t in e)o.bd[t].cl.rgb=e[t];else{o.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)o.bd[t].cl.rgb=e[t]}}if(r===`border-width`||r===`border-style`){let e=Ur(a,` `);for(let t in e)s[t]+=` ${e[t]}`;o.bd?(o.bd.b.s=(0,c.getBorderStyleType)(s.b),o.bd.t.s=(0,c.getBorderStyleType)(s.t),o.bd.l.s=(0,c.getBorderStyleType)(s.l),o.bd.r.s=(0,c.getBorderStyleType)(s.r)):o.bd={b:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.b)},t:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.t)},l:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.l)},r:{cl:{rgb:`#000`},s:(0,c.getBorderStyleType)(s.r)}}}if(r===`border-bottom`||r===`border-top`||r===`border-left`||r===`border-right`||r===`border`){o.bd||(o.bd={});let e=a.split(` `),t=`${e[0]} ${e[1]}`;e.splice(0,2);let n=e.join(``);if((0,c.getBorderStyleType)(t)!==c.BorderStyleTypes.NONE&&n){let e={cl:{rgb:n},s:(0,c.getBorderStyleType)(t)};r===`border-bottom`?o.bd.b=a===`none`?null:e:r===`border-top`?o.bd.t=a===`none`?null:e:r===`border-left`?o.bd.l=a===`none`?null:e:r===`border-right`?o.bd.r=a===`none`?null:e:r===`border`&&(o.bd={r:a===`none`?null:e,t:a===`none`?null:e,b:a===`none`?null:e,l:a===`none`?null:e})}}else if(r===`--data-rotate`){let e=a.match(/[+-]?\d+/);a===`(0deg ,1)`?o.tr={a:0,v:1}:e&&(o.tr={a:Number(e[0])})}}),Object.keys(o).forEach(e=>{typeof o[e]==`object`&&!Object.keys(o[e]).length&&delete o[e]}),o}function Ur(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 Wr(e){return e===``?[e]:e.match(/(?:(\n+.+)|(.+))/g).map(e=>e.replace(/\n/g,`\r
|
|
131
|
+
`))}function Gr(e){let t=Un(e,Br),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=Kr(t.getAttribute(`width`),72);n.push(e)}else{let e=Kr(t.getAttribute(`width`),72);n.push(e)}}return n}function Kr(e,t){if(!e)return t;let n;return n=e.includes(`pt`)?(0,h.ptToPx)(Number.parseFloat(e)):e.includes(`px`)?Number.parseFloat(e):Number.parseFloat(e)*72/96,n}function qr(e){let t=Un(e,Br),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=Kr(t[0].style.height,19);for(let e=0;e<t.length;e++){let n=t[e].getAttribute(`rowSpan`);if(!(n&&+n>1)){i=Kr(t[e].style.height,19);break}}n.push(i)}return n}function Jr(e){let t=[],n=Un(e,Br);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=Vr(e);typeof t!=`string`&&(i.p=t)}let o=e.innerText;o.trim().length===0?i.v=``:i.v=o;let s=Hr(e);for(c.Tools.isPlainObject(s)&&(i.s=s);n<r&&t[a][n]!=null;)n++;if(n!==r){if(t[a][n]==null){var l,u;t[a][n]=i;let r=(l=Number(e.getAttribute(`rowSpan`)))==null?1:l,o=(u=Number(e.getAttribute(`colSpan`)))==null?1:u;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 Yr(e){let t=[],n=e.replace(/\r/g,``).split(`
|
|
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 Xr(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 Zr(e){var t;let n=[],r=Wn(e,Br),i=(t=r.querySelector(`style`))==null?void 0:t.innerText;if(!i)return;let a=Qr(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 l=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=Vr(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 u=Hr(e,s);for(c.Tools.isPlainObject(u)&&(r.s=u);t<o&&n[l][t]!=null;)t++;if(t!==o){if(n[l][t]==null){var d,f;n[l][t]=r;let i=(d=Number(e.getAttribute(`rowSpan`)))==null?1:d,a=(f=Number(e.getAttribute(`colSpan`)))==null?1:f;if(i>1||a>1){let e={rs:i-1,cs:a-1,r:l,c:t};n[l][t].mc=e;for(let e=0;e<i;e++)for(let r=0;r<a;r++)e===0&&r===0||(n[l+e][t+r]={mc:null})}}t++}}),l++}),n}function Qr(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 $r(e){let t=Math.round(e*.75);return t<9?9:t>78?78:t}function ei(e){let t=e.match(/font-family:\s*(?:"([^"]+)"|'([^']+)'|([^;]+))/i);return t?(t[1]||t[2]||t[3]).trim():null}const ti=(0,d.memo)(e=>{var t,n;let{layer:r,id:i,position:a}=e,o=(0,f.useDependency)(c.IUniverInstanceService),s=(0,d.useRef)(null),l=(0,d.useRef)(null),u=(0,d.useRef)(`transform: rotate(${a==null?void 0:a.rotate}deg) translate(${a==null?void 0:a.startX}px, ${a==null?void 0:a.startY}px)`),m=(0,d.useRef)((t=a==null?void 0:a.startY)==null?0:t),h=(0,d.useRef)((n=a==null?void 0:a.startX)==null?0:n),g=typeof r.componentKey==`string`?(0,f.useDependency)(k).get(r.componentKey):r.componentKey,_=(0,d.useMemo)(()=>({data:r.data,...r.props}),[r.data,r.props]),v={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}`};u.current=`rotate(${a.rotate}deg)`,m.current=a.startY,h.current=a.startX;let y=o.getUnit(r.unitId),b=(0,d.useMemo)(()=>g?(0,p.jsx)(g,{..._,unitId:r.unitId,unit:y,floatDomId:r.id,context:{root:l}}):null,[g,_]);return a?(0,p.jsx)(`div`,{ref:s,className:`univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden`,style:{top:m.current,left:h.current,width:Math.max(a.endX-a.startX-2,0),height:Math.max(a.endY-a.startY-2,0),transform:u.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:(0,p.jsx)(`div`,{ref:l,id:i,className:`univer-absolute univer-overflow-hidden`,style:{...v},children:b})}):null});exports.AnchoredContextMenu=an,Object.defineProperty(exports,`BrowserClipboardService`,{enumerable:!0,get:function(){return rr}}),exports.BuiltInUIPart=X,exports.COLOR_PICKER_COMPONENT=ce,exports.COMMON_LABEL_COMPONENT=ne,exports.CanvasFloatDomService=_t,exports.CanvasPopup=Et,exports.CanvasPopupService=xt,exports.CommonLabel=F,exports.ComponentContainer=Q,exports.ComponentManager=k,exports.ContextMenu=on,exports.ContextMenuGroup=q,exports.ContextMenuHostService=Kt,exports.ContextMenuPanel=en,exports.ContextMenuPosition=K,exports.ContextMenuService=Wt,exports.CopyCommand=Me,exports.CopyShortcutItem=Je,exports.CustomLabel=I,exports.CutCommand=Pe,exports.CutShortcutItem=Ye,exports.DISABLE_AUTO_FOCUS_KEY=Fr,Object.defineProperty(exports,`DesktopBeforeCloseService`,{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,`DesktopConfirmService`,{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,`DesktopDialogService`,{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,`DesktopGalleryService`,{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,`DesktopGlobalZoneService`,{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(exports,`DesktopLayoutService`,{enumerable:!0,get:function(){return Be}}),exports.DesktopLocalFileService=Cr,exports.DesktopLocalStorageService=Tr,Object.defineProperty(exports,`DesktopMessageService`,{enumerable:!0,get:function(){return Or}}),Object.defineProperty(exports,`DesktopNotificationService`,{enumerable:!0,get:function(){return jr}}),Object.defineProperty(exports,`DesktopRibbonService`,{enumerable:!0,get:function(){return Ot}}),exports.DesktopSidebarService=Mr,Object.defineProperty(exports,`DesktopUIController`,{enumerable:!0,get:function(){return gn}}),Object.defineProperty(exports,`DesktopZenZoneService`,{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,`ErrorController`,{enumerable:!0,get:function(){return Ae}}),exports.FILE_PNG_CLIPBOARD_MIME_TYPE=Jn,exports.FILE_SVG_XML_CLIPBOARD_MIME_TYPE=`image/svg+xml`,exports.FILE__BMP_CLIPBOARD_MIME_TYPE=Xn,exports.FILE__JPEG_CLIPBOARD_MIME_TYPE=Yn,exports.FILE__WEBP_CLIPBOARD_MIME_TYPE=Zn,exports.FONT_FAMILY_COMPONENT=he,exports.FONT_FAMILY_ITEM_COMPONENT=ge,exports.FONT_SIZE_COMPONENT=be,exports.FONT_SIZE_LIST=ve,exports.FloatDom=yt,exports.FloatDomSingle=vt,exports.FontFamily=pe,exports.FontFamilyItem=me,exports.FontSize=_e,exports.GlobalZone=cn,exports.HEADING_ITEM_COMPONENT=ie,exports.HEADING_LIST=ye,exports.HTML_CLIPBOARD_MIME_TYPE=qn,exports.HeadingItem=re,exports.IBeforeCloseService=Bn,exports.ICanvasPopupService=bt,exports.IClipboardInterfaceService=nr,exports.IContextMenuHostService=Gt,exports.IContextMenuService=Ut,exports.IDialogService=gr,exports.IFontService=ue,exports.IGalleryService=yr,exports.IGlobalZoneService=sn,exports.ILayoutService=U,exports.ILeftSidebarService=w,exports.ILocalFileService=wr,exports.IMenuManagerService=J,exports.IMessageService=ke,exports.INotificationService=zn,exports.IPlatformService=He,exports.IRibbonService=Dt,exports.IShortcutService=We,exports.ISidebarService=T,exports.IUIController=yn,exports.IUIPartsService=Z,exports.IZenZoneService=un,exports.KeyCode=V,exports.MenuItemType=Y,exports.MenuManagerPosition=et,Object.defineProperty(exports,`MenuManagerService`,{enumerable:!0,get:function(){return ot}}),exports.MetaKeys=H,exports.MobileContextMenu=Pn,exports.MockMessageService=Lr,exports.PLAIN_TEXT_CLIPBOARD_MIME_TYPE=Kn,exports.PasteCommand=Ie,exports.PlatformService=Ue,exports.PrintFloatDomSingle=ti,exports.ProgressBar=Oe,exports.RectPopup=wt,Object.defineProperty(exports,`RediConsumer`,{enumerable:!0,get:function(){return f.RediConsumer}}),Object.defineProperty(exports,`RediContext`,{enumerable:!0,get:function(){return f.RediContext}}),Object.defineProperty(exports,`RediProvider`,{enumerable:!0,get:function(){return f.RediProvider}}),exports.RedoShortcutItem=Qe,exports.Ribbon=Vt,exports.RibbonDataGroup=rt,exports.RibbonFormulasGroup=nt,exports.RibbonInsertGroup=tt,exports.RibbonOthersGroup=at,exports.RibbonPosition=W,exports.RibbonStartGroup=G,exports.RibbonViewGroup=it,Object.defineProperty(exports,`SharedController`,{enumerable:!0,get:function(){return $e}}),exports.SheetPasteShortKeyCommandName=`sheet.command.paste-by-short-key`,Object.defineProperty(exports,`ShortcutPanelController`,{enumerable:!0,get:function(){return lt}}),exports.ShortcutPanelService=C,Object.defineProperty(exports,`ShortcutService`,{enumerable:!0,get:function(){return Ge}}),exports.Sidebar=ln,exports.SingleCanvasPopup=Tt,exports.SingleUnitUIController=hn,exports.Slider=se,exports.ThemeSwitcherService=Ht,exports.ToggleShortcutPanelOperation=D,exports.ToolbarButton=Nt,exports.ToolbarItem=Bt,exports.UIMenuSchema=ht,exports.UIPartsService=gt,exports.UI_PLUGIN_CONFIG_KEY=R,exports.UNI_DISABLE_CHANGING_FOCUS_KEY=`UNI_DISABLE_CHANGING_FOCUS`,exports.UndoShortcutItem=Ze,Object.defineProperty(exports,`UniverMobileUIPlugin`,{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(exports,`UniverUIPlugin`,{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,`WithDependency`,{enumerable:!0,get:function(){return f.WithDependency}}),exports.ZIndexManager=A,exports.ZenZone=dn,Object.defineProperty(exports,`connectDependencies`,{enumerable:!0,get:function(){return f.connectDependencies}}),Object.defineProperty(exports,`connectInjector`,{enumerable:!0,get:function(){return f.connectInjector}}),exports.getHeaderFooterMenuHiddenObservable=M,exports.getMenuHiddenObservable=j,exports.handelExcelToJson=Zr,exports.handelTableToJson=Jr,exports.handleDomToJson=Vr,exports.handlePlainToJson=Yr,exports.handleStringToStyle=Hr,exports.handleTableColgroup=Gr,exports.handleTableMergeData=Xr,exports.handleTableRowGroup=qr,exports.imageMimeTypeSet=Qn,exports.mergeMenuConfigs=N,exports.parseHtmlDocument=Wn,exports.parseHtmlFragment=Un,exports.sanitizeParsedHtml=Hn,exports.splitSpanText=Wr,exports.supportClipboardAPI=Gn,exports.t=De,exports.textTrim=zr,exports.useClickOutSide=Se,exports.useComponentsOfPart=$,exports.useConfigValue=oe,exports.useDebounceFn=Ce,Object.defineProperty(exports,`useDependency`,{enumerable:!0,get:function(){return f.useDependency}}),exports.useEvent=L,Object.defineProperty(exports,`useInjector`,{enumerable:!0,get:function(){return f.useInjector}}),Object.defineProperty(exports,`useObservable`,{enumerable:!0,get:function(){return f.useObservable}}),exports.useObservableRef=P,exports.useScrollYOverContainer=ae,exports.useSidebarClick=Rr,exports.useToolbarItemStatus=Pt,Object.defineProperty(exports,`useUpdateBinder`,{enumerable:!0,get:function(){return f.useUpdateBinder}}),exports.useUpdateEffect=xe,exports.useVirtualList=Ee;
|