@univerjs/ui 0.8.1 → 0.8.2-nightly.202506201607

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -8,13 +8,13 @@ hover:univer-bg-gray-100 whitespace-nowrap univer-w-max
8
8
  `;function Y6(e){const{children:t,className:r,style:n,disabled:i=!1,active:a=!1,noIcon:o,onClick:c,onDoubleClick:h,...g}=e,p=L=>{if(i){L.preventDefault();return}c&&c(L)},d=L=>{if(i){L.preventDefault();return}h&&h(L)};return f.jsx("button",{type:"button",className:T.clsx(W6,{"univer-px-2":o,"!univer-bg-gray-200 dark:!univer-bg-gray-500":a}),style:n,disabled:i,onClick:p,onDoubleClick:d,...g,children:t})}function X6(e){const{disabled$:t,hidden$:r,activated$:n,value$:i}=e,[a,o]=s.useState(),[c,h]=s.useState(!1),[g,p]=s.useState(!1),[d,L]=s.useState(!1);return s.useEffect(()=>{const _=[];return t&&_.push(t.subscribe(M=>h(M))),r&&_.push(r.subscribe(M=>L(M))),n&&_.push(n.subscribe(M=>p(M))),i&&_.push(i.subscribe(M=>o(M))),()=>_.forEach(M=>M.unsubscribe())},[n,t,r,i]),{disabled:c,value:a,activated:g,hidden:d}}const d3=s.createContext({dropdownVisible:!1,setDropdownVisible:e=>{}}),f4=s.forwardRef((e,t)=>{const{children:r,...n}=e,i=s.useRef(null),[a,o]=s.useState(!1),[c,h]=s.useState(!1);function g(L){o(c?!1:L)}function p(L){h(L),o(!1)}const d=s.useMemo(()=>({dropdownVisible:c,setDropdownVisible:p}),[c]);return s.useImperativeHandle(t,()=>({el:i.current})),n.title?f.jsx(T.Tooltip,{visible:a,onVisibleChange:g,...n,children:f.jsx("span",{ref:i,children:f.jsx(d3.Provider,{value:d,children:r})})}):f.jsx("span",{ref:i,children:r})});function h4(e){const{children:t,overlay:r,disabled:n,align:i="start"}=e,{dropdownVisible:a,setDropdownVisible:o}=s.useContext(d3);function c(h){o(h)}return f.jsx(T.Dropdown,{align:i,overlay:f.jsx("div",{className:"univer-grid univer-gap-2",children:r}),disabled:n,open:a,onOpenChange:c,children:f.jsx("div",{className:"univer-h-full",onClick:h=>h.stopPropagation(),children:t})})}function fe({icon:e,value:t,option:r,onOptionSelect:n}){var o;const i=c=>{n==null||n({value:c,label:r==null?void 0:r.label,commandId:r==null?void 0:r.commandId})},a=typeof r.label=="string"||typeof r.label=="object"&&((o=r.label)==null?void 0:o.selectable)!==!1;return f.jsxs("div",{className:T.clsx("univer-relative univer-flex univer-items-center univer-gap-2",{"univer-pl-6":a}),children:[a&&String(t)===String(r.value)&&f.jsx(qe,{className:"univer-absolute univer-left-1 univer-top-0.5 univer-text-primary-600"}),f.jsx(h1,{className:"univer-text-sm",icon:e,value$:r.value$,value:r.value,label:r.label,onChange:i})]})}function et({menuId:e,slot:t,value:r,options:n,children:i,disabled:a,onOptionSelect:o}){var V;const{dropdownVisible:c,setDropdownVisible:h}=s.useContext(d3),g=O.useDependency(x1),[p,d]=s.useState({}),L=s.useMemo(()=>e?g.getMenuByPositionKey(e):[],[e]),_=s.useMemo(()=>L.filter(H=>{var E;if(!H.children)return!p[H.key];const x=((E=H.key)==null?void 0:E.toString())||"";return!p[x]}),[L,p]);function M(H){h(H)}if(s.useEffect(()=>{const H=[];return L.forEach(x=>{var E;if(x.children){const R=x.children.map(y=>{var N,k;return(k=(N=y.item)==null?void 0:N.hidden$)!=null?k:F.of(!1)}),$=F.combineLatest(R).subscribe(y=>{const N=y.every(k=>k===!0);d(k=>({...k,[x.key]:N}))});H.push($)}else if((E=x.item)!=null&&E.hidden$){const R=x.item.hidden$.subscribe($=>{d(y=>({...y,[x.key]:$}))});H.push(R)}}),()=>{H.forEach(x=>x==null?void 0:x.unsubscribe()),d({})}},[L]),t)return f.jsx(h4,{disabled:a,overlay:n.map((H,x)=>f.jsx(fe,{value:r,option:H,onOptionSelect:o},x)),children:i});if(n!=null&&n.length){const H=n.map(x=>{var E;return{type:"item",className:T.clsx({"focus:univer-bg-white":typeof x.label!="string"&&((E=x.label)==null?void 0:E.hoverable)===!1}),children:f.jsx(fe,{icon:x.icon,value:r,option:x,onOptionSelect:o}),disabled:x.disabled,onSelect:()=>{typeof x.value>"u"||o==null||o({...x})}}});for(const x of _){if(!x.item)continue;const{title:E,id:R,commandId:$,icon:y}=x.item;if(!E)throw new Error("Menu item title is required");H.push({type:"item",children:f.jsx(fe,{icon:y,value:r,option:{label:{name:E,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:$,id:R})}})}return f.jsx(T.DropdownMenu,{align:"start",items:H,disabled:a,open:c,onOpenChange:M,children:i})}else{const H=[];for(const x of _)if(x.item){const{title:E,id:R,commandId:$,icon:y}=x.item;if(!E)throw new Error("Menu item title is required");H.push({type:"item",children:f.jsx(fe,{icon:y,value:r,option:{label:{name:E,selectable:!1}}}),onSelect:()=>{o==null||o({commandId:$,id:R})}})}else(V=x.children)!=null&&V.length;return f.jsx(T.DropdownMenu,{align:"start",items:H,disabled:a,open:c,onOpenChange:M,children:i})}}const Y1=s.forwardRef((e,t)=>{const r=O.useDependency(C.LocaleService),n=O.useDependency(C.ICommandService),i=O.useDependency(S1),a=O.useDependency(m1),{value:o,hidden:c,disabled:h,activated:g}=X6(e),p=(G,W)=>{i.focus(),n.executeCommand(G,W)},{tooltip:d,shortcut:L,icon:_,title:M,label:V,id:H,commandId:x,type:E,slot:R,params:$}=e,y=r.t(d!=null?d:"")+(L?` (${L})`:""),{selections:N}=e,k=s.useMemo(()=>F.isObservable(N)?N:new F.Observable(G=>{G.next(N)}),[N]),Y=O.useObservable(k),B=s.useMemo(()=>F.isObservable(_)?_:new F.Observable(G=>{var K,a1;const W=(a1=(K=Y==null?void 0:Y.find(u1=>u1.value===o))==null?void 0:K.icon)!=null?a1:_;G.next(W)}),[_,Y,o]),z=O.useObservable(B,void 0,!0);function X(G){var o1;const W=e.selectionsCommandId,K=x!=null?x:H,a1=(o1=W!=null?W:x)!=null?o1:H;function u1(r1){if(h)return;let c1=a1;r1.id&&(c1=r1.id),p(c1,{value:r1.value})}function p1(r1){h||p(a1,{value:r1})}function L1(){h||G===g1.BUTTON_SELECTOR&&p(K,{value:o})}return G===g1.BUTTON_SELECTOR?f.jsxs("div",{"data-u-command":H,"data-disabled":h,className:T.clsx("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:[f.jsx("div",{className:T.clsx("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:L1,children:f.jsx(h1,{icon:z,title:M,value:o,label:V,onChange:p1})}),f.jsx(et,{menuId:H,slot:R,value:o,options:Y,disabled:h,onOptionSelect:u1,children:f.jsx("div",{className:T.clsx("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:f.jsx(J1,{})})})]}):f.jsx(et,{menuId:H,slot:R,value:o,options:Y,disabled:h,onOptionSelect:u1,children:f.jsxs("div",{"data-u-command":H,className:T.clsx("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:[f.jsx(h1,{icon:z,title:M,value:o,label:V,onChange:p1}),f.jsx("div",{className:T.clsx("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:f.jsx(J1,{})})]})})}function q(){var W;const G=a.get(typeof V=="string"?V:(W=V==null?void 0:V.name)!=null?W:"");return f.jsx(Y6,{"data-u-command":H,className:"univer-text-sm",noIcon:!_,active:g,disabled:h,onClick:()=>{var K;return p((K=e.commandId)!=null?K:e.id,o!=null?o:$)},onDoubleClick:()=>e.subId&&p(e.subId),children:G?f.jsx(h1,{title:M,value:o,label:V}):_?f.jsx(h1,{icon:_}):f.jsx(h1,{title:M})})}function Q(){switch(E){case g1.BUTTON_SELECTOR:case g1.SELECTOR:case g1.SUBITEMS:return X(E);case g1.BUTTON:default:return q()}}return!c&&f.jsx(f4,{ref:t,title:y,placement:"bottom",children:Q()})}),C4={[f1.START]:c9,[f1.INSERT]:p9,[f1.FORMULAS]:Qe,[f1.DATA]:At,[f1.VIEW]:Jt,[f1.OTHERS]:Ke};function q6(e){const{ribbonType:t,headerMenuComponents:r,headerMenu:n=!0}=e,i=O.useDependency(x1),a=O.useDependency(C.IUniverInstanceService),o=O.useDependency(C.LocaleService),[c,h]=s.useState(0),g=O.useObservable(a.focused$);s.useEffect(()=>{const B=i.menuChanged$.subscribe(()=>{h(z=>z+1)});return()=>{B.unsubscribe()}},[]);const p=s.useRef(null),d=s.useRef({}),[L,_]=s.useState([]),[M,V]=s.useState(f1.START),[H,x]=s.useState(!1),[E,R]=s.useState([]),[$,y]=s.useState(!1),N=s.useCallback(B=>{d.current={},V(B.key),x(!1)},[]);s.useEffect(()=>{var q;const B=i.getMenuByPositionKey(K1.RIBBON),z=[],X=[];for(const Q of B)if(Q.children){for(const G of Q.children)if(G.children)for(const W of G.children)(q=W.item)!=null&&q.hidden$&&(z.push(W.item.hidden$),X.push(`${Q.key}/${G.key}/${W.key}`))}F.combineLatest(z).subscribe(Q=>{var K,a1,u1,p1,L1,o1;const G=[],W=Q.map((r1,c1)=>r1?X[c1]:null).filter(r1=>!!r1);for(const r1 of B){const c1={...r1,children:[]};if((K=r1.children)!=null&&K.length)for(const b1 of r1.children){const M1={...b1,children:[]};let V1=!0;if((a1=b1.children)!=null&&a1.length){for(const Z1 of b1.children){const j1=`${r1.key}/${b1.key}/${Z1.key}`;W.includes(j1)||(u1=M1.children)==null||u1.push(Z1)}(p1=M1.children)!=null&&p1.every(Z1=>{var j1;return((j1=Z1.children)==null?void 0:j1.length)===0})&&(V1=!1)}V1&&((L1=c1.children)==null||L1.push(M1))}(o1=c1.children)!=null&&o1.length&&c1.children.every(b1=>{var M1;return(M1=b1.children)==null?void 0:M1.length})&&G.push(c1)}if(t==="simple"){const r1=[{key:f1.START,children:[],order:0}];G.forEach(c1=>{var b1;(b1=c1.children)==null||b1.forEach(M1=>{var V1;(V1=r1[0].children)==null||V1.push(M1)})}),_(r1)}else _(G)}).unsubscribe()},[c,g]);const k=s.useMemo(()=>{var q,Q;const B=(Q=(q=L.find(G=>G.key===M))==null?void 0:q.children)!=null?Q:[],z=[],X=[];for(const G of B)if(G.children){const W=G.children.filter(K=>!E.includes(K.key));W.length>0&&z.push({...G,children:W}),W.length<G.children.length&&X.push({...G,children:G.children.filter(K=>E.includes(K.key))})}return{allGroups:B,visibleGroups:z,hiddenGroups:X}},[E,L,M]);s.useEffect(()=>{let B=null;const z=new ResizeObserver(C.throttle(X=>{for(const q of X)y(!0),B=requestAnimationFrame(()=>{var L1,o1;const{width:Q}=q.contentRect,W=Object.values(d.current).sort((r1,c1)=>r1.order-c1.order||r1.groupOrder-c1.groupOrder||r1.itemOrder-c1.itemOrder),K=[];let a1=32;const p1=(((o1=(L1=L.find(r1=>r1.key===M))==null?void 0:L1.children)!=null?o1:[]).length-1)*8;a1+=p1;for(const{el:r1,key:c1}of W){const{width:b1}=r1.getBoundingClientRect();a1+=b1+8,a1>Q&&K.push(c1)}R(K),y(!1)})},100));return z.observe(p.current),()=>{B&&cancelAnimationFrame(B),z.disconnect()}},[L,M]);const Y=s.useMemo(()=>f.jsx("div",{"aria-hidden":"true",className:T.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":!$},T.divideXClassName,T.borderBottomClassName),children:k.allGroups.map((B,z)=>{var X,q;return(((X=B.children)==null?void 0:X.length)||B.item)&&f.jsx(s.Fragment,{children:f.jsx("div",{className:"univer-grid univer-grid-flow-col univer-gap-2 univer-px-2",children:B.children&&((q=B.children)==null?void 0:q.map(Q=>Q.item&&f.jsx(Y1,{...Q.item,ref:G=>{G!=null&&G.el&&(d.current[Q.key]={el:G.el,key:Q.key,order:z,groupOrder:B.order,itemOrder:Q.order})}},Q.key)))})},B.key)})}),[k.allGroups,$]);return f.jsxs(f.Fragment,{children:[n&&r&&r.size>0&&f.jsx("header",{className:T.clsx("univer-relative univer-h-11 univer-select-none",T.borderBottomClassName),children:f.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:f.jsx(v1,{components:r})})}),f.jsxs("div",{className:T.clsx("univer-box-border univer-grid univer-h-10 univer-grid-flow-col univer-items-center univer-px-3",{"univer-grid-cols-[auto,1fr]":L.length>1,"univer-grid-cols-none":L.length===1},T.borderBottomClassName),children:[L.length>1&&f.jsx(T.HoverCard,{className:"univer-max-w-96 !univer-rounded-xl",align:"start",open:H,overlay:f.jsx("div",{className:"univer-grid univer-gap-1 univer-px-2 univer-py-1",children:L.map(B=>{const z=C4[B.key];return f.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",onClick:()=>N(B),children:[f.jsx("span",{className:T.clsx("univer-box-border univer-flex univer-size-9 univer-flex-shrink-0 univer-items-center univer-justify-center univer-rounded-lg",T.borderClassName),children:f.jsx(z,{className:"univer-text-gray-500 dark:!univer-text-gray-300"})}),f.jsxs("span",{className:"univer-flex univer-flex-col",children:[f.jsx("strong",{className:"univer-text-sm univer-font-semibold univer-text-gray-800 dark:!univer-text-gray-200",children:o.t(B.key)}),f.jsx("span",{className:"univer-text-xs univer-text-gray-400",children:o.t(`${B.key}Desc`)})]})]},B.key)})}),onOpenChange:x,children:f.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:()=>x(!0),children:[o.t(M),f.jsx(J1,{className:"univer-text-gray-200 dark:!univer-text-gray-500"})]})}),f.jsxs("div",{"data-u-comp":"ribbon-toolbar",ref:p,className:T.clsx("univer-flex univer-overflow-hidden",T.divideXClassName),children:[k.visibleGroups.map(B=>{var z,X;return(((z=B.children)==null?void 0:z.length)||B.item)&&f.jsx(s.Fragment,{children:f.jsx("div",{className:"univer-grid univer-grid-flow-col univer-gap-2 univer-px-2",children:B.children&&((X=B.children)==null?void 0:X.map(q=>q.item&&f.jsx(Y1,{...q.item},q.key)))})},B.key)}),E.length>0&&f.jsx("div",{"data-u-comp":"ribbon-toolbar-more",className:"univer-pl-2 rtl:univer-pr-2",children:f.jsx(T.Dropdown,{collisionPadding:{right:12,left:12},overlay:f.jsx("div",{className:"univer-box-border univer-grid univer-max-w-[var(--radix-popper-available-width)] univer-gap-2 univer-p-2",children:k.hiddenGroups.map(B=>{var z;return f.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:f.jsx("div",{className:"univer-flex univer-flex-wrap univer-gap-2",children:B.children?(z=B.children)==null?void 0:z.map(X=>X.item&&f.jsx(Y1,{...X.item},X.key)):B.item&&f.jsx(Y1,{...B.item},B.key)})},B.key)})}),children:f.jsx("a",{className:W6,type:"button",children:f.jsx(Ke,{})})})})]})]}),Y]})}class ie extends C.Disposable{constructor(){super(...arguments);U(this,"_styleSheetId","univer-theme-css-variables")}injectThemeToHead(r){function n(c,h="--univer"){const g=[];function p(d,L=""){for(const _ in d){const M=d[_],V=L?`${L}-${_}`:_;typeof M=="object"&&M!==null?p(M,V):g.push(`${h}-${V}: ${M};`)}}return p(c),g.join(`
