@univerjs/sheets-hyper-link-ui 0.1.13 → 0.1.15

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.
@@ -1,19 +1,7 @@
1
- /**
2
- * Copyright 2023-present DreamNum Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
1
+ import { ICellData, Nullable } from '@univerjs/core';
2
+
16
3
  export declare function isLegalLink(link: string): boolean;
17
4
  export declare function hasProtocol(urlString: string): boolean;
18
5
  export declare function isEmail(url: string): boolean;
19
- export declare function serializeUrl(url: string): string;
6
+ export declare function serializeUrl(urlStr: string): string;
7
+ export declare function getCellValueOrigin(cell: Nullable<ICellData>): Nullable<import('@univerjs/core').CellValue>;
@@ -1,10 +1,12 @@
1
1
  import { Disposable } from '@univerjs/core';
2
2
  import { HoverManagerService } from '@univerjs/sheets-ui';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
3
4
  import { SheetsHyperLinkPopupService } from '../services/popup.service';
4
5
 
5
6
  export declare class SheetsHyperLinkPopupController extends Disposable {
6
7
  private readonly _hoverManagerService;
7
8
  private readonly _sheetsHyperLinkPopupService;
8
- constructor(_hoverManagerService: HoverManagerService, _sheetsHyperLinkPopupService: SheetsHyperLinkPopupService);
9
+ private readonly _renderManagerService;
10
+ constructor(_hoverManagerService: HoverManagerService, _sheetsHyperLinkPopupService: SheetsHyperLinkPopupService, _renderManagerService: IRenderManagerService);
9
11
  private _initHoverListener;
10
12
  }
@@ -1,17 +1,21 @@
1
- import { Disposable, IUniverInstanceService, ThemeService } from '@univerjs/core';
1
+ import { Workbook, Disposable, ThemeService } from '@univerjs/core';
2
2
  import { SheetInterceptorService } from '@univerjs/sheets';
3
3
  import { SheetSkeletonManagerService } from '@univerjs/sheets-ui';
4
- import { IRenderManagerService } from '@univerjs/engine-render';
4
+ import { IRenderContext, IRenderModule, IRenderManagerService } from '@univerjs/engine-render';
5
5
  import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
6
6
 
7
- export declare class SheetsHyperLinkRenderController extends Disposable {
8
- private readonly _sheetInterceptorService;
7
+ export declare class SheetsHyperLinkRenderController extends Disposable implements IRenderModule {
8
+ private readonly _context;
9
9
  private readonly _hyperLinkModel;
10
- private readonly _univerInstanceService;
11
10
  private readonly _sheetSkeletonManagerService;
12
11
  private readonly _renderManagerService;
12
+ constructor(_context: IRenderContext<Workbook>, _hyperLinkModel: HyperLinkModel, _sheetSkeletonManagerService: SheetSkeletonManagerService, _renderManagerService: IRenderManagerService);
13
+ private _initSkeletonChange;
14
+ }
15
+ export declare class SheetsHyperLinkRenderManagerController extends Disposable {
16
+ private readonly _sheetInterceptorService;
17
+ private readonly _hyperLinkModel;
13
18
  private readonly _themeService;
14
- constructor(_sheetInterceptorService: SheetInterceptorService, _hyperLinkModel: HyperLinkModel, _univerInstanceService: IUniverInstanceService, _sheetSkeletonManagerService: SheetSkeletonManagerService, _renderManagerService: IRenderManagerService, _themeService: ThemeService);
19
+ constructor(_sheetInterceptorService: SheetInterceptorService, _hyperLinkModel: HyperLinkModel, _themeService: ThemeService);
15
20
  private _initViewModelIntercept;
16
- private _initSkeletonChange;
17
21
  }
@@ -14,8 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { SheetsHyperLinkRemoveSheetController } from './controllers/remove-sheet.controller';
17
- export { SheetsHyperLinkRefRangeController } from './controllers/ref-range.controller';
18
- export { SheetsHyperLinkRenderController } from './controllers/render-controllers/render.controller';
17
+ export { SheetsHyperLinkRenderManagerController, SheetsHyperLinkRenderController } from './controllers/render-controllers/render.controller';
19
18
  export { SheetsHyperLinkPopupService } from './services/popup.service';
20
19
  export { SheetsHyperLinkResolverService } from './services/resolver.service';
21
20
  export { SheetHyperLinkSetRangeController } from './controllers/set-range.controller';
@@ -1,13 +1,14 @@
1
1
  import { Injector } from '@wendellhu/redi';
2
- import { UniverInstanceType } from '@univerjs/core';
3
- import { UniverSheetsHyperLinkPlugin } from '@univerjs/sheets-hyper-link';
2
+ import { Plugin, UniverInstanceType } from '@univerjs/core';
3
+ import { IRenderManagerService } from '@univerjs/engine-render';
4
4
  import { IUniverSheetsHyperLinkUIConfig } from './controllers/ui.controller';
5
5
 
6
- export declare class UniverSheetsHyperLinkUIPlugin extends UniverSheetsHyperLinkPlugin {
6
+ export declare class UniverSheetsHyperLinkUIPlugin extends Plugin {
7
7
  private _config;
8
8
  protected _injector: Injector;
9
+ private readonly _renderManagerService;
9
10
  static pluginName: string;
10
11
  static type: UniverInstanceType;
11
- constructor(_config: IUniverSheetsHyperLinkUIConfig, _injector: Injector);
12
+ constructor(_config: IUniverSheetsHyperLinkUIConfig, _injector: Injector, _renderManagerService: IRenderManagerService);
12
13
  onStarting(injector: Injector): void;
13
14
  }
@@ -2,12 +2,15 @@ import { ISheetLocationBase } from '@univerjs/sheets';
2
2
  import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
3
3
  import { SheetCanvasPopManagerService } from '@univerjs/sheets-ui';
4
4
  import { IDisposable } from '@wendellhu/redi';
5
+ import { Disposable } from '@univerjs/core';
5
6
 
6
7
  interface IHyperLinkPopup {
7
8
  unitId: string;
8
9
  subUnitId: string;
9
10
  id: string;
10
11
  disposable?: IDisposable;
12
+ row: number;
13
+ col: number;
11
14
  }
12
15
  interface IHyperLinkEditing {
13
16
  unitId: string;
@@ -15,7 +18,7 @@ interface IHyperLinkEditing {
15
18
  row: number;
16
19
  column: number;
17
20
  }
18
- export declare class SheetsHyperLinkPopupService {
21
+ export declare class SheetsHyperLinkPopupService extends Disposable {
19
22
  private readonly _hyperLinkModel;
20
23
  private readonly _sheetCanvasPopManagerService;
21
24
  private _currentPopup;
@@ -1,4 +1,4 @@
1
- import { IRange, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
1
+ import { IRange, Worksheet, ICommandService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { IDefinedNamesService } from '@univerjs/engine-formula';
3
3
  import { IMessageService } from '@univerjs/ui';
4
4
 
@@ -31,7 +31,7 @@ export declare class SheetsHyperLinkResolverService {
31
31
  };
32
32
  navigateToRange(unitId: string, subUnitId: string, range: IRange): Promise<void>;
33
33
  navigateToSheet(unitId: string, sheetName: string): Promise<boolean | undefined>;
34
- navigateToSheetById(unitId: string, subUnitId: string): Promise<false | import('@univerjs/core').Worksheet>;
34
+ navigateToSheetById(unitId: string, subUnitId: string): Promise<false | Worksheet>;
35
35
  navigateToDefineName(unitId: string, rangeid: string): Promise<boolean>;
36
36
  navigateToOtherWebsite(url: string): Promise<void>;
37
37
  }
@@ -13,5 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const SHEETS_HYPER_LINK_UI_PLUGIN = "SHEETS_HYPER_LINK_UI_PLUGIN";
17
- export declare const ERROR_RANGE = "err";
16
+ export declare const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(l,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/engine-formula"),require("@univerjs/design"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx"),require("@univerjs/sheets-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/engine-formula","@univerjs/design","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-render","rxjs","react","@wendellhu/redi/react-bindings","clsx","@univerjs/sheets-formula"],s):(l=typeof globalThis<"u"?globalThis:l||self,s(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l["@wendellhu/redi"],l.UniverSheetsHyperLink,l.UniverEngineFormula,l.UniverDesign,l.UniverSheetsUi,l.UniverUi,l.UniverEngineRender,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.clsx,l.UniverSheetsFormula))})(this,function(l,s,p,S,v,H,I,_,O,Ae,pe,C,w,Le,Ve){"use strict";var rn=Object.defineProperty;var on=(l,s,p)=>s in l?rn(l,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[s]=p;var A=(l,s,p)=>(on(l,typeof s!="symbol"?s+"":s,p),p);var de;var We=Object.defineProperty,xe=Object.getOwnPropertyDescriptor,$e=(i,n,t,e)=>{for(var r=e>1?void 0:e?xe(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&We(n,t,r),r},he=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRemoveSheetController=class extends s.Disposable{constructor(n,t,e){super(),this._sheetInterceptorService=n,this._univerInstanceService=t,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.RemoveSheetCommand.id){const t=n.params,e=t.unitId?this._univerInstanceService.getUnit(t.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=t.subUnitId||e.getActiveSheet().getSheetId(),a=this._hyperLinkModel.getSubUnit(r,o),c=a.map(u=>({id:v.RemoveHyperLinkCommand.id,params:{unitId:r,subUnitId:o,id:u.id}})),d=a.map(u=>({id:v.AddHyperLinkCommand.id,params:{unitId:r,subUnitId:o,link:u}}));return{redos:c,undos:d}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=$e([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),he(0,S.Inject(p.SheetInterceptorService)),he(1,s.IUniverInstanceService),he(2,S.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);const ve="SHEETS_HYPER_LINK_UI_PLUGIN",me="err";var Be=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,ze=(i,n,t,e)=>{for(var r=e>1?void 0:e?Fe(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Be(n,t,r),r},X=(i,n)=>(t,e)=>n(t,e,i);function Ye(i,n){const t=[];return n.forEach(e=>{s.Rectangle.intersects(i,e)&&t.push(e)}),s.Rectangle.realUnion(i,...t)}l.SheetsHyperLinkResolverService=class{constructor(n,t,e,r,o){this._univerInstanceService=n,this._commandService=t,this._definedNamesService=e,this._messageService=r,this._localeService=o}_getURLName(n){var d;const{gid:t,range:e,rangeid:r}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const a=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=a==null?void 0:a.getName())!=null?d:"";if(e){const u=H.deserializeRangeWithSheet(e).range;return s.isValidRange(u)&&e!==me?{type:"range",name:H.serializeRangeWithSheet(c,u)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const u=this._definedNamesService.getValueById(o.getUnitId(),r);return u?{type:"defineName",name:u.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const u=o.getSheetBySheetId(t);return u?{type:"sheet",name:u.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(n){const{gid:t,range:e,rangeid:r}=n,o=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r&&this.navigateToDefineName(a,r),!!t){if(e){const c=H.deserializeRangeWithSheet(e);s.isValidRange(c.range)&&e!==me&&this.navigateToRange(a,t,c.range);return}this.navigateToSheetById(a,t)}}parseHyperLink(n){var t,e,r;if(n!=null&&n.startsWith("#")){const o=new URLSearchParams(n.slice(1)),a={gid:(t=o.get("gid"))!=null?t:"",range:(e=o.get("range"))!=null?e:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(a);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||n,url:n,searchObj:a,handler:()=>{this.navigateTo(a)}}}else return{type:"outer",name:n,url:n,handler:()=>{this.navigateToOtherWebsite(n)}}}async navigateToRange(n,t,e){const r=await this.navigateToSheetById(n,t);if(r){const o=Ye(e,r.getMergeData());await this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:n,subUnitId:t,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}),await this._commandService.executeCommand(_.ScrollToCellCommand.id,{range:o})}}async navigateToSheet(n,t){const e=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=e.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error});return}const a=o.getSheetId();return e.getHiddenWorksheets().indexOf(a)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:a})}async navigateToSheetById(n,t){const e=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if(r.getSheetId()===t)return r;const o=e.getSheetBySheetId(t);return o?e.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:n,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(n,t){return this._definedNamesService.focusRange(n,t),!0}async navigateToOtherWebsite(n){window.open(n,"_blank","noopener noreferrer")}},l.SheetsHyperLinkResolverService=ze([X(0,s.IUniverInstanceService),X(1,s.ICommandService),X(2,H.IDefinedNamesService),X(3,O.IMessageService),X(4,S.Inject(s.LocaleService))],l.SheetsHyperLinkResolverService);var Ze=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ge=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ke(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ze(n,t,r),r},ne=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRefRangeController=class extends s.Disposable{constructor(t,e,r,o){super();A(this,"_disposableMap",new Map);A(this,"_rangeDisableMap",new Map);this._refRangeService=t,this._hyperLinkModel=e,this._resolverService=r,this._univerInstanceService=o,this._initData(),this._initRefRange()}_register(t,e,r){const o=r.id,a={startColumn:r.column,endColumn:r.column,startRow:r.row,endRow:r.row},c=d=>{const u=p.handleDefaultRangeChangeWithEffectRefCommands(a,d);return u&&u.startColumn===a.startColumn&&u.startRow===a.startRow?{undos:[],redos:[]}:u?{redos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:t,subUnitId:e,id:r.id,row:u.startRow,column:u.startColumn}}],undos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:t,subUnitId:e,id:r.id,row:a.startRow,column:a.startColumn}}]}:{redos:[{id:v.RemoveHyperLinkMutation.id,params:{unitId:t,subUnitId:e,id:r.id}}],undos:[{id:v.AddHyperLinkMutation.id,params:{unitId:t,subUnitId:e,link:r}}]}};this._disposableMap.set(o,this._refRangeService.registerRefRange(a,c,t,e))}_unregister(t){const e=this._disposableMap.get(t);e==null||e.dispose(),this._disposableMap.delete(t)}_registerRange(t,e,r){const o=this._resolverService.parseHyperLink(r);if(o.searchObj&&o.searchObj.range&&o.searchObj.gid){const a=o.searchObj.gid,c=H.deserializeRangeWithSheet(o.searchObj.range).range;if(s.isValidRange(c)&&o.searchObj.range!==me){const d=u=>{const g=p.handleDefaultRangeChangeWithEffectRefCommands(c,u);return g&&H.serializeRange(g)===H.serializeRange(c)?{redos:[],undos:[]}:{redos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:t,subUnitId:a,id:e,payload:{payload:`#gid=${a}&range=${g?H.serializeRange(g):"err"}`}}}],undos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:t,subUnitId:a,id:e,payload:{payload:r}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(c,d,t,a))}}}_unregisterRange(t){const e=this._rangeDisableMap.get(t);e==null||e.dispose(),this._rangeDisableMap.delete(t)}_initData(){this._hyperLinkModel.getAll().forEach(e=>{e.forEach(r=>{const{unitId:o,subUnitId:a,links:c}=r;c.forEach(d=>{this._register(o,a,d)})})})}_initRefRange(){this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(t=>{switch(t.type){case"add":{this._register(t.unitId,t.subUnitId,t.payload),this._registerRange(t.unitId,t.payload.id,t.payload.payload);break}case"remove":{this._unregister(t.payload.id),this._unregisterRange(t.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:r,id:o}=t,a=this._hyperLinkModel.getHyperLink(e,r,o);if(!a)return;this._unregister(o),this._register(e,r,a);break}case"unload":{const{unitLinks:e}=t;e.forEach(r=>{const{links:o}=r;o.forEach(a=>{this._unregister(a.id),this._unregisterRange(a.id)})});break}case"update":{this._unregisterRange(t.id),this._registerRange(t.unitId,t.id,t.payload.payload);break}}})),this.disposeWithMe(s.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}},l.SheetsHyperLinkRefRangeController=Ge([s.OnLifecycle(s.LifecycleStages.Starting,l.SheetsHyperLinkRefRangeController),ne(0,S.Inject(p.RefRangeService)),ne(1,S.Inject(v.HyperLinkModel)),ne(2,S.Inject(l.SheetsHyperLinkResolverService)),ne(3,s.IUniverInstanceService)],l.SheetsHyperLinkRefRangeController);var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,n,t,e)=>{for(var r=e>1?void 0:e?Je(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Xe(n,t,r),r},z=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkRenderController=class extends s.Disposable{constructor(n,t,e,r,o,a){super(),this._sheetInterceptorService=n,this._hyperLinkModel=t,this._univerInstanceService=e,this._sheetSkeletonManagerService=r,this._renderManagerService=o,this._themeService=a,this._initViewModelIntercept(),this._initSkeletonChange()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(n,t,e)=>{const{row:r,col:o,unitId:a,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(a,c,r,o),u=this._themeService.getCurrentTheme();return e(d?{...n,interceptorStyle:{ul:{s:s.BooleanNumber.TRUE},cl:{rgb:u.blue500}}}:n)},priority:100}))}_initSkeletonChange(){const n=()=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return;const e=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._sheetSkeletonManagerService.getOrCreateSkeleton({unitId:e,sheetId:r}),a=this._renderManagerService.getRenderById(e);o==null||o.makeDirty(!0),o==null||o.calculate(),a&&a.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{n()}))}},l.SheetsHyperLinkRenderController=Qe([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRenderController),z(0,S.Inject(p.SheetInterceptorService)),z(1,S.Inject(v.HyperLinkModel)),z(2,s.IUniverInstanceService),z(3,S.Inject(_.SheetSkeletonManagerService)),z(4,Ae.IRenderManagerService),z(5,S.Inject(s.ThemeService))],l.SheetsHyperLinkRenderController);var ke={exports:{}},re={};/**
1
+ (function(l,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@wendellhu/redi"),require("@univerjs/sheets-hyper-link"),require("@univerjs/sheets-ui"),require("@univerjs/engine-render"),require("rxjs"),require("react"),require("@wendellhu/redi/react-bindings"),require("clsx"),require("@univerjs/design"),require("@univerjs/ui"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@wendellhu/redi","@univerjs/sheets-hyper-link","@univerjs/sheets-ui","@univerjs/engine-render","rxjs","react","@wendellhu/redi/react-bindings","clsx","@univerjs/design","@univerjs/ui","@univerjs/engine-formula","@univerjs/sheets-formula"],s):(l=typeof globalThis<"u"?globalThis:l||self,s(l.UniverSheetsHyperLinkUi={},l.UniverCore,l.UniverSheets,l["@wendellhu/redi"],l.UniverSheetsHyperLink,l.UniverSheetsUi,l.UniverEngineRender,l.rxjs,l.React,l["@wendellhu/redi/react-bindings"],l.clsx,l.UniverDesign,l.UniverUi,l.UniverEngineFormula,l.UniverSheetsFormula))})(this,function(l,s,h,f,v,y,pe,he,C,w,Re,L,P,D,Ve){"use strict";var Qn=Object.defineProperty;var qn=(l,s,h)=>s in l?Qn(l,s,{enumerable:!0,configurable:!0,writable:!0,value:h}):l[s]=h;var Y=(l,s,h)=>(qn(l,typeof s!="symbol"?s+"":s,h),h);var xe=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Be=(i,e,t,n)=>{for(var r=n>1?void 0:n?We(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&xe(e,t,r),r},ve=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRemoveSheetController=class extends s.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=>{if(e.id===h.RemoveSheetCommand.id){const t=e.params,n=t.unitId?this._univerInstanceService.getUnit(t.unitId):this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return{redos:[],undos:[]};const r=n.getUnitId(),o=t.subUnitId||n.getActiveSheet().getSheetId(),a=this._hyperLinkModel.getSubUnit(r,o),c=a.map(p=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:r,subUnitId:o,id:p.id}})),d=a.map(p=>({id:v.AddHyperLinkMutation.id,params:{unitId:r,subUnitId:o,link:p}}));return{redos:c,undos:d}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=Be([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),ve(0,f.Inject(h.SheetInterceptorService)),ve(1,s.IUniverInstanceService),ve(2,f.Inject(v.HyperLinkModel))],l.SheetsHyperLinkRemoveSheetController);var Fe=Object.defineProperty,$e=Object.getOwnPropertyDescriptor,Pe=(i,e,t,n)=>{for(var r=n>1?void 0:n?$e(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Fe(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRenderController=class extends s.Disposable{constructor(e,t,n,r){super(),this._context=e,this._hyperLinkModel=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{const t=this._context.unit,n=t.getUnitId(),r=t.getActiveSheet().getSheetId(),o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),a=this._renderManagerService.getRenderById(n);o==null||o.makeDirty(!0),o==null||o.calculate(),a&&a.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Pe([z(1,f.Inject(v.HyperLinkModel)),z(2,f.Inject(y.SheetSkeletonManagerService)),z(3,pe.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends s.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:a,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(a,c,r,o),p=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:s.BooleanNumber.TRUE},cl:{rgb:p.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Pe([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),z(0,f.Inject(h.SheetInterceptorService)),z(1,f.Inject(v.HyperLinkModel)),z(2,f.Inject(s.ThemeService))],l.SheetsHyperLinkRenderManagerController);var be={exports:{}},te={};/**
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 qe=C,et=Symbol.for("react.element"),tt=Symbol.for("react.fragment"),nt=Object.prototype.hasOwnProperty,rt=qe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,it={key:!0,ref:!0,__self:!0,__source:!0};function Ie(i,n,t){var e,r={},o=null,a=null;t!==void 0&&(o=""+t),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(a=n.ref);for(e in n)nt.call(n,e)&&!it.hasOwnProperty(e)&&(r[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)r[e]===void 0&&(r[e]=n[e]);return{$$typeof:et,type:i,key:o,ref:a,props:r,_owner:rt.current}}re.Fragment=tt,re.jsx=Ie,re.jsxs=Ie,ke.exports=re;var m=ke.exports,N=function(){return N=Object.assign||function(i){for(var n,t=1,e=arguments.length;t<e;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])}return i},N.apply(this,arguments)},ot=function(i,n){var t={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(t[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)n.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(t[e[r]]=i[e[r]]);return t},$=C.forwardRef(function(i,n){var t=i.icon,e=i.id,r=i.className,o=i.extend,a=ot(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=C.useRef("_".concat(lt()));return Re(t,"".concat(e),{defIds:t.defIds,idSuffix:d.current},N({ref:n,className:c},a),o)});function Re(i,n,t,e,r){return C.createElement(i.tag,N(N({key:n},at(i,t,r)),e),(st(i,t).children||[]).map(function(o,a){return Re(o,"".concat(n,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function at(i,n,t){var e=N({},i.attrs);t!=null&&t.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var a=o[0],c=o[1];typeof c=="string"&&(e[a]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function st(i,n){var t,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?N(N({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&e&&e.indexOf(r.attrs.id)>-1?N(N({},r),{attrs:N(N({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):i}function lt(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var ct={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"}}]},Pe=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"all-border-single",ref:n,icon:ct}))});Pe.displayName="AllBorderSingle";const ge=Pe;var dt={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"}}]},be=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:n,icon:dt}))});be.displayName="CopySingle";const ut=be;var pt={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,n){return C.createElement($,Object.assign({},i,{id:"link-single",ref:n,icon:pt}))});ie.displayName="LinkSingle";var ht={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,n){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:n,icon:ht}))});Oe.displayName="UnlinkSingle";const vt=Oe;var mt={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,n){return C.createElement($,Object.assign({},i,{id:"write-single",ref:n,icon:mt}))});Me.displayName="WriteSingle";const gt=Me;var St={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"}}]},Ee=C.forwardRef(function(i,n){return C.createElement($,Object.assign({},i,{id:"xlsx",ref:n,icon:St}))});Ee.displayName="Xlsx";const He=Ee,ft=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,yt=new RegExp(ft);function J(i){return i.startsWith("http://localhost:3002")||i.startsWith("localhost:3002")?!0:!!i.match(yt)}function we(i){return/^[a-zA-Z]+:\/\//.test(i)}function _t(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function je(i){return J(i)?we(i)?i:_t(i)?`mailto://${i}`:`http://${i}`:i}const Ct={cellLinkEditButtons:"univer-cell-link-edit-buttons"};function Lt(i){if(i===null)return"";if(i!=null&&i.p){const n=i==null?void 0:i.p.body;if(n==null)return"";const t=n.dataStream;return t.substring(t.length-2,t.length)===s.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const oe=()=>{var ue;const[i,n]=C.useState(""),[t,e]=C.useState(""),[r,o]=C.useState("link"),[a,c]=C.useState(""),d=w.useDependency(s.LocaleService),u=w.useDependency(H.IDefinedNamesService),g=w.useDependency(s.IUniverInstanceService),y=w.useDependency(l.SheetsHyperLinkPopupService),h=O.useObservable(y.currentEditing$),P=w.useDependency(v.HyperLinkModel),b=w.useDependency(l.SheetsHyperLinkResolverService),R=w.useDependency(s.ICommandService),[E,j]=C.useState(!1),L=C.useRef(!1);C.useEffect(()=>{var f,k,M;if((h==null?void 0:h.row)!==void 0&&h.column!==void 0){const U=P.getHyperLinkByLocation(h.unitId,h.subUnitId,h.row,h.column);if(U){const Ce=b.parseHyperLink(U.payload);if(n(U.id),e(U.display),Ce.type==="outer"){o("link"),c(Ce.url);return}else{const x=Ce.searchObj;if(x.rangeid){o("rangeid"),c(x.rangeid);return}if(x.range){const nn=x.gid&&(M=(k=(f=g.getUnit(h.unitId))==null?void 0:f.getSheetBySheetId(x.gid))==null?void 0:k.getName())!=null?M:"";o("range"),c(H.serializeRangeWithSheet(nn,H.deserializeRangeWithSheet(x.range).range));return}if(x.gid){o("gid"),c(x.gid);return}}}const G=g.getUnit(h.unitId),W=G==null?void 0:G.getSheetBySheetId(h.subUnitId),tn=W==null?void 0:W.getCellRaw(h.row,h.column),_e=Lt(tn);o("link"),c(""),e((_e!=null?_e:"").toString()),n("");return}o("link"),c(""),e(""),n("")},[h,P,b,g]);const D=C.useMemo(()=>a,[r]),Z=[{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"}],T=g.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!T)return;const K=T.getHiddenWorksheets(),B=T.getSheets().map(f=>({label:f.getName(),value:f.getSheetId()})).filter(f=>K.indexOf(f.value)===-1),F=Object.values((ue=u.getDefinedNameMap(T.getUnitId()))!=null?ue:{}).map(f=>({label:f.name,value:f.id})),te=(f,k)=>{if(f==="link")return we(k)?k:`http://${k}`;if(f==="range"){const M=H.deserializeRangeWithSheet(k),U=T.getSheetBySheetName(M.sheetName);if(U)return`#gid=${U.getSheetId()}&range=${H.serializeRange(M.range)}`}return`#${f}=${k}`},ye=async()=>{h&&(i?await R.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,id:i,payload:{display:t,payload:te(r,a)}}):await R.executeCommand(v.AddHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,link:{id:s.Tools.generateRandomId(),row:h.row,column:h.column,payload:te(r,a),display:t}})),h&&(await R.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:h.unitId,subUnitId:h.subUnitId}),await R.executeCommand(_.ScrollToCellCommand.id,{range:{startRow:h.row,endRow:h.row,startColumn:h.column,endColumn:h.column}})),R.executeCommand(Q.id)};return m.jsxs("div",{children:[m.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:E&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:t,onChange:f=>{e(f),L.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(I.Select,{options:Z,value:r,onChange:f=>{o(f),c("")}})}),r==="link"&&m.jsx(I.FormLayout,{error:E?a?J(a)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(I.Input,{value:a,onChange:f=>{c(f),f&&(L.current||!t)&&(e(f),L.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:T.getUnitId(),id:s.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:D,onChange:f=>{const k=f[0];if(!k||!s.isValidRange(k.range))return;k.sheetName||(k.sheetName=T.getActiveSheet().getName());const M=H.serializeRangeToRefString(k);c(M),M&&(L.current||!t)&&(e(M),L.current=!0)}})}),r==="gid"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:B,value:a,onChange:f=>{var M;c(f);const k=(M=B.find(U=>U.value===f))==null?void 0:M.label;k&&(L.current||!t)&&(e(k),L.current=!0)}})}),r==="rangeid"&&m.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:m.jsx(I.Select,{options:F,value:a,onChange:f=>{var M;c(f);const k=(M=F.find(U=>U.value===f))==null?void 0:M.label;k&&(L.current||!t)&&(e(k),L.current=!0)}})}),m.jsxs("div",{className:Ct.cellLinkEditButtons,children:[m.jsx(I.Button,{onClick:()=>{h&&R.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:h.unitId,subUnitId:h.subUnitId}),R.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!a||r==="link"&&!J(a)){j(!0);return}ye()},children:d.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const ae={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,n){if(!n)return!1;const{unitId:t,subUnitId:e,row:r,column:o}=n,a=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),u=a.getHyperLinkByLocation(t,e,r,o);return d.startEditing(n),c.open({header:{title:u?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:oe.componentKey}}),!0}},Q={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const n=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return n.close(),t.endEditing(),!0}},q={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const n=i.get(s.IUniverInstanceService),t=p.getSheetCommandTarget(n);if(!t)return!1;const e=i.get(s.ICommandService),o=i.get(p.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const a=o.primary.actualRow,c=o.primary.actualColumn;return e.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:a,column:c})}},Te={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const n=i.get(s.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Q.id):n.executeCommand(q.id)}},V={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"},kt={outer:m.jsx(ie,{}),link:m.jsx(ie,{}),sheet:m.jsx(He,{}),range:m.jsx(ge,{}),defineName:m.jsx(ge,{}),"range-error":m.jsx(ge,{}),"sheet-error":m.jsx(He,{})},se=()=>{const i=w.useDependency(l.SheetsHyperLinkPopupService),n=w.useDependency(v.HyperLinkModel),t=w.useDependency(s.ICommandService),e=w.useDependency(O.IMessageService),r=w.useDependency(s.LocaleService),o=w.useObservable(i.currentPopup$,i.currentPopup),a=w.useDependency(l.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:u}=o,g=n.getHyperLink(c,d,u);if(!g)return null;const y=a.parseHyperLink(g.payload),h=y.type.indexOf("error")>-1;return m.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Le(V.cellLinkContent,{[V.cellLinkContentError]:h}),onClick:y.handler,children:[m.jsx("div",{className:V.cellLinkType,children:kt[y.type]}),m.jsx("div",{className:V.cellLinkUrl,children:y.name})]}),m.jsxs("div",{className:V.cellLinkOperations,children:[m.jsx("div",{className:Le(V.cellLinkOperation,{[V.cellLinkOperationError]:h}),onClick:()=>{if(!h){if(y.type!=="outer"){const P=new URL(window.location.href);P.hash=y.url.slice(1),navigator.clipboard.writeText(P.href)}else navigator.clipboard.writeText(y.url);e.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(ut,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:c,subUnitId:d,row:g.row,column:g.column})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(gt,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:g.id})},children:m.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(vt,{})})})]})]})};se.componentKey="univer.sheet.cell-link-popup";var It=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,Pt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Rt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&It(n,t,r),r},Ue=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkPopupService=class{constructor(n,t){A(this,"_currentPopup",null);A(this,"_currentPopup$",new pe.Subject);A(this,"currentPopup$",this._currentPopup$.asObservable());A(this,"_currentEditing$",new pe.BehaviorSubject(null));A(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=n,this._sheetCanvasPopManagerService=t}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(n){this.hideCurrentPopup();const{unitId:t,subUnitId:e,row:r,col:o}=n,a=this._hyperLinkModel.getHyperLinkByLocation(t,e,r,o);if(!a)return;const c=this._sheetCanvasPopManagerService.attachPopupToCell(r,o,{componentKey:se.componentKey,direction:"bottom",closeOnSelfTarget:!0});c&&(this._currentPopup={unitId:t,subUnitId:e,id:a.id,disposable:c},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var n;this._currentPopup&&((n=this._currentPopup.disposable)==null||n.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(n){this._currentEditing$.next(n)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=Pt([Ue(0,S.Inject(v.HyperLinkModel)),Ue(1,S.Inject(_.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var bt=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Mt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ot(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&bt(n,t,r),r},ee=(i,n)=>(t,e)=>n(t,e,i);l.SheetHyperLinkSetRangeController=class extends s.Disposable{constructor(n,t,e,r,o){super(),this._sheetInterceptorService=n,this._injector=t,this._hyperLinkModel=e,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===v.AddHyperLinkCommand.id){const t=n.params,{unitId:e,subUnitId:r,link:o}=t,a={unitId:e,subUnitId:r,cellValue:{[o.row]:{[o.column]:{v:o.display,t:s.CellValueType.STRING,p:null}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:a}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===v.UpdateHyperLinkCommand.id){const t=n.params,{unitId:e,subUnitId:r,id:o,payload:a}=t,c=this._hyperLinkModel.getHyperLink(e,r,o);if(c&&c.display!==a.display){const d={unitId:e,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:a.display,t:s.CellValueType.STRING,p:null}}}};return{redos:[{id:p.SetRangeValuesMutation.id,params:d}],undos:[{id:p.SetRangeValuesMutation.id,params:p.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.SetRangeValuesCommand.id){const t=n.params,{unitId:e,subUnitId:r}=t,o=[],a=[];return t.cellValue&&new s.ObjectMatrix(t.cellValue).forValue((c,d,u)=>{var b,R,E,j;const g=((j=(E=u==null?void 0:u.v)!=null?E:(R=(b=u==null?void 0:u.p)==null?void 0:b.body)==null?void 0:R.dataStream.slice(0,-2))!=null?j:"").toString(),y=this._hyperLinkModel.getHyperLinkByLocation(e,r,c,d);if(!y){if(J(g)){const L=s.Tools.generateRandomId();a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:r,id:L}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:r,link:{id:L,row:c,column:d,display:g,payload:je(g)}}})}return}if(y.display===g)return;g||(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e,subUnitId:r,id:y.id}}),a.push({id:v.AddHyperLinkMutation.id,params:{unitId:e,subUnitId:r,link:y}}));const h={unitId:e,subUnitId:r,id:y.id,payload:{payload:y.payload,display:g}},P={unitId:e,subUnitId:r,id:y.id,payload:{payload:y.payload,display:y.display}};o.push({id:v.UpdateHyperLinkMutation.id,params:h}),a.push({id:v.UpdateHyperLinkMutation.id,params:P})}),{undos:a,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:n=>{if(n.id===p.ClearSelectionContentCommand.id||n.id===p.ClearSelectionAllCommand.id){const t=[],e=[],r=this._selectionManagerService.getFirst(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:a,subUnitId:c}=o;s.Range.foreach(r.range,(d,u)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(a,c,d,u);g&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:g.id}}),e.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:g}}))})}return{redos:t,undos:e}}return{redos:[],undos:[]}}}))}},l.SheetHyperLinkSetRangeController=Mt([s.OnLifecycle(s.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),ee(0,S.Inject(p.SheetInterceptorService)),ee(1,S.Inject(S.Injector)),ee(2,S.Inject(v.HyperLinkModel)),ee(3,S.Inject(p.SelectionManagerService)),ee(4,s.IUniverInstanceService)],l.SheetHyperLinkSetRangeController);var Et=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,wt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Ht(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Et(n,t,r),r},Ne=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkPopupController=class extends s.Disposable{constructor(n,t){super(),this._hoverManagerService=n,this._sheetsHyperLinkPopupService=t,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(pe.debounceTime(100)).subscribe(n=>{if(!n){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup(n.location)}))}},l.SheetsHyperLinkPopupController=wt([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),Ne(0,S.Inject(_.HoverManagerService)),Ne(1,S.Inject(l.SheetsHyperLinkPopupService))],l.SheetsHyperLinkPopupController);const jt=i=>({id:q.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Tt=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:Te.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Se={id:q.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:_.whenSheetEditorFocused};var Ut=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,Dt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Nt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ut(n,t,r),r},Y=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkUIController=class extends s.Disposable{constructor(n,t,e,r,o,a,c){super(),this._config=n,this._componentManager=t,this._commandService=e,this._localeService=r,this._menuService=o,this._injector=a,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[se,se.componentKey],[oe,oe.componentKey],[ie,"LinkSingle"]].forEach(([n,t])=>{this._componentManager.register(t,n)})}_initCommands(){[ae,Q,q,Te].forEach(n=>{this._commandService.registerCommand(n)})}_initMenus(){var n,t,e,r;this._menuService.addMenuItem(jt(this._injector),(t=(n=this._config)==null?void 0:n.menu)!=null?t:{}),this._menuService.addMenuItem(Tt(this._injector),(r=(e=this._config)==null?void 0:e.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(Se)}},l.SheetsHyperLinkUIController=Dt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkUIController),Y(1,S.Inject(O.ComponentManager)),Y(2,s.ICommandService),Y(3,S.Inject(s.LocaleService)),Y(4,O.IMenuService),Y(5,S.Inject(S.Injector)),Y(6,S.Inject(O.IShortcutService))],l.SheetsHyperLinkUIController);var At=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Wt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Vt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&At(n,t,r),r},De=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkAutoFillController=class extends s.Disposable{constructor(n,t){super(),this._autoFillService=n,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:a,target:c,unitId:d,subUnitId:u}=r,g=_.virtualizeDiscreteRanges([a,c]),[y,h]=g.ranges,{mapFunc:P}=g,b={row:y.startRow,col:y.startColumn},R=_.getAutoFillRepeatRange(y,h),E=[],j=[];return R.forEach(L=>{const D=L.repeatStartCell,Z=L.relativeRange,T={startRow:b.row,startColumn:b.col,endColumn:b.col,endRow:b.row},K={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};s.Range.foreach(Z,(B,F)=>{const te=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},T),{row:ye,col:ue}=P(te.startRow,te.startColumn),f=this._hyperLinkModel.getHyperLinkByLocation(d,u,ye,ue);if(f){const k=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},K),{row:M,col:U}=P(k.startRow,k.startColumn),G=s.Tools.generateRandomId(),W=this._hyperLinkModel.getHyperLinkByLocation(d,u,M,U);W&&E.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:W.id}}),_.APPLY_TYPE.COPY===o&&(E.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:{...f,id:G,row:M,column:U}}}),j.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:G}})),W&&j.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:W}})}})}),{undos:j,redos:E}},e={id:ve,onFillData:(r,o,a)=>a===_.APPLY_TYPE.COPY||a===_.APPLY_TYPE.ONLY_FORMAT||a===_.APPLY_TYPE.SERIES?t(r,a):n()};this.disposeWithMe(this._autoFillService.addHook(e))}},l.SheetsHyperLinkAutoFillController=Wt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),De(0,_.IAutoFillService),De(1,S.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var xt=Object.defineProperty,$t=Object.getOwnPropertyDescriptor,Bt=(i,n,t,e)=>{for(var r=e>1?void 0:e?$t(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&xt(n,t,r),r},le=(i,n)=>(t,e)=>n(t,e,i);l.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(t,e,r,o){super();A(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=e,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:ve,onBeforeCopy:(t,e,r)=>this._collect(t,e,r),onPasteCells:(t,e,r,o)=>{const{copyType:a=_.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:u,unitId:g,subUnitId:y}=e;return this._generateMutations(u,{copyType:a,pasteType:c,copyRange:d,unitId:g,subUnitId:y})},onPastePlainText:(t,e)=>{if(J(e)){let r=je(e);const o=new URL(r),a=e;o.hostname===location.hostname&&o.port===location.port&&o.protocol===location.protocol&&o.pathname===location.pathname&&o.hash&&(r=o.hash);const{range:c,unitId:d,subUnitId:u}=t,{ranges:[g],mapFunc:y}=_.virtualizeDiscreteRanges([c]),h=[],P=[];return s.Range.foreach(g,(b,R)=>{const{row:E,col:j}=y(b,R),L=this._hyperLinkModel.getHyperLinkByLocation(d,u,E,j);L&&h.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:L.id}});const D=s.Tools.generateRandomId();h.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:{id:D,row:E,column:j,display:a,payload:r}}}),P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:u,id:D}}),L&&P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:u,link:L}})}),{redos:h,undos:P}}return{undos:[],redos:[]}}})}_collect(t,e,r){const o=new s.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:e,matrix:o};const a={get:this._injector.get.bind(this._injector)},c=_.rangeToDiscreteRange(r,a,t,e);if(!c)return;const{rows:d,cols:u}=c;d.forEach((g,y)=>{u.forEach((h,P)=>{var R;const b=this._hyperLinkModel.getHyperLinkByLocation(t,e,g,h);o.setValue(y,P,(R=b==null?void 0:b.id)!=null?R:"")})})}_generateMutations(t,e){if(!this._copyInfo)return{redos:[],undos:[]};if(e.copyType===_.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!e.copyRange)return{redos:[],undos:[]};if([_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,_.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,Ve.SPECIAL_PASTE_FORMULA].includes(e.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,a=[],c=[],{ranges:[d,u],mapFunc:g}=_.virtualizeDiscreteRanges([e.copyRange,t]);return _.getRepeatRange(d,u,!0).forEach(({startRange:h})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((b,R,E)=>{const j=s.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:R,endColumn:R},h),L=this._hyperLinkModel.getHyperLink(r,o,E),{row:D,col:Z}=g(j.startRow,j.startColumn),T=this._hyperLinkModel.getHyperLinkByLocation(e.unitId,e.subUnitId,D,Z),K=s.Tools.generateRandomId();T&&a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,id:T.id}}),L&&(a.push({id:v.AddHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,link:{...L,id:K,row:D,column:Z}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,id:K}})),T&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:e.unitId,subUnitId:e.subUnitId,link:T}})})}),{redos:a,undos:c}}},l.SheetsHyperLinkCopyPasteController=Bt([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),le(0,_.ISheetClipboardService),le(1,S.Inject(v.HyperLinkModel)),le(2,S.Inject(S.Injector)),le(3,S.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var Ft=Object.defineProperty,zt=Object.getOwnPropertyDescriptor,Yt=(i,n,t,e)=>{for(var r=e>1?void 0:e?zt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Ft(n,t,r),r},Zt=(i,n)=>(t,e)=>n(t,e,i);l.SheetHyperLinkUrlController=class extends s.Disposable{constructor(n){super(),this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const n=location.hash;n&&this._resolverService.parseHyperLink(n).handler()}},l.SheetHyperLinkUrlController=Yt([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Zt(0,S.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var Kt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Xt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Gt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Kt(n,t,r),r},fe=(i,n)=>(t,e)=>n(t,e,i);let ce=class extends s.Disposable{constructor(i,n,t){super(),this._localeService=i,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===Se.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[p.WorkbookEditablePermission],rangeTypes:[p.RangeProtectionPermissionEditPoint],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ce=Xt([s.OnLifecycle(s.LifecycleStages.Rendered,ce),fe(0,S.Inject(s.LocaleService)),fe(1,s.ICommandService),fe(2,S.Inject(_.SheetPermissionInterceptorBaseController))],ce);var Jt=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,qt=(i,n,t,e)=>{for(var r=e>1?void 0:e?Qt(n,t):n,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(n,t,r):a(r))||r);return e&&r&&Jt(n,t,r),r},en=(i,n)=>(t,e)=>n(t,e,i);l.UniverSheetsHyperLinkUIPlugin=(de=class extends v.UniverSheetsHyperLinkPlugin{constructor(n,t){super(n,t),this._config=n,this._injector=t}onStarting(n){super.onStarting(n),[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRefRangeController],[l.SheetsHyperLinkRenderController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ce],[l.SheetHyperLinkUrlController]].forEach(e=>{n.add(e)})}},A(de,"pluginName",ve),A(de,"type",s.UniverInstanceType.UNIVER_SHEET),de),l.UniverSheetsHyperLinkUIPlugin=qt([en(1,S.Inject(S.Injector))],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=q,l.InsertLinkShortcut=Se,l.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
9
+ */var Ye=C,ze=Symbol.for("react.element"),Ze=Symbol.for("react.fragment"),Ke=Object.prototype.hasOwnProperty,Ge=Ye.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0};function Ee(i,e,t){var n,r={},o=null,a=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(n in e)Ke.call(e,n)&&!Xe.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:ze,type:i,key:o,ref:a,props:r,_owner:Ge.current}}te.Fragment=Ze,te.jsx=Ee,te.jsxs=Ee,be.exports=te;var g=be.exports,U=function(){return U=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},U.apply(this,arguments)},Je=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},$=C.forwardRef(function(i,e){var t=i.icon,n=i.id,r=i.className,o=i.extend,a=Je(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(n," ").concat(r||"").trim(),d=C.useRef("_".concat(en()));return Oe(t,"".concat(n),{defIds:t.defIds,idSuffix:d.current},U({ref:e,className:c},a),o)});function Oe(i,e,t,n,r){return C.createElement(i.tag,U(U({key:e},Qe(i,t,r)),n),(qe(i,t).children||[]).map(function(o,a){return Oe(o,"".concat(e,"-").concat(i.tag,"-").concat(a),t,void 0,r)}))}function Qe(i,e,t){var n=U({},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 a=o[0],c=o[1];typeof c=="string"&&(n[a]=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)?U(U({},i),{children:i.children.map(function(r){return typeof r.attrs.id=="string"&&n&&n.indexOf(r.attrs.id)>-1?U(U({},r),{attrs:U(U({},r.attrs),{id:r.attrs.id+e.idSuffix})}):r})}):i}function en(){return Math.random().toString(36).substring(2,8)}$.displayName="UniverIcon";var nn={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($,Object.assign({},i,{id:"all-border-single",ref:e,icon:nn}))});re.displayName="AllBorderSingle";var tn={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"}}]},Me=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:e,icon:tn}))});Me.displayName="CopySingle";var rn={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($,Object.assign({},i,{id:"link-single",ref:e,icon:rn}))});ie.displayName="LinkSingle";var on={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"}}]},He=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:e,icon:on}))});He.displayName="UnlinkSingle";var an={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"}}]},we=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"write-single",ref:e,icon:an}))});we.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($,Object.assign({},i,{id:"xlsx",ref:e,icon:sn}))});me.displayName="Xlsx";var ln=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,dn=(i,e,t,n)=>{for(var r=n>1?void 0:n?cn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&ln(e,t,r),r},X=(i,e)=>(t,n)=>e(t,n,i);function un(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===s.RANGE_TYPE.COLUMN||s.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(a=>{s.Rectangle.intersects(i,a)&&o.push(a)}),s.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(s.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const a=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=a==null?void 0:a.getName())!=null?d:"";if(n){const p=D.deserializeRangeWithSheet(n).range;return s.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(s.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r&&this.navigateToDefineName(a,r),!!t){if(n){const c=D.deserializeRangeWithSheet(n);s.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(a,t,c.range);return}this.navigateToSheetById(a,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),a={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(a);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:a,handler:()=>{this.navigateTo(a)}}}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=un(n,r);await this._commandService.executeCommand(h.SetSelectionsOperation.id,{unitId:e,subUnitId:t,pluginName:h.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}),await this._commandService.executeCommand(y.ScrollToRangeOperation.id,{range:o})}}async navigateToSheet(e,t){const n=this._univerInstanceService.getUnit(e,s.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:L.MessageType.Error});return}const a=o.getSheetId();return n.getHiddenWorksheets().indexOf(a)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:L.MessageType.Error}),await this._commandService.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:a})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,s.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();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:L.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:L.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=dn([X(0,s.IUniverInstanceService),X(1,s.ICommandService),X(2,D.IDefinedNamesService),X(3,P.IMessageService),X(4,f.Inject(s.LocaleService))],l.SheetsHyperLinkResolverService);const pn=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,hn=new RegExp(pn);function J(i){return Number.isNaN(+i)?i.startsWith("http://localhost:3002")||i.startsWith("localhost:3002")?!0:!!i.match(hn):!1}function vn(i){return/^[a-zA-Z]+:\/\//.test(i)}function mn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function ge(i){if(J(i)){const e=vn(i)?i:mn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);if(t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search)return t.hash}return i}function gn(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)===s.DEFAULT_EMPTY_DOCUMENT_VALUE?t.substring(0,t.length-2):t}return i==null?void 0:i.v}const Sn={cellLinkEditButtons:"univer-cell-link-edit-buttons"},oe=()=>{var ne;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[a,c]=C.useState(""),d=w.useDependency(s.LocaleService),p=w.useDependency(D.IDefinedNamesService),S=w.useDependency(s.IUniverInstanceService),_=w.useDependency(l.SheetsHyperLinkPopupService),u=P.useObservable(_.currentEditing$),E=w.useDependency(v.HyperLinkModel),R=w.useDependency(l.SheetsHyperLinkResolverService),I=w.useDependency(s.ICommandService),[b,N]=C.useState(!1),M=C.useRef(!1);C.useEffect(()=>{var m,k,H;if((u==null?void 0:u.row)!==void 0&&u.column!==void 0){const O=E.getHyperLinkByLocationSync(u.unitId,u.subUnitId,u.row,u.column);if(O){const ue=R.parseHyperLink(O.payload);if(e(O.id),n(O.display),ue.type==="outer"){o("link"),c(ue.url),ue.url===O.display&&(M.current=!0);return}else{const W=ue.searchObj;if(W.rangeid){o("rangeid"),c(W.rangeid);return}if(W.range){const Jn=W.gid&&(H=(k=(m=S.getUnit(u.unitId))==null?void 0:m.getSheetBySheetId(W.gid))==null?void 0:k.getName())!=null?H:"";if(o("range"),W.range===v.ERROR_RANGE)c("");else{const De=D.serializeRangeWithSheet(Jn,D.deserializeRangeWithSheet(W.range).range);c(De),De===O.display&&(M.current=!0)}return}if(W.gid){o("gid"),c(W.gid);return}}}const T=S.getUnit(u.unitId),A=T==null?void 0:T.getSheetBySheetId(u.subUnitId),Xn=A==null?void 0:A.getCellRaw(u.row,u.column),ke=gn(Xn);o("link"),c(""),n((ke!=null?ke:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[u,E,R,S]);const x=C.useMemo(()=>a,[r]),K=[{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"}],j=S.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!j)return;const G=j.getHiddenWorksheets(),B=j.getSheets().map(m=>({label:m.getName(),value:m.getSheetId()})).filter(m=>G.indexOf(m.value)===-1),F=Object.values((ne=p.getDefinedNameMap(j.getUnitId()))!=null?ne:{}).map(m=>({label:m.name,value:m.id})),ee=(m,k)=>{if(m==="link")return ge(k);if(m==="range"){const H=D.deserializeRangeWithSheet(k),O=j.getSheetBySheetName(H.sheetName);if(O)return`#gid=${O.getSheetId()}&range=${D.serializeRange(H.range)}`}return`#${m}=${k}`},Le=P.useEvent(m=>{const k=m[0];if(!k||!s.isValidRange(k.range))return;k.sheetName||(k.sheetName=j.getActiveSheet().getName());const H=D.serializeRangeToRefString(k);c(H),H&&(M.current||!t)&&(n(H),M.current=!0)}),Ie=async()=>{if(u&&(i?await I.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,id:i,payload:{display:t,payload:ee(r,a)}}):await I.executeCommand(v.AddHyperLinkCommand.id,{unitId:u.unitId,subUnitId:u.subUnitId,link:{id:s.Tools.generateRandomId(),row:u.row,column:u.column,payload:ee(r,a),display:t}})),u){await I.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId});const m=5;await I.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(u.row-m,0),endRow:u.row+m,startColumn:Math.max(u.column-m,0),endColumn:u.column+m}})}I.executeCommand(Q.id)};return g.jsxs("div",{children:[g.jsx(L.FormLayout,{label:d.t("hyperLink.form.label"),error:b&&!t?d.t("hyperLink.form.inputError"):"",children:g.jsx(L.Input,{value:t,onChange:m=>{n(m),M.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),g.jsx(L.FormLayout,{label:d.t("hyperLink.form.type"),children:g.jsx(L.Select,{options:K,value:r,onChange:m=>{o(m),c("")}})}),r==="link"&&g.jsx(L.FormLayout,{error:b?a?J(a)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:g.jsx(L.Input,{value:a,onChange:m=>{c(m),m&&(M.current||!t||t===a)&&(n(m),M.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&g.jsx(L.FormLayout,{error:b&&!a?d.t("hyperLink.form.inputError"):"",children:g.jsx(P.RangeSelector,{openForSheetUnitId:j.getUnitId(),id:s.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:x,onChange:Le})}),r==="gid"&&g.jsx(L.FormLayout,{error:b&&!a?d.t("hyperLink.form.selectError"):"",children:g.jsx(L.Select,{options:B,value:a,onChange:m=>{var O,T;c(m);const k=(O=B.find(A=>A.value===m))==null?void 0:O.label,H=(T=B.find(A=>A.value===a))==null?void 0:T.label;k&&(M.current||!t||t===H)&&(n(k),M.current=!0)}})}),r==="rangeid"&&g.jsx(L.FormLayout,{error:b&&!a?d.t("hyperLink.form.selectError"):"",children:g.jsx(L.Select,{options:F,value:a,onChange:m=>{var O,T;c(m);const k=(O=F.find(A=>A.value===m))==null?void 0:O.label,H=(T=F.find(A=>A.value===a))==null?void 0:T.label;k&&(M.current||!t||t===H)&&(n(k),M.current=!0)}})}),g.jsxs("div",{className:Sn.cellLinkEditButtons,children:[g.jsx(L.Button,{onClick:()=>{u&&I.executeCommand(h.SetWorksheetActiveOperation.id,{unitId:u.unitId,subUnitId:u.subUnitId}),I.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),g.jsx(L.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!a||r==="link"&&!J(a)){N(!0);return}Ie()},children:d.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const ae={type:s.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,a=i.get(v.HyperLinkModel),c=i.get(P.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),p=a.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}},Q={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(P.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(s.IUniverInstanceService),t=h.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(s.ICommandService),o=i.get(h.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const a=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:a,column:c})}},Se={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(s.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(Q.id):e.executeCommand(se.id)}},V={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"},fn={outer:g.jsx(ie,{}),link:g.jsx(ie,{}),sheet:g.jsx(me,{}),range:g.jsx(re,{}),defineName:g.jsx(re,{}),"range-error":g.jsx(re,{}),"sheet-error":g.jsx(me,{})},le=()=>{const i=w.useDependency(l.SheetsHyperLinkPopupService),e=w.useDependency(v.HyperLinkModel),t=w.useDependency(s.ICommandService),n=w.useDependency(P.IMessageService),r=w.useDependency(s.LocaleService),o=w.useObservable(i.currentPopup$,i.currentPopup),a=w.useDependency(l.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:p}=o,S=e.getHyperLink(c,d,p);if(!S)return null;const _=a.parseHyperLink(S.payload),u=_.type.indexOf("error")>-1;return g.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[g.jsxs("div",{className:Re(V.cellLinkContent,{[V.cellLinkContentError]:u}),onClick:_.handler,children:[g.jsx("div",{className:V.cellLinkType,children:fn[_.type]}),g.jsx("div",{className:V.cellLinkUrl,children:_.name})]}),g.jsxs("div",{className:V.cellLinkOperations,children:[g.jsx("div",{className:Re(V.cellLinkOperation,{[V.cellLinkOperationError]:u}),onClick:()=>{if(!u){if(_.type!=="outer"){const E=new URL(window.location.href);E.hash=_.url.slice(1),navigator.clipboard.writeText(E.href)}else navigator.clipboard.writeText(_.url);n.show({content:r.t("hyperLink.message.coped"),type:L.MessageType.Info})}},children:g.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:g.jsx(Me,{})})}),g.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:c,subUnitId:d,row:S.row,column:S.column})},children:g.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:g.jsx(we,{})})}),g.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:S.id})},children:g.jsx(L.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:g.jsx(He,{})})})]})]})};le.componentKey="univer.sheet.cell-link-popup";var yn=Object.defineProperty,_n=Object.getOwnPropertyDescriptor,Cn=(i,e,t,n)=>{for(var r=n>1?void 0:n?_n(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&yn(e,t,r),r},je=(i,e)=>(t,n)=>e(t,n,i);const Ln=(i,e)=>i.unitId===e.unitId&&i.subUnitId===e.subUnitId&&i.row===e.row&&i.col===e.col;l.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(t,n){super();Y(this,"_currentPopup",null);Y(this,"_currentPopup$",new he.Subject);Y(this,"currentPopup$",this._currentPopup$.asObservable());Y(this,"_currentEditing$",new he.BehaviorSubject(null));Y(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&&Ln(t,this._currentPopup))return;this.hideCurrentPopup();const{unitId:n,subUnitId:r,row:o,col:a}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,a);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,a,{componentKey:le.componentKey,direction:"bottom",closeOnSelfTarget:!0});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:a},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=Cn([je(0,f.Inject(v.HyperLinkModel)),je(1,f.Inject(y.SheetCanvasPopManagerService))],l.SheetsHyperLinkPopupService);var In=Object.defineProperty,kn=Object.getOwnPropertyDescriptor,Rn=(i,e,t,n)=>{for(var r=n>1?void 0:n?kn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&In(e,t,r),r},q=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends s.Disposable{constructor(e,t,n,r,o){super(),this._sheetInterceptorService=e,this._injector=t,this._hyperLinkModel=n,this._selectionManagerService=r,this._univerInstanceService=o,this._initCommandInterceptor()}_initCommandInterceptor(){this._initAddHyperLinkCommandInterceptor(),this._initSetRangeValuesCommandInterceptor(),this._initUpdateHyperLinkCommandInterceptor(),this._initClearSelectionCommandInterceptor()}_initAddHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.AddHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,link:o}=t,a={unitId:n,subUnitId:r,cellValue:{[o.row]:{[o.column]:{v:o.display,t:s.CellValueType.STRING,p:null}}}};return{redos:[{id:h.SetRangeValuesMutation.id,params:a}],undos:[{id:h.SetRangeValuesMutation.id,params:h.SetRangeValuesUndoMutationFactory(this._injector,a)}]}}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:a}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==a.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:a.display,t:s.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=[],a=[];return t.cellValue&&new s.ObjectMatrix(t.cellValue).forValue((c,d,p)=>{var E,R,I;const S=(I=p==null?void 0:p.v)!=null?I:(R=(E=p==null?void 0:p.p)==null?void 0:E.body)==null?void 0:R.dataStream.slice(0,-2),_=(S!=null?S:"").toString(),u=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!u){if(J(_)){const b=s.Tools.generateRandomId();a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:b}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:b,row:c,column:d,display:_,payload:ge(_)}}})}return}S===""&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:u.id}}),a.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:u}}))}),{undos:a,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===h.ClearSelectionContentCommand.id||e.id===h.ClearSelectionAllCommand.id){const t=[],n=[],r=this._selectionManagerService.getFirst(),o=h.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:a,subUnitId:c}=o;s.Range.foreach(r.range,(d,p)=>{const S=this._hyperLinkModel.getHyperLinkByLocation(a,c,d,p);S&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:S.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:S}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}},l.SheetHyperLinkSetRangeController=Rn([s.OnLifecycle(s.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),q(0,f.Inject(h.SheetInterceptorService)),q(1,f.Inject(f.Injector)),q(2,f.Inject(v.HyperLinkModel)),q(3,f.Inject(h.SelectionManagerService)),q(4,s.IUniverInstanceService)],l.SheetHyperLinkSetRangeController);var Pn=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,En=(i,e,t,n)=>{for(var r=n>1?void 0:n?bn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Pn(e,t,r),r},fe=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends s.Disposable{constructor(e,t,n){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(he.debounceTime(100)).subscribe(e=>{var c,d;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(d=(c=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:c.with(y.SheetSkeletonManagerService).getUnitSkeleton(e.location.unitId,e.location.subUnitId))==null?void 0:d.skeleton,n=e.location.col,r=e.location.row;let o=r,a=n;t&&t.overflowCache.forValue((p,S,_)=>{s.Rectangle.contains(_,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=p,a=S)}),this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:a})}))}},l.SheetsHyperLinkPopupController=En([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),fe(0,f.Inject(y.HoverManagerService)),fe(1,f.Inject(l.SheetsHyperLinkPopupService)),fe(2,f.Inject(pe.IRenderManagerService))],l.SheetsHyperLinkPopupController);const On=i=>({id:se.id,type:P.MenuItemType.BUTTON,positions:[P.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:P.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:y.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),Mn=i=>({tooltip:"hyperLink.form.addTitle",positions:P.MenuPosition.TOOLBAR_START,group:P.MenuGroup.TOOLBAR_OTHERS,id:Se.id,type:P.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:P.getMenuHiddenObservable(i,s.UniverInstanceType.UNIVER_SHEET),disabled$:y.getCurrentRangeDisable$(i,{workbookTypes:[h.WorkbookEditablePermission],worksheetTypes:[h.WorksheetEditPermission,h.WorksheetSetCellValuePermission,h.WorksheetInsertHyperlinkPermission],rangeTypes:[h.RangeProtectionPermissionEditPoint]})}),ye={id:Se.id,binding:P.KeyCode.K|P.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Hn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,jn=(i,e,t,n)=>{for(var r=n>1?void 0:n?wn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Hn(e,t,r),r},Z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkUIController=class extends s.Disposable{constructor(e,t,n,r,o,a,c){super(),this._config=e,this._componentManager=t,this._commandService=n,this._localeService=r,this._menuService=o,this._injector=a,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(){[ae,Q,se,Se].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){var e,t,n,r;this._menuService.addMenuItem(On(this._injector),(t=(e=this._config)==null?void 0:e.menu)!=null?t:{}),this._menuService.addMenuItem(Mn(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(ye)}},l.SheetsHyperLinkUIController=jn([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkUIController),Z(1,f.Inject(P.ComponentManager)),Z(2,s.ICommandService),Z(3,f.Inject(s.LocaleService)),Z(4,P.IMenuService),Z(5,f.Inject(f.Injector)),Z(6,f.Inject(P.IShortcutService))],l.SheetsHyperLinkUIController);const _e="SHEET_HYPER_LINK_UI_PLUGIN";var Tn=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,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Tn(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends s.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:a,target:c,unitId:d,subUnitId:p}=r,S=y.virtualizeDiscreteRanges([a,c]),[_,u]=S.ranges,{mapFunc:E}=S,R={row:_.startRow,col:_.startColumn},I=y.getAutoFillRepeatRange(_,u),b=[],N=[];return I.forEach(M=>{const x=M.repeatStartCell,K=M.relativeRange,j={startRow:R.row,startColumn:R.col,endColumn:R.col,endRow:R.row},G={startRow:x.row,startColumn:x.col,endColumn:x.col,endRow:x.row};s.Range.foreach(K,(B,F)=>{const ee=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},j),{row:Le,col:Ie}=E(ee.startRow,ee.startColumn),ne=this._hyperLinkModel.getHyperLinkByLocation(d,p,Le,Ie);if(ne){const m=s.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},G),{row:k,col:H}=E(m.startRow,m.startColumn),O=s.Tools.generateRandomId(),T=this._hyperLinkModel.getHyperLinkByLocation(d,p,k,H);T&&b.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:T.id}}),(y.APPLY_TYPE.COPY===o||y.APPLY_TYPE.SERIES===o)&&(b.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:{...ne,id:O,row:k,column:H}}}),N.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:p,id:O}})),T&&N.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:p,link:T}})}})}),{undos:N,redos:b}},n={id:_e,onFillData:(r,o,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?t(r,a):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=Nn([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkAutoFillController),Te(0,y.IAutoFillService),Te(1,f.Inject(v.HyperLinkModel))],l.SheetsHyperLinkAutoFillController);var An=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,Vn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Dn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&An(e,t,r),r},ce=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends s.Disposable{constructor(t,n,r,o){super();Y(this,"_copyInfo");this._sheetClipboardService=t,this._hyperLinkModel=n,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:_e,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,o)=>{const{copyType:a=y.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:p,unitId:S,subUnitId:_}=n;return this._generateMutations(p,{copyType:a,pasteType:c,copyRange:d,unitId:S,subUnitId:_})},onPastePlainText:(t,n)=>{if(J(n)){const r=ge(n),{range:o,unitId:a,subUnitId:c}=t,{ranges:[d],mapFunc:p}=y.virtualizeDiscreteRanges([o]),S=[],_=[];return s.Range.foreach(d,(u,E)=>{const{row:R,col:I}=p(u,E),b=this._hyperLinkModel.getHyperLinkByLocation(a,c,R,I);b&&S.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:b.id}});const N=s.Tools.generateRandomId();S.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:{id:N,row:R,column:I,payload:r}}}),_.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:N}}),b&&_.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:b}})}),{redos:S,undos:_}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new s.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const a={get:this._injector.get.bind(this._injector)},c=y.rangeToDiscreteRange(r,a,t,n);if(!c)return;const{rows:d,cols:p}=c;d.forEach((S,_)=>{p.forEach((u,E)=>{var I;const R=this._hyperLinkModel.getHyperLinkByLocation(t,n,S,u);o.setValue(_,E,(I=R==null?void 0:R.id)!=null?I:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===y.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,y.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,Ve.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,a=[],c=[],{ranges:[d,p],mapFunc:S}=y.virtualizeDiscreteRanges([n.copyRange,t]);return y.getRepeatRange(d,p,!0).forEach(({startRange:u})=>{var E;(E=this._copyInfo)==null||E.matrix.forValue((R,I,b)=>{const N=s.Rectangle.getPositionRange({startRow:R,endRow:R,startColumn:I,endColumn:I},u),M=this._hyperLinkModel.getHyperLink(r,o,b),{row:x,col:K}=S(N.startRow,N.startColumn),j=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,x,K),G=s.Tools.generateRandomId();j&&a.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:j.id}}),M&&(a.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...M,id:G,row:x,column:K}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:G}})),j&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:j}})})}),{redos:a,undos:c}}},l.SheetsHyperLinkCopyPasteController=Vn([s.OnLifecycle(s.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),ce(0,y.ISheetClipboardService),ce(1,f.Inject(v.HyperLinkModel)),ce(2,f.Inject(f.Injector)),ce(3,f.Inject(l.SheetsHyperLinkResolverService))],l.SheetsHyperLinkCopyPasteController);var xn=Object.defineProperty,Wn=Object.getOwnPropertyDescriptor,Bn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Wn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&xn(e,t,r),r},Fn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends s.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Bn([s.OnLifecycle(s.LifecycleStages.Rendered,l.SheetHyperLinkUrlController),Fn(0,f.Inject(l.SheetsHyperLinkResolverService))],l.SheetHyperLinkUrlController);var $n=Object.defineProperty,Yn=Object.getOwnPropertyDescriptor,zn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Yn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&$n(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let de=class extends s.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===ye.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=zn([s.OnLifecycle(s.LifecycleStages.Rendered,de),Ce(0,f.Inject(s.LocaleService)),Ce(1,s.ICommandService),Ce(2,f.Inject(y.SheetPermissionInterceptorBaseController))],de);var Ue=Object.defineProperty,Zn=Object.getOwnPropertyDescriptor,Kn=(i,e,t)=>e in i?Ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Gn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Zn(e,t):e,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(n?a(e,t,r):a(r))||r);return n&&r&&Ue(e,t,r),r},Ne=(i,e)=>(t,n)=>e(t,n,i),Ae=(i,e,t)=>(Kn(i,typeof e!="symbol"?e+"":e,t),t);l.UniverSheetsHyperLinkUIPlugin=class extends s.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)),this._renderManagerService.registerRenderController(s.UniverInstanceType.UNIVER_SHEET,l.SheetsHyperLinkRenderController)}},Ae(l.UniverSheetsHyperLinkUIPlugin,"pluginName",_e),Ae(l.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=Gn([s.DependentOn(v.UniverSheetsHyperLinkPlugin),Ne(1,f.Inject(f.Injector)),Ne(2,pe.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=se,l.InsertLinkShortcut=ye,l.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(l,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.1.13",
3
+ "version": "0.1.15",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -34,8 +34,8 @@
34
34
  "require": "./lib/cjs/*",
35
35
  "types": "./lib/types/index.d.ts"
36
36
  },
