@univerjs/sheets-hyper-link-ui 0.2.5 → 0.2.7

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.
@@ -8,6 +8,10 @@ export declare class SheetsHyperLinkCopyPasteController extends Disposable {
8
8
  private _hyperLinkModel;
9
9
  private _injector;
10
10
  private _resolverService;
11
+ private _plainTextFilter;
12
+ registerPlainTextFilter(filter: (text: string) => boolean): void;
13
+ removePlainTextFilter(filter: (text: string) => boolean): void;
14
+ private _filterPlainText;
11
15
  private _copyInfo;
12
16
  constructor(_sheetClipboardService: ISheetClipboardService, _hyperLinkModel: HyperLinkModel, _injector: Injector, _resolverService: SheetsHyperLinkResolverService);
13
17
  private _initCopyPaste;
@@ -1,9 +1,7 @@
1
- import { Disposable, ICommandService, Injector, LocaleService } from '@univerjs/core';
2
- import { MenuConfig, ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
1
+ import { Nullable, Disposable, ICommandService, Injector, LocaleService } from '@univerjs/core';
2
+ import { ComponentManager, IMenuService, IShortcutService } from '@univerjs/ui';
3
+ import { IUniverSheetsHyperLinkUIConfig } from '../types/interfaces/i-config';
3
4
 
4
- export interface IUniverSheetsHyperLinkUIConfig {
5
- menu?: MenuConfig;
6
- }
7
5
  export declare class SheetsHyperLinkUIController extends Disposable {
8
6
  private _config;
9
7
  private _componentManager;
@@ -12,7 +10,7 @@ export declare class SheetsHyperLinkUIController extends Disposable {
12
10
  private _menuService;
13
11
  private _injector;
14
12
  private _shortcutService;
15
- constructor(_config: IUniverSheetsHyperLinkUIConfig | undefined, _componentManager: ComponentManager, _commandService: ICommandService, _localeService: LocaleService, _menuService: IMenuService, _injector: Injector, _shortcutService: IShortcutService);
13
+ constructor(_config: Nullable<IUniverSheetsHyperLinkUIConfig>, _componentManager: ComponentManager, _commandService: ICommandService, _localeService: LocaleService, _menuService: IMenuService, _injector: Injector, _shortcutService: IShortcutService);
16
14
  private _initComponents;
17
15
  private _initCommands;
18
16
  private _initMenus;
@@ -15,6 +15,7 @@
15
15
  */
16
16
  export { SheetsHyperLinkRemoveSheetController } from './controllers/remove-sheet.controller';
17
17
  export { SheetsHyperLinkRenderManagerController, SheetsHyperLinkRenderController } from './controllers/render-controllers/render.controller';
18
+ export { SheetsHyperLinkSidePanelService, type ICustomHyperLinkView } from './services/side-panel.service';
18
19
  export { SheetsHyperLinkPopupService } from './services/popup.service';
19
20
  export { SheetsHyperLinkResolverService } from './services/resolver.service';
20
21
  export { SheetHyperLinkSetRangeController } from './controllers/set-range.controller';
@@ -25,4 +26,5 @@ export { SheetsHyperLinkCopyPasteController } from './controllers/copy-paste.con
25
26
  export { SheetHyperLinkUrlController } from './controllers/url.controller';
26
27
  export { UniverSheetsHyperLinkUIPlugin } from './plugin';
27
28
  export { InsertLinkShortcut } from './controllers/menu';
29
+ export type { IUrlHandler, IUniverSheetsHyperLinkUIConfig } from './types/interfaces/i-config';
28
30
  export { OpenHyperLinkSidebarOperation, InsertHyperLinkOperation, CloseHyperLinkSidebarOperation, type IOpenHyperLinkSidebarOperationParams, } from './commands/operations/sidebar.operations';
@@ -1,6 +1,6 @@
1
- import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
1
+ import { Nullable, Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
- import { IUniverSheetsHyperLinkUIConfig } from './controllers/ui.controller';
3
+ import { IUniverSheetsHyperLinkUIConfig } from './types/interfaces/i-config';
4
4
 
5
5
  export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
6
6
  private _config;
@@ -8,7 +8,7 @@ export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
8
8
  private readonly _renderManagerService;
9
9
  static pluginName: string;
10
10
  static type: UniverInstanceType;
11
- constructor(_config: IUniverSheetsHyperLinkUIConfig, _injector: Injector, _renderManagerService: IRenderManagerService);
12
- onStarting(injector: Injector): void;
11
+ constructor(_config: Nullable<IUniverSheetsHyperLinkUIConfig>, _injector: Injector, _renderManagerService: IRenderManagerService);
12
+ onStarting(): void;
13
13
  onReady(): void;
14
14
  }
@@ -1,19 +1,27 @@
1
- import { IRange, Worksheet, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { IRange, Nullable, Worksheet, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { IDefinedNamesService } from '@univerjs/engine-formula';
3
3
  import { IMessageService } from '@univerjs/ui';
4
+ import { IUrlHandler } from '../types/interfaces/i-config';
4
5
 
5
6
  interface ISheetUrlParams {
6
7
  gid?: string;
7
8
  range?: string;
8
9
  rangeid?: string;
9
10
  }
11
+ export interface IHyperLinkInfo<T extends string> {
12
+ type: T;
13
+ name: string;
14
+ url: string;
15
+ handler: () => void;
16
+ }
10
17
  export declare class SheetsHyperLinkResolverService {
18
+ private _urlHandler;
11
19
  private _univerInstanceService;
12
20
  private _commandService;
13
21
  private _definedNamesService;
14
22
  private _messageService;
15
23
  private _localeService;
16
- constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _definedNamesService: IDefinedNamesService, _messageService: IMessageService, _localeService: LocaleService);
24
+ constructor(_urlHandler: Nullable<IUrlHandler>, _univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _definedNamesService: IDefinedNamesService, _messageService: IMessageService, _localeService: LocaleService);
17
25
  private _getURLName;
18
26
  navigateTo(params: ISheetUrlParams): void;
19
27
  parseHyperLink(urlStr: string): {
@@ -0,0 +1,46 @@
1
+ import { Disposable } from '@univerjs/core';
2
+ import { ICellHyperLink } from '@univerjs/sheets-hyper-link';
3
+ import { default as React } from 'react';
4
+
5
+ export interface CustomHyperLinkFormProps {
6
+ linkId: string;
7
+ payload: string;
8
+ display: string;
9
+ setByPayload: React.MutableRefObject<boolean>;
10
+ showError: boolean;
11
+ setDisplay: (display: string) => void;
12
+ setPayload: (payload: string) => void;
13
+ }
14
+ export interface ICustomHyperLinkView {
15
+ type: string;
16
+ option: {
17
+ label: string;
18
+ value: string;
19
+ };
20
+ Form: React.FC<CustomHyperLinkFormProps>;
21
+ convert: (link: ICellHyperLink) => {
22
+ display: string;
23
+ payload: string;
24
+ type: string;
25
+ };
26
+ match: (link: ICellHyperLink) => boolean;
27
+ }
28
+ export declare enum LinkType {
29
+ link = "link",
30
+ range = "range",
31
+ sheet = "gid",
32
+ definedName = "rangeid"
33
+ }
34
+ export declare class SheetsHyperLinkSidePanelService extends Disposable {
35
+ private _customHyperLinks;
36
+ isBuiltInLinkType(type: string): boolean;
37
+ getOptions(): {
38
+ label: string;
39
+ value: string;
40
+ }[];
41
+ findCustomHyperLink(link: ICellHyperLink): ICustomHyperLinkView | undefined;
42
+ registerCustomHyperLink(customHyperLink: ICustomHyperLinkView): void;
43
+ getCustomHyperLink(type: string): ICustomHyperLinkView | undefined;
44
+ removeCustomHyperLink(type: string): void;
45
+ dispose(): void;
46
+ }
@@ -0,0 +1,9 @@
1
+ import { MenuConfig } from '@univerjs/ui';
2
+
3
+ export interface IUrlHandler {
4
+ navigateToOtherWebsite?: (url: string) => void;
5
+ }
6
+ export interface IUniverSheetsHyperLinkUIConfig {
7
+ menu?: MenuConfig;
8
+ urlHandler?: IUrlHandler;
9
+ }
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/docs-hyper-link"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula","@univerjs/docs-hyper-link","@univerjs/docs"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l.UniverSheetsHyperLink,l.UniverSheetsUi,l.UniverEngineRender,l.rxjs,l.React,l.clsx,l.UniverDesign,l.UniverUi,l.UniverEngineFormula,l.UniverDocsHyperLink,l.UniverDocs))})(this,function(l,a,h,v,f,pe,ne,C,ke,I,O,D,De,Ae){"use strict";var Gn=Object.defineProperty;var Xn=(l,a,h)=>a in l?Gn(l,a,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[a]=h;var $=(l,a,h)=>Xn(l,typeof a!="symbol"?a+"":a,h);var Ve=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,xe=(i,e,t,n)=>{for(var r=n>1?void 0:n?Be(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Ve(e,t,r),r},he=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===h.RemoveSheetCommand.id){const n=e.params,r=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=n.subUnitId||((t=r.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),d=c.map(S=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:S.id}})),p=c.map(S=>({id:v.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:S}}));return{redos:d,undos:p}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=xe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),he(0,a.Inject(h.SheetInterceptorService)),he(1,a.IUniverInstanceService),he(2,a.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);var We=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Ie=(i,e,t,n)=>{for(var r=n>1?void 0:n?Fe(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&We(e,t,r),r},Y=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,t,n,r){super(),this._context=e,this._hyperLinkModel=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const t=this._context.unit,n=t.getUnitId(),r=(c=t.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(n);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(ne.debounceTime(16)).subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Ie([Y(1,a.Inject(v.HyperLinkModel)),Y(2,a.Inject(f.SheetSkeletonManagerService)),Y(3,pe.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._themeService=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(h.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),p=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Ie([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),Y(0,a.Inject(h.SheetInterceptorService)),Y(1,a.Inject(v.HyperLinkModel)),Y(2,a.Inject(a.ThemeService))],l.SheetsHyperLinkRenderManagerController);var Re={exports:{}},te={};/**
1
+ (function(global,factory){typeof exports=="object"&&typeof module<"u"?factory(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/docs-hyper-link"),require("@univerjs/docs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula","@univerjs/docs-hyper-link","@univerjs/docs"],factory):(global=typeof globalThis<"u"?globalThis:global||self,factory(global.UniverSheetsHyperLinkUi={},global.UniverCore,global.UniverSheets,global.UniverSheetsHyperLink,global.UniverSheetsUi,global.UniverEngineRender,global.rxjs,global.React,global.clsx,global.UniverDesign,global.UniverUi,global.UniverEngineFormula,global.UniverDocsHyperLink,global.UniverDocs))})(this,function(exports2,core,sheets,sheetsHyperLink,sheetsUi,engineRender,rxjs,require$$0,cs,design,ui,engineFormula,docsHyperLink,docs){"use strict";var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);var _a,_b,_c,_d,_e,_f,_g,_h,_i,_j,_k,_l,_m;var __defProp$b=Object.defineProperty,__getOwnPropDesc$b=Object.getOwnPropertyDescriptor,__decorateClass$b=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$b(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$b(target,key,result),result},"__decorateClass$b"),__decorateParam$b=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$b");exports2.SheetsHyperLinkRemoveSheetController=(_a=class extends core.Disposable{constructor(_sheetInterceptorService,_univerInstanceService,_hyperLinkModel){super(),this._sheetInterceptorService=_sheetInterceptorService,this._univerInstanceService=_univerInstanceService,this._hyperLinkModel=_hyperLinkModel,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(commandInfo=>{var _a2;if(commandInfo.id===sheets.RemoveSheetCommand.id){const params=commandInfo.params,workbook=params.unitId?this._univerInstanceService.getUnit(params.unitId):this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return{redos:[],undos:[]};const unitId=workbook.getUnitId(),subUnitId=params.subUnitId||((_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId());if(!subUnitId)return{redos:[],undos:[]};const links=this._hyperLinkModel.getSubUnit(unitId,subUnitId),redos=links.map(link=>({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}})),undos=links.map(link=>({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}));return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}},__name(_a,"SheetsHyperLinkRemoveSheetController"),_a),exports2.SheetsHyperLinkRemoveSheetController=__decorateClass$b([core.OnLifecycle(core.LifecycleStages.Ready,exports2.SheetsHyperLinkRemoveSheetController),__decorateParam$b(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$b(1,core.IUniverInstanceService),__decorateParam$b(2,core.Inject(sheetsHyperLink.HyperLinkModel))],exports2.SheetsHyperLinkRemoveSheetController);var __defProp$a=Object.defineProperty,__getOwnPropDesc$a=Object.getOwnPropertyDescriptor,__decorateClass$a=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$a(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$a(target,key,result),result},"__decorateClass$a"),__decorateParam$a=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$a");exports2.SheetsHyperLinkRenderController=(_b=class extends core.Disposable{constructor(_context,_hyperLinkModel,_sheetSkeletonManagerService,_renderManagerService){super(),this._context=_context,this._hyperLinkModel=_hyperLinkModel,this._sheetSkeletonManagerService=_sheetSkeletonManagerService,this._renderManagerService=_renderManagerService,this._initSkeletonChange()}_initSkeletonChange(){const markSkeletonDirty=__name(()=>{var _a2;const workbook=this._context.unit,unitId=workbook.getUnitId(),subUnitId=(_a2=workbook.getActiveSheet())==null?void 0:_a2.getSheetId();if(!subUnitId){console.warn("No active sheet found");return}const skeleton=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:subUnitId}),currentRender=this._renderManagerService.getRenderById(unitId);skeleton==null||skeleton.makeDirty(!0),skeleton==null||skeleton.calculate(),currentRender&&currentRender.mainComponent.makeForceDirty()},"markSkeletonDirty");this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(rxjs.debounceTime(16)).subscribe(()=>{markSkeletonDirty()}))}},__name(_b,"SheetsHyperLinkRenderController"),_b),exports2.SheetsHyperLinkRenderController=__decorateClass$a([__decorateParam$a(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$a(2,core.Inject(sheetsUi.SheetSkeletonManagerService)),__decorateParam$a(3,engineRender.IRenderManagerService)],exports2.SheetsHyperLinkRenderController),exports2.SheetsHyperLinkRenderManagerController=(_c=class extends core.Disposable{constructor(_sheetInterceptorService,_hyperLinkModel,_themeService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._hyperLinkModel=_hyperLinkModel,this._themeService=_themeService,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(sheets.INTERCEPTOR_POINT.CELL_CONTENT,{handler:__name((cell,pos,next)=>{const{row,col,unitId,subUnitId}=pos,link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col),styleSheet=this._themeService.getCurrentTheme();return next(link?{...cell,interceptorStyle:{ul:{s:core.BooleanNumber.TRUE},cl:{rgb:styleSheet.blue500}}}:cell)},"handler"),priority:100}))}},__name(_c,"SheetsHyperLinkRenderManagerController"),_c),exports2.SheetsHyperLinkRenderManagerController=__decorateClass$a([core.OnLifecycle(core.LifecycleStages.Ready,exports2.SheetsHyperLinkRenderManagerController),__decorateParam$a(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$a(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$a(2,core.Inject(core.ThemeService))],exports2.SheetsHyperLinkRenderManagerController);var LinkType=(LinkType2=>(LinkType2.link="link",LinkType2.range="range",LinkType2.sheet="gid",LinkType2.definedName="rangeid",LinkType2))(LinkType||{});const _SheetsHyperLinkSidePanelService=class _SheetsHyperLinkSidePanelService extends core.Disposable{constructor(){super(...arguments);__publicField(this,"_customHyperLinks",new Map)}isBuiltInLinkType(type){return!!LinkType[type]}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option})=>option)}findCustomHyperLink(link){return Array.from(this._customHyperLinks.values()).find(item=>item.match(link))}registerCustomHyperLink(customHyperLink){this._customHyperLinks.set(customHyperLink.type,customHyperLink)}getCustomHyperLink(type){return this._customHyperLinks.get(type)}removeCustomHyperLink(type){const{_customHyperLinks}=this;_customHyperLinks.delete(type)}dispose(){super.dispose(),this._customHyperLinks.clear()}};__name(_SheetsHyperLinkSidePanelService,"SheetsHyperLinkSidePanelService");let SheetsHyperLinkSidePanelService=_SheetsHyperLinkSidePanelService;var jsxRuntime={exports:{}},reactJsxRuntime_production_min={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var $e=C,Ye=Symbol.for("react.element"),Ke=Symbol.for("react.fragment"),ze=Object.prototype.hasOwnProperty,Ze=$e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0};function Pe(i,e,t){var n,r={},o=null,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)ze.call(e,n)&&!Ge.hasOwnProperty(n)&&(r[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)r[n]===void 0&&(r[n]=e[n]);return{$$typeof:Ye,type:i,key:o,ref:s,props:r,_owner:Ze.current}}te.Fragment=Ke,te.jsx=Pe,te.jsxs=Pe,Re.exports=te;var m=Re.exports,j=function(){return j=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(i[r]=e[r])}return i},j.apply(this,arguments)},Xe=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t},F=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,s=Xe(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=C.useRef("_".concat(qe()));return be(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},j({ref:e,className:c},s),o)});function be(i,e,t,n,r){return C.createElement(i.tag,j(j({key:e},Je(i,t,r)),n),(Qe(i,t).children||[]).map(function(o,s){return be(o,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,r)}))}function Je(i,e,t){var n=j({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var r=e.defIds;return!r||r.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Qe(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?j(j({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?j(j({},r),{attrs:j(j({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function qe(){return Math.random().toString(36).substring(2,8)}F.displayName="UniverIcon";var en={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},re=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"all-border-single",ref:e,icon:en}))});re.displayName="AllBorderSingle";var nn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.02547 12.4251C5.15328 13.7417 6.26305 14.7708 7.61318 14.7708H12.6132C14.0491 14.7708 15.2132 13.6067 15.2132 12.1708V6.1708C15.2132 4.78586 14.1303 3.65383 12.7651 3.57517C12.6373 2.25858 11.5275 1.22949 10.1774 1.22949H5.17739C3.74145 1.22949 2.57739 2.39355 2.57739 3.82949V9.82949C2.57739 11.2144 3.66024 12.3465 5.02547 12.4251ZM11.5535 3.5708H7.61318C6.17724 3.5708 5.01318 4.73486 5.01318 6.1708V11.22C4.31736 11.1387 3.77739 10.5471 3.77739 9.82949V3.82949C3.77739 3.05629 4.40419 2.42949 5.17739 2.42949H10.1774C10.8622 2.42949 11.4322 2.92119 11.5535 3.5708ZM14.0132 6.1708C14.0132 5.3976 13.3864 4.7708 12.6132 4.7708H7.61318C6.83998 4.7708 6.21318 5.3976 6.21318 6.1708V12.1708C6.21318 12.944 6.83998 13.5708 7.61318 13.5708H12.6132C13.3864 13.5708 14.0132 12.944 14.0132 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ee=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"copy-single",ref:e,icon:nn}))});Ee.displayName="CopySingle";var tn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},ie=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"link-single",ref:e,icon:tn}))});ie.displayName="LinkSingle";var rn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},Oe=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"unlink-single",ref:e,icon:rn}))});Oe.displayName="UnlinkSingle";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},Me=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"write-single",ref:e,icon:on}))});Me.displayName="WriteSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.36396 1.12549C2.61066 1.12549 2 1.73615 2 2.48945V13.5104C2 14.2637 2.61066 14.8744 3.36396 14.8744H12.457C13.2103 14.8744 13.821 14.2637 13.821 13.5104V5.0992L9.91954 1.12549H3.36396Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M9.91797 1.12549L13.8209 5.09842H10.5846C10.2164 5.09842 9.91797 4.79994 9.91797 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.71926 10.2949L6.28687 12.403C6.17306 12.5705 5.94501 12.614 5.77751 12.5002C5.61002 12.3864 5.56649 12.1584 5.6803 11.9909L7.27596 9.64252L5.85088 7.54519C5.73707 7.37769 5.78059 7.14964 5.94809 7.03583C6.11558 6.92202 6.34363 6.96555 6.45744 7.13304L7.71926 8.9901L8.98108 7.13304C9.09489 6.96555 9.32294 6.92202 9.49044 7.03583C9.65793 7.14964 9.70146 7.37769 9.58765 7.54519L8.16256 9.64252L9.75822 11.9909C9.87203 12.1584 9.82851 12.3864 9.66101 12.5002C9.49351 12.614 9.26547 12.5705 9.15166 12.403L7.71926 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},me=C.forwardRef(function(i,e){return C.createElement(F,Object.assign({},i,{id:"xlsx",ref:e,icon:sn}))});me.displayName="Xlsx";var an=Object.defineProperty,ln=Object.getOwnPropertyDescriptor,cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?ln(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&an(e,t,r),r},G=(i,e)=>(t,n)=>e(t,n,i);function dn(i,e){const t=e.getMergeData(),n=e.getMaxColumns()-1,r=e.getMaxRows()-1;if(n<i.endColumn&&(i.endColumn=n),r<i.endRow&&(i.endRow=r),i.rangeType===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const p=D.deserializeRangeWithSheet(n).range;return a.isValidRange(p)&&n!==v.ERROR_RANGE?{type:"range",name:D.serializeRangeWithSheet(c,p)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const p=this._definedNamesService.getValueById(o.getUnitId(),r);return p?{type:"defineName",name:p.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const p=o.getSheetBySheetId(t);return p?{type:"sheet",name:p.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=D.deserializeRangeWithSheet(n);a.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(s,t,c.range);return}this.navigateToSheetById(s,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,t,n){const r=await this.navigateToSheetById(e,t);if(r){const o=dn(n,r);await this._commandService.executeCommand(h.SetSelectionsOperation.id,{unitId:e,subUnitId:t,selections:[{range:o}]}),await this._commandService.executeCommand(f.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=n.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(e,t){return this._definedNamesService.focusRange(e,t),!0}async navigateToOtherWebsite(e){window.open(e,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=cn([G(0,a.IUniverInstanceService),G(1,a.ICommandService),G(2,D.IDefinedNamesService),G(3,O.IMessageService),G(4,a.Inject(a.LocaleService))],l.SheetsHyperLinkResolverService);function X(i){return a.Tools.isLegalUrl(i)}function un(i){return/^[a-zA-Z]+:\/\//.test(i)}function pn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function ve(i){if(X(i)){const e=un(i)?i:pn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:e}return i}function hn(i){if(i===null)return"";if(i!=null&&i.p){const e=i==null?void 0:i.p.body;if(e==null)return"";const t=e.dataStream;return t.substring(t.length-2,t.length)===a.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const mn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},oe=()=>{var ee;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[s,c]=C.useState(""),d=a.useDependency(a.LocaleService),p=a.useDependency(D.IDefinedNamesService),S=a.useDependency(a.IUniverInstanceService),_=a.useDependency(l.SheetsHyperLinkPopupService),u=O.useObservable(_.currentEditing$),k=a.useDependency(v.HyperLinkModel),y=a.useDependency(l.SheetsHyperLinkResolverService),L=a.useDependency(a.ICommandService),[R,H]=C.useState(!1),E=C.useRef(!1);C.useEffect(()=>{var g,P,w;if((u==null?void 0:u.row)!==void 0&&u.column!==void 0){const b=k.getHyperLinkByLocationSync(u.unitId,u.subUnitId,u.row,u.column);if(b){const ue=y.parseHyperLink(b.payload);if(e(b.id),n(b.display),ue.type==="outer"){o("link"),c(ue.url),ue.url===b.display&&(E.current=!0);return}else{const V=ue.searchObj;if(V.rangeid){o("rangeid"),c(V.rangeid);return}if(V.range){const Zn=V.gid&&(w=(P=(g=S.getUnit(u.unitId))==null?void 0:g.getSheetBySheetId(V.gid))==null?void 0:P.getName())!=null?w:"";if(o("range"),V.range===v.ERROR_RANGE)c("");else{const Ne=D.serializeRangeWithSheet(Zn,D.deserializeRangeWithSheet(V.range).range);c(Ne),Ne===b.display&&(E.current=!0)}return}if(V.gid){o("gid"),c(V.gid);return}}}const T=S.getUnit(u.unitId),N=T==null?void 0:T.getSheetBySheetId(u.subUnitId),zn=N==null?void 0:N.getCellRaw(u.row,u.column),Le=hn(zn);o("link"),c(""),n((Le!=null?Le:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[u,k,y,S]);const U=C.useMemo(()=>s,[r]),B=[{label:d.t("hyperLink.form.link"),value:"link"},{label:d.t("hyperLink.form.range"),value:"range"},{label:d.t("hyperLink.form.worksheet"),value:"gid"},{label:d.t("hyperLink.form.definedName"),value:"rangeid"}],M=S.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!M)return;const Z=M.getHiddenWorksheets(),x=M.getSheets().map(g=>({label:g.getName(),value:g.getSheetId()})).filter(g=>Z.indexOf(g.value)===-1),W=Object.values((ee=p.getDefinedNameMap(M.getUnitId()))!=null?ee:{}).map(g=>({label:g.name,value:g.id})),q=(g,P)=>{if(g==="link")return ve(P);if(g==="range"){const w=D.deserializeRangeWithSheet(P),b=M.getSheetBySheetName(w.sheetName);if(b)return`#gid=${b.getSheetId()}&range=${D.serializeRange(w.range)}`}return`#${g}=${P}`},_e=O.useEvent(g=>{var b;const P=g[0];if(!P||!a.isValidRange(P.range))return;P.sheetName||(P.sheetName=((b=M.getActiveSheet())==null?void 0:b.getName())||"");const w=D.serializeRangeToRefString(P);c(w),w&&(E.current||!t)&&(n(w),E.current=!0)}),Ce=async()=>{if(u&&(i?await L.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,id:i,payload:{display:t,payload:q(r,s)}}):await L.executeCommand(v.AddHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,link:{id:a.Tools.generateRandomId(),row:u.row,column:u.column,payload:q(r,s),display:t}})),u){await L.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId});const g=1;await L.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-g,0),endRow:u.row+g,startColumn:Math.max(u.column-g,0),endColumn:u.column+g}})}L.executeCommand(J.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:R&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:g=>{n(g),E.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:B,value:r,onChange:g=>{o(g),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:R?s?X(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:s,onChange:g=>{c(g),g&&(E.current||!t||t===s)&&(n(g),E.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:M.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:U,onChange:_e})}),r==="gid"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:x,value:s,onChange:g=>{var b,T;c(g);const P=(b=x.find(N=>N.value===g))==null?void 0:b.label,w=(T=x.find(N=>N.value===s))==null?void 0:T.label;P&&(E.current||!t||t===w)&&(n(P),E.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:R&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:W,value:s,onChange:g=>{var b,T;c(g);const P=(b=W.find(N=>N.value===g))==null?void 0:b.label,w=(T=W.find(N=>N.value===s))==null?void 0:T.label;P&&(E.current||!t||t===w)&&(n(P),E.current=!0)}})}),m.jsxs("div",{className:mn.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{u&&L.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId}),L.executeCommand(J.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!X(s)){H(!0);return}Ce()},children:d.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const se={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:t,subUnitId:n,row:r,column:o}=e,s=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),p=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:p?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:oe.componentKey}}),!0}},J={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},ae={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=h.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(h.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(se.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},ge={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(J.id):e.executeCommand(ae.id)}},A={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},vn={outer:m.jsx(ie,{}),link:m.jsx(ie,{}),sheet:m.jsx(me,{}),range:m.jsx(re,{}),defineName:m.jsx(re,{}),"range-error":m.jsx(re,{}),"sheet-error":m.jsx(me,{})},le=()=>{const i=a.useDependency(l.SheetsHyperLinkPopupService),e=a.useDependency(v.HyperLinkModel),t=a.useDependency(a.ICommandService),n=a.useDependency(O.IMessageService),r=a.useDependency(a.LocaleService),[o,s]=C.useState(null),c=a.useDependency(l.SheetsHyperLinkResolverService);if(C.useEffect(()=>{s(i.currentPopup);const y=i.currentPopup$.subscribe(L=>{s(L)});return()=>{y.unsubscribe()}},[i.currentPopup,i.currentPopup$]),!o)return null;const{unitId:d,subUnitId:p,id:S}=o,_=e.getHyperLink(d,p,S);if(!_)return null;const u=c.parseHyperLink(_.payload),k=u.type.indexOf("error")>-1;return m.jsxs("div",{className:A.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:ke(A.cellLinkContent,{[A.cellLinkContentError]:k}),onClick:u.handler,children:[m.jsx("div",{className:A.cellLinkType,children:vn[u.type]}),m.jsx(I.Tooltip,{showIfEllipsis:!0,title:u.name,children:m.jsx("span",{className:A.cellLinkUrl,children:u.name})})]}),m.jsxs("div",{className:A.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:ke(A.cellLinkOperation,{[A.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(u.type!=="outer"){const y=new URL(window.location.href);y.hash=u.url.slice(1),navigator.clipboard.writeText(y.href)}else navigator.clipboard.writeText(u.url);n.show({content:r.t("hyperLink.message.coped"),type:I.MessageType.Info})}},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(Ee,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:A.cellLinkOperation,onClick:()=>{t.executeCommand(se.id,{unitId:d,subUnitId:p,row:_.row,column:_.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(Me,{})})}),m.jsx("div",{className:A.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:d,subUnitId:p,id:_.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Oe,{})})})]})]})]})};le.componentKey="univer.sheet.cell-link-popup";var gn=Object.defineProperty,Sn=Object.getOwnPropertyDescriptor,yn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Sn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&gn(e,t,r),r},we=(i,e)=>(t,n)=>e(t,n,i);const fn=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;l.SheetsHyperLinkPopupService=class extends a.Disposable{constructor(t,n){super();$(this,"_currentPopup",null);$(this,"_currentPopup$",new ne.Subject);$(this,"currentPopup$",this._currentPopup$.asObservable());$(this,"_currentEditing$",new ne.BehaviorSubject(null));$(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=t,this._sheetCanvasPopManagerService=n,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(t){if(this._currentPopup&&fn(t,this._currentPopup))return;this.hideCurrentPopup();const{unitId:n,subUnitId:r,row:o,col:s}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,s);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:le.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:s,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var t;this._currentPopup&&((t=this._currentPopup.disposable)==null||t.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(t){this._currentEditing$.next(t)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=yn([we(0,a.Inject(v.HyperLinkModel)),we(1,a.Inject(f.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var _n=Object.defineProperty,Cn=Object.getOwnPropertyDescriptor,Ln=(i,e,t,n)=>{for(var r=n>1?void 0:n?Cn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&_n(e,t,r),r},K=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.Disposable{constructor(e,t,n,r,o,s){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._editorBridgeService=s,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:d}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,p)=>{var k,y,L,R,H,E,U;const S=(L=p==null?void 0:p.v)!=null?L:(y=(k=p==null?void 0:p.p)==null?void 0:k.body)==null?void 0:y.dataStream.slice(0,-2),_=(S!=null?S:"").toString(),u=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!u){if(X(_)||(R=p==null?void 0:p.custom)!=null&&R.__link_url){const B=(E=(H=p==null?void 0:p.custom)==null?void 0:H.__link_url)!=null?E:_,M=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:M}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:M,row:c,column:d,display:_,payload:ve(B)}}})}return}(S===""||((U=p==null?void 0:p.custom)==null?void 0:U.__link_url)==="")&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:u.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:u}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.ClearSelectionContentCommand.id||e.id===h.ClearSelectionAllCommand.id||e.id===h.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getCurrentLastSelection(),o=h.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,p)=>{const S=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,p);S&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:S.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:S}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r,o,s,c,d,p;if(e!=null&&e.p){const S=(o=(r=e.p.body)==null?void 0:r.customRanges)==null?void 0:o.find(u=>u.rangeType===a.CustomRangeType.HYPERLINK),_=(s=e.p.resources)==null?void 0:s.find(u=>u.name===De.DOC_HYPER_LINK_PLUGIN);if(S&&_){const u=S.rangeId,k=(p=(d=(c=JSON.parse(_.data))==null?void 0:c.links)==null?void 0:d.find(y=>y.id===u))==null?void 0:p.payload;return n({...e,p:null,v:Ae.getPlainTextFormDocument(e.p),t:a.CellValueType.STRING,custom:{__link_url:k}})}}return n(e)}}))}},l.SheetHyperLinkSetRangeController=Ln([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),K(0,a.Inject(h.SheetInterceptorService)),K(1,a.Inject(a.Injector)),K(2,a.Inject(v.HyperLinkModel)),K(3,a.Inject(h.SheetsSelectionsService)),K(4,a.IUniverInstanceService),K(5,f.IEditorBridgeService)],l.SheetHyperLinkSetRangeController);var kn=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?In(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&kn(e,t,r),r},Q=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ne.debounceTime(200)).subscribe(e=>{var u,k;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(k=(u=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:u.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(e.location.subUnitId))==null?void 0:k.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((y,L,R)=>{a.Rectangle.contains(R,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=y,s=L)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookViewPermission],worksheetTypes:[h.WorksheetViewPermission],rangeTypes:[h.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),p=e.location.unitId,S=e.location.subUnitId,_=this._permissionService.composePermission([new h.WorkbookCopyPermission(p).id,new h.WorksheetCopyPermission(p,S).id]).every(y=>y.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:_})}))}},l.SheetsHyperLinkPopupController=Rn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),Q(0,a.Inject(f.HoverManagerService)),Q(1,a.Inject(l.SheetsHyperLinkPopupService)),Q(2,a.Inject(pe.IRenderManagerService)),Q(3,a.Inject(a.IPermissionService)),Q(4,a.Inject(f.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const Pn=i=>({id:ae.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),bn=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:ge.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:f.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Se={id:ge.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var En=Object.defineProperty,On=Object.getOwnPropertyDescriptor,Mn=(i,e,t,n)=>{for(var r=n>1?void 0:n?On(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&En(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,t,n,r,o,s,c){super(),this._config=e,this._componentManager=t,this._commandService=n,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[le,le.componentKey],[oe,oe.componentKey],[ie,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[se,J,ae,ge].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(Pn(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(bn(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(Se)}},l.SheetsHyperLinkUIController=Mn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),z(1,a.Inject(O.ComponentManager)),z(2,a.ICommandService),z(3,a.Inject(a.LocaleService)),z(4,O.IMenuService),z(5,a.Inject(a.Injector)),z(6,a.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);const ye="SHEET_HYPER_LINK_UI_PLUGIN";var wn=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,Tn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&wn(e,t,r),r},He=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:p}=r,S=f.virtualizeDiscreteRanges([s,c]),[_,u]=S.ranges,{mapFunc:k}=S,y={row:_.startRow,col:_.startColumn},L=f.getAutoFillRepeatRange(_,u),R=[],H=[];return L.forEach(E=>{const U=E.repeatStartCell,B=E.relativeRange,M={startRow:y.row,startColumn:y.col,endColumn:y.col,endRow:y.row},Z={startRow:U.row,startColumn:U.col,endColumn:U.col,endRow:U.row};a.Range.foreach(B,(x,W)=>{const q=a.Rectangle.getPositionRange({startRow:x,startColumn:W,endColumn:W,endRow:x},M),{row:_e,col:Ce}=k(q.startRow,q.startColumn),ee=this._hyperLinkModel.getHyperLinkByLocation(d,p,_e,Ce);if(ee){const g=a.Rectangle.getPositionRange({startRow:x,startColumn:W,endColumn:W,endRow:x},Z),{row:P,col:w}=k(g.startRow,g.startColumn),b=a.Tools.generateRandomId(),T=this._hyperLinkModel.getHyperLinkByLocation(d,p,P,w);T&&R.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:T.id}}),(f.APPLY_TYPE.COPY===o||f.APPLY_TYPE.SERIES===o)&&(R.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:{...ee,id:b,row:P,column:w}}}),H.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:b}})),T&&H.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:T}})}})}),{undos:H,redos:R}},n={id:ye,onFillData:(r,o,s)=>s===f.APPLY_TYPE.COPY||s===f.APPLY_TYPE.ONLY_FORMAT||s===f.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=Tn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),He(0,f.IAutoFillService),He(1,a.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var jn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Nn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Un(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&jn(e,t,r),r},ce=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.Disposable{constructor(t,n,r,o){super();$(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ye,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,o)=>{const{copyType:s=f.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:p,unitId:S,subUnitId:_}=n;return this._generateMutations(p,{copyType:s,pasteType:c,copyRange:d,unitId:S,subUnitId:_})},onPastePlainText:(t,n)=>{if(X(n)){const r=ve(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:p}=f.virtualizeDiscreteRanges([o]),S=[],_=[];return a.Range.foreach(d,(u,k)=>{const{row:y,col:L}=p(u,k),R=this._hyperLinkModel.getHyperLinkByLocation(s,c,y,L);R&&S.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:R.id}});const H=a.Tools.generateRandomId();S.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:H,row:y,column:L,payload:r}}}),_.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:H}}),R&&_.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:R}})}),{redos:S,undos:_}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=f.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:p}=c;d.forEach((S,_)=>{p.forEach((u,k)=>{var L;const y=this._hyperLinkModel.getHyperLinkByLocation(t,n,S,u);o.setValue(_,k,(L=y==null?void 0:y.id)!=null?L:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,f.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,s=[],c=[],{ranges:[d,p],mapFunc:S}=f.virtualizeDiscreteRanges([n.copyRange,t]);return f.getRepeatRange(d,p,!0).forEach(({startRange:u})=>{var k;(k=this._copyInfo)==null||k.matrix.forValue((y,L,R)=>{const H=a.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:L,endColumn:L},u),E=this._hyperLinkModel.getHyperLink(r,o,R),{row:U,col:B}=S(H.startRow,H.startColumn),M=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,U,B),Z=a.Tools.generateRandomId();M&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:M.id}}),E&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...E,id:Z,row:U,column:B}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:Z}})),M&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:M}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=Nn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),ce(0,f.ISheetClipboardService),ce(1,a.Inject(v.HyperLinkModel)),ce(2,a.Inject(a.Injector)),ce(3,a.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Dn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?An(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Dn(e,t,r),r},Bn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Vn([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Bn(0,a.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var xn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,Fn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&xn(e,t,r),r},fe=(i,e)=>(t,n)=>e(t,n,i);let de=class extends a.Disposable{constructor(i,e,t){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===Se.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[h.WorkbookEditablePermission],rangeTypes:[h.RangeProtectionPermissionEditPoint],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};de=Fn([a.OnLifecycle(a.LifecycleStages.Rendered,de),fe(0,a.Inject(a.LocaleService)),fe(1,a.ICommandService),fe(2,a.Inject(f.SheetPermissionInterceptorBaseController))],de);var Te=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Yn=(i,e,t)=>e in i?Te(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Kn=(i,e,t,n)=>{for(var r=n>1?void 0:n?$n(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Te(e,t,r),r},je=(i,e)=>(t,n)=>e(t,n,i),Ue=(i,e,t)=>Yn(i,typeof e!="symbol"?e+"":e,t);l.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,t,n){super(),this._config=e,this._injector=t,this._renderManagerService=n}onStarting(e){[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRenderManagerController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[de],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n))}onReady(){[[l.SheetsHyperLinkRenderController]].forEach(t=>this._renderManagerService.registerRenderModule(a.UniverInstanceType.UNIVER_SHEET,t))}},Ue(l.UniverSheetsHyperLinkUIPlugin,"pluginName",ye),Ue(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=Kn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),je(1,a.Inject(a.Injector)),je(2,pe.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=J,l.InsertHyperLinkOperation=ae,l.InsertLinkShortcut=Se,l.OpenHyperLinkSidebarOperation=se,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
9
+ */var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function q(c,a,g){var b,d={},e=null,h=null;g!==void 0&&(e=""+g),a.key!==void 0&&(e=""+a.key),a.ref!==void 0&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)d[b]===void 0&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__name(q,"q"),reactJsxRuntime_production_min.Fragment=l,reactJsxRuntime_production_min.jsx=q,reactJsxRuntime_production_min.jsxs=q,jsxRuntime.exports=reactJsxRuntime_production_min;var jsxRuntimeExports=jsxRuntime.exports,__assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n2=arguments.length;i<n2;i++){s=arguments[i];for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&(t[p2]=s[p2])}return t},__assign.apply(this,arguments)},__rest=function(s,e){var t={};for(var p2 in s)Object.prototype.hasOwnProperty.call(s,p2)&&e.indexOf(p2)<0&&(t[p2]=s[p2]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p2=Object.getOwnPropertySymbols(s);i<p2.length;i++)e.indexOf(p2[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p2[i])&&(t[p2[i]]=s[p2[i]]);return t},IconBase=require$$0.forwardRef(function(props,ref){var icon=props.icon,id=props.id,className=props.className,extend=props.extend,restProps=__rest(props,["icon","id","className","extend"]),cls="univerjs-icon univerjs-icon-".concat(id," ").concat(className||"").trim(),idSuffix=require$$0.useRef("_".concat(generateShortUuid()));return render(icon,"".concat(id),{defIds:icon.defIds,idSuffix:idSuffix.current},__assign({ref,className:cls},restProps),extend)});function render(node,id,runtimeProps,rootProps,extend){return require$$0.createElement(node.tag,__assign(__assign({key:id},replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend)),rootProps),(replaceRuntimeIdsInDefs(node,runtimeProps).children||[]).map(function(child,index){return render(child,"".concat(id,"-").concat(node.tag,"-").concat(index),runtimeProps,void 0,extend)}))}__name(render,"render");function replaceRuntimeIdsAndExtInAttrs(node,runtimeProps,extend){var attrs=__assign({},node.attrs);extend!=null&&extend.colorChannel1&&attrs.fill==="colorChannel1"&&(attrs.fill=extend.colorChannel1);var defIds=runtimeProps.defIds;return!defIds||defIds.length===0||(node.tag==="use"&&attrs["xlink:href"]&&(attrs["xlink:href"]=attrs["xlink:href"]+runtimeProps.idSuffix),Object.entries(attrs).forEach(function(_a2){var key=_a2[0],value=_a2[1];typeof value=="string"&&(attrs[key]=value.replace(/url\(#(.*)\)/,"url(#$1".concat(runtimeProps.idSuffix,")")))})),attrs}__name(replaceRuntimeIdsAndExtInAttrs,"replaceRuntimeIdsAndExtInAttrs");function replaceRuntimeIdsInDefs(node,runtimeProps){var _a2,defIds=runtimeProps.defIds;return!defIds||defIds.length===0?node:node.tag==="defs"&&(!((_a2=node.children)===null||_a2===void 0)&&_a2.length)?__assign(__assign({},node),{children:node.children.map(function(child){return typeof child.attrs.id=="string"&&defIds&&defIds.indexOf(child.attrs.id)>-1?__assign(__assign({},child),{attrs:__assign(__assign({},child.attrs),{id:child.attrs.id+runtimeProps.idSuffix})}):child})}):node}__name(replaceRuntimeIdsInDefs,"replaceRuntimeIdsInDefs");function generateShortUuid(){return Math.random().toString(36).substring(2,8)}__name(generateShortUuid,"generateShortUuid"),IconBase.displayName="UniverIcon";var element$5={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M7.9999 1.12915C8.03875 1.12915 8.07673 1.13284 8.11352 1.13989H12.2599C13.6958 1.13989 14.8599 2.30395 14.8599 3.73989V7.88619C14.867 7.92301 14.8707 7.96102 14.8707 7.9999C14.8707 8.03878 14.867 8.0768 14.8599 8.11362V12.2599C14.8599 13.6958 13.6958 14.8599 12.2599 14.8599H8.11362C8.0768 14.867 8.03878 14.8707 7.9999 14.8707C7.96102 14.8707 7.92301 14.867 7.88619 14.8599H3.73989C2.30396 14.8599 1.13989 13.6958 1.13989 12.2599V8.11352C1.13284 8.07673 1.12915 8.03875 1.12915 7.9999C1.12915 7.96106 1.13284 7.92308 1.13989 7.88629V3.73989C1.13989 2.30396 2.30395 1.13989 3.73989 1.13989H7.88629C7.92308 1.13284 7.96106 1.12915 7.9999 1.12915ZM2.33989 8.5999V12.2599C2.33989 13.0331 2.9667 13.6599 3.73989 13.6599H7.3999V8.5999H2.33989ZM7.3999 7.3999H2.33989V3.73989C2.33989 2.9667 2.96669 2.33989 3.73989 2.33989H7.3999V7.3999ZM8.5999 8.5999V13.6599H12.2599C13.0331 13.6599 13.6599 13.0331 13.6599 12.2599V8.5999H8.5999ZM13.6599 7.3999H8.5999V2.33989H12.2599C13.0331 2.33989 13.6599 2.96669 13.6599 3.73989V7.3999Z",fillRule:"evenodd",clipRule:"evenodd"}}]},AllBorderSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"all-border-single",ref,icon:element$5}))});AllBorderSingle.displayName="AllBorderSingle";var element$4={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},CopySingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"copy-single",ref,icon:element$4}))});CopySingle.displayName="CopySingle";var element$3={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.9564 2.91332C4.91407 1.87102 3.22413 1.87101 2.18182 2.91333L2.18182 2.91333C1.13953 3.95567 1.13952 5.6456 2.18182 6.68791L8.27777 12.7838C9.72408 14.2302 12.069 14.2302 13.5154 12.7839L13.0911 12.3596L13.5154 12.7839C14.9617 11.3375 14.9617 8.99257 13.5154 7.54626L8.39476 2.42566C8.16044 2.19134 7.78054 2.19134 7.54623 2.42566C7.31191 2.65997 7.31191 3.03987 7.54623 3.27419L12.6668 8.39479L13.0911 7.97052L12.6668 8.39479C13.6445 9.37247 13.6445 10.9576 12.6668 11.9353L13.0399 12.3084L12.6668 11.9353C11.6891 12.913 10.104 12.913 9.1263 11.9353L3.03035 5.83938C2.45668 5.26571 2.45667 4.33556 3.03036 3.76184C3.60403 3.18818 4.53416 3.18817 5.10788 3.76185C5.10788 3.76186 5.10788 3.76186 5.10789 3.76186L11.2038 9.8578L11.601 9.46061L11.2038 9.8578C11.3735 10.0275 11.3735 10.3026 11.2038 10.4723L11.2038 10.4723C11.0341 10.642 10.759 10.642 10.5893 10.4723L5.46874 5.35171C5.23442 5.1174 4.85452 5.1174 4.62021 5.35171C4.38589 5.58602 4.38589 5.96592 4.62021 6.20024L9.74078 11.3208C10.3791 11.9591 11.414 11.9591 12.0523 11.3208C12.0523 11.3208 12.0523 11.3208 12.0523 11.3208M12.0523 11.3208C12.6907 10.6825 12.6906 9.64757 12.0523 9.00927L5.95641 2.91333L5.9564 2.91332",fillRule:"evenodd",clipRule:"evenodd"}}]},LinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"link-single",ref,icon:element$3}))});LinkSingle.displayName="LinkSingle";var element$2={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.5935 3.47302C11.6354 2.51492 10.082 2.51492 9.12388 3.47302L7.83534 4.76157C7.60102 4.99588 7.22112 4.99588 6.98681 4.76157 6.75249 4.52725 6.75249 4.14735 6.98681 3.91304L8.27535 2.62449C9.70209 1.19776 12.0153 1.19776 13.442 2.62449 14.8688 4.05123 14.8688 6.36442 13.442 7.79116L12.1535 9.0797C11.9192 9.31402 11.5393 9.31402 11.3049 9.0797 11.0706 8.84539 11.0706 8.46549 11.3049 8.23117L12.5935 6.94263C13.5516 5.98452 13.5516 4.43113 12.5935 3.47302zM3.40637 12.6606C2.44827 11.7025 2.44827 10.1491 3.40637 9.19102L4.69492 7.90248C4.92923 7.66816 4.92923 7.28826 4.69492 7.05395 4.4606 6.81963 4.0807 6.81963 3.84639 7.05395L2.55784 8.34249C1.13111 9.76923 1.13111 12.0824 2.55784 13.5092 3.98458 14.9359 6.29777 14.9359 7.72451 13.5092L9.01305 12.2206C9.24737 11.9863 9.24737 11.6064 9.01305 11.3721 8.77874 11.1378 8.39884 11.1378 8.16452 11.3721L6.87598 12.6606C5.91787 13.6187 4.36448 13.6187 3.40637 12.6606zM3.5852 2.80332C3.35088 2.569 2.97098 2.569 2.73667 2.80332 2.50235 3.03763 2.50235 3.41753 2.73667 3.65185L12.4151 13.3302C12.6494 13.5646 13.0293 13.5646 13.2636 13.3302 13.4979 13.0959 13.4979 12.716 13.2636 12.4817L3.5852 2.80332z"}}]},UnlinkSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"unlink-single",ref,icon:element$2}))});UnlinkSingle.displayName="UnlinkSingle";var element$1={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M12.6551 1.98906C11.7476 1.08113 10.2757 1.08149 9.3686 1.98987L4.82542 6.53955C4.75087 6.61421 4.69336 6.70411 4.65682 6.80309L3.2461 10.625C3.16506 10.8446 3.21909 11.0912 3.3845 11.2568C3.54991 11.4224 3.79651 11.4767 4.01616 11.3959L7.85031 9.98517C7.94979 9.94856 8.04014 9.89077 8.11508 9.81579L12.6552 5.27327C13.5618 4.36621 13.5618 2.89607 12.6551 1.98906ZM10.2177 2.83779C10.6562 2.39869 11.3677 2.39851 11.8064 2.8374C12.2447 3.27584 12.2447 3.9865 11.8065 4.42497L7.3392 8.89457L4.82213 9.82068L5.74706 7.31487L10.2177 2.83779Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.79238 13.2999C1.46101 13.2999 1.19238 13.5685 1.19238 13.8999C1.19238 14.2313 1.46101 14.4999 1.79238 14.4999H14.4924C14.8238 14.4999 15.0924 14.2313 15.0924 13.8999C15.0924 13.5685 14.8238 13.2999 14.4924 13.2999H1.79238Z"}}]},WriteSingle=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"write-single",ref,icon:element$1}))});WriteSingle.displayName="WriteSingle";var element={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Xlsx=require$$0.forwardRef(function(props,ref){return require$$0.createElement(IconBase,Object.assign({},props,{id:"xlsx",ref,icon:element}))});Xlsx.displayName="Xlsx";var __defProp$9=Object.defineProperty,__getOwnPropDesc$9=Object.getOwnPropertyDescriptor,__decorateClass$9=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$9(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$9(target,key,result),result},"__decorateClass$9"),__decorateParam$9=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$9");function getContainRange(range,worksheet){const mergedCells=worksheet.getMergeData(),maxCol=worksheet.getMaxColumns()-1,maxRow=worksheet.getMaxRows()-1;if(maxCol<range.endColumn&&(range.endColumn=maxCol),maxRow<range.endRow&&(range.endRow=maxRow),range.rangeType===core.RANGE_TYPE.COLUMN||core.RANGE_TYPE.ROW)return range;const relativeCells=[];return mergedCells.forEach(cell=>{core.Rectangle.intersects(range,cell)&&relativeCells.push(cell)}),core.Rectangle.realUnion(range,...relativeCells)}__name(getContainRange,"getContainRange"),exports2.SheetsHyperLinkResolverService=(_d=class{constructor(_urlHandler,_univerInstanceService,_commandService,_definedNamesService,_messageService,_localeService){this._urlHandler=_urlHandler,this._univerInstanceService=_univerInstanceService,this._commandService=_commandService,this._definedNamesService=_definedNamesService,this._messageService=_messageService,this._localeService=_localeService}_getURLName(params){var _a2;const{gid,range,rangeid}=params,workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return null;const sheet=gid?workbook.getSheetBySheetId(gid):workbook.getActiveSheet(),sheetName=(_a2=sheet==null?void 0:sheet.getName())!=null?_a2:"";if(range){const rangeObj=engineFormula.deserializeRangeWithSheet(range).range;return core.isValidRange(rangeObj)&&range!==sheetsHyperLink.ERROR_RANGE?{type:"range",name:engineFormula.serializeRangeWithSheet(sheetName,rangeObj)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(rangeid){const range2=this._definedNamesService.getValueById(workbook.getUnitId(),rangeid);return range2?{type:"defineName",name:range2.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(gid){const worksheet=workbook.getSheetBySheetId(gid);return worksheet?{type:"sheet",name:worksheet.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(params){const{gid,range,rangeid}=params,workbook=this._univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const unitId=workbook.getUnitId();if(rangeid&&this.navigateToDefineName(unitId,rangeid),!!gid){if(range){const rangeInfo=engineFormula.deserializeRangeWithSheet(range);core.isValidRange(rangeInfo.range)&&range!==sheetsHyperLink.ERROR_RANGE&&this.navigateToRange(unitId,gid,rangeInfo.range);return}this.navigateToSheetById(unitId,gid)}}parseHyperLink(urlStr){var _a2,_b2,_c2;if(urlStr!=null&&urlStr.startsWith("#")){const search=new URLSearchParams(urlStr.slice(1)),searchObj={gid:(_a2=search.get("gid"))!=null?_a2:"",range:(_b2=search.get("range"))!=null?_b2:"",rangeid:(_c2=search.get("rangeid"))!=null?_c2:""},urlInfo=this._getURLName(searchObj);return{type:(urlInfo==null?void 0:urlInfo.type)||"link",name:(urlInfo==null?void 0:urlInfo.name)||urlStr,url:urlStr,searchObj,handler:__name(()=>{this.navigateTo(searchObj)},"handler")}}else return{type:"outer",name:urlStr,url:urlStr,handler:__name(()=>{this.navigateToOtherWebsite(urlStr)},"handler")}}async navigateToRange(unitId,subUnitId,range){const worksheet=await this.navigateToSheetById(unitId,subUnitId);if(worksheet){const realRange=getContainRange(range,worksheet);await this._commandService.executeCommand(sheets.SetSelectionsOperation.id,{unitId,subUnitId,selections:[{range:realRange}]}),await this._commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:realRange})}}async navigateToSheet(unitId,sheetName){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if((worksheet==null?void 0:worksheet.getName())===sheetName)return!0;const targetSheet=workbook.getSheetBySheetName(sheetName);if(!targetSheet){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error});return}const sheetId=targetSheet.getSheetId();return workbook.getHiddenWorksheets().indexOf(sheetId)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId:sheetId})}async navigateToSheetById(unitId,subUnitId){const workbook=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return!1;const worksheet=workbook.getActiveSheet();if(!worksheet)return!1;if(worksheet.getSheetId()===subUnitId)return worksheet;const targetSheet=workbook.getSheetBySheetId(subUnitId);return targetSheet?workbook.getHiddenWorksheets().indexOf(subUnitId)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:design.MessageType.Error}),!1):await this._commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId,subUnitId})?targetSheet:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:design.MessageType.Error}),!1)}async navigateToDefineName(unitId,rangeid){return this._definedNamesService.focusRange(unitId,rangeid),!0}async navigateToOtherWebsite(url){var _a2;if((_a2=this._urlHandler)!=null&&_a2.navigateToOtherWebsite)return this._urlHandler.navigateToOtherWebsite(url);window.open(url,"_blank","noopener noreferrer")}},__name(_d,"SheetsHyperLinkResolverService"),_d),exports2.SheetsHyperLinkResolverService=__decorateClass$9([__decorateParam$9(1,core.IUniverInstanceService),__decorateParam$9(2,core.ICommandService),__decorateParam$9(3,engineFormula.IDefinedNamesService),__decorateParam$9(4,ui.IMessageService),__decorateParam$9(5,core.Inject(core.LocaleService))],exports2.SheetsHyperLinkResolverService);function isLegalLink(link){return core.Tools.isLegalUrl(link)}__name(isLegalLink,"isLegalLink");function hasProtocol(urlString){return/^[a-zA-Z]+:\/\//.test(urlString)}__name(hasProtocol,"hasProtocol");function isEmail(url){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(url)}__name(isEmail,"isEmail");function serializeUrl(urlStr){if(isLegalLink(urlStr)){const transformedUrl=hasProtocol(urlStr)?urlStr:isEmail(urlStr)?`mailto://${urlStr}`:`http://${urlStr}`;let url;try{url=new URL(transformedUrl)}catch{return urlStr}return url.hostname===location.hostname&&url.port===location.port&&url.protocol===location.protocol&&url.pathname===location.pathname&&url.hash&&!url.search?url.hash:transformedUrl}return urlStr}__name(serializeUrl,"serializeUrl");function getCellValueOrigin(cell){if(cell===null)return"";if(cell!=null&&cell.p){const body=cell==null?void 0:cell.p.body;if(body==null)return"";const data=body.dataStream;return data.substring(data.length-2,data.length)===core.DEFAULT_EMPTY_DOCUMENT_VALUE?data.substring(0,data.length-2):data}return cell==null?void 0:cell.v}__name(getCellValueOrigin,"getCellValueOrigin");const styles$1={cellLinkEditButtons:"univer-cell-link-edit-buttons"},CellLinkEdit=__name(()=>{var _a2;const[id,setId]=require$$0.useState(""),[display,setDisplay]=require$$0.useState(""),[type,setType]=require$$0.useState(LinkType.link),[payload,setPayload]=require$$0.useState(""),localeService=core.useDependency(core.LocaleService),definedNameService=core.useDependency(engineFormula.IDefinedNamesService),univerInstanceService=core.useDependency(core.IUniverInstanceService),popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),editing=ui.useObservable(popupService.currentEditing$),hyperLinkModel=core.useDependency(sheetsHyperLink.HyperLinkModel),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService),commandService=core.useDependency(core.ICommandService),sidePanelService=core.useDependency(SheetsHyperLinkSidePanelService),sidePanelOptions=require$$0.useMemo(()=>sidePanelService.getOptions(),[sidePanelService]),customHyperLinkSidePanel=require$$0.useMemo(()=>{if(!sidePanelService.isBuiltInLinkType(type))return sidePanelService.getCustomHyperLink(type)},[sidePanelService,type]),[showError,setShowError]=require$$0.useState(!1),setByPayload=require$$0.useRef(!1);require$$0.useEffect(()=>{var _a3,_b2,_c2;if((editing==null?void 0:editing.row)!==void 0&&editing.column!==void 0){const link=hyperLinkModel.getHyperLinkByLocationSync(editing.unitId,editing.subUnitId,editing.row,editing.column);if(link){setId(link.id);const customLink=sidePanelService.findCustomHyperLink(link);if(customLink){const customLinkInfo=customLink.convert(link);setType(customLinkInfo.type),setPayload(customLinkInfo.payload),setDisplay(customLinkInfo.display);return}setDisplay(link.display);const linkInfo=resolverService.parseHyperLink(link.payload);if(linkInfo.type==="outer"){setType(LinkType.link),setPayload(linkInfo.url),linkInfo.url===link.display&&(setByPayload.current=!0);return}else{const params=linkInfo.searchObj;if(params.rangeid){setType(LinkType.definedName),setPayload(params.rangeid);return}if(params.range){const sheetName=params.gid&&(_c2=(_b2=(_a3=univerInstanceService.getUnit(editing.unitId))==null?void 0:_a3.getSheetBySheetId(params.gid))==null?void 0:_b2.getName())!=null?_c2:"";if(setType(LinkType.range),params.range===sheetsHyperLink.ERROR_RANGE)setPayload("");else{const payload2=engineFormula.serializeRangeWithSheet(sheetName,engineFormula.deserializeRangeWithSheet(params.range).range);setPayload(payload2),payload2===link.display&&(setByPayload.current=!0)}return}if(params.gid){setType(LinkType.sheet),setPayload(params.gid);return}}}const workbook2=univerInstanceService.getUnit(editing.unitId),worksheet=workbook2==null?void 0:workbook2.getSheetBySheetId(editing.subUnitId),cell=worksheet==null?void 0:worksheet.getCellRaw(editing.row,editing.column),cellValue=getCellValueOrigin(cell);setType(LinkType.link),setPayload(""),setDisplay((cellValue!=null?cellValue:"").toString()),setId("");return}setType(LinkType.link),setPayload(""),setDisplay(""),setId("")},[editing,hyperLinkModel,resolverService,univerInstanceService]);const payloadInitial=require$$0.useMemo(()=>payload,[type]),linkTypeOptions=[{label:localeService.t("hyperLink.form.link"),value:LinkType.link},{label:localeService.t("hyperLink.form.range"),value:LinkType.range},{label:localeService.t("hyperLink.form.worksheet"),value:LinkType.sheet},{label:localeService.t("hyperLink.form.definedName"),value:LinkType.definedName},...sidePanelOptions],workbook=univerInstanceService.getCurrentUnitForType(core.UniverInstanceType.UNIVER_SHEET);if(!workbook)return;const hiddens=workbook.getHiddenWorksheets(),sheetsOption=workbook.getSheets().map(sheet=>({label:sheet.getName(),value:sheet.getSheetId()})).filter(opt=>hiddens.indexOf(opt.value)===-1),definedNames=Object.values((_a2=definedNameService.getDefinedNameMap(workbook.getUnitId()))!=null?_a2:{}).map(value=>({label:value.name,value:value.id})),formatUrl=__name((type2,payload2)=>{if(type2===LinkType.link)return serializeUrl(payload2);if(type2===LinkType.range){const info=engineFormula.deserializeRangeWithSheet(payload2),worksheet=workbook.getSheetBySheetName(info.sheetName);if(worksheet)return`#gid=${worksheet.getSheetId()}&range=${engineFormula.serializeRange(info.range)}`}return`#${type2}=${payload2}`},"formatUrl"),handleRangeChange=ui.useEvent(newValue=>{var _a3;const range=newValue[0];if(!range||!core.isValidRange(range.range))return;range.sheetName||(range.sheetName=((_a3=workbook.getActiveSheet())==null?void 0:_a3.getName())||"");const newPayload=engineFormula.serializeRangeToRefString(range);setPayload(newPayload),newPayload&&(setByPayload.current||!display)&&(setDisplay(newPayload),setByPayload.current=!0)}),handleSubmit=__name(async()=>{if(editing&&(id?await commandService.executeCommand(sheetsHyperLink.UpdateHyperLinkCommand.id,{unitId:editing.unitId,subUnitId:editing.subUnitId,id,payload:{display,payload:formatUrl(type,payload)}}):await commandService.executeCommand(sheetsHyperLink.AddHyperLinkCommand.id,{unitId:editing.unitId,subUnitId:editing.subUnitId,link:{id:core.Tools.generateRandomId(),row:editing.row,column:editing.column,payload:formatUrl(type,payload),display}})),editing){await commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId});const GAP=1;await commandService.executeCommand(sheetsUi.ScrollToRangeOperation.id,{range:{startRow:Math.max(editing.row-GAP,0),endRow:editing.row+GAP,startColumn:Math.max(editing.column-GAP,0),endColumn:editing.column+GAP}})}commandService.executeCommand(CloseHyperLinkSidebarOperation.id)},"handleSubmit");return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.label"),error:showError&&!display?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:display,onChange:__name(v=>{setDisplay(v),setByPayload.current=!1},"onChange"),placeholder:localeService.t("hyperLink.form.labelPlaceholder")})}),jsxRuntimeExports.jsx(design.FormLayout,{label:localeService.t("hyperLink.form.type"),children:jsxRuntimeExports.jsx(design.Select,{options:linkTypeOptions,value:type,onChange:__name(newType=>{setType(newType),setPayload("")},"onChange")})}),type===LinkType.link&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError?payload?isLegalLink(payload)?"":localeService.t("hyperLink.form.linkError"):localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(design.Input,{value:payload,onChange:__name(newLink=>{setPayload(newLink),newLink&&(setByPayload.current||!display||display===payload)&&(setDisplay(newLink),setByPayload.current=!0)},"onChange"),placeholder:localeService.t("hyperLink.form.linkPlaceholder")})}),type===LinkType.range&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.inputError"):"",children:jsxRuntimeExports.jsx(ui.RangeSelector,{openForSheetUnitId:workbook.getUnitId(),id:core.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:payloadInitial,onChange:handleRangeChange})}),type===LinkType.sheet&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:sheetsOption,value:payload,onChange:__name(newPayload=>{var _a3,_b2;setPayload(newPayload);const label=(_a3=sheetsOption.find(i=>i.value===newPayload))==null?void 0:_a3.label,oldLabel=(_b2=sheetsOption.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),type===LinkType.definedName&&jsxRuntimeExports.jsx(design.FormLayout,{error:showError&&!payload?localeService.t("hyperLink.form.selectError"):"",children:jsxRuntimeExports.jsx(design.Select,{options:definedNames,value:payload,onChange:__name(newValue=>{var _a3,_b2;setPayload(newValue);const label=(_a3=definedNames.find(i=>i.value===newValue))==null?void 0:_a3.label,oldLabel=(_b2=definedNames.find(i=>i.value===payload))==null?void 0:_b2.label;label&&(setByPayload.current||!display||display===oldLabel)&&(setDisplay(label),setByPayload.current=!0)},"onChange")})}),(customHyperLinkSidePanel==null?void 0:customHyperLinkSidePanel.Form)&&jsxRuntimeExports.jsx(customHyperLinkSidePanel.Form,{linkId:id,payload,display,showError,setByPayload,setDisplay:__name(newLink=>{setDisplay(newLink),setByPayload.current=!0},"setDisplay"),setPayload}),jsxRuntimeExports.jsxs("div",{className:styles$1.cellLinkEditButtons,children:[jsxRuntimeExports.jsx(design.Button,{onClick:__name(()=>{editing&&commandService.executeCommand(sheets.SetWorksheetActiveOperation.id,{unitId:editing.unitId,subUnitId:editing.subUnitId}),commandService.executeCommand(CloseHyperLinkSidebarOperation.id)},"onClick"),children:localeService.t("hyperLink.form.cancel")}),jsxRuntimeExports.jsx(design.Button,{type:"primary",style:{marginLeft:8},onClick:__name(async()=>{if(!display||!payload||type===LinkType.link&&!isLegalLink(payload)){setShowError(!0);return}handleSubmit()},"onClick"),children:localeService.t("hyperLink.form.ok")})]})]})},"CellLinkEdit");CellLinkEdit.componentKey="univer.sheet.cell-link-edit";const OpenHyperLinkSidebarOperation={type:core.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(accessor,params){if(!params)return!1;const{unitId,subUnitId,row,column}=params,hyperLinkModel=accessor.get(sheetsHyperLink.HyperLinkModel),sidebarService=accessor.get(ui.ISidebarService),popupService=accessor.get(exports2.SheetsHyperLinkPopupService),currentLink=hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);return popupService.startEditing(params),sidebarService.open({header:{title:currentLink?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:CellLinkEdit.componentKey}}),!0}},CloseHyperLinkSidebarOperation={type:core.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(accessor){const sidebarService=accessor.get(ui.ISidebarService),popupService=accessor.get(exports2.SheetsHyperLinkPopupService);return sidebarService.close(),popupService.endEditing(),!0}},InsertHyperLinkOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(accessor){const univerInstanceService=accessor.get(core.IUniverInstanceService),target=sheets.getSheetCommandTarget(univerInstanceService);if(!target)return!1;const commandService=accessor.get(core.ICommandService),selection=accessor.get(sheets.SheetsSelectionsService).getCurrentLastSelection();if(!selection)return!1;const row=selection.primary.startRow,column=selection.primary.startColumn;return commandService.executeCommand(OpenHyperLinkSidebarOperation.id,{unitId:target.unitId,subUnitId:target.subUnitId,row,column})}},InsertHyperLinkToolbarOperation={type:core.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(accessor){const commandService=accessor.get(core.ICommandService);return accessor.get(exports2.SheetsHyperLinkPopupService).currentEditing?commandService.executeCommand(CloseHyperLinkSidebarOperation.id):commandService.executeCommand(InsertHyperLinkOperation.id)}},styles={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},iconsMap={outer:jsxRuntimeExports.jsx(LinkSingle,{}),link:jsxRuntimeExports.jsx(LinkSingle,{}),sheet:jsxRuntimeExports.jsx(Xlsx,{}),range:jsxRuntimeExports.jsx(AllBorderSingle,{}),defineName:jsxRuntimeExports.jsx(AllBorderSingle,{}),"range-error":jsxRuntimeExports.jsx(AllBorderSingle,{}),"sheet-error":jsxRuntimeExports.jsx(Xlsx,{})},CellLinkPopup=__name(()=>{const popupService=core.useDependency(exports2.SheetsHyperLinkPopupService),hyperLinkModel=core.useDependency(sheetsHyperLink.HyperLinkModel),commandService=core.useDependency(core.ICommandService),messageService=core.useDependency(ui.IMessageService),localeService=core.useDependency(core.LocaleService),[currentPopup,setCurrentPopup]=require$$0.useState(null),resolverService=core.useDependency(exports2.SheetsHyperLinkResolverService);if(require$$0.useEffect(()=>{setCurrentPopup(popupService.currentPopup);const ob=popupService.currentPopup$.subscribe(popup=>{setCurrentPopup(popup)});return()=>{ob.unsubscribe()}},[popupService.currentPopup,popupService.currentPopup$]),!currentPopup)return null;const{unitId,subUnitId,id}=currentPopup,link=hyperLinkModel.getHyperLink(unitId,subUnitId,id);if(!link)return null;const linkObj=resolverService.parseHyperLink(link.payload),isError=linkObj.type.indexOf("error")>-1;return jsxRuntimeExports.jsxs("div",{className:styles.cellLink,onClick:__name(()=>popupService.hideCurrentPopup(),"onClick"),children:[jsxRuntimeExports.jsxs("div",{className:cs(styles.cellLinkContent,{[styles.cellLinkContentError]:isError}),onClick:linkObj.handler,children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkType,children:iconsMap[linkObj.type]}),jsxRuntimeExports.jsx(design.Tooltip,{showIfEllipsis:!0,title:linkObj.name,children:jsxRuntimeExports.jsx("span",{className:styles.cellLinkUrl,children:linkObj.name})})]}),jsxRuntimeExports.jsxs("div",{className:styles.cellLinkOperations,children:[currentPopup.copyPermission&&jsxRuntimeExports.jsx("div",{className:cs(styles.cellLinkOperation,{[styles.cellLinkOperationError]:isError}),onClick:__name(()=>{if(!isError){if(linkObj.type!=="outer"){const url=new URL(window.location.href);url.hash=linkObj.url.slice(1),navigator.clipboard.writeText(url.href)}else navigator.clipboard.writeText(linkObj.url);messageService.show({content:localeService.t("hyperLink.message.coped"),type:design.MessageType.Info})}},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.copy"),children:jsxRuntimeExports.jsx(CopySingle,{})})}),currentPopup.editPermission&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{commandService.executeCommand(OpenHyperLinkSidebarOperation.id,{unitId,subUnitId,row:link.row,column:link.column})},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.edit"),children:jsxRuntimeExports.jsx(WriteSingle,{})})}),jsxRuntimeExports.jsx("div",{className:styles.cellLinkOperation,onClick:__name(()=>{commandService.executeCommand(sheetsHyperLink.CancelHyperLinkCommand.id,{unitId,subUnitId,id:link.id})},"onClick"),children:jsxRuntimeExports.jsx(design.Tooltip,{placement:"bottom",title:localeService.t("hyperLink.popup.cancel"),children:jsxRuntimeExports.jsx(UnlinkSingle,{})})})]})]})]})},"CellLinkPopup");CellLinkPopup.componentKey="univer.sheet.cell-link-popup";var __defProp$8=Object.defineProperty,__getOwnPropDesc$8=Object.getOwnPropertyDescriptor,__decorateClass$8=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$8(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$8(target,key,result),result},"__decorateClass$8"),__decorateParam$8=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$8");const isEqualLink=__name((a,b)=>a.unitId===b.unitId&&a.subUnitId===b.subUnitId&&a.row===b.row&&a.col===b.col,"isEqualLink");exports2.SheetsHyperLinkPopupService=(_e=class extends core.Disposable{constructor(_hyperLinkModel,_sheetCanvasPopManagerService){super();__publicField(this,"_currentPopup",null);__publicField(this,"_currentPopup$",new rxjs.Subject);__publicField(this,"currentPopup$",this._currentPopup$.asObservable());__publicField(this,"_currentEditing$",new rxjs.BehaviorSubject(null));__publicField(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=_hyperLinkModel,this._sheetCanvasPopManagerService=_sheetCanvasPopManagerService,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(location2){if(this._currentPopup&&isEqualLink(location2,this._currentPopup))return;this.hideCurrentPopup();const{unitId,subUnitId,row,col}=location2,link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);if(!link)return;const disposable=this._sheetCanvasPopManagerService.attachPopupToCell(row,col,{componentKey:CellLinkPopup.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:__name(()=>{this.hideCurrentPopup()},"onClickOutside")});disposable&&(this._currentPopup={unitId,subUnitId,id:link.id,disposable,row,col,editPermission:!!location2.editPermission,copyPermission:!!location2.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var _a2;this._currentPopup&&((_a2=this._currentPopup.disposable)==null||_a2.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(link){this._currentEditing$.next(link)}endEditing(){this._currentEditing$.next(null)}},__name(_e,"SheetsHyperLinkPopupService"),_e),exports2.SheetsHyperLinkPopupService=__decorateClass$8([__decorateParam$8(0,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$8(1,core.Inject(sheetsUi.SheetCanvasPopManagerService))],exports2.SheetsHyperLinkPopupService);var __defProp$7=Object.defineProperty,__getOwnPropDesc$7=Object.getOwnPropertyDescriptor,__decorateClass$7=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$7(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$7(target,key,result),result},"__decorateClass$7"),__decorateParam$7=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$7");exports2.SheetHyperLinkSetRangeController=(_f=class extends core.Disposable{constructor(_sheetInterceptorService,_injector,_hyperLinkModel,_selectionManagerService,_univerInstanceService,_editorBridgeService){super(),this._sheetInterceptorService=_sheetInterceptorService,this._injector=_injector,this._hyperLinkModel=_hyperLinkModel,this._selectionManagerService=_selectionManagerService,this._univerInstanceService=_univerInstanceService,this._editorBridgeService=_editorBridgeService,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor(),this._initRichTextEditorInterceptor()}_getCurrentCell(unitId,subUnitId,row,col){var _a2,_b2;return(_b2=(_a2=this._univerInstanceService.getUnit(unitId,core.UniverInstanceType.UNIVER_SHEET))==null?void 0:_a2.getSheetBySheetId(subUnitId))==null?void 0:_b2.getCell(row,col)}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{var _a2;if(command.id===sheetsHyperLink.AddHyperLinkCommand.id){const params=command.params,{unitId,subUnitId,link}=params,currentCell=this._getCurrentCell(unitId,subUnitId,link.row,link.column),redoParams={unitId,subUnitId,cellValue:{[link.row]:{[link.column]:{v:link.display,p:null,t:(_a2=currentCell==null?void 0:currentCell.t)!=null?_a2:void 0}}}};return{redos:[{id:sheets.SetRangeValuesMutation.id,params:redoParams}],undos:[{id:sheets.SetRangeValuesMutation.id,params:sheets.SetRangeValuesUndoMutationFactory(this._injector,redoParams)}]}}return{redos:[],undos:[]}},"getMutations")}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheetsHyperLink.UpdateHyperLinkCommand.id){const params=command.params,{unitId,subUnitId,id,payload}=params,current=this._hyperLinkModel.getHyperLink(unitId,subUnitId,id);if(current&&current.display!==payload.display){const redoParams={unitId,subUnitId,cellValue:{[current.row]:{[current.column]:{v:payload.display,t:core.CellValueType.STRING,p:null}}}};return{redos:[{id:sheets.SetRangeValuesMutation.id,params:redoParams}],undos:[{id:sheets.SetRangeValuesMutation.id,params:sheets.SetRangeValuesUndoMutationFactory(this._injector,redoParams)}]}}}return{redos:[],undos:[]}},"getMutations")}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.SetRangeValuesCommand.id){const params=command.params,{unitId,subUnitId}=params,redos=[],undos=[];return params.cellValue&&new core.ObjectMatrix(params.cellValue).forValue((row,col,cell)=>{var _a2,_b2,_c2,_d2,_e2,_f2,_g2;const cellValueRaw=(_c2=cell==null?void 0:cell.v)!=null?_c2:(_b2=(_a2=cell==null?void 0:cell.p)==null?void 0:_a2.body)==null?void 0:_b2.dataStream.slice(0,-2),cellValue=(cellValueRaw!=null?cellValueRaw:"").toString(),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);if(!link){if(isLegalLink(cellValue)||(_d2=cell==null?void 0:cell.custom)!=null&&_d2.__link_url){const url=(_f2=(_e2=cell==null?void 0:cell.custom)==null?void 0:_e2.__link_url)!=null?_f2:cellValue,id=core.Tools.generateRandomId();undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}}),redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{id,row,column:col,display:cellValue,payload:serializeUrl(url)}}})}return}(cellValueRaw===""||((_g2=cell==null?void 0:cell.custom)==null?void 0:_g2.__link_url)==="")&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))}),{undos,redos}}return{redos:[],undos:[]}},"getMutations")}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:__name(command=>{if(command.id===sheets.ClearSelectionContentCommand.id||command.id===sheets.ClearSelectionAllCommand.id||command.id===sheets.ClearSelectionFormatCommand.id){const redos=[],undos=[],selection=this._selectionManagerService.getCurrentLastSelection(),target=sheets.getSheetCommandTarget(this._univerInstanceService);if(selection&&target){const{unitId,subUnitId}=target;core.Range.foreach(selection.range,(row,col)=>{const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);link&&(redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}}),undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}}))})}return{redos,undos}}return{redos:[],undos:[]}},"getMutations")}))}_initRichTextEditorInterceptor(){this.disposeWithMe(this._editorBridgeService.interceptor.intercept(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{handler:__name((data,context,next)=>{var _a2,_b2,_c2,_d2,_e2,_f2;if(data!=null&&data.p){const range=(_b2=(_a2=data.p.body)==null?void 0:_a2.customRanges)==null?void 0:_b2.find(i=>i.rangeType===core.CustomRangeType.HYPERLINK),resource=(_c2=data.p.resources)==null?void 0:_c2.find(i=>i.name===docsHyperLink.DOC_HYPER_LINK_PLUGIN);if(range&&resource){const rangeId=range.rangeId,url=(_f2=(_e2=(_d2=JSON.parse(resource.data))==null?void 0:_d2.links)==null?void 0:_e2.find(i=>i.id===rangeId))==null?void 0:_f2.payload;return next({...data,p:null,v:docs.getPlainTextFormDocument(data.p),t:core.CellValueType.STRING,custom:{__link_url:url}})}}return next(data)},"handler")}))}},__name(_f,"SheetHyperLinkSetRangeController"),_f),exports2.SheetHyperLinkSetRangeController=__decorateClass$7([core.OnLifecycle(core.LifecycleStages.Starting,exports2.SheetHyperLinkSetRangeController),__decorateParam$7(0,core.Inject(sheets.SheetInterceptorService)),__decorateParam$7(1,core.Inject(core.Injector)),__decorateParam$7(2,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$7(3,core.Inject(sheets.SheetsSelectionsService)),__decorateParam$7(4,core.IUniverInstanceService),__decorateParam$7(5,sheetsUi.IEditorBridgeService)],exports2.SheetHyperLinkSetRangeController);var __defProp$6=Object.defineProperty,__getOwnPropDesc$6=Object.getOwnPropertyDescriptor,__decorateClass$6=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$6(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$6(target,key,result),result},"__decorateClass$6"),__decorateParam$6=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$6");exports2.SheetsHyperLinkPopupController=(_g=class extends core.Disposable{constructor(_hoverManagerService,_sheetsHyperLinkPopupService,_renderManagerService,_permissionService,_sheetPermissionInterceptorBaseController){super(),this._hoverManagerService=_hoverManagerService,this._sheetsHyperLinkPopupService=_sheetsHyperLinkPopupService,this._renderManagerService=_renderManagerService,this._permissionService=_permissionService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rxjs.debounceTime(200)).subscribe(currentCell=>{var _a2,_b2;if(!currentCell){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const skeleton=(_b2=(_a2=this._renderManagerService.getRenderById(currentCell.location.unitId))==null?void 0:_a2.with(sheetsUi.SheetSkeletonManagerService).getWorksheetSkeleton(currentCell.location.subUnitId))==null?void 0:_b2.skeleton,currentCol=currentCell.location.col,currentRow=currentCell.location.row;let targetRow=currentRow,targetCol=currentCol;if(skeleton&&skeleton.overflowCache.forValue((row,col,value)=>{core.Rectangle.contains(value,{startColumn:currentCol,endColumn:currentCol,startRow:currentRow,endRow:currentRow})&&(targetRow=row,targetCol=col)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookViewPermission],worksheetTypes:[sheets.WorksheetViewPermission],rangeTypes:[sheets.RangeProtectionPermissionViewPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const editPermission=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]},[{startRow:currentRow,startColumn:currentCol,endRow:currentRow,endColumn:currentCol}]),unitId=currentCell.location.unitId,subUnitId=currentCell.location.subUnitId,copyPermission=this._permissionService.composePermission([new sheets.WorkbookCopyPermission(unitId).id,new sheets.WorksheetCopyPermission(unitId,subUnitId).id]).every(permission=>permission.value);this._sheetsHyperLinkPopupService.showPopup({...currentCell.location,row:targetRow,col:targetCol,editPermission,copyPermission})}))}},__name(_g,"SheetsHyperLinkPopupController"),_g),exports2.SheetsHyperLinkPopupController=__decorateClass$6([core.OnLifecycle(core.LifecycleStages.Rendered,exports2.SheetsHyperLinkPopupController),__decorateParam$6(0,core.Inject(sheetsUi.HoverManagerService)),__decorateParam$6(1,core.Inject(exports2.SheetsHyperLinkPopupService)),__decorateParam$6(2,core.Inject(engineRender.IRenderManagerService)),__decorateParam$6(3,core.Inject(core.IPermissionService)),__decorateParam$6(4,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],exports2.SheetsHyperLinkPopupController);const insertLinkMenuFactory=__name(accessor=>({id:InsertHyperLinkOperation.id,type:ui.MenuItemType.BUTTON,positions:[ui.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"insertLinkMenuFactory"),insertLinkMenuToolbarFactory=__name(accessor=>({tooltip:"hyperLink.form.addTitle",positions:ui.MenuPosition.TOOLBAR_START,group:ui.MenuGroup.TOOLBAR_OTHERS,id:InsertHyperLinkToolbarOperation.id,type:ui.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:ui.getMenuHiddenObservable(accessor,core.UniverInstanceType.UNIVER_SHEET),disabled$:sheetsUi.getCurrentRangeDisable$(accessor,{workbookTypes:[sheets.WorkbookEditablePermission],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint]})}),"insertLinkMenuToolbarFactory"),InsertLinkShortcut={id:InsertHyperLinkToolbarOperation.id,binding:ui.KeyCode.K|ui.MetaKeys.CTRL_COMMAND,preconditions:sheetsUi.whenSheetEditorFocused};var __defProp$5=Object.defineProperty,__getOwnPropDesc$5=Object.getOwnPropertyDescriptor,__decorateClass$5=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$5(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$5(target,key,result),result},"__decorateClass$5"),__decorateParam$5=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$5");exports2.SheetsHyperLinkUIController=(_h=class extends core.Disposable{constructor(_config,_componentManager,_commandService,_localeService,_menuService,_injector,_shortcutService){super(),this._config=_config,this._componentManager=_componentManager,this._commandService=_commandService,this._localeService=_localeService,this._menuService=_menuService,this._injector=_injector,this._shortcutService=_shortcutService,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[CellLinkPopup,CellLinkPopup.componentKey],[CellLinkEdit,CellLinkEdit.componentKey],[LinkSingle,"LinkSingle"]].forEach(([comp,key])=>{this._componentManager.register(key,comp)})}_initCommands(){[OpenHyperLinkSidebarOperation,CloseHyperLinkSidebarOperation,InsertHyperLinkOperation,InsertHyperLinkToolbarOperation].forEach(command=>{this._commandService.registerCommand(command)})}_initMenus(){var _a2,_b2,_c2,_d2;this._menuService.addMenuItem(insertLinkMenuFactory(this._injector),(_b2=(_a2=this._config)==null?void 0:_a2.menu)!=null?_b2:{}),this._menuService.addMenuItem(insertLinkMenuToolbarFactory(this._injector),(_d2=(_c2=this._config)==null?void 0:_c2.menu)!=null?_d2:{})}_initShortCut(){this._shortcutService.registerShortcut(InsertLinkShortcut)}},__name(_h,"SheetsHyperLinkUIController"),_h),exports2.SheetsHyperLinkUIController=__decorateClass$5([core.OnLifecycle(core.LifecycleStages.Ready,exports2.SheetsHyperLinkUIController),__decorateParam$5(1,core.Inject(ui.ComponentManager)),__decorateParam$5(2,core.ICommandService),__decorateParam$5(3,core.Inject(core.LocaleService)),__decorateParam$5(4,ui.IMenuService),__decorateParam$5(5,core.Inject(core.Injector)),__decorateParam$5(6,core.Inject(ui.IShortcutService))],exports2.SheetsHyperLinkUIController);const SHEET_HYPER_LINK_UI_PLUGIN="SHEET_HYPER_LINK_UI_PLUGIN";var __defProp$4=Object.defineProperty,__getOwnPropDesc$4=Object.getOwnPropertyDescriptor,__decorateClass$4=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$4(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$4(target,key,result),result},"__decorateClass$4"),__decorateParam$4=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$4");exports2.SheetsHyperLinkAutoFillController=(_i=class extends core.Disposable{constructor(_autoFillService,_hyperLinkModel){super(),this._autoFillService=_autoFillService,this._hyperLinkModel=_hyperLinkModel,this._initAutoFill()}_initAutoFill(){const noopReturnFunc=__name(()=>({redos:[],undos:[]}),"noopReturnFunc"),generalApplyFunc=__name((location2,applyType)=>{const{source:sourceRange,target:targetRange,unitId,subUnitId}=location2,virtualRange=sheetsUi.virtualizeDiscreteRanges([sourceRange,targetRange]),[vSourceRange,vTargetRange]=virtualRange.ranges,{mapFunc}=virtualRange,sourceStartCell={row:vSourceRange.startRow,col:vSourceRange.startColumn},repeats=sheetsUi.getAutoFillRepeatRange(vSourceRange,vTargetRange),redos=[],undos=[];return repeats.forEach(repeat=>{const targetStartCell=repeat.repeatStartCell,relativeRange=repeat.relativeRange,sourceRange2={startRow:sourceStartCell.row,startColumn:sourceStartCell.col,endColumn:sourceStartCell.col,endRow:sourceStartCell.row},targetRange2={startRow:targetStartCell.row,startColumn:targetStartCell.col,endColumn:targetStartCell.col,endRow:targetStartCell.row};core.Range.foreach(relativeRange,(row,col)=>{const sourcePositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},sourceRange2),{row:sourceRow,col:sourceCol}=mapFunc(sourcePositionRange.startRow,sourcePositionRange.startColumn),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,sourceRow,sourceCol),targetPositionRange=core.Rectangle.getPositionRange({startRow:row,startColumn:col,endColumn:col,endRow:row},targetRange2),{row:targetRow,col:targetCol}=mapFunc(targetPositionRange.startRow,targetPositionRange.startColumn),id=core.Tools.generateRandomId(),currentLink=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,targetRow,targetCol);currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:currentLink.id}}),(sheetsUi.APPLY_TYPE.COPY===applyType||sheetsUi.APPLY_TYPE.SERIES===applyType)&&link&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{...link,id,row:targetRow,column:targetCol}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:currentLink}})})}),{undos,redos}},"generalApplyFunc"),hook={id:SHEET_HYPER_LINK_UI_PLUGIN,onFillData:__name((location2,direction,applyType)=>applyType===sheetsUi.APPLY_TYPE.COPY||applyType===sheetsUi.APPLY_TYPE.ONLY_FORMAT||applyType===sheetsUi.APPLY_TYPE.SERIES?generalApplyFunc(location2,applyType):noopReturnFunc(),"onFillData")};this.disposeWithMe(this._autoFillService.addHook(hook))}},__name(_i,"SheetsHyperLinkAutoFillController"),_i),exports2.SheetsHyperLinkAutoFillController=__decorateClass$4([core.OnLifecycle(core.LifecycleStages.Ready,exports2.SheetsHyperLinkAutoFillController),__decorateParam$4(0,sheetsUi.IAutoFillService),__decorateParam$4(1,core.Inject(sheetsHyperLink.HyperLinkModel))],exports2.SheetsHyperLinkAutoFillController);var __defProp$3=Object.defineProperty,__getOwnPropDesc$3=Object.getOwnPropertyDescriptor,__decorateClass$3=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$3(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$3(target,key,result),result},"__decorateClass$3"),__decorateParam$3=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$3");exports2.SheetsHyperLinkCopyPasteController=(_j=class extends core.Disposable{constructor(_sheetClipboardService,_hyperLinkModel,_injector,_resolverService){super();__publicField(this,"_plainTextFilter",new Set);__publicField(this,"_copyInfo");this._sheetClipboardService=_sheetClipboardService,this._hyperLinkModel=_hyperLinkModel,this._injector=_injector,this._resolverService=_resolverService,this._initCopyPaste(),this.disposeWithMe(()=>{this._plainTextFilter.clear()})}registerPlainTextFilter(filter){this._plainTextFilter.add(filter)}removePlainTextFilter(filter){this._plainTextFilter.delete(filter)}_filterPlainText(text){return Array.from(this._plainTextFilter).every(filter=>filter(text))}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:SHEET_HYPER_LINK_UI_PLUGIN,onBeforeCopy:__name((unitId,subUnitId,range)=>this._collect(unitId,subUnitId,range),"onBeforeCopy"),onPasteCells:__name((pasteFrom,pasteTo,data,payload)=>{const{copyType=sheetsUi.COPY_TYPE.COPY,pasteType}=payload,{range:copyRange}=pasteFrom||{},{range:pastedRange,unitId,subUnitId}=pasteTo;return this._generateMutations(pastedRange,{copyType,pasteType,copyRange,unitId,subUnitId})},"onPasteCells"),onPastePlainText:__name((pasteTo,clipText)=>{const filterResult=this._filterPlainText(clipText);if(isLegalLink(clipText)&&filterResult){const text=serializeUrl(clipText),{range,unitId,subUnitId}=pasteTo,{ranges:[pasteToRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([range]),redos=[],undos=[];return core.Range.foreach(pasteToRange,(originRow,originCol)=>{const{row,col:column}=mapFunc(originRow,originCol),link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,column);link&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:link.id}});const newId=core.Tools.generateRandomId();redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link:{id:newId,row,column,payload:text}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId,subUnitId,id:newId}}),link&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId,subUnitId,link}})}),{redos,undos}}return{undos:[],redos:[]}},"onPastePlainText"),priority:99})}_collect(unitId,subUnitId,range){const matrix=new core.ObjectMatrix;this._copyInfo={unitId,subUnitId,matrix};const accessor={get:this._injector.get.bind(this._injector)},discreteRange=sheetsUi.rangeToDiscreteRange(range,accessor,unitId,subUnitId);if(!discreteRange)return;const{rows,cols}=discreteRange;rows.forEach((row,rowIndex)=>{cols.forEach((col,colIndex)=>{var _a2;const link=this._hyperLinkModel.getHyperLinkByLocation(unitId,subUnitId,row,col);matrix.setValue(rowIndex,colIndex,(_a2=link==null?void 0:link.id)!=null?_a2:"")})})}_generateMutations(pastedRange,copyInfo){if(!this._copyInfo)return{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!copyInfo.copyRange)return{redos:[],undos:[]};if([sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,sheetsUi.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(copyInfo.pasteType))return{redos:[],undos:[]};const{unitId,subUnitId}=this._copyInfo,redos=[],undos=[],{ranges:[vCopyRange,vPastedRange],mapFunc}=sheetsUi.virtualizeDiscreteRanges([copyInfo.copyRange,pastedRange]);return sheetsUi.getRepeatRange(vCopyRange,vPastedRange,!0).forEach(({startRange})=>{var _a2;(_a2=this._copyInfo)==null||_a2.matrix.forValue((row,col,ruleId)=>{const range=core.Rectangle.getPositionRange({startRow:row,endRow:row,startColumn:col,endColumn:col},startRange),oldLink=this._hyperLinkModel.getHyperLink(unitId,subUnitId,ruleId),{row:startRow,col:startColumn}=mapFunc(range.startRow,range.startColumn),currentLink=this._hyperLinkModel.getHyperLinkByLocation(copyInfo.unitId,copyInfo.subUnitId,startRow,startColumn),id=core.Tools.generateRandomId();currentLink&&redos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id:currentLink.id}}),oldLink&&(redos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:{...oldLink,id,row:startRow,column:startColumn}}}),undos.push({id:sheetsHyperLink.RemoveHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,id}})),currentLink&&undos.push({id:sheetsHyperLink.AddHyperLinkMutation.id,params:{unitId:copyInfo.unitId,subUnitId:copyInfo.subUnitId,link:currentLink}})})}),{redos,undos}}},__name(_j,"SheetsHyperLinkCopyPasteController"),_j),exports2.SheetsHyperLinkCopyPasteController=__decorateClass$3([core.OnLifecycle(core.LifecycleStages.Ready,exports2.SheetsHyperLinkCopyPasteController),__decorateParam$3(0,sheetsUi.ISheetClipboardService),__decorateParam$3(1,core.Inject(sheetsHyperLink.HyperLinkModel)),__decorateParam$3(2,core.Inject(core.Injector)),__decorateParam$3(3,core.Inject(exports2.SheetsHyperLinkResolverService))],exports2.SheetsHyperLinkCopyPasteController);var __defProp$2=Object.defineProperty,__getOwnPropDesc$2=Object.getOwnPropertyDescriptor,__decorateClass$2=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$2(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$2(target,key,result),result},"__decorateClass$2"),__decorateParam$2=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$2");exports2.SheetHyperLinkUrlController=(_k=class extends core.Disposable{constructor(_resolverService){super(),this._resolverService=_resolverService,this._handleInitUrl()}_handleInitUrl(){const hash=location.hash;hash&&this._resolverService.parseHyperLink(hash).handler()}},__name(_k,"SheetHyperLinkUrlController"),_k),exports2.SheetHyperLinkUrlController=__decorateClass$2([core.OnLifecycle(core.LifecycleStages.Rendered,exports2.SheetHyperLinkUrlController),__decorateParam$2(0,core.Inject(exports2.SheetsHyperLinkResolverService))],exports2.SheetHyperLinkUrlController);var __defProp$1=Object.defineProperty,__getOwnPropDesc$1=Object.getOwnPropertyDescriptor,__decorateClass$1=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc$1(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp$1(target,key,result),result},"__decorateClass$1"),__decorateParam$1=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam$1");let SheetsHyperLinkPermissionController=(_l=class extends core.Disposable{constructor(_localeService,_commandService,_sheetPermissionInterceptorBaseController){super(),this._localeService=_localeService,this._commandService=_commandService,this._sheetPermissionInterceptorBaseController=_sheetPermissionInterceptorBaseController,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(command=>{command.id===InsertLinkShortcut.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[sheets.WorkbookEditablePermission],rangeTypes:[sheets.RangeProtectionPermissionEditPoint],worksheetTypes:[sheets.WorksheetEditPermission,sheets.WorksheetSetCellValuePermission,sheets.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}},__name(_l,"SheetsHyperLinkPermissionController"),_l);SheetsHyperLinkPermissionController=__decorateClass$1([core.OnLifecycle(core.LifecycleStages.Rendered,SheetsHyperLinkPermissionController),__decorateParam$1(0,core.Inject(core.LocaleService)),__decorateParam$1(1,core.ICommandService),__decorateParam$1(2,core.Inject(sheetsUi.SheetPermissionInterceptorBaseController))],SheetsHyperLinkPermissionController);var __defProp2=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__defNormalProp2=__name((obj,key,value)=>key in obj?__defProp2(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,"__defNormalProp"),__decorateClass=__name((decorators,target,key,kind)=>{for(var result=kind>1?void 0:kind?__getOwnPropDesc(target,key):target,i=decorators.length-1,decorator;i>=0;i--)(decorator=decorators[i])&&(result=(kind?decorator(target,key,result):decorator(result))||result);return kind&&result&&__defProp2(target,key,result),result},"__decorateClass"),__decorateParam=__name((index,decorator)=>(target,key)=>decorator(target,key,index),"__decorateParam"),__publicField2=__name((obj,key,value)=>__defNormalProp2(obj,typeof key!="symbol"?key+"":key,value),"__publicField");exports2.UniverSheetsHyperLinkUIPlugin=(_m=class extends core.Plugin{constructor(_config,_injector,_renderManagerService){super(),this._config=_config,this._injector=_injector,this._renderManagerService=_renderManagerService}onStarting(){[[exports2.SheetsHyperLinkResolverService,{useFactory:__name(()=>{var _a2;return this._injector.createInstance(exports2.SheetsHyperLinkResolverService,(_a2=this._config)==null?void 0:_a2.urlHandler)},"useFactory")}],[exports2.SheetsHyperLinkPopupService],[SheetsHyperLinkSidePanelService],[exports2.SheetsHyperLinkRemoveSheetController],[exports2.SheetsHyperLinkRenderManagerController],[exports2.SheetHyperLinkSetRangeController],[exports2.SheetsHyperLinkPopupController],[exports2.SheetsHyperLinkUIController,{useFactory:__name(()=>this._injector.createInstance(exports2.SheetsHyperLinkUIController,this._config),"useFactory")}],[exports2.SheetsHyperLinkAutoFillController],[exports2.SheetsHyperLinkCopyPasteController],[SheetsHyperLinkPermissionController],[exports2.SheetHyperLinkUrlController]].forEach(dep=>this._injector.add(dep))}onReady(){[[exports2.SheetsHyperLinkRenderController]].forEach(d=>this._renderManagerService.registerRenderModule(core.UniverInstanceType.UNIVER_SHEET,d))}},__name(_m,"UniverSheetsHyperLinkUIPlugin"),_m),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"pluginName",SHEET_HYPER_LINK_UI_PLUGIN),__publicField2(exports2.UniverSheetsHyperLinkUIPlugin,"type",core.UniverInstanceType.UNIVER_SHEET),exports2.UniverSheetsHyperLinkUIPlugin=__decorateClass([core.DependentOn(sheetsHyperLink.UniverSheetsHyperLinkPlugin),__decorateParam(1,core.Inject(core.Injector)),__decorateParam(2,engineRender.IRenderManagerService)],exports2.UniverSheetsHyperLinkUIPlugin),exports2.CloseHyperLinkSidebarOperation=CloseHyperLinkSidebarOperation,exports2.InsertHyperLinkOperation=InsertHyperLinkOperation,exports2.InsertLinkShortcut=InsertLinkShortcut,exports2.OpenHyperLinkSidebarOperation=OpenHyperLinkSidebarOperation,exports2.SheetsHyperLinkSidePanelService=SheetsHyperLinkSidePanelService,Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-hyper-link-ui",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,36 +53,36 @@
53
53
  "clsx": ">=2.0.0",
54
54
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
55
55
  "rxjs": ">=7.0.0",
56
- "@univerjs/core": "0.2.5",
57
- "@univerjs/docs": "0.2.5",
58
- "@univerjs/design": "0.2.5",
59
- "@univerjs/docs-hyper-link": "0.2.5",
60
- "@univerjs/engine-render": "0.2.5",
61
- "@univerjs/sheets": "0.2.5",
62
- "@univerjs/sheets-hyper-link": "0.2.5",
63
- "@univerjs/engine-formula": "0.2.5",
64
- "@univerjs/sheets-ui": "0.2.5",
65
- "@univerjs/ui": "0.2.5"
56
+ "@univerjs/core": "0.2.7",
57
+ "@univerjs/design": "0.2.7",
58
+ "@univerjs/docs-hyper-link": "0.2.7",
59
+ "@univerjs/docs": "0.2.7",
60
+ "@univerjs/engine-formula": "0.2.7",
61
+ "@univerjs/engine-render": "0.2.7",
62
+ "@univerjs/sheets": "0.2.7",
63
+ "@univerjs/sheets-hyper-link": "0.2.7",
64
+ "@univerjs/sheets-ui": "0.2.7",
65
+ "@univerjs/ui": "0.2.7"
66
66
  },
67
67
  "dependencies": {
68
- "@univerjs/icons": "^0.1.65",
69
- "@univerjs/sheets-hyper-link": "0.2.5"
68
+ "@univerjs/icons": "^0.1.72",
69
+ "@univerjs/sheets-hyper-link": "0.2.7"
70
70
  },
71
71
  "devDependencies": {
72
72
  "clsx": "^2.1.1",
73
73
  "rxjs": "^7.8.1",
74
- "typescript": "^5.5.3",
75
- "vite": "^5.3.4",
76
- "vitest": "^2.0.3",
77
- "@univerjs/docs": "0.2.5",
78
- "@univerjs/docs-hyper-link": "0.2.5",
79
- "@univerjs/engine-formula": "0.2.5",
80
- "@univerjs/engine-render": "0.2.5",
81
- "@univerjs/shared": "0.2.5",
82
- "@univerjs/core": "0.2.5",
83
- "@univerjs/sheets": "0.2.5",
84
- "@univerjs/ui": "0.2.5",
85
- "@univerjs/sheets-ui": "0.2.5"
74
+ "typescript": "^5.5.4",
75
+ "vite": "^5.3.5",
76
+ "vitest": "^2.0.5",
77
+ "@univerjs/core": "0.2.7",
78
+ "@univerjs/docs": "0.2.7",
79
+ "@univerjs/docs-hyper-link": "0.2.7",
80
+ "@univerjs/engine-formula": "0.2.7",
81
+ "@univerjs/shared": "0.2.7",
82
+ "@univerjs/engine-render": "0.2.7",
83
+ "@univerjs/sheets": "0.2.7",
84
+ "@univerjs/sheets-ui": "0.2.7",
85
+ "@univerjs/ui": "0.2.7"
86
86
  },
87
87
  "univerSpace": {
88
88
  ".": {