9
9
  `)}const i=n(r),a=document.getElementById(this._styleSheetId);a&&a.remove();const o=document.createElement("style");o.setAttribute("id",this._styleSheetId),o.innerHTML=`:root {
10
10
  ${i}
11
- }`,document.head.appendChild(o)}dispose(){super.dispose()}}const oe=C.createIdentifier("ui.contextmenu.service");class f3 extends C.Disposable{constructor(){super(...arguments);U(this,"_currentHandler",null);U(this,"disabled",!1)}get visible(){var r,n;return(n=(r=this._currentHandler)==null?void 0:r.visible)!=null?n:!1}disable(){this.disabled=!0}enable(){this.disabled=!1}triggerContextMenu(r,n){var i;r.stopPropagation(),!this.disabled&&((i=this._currentHandler)==null||i.handleContextMenu(r,n))}hideContextMenu(){var r;(r=this._currentHandler)==null||r.hideContextMenu()}registerContextMenuHandler(r){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=r,C.toDisposable(()=>this._currentHandler=null)}}function J6(){const e=s.useRef(null),[t,r]=s.useState(!1),[n,i]=s.useState(""),[a,o]=s.useState([0,0]),c=s.useRef(t),h=O.useDependency(oe),g=O.useDependency(C.ICommandService),p=O.useInjector();c.current=t,s.useEffect(()=>{const _=h.registerContextMenuHandler({handleContextMenu:d,hideContextMenu(){r(!1)},get visible(){return c.current}});function M(V){e.current&&!e.current.contains(V.target)&&L()}return document.addEventListener("pointerdown",M),document.addEventListener("wheel",L),()=>{document.removeEventListener("pointerdown",M),document.removeEventListener("wheel",L),_.dispose()}},[h]);function d(_,M){r(!1),requestAnimationFrame(()=>{i(M),o([_.clientX,_.clientY]),r(!0)})}function L(){r(!1)}return f.jsx(T.Popup,{visible:t,offset:a,children:f.jsx("section",{ref:e,children:n&&f.jsx(r3,{menuType:n,onOptionSelect:_=>{const{label:M,commandId:V,value:H}=_;g&&g.executeCommand(V!=null?V:M,{value:H}),p.get(S1).focus(),r(!1)}})})})}const Me=C.createIdentifier("univer.global-zone-service");function h3(){const e=O.useDependency(Me),[t,r]=s.useState(!1),n=O.useObservable(e.componentKey$,e.componentKey),i=O.useDependency(m1),a=s.useMemo(()=>{const o=i.get(n!=null?n:"");if(o)return o},[n,i]);return s.useEffect(()=>{const o=e.visible$.subscribe(c=>{r(c)});return()=>{o.unsubscribe()}},[e.visible$]),t?f.jsx("section",{className:T.clsx("univer-absolute univer-bg-gray-100",{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&f.jsx(a,{})}):null}function C3(){const e=O.useDependency(P1),t=O.useObservable(e.sidebarOptions$),r=s.useRef(null),n=s.useMemo(()=>{if(!t)return null;const o={...t};for(const c of["children","header","footer"]){const h=c;if(t[h]){const{key:g,...p}=t[h];p&&(o[h]=f.jsx(h1,{...p},g))}}return o},[t]);s.useEffect(()=>(r.current&&e.setContainer(r.current),()=>{e.setContainer(void 0)}),[e]),s.useEffect(()=>{const o=h=>{e.scrollEvent$.next(h)},c=r.current;return c&&c.addEventListener("scroll",o),()=>{c==null||c.removeEventListener("scroll",o)}},[e]);const i=s.useMemo(()=>n!=null&&n.visible?typeof n.width=="number"?`${n.width}px`:n.width:0,[n]);function a(){var c;const o={...t,visible:!1};e.options.visible=!1,e.sidebarOptions$.next(o),(c=o==null?void 0:o.onClose)==null||c.call(o)}return f.jsx("section",{"data-u-comp":"sidebar",className:T.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":n==null?void 0:n.visible,"univer-w-0 univer-translate-x-full":!(n!=null&&n.visible)}),style:{width:i},children:f.jsxs("section",{ref:r,className:T.clsx("univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto] univer-overflow-y-auto",T.borderLeftBottomClassName,T.scrollbarClassName),children:[f.jsxs("header",{className:"univer-sticky univer-top-0 univer-z-10 univer-box-border univer-flex 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:[n==null?void 0:n.header,f.jsx("a",{className:"univer-cursor-pointer univer-text-gray-500 dark:!univer-text-gray-300",onClick:a,children:f.jsx(Je,{})})]}),f.jsx("section",{className:"univer-box-border univer-px-4",style:n==null?void 0:n.bodyStyle,children:n==null?void 0:n.children}),(n==null?void 0:n.footer)&&f.jsx("footer",{className:"univer-sticky univer-bottom-0 univer-box-border univer-bg-white univer-p-4 dark:!univer-bg-gray-900",children:n.footer})]})})}const xe=C.createIdentifier("univer.zen-zone-service");function v3(){const e=O.useDependency(xe),[t,r]=s.useState(!1),[n,i]=s.useState(),a=O.useObservable(e.temporaryHidden$),o=O.useDependency(m1);s.useEffect(()=>{const h=[e.visible$.subscribe(g=>{r(g)}),e.componentKey$.subscribe(g=>{i(g)})];return()=>{h.forEach(g=>{g.unsubscribe()})}},[]);const c=s.useMemo(()=>{const h=o.get(n!=null?n:"");if(h)return h},[n]);return f.jsx("section",{className:T.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:f.jsx("div",{className:"univer-relative univer-flex-1",children:c&&f.jsx(c,{})})})}function v4(e){const t=M6(re);return f.jsx(g4,{...e,...t})}function g4(e){var Q;const{header:t=!0,toolbar:r=!0,footer:n=!0,headerMenu:i=!0,contextMenu:a=!0,ribbonType:o="default",mountContainer:c,onRendered:h}=e,g=O.useDependency(C.LocaleService),p=O.useDependency(C.ThemeService),d=O.useDependency(ie),L=s.useRef(null),M=O.useDependency(C.IConfigService).getConfig(re),V=C1(i1.CUSTOM_HEADER),H=C1(i1.FOOTER),x=C1(i1.HEADER),E=C1(i1.HEADER_MENU),R=C1(i1.CONTENT),$=C1(i1.LEFT_SIDEBAR),y=C1(i1.GLOBAL),N=C1(i1.TOOLBAR),k=(Q=M==null?void 0:M.popupRootId)!=null?Q:"univer-popup-portal";s.useLayoutEffect(()=>{const G=p.currentTheme$.subscribe(W=>{d.injectThemeToHead(W)});return()=>{G.unsubscribe()}},[]);const[Y,B]=s.useState(!1);s.useLayoutEffect(()=>{const G=p.darkMode$.subscribe(W=>{B(W),W?document.documentElement.classList.add("univer-dark"):document.documentElement.classList.remove("univer-dark")});return()=>{G.unsubscribe()}},[]),s.useEffect(()=>{L.current&&(h==null||h(L.current))},[h]);const[z,X]=s.useState(g.getLocales()),q=s.useMemo(()=>document.createElement("div"),[]);return s.useEffect(()=>{document.body.appendChild(q);const G=[g.localeChanged$.subscribe(()=>{X(g.getLocales())})];return()=>{G.forEach(W=>W.unsubscribe()),document.body.removeChild(q)}},[g,c,q]),f.jsxs(T.ConfigProvider,{locale:z==null?void 0:z.design,mountContainer:q,children:[f.jsxs("div",{"data-u-comp":"workbench-layout",className:T.clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",{"univer-dark":Y}),tabIndex:-1,onBlur:G=>G.stopPropagation(),onContextMenu:G=>G.preventDefault(),children:[f.jsx("div",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white",children:f.jsx(v1,{components:V},"custom-header")}),t&&r&&f.jsx("header",{"data-u-comp":"headerbar",className:"univer-relative univer-z-10 univer-w-full",children:f.jsx(v1,{components:N,sharedProps:{ribbonType:o,headerMenuComponents:E,headerMenu:i}},"toolbar")}),f.jsxs("section",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",children:[f.jsxs("div",{className:"univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",children:[f.jsx("aside",{"data-u-comp":"left-sidebar",className:"univer-h-full",children:f.jsx(v1,{components:$},"left-sidebar")}),f.jsxs("section",{className:T.clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white",T.borderBottomClassName),children:[f.jsx("header",{children:t&&f.jsx(v1,{components:x},"header")}),f.jsx("section",{className:"univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",ref:L,"data-range-selector":!0,onContextMenu:G=>G.preventDefault(),children:f.jsx(v1,{components:R},"content")})]}),f.jsx("aside",{"data-u-comp":"right-sidebar",className:"univer-h-full",children:f.jsx(C3,{})})]}),n&&f.jsx("footer",{children:f.jsx(v1,{components:H,sharedProps:{contextMenu:a}},"footer")}),f.jsx(v3,{})]})]}),f.jsx(v1,{components:y},"global"),f.jsx(h3,{}),a&&f.jsx(J6,{}),f.jsx(m4,{}),f.jsx("div",{id:k})]})}function m4(){const{mountContainer:e}=s.useContext(T.ConfigContext),t=C1(i1.FLOATING);return ht.createPortal(f.jsx(v1,{components:t},"floating"),e)}const p4=3e3;class g3 extends C.Disposable{constructor(r,n,i,a,o){super();U(this,"_steadyTimeout");U(this,"_renderTimeout");U(this,"_currentRenderId",null);this._injector=r,this._instanceService=n,this._layoutService=i,this._lifecycleService=a,this._renderManagerService=o}dispose(){super.dispose(),clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout)}_bootstrapWorkbench(){this.disposeWithMe(this.bootstrap(async(r,n)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(n)),this.disposeWithMe(this._layoutService.registerContentElement(r)));try{await this._lifecycleService.onStage(C.LifecycleStages.Ready),this._renderTimeout=window.setTimeout(()=>{const i=this._renderManagerService.getRenderAll();for(const[a]of i)if(this._changeRenderUnit(a,r))break;this.disposeWithMe(this._instanceService.focused$.subscribe(a=>{a&&this._changeRenderUnit(a,r)})),this.disposeWithMe(this._renderManagerService.created$.subscribe(a=>{var o;a.unitId===((o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId())&&this._changeRenderUnit(a.unitId,r)})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(a=>{this._currentRenderId===a&&(this._currentRenderId=null)})),this._lifecycleService.stage=C.LifecycleStages.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=C.LifecycleStages.Steady},p4)},300)}catch(i){if(i instanceof C.LifecycleUnreachableError)return;throw i}}))}_changeRenderUnit(r,n){if(this._currentRenderId===r)return!1;const i=this._renderManagerService.getRenderById(r);if(!i||!i.unitId||C.isInternalEditorID(i.unitId))return!1;const a=this._currentRenderId?this._renderManagerService.getRenderById(this._currentRenderId):null;return a==null||a.deactivate(),a==null||a.engine.unmount(),i.engine.mount(n),i.activate(),this._currentRenderId=r,!0}}var b4=Object.getOwnPropertyDescriptor,L4=(e,t,r,n)=>{for(var i=n>1?void 0:n?b4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},R1=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopUIController=class extends g3{constructor(t,r,n,i,a,o,c,h,g){super(r,o,a,n,i),this._config=t,this._componentManager=g,c.mergeMenu(k6),this._initBuiltinComponents(h),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[L6,b6],[_6,w6],[E6,I6],[D6,H6],[R6,S6],[x6,T.ColorPicker]].forEach(([t,r])=>{this.disposeWithMe(this._componentManager.register(t,r))})}bootstrap(t){return w4(this._injector,this._config,t)}_initBuiltinComponents(t){this.disposeWithMe(t.registerComponent(i1.FLOATING,()=>O.connectInjector(u3,this._injector))),this.disposeWithMe(t.registerComponent(i1.CONTENT,()=>O.connectInjector(l3,this._injector))),this.disposeWithMe(t.registerComponent(i1.TOOLBAR,()=>O.connectInjector(q6,this._injector)))}};exports.DesktopUIController=L4([R1(1,C.Inject(C.Injector)),R1(2,C.Inject(C.LifecycleService)),R1(3,te.IRenderManagerService),R1(4,S1),R1(5,C.IUniverInstanceService),R1(6,x1),R1(7,y1),R1(8,C.Inject(m1))],exports.DesktopUIController);function w4(e,t,r){let n;const i=t.container;if(typeof i=="string"){const h=document.getElementById(i);h?n=h:n=tt(i)}else i instanceof HTMLElement?n=i:n=tt("univer");const a=O.connectInjector(v4,e),o=h=>r(h,n);function c(){T.render(f.jsx(a,{...t,mountContainer:n,onRendered:o}),n)}return c(),C.toDisposable(()=>{T.render(f.jsx("div",{}),n),setTimeout(()=>T.render(f.jsx("div",{}),n),200),setTimeout(()=>T.unmount(n),500)})}function tt(e){const t=document.createElement("div");return t.id=e,t}function _4(e){const{menuType:t,onOptionSelect:r}=e,n=O.useDependency(x1);if(!t)return null;const i=s.useMemo(()=>{const a=n.getMenuByPositionKey(t);function o(c){return c.reduce((h,g)=>g.children?[...h,...o(g.children)]:[...h,g],[])}return o(a)},[t]);return f.jsx("div",{className:"univer-box-border univer-grid univer-min-w-8 univer-max-w-52 univer-gap-1 univer-rounded univer-bg-gray-900 univer-px-2 univer-py-1",style:{gridTemplateColumns:`repeat(${Math.min(2,i.length)}, 72px)`},children:i.map(a=>a.item&&f.jsx(y4,{menuItem:a.item,onClick:o=>r==null?void 0:r({value:"",label:a.key,...o})},a.key))})}function y4(e){const{menuItem:t,onClick:r}=e,{id:n,type:i,title:a,label:o,icon:c}=t;if(i!==g1.BUTTON)throw new Error(`[MobileMenuItem]: on mobile devices only "BUTTON" type menu items are supported. Please check "${n}".`);const h=O.useObservable(t.disabled$,!1),g=O.useObservable(t.value$);return f.jsx("button",{type:"button",className:T.clsx("univer-w-18 univer-flex univer-flex-col univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-text-white [&>span]:univer-mt-0.5 [&>span]:univer-w-full [&>span]:univer-truncate [&>span]:univer-text-sm [&>svg]:univer-size-[18px] [&>svg]:univer-text-lg"),disabled:h,onClick:()=>r({id:n}),children:f.jsx(h1,{value:g,title:a,label:o,icon:c})},n)}function Q6(){const[e,t]=s.useState(!1),[r,n]=s.useState(""),[i,a]=s.useState([0,0]),o=s.useRef(e),c=O.useDependency(oe),h=O.useDependency(C.ICommandService);o.current=e,s.useEffect(()=>{const d=c.registerContextMenuHandler({handleContextMenu:g,hideContextMenu(){t(!1)},get visible(){return o.current}});return document.addEventListener("pointerdown",p),document.addEventListener("wheel",p),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("wheel",p),d.dispose()}},[c]);function g(d,L){n(L),a([d.clientX,d.clientY]),t(!0)}function p(){t(!1)}return f.jsx(T.Popup,{visible:e,offset:i,children:f.jsx("section",{onPointerDown:d=>d.stopPropagation(),children:r&&f.jsx(_4,{menuType:r,onOptionSelect:d=>{const{label:L,value:_,commandId:M}=d;h&&h.executeCommand(M!=null?M:L,{value:_}),t(!1)}})})})}function M4(e){const{header:t=!0,footer:r=!0,contextMenu:n=!0,mountContainer:i,onRendered:a}=e,o=O.useDependency(C.LocaleService),c=O.useDependency(C.ThemeService),h=O.useDependency(ie),g=s.useRef(null),p=C1(i1.FOOTER),d=C1(i1.HEADER),L=C1(i1.CONTENT),_=C1(i1.LEFT_SIDEBAR),M=C1(i1.GLOBAL),[V,H]=s.useState(!1);s.useEffect(()=>{const $=c.darkMode$.subscribe(y=>{H(y)});return()=>{$.unsubscribe()}},[]),s.useEffect(()=>{g.current&&(a==null||a(g.current))},[a]);const[x,E]=s.useState(o.getLocales()),R=s.useMemo(()=>document.createElement("div"),[]);return s.useLayoutEffect(()=>{const $=c.currentTheme$.subscribe(y=>{h.injectThemeToHead(y)});return()=>{$.unsubscribe()}},[]),s.useEffect(()=>{document.body.appendChild(R);const $=[o.localeChanged$.subscribe(()=>{E(o.getLocales())})];return()=>{$.forEach(y=>y.unsubscribe()),document.body.removeChild(R)}},[o,i,R]),f.jsxs(T.ConfigProvider,{locale:x==null?void 0:x.design,mountContainer:R,children:[f.jsxs("div",{"data-u-comp":"app-layout",className:T.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":V}),tabIndex:-1,onBlur:$=>$.stopPropagation(),children:[t&&f.jsx("header",{className:"univer-relative univer-z-10 univer-w-full"}),f.jsxs("section",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",children:[f.jsxs("div",{className:"univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",children:[f.jsx("aside",{className:"univer-h-full",children:f.jsx(v1,{components:_},"left-sidebar")}),f.jsxs("section",{className:T.clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white",T.borderBottomClassName),children:[f.jsx("header",{className:"univer-w-screen",children:t&&f.jsx(v1,{components:d},"header")}),f.jsx("section",{ref:g,className:"univer-relative univer-overflow-hidden","data-range-selector":!0,onContextMenu:$=>$.preventDefault(),children:f.jsx(v1,{components:L},"content")})]}),f.jsx("aside",{className:"univer-h-full",children:f.jsx(C3,{})})]}),r&&f.jsx("footer",{children:f.jsx(v1,{components:p},"footer")}),f.jsx(h3,{}),f.jsx(v3,{})]})]}),f.jsx(v1,{components:M},"global"),n&&f.jsx(Q6,{})]})}var x4=Object.getOwnPropertyDescriptor,S4=(e,t,r,n)=>{for(var i=n>1?void 0:n?x4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},$1=(e,t)=>(r,n)=>t(r,n,e);let ze=class extends g3{constructor(e,t,r,n,i,a,o){super(t,a,i,r,n),this._config=e,this._initBuiltinComponents(o),this._bootstrapWorkbench()}bootstrap(e){return I4(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(i1.CONTENT,()=>O.connectInjector(u3,this._injector))),this.disposeWithMe(e.registerComponent(i1.CONTENT,()=>O.connectInjector(l3,this._injector)))}};ze=S4([$1(1,C.Inject(C.Injector)),$1(2,C.Inject(C.LifecycleService)),$1(3,te.IRenderManagerService),$1(4,S1),$1(5,C.IUniverInstanceService),$1(6,y1)],ze);function I4(e,t,r){let n;const i=t.container;if(typeof i=="string"){const h=document.getElementById(i);h?n=h:n=rt(i)}else i instanceof HTMLElement?n=i:n=rt("univer");const a=O.connectInjector(M4,e),o=h=>r(h,n);function c(){T.render(f.jsx(a,{...t,mountContainer:n,onRendered:o}),n)}return c(),C.toDisposable(()=>{T.unmount(n)})}function rt(e){const t=document.createElement("div");return t.id=e,t}const ae=C.createIdentifier("ui.notification.service");var H4=Object.getOwnPropertyDescriptor,R4=(e,t,r,n)=>{for(var i=n>1?void 0:n?H4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},E4=(e,t)=>(r,n)=>t(r,n,e);const m3=C.createIdentifier("univer.ui.before-close-service");exports.DesktopBeforeCloseService=class{constructor(t){U(this,"_beforeUnloadCallbacks",[]);U(this,"_onCloseCallbacks",[]);this._notificationService=t,this._init()}registerBeforeClose(t){return this._beforeUnloadCallbacks.push(t),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(r=>r!==t)}}}registerOnClose(t){return this._onCloseCallbacks.push(t),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(r=>r!==t)}}}_init(){window.addEventListener("beforeunload",t=>{let r=t;const n=this._beforeUnloadCallbacks.map(i=>i()).filter(i=>!!i).join(`
11
+ }`,document.head.appendChild(o)}dispose(){super.dispose()}}const oe=C.createIdentifier("ui.contextmenu.service");class f3 extends C.Disposable{constructor(){super(...arguments);U(this,"_currentHandler",null);U(this,"disabled",!1)}get visible(){var r,n;return(n=(r=this._currentHandler)==null?void 0:r.visible)!=null?n:!1}disable(){this.disabled=!0}enable(){this.disabled=!1}triggerContextMenu(r,n){var i;r.stopPropagation(),!this.disabled&&((i=this._currentHandler)==null||i.handleContextMenu(r,n))}hideContextMenu(){var r;(r=this._currentHandler)==null||r.hideContextMenu()}registerContextMenuHandler(r){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=r,C.toDisposable(()=>this._currentHandler=null)}}function J6(){const e=s.useRef(null),[t,r]=s.useState(!1),[n,i]=s.useState(""),[a,o]=s.useState([0,0]),c=s.useRef(t),h=O.useDependency(oe),g=O.useDependency(C.ICommandService),p=O.useInjector();c.current=t,s.useEffect(()=>{const _=h.registerContextMenuHandler({handleContextMenu:d,hideContextMenu(){r(!1)},get visible(){return c.current}});function M(V){e.current&&!e.current.contains(V.target)&&L()}return document.addEventListener("pointerdown",M),document.addEventListener("wheel",L),()=>{document.removeEventListener("pointerdown",M),document.removeEventListener("wheel",L),_.dispose()}},[h]);function d(_,M){r(!1),requestAnimationFrame(()=>{i(M),o([_.clientX,_.clientY]),r(!0)})}function L(){r(!1)}return f.jsx(T.Popup,{visible:t,offset:a,children:f.jsx("section",{ref:e,children:n&&f.jsx(r3,{menuType:n,onOptionSelect:_=>{const{label:M,commandId:V,value:H}=_;g&&g.executeCommand(V!=null?V:M,{value:H}),p.get(S1).focus(),r(!1)}})})})}const Me=C.createIdentifier("univer.global-zone-service");function h3(){const e=O.useDependency(Me),[t,r]=s.useState(!1),n=O.useObservable(e.componentKey$,e.componentKey),i=O.useDependency(m1),a=s.useMemo(()=>{const o=i.get(n!=null?n:"");if(o)return o},[n,i]);return s.useEffect(()=>{const o=e.visible$.subscribe(c=>{r(c)});return()=>{o.unsubscribe()}},[e.visible$]),t?f.jsx("section",{className:T.clsx("univer-absolute univer-bg-gray-100",{"univer-hidden":!t,"univer-inset-0 univer-z-[100] univer-block univer-size-full":t}),children:a&&f.jsx(a,{})}):null}function C3(){const e=O.useDependency(P1),t=O.useObservable(e.sidebarOptions$),r=s.useRef(null),n=s.useMemo(()=>{if(!t)return null;const o={...t};for(const c of["children","header","footer"]){const h=c;if(t[h]){const{key:g,...p}=t[h];p&&(o[h]=f.jsx(h1,{...p},g))}}return o},[t]);s.useEffect(()=>(r.current&&e.setContainer(r.current),()=>{e.setContainer(void 0)}),[e]),s.useEffect(()=>{const o=h=>{e.scrollEvent$.next(h)},c=r.current;return c&&c.addEventListener("scroll",o),()=>{c==null||c.removeEventListener("scroll",o)}},[e]);const i=s.useMemo(()=>n!=null&&n.visible?typeof n.width=="number"?`${n.width}px`:n.width:0,[n]);function a(){var c;const o={...t,visible:!1};e.options.visible=!1,e.sidebarOptions$.next(o),(c=o==null?void 0:o.onClose)==null||c.call(o)}return f.jsx("section",{"data-u-comp":"sidebar",className:T.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":n==null?void 0:n.visible,"univer-w-0 univer-translate-x-full":!(n!=null&&n.visible)}),style:{width:i},children:f.jsxs("section",{ref:r,className:T.clsx("univer-box-border univer-grid univer-h-0 univer-min-h-full univer-grid-rows-[auto_1fr_auto] univer-overflow-y-auto",T.borderLeftBottomClassName,T.scrollbarClassName),children:[f.jsxs("header",{className:"univer-sticky univer-top-0 univer-z-10 univer-box-border univer-flex 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:[n==null?void 0:n.header,f.jsx("a",{className:"univer-cursor-pointer univer-text-gray-500 dark:!univer-text-gray-300",onClick:a,children:f.jsx(Je,{})})]}),f.jsx("section",{className:"univer-box-border univer-px-4",style:n==null?void 0:n.bodyStyle,children:n==null?void 0:n.children}),(n==null?void 0:n.footer)&&f.jsx("footer",{className:"univer-sticky univer-bottom-0 univer-box-border univer-bg-white univer-p-4 dark:!univer-bg-gray-900",children:n.footer})]})})}const xe=C.createIdentifier("univer.zen-zone-service");function v3(){const e=O.useDependency(xe),[t,r]=s.useState(!1),[n,i]=s.useState(),a=O.useObservable(e.temporaryHidden$),o=O.useDependency(m1);s.useEffect(()=>{const h=[e.visible$.subscribe(g=>{r(g)}),e.componentKey$.subscribe(g=>{i(g)})];return()=>{h.forEach(g=>{g.unsubscribe()})}},[]);const c=s.useMemo(()=>{const h=o.get(n!=null?n:"");if(h)return h},[n]);return f.jsx("section",{className:T.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:f.jsx("div",{className:"univer-relative univer-flex-1",children:c&&f.jsx(c,{})})})}function v4(e){const t=M6(re);return f.jsx(g4,{...e,...t})}function g4(e){var Q;const{header:t=!0,toolbar:r=!0,footer:n=!0,headerMenu:i=!0,contextMenu:a=!0,ribbonType:o="default",mountContainer:c,onRendered:h}=e,g=O.useDependency(C.LocaleService),p=O.useDependency(C.ThemeService),d=O.useDependency(ie),L=s.useRef(null),M=O.useDependency(C.IConfigService).getConfig(re),V=C1(i1.CUSTOM_HEADER),H=C1(i1.FOOTER),x=C1(i1.HEADER),E=C1(i1.HEADER_MENU),R=C1(i1.CONTENT),$=C1(i1.LEFT_SIDEBAR),y=C1(i1.GLOBAL),N=C1(i1.TOOLBAR),k=(Q=M==null?void 0:M.popupRootId)!=null?Q:"univer-popup-portal";s.useLayoutEffect(()=>{const G=p.currentTheme$.subscribe(W=>{d.injectThemeToHead(W)});return()=>{G.unsubscribe()}},[]);const[Y,B]=s.useState(!1);s.useLayoutEffect(()=>{const G=p.darkMode$.subscribe(W=>{B(W),W?document.documentElement.classList.add("univer-dark"):document.documentElement.classList.remove("univer-dark")});return()=>{G.unsubscribe()}},[]),s.useEffect(()=>{L.current&&(h==null||h(L.current))},[h]);const[z,X]=s.useState(g.getLocales()),q=s.useMemo(()=>document.createElement("div"),[]);return s.useEffect(()=>{document.body.appendChild(q);const G=[g.localeChanged$.subscribe(()=>{X(g.getLocales())})];return()=>{G.forEach(W=>W.unsubscribe()),document.body.removeChild(q)}},[g,c,q]),f.jsxs(T.ConfigProvider,{locale:z==null?void 0:z.design,mountContainer:q,children:[f.jsxs("div",{"data-u-comp":"workbench-layout",className:T.clsx("univer-flex univer-h-full univer-min-h-0 univer-flex-col univer-bg-white dark:!univer-bg-gray-800",{"univer-dark":Y}),tabIndex:-1,onBlur:G=>G.stopPropagation(),onContextMenu:G=>G.preventDefault(),children:[f.jsx("div",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-col univer-bg-white",children:f.jsx(v1,{components:V},"custom-header")}),t&&r&&f.jsx("header",{"data-u-comp":"headerbar",className:"univer-relative univer-z-10 univer-w-full univer-overflow-hidden",children:f.jsx(v1,{components:N,sharedProps:{ribbonType:o,headerMenuComponents:E,headerMenu:i}},"toolbar")}),f.jsxs("section",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",children:[f.jsxs("div",{className:"univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",children:[f.jsx("aside",{"data-u-comp":"left-sidebar",className:"univer-h-full",children:f.jsx(v1,{components:$},"left-sidebar")}),f.jsxs("section",{className:T.clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white",T.borderBottomClassName),children:[f.jsx("header",{children:t&&f.jsx(v1,{components:x},"header")}),f.jsx("section",{className:"univer-relative univer-overflow-hidden dark:!univer-bg-gray-900",ref:L,"data-range-selector":!0,onContextMenu:G=>G.preventDefault(),children:f.jsx(v1,{components:R},"content")})]}),f.jsx("aside",{"data-u-comp":"right-sidebar",className:"univer-h-full",children:f.jsx(C3,{})})]}),n&&f.jsx("footer",{children:f.jsx(v1,{components:H,sharedProps:{contextMenu:a}},"footer")}),f.jsx(v3,{})]})]}),f.jsx(v1,{components:y},"global"),f.jsx(h3,{}),a&&f.jsx(J6,{}),f.jsx(m4,{}),f.jsx("div",{id:k})]})}function m4(){const{mountContainer:e}=s.useContext(T.ConfigContext),t=C1(i1.FLOATING);return ht.createPortal(f.jsx(v1,{components:t},"floating"),e)}const p4=3e3;class g3 extends C.Disposable{constructor(r,n,i,a,o){super();U(this,"_steadyTimeout");U(this,"_renderTimeout");U(this,"_currentRenderId",null);this._injector=r,this._instanceService=n,this._layoutService=i,this._lifecycleService=a,this._renderManagerService=o}dispose(){super.dispose(),clearTimeout(this._steadyTimeout),clearTimeout(this._renderTimeout)}_bootstrapWorkbench(){this.disposeWithMe(this.bootstrap(async(r,n)=>{this._layoutService&&(this.disposeWithMe(this._layoutService.registerRootContainerElement(n)),this.disposeWithMe(this._layoutService.registerContentElement(r)));try{await this._lifecycleService.onStage(C.LifecycleStages.Ready),this._renderTimeout=window.setTimeout(()=>{const i=this._renderManagerService.getRenderAll();for(const[a]of i)if(this._changeRenderUnit(a,r))break;this.disposeWithMe(this._instanceService.focused$.subscribe(a=>{a&&this._changeRenderUnit(a,r)})),this.disposeWithMe(this._renderManagerService.created$.subscribe(a=>{var o;a.unitId===((o=this._instanceService.getFocusedUnit())==null?void 0:o.getUnitId())&&this._changeRenderUnit(a.unitId,r)})),this.disposeWithMe(this._renderManagerService.disposed$.subscribe(a=>{this._currentRenderId===a&&(this._currentRenderId=null)})),this._lifecycleService.stage=C.LifecycleStages.Rendered,this._steadyTimeout=window.setTimeout(()=>{this._lifecycleService.stage=C.LifecycleStages.Steady},p4)},300)}catch(i){if(i instanceof C.LifecycleUnreachableError)return;throw i}}))}_changeRenderUnit(r,n){if(this._currentRenderId===r)return!1;const i=this._renderManagerService.getRenderById(r);if(!i||!i.unitId||C.isInternalEditorID(i.unitId))return!1;const a=this._currentRenderId?this._renderManagerService.getRenderById(this._currentRenderId):null;return a==null||a.deactivate(),a==null||a.engine.unmount(),i.engine.mount(n),i.activate(),this._currentRenderId=r,!0}}var b4=Object.getOwnPropertyDescriptor,L4=(e,t,r,n)=>{for(var i=n>1?void 0:n?b4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},R1=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopUIController=class extends g3{constructor(t,r,n,i,a,o,c,h,g){super(r,o,a,n,i),this._config=t,this._componentManager=g,c.mergeMenu(k6),this._initBuiltinComponents(h),this._registerComponents(),this._bootstrapWorkbench()}_registerComponents(){[[L6,b6],[_6,w6],[E6,I6],[D6,H6],[R6,S6],[x6,T.ColorPicker]].forEach(([t,r])=>{this.disposeWithMe(this._componentManager.register(t,r))})}bootstrap(t){return w4(this._injector,this._config,t)}_initBuiltinComponents(t){this.disposeWithMe(t.registerComponent(i1.FLOATING,()=>O.connectInjector(u3,this._injector))),this.disposeWithMe(t.registerComponent(i1.CONTENT,()=>O.connectInjector(l3,this._injector))),this.disposeWithMe(t.registerComponent(i1.TOOLBAR,()=>O.connectInjector(q6,this._injector)))}};exports.DesktopUIController=L4([R1(1,C.Inject(C.Injector)),R1(2,C.Inject(C.LifecycleService)),R1(3,te.IRenderManagerService),R1(4,S1),R1(5,C.IUniverInstanceService),R1(6,x1),R1(7,y1),R1(8,C.Inject(m1))],exports.DesktopUIController);function w4(e,t,r){let n;const i=t.container;if(typeof i=="string"){const h=document.getElementById(i);h?n=h:n=tt(i)}else i instanceof HTMLElement?n=i:n=tt("univer");const a=O.connectInjector(v4,e),o=h=>r(h,n);function c(){T.render(f.jsx(a,{...t,mountContainer:n,onRendered:o}),n)}return c(),C.toDisposable(()=>{T.render(f.jsx("div",{}),n),setTimeout(()=>T.render(f.jsx("div",{}),n),200),setTimeout(()=>T.unmount(n),500)})}function tt(e){const t=document.createElement("div");return t.id=e,t}function _4(e){const{menuType:t,onOptionSelect:r}=e,n=O.useDependency(x1);if(!t)return null;const i=s.useMemo(()=>{const a=n.getMenuByPositionKey(t);function o(c){return c.reduce((h,g)=>g.children?[...h,...o(g.children)]:[...h,g],[])}return o(a)},[t]);return f.jsx("div",{className:"univer-box-border univer-grid univer-min-w-8 univer-max-w-52 univer-gap-1 univer-rounded univer-bg-gray-900 univer-px-2 univer-py-1",style:{gridTemplateColumns:`repeat(${Math.min(2,i.length)}, 72px)`},children:i.map(a=>a.item&&f.jsx(y4,{menuItem:a.item,onClick:o=>r==null?void 0:r({value:"",label:a.key,...o})},a.key))})}function y4(e){const{menuItem:t,onClick:r}=e,{id:n,type:i,title:a,label:o,icon:c}=t;if(i!==g1.BUTTON)throw new Error(`[MobileMenuItem]: on mobile devices only "BUTTON" type menu items are supported. Please check "${n}".`);const h=O.useObservable(t.disabled$,!1),g=O.useObservable(t.value$);return f.jsx("button",{type:"button",className:T.clsx("univer-w-18 univer-flex univer-flex-col univer-items-center univer-justify-center univer-border-none univer-bg-transparent univer-text-white [&>span]:univer-mt-0.5 [&>span]:univer-w-full [&>span]:univer-truncate [&>span]:univer-text-sm [&>svg]:univer-size-[18px] [&>svg]:univer-text-lg"),disabled:h,onClick:()=>r({id:n}),children:f.jsx(h1,{value:g,title:a,label:o,icon:c})},n)}function Q6(){const[e,t]=s.useState(!1),[r,n]=s.useState(""),[i,a]=s.useState([0,0]),o=s.useRef(e),c=O.useDependency(oe),h=O.useDependency(C.ICommandService);o.current=e,s.useEffect(()=>{const d=c.registerContextMenuHandler({handleContextMenu:g,hideContextMenu(){t(!1)},get visible(){return o.current}});return document.addEventListener("pointerdown",p),document.addEventListener("wheel",p),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("wheel",p),d.dispose()}},[c]);function g(d,L){n(L),a([d.clientX,d.clientY]),t(!0)}function p(){t(!1)}return f.jsx(T.Popup,{visible:e,offset:i,children:f.jsx("section",{onPointerDown:d=>d.stopPropagation(),children:r&&f.jsx(_4,{menuType:r,onOptionSelect:d=>{const{label:L,value:_,commandId:M}=d;h&&h.executeCommand(M!=null?M:L,{value:_}),t(!1)}})})})}function M4(e){const{header:t=!0,footer:r=!0,contextMenu:n=!0,mountContainer:i,onRendered:a}=e,o=O.useDependency(C.LocaleService),c=O.useDependency(C.ThemeService),h=O.useDependency(ie),g=s.useRef(null),p=C1(i1.FOOTER),d=C1(i1.HEADER),L=C1(i1.CONTENT),_=C1(i1.LEFT_SIDEBAR),M=C1(i1.GLOBAL),[V,H]=s.useState(!1);s.useEffect(()=>{const $=c.darkMode$.subscribe(y=>{H(y)});return()=>{$.unsubscribe()}},[]),s.useEffect(()=>{g.current&&(a==null||a(g.current))},[a]);const[x,E]=s.useState(o.getLocales()),R=s.useMemo(()=>document.createElement("div"),[]);return s.useLayoutEffect(()=>{const $=c.currentTheme$.subscribe(y=>{h.injectThemeToHead(y)});return()=>{$.unsubscribe()}},[]),s.useEffect(()=>{document.body.appendChild(R);const $=[o.localeChanged$.subscribe(()=>{E(o.getLocales())})];return()=>{$.forEach(y=>y.unsubscribe()),document.body.removeChild(R)}},[o,i,R]),f.jsxs(T.ConfigProvider,{locale:x==null?void 0:x.design,mountContainer:R,children:[f.jsxs("div",{"data-u-comp":"app-layout",className:T.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":V}),tabIndex:-1,onBlur:$=>$.stopPropagation(),children:[t&&f.jsx("header",{className:"univer-relative univer-z-10 univer-w-full"}),f.jsxs("section",{className:"univer-relative univer-flex univer-min-h-0 univer-flex-1 univer-flex-col",children:[f.jsxs("div",{className:"univer-grid univer-h-full univer-grid-cols-[auto_1fr_auto] univer-grid-rows-[100%] univer-overflow-hidden",children:[f.jsx("aside",{className:"univer-h-full",children:f.jsx(v1,{components:_},"left-sidebar")}),f.jsxs("section",{className:T.clsx("univer-relative univer-grid univer-flex-1 univer-grid-rows-[auto_1fr] univer-overflow-hidden univer-bg-white",T.borderBottomClassName),children:[f.jsx("header",{className:"univer-w-screen",children:t&&f.jsx(v1,{components:d},"header")}),f.jsx("section",{ref:g,className:"univer-relative univer-overflow-hidden","data-range-selector":!0,onContextMenu:$=>$.preventDefault(),children:f.jsx(v1,{components:L},"content")})]}),f.jsx("aside",{className:"univer-h-full",children:f.jsx(C3,{})})]}),r&&f.jsx("footer",{children:f.jsx(v1,{components:p},"footer")}),f.jsx(h3,{}),f.jsx(v3,{})]})]}),f.jsx(v1,{components:M},"global"),n&&f.jsx(Q6,{})]})}var x4=Object.getOwnPropertyDescriptor,S4=(e,t,r,n)=>{for(var i=n>1?void 0:n?x4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},$1=(e,t)=>(r,n)=>t(r,n,e);let ze=class extends g3{constructor(e,t,r,n,i,a,o){super(t,a,i,r,n),this._config=e,this._initBuiltinComponents(o),this._bootstrapWorkbench()}bootstrap(e){return I4(this._injector,this._config,e)}_initBuiltinComponents(e){this.disposeWithMe(e.registerComponent(i1.CONTENT,()=>O.connectInjector(u3,this._injector))),this.disposeWithMe(e.registerComponent(i1.CONTENT,()=>O.connectInjector(l3,this._injector)))}};ze=S4([$1(1,C.Inject(C.Injector)),$1(2,C.Inject(C.LifecycleService)),$1(3,te.IRenderManagerService),$1(4,S1),$1(5,C.IUniverInstanceService),$1(6,y1)],ze);function I4(e,t,r){let n;const i=t.container;if(typeof i=="string"){const h=document.getElementById(i);h?n=h:n=rt(i)}else i instanceof HTMLElement?n=i:n=rt("univer");const a=O.connectInjector(M4,e),o=h=>r(h,n);function c(){T.render(f.jsx(a,{...t,mountContainer:n,onRendered:o}),n)}return c(),C.toDisposable(()=>{T.unmount(n)})}function rt(e){const t=document.createElement("div");return t.id=e,t}const ae=C.createIdentifier("ui.notification.service");var H4=Object.getOwnPropertyDescriptor,R4=(e,t,r,n)=>{for(var i=n>1?void 0:n?H4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},E4=(e,t)=>(r,n)=>t(r,n,e);const m3=C.createIdentifier("univer.ui.before-close-service");exports.DesktopBeforeCloseService=class{constructor(t){U(this,"_beforeUnloadCallbacks",[]);U(this,"_onCloseCallbacks",[]);this._notificationService=t,this._init()}registerBeforeClose(t){return this._beforeUnloadCallbacks.push(t),{dispose:()=>{this._beforeUnloadCallbacks=this._beforeUnloadCallbacks.filter(r=>r!==t)}}}registerOnClose(t){return this._onCloseCallbacks.push(t),{dispose:()=>{this._onCloseCallbacks=this._onCloseCallbacks.filter(r=>r!==t)}}}_init(){window.addEventListener("beforeunload",t=>{let r=t;const n=this._beforeUnloadCallbacks.map(i=>i()).filter(i=>!!i).join(`
12
12
  `);if(n)return this._notificationService.show({type:"error",title:"Some changes are not saved",content:n}),typeof r>"u"&&(r=window.event),r.returnValue=n,n}),window.addEventListener("unload",()=>{this._onCloseCallbacks.forEach(t=>t())})}};exports.DesktopBeforeCloseService=R4([E4(0,ae)],exports.DesktopBeforeCloseService);function K6(){return typeof navigator.clipboard<"u"&&typeof navigator.clipboard.readText<"u"}var D4=Object.getOwnPropertyDescriptor,O4=(e,t,r,n)=>{for(var i=n>1?void 0:n?D4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Be=(e,t)=>(r,n)=>t(r,n,e);const Ge="text/plain",We="text/html",er="image/png",tr="image/jpeg",rr="image/bmp",nr="image/webp",V4="image/svg+xml",N4=new Set([rr,tr,nr,er]),p3=C.createIdentifier("univer.clipboard-interface-service");exports.BrowserClipboardService=class extends C.Disposable{constructor(t,r,n){super(),this._localeService=t,this._logService=r,this._notificationService=n}get supportClipboard(){return K6()}async write(t,r){if(!this.supportClipboard)return this._legacyCopyHtml(r);try{return await navigator.clipboard.write([new ClipboardItem({[Ge]:new Blob([t],{type:Ge}),[We]:new Blob([r],{type:We})})])}catch(n){this._logService.error("[BrowserClipboardService]",n),this._showClipboardAuthenticationNotification()}}async writeText(t){if(!this.supportClipboard)return this._legacyCopyText(t);try{return await navigator.clipboard.writeText(t)}catch(r){this._logService.error("[BrowserClipboardService]",r),this._showClipboardAuthenticationNotification()}}async read(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return navigator.clipboard.read()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),[]}}async readText(){if(!this.supportClipboard)throw new Error("[BrowserClipboardService] read() is not supported on this platform.");try{return await navigator.clipboard.readText()}catch(t){return this._logService.error("[BrowserClipboardService]",t),this._showClipboardAuthenticationNotification(),""}}_legacyCopyHtml(t){const r=document.activeElement,n=Z4();document.body.appendChild(n),n.innerHTML=t;try{nt(n),document.execCommand("copy")}finally{r instanceof HTMLElement&&r.focus(),document.body.removeChild(n)}}_legacyCopyText(t){const r=document.activeElement,n=T4();document.body.appendChild(n),n.value=t;try{nt(n),document.execCommand("copy")}finally{r instanceof HTMLElement&&r.focus(),document.body.removeChild(n)}}_showClipboardAuthenticationNotification(){var t;(t=this._notificationService)==null||t.show({type:"warning",title:this._localeService.t("clipboard.authentication.title"),content:this._localeService.t("clipboard.authentication.content")})}};exports.BrowserClipboardService=O4([Be(0,C.Inject(C.LocaleService)),Be(1,C.ILogService),Be(2,C.Optional(ae))],exports.BrowserClipboardService);function T4(){const 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 Z4(){const 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 nt(e){if(e instanceof HTMLTextAreaElement){const n=e.hasAttribute("readonly");return n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),e.value}e.hasAttribute("contenteditable")&&e.focus();const t=document.createRange();t.selectNodeContents(e);const r=window.getSelection();if(!r)throw new Error;return r.removeAllRanges(),r.addRange(t),r.toString()}const Se=C.createIdentifier("univer.confirm-service");class j4{constructor(){U(this,"confirmOptions$",new F.Subject)}dispose(){this.confirmOptions$.complete()}open(t){throw new Error("This is not implemented in the test service!")}confirm(t){return Promise.resolve(!0)}close(t){throw new Error("This is not implemented in the test service!")}}const k4=e=>{const{children:t,onClose:r,onConfirm:n}=e,[i]=s.useState({}),a=t?s.cloneElement(t,{hooks:i}):null;return f.jsx(T.Confirm,{...e,children:a,onClose:()=>{const o=i.beforeClose;if(o){const c=o();if(c.cancel)return;r==null||r(c);return}r==null||r()},onConfirm:()=>{const o=i.beforeConfirm;if(o){const c=o();if(c.cancel)return;n==null||n(c);return}n==null||n()}})};function A4(){const e=O.useDependency(Se),[t,r]=s.useState([]);s.useEffect(()=>{const i=e.confirmOptions$.subscribe(a=>{r(a)});return()=>{i.unsubscribe()}},[]);const n=t.map(i=>{const{children:a,title:o,...c}=i,h=c;for(const g of["children","title"]){const p=g,d=i[p];d&&(h[p]=f.jsx(h1,{...d}))}return h});return n==null?void 0:n.map((i,a)=>f.jsx(k4,{...i,children:i.children},a))}var $4=Object.getOwnPropertyDescriptor,B4=(e,t,r,n)=>{for(var i=n>1?void 0:n?$4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},it=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopConfirmService=class extends C.Disposable{constructor(r,n){super();U(this,"_confirmOptions",[]);U(this,"confirmOptions$",new F.BehaviorSubject([]));this._injector=r,this._uiPartsService=n,this._initUIPart()}open(r){return this._confirmOptions.find(n=>n.id===r.id)?this._confirmOptions=this._confirmOptions.map(n=>({...n.id===r.id?r:n,visible:n.id===r.id?!0:n.visible})):this._confirmOptions.push({...r,visible:!0}),this.confirmOptions$.next(this._confirmOptions),C.toDisposable(()=>{this._confirmOptions=[],this.confirmOptions$.next([])})}confirm(r){return new Promise(n=>{const i=this.open({...r,onConfirm:()=>{i.dispose(),n(!0)},onClose:()=>{i.dispose(),n(!1)}})})}close(r){this._confirmOptions=this._confirmOptions.map(n=>({...n,visible:n.id===r?!1:n.visible})),this.confirmOptions$.next([...this._confirmOptions])}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(A4,this._injector)))}};exports.DesktopConfirmService=B4([it(0,C.Inject(C.Injector)),it(1,y1)],exports.DesktopConfirmService);const Ie=C.createIdentifier("univer.ui.dialog-service");function P4(){const e=O.useDependency(Ie),[t,r]=s.useState([]);s.useEffect(()=>{const a=e.getDialogs$().subscribe(o=>{r(o)});return()=>a.unsubscribe()},[]);const n=s.useMemo(()=>t.map(i=>{const{children:a,title:o,footer:c,...h}=i,g=h;for(const p of["children","title","footer"]){const d=p,L=i[d];L&&(g[d]=f.jsx(h1,{...L}))}return g}),[t]);return n==null?void 0:n.map(i=>f.jsx(T.Dialog,{...i},i.id))}var U4=Object.getOwnPropertyDescriptor,F4=(e,t,r,n)=>{for(var i=n>1?void 0:n?U4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},ot=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopDialogService=class extends C.Disposable{constructor(r,n){super();U(this,"_dialogOptions",[]);U(this,"_dialogOptions$",new F.Subject);this._injector=r,this._uiPartsService=n,this._initUIPart()}dispose(){super.dispose(),this._dialogOptions=[],this._dialogOptions$.complete()}open(r){return this._dialogOptions.find(n=>n.id===r.id)?this._dialogOptions=this._dialogOptions.map(n=>({...n.id===r.id?r:n,open:n.id===r.id?!0:n.open})):this._dialogOptions.push({...r,open:!0}),this._dialogOptions$.next(this._dialogOptions),C.toDisposable(()=>{this._dialogOptions=[],this._dialogOptions$.next([])})}close(r){this._dialogOptions=this._dialogOptions.map(n=>({...n,open:n.id===r?!1:n.open})),this._dialogOptions$.next([...this._dialogOptions])}closeAll(r){const n=new Set(r);this._dialogOptions=this._dialogOptions.map(i=>({...i,open:n.has(i.id)?i.open:!1})),this._dialogOptions$.next([...this._dialogOptions])}getDialogs$(){return this._dialogOptions$.asObservable()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(P4,this._injector)))}};exports.DesktopDialogService=F4([ot(0,C.Inject(C.Injector)),ot(1,y1)],exports.DesktopDialogService);const He=C.createIdentifier("univer.ui.gallery-service");function z4(){const e=O.useDependency(He),t=O.useObservable(e.gallery$);return t?f.jsx(T.Gallery,{...t}):null}var G4=Object.getOwnPropertyDescriptor,W4=(e,t,r,n)=>{for(var i=n>1?void 0:n?G4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},at=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopGalleryService=class extends C.Disposable{constructor(r,n){super();U(this,"gallery$",new F.Subject);this._injector=r,this._uiPartsService=n,this._initUIPart()}dispose(){super.dispose()}open(r){return this.gallery$.next({open:!0,...r}),C.toDisposable(()=>{this.gallery$.complete()})}close(){this.gallery$.next({open:!1,images:[]})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(z4,this._injector)))}};exports.DesktopGalleryService=W4([at(0,C.Inject(C.Injector)),at(1,y1)],exports.DesktopGalleryService);var Y4=Object.getOwnPropertyDescriptor,X4=(e,t,r,n)=>{for(var i=n>1?void 0:n?Y4(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},q4=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopGlobalZoneService=class{constructor(t){U(this,"visible$",new F.Subject);U(this,"componentKey$",new F.Subject);U(this,"_componentKey","");this._componentManager=t}get componentKey(){return this._componentKey}set(t,r){return this._componentManager.register(t,r),this.componentKey$.next(t),this._componentKey=t,C.toDisposable(()=>{this._componentManager.delete(t),this.visible$.complete(),this.componentKey$.complete()})}open(){this.visible$.next(!0)}close(){this.visible$.next(!1)}};exports.DesktopGlobalZoneService=X4([q4(0,C.Inject(m1))],exports.DesktopGlobalZoneService);var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function J4(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ce(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Pe={exports:{}};/*!
13
13
  localForage -- Offline Storage, Improved
14
14
  Version 1.10.0
15
15
  https://localforage.github.io/localForage
16
16
  (c) 2013-2017 Mozilla, Apache License 2.0
17
- */var st;function Q4(){return st||(st=1,function(e,t){(function(r){e.exports=r()})(function(){return function r(n,i,a){function o(g,p){if(!i[g]){if(!n[g]){var d=typeof Ce=="function"&&Ce;if(!p&&d)return d(g,!0);if(c)return c(g,!0);var L=new Error("Cannot find module '"+g+"'");throw L.code="MODULE_NOT_FOUND",L}var _=i[g]={exports:{}};n[g][0].call(_.exports,function(M){var V=n[g][1][M];return o(V||M)},_,_.exports,r,n,i,a)}return i[g].exports}for(var c=typeof Ce=="function"&&Ce,h=0;h<a.length;h++)o(a[h]);return o}({1:[function(r,n,i){(function(a){var o=a.MutationObserver||a.WebKitMutationObserver,c;if(o){var h=0,g=new o(M),p=a.document.createTextNode("");g.observe(p,{characterData:!0}),c=function(){p.data=h=++h%2}}else if(!a.setImmediate&&typeof a.MessageChannel<"u"){var d=new a.MessageChannel;d.port1.onmessage=M,c=function(){d.port2.postMessage(0)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?c=function(){var H=a.document.createElement("script");H.onreadystatechange=function(){M(),H.onreadystatechange=null,H.parentNode.removeChild(H),H=null},a.document.documentElement.appendChild(H)}:c=function(){setTimeout(M,0)};var L,_=[];function M(){L=!0;for(var H,x,E=_.length;E;){for(x=_,_=[],H=-1;++H<E;)x[H]();E=_.length}L=!1}n.exports=V;function V(H){_.push(H)===1&&!L&&c()}}).call(this,typeof he<"u"?he:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(r,n,i){var a=r(1);function o(){}var c={},h=["REJECTED"],g=["FULFILLED"],p=["PENDING"];n.exports=d;function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,y!==o&&V(this,y)}d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,N){if(typeof y!="function"&&this.state===g||typeof N!="function"&&this.state===h)return this;var k=new this.constructor(o);if(this.state!==p){var Y=this.state===g?y:N;_(k,Y,this.outcome)}else this.queue.push(new L(k,y,N));return k};function L(y,N,k){this.promise=y,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}L.prototype.callFulfilled=function(y){c.resolve(this.promise,y)},L.prototype.otherCallFulfilled=function(y){_(this.promise,this.onFulfilled,y)},L.prototype.callRejected=function(y){c.reject(this.promise,y)},L.prototype.otherCallRejected=function(y){_(this.promise,this.onRejected,y)};function _(y,N,k){a(function(){var Y;try{Y=N(k)}catch(B){return c.reject(y,B)}Y===y?c.reject(y,new TypeError("Cannot resolve promise with itself")):c.resolve(y,Y)})}c.resolve=function(y,N){var k=H(M,N);if(k.status==="error")return c.reject(y,k.value);var Y=k.value;if(Y)V(y,Y);else{y.state=g,y.outcome=N;for(var B=-1,z=y.queue.length;++B<z;)y.queue[B].callFulfilled(N)}return y},c.reject=function(y,N){y.state=h,y.outcome=N;for(var k=-1,Y=y.queue.length;++k<Y;)y.queue[k].callRejected(N);return y};function M(y){var N=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof N=="function")return function(){N.apply(y,arguments)}}function V(y,N){var k=!1;function Y(q){k||(k=!0,c.reject(y,q))}function B(q){k||(k=!0,c.resolve(y,q))}function z(){N(B,Y)}var X=H(z);X.status==="error"&&Y(X.value)}function H(y,N){var k={};try{k.value=y(N),k.status="success"}catch(Y){k.status="error",k.value=Y}return k}d.resolve=x;function x(y){return y instanceof this?y:c.resolve(new this(o),y)}d.reject=E;function E(y){var N=new this(o);return c.reject(N,y)}d.all=R;function R(y){var N=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,Y=!1;if(!k)return this.resolve([]);for(var B=new Array(k),z=0,X=-1,q=new this(o);++X<k;)Q(y[X],X);return q;function Q(G,W){N.resolve(G).then(K,function(a1){Y||(Y=!0,c.reject(q,a1))});function K(a1){B[W]=a1,++z===k&&!Y&&(Y=!0,c.resolve(q,B))}}}d.race=$;function $(y){var N=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,Y=!1;if(!k)return this.resolve([]);for(var B=-1,z=new this(o);++B<k;)X(y[B]);return z;function X(q){N.resolve(q).then(function(Q){Y||(Y=!0,c.resolve(z,Q))},function(Q){Y||(Y=!0,c.reject(z,Q))})}}},{1:1}],3:[function(r,n,i){(function(a){typeof a.Promise!="function"&&(a.Promise=r(2))}).call(this,typeof he<"u"?he:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(r,n,i){var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l};function o(l,v){if(!(l instanceof v))throw new TypeError("Cannot call a class as a function")}function c(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var h=c();function g(){try{if(!h||!h.open)return!1;var l=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),v=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!l||v)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(l,v){l=l||[],v=v||{};try{return new Blob(l,v)}catch(m){if(m.name!=="TypeError")throw m;for(var u=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,b=new u,w=0;w<l.length;w+=1)b.append(l[w]);return b.getBlob(v.type)}}typeof Promise>"u"&&r(3);var d=Promise;function L(l,v){v&&l.then(function(u){v(null,u)},function(u){v(u)})}function _(l,v,u){typeof v=="function"&&l.then(v),typeof u=="function"&&l.catch(u)}function M(l){return typeof l!="string"&&(console.warn(l+" used as a key, but it is not a string."),l=String(l)),l}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var H="local-forage-detect-blob-support",x=void 0,E={},R=Object.prototype.toString,$="readonly",y="readwrite";function N(l){for(var v=l.length,u=new ArrayBuffer(v),b=new Uint8Array(u),w=0;w<v;w++)b[w]=l.charCodeAt(w);return u}function k(l){return new d(function(v){var u=l.transaction(H,y),b=p([""]);u.objectStore(H).put(b,"key"),u.onabort=function(w){w.preventDefault(),w.stopPropagation(),v(!1)},u.oncomplete=function(){var w=navigator.userAgent.match(/Chrome\/(\d+)/),m=navigator.userAgent.match(/Edge\//);v(m||!w||parseInt(w[1],10)>=43)}}).catch(function(){return!1})}function Y(l){return typeof x=="boolean"?d.resolve(x):k(l).then(function(v){return x=v,x})}function B(l){var v=E[l.name],u={};u.promise=new d(function(b,w){u.resolve=b,u.reject=w}),v.deferredOperations.push(u),v.dbReady?v.dbReady=v.dbReady.then(function(){return u.promise}):v.dbReady=u.promise}function z(l){var v=E[l.name],u=v.deferredOperations.pop();if(u)return u.resolve(),u.promise}function X(l,v){var u=E[l.name],b=u.deferredOperations.pop();if(b)return b.reject(v),b.promise}function q(l,v){return new d(function(u,b){if(E[l.name]=E[l.name]||r1(),l.db)if(v)B(l),l.db.close();else return u(l.db);var w=[l.name];v&&w.push(l.version);var m=h.open.apply(h,w);v&&(m.onupgradeneeded=function(I){var D=m.result;try{D.createObjectStore(l.storeName),I.oldVersion<=1&&D.createObjectStore(H)}catch(Z){if(Z.name==="ConstraintError")console.warn('The database "'+l.name+'" has been upgraded from version '+I.oldVersion+" to version "+I.newVersion+', but the storage "'+l.storeName+'" already exists.');else throw Z}}),m.onerror=function(I){I.preventDefault(),b(m.error)},m.onsuccess=function(){var I=m.result;I.onversionchange=function(D){D.target.close()},u(I),z(l)}})}function Q(l){return q(l,!1)}function G(l){return q(l,!0)}function W(l,v){if(!l.db)return!0;var u=!l.db.objectStoreNames.contains(l.storeName),b=l.version<l.db.version,w=l.version>l.db.version;if(b&&(l.version!==v&&console.warn('The database "'+l.name+`" can't be downgraded from version `+l.db.version+" to version "+l.version+"."),l.version=l.db.version),w||u){if(u){var m=l.db.version+1;m>l.version&&(l.version=m)}return!0}return!1}function K(l){return new d(function(v,u){var b=new FileReader;b.onerror=u,b.onloadend=function(w){var m=btoa(w.target.result||"");v({__local_forage_encoded_blob:!0,data:m,type:l.type})},b.readAsBinaryString(l)})}function a1(l){var v=N(atob(l.data));return p([v],{type:l.type})}function u1(l){return l&&l.__local_forage_encoded_blob}function p1(l){var v=this,u=v._initReady().then(function(){var b=E[v._dbInfo.name];if(b&&b.dbReady)return b.dbReady});return _(u,l,l),u}function L1(l){B(l);for(var v=E[l.name],u=v.forages,b=0;b<u.length;b++){var w=u[b];w._dbInfo.db&&(w._dbInfo.db.close(),w._dbInfo.db=null)}return l.db=null,Q(l).then(function(m){return l.db=m,W(l)?G(l):m}).then(function(m){l.db=v.db=m;for(var I=0;I<u.length;I++)u[I]._dbInfo.db=m}).catch(function(m){throw X(l,m),m})}function o1(l,v,u,b){b===void 0&&(b=1);try{var w=l.db.transaction(l.storeName,v);u(null,w)}catch(m){if(b>0&&(!l.db||m.name==="InvalidStateError"||m.name==="NotFoundError"))return d.resolve().then(function(){if(!l.db||m.name==="NotFoundError"&&!l.db.objectStoreNames.contains(l.storeName)&&l.version<=l.db.version)return l.db&&(l.version=l.db.version+1),G(l)}).then(function(){return L1(l).then(function(){o1(l,v,u,b-1)})}).catch(u);u(m)}}function r1(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function c1(l){var v=this,u={db:null};if(l)for(var b in l)u[b]=l[b];var w=E[u.name];w||(w=r1(),E[u.name]=w),w.forages.push(v),v._initReady||(v._initReady=v.ready,v.ready=p1);var m=[];function I(){return d.resolve()}for(var D=0;D<w.forages.length;D++){var Z=w.forages[D];Z!==v&&m.push(Z._initReady().catch(I))}var j=w.forages.slice(0);return d.all(m).then(function(){return u.db=w.db,Q(u)}).then(function(A){return u.db=A,W(u,v._defaultConfig.version)?G(u):A}).then(function(A){u.db=w.db=A,v._dbInfo=u;for(var P=0;P<j.length;P++){var J=j[P];J!==v&&(J._dbInfo.db=u.db,J._dbInfo.version=u.version)}})}function b1(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.get(l);j.onsuccess=function(){var A=j.result;A===void 0&&(A=null),u1(A)&&(A=a1(A)),w(A)},j.onerror=function(){m(j.error)}}catch(A){m(A)}})}).catch(m)});return L(b,v),b}function M1(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.openCursor(),A=1;j.onsuccess=function(){var P=j.result;if(P){var J=P.value;u1(J)&&(J=a1(J));var e1=l(J,P.key,A++);e1!==void 0?w(e1):P.continue()}else w()},j.onerror=function(){m(j.error)}}catch(P){m(P)}})}).catch(m)});return L(b,v),b}function V1(l,v,u){var b=this;l=M(l);var w=new d(function(m,I){var D;b.ready().then(function(){return D=b._dbInfo,R.call(v)==="[object Blob]"?Y(D.db).then(function(Z){return Z?v:K(v)}):v}).then(function(Z){o1(b._dbInfo,y,function(j,A){if(j)return I(j);try{var P=A.objectStore(b._dbInfo.storeName);Z===null&&(Z=void 0);var J=P.put(Z,l);A.oncomplete=function(){Z===void 0&&(Z=null),m(Z)},A.onabort=A.onerror=function(){var e1=J.error?J.error:J.transaction.error;I(e1)}}catch(e1){I(e1)}})}).catch(I)});return L(w,u),w}function Z1(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,y,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.delete(l);D.oncomplete=function(){w()},D.onerror=function(){m(j.error)},D.onabort=function(){var A=j.error?j.error:j.transaction.error;m(A)}}catch(A){m(A)}})}).catch(m)});return L(b,v),b}function j1(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,y,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.clear();I.oncomplete=function(){b()},I.onabort=I.onerror=function(){var j=Z.error?Z.error:Z.transaction.error;w(j)}}catch(j){w(j)}})}).catch(w)});return L(u,l),u}function dr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,$,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.count();Z.onsuccess=function(){b(Z.result)},Z.onerror=function(){w(Z.error)}}catch(j){w(j)}})}).catch(w)});return L(u,l),u}function fr(l,v){var u=this,b=new d(function(w,m){if(l<0){w(null);return}u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=!1,A=Z.openKeyCursor();A.onsuccess=function(){var P=A.result;if(!P){w(null);return}l===0||j?w(P.key):(j=!0,P.advance(l))},A.onerror=function(){m(A.error)}}catch(P){m(P)}})}).catch(m)});return L(b,v),b}function hr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,$,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.openKeyCursor(),j=[];Z.onsuccess=function(){var A=Z.result;if(!A){b(j);return}j.push(A.key),A.continue()},Z.onerror=function(){w(Z.error)}}catch(A){w(A)}})}).catch(w)});return L(u,l),u}function Cr(l,v){v=V.apply(this,arguments);var u=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||u.name,l.storeName=l.storeName||u.storeName);var b=this,w;if(!l.name)w=d.reject("Invalid arguments");else{var m=l.name===u.name&&b._dbInfo.db,I=m?d.resolve(b._dbInfo.db):Q(l).then(function(D){var Z=E[l.name],j=Z.forages;Z.db=D;for(var A=0;A<j.length;A++)j[A]._dbInfo.db=D;return D});l.storeName?w=I.then(function(D){if(D.objectStoreNames.contains(l.storeName)){var Z=D.version+1;B(l);var j=E[l.name],A=j.forages;D.close();for(var P=0;P<A.length;P++){var J=A[P];J._dbInfo.db=null,J._dbInfo.version=Z}var e1=new d(function(t1,l1){var s1=h.open(l.name,Z);s1.onerror=function(w1){var z1=s1.result;z1.close(),l1(w1)},s1.onupgradeneeded=function(){var w1=s1.result;w1.deleteObjectStore(l.storeName)},s1.onsuccess=function(){var w1=s1.result;w1.close(),t1(w1)}});return e1.then(function(t1){j.db=t1;for(var l1=0;l1<A.length;l1++){var s1=A[l1];s1._dbInfo.db=t1,z(s1._dbInfo)}}).catch(function(t1){throw(X(l,t1)||d.resolve()).catch(function(){}),t1})}}):w=I.then(function(D){B(l);var Z=E[l.name],j=Z.forages;D.close();for(var A=0;A<j.length;A++){var P=j[A];P._dbInfo.db=null}var J=new d(function(e1,t1){var l1=h.deleteDatabase(l.name);l1.onerror=function(){var s1=l1.result;s1&&s1.close(),t1(l1.error)},l1.onblocked=function(){console.warn('dropInstance blocked for database "'+l.name+'" until all open connections are closed')},l1.onsuccess=function(){var s1=l1.result;s1&&s1.close(),e1(s1)}});return J.then(function(e1){Z.db=e1;for(var t1=0;t1<j.length;t1++){var l1=j[t1];z(l1._dbInfo)}}).catch(function(e1){throw(X(l,e1)||d.resolve()).catch(function(){}),e1})})}return L(w,v),w}var vr={_driver:"asyncStorage",_initStorage:c1,_support:g(),iterate:M1,getItem:b1,setItem:V1,removeItem:Z1,clear:j1,length:dr,key:fr,keys:hr,dropInstance:Cr};function gr(){return typeof openDatabase=="function"}var I1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mr="~~local_forage_type~",_3=/^~~local_forage_type~([^~]+)~/,se="__lfsc__:",Ee=se.length,De="arbf",Oe="blob",y3="si08",M3="ui08",x3="uic8",S3="si16",I3="si32",H3="ur16",R3="ui32",E3="fl32",D3="fl64",O3=Ee+De.length,V3=Object.prototype.toString;function N3(l){var v=l.length*.75,u=l.length,b,w=0,m,I,D,Z;l[l.length-1]==="="&&(v--,l[l.length-2]==="="&&v--);var j=new ArrayBuffer(v),A=new Uint8Array(j);for(b=0;b<u;b+=4)m=I1.indexOf(l[b]),I=I1.indexOf(l[b+1]),D=I1.indexOf(l[b+2]),Z=I1.indexOf(l[b+3]),A[w++]=m<<2|I>>4,A[w++]=(I&15)<<4|D>>2,A[w++]=(D&3)<<6|Z&63;return j}function Ve(l){var v=new Uint8Array(l),u="",b;for(b=0;b<v.length;b+=3)u+=I1[v[b]>>2],u+=I1[(v[b]&3)<<4|v[b+1]>>4],u+=I1[(v[b+1]&15)<<2|v[b+2]>>6],u+=I1[v[b+2]&63];return v.length%3===2?u=u.substring(0,u.length-1)+"=":v.length%3===1&&(u=u.substring(0,u.length-2)+"=="),u}function pr(l,v){var u="";if(l&&(u=V3.call(l)),l&&(u==="[object ArrayBuffer]"||l.buffer&&V3.call(l.buffer)==="[object ArrayBuffer]")){var b,w=se;l instanceof ArrayBuffer?(b=l,w+=De):(b=l.buffer,u==="[object Int8Array]"?w+=y3:u==="[object Uint8Array]"?w+=M3:u==="[object Uint8ClampedArray]"?w+=x3:u==="[object Int16Array]"?w+=S3:u==="[object Uint16Array]"?w+=H3:u==="[object Int32Array]"?w+=I3:u==="[object Uint32Array]"?w+=R3:u==="[object Float32Array]"?w+=E3:u==="[object Float64Array]"?w+=D3:v(new Error("Failed to get type for BinaryArray"))),v(w+Ve(b))}else if(u==="[object Blob]"){var m=new FileReader;m.onload=function(){var I=mr+l.type+"~"+Ve(this.result);v(se+Oe+I)},m.readAsArrayBuffer(l)}else try{v(JSON.stringify(l))}catch(I){console.error("Couldn't convert value into a JSON string: ",l),v(null,I)}}function br(l){if(l.substring(0,Ee)!==se)return JSON.parse(l);var v=l.substring(O3),u=l.substring(Ee,O3),b;if(u===Oe&&_3.test(v)){var w=v.match(_3);b=w[1],v=v.substring(w[0].length)}var m=N3(v);switch(u){case De:return m;case Oe:return p([m],{type:b});case y3:return new Int8Array(m);case M3:return new Uint8Array(m);case x3:return new Uint8ClampedArray(m);case S3:return new Int16Array(m);case H3:return new Uint16Array(m);case I3:return new Int32Array(m);case R3:return new Uint32Array(m);case E3:return new Float32Array(m);case D3:return new Float64Array(m);default:throw new Error("Unkown type: "+u)}}var Ne={serialize:pr,deserialize:br,stringToBuffer:N3,bufferToString:Ve};function T3(l,v,u,b){l.executeSql("CREATE TABLE IF NOT EXISTS "+v.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],u,b)}function Lr(l){var v=this,u={db:null};if(l)for(var b in l)u[b]=typeof l[b]!="string"?l[b].toString():l[b];var w=new d(function(m,I){try{u.db=openDatabase(u.name,String(u.version),u.description,u.size)}catch(D){return I(D)}u.db.transaction(function(D){T3(D,u,function(){v._dbInfo=u,m()},function(Z,j){I(j)})},I)});return u.serializer=Ne,w}function H1(l,v,u,b,w,m){l.executeSql(u,b,w,function(I,D){D.code===D.SYNTAX_ERR?I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[v.storeName],function(Z,j){j.rows.length?m(Z,D):T3(Z,v,function(){Z.executeSql(u,b,w,m)},m)},m):m(I,D)},m)}function wr(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT * FROM "+I.storeName+" WHERE key = ? LIMIT 1",[l],function(Z,j){var A=j.rows.length?j.rows.item(0).value:null;A&&(A=I.serializer.deserialize(A)),w(A)},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function _r(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT * FROM "+I.storeName,[],function(Z,j){for(var A=j.rows,P=A.length,J=0;J<P;J++){var e1=A.item(J),t1=e1.value;if(t1&&(t1=I.serializer.deserialize(t1)),t1=l(t1,e1.key,J+1),t1!==void 0){w(t1);return}}w()},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function Z3(l,v,u,b){var w=this;l=M(l);var m=new d(function(I,D){w.ready().then(function(){v===void 0&&(v=null);var Z=v,j=w._dbInfo;j.serializer.serialize(v,function(A,P){P?D(P):j.db.transaction(function(J){H1(J,j,"INSERT OR REPLACE INTO "+j.storeName+" (key, value) VALUES (?, ?)",[l,A],function(){I(Z)},function(e1,t1){D(t1)})},function(J){if(J.code===J.QUOTA_ERR){if(b>0){I(Z3.apply(w,[l,Z,u,b-1]));return}D(J)}})})}).catch(D)});return L(m,u),m}function yr(l,v,u){return Z3.apply(this,[l,v,u,1])}function Mr(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"DELETE FROM "+I.storeName+" WHERE key = ?",[l],function(){w()},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function xr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"DELETE FROM "+m.storeName,[],function(){b()},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Sr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"SELECT COUNT(key) as c FROM "+m.storeName,[],function(D,Z){var j=Z.rows.item(0).c;b(j)},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Ir(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT key FROM "+I.storeName+" WHERE id = ? LIMIT 1",[l+1],function(Z,j){var A=j.rows.length?j.rows.item(0).key:null;w(A)},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function Hr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"SELECT key FROM "+m.storeName,[],function(D,Z){for(var j=[],A=0;A<Z.rows.length;A++)j.push(Z.rows.item(A).key);b(j)},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Rr(l){return new d(function(v,u){l.transaction(function(b){b.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(w,m){for(var I=[],D=0;D<m.rows.length;D++)I.push(m.rows.item(D).name);v({db:l,storeNames:I})},function(w,m){u(m)})},function(b){u(b)})})}function Er(l,v){v=V.apply(this,arguments);var u=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||u.name,l.storeName=l.storeName||u.storeName);var b=this,w;return l.name?w=new d(function(m){var I;l.name===u.name?I=b._dbInfo.db:I=openDatabase(l.name,"","",0),l.storeName?m({db:I,storeNames:[l.storeName]}):m(Rr(I))}).then(function(m){return new d(function(I,D){m.db.transaction(function(Z){function j(e1){return new d(function(t1,l1){Z.executeSql("DROP TABLE IF EXISTS "+e1,[],function(){t1()},function(s1,w1){l1(w1)})})}for(var A=[],P=0,J=m.storeNames.length;P<J;P++)A.push(j(m.storeNames[P]));d.all(A).then(function(){I()}).catch(function(e1){D(e1)})},function(Z){D(Z)})})}):w=d.reject("Invalid arguments"),L(w,v),w}var Dr={_driver:"webSQLStorage",_initStorage:Lr,_support:gr(),iterate:_r,getItem:wr,setItem:yr,removeItem:Mr,clear:xr,length:Sr,key:Ir,keys:Hr,dropInstance:Er};function Or(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function j3(l,v){var u=l.name+"/";return l.storeName!==v.storeName&&(u+=l.storeName+"/"),u}function Vr(){var l="_localforage_support_test";try{return localStorage.setItem(l,!0),localStorage.removeItem(l),!1}catch{return!0}}function Nr(){return!Vr()||localStorage.length>0}function Tr(l){var v=this,u={};if(l)for(var b in l)u[b]=l[b];return u.keyPrefix=j3(l,v._defaultConfig),Nr()?(v._dbInfo=u,u.serializer=Ne,d.resolve()):d.reject()}function Zr(l){var v=this,u=v.ready().then(function(){for(var b=v._dbInfo.keyPrefix,w=localStorage.length-1;w>=0;w--){var m=localStorage.key(w);m.indexOf(b)===0&&localStorage.removeItem(m)}});return L(u,l),u}function jr(l,v){var u=this;l=M(l);var b=u.ready().then(function(){var w=u._dbInfo,m=localStorage.getItem(w.keyPrefix+l);return m&&(m=w.serializer.deserialize(m)),m});return L(b,v),b}function kr(l,v){var u=this,b=u.ready().then(function(){for(var w=u._dbInfo,m=w.keyPrefix,I=m.length,D=localStorage.length,Z=1,j=0;j<D;j++){var A=localStorage.key(j);if(A.indexOf(m)===0){var P=localStorage.getItem(A);if(P&&(P=w.serializer.deserialize(P)),P=l(P,A.substring(I),Z++),P!==void 0)return P}}});return L(b,v),b}function Ar(l,v){var u=this,b=u.ready().then(function(){var w=u._dbInfo,m;try{m=localStorage.key(l)}catch{m=null}return m&&(m=m.substring(w.keyPrefix.length)),m});return L(b,v),b}function $r(l){var v=this,u=v.ready().then(function(){for(var b=v._dbInfo,w=localStorage.length,m=[],I=0;I<w;I++){var D=localStorage.key(I);D.indexOf(b.keyPrefix)===0&&m.push(D.substring(b.keyPrefix.length))}return m});return L(u,l),u}function Br(l){var v=this,u=v.keys().then(function(b){return b.length});return L(u,l),u}function Pr(l,v){var u=this;l=M(l);var b=u.ready().then(function(){var w=u._dbInfo;localStorage.removeItem(w.keyPrefix+l)});return L(b,v),b}function Ur(l,v,u){var b=this;l=M(l);var w=b.ready().then(function(){v===void 0&&(v=null);var m=v;return new d(function(I,D){var Z=b._dbInfo;Z.serializer.serialize(v,function(j,A){if(A)D(A);else try{localStorage.setItem(Z.keyPrefix+l,j),I(m)}catch(P){(P.name==="QuotaExceededError"||P.name==="NS_ERROR_DOM_QUOTA_REACHED")&&D(P),D(P)}})})});return L(w,u),w}function Fr(l,v){if(v=V.apply(this,arguments),l=typeof l!="function"&&l||{},!l.name){var u=this.config();l.name=l.name||u.name,l.storeName=l.storeName||u.storeName}var b=this,w;return l.name?w=new d(function(m){l.storeName?m(j3(l,b._defaultConfig)):m(l.name+"/")}).then(function(m){for(var I=localStorage.length-1;I>=0;I--){var D=localStorage.key(I);D.indexOf(m)===0&&localStorage.removeItem(D)}}):w=d.reject("Invalid arguments"),L(w,v),w}var zr={_driver:"localStorageWrapper",_initStorage:Tr,_support:Or(),iterate:kr,getItem:jr,setItem:Ur,removeItem:Pr,clear:Zr,length:Br,key:Ar,keys:$r,dropInstance:Fr},Gr=function(v,u){return v===u||typeof v=="number"&&typeof u=="number"&&isNaN(v)&&isNaN(u)},Wr=function(v,u){for(var b=v.length,w=0;w<b;){if(Gr(v[w],u))return!0;w++}return!1},k3=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"},F1={},A3={},k1={INDEXEDDB:vr,WEBSQL:Dr,LOCALSTORAGE:zr},Yr=[k1.INDEXEDDB._driver,k1.WEBSQL._driver,k1.LOCALSTORAGE._driver],le=["dropInstance"],Te=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),Xr={description:"",driver:Yr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function qr(l,v){l[v]=function(){var u=arguments;return l.ready().then(function(){return l[v].apply(l,u)})}}function Ze(){for(var l=1;l<arguments.length;l++){var v=arguments[l];if(v)for(var u in v)v.hasOwnProperty(u)&&(k3(v[u])?arguments[0][u]=v[u].slice():arguments[0][u]=v[u])}return arguments[0]}var Jr=function(){function l(v){o(this,l);for(var u in k1)if(k1.hasOwnProperty(u)){var b=k1[u],w=b._driver;this[u]=w,F1[w]||this.defineDriver(b)}this._defaultConfig=Ze({},Xr),this._config=Ze({},this._defaultConfig,v),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return l.prototype.config=function(u){if((typeof u>"u"?"undefined":a(u))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in u){if(b==="storeName"&&(u[b]=u[b].replace(/\W/g,"_")),b==="version"&&typeof u[b]!="number")return new Error("Database version must be a number.");this._config[b]=u[b]}return"driver"in u&&u.driver?this.setDriver(this._config.driver):!0}else return typeof u=="string"?this._config[u]:this._config},l.prototype.defineDriver=function(u,b,w){var m=new d(function(I,D){try{var Z=u._driver,j=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!u._driver){D(j);return}for(var A=Te.concat("_initStorage"),P=0,J=A.length;P<J;P++){var e1=A[P],t1=!Wr(le,e1);if((t1||u[e1])&&typeof u[e1]!="function"){D(j);return}}var l1=function(){for(var z1=function(en){return function(){var tn=new Error("Method "+en+" is not implemented by the current driver"),$3=d.reject(tn);return L($3,arguments[arguments.length-1]),$3}},je=0,Kr=le.length;je<Kr;je++){var ke=le[je];u[ke]||(u[ke]=z1(ke))}};l1();var s1=function(z1){F1[Z]&&console.info("Redefining LocalForage driver: "+Z),F1[Z]=u,A3[Z]=z1,I()};"_support"in u?u._support&&typeof u._support=="function"?u._support().then(s1,D):s1(!!u._support):s1(!0)}catch(w1){D(w1)}});return _(m,b,w),m},l.prototype.driver=function(){return this._driver||null},l.prototype.getDriver=function(u,b,w){var m=F1[u]?d.resolve(F1[u]):d.reject(new Error("Driver not found."));return _(m,b,w),m},l.prototype.getSerializer=function(u){var b=d.resolve(Ne);return _(b,u),b},l.prototype.ready=function(u){var b=this,w=b._driverSet.then(function(){return b._ready===null&&(b._ready=b._initDriver()),b._ready});return _(w,u,u),w},l.prototype.setDriver=function(u,b,w){var m=this;k3(u)||(u=[u]);var I=this._getSupportedDrivers(u);function D(){m._config.driver=m.driver()}function Z(P){return m._extend(P),D(),m._ready=m._initStorage(m._config),m._ready}function j(P){return function(){var J=0;function e1(){for(;J<P.length;){var t1=P[J];return J++,m._dbInfo=null,m._ready=null,m.getDriver(t1).then(Z).catch(e1)}D();var l1=new Error("No available storage method found.");return m._driverSet=d.reject(l1),m._driverSet}return e1()}}var A=this._driverSet!==null?this._driverSet.catch(function(){return d.resolve()}):d.resolve();return this._driverSet=A.then(function(){var P=I[0];return m._dbInfo=null,m._ready=null,m.getDriver(P).then(function(J){m._driver=J._driver,D(),m._wrapLibraryMethodsWithReady(),m._initDriver=j(I)})}).catch(function(){D();var P=new Error("No available storage method found.");return m._driverSet=d.reject(P),m._driverSet}),_(this._driverSet,b,w),this._driverSet},l.prototype.supports=function(u){return!!A3[u]},l.prototype._extend=function(u){Ze(this,u)},l.prototype._getSupportedDrivers=function(u){for(var b=[],w=0,m=u.length;w<m;w++){var I=u[w];this.supports(I)&&b.push(I)}return b},l.prototype._wrapLibraryMethodsWithReady=function(){for(var u=0,b=Te.length;u<b;u++)qr(this,Te[u])},l.prototype.createInstance=function(u){return new l(u)},l}(),Qr=new Jr;n.exports=Qr},{3:3}]},{},[4])(4)})}(Pe)),Pe.exports}var K4=Q4();const N1=J4(K4);class b3{getItem(t){return N1.getItem(t)}setItem(t,r){return N1.setItem(t,r)}removeItem(t){return N1.removeItem(t)}clear(){return N1.clear()}key(t){return N1.key(t)}keys(){return N1.keys()}iterate(t){return N1.iterate(t)}}var e5=Object.getOwnPropertyDescriptor,t5=(e,t,r,n)=>{for(var i=n>1?void 0:n?e5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},lt=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopMessageService=class extends C.Disposable{constructor(t,r){super(),this._injector=t,this._uiPartsService=r,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(T.Messager,this._injector)))}dispose(){T.removeMessage()}show(t){let r=t;return typeof t.id>"u"&&(r=Object.assign({},t,{id:`message-${Date.now()}`})),T.message(r),C.toDisposable(()=>T.removeMessage(r.id))}remove(t){T.removeMessage(t)}removeAll(){T.removeMessage()}};exports.DesktopMessageService=t5([lt(0,C.Inject(C.Injector)),lt(1,y1)],exports.DesktopMessageService);function r5(){const e=O.useDependency(C.ThemeService),t=O.useObservable(e.darkMode$);return f.jsx(T.Toaster,{theme:t?"dark":"light"})}const n5={show:e=>{const{type:t="message",title:r,content:n,duration:i,closable:a=!0,position:o="top-right"}=e;T.toast[t](r,{position:o,description:n,duration:i,closeButton:a})}};var i5=Object.getOwnPropertyDescriptor,o5=(e,t,r,n)=>{for(var i=n>1?void 0:n?i5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},ct=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopNotificationService=class extends C.Disposable{constructor(t,r){super(),this._injector=t,this._uiPartsService=r,this._initUIPart()}show(t){return n5.show(t),C.toDisposable(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(r5,this._injector)))}};exports.DesktopNotificationService=o5([ct(0,C.Inject(C.Injector)),ct(1,y1)],exports.DesktopNotificationService);class L3{constructor(){U(this,"_sidebarOptions",{});U(this,"sidebarOptions$",new F.Subject);U(this,"scrollEvent$",new F.Subject);U(this,"_container")}get visible(){return this._sidebarOptions.visible||!1}get options(){return this._sidebarOptions}open(t){return this._sidebarOptions={...t,id:t.id,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),C.toDisposable(()=>{this.close()})}close(t){t&&this._sidebarOptions.id!==t||(this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),this._sidebarOptions.onClose&&this._sidebarOptions.onClose())}getContainer(){return this._container}setContainer(t){this._container=t}}var a5=Object.getOwnPropertyDescriptor,s5=(e,t,r,n)=>{for(var i=n>1?void 0:n?a5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},l5=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopZenZoneService=class{constructor(t){U(this,"visible$",new F.BehaviorSubject(!1));U(this,"componentKey$",new F.ReplaySubject);U(this,"_temporaryHidden$",new F.BehaviorSubject(!1));U(this,"temporaryHidden$",this._temporaryHidden$.asObservable());U(this,"_visible",!1);this._componentManager=t}get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}dispose(){this.visible$.next(!1),this.visible$.complete(),this.componentKey$.complete()}hide(){this._temporaryHidden$.next(!0)}show(){this._temporaryHidden$.next(!1)}set(t,r){return this._componentManager.register(t,r),this.componentKey$.next(t),C.toDisposable(()=>{this._componentManager.delete(t),this.visible$.complete(),this.componentKey$.complete()})}open(){this._visible=!0,this.visible$.next(!0)}close(){this._visible=!1,this.visible$.next(!1)}};exports.DesktopZenZoneService=s5([l5(0,C.Inject(m1))],exports.DesktopZenZoneService);var c5=Object.defineProperty,u5=Object.getOwnPropertyDescriptor,d5=(e,t,r)=>t in e?c5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f5=(e,t,r,n)=>{for(var i=n>1?void 0:n?u5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},h5=(e,t)=>(r,n)=>t(r,n,e),C5=(e,t,r)=>d5(e,t+"",r);const v5="UNIVER_MOBILE_UI_PLUGIN";exports.UniverMobileUIPlugin=class extends C.Plugin{constructor(t,r){super(),this._config=t,this._injector=r}onStarting(){C.mergeOverrideWithDependencies([[m1],[Q1],[Le],[y1,{useClass:s3}],[S1,{useClass:exports.DesktopLayoutService}],[ie],[U1,{useClass:exports.ShortcutService}],[we,{useClass:a3}],[x1,{useClass:exports.MenuManagerService}],[oe,{useClass:f3}],[p3,{useClass:exports.BrowserClipboardService,lazy:!0}],[ae,{useClass:exports.DesktopNotificationService,lazy:!0}],[He,{useClass:exports.DesktopGalleryService,lazy:!0}],[Ie,{useClass:exports.DesktopDialogService,lazy:!0}],[Se,{useClass:exports.DesktopConfirmService,lazy:!0}],[P1,{useClass:L3,lazy:!0}],[xe,{useClass:exports.DesktopZenZoneService,lazy:!0}],[Me,{useClass:exports.DesktopGlobalZoneService,lazy:!0}],[be,{useClass:exports.DesktopMessageService,lazy:!0}],[C.ILocalStorageService,{useClass:b3,lazy:!0}],[m3,{useClass:exports.DesktopBeforeCloseService}],[ye,{useClass:c3}],[_e],[ee,{useFactory:r=>r.createInstance(ze,this._config),deps:[C.Injector]}],[exports.SharedController],[exports.ErrorController]],this._config.override).forEach(r=>this._injector.add(r)),this._injector.get(ee),this._injector.get(exports.ErrorController)}};C5(exports.UniverMobileUIPlugin,"pluginName",v5);exports.UniverMobileUIPlugin=f5([C.DependentOn(te.UniverRenderEnginePlugin),h5(1,C.Inject(C.Injector))],exports.UniverMobileUIPlugin);class ir extends C.Disposable{openFile(t){return new Promise(r=>{var i,a;const n=document.createElement("input");n.type="file",n.accept=(i=t==null?void 0:t.accept)!=null?i:"",n.multiple=(a=t==null?void 0:t.multiple)!=null?a:!1,n.onchange=o=>{const c=o.target.files;c&&r(Array.from(c))},n.click()})}downloadFile(t,r){const n=document.createElement("a");n.download=r,n.href=window.URL.createObjectURL(t),n.click()}}const or=C.createIdentifier("univer-ui.local-file.service"),g5=e=>{const r=O.useDependency(P1).getContainer();s.useEffect(()=>{if(r)return r.addEventListener("mousedown",e),()=>{r.removeEventListener("mousedown",e)}},[e,r])},m5=s.memo(e=>{var V,H;const{layer:t,id:r,position:n}=e,i=O.useDependency(C.IUniverInstanceService),a=s.useRef(null),o=s.useRef(null),c=s.useRef(`transform: rotate(${n==null?void 0:n.rotate}deg) translate(${n==null?void 0:n.startX}px, ${n==null?void 0:n.startY}px)`),h=s.useRef((V=n==null?void 0:n.startY)!=null?V:0),g=s.useRef((H=n==null?void 0:n.startX)!=null?H:0),p=typeof t.componentKey=="string"?O.useDependency(m1).get(t.componentKey):t.componentKey,d=s.useMemo(()=>({data:t.data,...t.props}),[t.data,t.props]),L={width:`${n.width-4}px`,height:`${n.height-4}px`,left:`${n.absolute.left?0:"auto"}`,top:`${n.absolute.top?0:"auto"}`,right:`${n.absolute.left?"auto":0}`,bottom:`${n.absolute.top?"auto":0}`};c.current=`rotate(${n.rotate}deg)`,h.current=n.startY,g.current=n.startX;const _=i.getUnit(t.unitId),M=s.useMemo(()=>p?f.jsx(p,{...d,unitId:t.unitId,unit:_,floatDomId:t.id,context:{root:o}}):null,[p,d]);return n?f.jsx("div",{ref:a,className:"univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden",style:{top:h.current,left:g.current,width:Math.max(n.endX-n.startX-2,0),height:Math.max(n.endY-n.startY-2,0),transform:c.current},onPointerMove:x=>{t.onPointerMove(x.nativeEvent)},onPointerDown:x=>{t.onPointerDown(x.nativeEvent)},onPointerUp:x=>{t.onPointerUp(x.nativeEvent)},onWheel:x=>{t.onWheel(x.nativeEvent)},children:f.jsx("div",{ref:o,id:r,className:"univer-absolute univer-overflow-hidden",style:{...L},children:M})}):null});var p5=Object.defineProperty,b5=Object.getOwnPropertyDescriptor,L5=(e,t,r)=>t in e?p5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w5=(e,t,r,n)=>{for(var i=n>1?void 0:n?b5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Ue=(e,t)=>(r,n)=>t(r,n,e),_5=(e,t,r)=>L5(e,t+"",r);const ar="UNIVER_UI_PLUGIN",sr="DISABLE_AUTO_FOCUS";exports.UniverUIPlugin=class extends C.Plugin{constructor(t=U3,r,n,i){super(),this._config=t,this._contextService=r,this._injector=n,this._configService=i;const{menu:a,...o}=C.merge({popupRootId:`univer-popup-portal-${C.generateRandomId(6)}`},U3,this._config);o.disableAutoFocus&&this._contextService.setContextValue(sr,!0),a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(re,o)}onStarting(){C.mergeOverrideWithDependencies([[m1],[ie],[Q1],[Le],[y1,{useClass:s3}],[S1,{useClass:exports.DesktopLayoutService}],[U1,{useClass:exports.ShortcutService}],[we,{useClass:a3}],[x1,{useClass:exports.MenuManagerService}],[oe,{useClass:f3}],[p3,{useClass:exports.BrowserClipboardService,lazy:!0}],[ae,{useClass:exports.DesktopNotificationService,lazy:!0}],[He,{useClass:exports.DesktopGalleryService,lazy:!0}],[Ie,{useClass:exports.DesktopDialogService,lazy:!0}],[Se,{useClass:exports.DesktopConfirmService,lazy:!0}],[P1,{useClass:L3,lazy:!0}],[xe,{useClass:exports.DesktopZenZoneService,lazy:!0}],[Me,{useClass:exports.DesktopGlobalZoneService,lazy:!0}],[be,{useClass:exports.DesktopMessageService,lazy:!0}],[C.ILocalStorageService,{useClass:b3,lazy:!0}],[m3,{useClass:exports.DesktopBeforeCloseService}],[or,{useClass:ir}],[ye,{useClass:c3}],[_e],[ee,{useFactory:r=>r.createInstance(exports.DesktopUIController,this._config),deps:[C.Injector]}],[exports.SharedController],[exports.ErrorController],[exports.ShortcutPanelController]],this._config.override).forEach(r=>this._injector.add(r)),this._injector.get(ee),this._injector.get(exports.ErrorController)}onReady(){this._injector.get(exports.SharedController)}onSteady(){this._injector.get(exports.ShortcutPanelController)}};_5(exports.UniverUIPlugin,"pluginName",ar);exports.UniverUIPlugin=w5([C.DependentOn(te.UniverRenderEnginePlugin),Ue(1,C.IContextService),Ue(2,C.Inject(C.Injector)),Ue(3,C.IConfigService)],exports.UniverUIPlugin);function ve(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,"")}const y5=.75,ut=78,dt=9,lr="rgba(0,0,0,0)",cr="rgb(0,0,0)";function w3(e){var c;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;const r=[];let n=0,i=0,a=e.textContent||"";a+=`\r
17
+ */var st;function Q4(){return st||(st=1,function(e,t){(function(r){e.exports=r()})(function(){return function r(n,i,a){function o(g,p){if(!i[g]){if(!n[g]){var d=typeof Ce=="function"&&Ce;if(!p&&d)return d(g,!0);if(c)return c(g,!0);var L=new Error("Cannot find module '"+g+"'");throw L.code="MODULE_NOT_FOUND",L}var _=i[g]={exports:{}};n[g][0].call(_.exports,function(M){var V=n[g][1][M];return o(V||M)},_,_.exports,r,n,i,a)}return i[g].exports}for(var c=typeof Ce=="function"&&Ce,h=0;h<a.length;h++)o(a[h]);return o}({1:[function(r,n,i){(function(a){var o=a.MutationObserver||a.WebKitMutationObserver,c;if(o){var h=0,g=new o(M),p=a.document.createTextNode("");g.observe(p,{characterData:!0}),c=function(){p.data=h=++h%2}}else if(!a.setImmediate&&typeof a.MessageChannel<"u"){var d=new a.MessageChannel;d.port1.onmessage=M,c=function(){d.port2.postMessage(0)}}else"document"in a&&"onreadystatechange"in a.document.createElement("script")?c=function(){var H=a.document.createElement("script");H.onreadystatechange=function(){M(),H.onreadystatechange=null,H.parentNode.removeChild(H),H=null},a.document.documentElement.appendChild(H)}:c=function(){setTimeout(M,0)};var L,_=[];function M(){L=!0;for(var H,x,E=_.length;E;){for(x=_,_=[],H=-1;++H<E;)x[H]();E=_.length}L=!1}n.exports=V;function V(H){_.push(H)===1&&!L&&c()}}).call(this,typeof he<"u"?he:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(r,n,i){var a=r(1);function o(){}var c={},h=["REJECTED"],g=["FULFILLED"],p=["PENDING"];n.exports=d;function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,y!==o&&V(this,y)}d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,N){if(typeof y!="function"&&this.state===g||typeof N!="function"&&this.state===h)return this;var k=new this.constructor(o);if(this.state!==p){var Y=this.state===g?y:N;_(k,Y,this.outcome)}else this.queue.push(new L(k,y,N));return k};function L(y,N,k){this.promise=y,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}L.prototype.callFulfilled=function(y){c.resolve(this.promise,y)},L.prototype.otherCallFulfilled=function(y){_(this.promise,this.onFulfilled,y)},L.prototype.callRejected=function(y){c.reject(this.promise,y)},L.prototype.otherCallRejected=function(y){_(this.promise,this.onRejected,y)};function _(y,N,k){a(function(){var Y;try{Y=N(k)}catch(B){return c.reject(y,B)}Y===y?c.reject(y,new TypeError("Cannot resolve promise with itself")):c.resolve(y,Y)})}c.resolve=function(y,N){var k=H(M,N);if(k.status==="error")return c.reject(y,k.value);var Y=k.value;if(Y)V(y,Y);else{y.state=g,y.outcome=N;for(var B=-1,z=y.queue.length;++B<z;)y.queue[B].callFulfilled(N)}return y},c.reject=function(y,N){y.state=h,y.outcome=N;for(var k=-1,Y=y.queue.length;++k<Y;)y.queue[k].callRejected(N);return y};function M(y){var N=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof N=="function")return function(){N.apply(y,arguments)}}function V(y,N){var k=!1;function Y(q){k||(k=!0,c.reject(y,q))}function B(q){k||(k=!0,c.resolve(y,q))}function z(){N(B,Y)}var X=H(z);X.status==="error"&&Y(X.value)}function H(y,N){var k={};try{k.value=y(N),k.status="success"}catch(Y){k.status="error",k.value=Y}return k}d.resolve=x;function x(y){return y instanceof this?y:c.resolve(new this(o),y)}d.reject=E;function E(y){var N=new this(o);return c.reject(N,y)}d.all=R;function R(y){var N=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,Y=!1;if(!k)return this.resolve([]);for(var B=new Array(k),z=0,X=-1,q=new this(o);++X<k;)Q(y[X],X);return q;function Q(G,W){N.resolve(G).then(K,function(a1){Y||(Y=!0,c.reject(q,a1))});function K(a1){B[W]=a1,++z===k&&!Y&&(Y=!0,c.resolve(q,B))}}}d.race=$;function $(y){var N=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,Y=!1;if(!k)return this.resolve([]);for(var B=-1,z=new this(o);++B<k;)X(y[B]);return z;function X(q){N.resolve(q).then(function(Q){Y||(Y=!0,c.resolve(z,Q))},function(Q){Y||(Y=!0,c.reject(z,Q))})}}},{1:1}],3:[function(r,n,i){(function(a){typeof a.Promise!="function"&&(a.Promise=r(2))}).call(this,typeof he<"u"?he:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(r,n,i){var a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l};function o(l,v){if(!(l instanceof v))throw new TypeError("Cannot call a class as a function")}function c(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var h=c();function g(){try{if(!h||!h.open)return!1;var l=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),v=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!l||v)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function p(l,v){l=l||[],v=v||{};try{return new Blob(l,v)}catch(m){if(m.name!=="TypeError")throw m;for(var u=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,b=new u,w=0;w<l.length;w+=1)b.append(l[w]);return b.getBlob(v.type)}}typeof Promise>"u"&&r(3);var d=Promise;function L(l,v){v&&l.then(function(u){v(null,u)},function(u){v(u)})}function _(l,v,u){typeof v=="function"&&l.then(v),typeof u=="function"&&l.catch(u)}function M(l){return typeof l!="string"&&(console.warn(l+" used as a key, but it is not a string."),l=String(l)),l}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var H="local-forage-detect-blob-support",x=void 0,E={},R=Object.prototype.toString,$="readonly",y="readwrite";function N(l){for(var v=l.length,u=new ArrayBuffer(v),b=new Uint8Array(u),w=0;w<v;w++)b[w]=l.charCodeAt(w);return u}function k(l){return new d(function(v){var u=l.transaction(H,y),b=p([""]);u.objectStore(H).put(b,"key"),u.onabort=function(w){w.preventDefault(),w.stopPropagation(),v(!1)},u.oncomplete=function(){var w=navigator.userAgent.match(/Chrome\/(\d+)/),m=navigator.userAgent.match(/Edge\//);v(m||!w||parseInt(w[1],10)>=43)}}).catch(function(){return!1})}function Y(l){return typeof x=="boolean"?d.resolve(x):k(l).then(function(v){return x=v,x})}function B(l){var v=E[l.name],u={};u.promise=new d(function(b,w){u.resolve=b,u.reject=w}),v.deferredOperations.push(u),v.dbReady?v.dbReady=v.dbReady.then(function(){return u.promise}):v.dbReady=u.promise}function z(l){var v=E[l.name],u=v.deferredOperations.pop();if(u)return u.resolve(),u.promise}function X(l,v){var u=E[l.name],b=u.deferredOperations.pop();if(b)return b.reject(v),b.promise}function q(l,v){return new d(function(u,b){if(E[l.name]=E[l.name]||r1(),l.db)if(v)B(l),l.db.close();else return u(l.db);var w=[l.name];v&&w.push(l.version);var m=h.open.apply(h,w);v&&(m.onupgradeneeded=function(I){var D=m.result;try{D.createObjectStore(l.storeName),I.oldVersion<=1&&D.createObjectStore(H)}catch(Z){if(Z.name==="ConstraintError")console.warn('The database "'+l.name+'" has been upgraded from version '+I.oldVersion+" to version "+I.newVersion+', but the storage "'+l.storeName+'" already exists.');else throw Z}}),m.onerror=function(I){I.preventDefault(),b(m.error)},m.onsuccess=function(){var I=m.result;I.onversionchange=function(D){D.target.close()},u(I),z(l)}})}function Q(l){return q(l,!1)}function G(l){return q(l,!0)}function W(l,v){if(!l.db)return!0;var u=!l.db.objectStoreNames.contains(l.storeName),b=l.version<l.db.version,w=l.version>l.db.version;if(b&&(l.version!==v&&console.warn('The database "'+l.name+`" can't be downgraded from version `+l.db.version+" to version "+l.version+"."),l.version=l.db.version),w||u){if(u){var m=l.db.version+1;m>l.version&&(l.version=m)}return!0}return!1}function K(l){return new d(function(v,u){var b=new FileReader;b.onerror=u,b.onloadend=function(w){var m=btoa(w.target.result||"");v({__local_forage_encoded_blob:!0,data:m,type:l.type})},b.readAsBinaryString(l)})}function a1(l){var v=N(atob(l.data));return p([v],{type:l.type})}function u1(l){return l&&l.__local_forage_encoded_blob}function p1(l){var v=this,u=v._initReady().then(function(){var b=E[v._dbInfo.name];if(b&&b.dbReady)return b.dbReady});return _(u,l,l),u}function L1(l){B(l);for(var v=E[l.name],u=v.forages,b=0;b<u.length;b++){var w=u[b];w._dbInfo.db&&(w._dbInfo.db.close(),w._dbInfo.db=null)}return l.db=null,Q(l).then(function(m){return l.db=m,W(l)?G(l):m}).then(function(m){l.db=v.db=m;for(var I=0;I<u.length;I++)u[I]._dbInfo.db=m}).catch(function(m){throw X(l,m),m})}function o1(l,v,u,b){b===void 0&&(b=1);try{var w=l.db.transaction(l.storeName,v);u(null,w)}catch(m){if(b>0&&(!l.db||m.name==="InvalidStateError"||m.name==="NotFoundError"))return d.resolve().then(function(){if(!l.db||m.name==="NotFoundError"&&!l.db.objectStoreNames.contains(l.storeName)&&l.version<=l.db.version)return l.db&&(l.version=l.db.version+1),G(l)}).then(function(){return L1(l).then(function(){o1(l,v,u,b-1)})}).catch(u);u(m)}}function r1(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function c1(l){var v=this,u={db:null};if(l)for(var b in l)u[b]=l[b];var w=E[u.name];w||(w=r1(),E[u.name]=w),w.forages.push(v),v._initReady||(v._initReady=v.ready,v.ready=p1);var m=[];function I(){return d.resolve()}for(var D=0;D<w.forages.length;D++){var Z=w.forages[D];Z!==v&&m.push(Z._initReady().catch(I))}var j=w.forages.slice(0);return d.all(m).then(function(){return u.db=w.db,Q(u)}).then(function(A){return u.db=A,W(u,v._defaultConfig.version)?G(u):A}).then(function(A){u.db=w.db=A,v._dbInfo=u;for(var P=0;P<j.length;P++){var J=j[P];J!==v&&(J._dbInfo.db=u.db,J._dbInfo.version=u.version)}})}function b1(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.get(l);j.onsuccess=function(){var A=j.result;A===void 0&&(A=null),u1(A)&&(A=a1(A)),w(A)},j.onerror=function(){m(j.error)}}catch(A){m(A)}})}).catch(m)});return L(b,v),b}function M1(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.openCursor(),A=1;j.onsuccess=function(){var P=j.result;if(P){var J=P.value;u1(J)&&(J=a1(J));var e1=l(J,P.key,A++);e1!==void 0?w(e1):P.continue()}else w()},j.onerror=function(){m(j.error)}}catch(P){m(P)}})}).catch(m)});return L(b,v),b}function V1(l,v,u){var b=this;l=M(l);var w=new d(function(m,I){var D;b.ready().then(function(){return D=b._dbInfo,R.call(v)==="[object Blob]"?Y(D.db).then(function(Z){return Z?v:K(v)}):v}).then(function(Z){o1(b._dbInfo,y,function(j,A){if(j)return I(j);try{var P=A.objectStore(b._dbInfo.storeName);Z===null&&(Z=void 0);var J=P.put(Z,l);A.oncomplete=function(){Z===void 0&&(Z=null),m(Z)},A.onabort=A.onerror=function(){var e1=J.error?J.error:J.transaction.error;I(e1)}}catch(e1){I(e1)}})}).catch(I)});return L(w,u),w}function Z1(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){o1(u._dbInfo,y,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=Z.delete(l);D.oncomplete=function(){w()},D.onerror=function(){m(j.error)},D.onabort=function(){var A=j.error?j.error:j.transaction.error;m(A)}}catch(A){m(A)}})}).catch(m)});return L(b,v),b}function j1(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,y,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.clear();I.oncomplete=function(){b()},I.onabort=I.onerror=function(){var j=Z.error?Z.error:Z.transaction.error;w(j)}}catch(j){w(j)}})}).catch(w)});return L(u,l),u}function dr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,$,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.count();Z.onsuccess=function(){b(Z.result)},Z.onerror=function(){w(Z.error)}}catch(j){w(j)}})}).catch(w)});return L(u,l),u}function fr(l,v){var u=this,b=new d(function(w,m){if(l<0){w(null);return}u.ready().then(function(){o1(u._dbInfo,$,function(I,D){if(I)return m(I);try{var Z=D.objectStore(u._dbInfo.storeName),j=!1,A=Z.openKeyCursor();A.onsuccess=function(){var P=A.result;if(!P){w(null);return}l===0||j?w(P.key):(j=!0,P.advance(l))},A.onerror=function(){m(A.error)}}catch(P){m(P)}})}).catch(m)});return L(b,v),b}function hr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){o1(v._dbInfo,$,function(m,I){if(m)return w(m);try{var D=I.objectStore(v._dbInfo.storeName),Z=D.openKeyCursor(),j=[];Z.onsuccess=function(){var A=Z.result;if(!A){b(j);return}j.push(A.key),A.continue()},Z.onerror=function(){w(Z.error)}}catch(A){w(A)}})}).catch(w)});return L(u,l),u}function Cr(l,v){v=V.apply(this,arguments);var u=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||u.name,l.storeName=l.storeName||u.storeName);var b=this,w;if(!l.name)w=d.reject("Invalid arguments");else{var m=l.name===u.name&&b._dbInfo.db,I=m?d.resolve(b._dbInfo.db):Q(l).then(function(D){var Z=E[l.name],j=Z.forages;Z.db=D;for(var A=0;A<j.length;A++)j[A]._dbInfo.db=D;return D});l.storeName?w=I.then(function(D){if(D.objectStoreNames.contains(l.storeName)){var Z=D.version+1;B(l);var j=E[l.name],A=j.forages;D.close();for(var P=0;P<A.length;P++){var J=A[P];J._dbInfo.db=null,J._dbInfo.version=Z}var e1=new d(function(t1,l1){var s1=h.open(l.name,Z);s1.onerror=function(w1){var z1=s1.result;z1.close(),l1(w1)},s1.onupgradeneeded=function(){var w1=s1.result;w1.deleteObjectStore(l.storeName)},s1.onsuccess=function(){var w1=s1.result;w1.close(),t1(w1)}});return e1.then(function(t1){j.db=t1;for(var l1=0;l1<A.length;l1++){var s1=A[l1];s1._dbInfo.db=t1,z(s1._dbInfo)}}).catch(function(t1){throw(X(l,t1)||d.resolve()).catch(function(){}),t1})}}):w=I.then(function(D){B(l);var Z=E[l.name],j=Z.forages;D.close();for(var A=0;A<j.length;A++){var P=j[A];P._dbInfo.db=null}var J=new d(function(e1,t1){var l1=h.deleteDatabase(l.name);l1.onerror=function(){var s1=l1.result;s1&&s1.close(),t1(l1.error)},l1.onblocked=function(){console.warn('dropInstance blocked for database "'+l.name+'" until all open connections are closed')},l1.onsuccess=function(){var s1=l1.result;s1&&s1.close(),e1(s1)}});return J.then(function(e1){Z.db=e1;for(var t1=0;t1<j.length;t1++){var l1=j[t1];z(l1._dbInfo)}}).catch(function(e1){throw(X(l,e1)||d.resolve()).catch(function(){}),e1})})}return L(w,v),w}var vr={_driver:"asyncStorage",_initStorage:c1,_support:g(),iterate:M1,getItem:b1,setItem:V1,removeItem:Z1,clear:j1,length:dr,key:fr,keys:hr,dropInstance:Cr};function gr(){return typeof openDatabase=="function"}var I1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mr="~~local_forage_type~",_3=/^~~local_forage_type~([^~]+)~/,se="__lfsc__:",Ee=se.length,De="arbf",Oe="blob",y3="si08",M3="ui08",x3="uic8",S3="si16",I3="si32",H3="ur16",R3="ui32",E3="fl32",D3="fl64",O3=Ee+De.length,V3=Object.prototype.toString;function N3(l){var v=l.length*.75,u=l.length,b,w=0,m,I,D,Z;l[l.length-1]==="="&&(v--,l[l.length-2]==="="&&v--);var j=new ArrayBuffer(v),A=new Uint8Array(j);for(b=0;b<u;b+=4)m=I1.indexOf(l[b]),I=I1.indexOf(l[b+1]),D=I1.indexOf(l[b+2]),Z=I1.indexOf(l[b+3]),A[w++]=m<<2|I>>4,A[w++]=(I&15)<<4|D>>2,A[w++]=(D&3)<<6|Z&63;return j}function Ve(l){var v=new Uint8Array(l),u="",b;for(b=0;b<v.length;b+=3)u+=I1[v[b]>>2],u+=I1[(v[b]&3)<<4|v[b+1]>>4],u+=I1[(v[b+1]&15)<<2|v[b+2]>>6],u+=I1[v[b+2]&63];return v.length%3===2?u=u.substring(0,u.length-1)+"=":v.length%3===1&&(u=u.substring(0,u.length-2)+"=="),u}function pr(l,v){var u="";if(l&&(u=V3.call(l)),l&&(u==="[object ArrayBuffer]"||l.buffer&&V3.call(l.buffer)==="[object ArrayBuffer]")){var b,w=se;l instanceof ArrayBuffer?(b=l,w+=De):(b=l.buffer,u==="[object Int8Array]"?w+=y3:u==="[object Uint8Array]"?w+=M3:u==="[object Uint8ClampedArray]"?w+=x3:u==="[object Int16Array]"?w+=S3:u==="[object Uint16Array]"?w+=H3:u==="[object Int32Array]"?w+=I3:u==="[object Uint32Array]"?w+=R3:u==="[object Float32Array]"?w+=E3:u==="[object Float64Array]"?w+=D3:v(new Error("Failed to get type for BinaryArray"))),v(w+Ve(b))}else if(u==="[object Blob]"){var m=new FileReader;m.onload=function(){var I=mr+l.type+"~"+Ve(this.result);v(se+Oe+I)},m.readAsArrayBuffer(l)}else try{v(JSON.stringify(l))}catch(I){console.error("Couldn't convert value into a JSON string: ",l),v(null,I)}}function br(l){if(l.substring(0,Ee)!==se)return JSON.parse(l);var v=l.substring(O3),u=l.substring(Ee,O3),b;if(u===Oe&&_3.test(v)){var w=v.match(_3);b=w[1],v=v.substring(w[0].length)}var m=N3(v);switch(u){case De:return m;case Oe:return p([m],{type:b});case y3:return new Int8Array(m);case M3:return new Uint8Array(m);case x3:return new Uint8ClampedArray(m);case S3:return new Int16Array(m);case H3:return new Uint16Array(m);case I3:return new Int32Array(m);case R3:return new Uint32Array(m);case E3:return new Float32Array(m);case D3:return new Float64Array(m);default:throw new Error("Unkown type: "+u)}}var Ne={serialize:pr,deserialize:br,stringToBuffer:N3,bufferToString:Ve};function T3(l,v,u,b){l.executeSql("CREATE TABLE IF NOT EXISTS "+v.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],u,b)}function Lr(l){var v=this,u={db:null};if(l)for(var b in l)u[b]=typeof l[b]!="string"?l[b].toString():l[b];var w=new d(function(m,I){try{u.db=openDatabase(u.name,String(u.version),u.description,u.size)}catch(D){return I(D)}u.db.transaction(function(D){T3(D,u,function(){v._dbInfo=u,m()},function(Z,j){I(j)})},I)});return u.serializer=Ne,w}function H1(l,v,u,b,w,m){l.executeSql(u,b,w,function(I,D){D.code===D.SYNTAX_ERR?I.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[v.storeName],function(Z,j){j.rows.length?m(Z,D):T3(Z,v,function(){Z.executeSql(u,b,w,m)},m)},m):m(I,D)},m)}function wr(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT * FROM "+I.storeName+" WHERE key = ? LIMIT 1",[l],function(Z,j){var A=j.rows.length?j.rows.item(0).value:null;A&&(A=I.serializer.deserialize(A)),w(A)},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function _r(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT * FROM "+I.storeName,[],function(Z,j){for(var A=j.rows,P=A.length,J=0;J<P;J++){var e1=A.item(J),t1=e1.value;if(t1&&(t1=I.serializer.deserialize(t1)),t1=l(t1,e1.key,J+1),t1!==void 0){w(t1);return}}w()},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function Z3(l,v,u,b){var w=this;l=M(l);var m=new d(function(I,D){w.ready().then(function(){v===void 0&&(v=null);var Z=v,j=w._dbInfo;j.serializer.serialize(v,function(A,P){P?D(P):j.db.transaction(function(J){H1(J,j,"INSERT OR REPLACE INTO "+j.storeName+" (key, value) VALUES (?, ?)",[l,A],function(){I(Z)},function(e1,t1){D(t1)})},function(J){if(J.code===J.QUOTA_ERR){if(b>0){I(Z3.apply(w,[l,Z,u,b-1]));return}D(J)}})})}).catch(D)});return L(m,u),m}function yr(l,v,u){return Z3.apply(this,[l,v,u,1])}function Mr(l,v){var u=this;l=M(l);var b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"DELETE FROM "+I.storeName+" WHERE key = ?",[l],function(){w()},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function xr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"DELETE FROM "+m.storeName,[],function(){b()},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Sr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"SELECT COUNT(key) as c FROM "+m.storeName,[],function(D,Z){var j=Z.rows.item(0).c;b(j)},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Ir(l,v){var u=this,b=new d(function(w,m){u.ready().then(function(){var I=u._dbInfo;I.db.transaction(function(D){H1(D,I,"SELECT key FROM "+I.storeName+" WHERE id = ? LIMIT 1",[l+1],function(Z,j){var A=j.rows.length?j.rows.item(0).key:null;w(A)},function(Z,j){m(j)})})}).catch(m)});return L(b,v),b}function Hr(l){var v=this,u=new d(function(b,w){v.ready().then(function(){var m=v._dbInfo;m.db.transaction(function(I){H1(I,m,"SELECT key FROM "+m.storeName,[],function(D,Z){for(var j=[],A=0;A<Z.rows.length;A++)j.push(Z.rows.item(A).key);b(j)},function(D,Z){w(Z)})})}).catch(w)});return L(u,l),u}function Rr(l){return new d(function(v,u){l.transaction(function(b){b.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(w,m){for(var I=[],D=0;D<m.rows.length;D++)I.push(m.rows.item(D).name);v({db:l,storeNames:I})},function(w,m){u(m)})},function(b){u(b)})})}function Er(l,v){v=V.apply(this,arguments);var u=this.config();l=typeof l!="function"&&l||{},l.name||(l.name=l.name||u.name,l.storeName=l.storeName||u.storeName);var b=this,w;return l.name?w=new d(function(m){var I;l.name===u.name?I=b._dbInfo.db:I=openDatabase(l.name,"","",0),l.storeName?m({db:I,storeNames:[l.storeName]}):m(Rr(I))}).then(function(m){return new d(function(I,D){m.db.transaction(function(Z){function j(e1){return new d(function(t1,l1){Z.executeSql("DROP TABLE IF EXISTS "+e1,[],function(){t1()},function(s1,w1){l1(w1)})})}for(var A=[],P=0,J=m.storeNames.length;P<J;P++)A.push(j(m.storeNames[P]));d.all(A).then(function(){I()}).catch(function(e1){D(e1)})},function(Z){D(Z)})})}):w=d.reject("Invalid arguments"),L(w,v),w}var Dr={_driver:"webSQLStorage",_initStorage:Lr,_support:gr(),iterate:_r,getItem:wr,setItem:yr,removeItem:Mr,clear:xr,length:Sr,key:Ir,keys:Hr,dropInstance:Er};function Or(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function j3(l,v){var u=l.name+"/";return l.storeName!==v.storeName&&(u+=l.storeName+"/"),u}function Vr(){var l="_localforage_support_test";try{return localStorage.setItem(l,!0),localStorage.removeItem(l),!1}catch{return!0}}function Nr(){return!Vr()||localStorage.length>0}function Tr(l){var v=this,u={};if(l)for(var b in l)u[b]=l[b];return u.keyPrefix=j3(l,v._defaultConfig),Nr()?(v._dbInfo=u,u.serializer=Ne,d.resolve()):d.reject()}function Zr(l){var v=this,u=v.ready().then(function(){for(var b=v._dbInfo.keyPrefix,w=localStorage.length-1;w>=0;w--){var m=localStorage.key(w);m.indexOf(b)===0&&localStorage.removeItem(m)}});return L(u,l),u}function jr(l,v){var u=this;l=M(l);var b=u.ready().then(function(){var w=u._dbInfo,m=localStorage.getItem(w.keyPrefix+l);return m&&(m=w.serializer.deserialize(m)),m});return L(b,v),b}function kr(l,v){var u=this,b=u.ready().then(function(){for(var w=u._dbInfo,m=w.keyPrefix,I=m.length,D=localStorage.length,Z=1,j=0;j<D;j++){var A=localStorage.key(j);if(A.indexOf(m)===0){var P=localStorage.getItem(A);if(P&&(P=w.serializer.deserialize(P)),P=l(P,A.substring(I),Z++),P!==void 0)return P}}});return L(b,v),b}function Ar(l,v){var u=this,b=u.ready().then(function(){var w=u._dbInfo,m;try{m=localStorage.key(l)}catch{m=null}return m&&(m=m.substring(w.keyPrefix.length)),m});return L(b,v),b}function $r(l){var v=this,u=v.ready().then(function(){for(var b=v._dbInfo,w=localStorage.length,m=[],I=0;I<w;I++){var D=localStorage.key(I);D.indexOf(b.keyPrefix)===0&&m.push(D.substring(b.keyPrefix.length))}return m});return L(u,l),u}function Br(l){var v=this,u=v.keys().then(function(b){return b.length});return L(u,l),u}function Pr(l,v){var u=this;l=M(l);var b=u.ready().then(function(){var w=u._dbInfo;localStorage.removeItem(w.keyPrefix+l)});return L(b,v),b}function Ur(l,v,u){var b=this;l=M(l);var w=b.ready().then(function(){v===void 0&&(v=null);var m=v;return new d(function(I,D){var Z=b._dbInfo;Z.serializer.serialize(v,function(j,A){if(A)D(A);else try{localStorage.setItem(Z.keyPrefix+l,j),I(m)}catch(P){(P.name==="QuotaExceededError"||P.name==="NS_ERROR_DOM_QUOTA_REACHED")&&D(P),D(P)}})})});return L(w,u),w}function Fr(l,v){if(v=V.apply(this,arguments),l=typeof l!="function"&&l||{},!l.name){var u=this.config();l.name=l.name||u.name,l.storeName=l.storeName||u.storeName}var b=this,w;return l.name?w=new d(function(m){l.storeName?m(j3(l,b._defaultConfig)):m(l.name+"/")}).then(function(m){for(var I=localStorage.length-1;I>=0;I--){var D=localStorage.key(I);D.indexOf(m)===0&&localStorage.removeItem(D)}}):w=d.reject("Invalid arguments"),L(w,v),w}var zr={_driver:"localStorageWrapper",_initStorage:Tr,_support:Or(),iterate:kr,getItem:jr,setItem:Ur,removeItem:Pr,clear:Zr,length:Br,key:Ar,keys:$r,dropInstance:Fr},Gr=function(v,u){return v===u||typeof v=="number"&&typeof u=="number"&&isNaN(v)&&isNaN(u)},Wr=function(v,u){for(var b=v.length,w=0;w<b;){if(Gr(v[w],u))return!0;w++}return!1},k3=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"},F1={},A3={},k1={INDEXEDDB:vr,WEBSQL:Dr,LOCALSTORAGE:zr},Yr=[k1.INDEXEDDB._driver,k1.WEBSQL._driver,k1.LOCALSTORAGE._driver],le=["dropInstance"],Te=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(le),Xr={description:"",driver:Yr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function qr(l,v){l[v]=function(){var u=arguments;return l.ready().then(function(){return l[v].apply(l,u)})}}function Ze(){for(var l=1;l<arguments.length;l++){var v=arguments[l];if(v)for(var u in v)v.hasOwnProperty(u)&&(k3(v[u])?arguments[0][u]=v[u].slice():arguments[0][u]=v[u])}return arguments[0]}var Jr=function(){function l(v){o(this,l);for(var u in k1)if(k1.hasOwnProperty(u)){var b=k1[u],w=b._driver;this[u]=w,F1[w]||this.defineDriver(b)}this._defaultConfig=Ze({},Xr),this._config=Ze({},this._defaultConfig,v),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return l.prototype.config=function(u){if((typeof u>"u"?"undefined":a(u))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var b in u){if(b==="storeName"&&(u[b]=u[b].replace(/\W/g,"_")),b==="version"&&typeof u[b]!="number")return new Error("Database version must be a number.");this._config[b]=u[b]}return"driver"in u&&u.driver?this.setDriver(this._config.driver):!0}else return typeof u=="string"?this._config[u]:this._config},l.prototype.defineDriver=function(u,b,w){var m=new d(function(I,D){try{var Z=u._driver,j=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!u._driver){D(j);return}for(var A=Te.concat("_initStorage"),P=0,J=A.length;P<J;P++){var e1=A[P],t1=!Wr(le,e1);if((t1||u[e1])&&typeof u[e1]!="function"){D(j);return}}var l1=function(){for(var z1=function(en){return function(){var tn=new Error("Method "+en+" is not implemented by the current driver"),$3=d.reject(tn);return L($3,arguments[arguments.length-1]),$3}},je=0,Kr=le.length;je<Kr;je++){var ke=le[je];u[ke]||(u[ke]=z1(ke))}};l1();var s1=function(z1){F1[Z]&&console.info("Redefining LocalForage driver: "+Z),F1[Z]=u,A3[Z]=z1,I()};"_support"in u?u._support&&typeof u._support=="function"?u._support().then(s1,D):s1(!!u._support):s1(!0)}catch(w1){D(w1)}});return _(m,b,w),m},l.prototype.driver=function(){return this._driver||null},l.prototype.getDriver=function(u,b,w){var m=F1[u]?d.resolve(F1[u]):d.reject(new Error("Driver not found."));return _(m,b,w),m},l.prototype.getSerializer=function(u){var b=d.resolve(Ne);return _(b,u),b},l.prototype.ready=function(u){var b=this,w=b._driverSet.then(function(){return b._ready===null&&(b._ready=b._initDriver()),b._ready});return _(w,u,u),w},l.prototype.setDriver=function(u,b,w){var m=this;k3(u)||(u=[u]);var I=this._getSupportedDrivers(u);function D(){m._config.driver=m.driver()}function Z(P){return m._extend(P),D(),m._ready=m._initStorage(m._config),m._ready}function j(P){return function(){var J=0;function e1(){for(;J<P.length;){var t1=P[J];return J++,m._dbInfo=null,m._ready=null,m.getDriver(t1).then(Z).catch(e1)}D();var l1=new Error("No available storage method found.");return m._driverSet=d.reject(l1),m._driverSet}return e1()}}var A=this._driverSet!==null?this._driverSet.catch(function(){return d.resolve()}):d.resolve();return this._driverSet=A.then(function(){var P=I[0];return m._dbInfo=null,m._ready=null,m.getDriver(P).then(function(J){m._driver=J._driver,D(),m._wrapLibraryMethodsWithReady(),m._initDriver=j(I)})}).catch(function(){D();var P=new Error("No available storage method found.");return m._driverSet=d.reject(P),m._driverSet}),_(this._driverSet,b,w),this._driverSet},l.prototype.supports=function(u){return!!A3[u]},l.prototype._extend=function(u){Ze(this,u)},l.prototype._getSupportedDrivers=function(u){for(var b=[],w=0,m=u.length;w<m;w++){var I=u[w];this.supports(I)&&b.push(I)}return b},l.prototype._wrapLibraryMethodsWithReady=function(){for(var u=0,b=Te.length;u<b;u++)qr(this,Te[u])},l.prototype.createInstance=function(u){return new l(u)},l}(),Qr=new Jr;n.exports=Qr},{3:3}]},{},[4])(4)})}(Pe)),Pe.exports}var K4=Q4();const N1=J4(K4);class b3{getItem(t){return N1.getItem(t)}setItem(t,r){return N1.setItem(t,r)}removeItem(t){return N1.removeItem(t)}clear(){return N1.clear()}key(t){return N1.key(t)}keys(){return N1.keys()}iterate(t){return N1.iterate(t)}}var e5=Object.getOwnPropertyDescriptor,t5=(e,t,r,n)=>{for(var i=n>1?void 0:n?e5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},lt=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopMessageService=class extends C.Disposable{constructor(t,r){super(),this._injector=t,this._uiPartsService=r,this._initUIPart()}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(T.Messager,this._injector)))}dispose(){T.removeMessage()}show(t){let r=t;return typeof t.id>"u"&&(r=Object.assign({},t,{id:`message-${Date.now()}`})),T.message(r),C.toDisposable(()=>T.removeMessage(r.id))}remove(t){T.removeMessage(t)}removeAll(){T.removeMessage()}};exports.DesktopMessageService=t5([lt(0,C.Inject(C.Injector)),lt(1,y1)],exports.DesktopMessageService);function r5(){const e=O.useDependency(C.ThemeService),t=O.useObservable(e.darkMode$);return f.jsx(T.Toaster,{theme:t?"dark":"light"})}const n5={show:e=>{const{type:t="message",title:r,content:n,duration:i,closable:a=!0,position:o="top-right"}=e;T.toast[t](r,{position:o,description:n,duration:i,closeButton:a})}};var i5=Object.getOwnPropertyDescriptor,o5=(e,t,r,n)=>{for(var i=n>1?void 0:n?i5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},ct=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopNotificationService=class extends C.Disposable{constructor(t,r){super(),this._injector=t,this._uiPartsService=r,this._initUIPart()}show(t){return n5.show(t),C.toDisposable(()=>{})}_initUIPart(){this.disposeWithMe(this._uiPartsService.registerComponent(i1.GLOBAL,()=>O.connectInjector(r5,this._injector)))}};exports.DesktopNotificationService=o5([ct(0,C.Inject(C.Injector)),ct(1,y1)],exports.DesktopNotificationService);class L3{constructor(){U(this,"_sidebarOptions",{});U(this,"sidebarOptions$",new F.Subject);U(this,"scrollEvent$",new F.Subject);U(this,"_container")}get visible(){return this._sidebarOptions.visible||!1}get options(){return this._sidebarOptions}open(t){return this._sidebarOptions={...t,id:t.id,visible:!0},this.sidebarOptions$.next(this._sidebarOptions),C.toDisposable(()=>{this.close()})}close(t){t&&this._sidebarOptions.id!==t||(this._sidebarOptions={...this._sidebarOptions,visible:!1},this.sidebarOptions$.next(this._sidebarOptions),this._sidebarOptions.onClose&&this._sidebarOptions.onClose())}getContainer(){return this._container}setContainer(t){this._container=t}}var a5=Object.getOwnPropertyDescriptor,s5=(e,t,r,n)=>{for(var i=n>1?void 0:n?a5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},l5=(e,t)=>(r,n)=>t(r,n,e);exports.DesktopZenZoneService=class{constructor(t){U(this,"visible$",new F.BehaviorSubject(!1));U(this,"componentKey$",new F.ReplaySubject);U(this,"_temporaryHidden$",new F.BehaviorSubject(!1));U(this,"temporaryHidden$",this._temporaryHidden$.asObservable());U(this,"_visible",!1);this._componentManager=t}get visible(){return this._visible}get temporaryHidden(){return this._temporaryHidden$.getValue()}dispose(){this.visible$.next(!1),this.visible$.complete(),this.componentKey$.complete()}hide(){this._temporaryHidden$.next(!0)}show(){this._temporaryHidden$.next(!1)}set(t,r){return this._componentManager.register(t,r),this.componentKey$.next(t),C.toDisposable(()=>{this._componentManager.delete(t),this.visible$.complete(),this.componentKey$.complete()})}open(){this._visible=!0,this.visible$.next(!0)}close(){this._visible=!1,this.visible$.next(!1)}};exports.DesktopZenZoneService=s5([l5(0,C.Inject(m1))],exports.DesktopZenZoneService);var c5=Object.defineProperty,u5=Object.getOwnPropertyDescriptor,d5=(e,t,r)=>t in e?c5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f5=(e,t,r,n)=>{for(var i=n>1?void 0:n?u5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},h5=(e,t)=>(r,n)=>t(r,n,e),C5=(e,t,r)=>d5(e,t+"",r);const v5="UNIVER_MOBILE_UI_PLUGIN";exports.UniverMobileUIPlugin=class extends C.Plugin{constructor(t,r){super(),this._config=t,this._injector=r}onStarting(){C.mergeOverrideWithDependencies([[m1],[Q1],[Le],[y1,{useClass:s3}],[S1,{useClass:exports.DesktopLayoutService}],[ie],[U1,{useClass:exports.ShortcutService}],[we,{useClass:a3}],[x1,{useClass:exports.MenuManagerService}],[oe,{useClass:f3}],[p3,{useClass:exports.BrowserClipboardService,lazy:!0}],[ae,{useClass:exports.DesktopNotificationService,lazy:!0}],[He,{useClass:exports.DesktopGalleryService,lazy:!0}],[Ie,{useClass:exports.DesktopDialogService,lazy:!0}],[Se,{useClass:exports.DesktopConfirmService,lazy:!0}],[P1,{useClass:L3,lazy:!0}],[xe,{useClass:exports.DesktopZenZoneService,lazy:!0}],[Me,{useClass:exports.DesktopGlobalZoneService,lazy:!0}],[be,{useClass:exports.DesktopMessageService,lazy:!0}],[C.ILocalStorageService,{useClass:b3,lazy:!0}],[m3,{useClass:exports.DesktopBeforeCloseService}],[ye,{useClass:c3}],[_e],[ee,{useFactory:r=>r.createInstance(ze,this._config),deps:[C.Injector]}],[exports.SharedController],[exports.ErrorController]],this._config.override).forEach(r=>this._injector.add(r)),this._injector.get(ee),this._injector.get(exports.ErrorController)}};C5(exports.UniverMobileUIPlugin,"pluginName",v5);exports.UniverMobileUIPlugin=f5([C.DependentOn(te.UniverRenderEnginePlugin),h5(1,C.Inject(C.Injector))],exports.UniverMobileUIPlugin);class ir extends C.Disposable{openFile(t){return new Promise(r=>{var i,a;const n=document.createElement("input");n.type="file",n.accept=(i=t==null?void 0:t.accept)!=null?i:"",n.multiple=(a=t==null?void 0:t.multiple)!=null?a:!1,n.onchange=o=>{const c=o.target.files;c&&r(Array.from(c))},n.click()})}downloadFile(t,r){const n=document.createElement("a");n.download=r,n.href=window.URL.createObjectURL(t),n.click()}}const or=C.createIdentifier("univer-ui.local-file.service"),g5=e=>{const r=O.useDependency(P1).getContainer();s.useEffect(()=>{if(r)return r.addEventListener("mousedown",e),()=>{r.removeEventListener("mousedown",e)}},[e,r])},m5=s.memo(e=>{var V,H;const{layer:t,id:r,position:n}=e,i=O.useDependency(C.IUniverInstanceService),a=s.useRef(null),o=s.useRef(null),c=s.useRef(`transform: rotate(${n==null?void 0:n.rotate}deg) translate(${n==null?void 0:n.startX}px, ${n==null?void 0:n.startY}px)`),h=s.useRef((V=n==null?void 0:n.startY)!=null?V:0),g=s.useRef((H=n==null?void 0:n.startX)!=null?H:0),p=typeof t.componentKey=="string"?O.useDependency(m1).get(t.componentKey):t.componentKey,d=s.useMemo(()=>({data:t.data,...t.props}),[t.data,t.props]),L={width:`${n.width-4}px`,height:`${n.height-4}px`,left:`${n.absolute.left?0:"auto"}`,top:`${n.absolute.top?0:"auto"}`,right:`${n.absolute.left?"auto":0}`,bottom:`${n.absolute.top?"auto":0}`};c.current=`rotate(${n.rotate}deg)`,h.current=n.startY,g.current=n.startX;const _=i.getUnit(t.unitId),M=s.useMemo(()=>p?f.jsx(p,{...d,unitId:t.unitId,unit:_,floatDomId:t.id,context:{root:o}}):null,[p,d]);return n?f.jsx("div",{ref:a,className:"univer-absolute univer-z-10 univer-origin-center univer-overflow-hidden",style:{top:h.current,left:g.current,width:Math.max(n.endX-n.startX-2,0),height:Math.max(n.endY-n.startY-2,0),transform:c.current},onPointerMove:x=>{t.onPointerMove(x.nativeEvent)},onPointerDown:x=>{t.onPointerDown(x.nativeEvent)},onPointerUp:x=>{t.onPointerUp(x.nativeEvent)},onWheel:x=>{t.onWheel(x.nativeEvent)},children:f.jsx("div",{ref:o,id:r,className:"univer-absolute univer-overflow-hidden",style:{...L},children:M})}):null});var p5=Object.defineProperty,b5=Object.getOwnPropertyDescriptor,L5=(e,t,r)=>t in e?p5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w5=(e,t,r,n)=>{for(var i=n>1?void 0:n?b5(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Ue=(e,t)=>(r,n)=>t(r,n,e),_5=(e,t,r)=>L5(e,t+"",r);const ar="UNIVER_UI_PLUGIN",sr="DISABLE_AUTO_FOCUS";exports.UniverUIPlugin=class extends C.Plugin{constructor(t=U3,r,n,i){super(),this._config=t,this._contextService=r,this._injector=n,this._configService=i;const{menu:a,...o}=C.merge({popupRootId:`univer-popup-portal-${C.generateRandomId(6)}`},U3,this._config);o.disableAutoFocus&&this._contextService.setContextValue(sr,!0),a&&this._configService.setConfig("menu",a,{merge:!0}),this._configService.setConfig(re,o)}onStarting(){C.registerDependencies(this._injector,C.mergeOverrideWithDependencies([[m1],[ie],[Q1],[Le],[y1,{useClass:s3}],[S1,{useClass:exports.DesktopLayoutService}],[U1,{useClass:exports.ShortcutService}],[we,{useClass:a3}],[x1,{useClass:exports.MenuManagerService}],[oe,{useClass:f3}],[p3,{useClass:exports.BrowserClipboardService,lazy:!0}],[ae,{useClass:exports.DesktopNotificationService,lazy:!0}],[He,{useClass:exports.DesktopGalleryService,lazy:!0}],[Ie,{useClass:exports.DesktopDialogService,lazy:!0}],[Se,{useClass:exports.DesktopConfirmService,lazy:!0}],[P1,{useClass:L3,lazy:!0}],[xe,{useClass:exports.DesktopZenZoneService,lazy:!0}],[Me,{useClass:exports.DesktopGlobalZoneService,lazy:!0}],[be,{useClass:exports.DesktopMessageService,lazy:!0}],[C.ILocalStorageService,{useClass:b3,lazy:!0}],[m3,{useClass:exports.DesktopBeforeCloseService}],[or,{useClass:ir}],[ye,{useClass:c3}],[_e],[ee,{useFactory:t=>t.createInstance(exports.DesktopUIController,this._config),deps:[C.Injector]}],[exports.SharedController],[exports.ErrorController],[exports.ShortcutPanelController]])),C.touchDependencies(this._injector,[[ee],[exports.ErrorController]])}onReady(){C.touchDependencies(this._injector,[[exports.SharedController]])}onSteady(){C.touchDependencies(this._injector,[[exports.ShortcutPanelController]])}};_5(exports.UniverUIPlugin,"pluginName",ar);exports.UniverUIPlugin=w5([C.DependentOn(te.UniverRenderEnginePlugin),Ue(1,C.IContextService),Ue(2,C.Inject(C.Injector)),Ue(3,C.IConfigService)],exports.UniverUIPlugin);function ve(e){return e.length===0?e:e.replace(/^\s+|\s+$/gm,"")}const y5=.75,ut=78,dt=9,lr="rgba(0,0,0,0)",cr="rgb(0,0,0)";function w3(e){var c;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;const r=[];let n=0,i=0,a=e.textContent||"";a+=`\r
18
18
  `;for(let h=0;h<t.length;h++){let g=t[`${h}`],p;g.nodeName==="#text"?(p=(c=g.textContent)!=null?c:"",g=g.parentElement):p=g.innerText;const d=Re(g);ur(p).forEach(_=>{const M=_.length;i+=M,n=i-M;const V=C.Tools.generateRandomId(6);r.push({sId:V,st:n,ed:i-1,ts:d})})}return C.Tools.generateRandomId(6),{id:C.Tools.generateRandomId(6),body:{dataStream:a,textRuns:r},documentStyle:{}}}function Re(e,t=""){var o,c;let r=(c=(o=e==null?void 0:e.style)==null?void 0:o.cssText)!=null?c:"";if(r+=t,r=r.replace(/[\r\n]+/g,""),r.length===0)return{};const n=r.split(";"),i={},a={t:"",r:"",b:"",l:""};return n.forEach(h=>{var L;const g=h.toLowerCase(),p=ve(g.substr(0,g.indexOf(":"))),d=ve(g.substr(g.indexOf(":")+1));if(p==="font-weight")d==="bold"||d==="700"?i.bl=1:i.bl=0;else if(p==="font-style")d==="italic"?i.it=1:i.it=0;else if(p==="font-family"){const _=ve(h),M=O5(_);i.ff=M}else if(p==="font-size"){let _=Number.parseInt(d);r.indexOf("vertical-align")>-1&&(r.indexOf("sub")>-1||r.indexOf("sup")>-1)&&(_*=2),d.indexOf("px")!==-1&&(_=D5(Number.parseInt(d,10))),i.fs=_}else if(p==="color"){const _=new C.ColorKit(d);i.cl={rgb:_.isValid?_.toRgbString():"rgb(0,0,0)"}}else if(p==="background"||p==="background-color"){const _=new C.ColorKit(d);if(_){const M=_.toRgbString();M!==lr&&M!==cr&&(i.bg={rgb:_.toRgbString()})}}else if(p==="text-decoration-line")d==="underline"?(i.ul||(i.ul={s:1}),i.ul.s=1):d==="line-through"?(i.st||(i.st={s:1}),i.st.s=1):d==="overline"&&(i.ol||(i.ol={s:1}),i.ol.s=1);else if(p==="text-decoration-color")i.hasOwnProperty("ul")&&(i.ul||(i.ul={s:1,cl:{rgb:d}}),i.ul.cl={rgb:d}),i.hasOwnProperty("st")&&(i.st||(i.st={s:1,cl:{rgb:d}}),i.st.cl={rgb:d}),i.hasOwnProperty("ol")&&(i.ol||(i.ol={s:1,cl:{rgb:d}}),i.ol.cl={rgb:d});else if(p==="text-decoration-style")i.hasOwnProperty("ul")&&(i.ul||(i.ul={s:1,t:Number(d)}),i.ul.t=Number(d)),i.hasOwnProperty("st")&&(i.st||(i.st={s:1,t:Number(d)}),i.st.t=Number(d)),i.hasOwnProperty("ol")&&(i.ol||(i.ol={s:1,t:Number(d)}),i.ol.t=Number(d));else if(p==="text-decoration"||p==="univer-strike"){const _=(L=d.split(" "))==null?void 0:L[0];_==="underline"?(i.ul||(i.ul={s:1}),i.ul.s=1):_==="line-through"?(i.st||(i.st={s:1}),i.st.s=1):_==="overline"&&(i.ol||(i.ol={s:1}),i.ol.s=1)}if(p==="univer-underline"&&(i.ul={s:1}),p==="vertical-align"&&(d==="sub"?i.va=C.BaselineOffset.SUBSCRIPT:d==="super"?i.va=C.BaselineOffset.SUPERSCRIPT:d==="top"?i.vt=1:d==="middle"?i.vt=2:d==="bottom"?i.vt=3:i.va=C.BaselineOffset.NORMAL),p==="transform"){const _=d.split(")"),M=_.findIndex(V=>V.includes("rotate"));if(M>-1){const V=_[M].match(/\d+/g);let H=0,x=0;V!=null&&V.length&&(H=+V[0]),e!=null&&e.dataset.vertical&&(x=+e.dataset.vertical),i.tr={a:H,v:x}}}if(p==="text-align"&&(d==="left"?i.ht=1:d==="center"?i.ht=2:d==="right"?i.ht=3:d==="justify"?i.ht=4:i.ht=0),i.tb!==1&&(p==="overflow-wrap"||p==="word-wrap"?d==="break-word"&&(i.tb=3):p==="text-overflow"?d==="clip"&&(i.tb=2):p==="text-break"&&d==="overflow"&&(i.tb=1)),p==="white-space"&&(d==="nowrap"?i.tb=1:d==="normal"?i.tb=3:d==="clip"&&(i.tb=2)),p==="border-color"){const _=ft(d,")");if(i.bd)for(const M in _)i.bd[M].cl.rgb=_[M];else{i.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(const M in _)i.bd[M].cl.rgb=_[M]}}if(p==="border-width"||p==="border-style"){const _=ft(d," ");for(const M in _)a[M]+=` ${_[M]}`;i.bd?(i.bd.b.s=C.getBorderStyleType(a.b),i.bd.t.s=C.getBorderStyleType(a.t),i.bd.l.s=C.getBorderStyleType(a.l),i.bd.r.s=C.getBorderStyleType(a.r)):i.bd={b:{cl:{rgb:"#000"},s:C.getBorderStyleType(a.b)},t:{cl:{rgb:"#000"},s:C.getBorderStyleType(a.t)},l:{cl:{rgb:"#000"},s:C.getBorderStyleType(a.l)},r:{cl:{rgb:"#000"},s:C.getBorderStyleType(a.r)}}}if(p==="border-bottom"||p==="border-top"||p==="border-left"||p==="border-right"||p==="border"){i.bd||(i.bd={});const _=d.split(" "),M=`${_[0]} ${_[1]}`;_.splice(0,2);const V=_.join("");if(C.getBorderStyleType(M)!==C.BorderStyleTypes.NONE&&V){const x={cl:{rgb:V},s:C.getBorderStyleType(M)};p==="border-bottom"?i.bd.b=d==="none"?null:x:p==="border-top"?i.bd.t=d==="none"?null:x:p==="border-left"?i.bd.l=d==="none"?null:x:p==="border-right"?i.bd.r=d==="none"?null:x:p==="border"&&(i.bd={r:d==="none"?null:x,t:d==="none"?null:x,b:d==="none"?null:x,l:d==="none"?null:x})}}else if(p==="--data-rotate"){const _=/[+-]?\d+/,M=d.match(_);d==="(0deg ,1)"?i.tr={a:0,v:1}:M&&(i.tr={a:Number(M[0])})}}),Object.keys(i).forEach(h=>{typeof i[h]=="object"&&!Object.keys(i[h]).length&&delete i[h]}),i}function ft(e,t){let r;t===" "?r=e.trim().split(t):r=e.trim().split(t).slice(0,-1),r.forEach(i=>`${i.trim()})`);let n={};return r.length===1?n={t:r[0],r:r[0],b:r[0],l:r[0]}:r.length===2?n={t:r[0],r:r[1],b:r[0],l:r[1]}:r.length===3?n={t:r[0],r:r[1],b:r[2],l:r[1]}:r.length===4&&(n={t:r[0],r:r[1],b:r[2],l:r[3]}),n}function ur(e){if(e==="")return[e];const t=/(?:(\n+.+)|(.+))/g;return e.match(t).map(i=>i.replace(/\n/g,`\r
19
19
  `))}function M5(e){const t=document.createElement("DIV"),r=[];t.innerHTML=e;const n=t.querySelectorAll("table col");if(!n.length)return[];for(let i=0;i<n.length;i++){const a=n[i],o=a.getAttribute("span");if(o&&+o>1)for(let c=0;c<+o;c++){const h=me(a.getAttribute("width"),72);r.push(h)}else{const c=me(a.getAttribute("width"),72);r.push(c)}}return r}function me(e,t){if(!e)return t;let r;return e.includes("pt")?r=te.ptToPx(Number.parseFloat(e)):e.includes("px")?r=Number.parseFloat(e):r=Number.parseFloat(e)*72/96,r}function x5(e){const t=document.createElement("DIV"),r=[];t.innerHTML=e;const n=t.querySelectorAll("table tr");if(!n.length)return[];for(let i=0;i<n.length;i++){const o=n[i].querySelectorAll("td");let c=me(o[0].style.height,19);for(let h=0;h<o.length;h++){const g=o[h].getAttribute("rowSpan");if(!(g&&+g>1)){c=me(o[h].style.height,19);break}}r.push(c)}return r}function S5(e){let t=[];const r=document.createElement("DIV");if(r.innerHTML=e,t=new Array(r.querySelectorAll("table tr").length),!t.length)return[];let n=0;const i=r.querySelectorAll("table tr");i[0].querySelectorAll("td").forEach(c=>{let h=0;const g=c.getAttribute("colSpan");g!==null?h=+g:h=1,n+=h});for(let c=0;c<t.length;c++)t[c]=new Array(n);let o=0;return i.forEach(c=>{let h=0;c.querySelectorAll("td").forEach(g=>{var _,M;const p={};if(g.querySelectorAll("span").length||g.querySelectorAll("font").length){const V=w3(g);typeof V!="string"&&(p.p=V)}const d=g.innerText;d.trim().length===0?p.v="":p.v=d;const L=Re(g);for(C.Tools.isPlainObject(L)&&(p.s=L);h<n&&t[o][h]!=null;)h++;if(h!==n){if(t[o][h]==null){t[o][h]=p;const V=(_=Number(g.getAttribute("rowSpan")))!=null?_:1,H=(M=Number(g.getAttribute("colSpan")))!=null?M:1;if(V>1||H>1){const x={rs:+V-1,cs:+H-1,r:o,c:h};t[o][h].mc=x;for(let E=0;E<V;E++)for(let R=0;R<H;R++)E===0&&R===0||(t[o+E][h+R]={mc:null})}}h++}}),o++}),t}function I5(e){const t=[],r=document.createElement("DIV");r.innerHTML=e;const i=e.replace(/\r/g,"").split(`
20
20
  `),a=i[0].split(" ").length;for(let o=0;o<i.length;o++)i[o].split(" ").length<a||t.push(i[o].split(" "));for(let o=0;o<t.length;o++)for(let c=0;c<t[o].length;c++)t[o][c].length?t[o][c]={v:t[o][c]||"",m:t[o][c]||""}:t[o][c]=null;return t}function H5(e,t){e.length,e[0].length;let r=0,n=0;t&&(r=t.startRow,n=t.startColumn);const i=[];for(let a=0;a<e.length;a++)for(let o=0;o<e[a].length;o++)if(e[a][o]&&typeof e[a][o]=="object"&&"mc"in e[a][o])if(e[a][o].mc){const c=e[a][o].mc,h=c.r+r,g=h+c.rs,p=c.c+n,d=p+c.cs;i.push({startRow:h,endRow:g,startColumn:p,endColumn:d}),delete e[a][o].mc}else e[a][o]=null;return{data:e,mergeData:i}}function R5(e){var g;let t=[];const r=document.createElement("html");r.innerHTML=e;const n=(g=r.querySelector("style"))==null?void 0:g.innerText;if(!n)return;const i=E5(n);if(t=new Array(r.querySelectorAll("table tr").length),!t.length)return[];let a=0;const o=r.querySelectorAll("table tr");o[0].querySelectorAll("td").forEach(p=>{let d=0;const L=p.getAttribute("colSpan");L!==null?d=+L:d=1,a+=d});for(let p=0;p<t.length;p++)t[p]=new Array(a);let h=0;return o.forEach(p=>{let d=0;p.querySelectorAll("td").forEach(L=>{var x,E;const _={};if(L.querySelectorAll("span").length||L.querySelectorAll("font").length){const R=w3(L);typeof R!="string"&&(_.p=R)}const M=L.innerText;M.trim().length===0?_.v="":_.v=M;let V="";for(const R in i)L.classList.contains(R)&&(V+=i[R]);const H=Re(L,V);for(C.Tools.isPlainObject(H)&&(_.s=H);d<a&&t[h][d]!=null;)d++;if(d!==a){if(t[h][d]==null){t[h][d]=_;const R=(x=Number(L.getAttribute("rowSpan")))!=null?x:1,$=(E=Number(L.getAttribute("colSpan")))!=null?E:1;if(R>1||$>1){const y={rs:+R-1,cs:+$-1,r:h,c:d};t[h][d].mc=y;for(let N=0;N<R;N++)for(let k=0;k<$;k++)N===0&&k===0||(t[h+N][d+k]={mc:null})}}d++}}),h++}),t}function E5(e){const t={},r=e.replaceAll("<!--","").replaceAll("-->","").trim(),n=r==null?void 0:r.replaceAll(" ","").replaceAll(`