37
- "./locale/*": "./lib/locale/*.json",
38
- "./lib/*": "./lib/*"
37
+ "./lib/*": "./lib/*",
38
+ "./locale/*": "./lib/locale/*.json"
39
39
  },
40
40
  "main": "./lib/cjs/index.js",
41
41
  "module": "./lib/es/index.js",
@@ -50,45 +50,60 @@
50
50
  "lib"
51
51
  ],
52
52
  "peerDependencies": {
53
- "@wendellhu/redi": "0.15.2",
53
+ "@wendellhu/redi": "0.15.4",
54
54
  "clsx": ">=2.0.0",
55
55
  "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
56
56
  "rxjs": ">=7.0.0",
57
- "@univerjs/design": "0.1.13",
58
- "@univerjs/engine-formula": "0.1.13",
59
- "@univerjs/core": "0.1.13",
60
- "@univerjs/engine-render": "0.1.13",
61
- "@univerjs/sheets-formula": "0.1.13",
62
- "@univerjs/sheets": "0.1.13",
63
- "@univerjs/sheets-hyper-link": "0.1.13",
64
- "@univerjs/sheets-ui": "0.1.13",
65
- "@univerjs/ui": "0.1.13"
57
+ "@univerjs/core": "0.1.15",
58
+ "@univerjs/design": "0.1.15",
59
+ "@univerjs/engine-formula": "0.1.15",
60
+ "@univerjs/sheets": "0.1.15",
61
+ "@univerjs/engine-render": "0.1.15",
62
+ "@univerjs/sheets-formula": "0.1.15",
63
+ "@univerjs/sheets-hyper-link": "0.1.15",
64
+ "@univerjs/sheets-ui": "0.1.15",
65
+ "@univerjs/ui": "0.1.15"
66
66
  },
67
67
  "dependencies": {
68
- "@univerjs/icons": "^0.1.55",
69
- "@univerjs/sheets-hyper-link": "0.1.13"
68
+ "@univerjs/icons": "^0.1.56",
69
+ "@univerjs/sheets-hyper-link": "0.1.15"
70
70
  },
71
71
  "devDependencies": {
72
- "@wendellhu/redi": "^0.15.2",
72
+ "@wendellhu/redi": "^0.15.4",
73
73
  "clsx": "^2.1.1",
74
74
  "rxjs": "^7.8.1",
75
75
  "typescript": "^5.4.5",
76
- "vite": "^5.2.12",
76
+ "vite": "^5.2.13",
77
77
  "vitest": "^1.6.0",
78
- "@univerjs/engine-formula": "0.1.13",
79
- "@univerjs/engine-render": "0.1.13",
80
- "@univerjs/shared": "0.1.13",
81
- "@univerjs/sheets": "0.1.13",
82
- "@univerjs/core": "0.1.13",
83
- "@univerjs/sheets-formula": "0.1.13",
84
- "@univerjs/sheets-ui": "0.1.13",
85
- "@univerjs/ui": "0.1.13"
78
+ "@univerjs/core": "0.1.15",
79
+ "@univerjs/engine-formula": "0.1.15",
80
+ "@univerjs/engine-render": "0.1.15",
81
+ "@univerjs/shared": "0.1.15",
82
+ "@univerjs/sheets": "0.1.15",
83
+ "@univerjs/sheets-formula": "0.1.15",
84
+ "@univerjs/sheets-ui": "0.1.15",
85
+ "@univerjs/ui": "0.1.15"
86
+ },
87
+ "univerSpace": {
88
+ ".": {
89
+ "import": "./lib/es/index.js",
90
+ "require": "./lib/cjs/index.js",
91
+ "types": "./lib/types/index.d.ts"
92
+ },
93
+ "./*": {
94
+ "import": "./lib/es/*",
95
+ "require": "./lib/cjs/*",
96
+ "types": "./lib/types/index.d.ts"
97
+ },
98
+ "./lib/*": "./lib/*",
99
+ "./locale/*": "./lib/locale/*.json"
86
100
  },
87
101
  "scripts": {
88
102
  "test": "vitest run",
89
103
  "test:watch": "vitest",
90
104
  "coverage": "vitest run --coverage",
91
105
  "lint:types": "tsc --noEmit",
92
- "build": "tsc && vite build"
106
+ "build": "tsc && vite build",
107
+ "sync:cnpm": "cnpm sync"
93
108
  }
94
109
  }
@@ -1,20 +0,0 @@
1
- import { Disposable, IUniverInstanceService } from '@univerjs/core';
2
- import { RefRangeService } from '@univerjs/sheets';
3
- import { HyperLinkModel } from '@univerjs/sheets-hyper-link';
4
- import { SheetsHyperLinkResolverService } from '../services/resolver.service';
5
-
6
- export declare class SheetsHyperLinkRefRangeController extends Disposable {
7
- private readonly _refRangeService;
8
- private readonly _hyperLinkModel;
9
- private readonly _resolverService;
10
- private readonly _univerInstanceService;
11
- private _disposableMap;
12
- private _rangeDisableMap;
13
- constructor(_refRangeService: RefRangeService, _hyperLinkModel: HyperLinkModel, _resolverService: SheetsHyperLinkResolverService, _univerInstanceService: IUniverInstanceService);
14
- private _register;
15
- private _unregister;
16
- private _registerRange;
17
- private _unregisterRange;
18
- private _initData;
19
- private _initRefRange;
20
- }