@univerjs/sheets-hyper-link-ui 0.1.14 → 0.1.16

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.
@@ -10,7 +10,7 @@
10
10
  "range": "Range",
11
11
  "worksheet": "Worksheet",
12
12
  "definedName": "Defined Name",
13
- "ok": "OK",
13
+ "ok": "Confirm",
14
14
  "cancel": "Cancel",
15
15
  "labelPlaceholder": "Enter label",
16
16
  "inputError": "Please enter",
@@ -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,14 @@
1
- import { Disposable } from '@univerjs/core';
2
- import { HoverManagerService } from '@univerjs/sheets-ui';
1
+ import { Disposable, IPermissionService } from '@univerjs/core';
2
+ import { HoverManagerService, SheetPermissionInterceptorBaseController } 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
+ private readonly _permissionService;
11
+ private readonly _sheetPermissionInterceptorBaseController;
12
+ constructor(_hoverManagerService: HoverManagerService, _sheetsHyperLinkPopupService: SheetsHyperLinkPopupService, _renderManagerService: IRenderManagerService, _permissionService: IPermissionService, _sheetPermissionInterceptorBaseController: SheetPermissionInterceptorBaseController);
9
13
  private _initHoverListener;
10
14
  }
@@ -15,4 +15,5 @@ export declare class SheetHyperLinkSetRangeController extends Disposable {
15
15
  private _initUpdateHyperLinkCommandInterceptor;
16
16
  private _initSetRangeValuesCommandInterceptor;
17
17
  private _initClearSelectionCommandInterceptor;
18
+ private _getCurrentCell;
18
19
  }
@@ -14,7 +14,6 @@
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
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';
@@ -2,12 +2,17 @@ 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;
14
+ editPermission: boolean;
15
+ copyPermission: boolean;
11
16
  }
12
17
  interface IHyperLinkEditing {
13
18
  unitId: string;
@@ -15,7 +20,7 @@ interface IHyperLinkEditing {
15
20
  row: number;
16
21
  column: number;
17
22
  }
18
- export declare class SheetsHyperLinkPopupService {
23
+ export declare class SheetsHyperLinkPopupService extends Disposable {
19
24
  private readonly _hyperLinkModel;
20
25
  private readonly _sheetCanvasPopManagerService;
21
26
  private _currentPopup;
@@ -26,7 +31,10 @@ export declare class SheetsHyperLinkPopupService {
26
31
  get currentPopup(): IHyperLinkPopup | null;
27
32
  get currentEditing(): IHyperLinkEditing | null;
28
33
  constructor(_hyperLinkModel: HyperLinkModel, _sheetCanvasPopManagerService: SheetCanvasPopManagerService);
29
- showPopup(location: ISheetLocationBase): void;
34
+ showPopup(location: ISheetLocationBase & {
35
+ editPermission?: boolean;
36
+ copyPermission?: boolean;
37
+ }): void;
30
38
  hideCurrentPopup(): void;
31
39
  startEditing(link: IHyperLinkEditing): void;
32
40
  endEditing(): void;
@@ -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
  }
@@ -14,4 +14,3 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const SHEET_HYPER_LINK_UI_PLUGIN = "SHEET_HYPER_LINK_UI_PLUGIN";
17
- export declare const ERROR_RANGE = "err";
package/lib/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(s,l){typeof exports=="object"&&typeof module<"u"?l(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"],l):(s=typeof globalThis<"u"?globalThis:s||self,l(s.UniverSheetsHyperLinkUi={},s.UniverCore,s.UniverSheets,s["@wendellhu/redi"],s.UniverSheetsHyperLink,s.UniverEngineFormula,s.UniverDesign,s.UniverSheetsUi,s.UniverUi,s.UniverEngineRender,s.rxjs,s.React,s["@wendellhu/redi/react-bindings"],s.clsx,s.UniverSheetsFormula))})(this,function(s,l,p,S,v,H,I,_,M,Ce,ue,C,w,Le,xe){"use strict";var ot=Object.defineProperty;var at=(s,l,p)=>l in s?ot(s,l,{enumerable:!0,configurable:!0,writable:!0,value:p}):s[l]=p;var V=(s,l,p)=>(at(s,typeof l!="symbol"?l+"":l,p),p);var Be=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,ze=(i,t,n,e)=>{for(var r=e>1?void 0:e?Fe(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Be(t,n,r),r},pe=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkRemoveSheetController=class extends l.Disposable{constructor(t,n,e){super(),this._sheetInterceptorService=t,this._univerInstanceService=n,this._hyperLinkModel=e,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:t=>{if(t.id===p.RemoveSheetCommand.id){const n=t.params,e=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return{redos:[],undos:[]};const r=e.getUnitId(),o=n.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:[]}}}))}},s.SheetsHyperLinkRemoveSheetController=ze([l.OnLifecycle(l.LifecycleStages.Ready,s.SheetsHyperLinkRemoveSheetController),pe(0,S.Inject(p.SheetInterceptorService)),pe(1,l.IUniverInstanceService),pe(2,S.Inject(v.HyperLinkModel))],s.SheetsHyperLinkRemoveSheetController);const he="SHEET_HYPER_LINK_UI_PLUGIN",ve="err";var Ye=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Ke=(i,t,n,e)=>{for(var r=e>1?void 0:e?Ze(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ye(t,n,r),r},X=(i,t)=>(n,e)=>t(n,e,i);function Ge(i,t){const n=[];return t.forEach(e=>{l.Rectangle.intersects(i,e)&&n.push(e)}),l.Rectangle.realUnion(i,...n)}s.SheetsHyperLinkResolverService=class{constructor(t,n,e,r,o){this._univerInstanceService=t,this._commandService=n,this._definedNamesService=e,this._messageService=r,this._localeService=o}_getURLName(t){var d;const{gid:n,range:e,rangeid:r}=t,o=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const a=n?o.getSheetBySheetId(n):o.getActiveSheet(),c=(d=a==null?void 0:a.getName())!=null?d:"";if(e){const u=H.deserializeRangeWithSheet(e).range;return l.isValidRange(u)&&e!==ve?{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(n){const u=o.getSheetBySheetId(n);return u?{type:"sheet",name:u.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(t){const{gid:n,range:e,rangeid:r}=t,o=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!o)return;const a=o.getUnitId();if(r&&this.navigateToDefineName(a,r),!!n){if(e){const c=H.deserializeRangeWithSheet(e);l.isValidRange(c.range)&&e!==ve&&this.navigateToRange(a,n,c.range);return}this.navigateToSheetById(a,n)}}parseHyperLink(t){var n,e,r;if(t!=null&&t.startsWith("#")){const o=new URLSearchParams(t.slice(1)),a={gid:(n=o.get("gid"))!=null?n:"",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)||t,url:t,searchObj:a,handler:()=>{this.navigateTo(a)}}}else return{type:"outer",name:t,url:t,handler:()=>{this.navigateToOtherWebsite(t)}}}async navigateToRange(t,n,e){const r=await this.navigateToSheetById(t,n);if(r){const o=Ge(e,r.getMergeData());await this._commandService.executeCommand(p.SetSelectionsOperation.id,{unitId:t,subUnitId:n,pluginName:p.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o}]}),await this._commandService.executeCommand(_.ScrollToCellCommand.id,{range:o})}}async navigateToSheet(t,n){const e=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if((r==null?void 0:r.getName())===n)return!0;const o=e.getSheetBySheetName(n);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:t,subUnitId:a})}async navigateToSheetById(t,n){const e=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET);if(!e)return!1;const r=e.getActiveSheet();if(r.getSheetId()===n)return r;const o=e.getSheetBySheetId(n);return o?e.getHiddenWorksheets().indexOf(n)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:I.MessageType.Error}),!1):await this._commandService.executeCommand(p.SetWorksheetActiveOperation.id,{unitId:t,subUnitId:n})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:I.MessageType.Error}),!1)}async navigateToDefineName(t,n){return this._definedNamesService.focusRange(t,n),!0}async navigateToOtherWebsite(t){window.open(t,"_blank","noopener noreferrer")}},s.SheetsHyperLinkResolverService=Ke([X(0,l.IUniverInstanceService),X(1,l.ICommandService),X(2,H.IDefinedNamesService),X(3,M.IMessageService),X(4,S.Inject(l.LocaleService))],s.SheetsHyperLinkResolverService);var Xe=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Qe=(i,t,n,e)=>{for(var r=e>1?void 0:e?Je(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Xe(t,n,r),r},te=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkRefRangeController=class extends l.Disposable{constructor(n,e,r,o){super();V(this,"_disposableMap",new Map);V(this,"_rangeDisableMap",new Map);this._refRangeService=n,this._hyperLinkModel=e,this._resolverService=r,this._univerInstanceService=o,this._initData(),this._initRefRange()}_register(n,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:n,subUnitId:e,id:r.id,row:u.startRow,column:u.startColumn}}],undos:[{id:v.UpdateHyperLinkRefMutation.id,params:{unitId:n,subUnitId:e,id:r.id,row:a.startRow,column:a.startColumn}}]}:{redos:[{id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:e,id:r.id}}],undos:[{id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:e,link:r}}]}};this._disposableMap.set(o,this._refRangeService.registerRefRange(a,c,n,e))}_unregister(n){const e=this._disposableMap.get(n);e==null||e.dispose(),this._disposableMap.delete(n)}_registerRange(n,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(l.isValidRange(c)&&o.searchObj.range!==ve){const d=u=>{const m=p.handleDefaultRangeChangeWithEffectRefCommands(c,u);return m&&H.serializeRange(m)===H.serializeRange(c)?{redos:[],undos:[]}:{redos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:n,subUnitId:a,id:e,payload:{payload:`#gid=${a}&range=${m?H.serializeRange(m):"err"}`}}}],undos:[{id:v.UpdateHyperLinkMutation.id,params:{unitId:n,subUnitId:a,id:e,payload:{payload:r}}}]}};this._rangeDisableMap.set(e,this._refRangeService.registerRefRange(c,d,n,a))}}}_unregisterRange(n){const e=this._rangeDisableMap.get(n);e==null||e.dispose(),this._rangeDisableMap.delete(n)}_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(n=>{switch(n.type){case"add":{this._register(n.unitId,n.subUnitId,n.payload),this._registerRange(n.unitId,n.payload.id,n.payload.payload);break}case"remove":{this._unregister(n.payload.id),this._unregisterRange(n.payload.id);break}case"updateRef":{const{unitId:e,subUnitId:r,id:o}=n,a=this._hyperLinkModel.getHyperLink(e,r,o);if(!a)return;this._unregister(o),this._register(e,r,a);break}case"unload":{const{unitLinks:e}=n;e.forEach(r=>{const{links:o}=r;o.forEach(a=>{this._unregister(a.id),this._unregisterRange(a.id)})});break}case"update":{this._unregisterRange(n.id),this._registerRange(n.unitId,n.id,n.payload.payload);break}}})),this.disposeWithMe(l.toDisposable(()=>{this._disposableMap.forEach(n=>{n.dispose()}),this._disposableMap.clear()}))}},s.SheetsHyperLinkRefRangeController=Qe([l.OnLifecycle(l.LifecycleStages.Starting,s.SheetsHyperLinkRefRangeController),te(0,S.Inject(p.RefRangeService)),te(1,S.Inject(v.HyperLinkModel)),te(2,S.Inject(s.SheetsHyperLinkResolverService)),te(3,l.IUniverInstanceService)],s.SheetsHyperLinkRefRangeController);var qe=Object.defineProperty,en=Object.getOwnPropertyDescriptor,ke=(i,t,n,e)=>{for(var r=e>1?void 0:e?en(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&qe(t,n,r),r},z=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkRenderController=class extends l.Disposable{constructor(t,n,e,r){super(),this._context=t,this._hyperLinkModel=n,this._sheetSkeletonManagerService=e,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const t=()=>{const n=this._context.unit,e=n.getUnitId(),r=n.getActiveSheet().getSheetId(),o=this._sheetSkeletonManagerService.getOrCreateSkeleton({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(()=>{t()}))}},s.SheetsHyperLinkRenderController=ke([z(1,S.Inject(v.HyperLinkModel)),z(2,S.Inject(_.SheetSkeletonManagerService)),z(3,Ce.IRenderManagerService)],s.SheetsHyperLinkRenderController),s.SheetsHyperLinkRenderManagerController=class extends l.Disposable{constructor(t,n,e){super(),this._sheetInterceptorService=t,this._hyperLinkModel=n,this._themeService=e,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(p.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(t,n,e)=>{const{row:r,col:o,unitId:a,subUnitId:c}=n,d=this._hyperLinkModel.getHyperLinkByLocation(a,c,r,o),u=this._themeService.getCurrentTheme();return e(d?{...t,interceptorStyle:{ul:{s:l.BooleanNumber.TRUE},cl:{rgb:u.blue500}}}:t)},priority:100}))}},s.SheetsHyperLinkRenderManagerController=ke([l.OnLifecycle(l.LifecycleStages.Ready,s.SheetsHyperLinkRenderManagerController),z(0,S.Inject(p.SheetInterceptorService)),z(1,S.Inject(v.HyperLinkModel)),z(2,S.Inject(l.ThemeService))],s.SheetsHyperLinkRenderManagerController);var Ie={exports:{}},re={};/**
1
+ (function(l,a){typeof exports=="object"&&typeof module<"u"?a(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"],a):(l=typeof globalThis<"u"?globalThis:l||self,a(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,a,u,f,v,y,he,me,C,T,Re,k,O,D,Ve){"use strict";var Qn=Object.defineProperty;var qn=(l,a,u)=>a in l?Qn(l,a,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[a]=u;var Y=(l,a,u)=>qn(l,typeof a!="symbol"?a+"":a,u);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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&xe(e,t,r),r},ve=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRemoveSheetController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._univerInstanceService=t,this._hyperLinkModel=n,this._initSheetChange()}_initSheetChange(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var t;if(e.id===u.RemoveSheetCommand.id){const n=e.params,r=n.unitId?this._univerInstanceService.getUnit(n.unitId):this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!r)return{redos:[],undos:[]};const o=r.getUnitId(),s=n.subUnitId||((t=r.getActiveSheet())==null?void 0:t.getSheetId());if(!s)return{redos:[],undos:[]};const c=this._hyperLinkModel.getSubUnit(o,s),d=c.map(g=>({id:v.RemoveHyperLinkMutation.id,params:{unitId:o,subUnitId:s,id:g.id}})),h=c.map(g=>({id:v.AddHyperLinkMutation.id,params:{unitId:o,subUnitId:s,link:g}}));return{redos:d,undos:h}}return{redos:[],undos:[]}}}))}},l.SheetsHyperLinkRemoveSheetController=Be([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRemoveSheetController),ve(0,f.Inject(u.SheetInterceptorService)),ve(1,a.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Fe(e,t,r),r},z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkRenderController=class extends a.Disposable{constructor(e,t,n,r){super(),this._context=e,this._hyperLinkModel=t,this._sheetSkeletonManagerService=n,this._renderManagerService=r,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var c;const t=this._context.unit,n=t.getUnitId(),r=(c=t.getActiveSheet())==null?void 0:c.getSheetId();if(!r){console.warn("No active sheet found");return}const o=this._sheetSkeletonManagerService.getOrCreateSkeleton({sheetId:r}),s=this._renderManagerService.getRenderById(n);o==null||o.makeDirty(!0),o==null||o.calculate(),s&&s.mainComponent.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.subscribe(()=>{e()}))}},l.SheetsHyperLinkRenderController=Pe([z(1,f.Inject(v.HyperLinkModel)),z(2,f.Inject(y.SheetSkeletonManagerService)),z(3,he.IRenderManagerService)],l.SheetsHyperLinkRenderController),l.SheetsHyperLinkRenderManagerController=class extends a.Disposable{constructor(e,t,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=t,this._themeService=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(u.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(e,t,n)=>{const{row:r,col:o,unitId:s,subUnitId:c}=t,d=this._hyperLinkModel.getHyperLinkByLocation(s,c,r,o),h=this._themeService.getCurrentTheme();return n(d?{...e,interceptorStyle:{ul:{s:a.BooleanNumber.TRUE},cl:{rgb:h.blue500}}}:e)},priority:100}))}},l.SheetsHyperLinkRenderManagerController=Pe([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkRenderManagerController),z(0,f.Inject(u.SheetInterceptorService)),z(1,f.Inject(v.HyperLinkModel)),z(2,f.Inject(a.ThemeService))],l.SheetsHyperLinkRenderManagerController);var be={exports:{}},re={};/**
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 nn=C,tn=Symbol.for("react.element"),rn=Symbol.for("react.fragment"),on=Object.prototype.hasOwnProperty,an=nn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sn={key:!0,ref:!0,__self:!0,__source:!0};function Re(i,t,n){var e,r={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(e in t)on.call(t,e)&&!sn.hasOwnProperty(e)&&(r[e]=t[e]);if(i&&i.defaultProps)for(e in t=i.defaultProps,t)r[e]===void 0&&(r[e]=t[e]);return{$$typeof:tn,type:i,key:o,ref:a,props:r,_owner:an.current}}re.Fragment=rn,re.jsx=Re,re.jsxs=Re,Ie.exports=re;var g=Ie.exports,N=function(){return N=Object.assign||function(i){for(var t,n=1,e=arguments.length;n<e;n++){t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},N.apply(this,arguments)},ln=function(i,t){var n={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.indexOf(e)<0&&(n[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,e=Object.getOwnPropertySymbols(i);r<e.length;r++)t.indexOf(e[r])<0&&Object.prototype.propertyIsEnumerable.call(i,e[r])&&(n[e[r]]=i[e[r]]);return n},x=C.forwardRef(function(i,t){var n=i.icon,e=i.id,r=i.className,o=i.extend,a=ln(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(r||"").trim(),d=C.useRef("_".concat(un()));return Pe(n,"".concat(e),{defIds:n.defIds,idSuffix:d.current},N({ref:t,className:c},a),o)});function Pe(i,t,n,e,r){return C.createElement(i.tag,N(N({key:t},cn(i,n,r)),e),(dn(i,n).children||[]).map(function(o,a){return Pe(o,"".concat(t,"-").concat(i.tag,"-").concat(a),n,void 0,r)}))}function cn(i,t,n){var e=N({},i.attrs);n!=null&&n.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=n.colorChannel1);var r=t.defIds;return!r||r.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+t.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(t.idSuffix,")")))})),e}function dn(i,t){var n,e=t.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((n=i.children)===null||n===void 0)&&n.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+t.idSuffix})}):r})}):i}function un(){return Math.random().toString(36).substring(2,8)}x.displayName="UniverIcon";var pn={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"}}]},be=C.forwardRef(function(i,t){return C.createElement(x,Object.assign({},i,{id:"all-border-single",ref:t,icon:pn}))});be.displayName="AllBorderSingle";const ge=be;var hn={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,t){return C.createElement(x,Object.assign({},i,{id:"copy-single",ref:t,icon:hn}))});Me.displayName="CopySingle";const vn=Me;var gn={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,t){return C.createElement(x,Object.assign({},i,{id:"link-single",ref:t,icon:gn}))});ie.displayName="LinkSingle";var mn={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,t){return C.createElement(x,Object.assign({},i,{id:"unlink-single",ref:t,icon:mn}))});Oe.displayName="UnlinkSingle";const Sn=Oe;var fn={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"}}]},Ee=C.forwardRef(function(i,t){return C.createElement(x,Object.assign({},i,{id:"write-single",ref:t,icon:fn}))});Ee.displayName="WriteSingle";const yn=Ee;var _n={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"}}]},He=C.forwardRef(function(i,t){return C.createElement(x,Object.assign({},i,{id:"xlsx",ref:t,icon:_n}))});He.displayName="Xlsx";const we=He,Cn=/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gi,Ln=new RegExp(Cn);function J(i){return i.startsWith("http://localhost:3002")||i.startsWith("localhost:3002")?!0:!!i.match(Ln)}function je(i){return/^[a-zA-Z]+:\/\//.test(i)}function kn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function Te(i){return J(i)?je(i)?i:kn(i)?`mailto://${i}`:`http://${i}`:i}const In={cellLinkEditButtons:"univer-cell-link-edit-buttons"};function Rn(i){if(i===null)return"";if(i!=null&&i.p){const t=i==null?void 0:i.p.body;if(t==null)return"";const n=t.dataStream;return n.substring(n.length-2,n.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?n.substring(0,n.length-2):n}return i==null?void 0:i.v}const oe=()=>{var de;const[i,t]=C.useState(""),[n,e]=C.useState(""),[r,o]=C.useState("link"),[a,c]=C.useState(""),d=w.useDependency(l.LocaleService),u=w.useDependency(H.IDefinedNamesService),m=w.useDependency(l.IUniverInstanceService),y=w.useDependency(s.SheetsHyperLinkPopupService),h=M.useObservable(y.currentEditing$),P=w.useDependency(v.HyperLinkModel),b=w.useDependency(s.SheetsHyperLinkResolverService),R=w.useDependency(l.ICommandService),[E,j]=C.useState(!1),L=C.useRef(!1);C.useEffect(()=>{var f,k,O;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 _e=b.parseHyperLink(U.payload);if(t(U.id),e(U.display),_e.type==="outer"){o("link"),c(_e.url);return}else{const $=_e.searchObj;if($.rangeid){o("rangeid"),c($.rangeid);return}if($.range){const it=$.gid&&(O=(k=(f=m.getUnit(h.unitId))==null?void 0:f.getSheetBySheetId($.gid))==null?void 0:k.getName())!=null?O:"";o("range"),c(H.serializeRangeWithSheet(it,H.deserializeRangeWithSheet($.range).range));return}if($.gid){o("gid"),c($.gid);return}}}const G=m.getUnit(h.unitId),W=G==null?void 0:G.getSheetBySheetId(h.subUnitId),rt=W==null?void 0:W.getCellRaw(h.row,h.column),ye=Rn(rt);o("link"),c(""),e((ye!=null?ye:"").toString()),t("");return}o("link"),c(""),e(""),t("")},[h,P,b,m]);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=m.getCurrentUnitForType(l.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((de=u.getDefinedNameMap(T.getUnitId()))!=null?de:{}).map(f=>({label:f.name,value:f.id})),ne=(f,k)=>{if(f==="link")return je(k)?k:`http://${k}`;if(f==="range"){const O=H.deserializeRangeWithSheet(k),U=T.getSheetBySheetName(O.sheetName);if(U)return`#gid=${U.getSheetId()}&range=${H.serializeRange(O.range)}`}return`#${f}=${k}`},fe=async()=>{h&&(i?await R.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,id:i,payload:{display:n,payload:ne(r,a)}}):await R.executeCommand(v.AddHyperLinkCommand.id,{unitId:h.unitId,subUnitId:h.subUnitId,link:{id:l.Tools.generateRandomId(),row:h.row,column:h.column,payload:ne(r,a),display:n}})),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 g.jsxs("div",{children:[g.jsx(I.FormLayout,{label:d.t("hyperLink.form.label"),error:E&&!n?d.t("hyperLink.form.inputError"):"",children:g.jsx(I.Input,{value:n,onChange:f=>{e(f),L.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),g.jsx(I.FormLayout,{label:d.t("hyperLink.form.type"),children:g.jsx(I.Select,{options:Z,value:r,onChange:f=>{o(f),c("")}})}),r==="link"&&g.jsx(I.FormLayout,{error:E?a?J(a)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:g.jsx(I.Input,{value:a,onChange:f=>{c(f),f&&(L.current||!n)&&(e(f),L.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&g.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.inputError"):"",children:g.jsx(M.RangeSelector,{openForSheetUnitId:T.getUnitId(),id:l.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:D,onChange:f=>{const k=f[0];if(!k||!l.isValidRange(k.range))return;k.sheetName||(k.sheetName=T.getActiveSheet().getName());const O=H.serializeRangeToRefString(k);c(O),O&&(L.current||!n)&&(e(O),L.current=!0)}})}),r==="gid"&&g.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:g.jsx(I.Select,{options:B,value:a,onChange:f=>{var O;c(f);const k=(O=B.find(U=>U.value===f))==null?void 0:O.label;k&&(L.current||!n)&&(e(k),L.current=!0)}})}),r==="rangeid"&&g.jsx(I.FormLayout,{error:E&&!a?d.t("hyperLink.form.selectError"):"",children:g.jsx(I.Select,{options:F,value:a,onChange:f=>{var O;c(f);const k=(O=F.find(U=>U.value===f))==null?void 0:O.label;k&&(L.current||!n)&&(e(k),L.current=!0)}})}),g.jsxs("div",{className:In.cellLinkEditButtons,children:[g.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")}),g.jsx(I.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!n||!a||r==="link"&&!J(a)){j(!0);return}fe()},children:d.t("hyperLink.form.ok")})]})]})};oe.componentKey="univer.sheet.cell-link-edit";const ae={type:l.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,t){if(!t)return!1;const{unitId:n,subUnitId:e,row:r,column:o}=t,a=i.get(v.HyperLinkModel),c=i.get(M.ISidebarService),d=i.get(s.SheetsHyperLinkPopupService),u=a.getHyperLinkByLocation(n,e,r,o);return d.startEditing(t),c.open({header:{title:u?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:oe.componentKey}}),!0}},Q={type:l.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const t=i.get(M.ISidebarService),n=i.get(s.SheetsHyperLinkPopupService);return t.close(),n.endEditing(),!0}},q={type:l.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const t=i.get(l.IUniverInstanceService),n=p.getSheetCommandTarget(t);if(!n)return!1;const e=i.get(l.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:n.unitId,subUnitId:n.subUnitId,row:a,column:c})}},Ue={type:l.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const t=i.get(l.ICommandService);return i.get(s.SheetsHyperLinkPopupService).currentEditing?t.executeCommand(Q.id):t.executeCommand(q.id)}},A={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},Pn={outer:g.jsx(ie,{}),link:g.jsx(ie,{}),sheet:g.jsx(we,{}),range:g.jsx(ge,{}),defineName:g.jsx(ge,{}),"range-error":g.jsx(ge,{}),"sheet-error":g.jsx(we,{})},se=()=>{const i=w.useDependency(s.SheetsHyperLinkPopupService),t=w.useDependency(v.HyperLinkModel),n=w.useDependency(l.ICommandService),e=w.useDependency(M.IMessageService),r=w.useDependency(l.LocaleService),o=w.useObservable(i.currentPopup$,i.currentPopup),a=w.useDependency(s.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:u}=o,m=t.getHyperLink(c,d,u);if(!m)return null;const y=a.parseHyperLink(m.payload),h=y.type.indexOf("error")>-1;return g.jsxs("div",{className:A.cellLink,onClick:()=>i.hideCurrentPopup(),children:[g.jsxs("div",{className:Le(A.cellLinkContent,{[A.cellLinkContentError]:h}),onClick:y.handler,children:[g.jsx("div",{className:A.cellLinkType,children:Pn[y.type]}),g.jsx("div",{className:A.cellLinkUrl,children:y.name})]}),g.jsxs("div",{className:A.cellLinkOperations,children:[g.jsx("div",{className:Le(A.cellLinkOperation,{[A.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:g.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:g.jsx(vn,{})})}),g.jsx("div",{className:A.cellLinkOperation,onClick:()=>{n.executeCommand(ae.id,{unitId:c,subUnitId:d,row:m.row,column:m.column})},children:g.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:g.jsx(yn,{})})}),g.jsx("div",{className:A.cellLinkOperation,onClick:()=>{n.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:m.id})},children:g.jsx(I.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:g.jsx(Sn,{})})})]})]})};se.componentKey="univer.sheet.cell-link-popup";var bn=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,On=(i,t,n,e)=>{for(var r=e>1?void 0:e?Mn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&bn(t,n,r),r},Ne=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkPopupService=class{constructor(t,n){V(this,"_currentPopup",null);V(this,"_currentPopup$",new ue.Subject);V(this,"currentPopup$",this._currentPopup$.asObservable());V(this,"_currentEditing$",new ue.BehaviorSubject(null));V(this,"currentEditing$",this._currentEditing$.asObservable());this._hyperLinkModel=t,this._sheetCanvasPopManagerService=n}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}showPopup(t){this.hideCurrentPopup();const{unitId:n,subUnitId:e,row:r,col:o}=t,a=this._hyperLinkModel.getHyperLinkByLocation(n,e,r,o);if(!a)return;const c=this._sheetCanvasPopManagerService.attachPopupToCell(r,o,{componentKey:se.componentKey,direction:"bottom",closeOnSelfTarget:!0});c&&(this._currentPopup={unitId:n,subUnitId:e,id:a.id,disposable:c},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)}},s.SheetsHyperLinkPopupService=On([Ne(0,S.Inject(v.HyperLinkModel)),Ne(1,S.Inject(_.SheetCanvasPopManagerService))],s.SheetsHyperLinkPopupService);var En=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,wn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Hn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&En(t,n,r),r},ee=(i,t)=>(n,e)=>t(n,e,i);s.SheetHyperLinkSetRangeController=class extends l.Disposable{constructor(t,n,e,r,o){super(),this._sheetInterceptorService=t,this._injector=n,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:t=>{if(t.id===v.AddHyperLinkCommand.id){const n=t.params,{unitId:e,subUnitId:r,link:o}=n,a={unitId:e,subUnitId:r,cellValue:{[o.row]:{[o.column]:{v:o.display,t:l.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:t=>{if(t.id===v.UpdateHyperLinkCommand.id){const n=t.params,{unitId:e,subUnitId:r,id:o,payload:a}=n,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:l.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:t=>{if(t.id===p.SetRangeValuesCommand.id){const n=t.params,{unitId:e,subUnitId:r}=n,o=[],a=[];return n.cellValue&&new l.ObjectMatrix(n.cellValue).forValue((c,d,u)=>{var b,R,E,j;const m=((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(m)){const L=l.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:m,payload:Te(m)}}})}return}if(y.display===m)return;m||(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:m}},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:t=>{if(t.id===p.ClearSelectionContentCommand.id||t.id===p.ClearSelectionAllCommand.id){const n=[],e=[],r=this._selectionManagerService.getFirst(),o=p.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:a,subUnitId:c}=o;l.Range.foreach(r.range,(d,u)=>{const m=this._hyperLinkModel.getHyperLinkByLocation(a,c,d,u);m&&(n.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:a,subUnitId:c,id:m.id}}),e.push({id:v.AddHyperLinkMutation.id,params:{unitId:a,subUnitId:c,link:m}}))})}return{redos:n,undos:e}}return{redos:[],undos:[]}}}))}},s.SheetHyperLinkSetRangeController=wn([l.OnLifecycle(l.LifecycleStages.Starting,s.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,l.IUniverInstanceService)],s.SheetHyperLinkSetRangeController);var jn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Un=(i,t,n,e)=>{for(var r=e>1?void 0:e?Tn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&jn(t,n,r),r},De=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkPopupController=class extends l.Disposable{constructor(t,n){super(),this._hoverManagerService=t,this._sheetsHyperLinkPopupService=n,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ue.debounceTime(100)).subscribe(t=>{if(!t){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup(t.location)}))}},s.SheetsHyperLinkPopupController=Un([l.OnLifecycle(l.LifecycleStages.Rendered,s.SheetsHyperLinkPopupController),De(0,S.Inject(_.HoverManagerService)),De(1,S.Inject(s.SheetsHyperLinkPopupService))],s.SheetsHyperLinkPopupController);const Nn=i=>({id:q.id,type:M.MenuItemType.BUTTON,positions:[M.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:M.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),Dn=i=>({tooltip:"hyperLink.form.addTitle",positions:M.MenuPosition.TOOLBAR_START,group:M.MenuGroup.TOOLBAR_OTHERS,id:Ue.id,type:M.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:M.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:_.getCurrentRangeDisable$(i,{workbookTypes:[p.WorkbookEditablePermission],worksheetTypes:[p.WorksheetEditPermission,p.WorksheetSetCellValuePermission,p.WorksheetInsertHyperlinkPermission],rangeTypes:[p.RangeProtectionPermissionEditPoint]})}),me={id:q.id,binding:M.KeyCode.K|M.MetaKeys.CTRL_COMMAND,preconditions:_.whenSheetEditorFocused};var An=Object.defineProperty,Vn=Object.getOwnPropertyDescriptor,Wn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Vn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&An(t,n,r),r},Y=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkUIController=class extends l.Disposable{constructor(t,n,e,r,o,a,c){super(),this._config=t,this._componentManager=n,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(([t,n])=>{this._componentManager.register(n,t)})}_initCommands(){[ae,Q,q,Ue].forEach(t=>{this._commandService.registerCommand(t)})}_initMenus(){var t,n,e,r;this._menuService.addMenuItem(Nn(this._injector),(n=(t=this._config)==null?void 0:t.menu)!=null?n:{}),this._menuService.addMenuItem(Dn(this._injector),(r=(e=this._config)==null?void 0:e.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(me)}},s.SheetsHyperLinkUIController=Wn([l.OnLifecycle(l.LifecycleStages.Ready,s.SheetsHyperLinkUIController),Y(1,S.Inject(M.ComponentManager)),Y(2,l.ICommandService),Y(3,S.Inject(l.LocaleService)),Y(4,M.IMenuService),Y(5,S.Inject(S.Injector)),Y(6,S.Inject(M.IShortcutService))],s.SheetsHyperLinkUIController);var $n=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Bn=(i,t,n,e)=>{for(var r=e>1?void 0:e?xn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&$n(t,n,r),r},Ae=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkAutoFillController=class extends l.Disposable{constructor(t,n){super(),this._autoFillService=t,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const t=()=>({redos:[],undos:[]}),n=(r,o)=>{const{source:a,target:c,unitId:d,subUnitId:u}=r,m=_.virtualizeDiscreteRanges([a,c]),[y,h]=m.ranges,{mapFunc:P}=m,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};l.Range.foreach(Z,(B,F)=>{const ne=l.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},T),{row:fe,col:de}=P(ne.startRow,ne.startColumn),f=this._hyperLinkModel.getHyperLinkByLocation(d,u,fe,de);if(f){const k=l.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},K),{row:O,col:U}=P(k.startRow,k.startColumn),G=l.Tools.generateRandomId(),W=this._hyperLinkModel.getHyperLinkByLocation(d,u,O,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:O,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:he,onFillData:(r,o,a)=>a===_.APPLY_TYPE.COPY||a===_.APPLY_TYPE.ONLY_FORMAT||a===_.APPLY_TYPE.SERIES?n(r,a):t()};this.disposeWithMe(this._autoFillService.addHook(e))}},s.SheetsHyperLinkAutoFillController=Bn([l.OnLifecycle(l.LifecycleStages.Ready,s.SheetsHyperLinkAutoFillController),Ae(0,_.IAutoFillService),Ae(1,S.Inject(v.HyperLinkModel))],s.SheetsHyperLinkAutoFillController);var Fn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,Yn=(i,t,n,e)=>{for(var r=e>1?void 0:e?zn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Fn(t,n,r),r},le=(i,t)=>(n,e)=>t(n,e,i);s.SheetsHyperLinkCopyPasteController=class extends l.Disposable{constructor(n,e,r,o){super();V(this,"_copyInfo");this._sheetClipboardService=n,this._hyperLinkModel=e,this._injector=r,this._resolverService=o,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:he,onBeforeCopy:(n,e,r)=>this._collect(n,e,r),onPasteCells:(n,e,r,o)=>{const{copyType:a=_.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=n||{},{range:u,unitId:m,subUnitId:y}=e;return this._generateMutations(u,{copyType:a,pasteType:c,copyRange:d,unitId:m,subUnitId:y})},onPastePlainText:(n,e)=>{if(J(e)){let r=Te(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}=n,{ranges:[m],mapFunc:y}=_.virtualizeDiscreteRanges([c]),h=[],P=[];return l.Range.foreach(m,(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=l.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(n,e,r){const o=new l.ObjectMatrix;this._copyInfo={unitId:n,subUnitId:e,matrix:o};const a={get:this._injector.get.bind(this._injector)},c=_.rangeToDiscreteRange(r,a,n,e);if(!c)return;const{rows:d,cols:u}=c;d.forEach((m,y)=>{u.forEach((h,P)=>{var R;const b=this._hyperLinkModel.getHyperLinkByLocation(n,e,m,h);o.setValue(y,P,(R=b==null?void 0:b.id)!=null?R:"")})})}_generateMutations(n,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,xe.SPECIAL_PASTE_FORMULA].includes(e.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:o}=this._copyInfo,a=[],c=[],{ranges:[d,u],mapFunc:m}=_.virtualizeDiscreteRanges([e.copyRange,n]);return _.getRepeatRange(d,u,!0).forEach(({startRange:h})=>{var P;(P=this._copyInfo)==null||P.matrix.forValue((b,R,E)=>{const j=l.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:R,endColumn:R},h),L=this._hyperLinkModel.getHyperLink(r,o,E),{row:D,col:Z}=m(j.startRow,j.startColumn),T=this._hyperLinkModel.getHyperLinkByLocation(e.unitId,e.subUnitId,D,Z),K=l.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}}},s.SheetsHyperLinkCopyPasteController=Yn([l.OnLifecycle(l.LifecycleStages.Ready,s.SheetsHyperLinkCopyPasteController),le(0,_.ISheetClipboardService),le(1,S.Inject(v.HyperLinkModel)),le(2,S.Inject(S.Injector)),le(3,S.Inject(s.SheetsHyperLinkResolverService))],s.SheetsHyperLinkCopyPasteController);var Zn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Gn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Kn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Zn(t,n,r),r},Xn=(i,t)=>(n,e)=>t(n,e,i);s.SheetHyperLinkUrlController=class extends l.Disposable{constructor(t){super(),this._resolverService=t,this._handleInitUrl()}_handleInitUrl(){const t=location.hash;t&&this._resolverService.parseHyperLink(t).handler()}},s.SheetHyperLinkUrlController=Gn([l.OnLifecycle(l.LifecycleStages.Rendered,s.SheetHyperLinkUrlController),Xn(0,S.Inject(s.SheetsHyperLinkResolverService))],s.SheetHyperLinkUrlController);var Jn=Object.defineProperty,Qn=Object.getOwnPropertyDescriptor,qn=(i,t,n,e)=>{for(var r=e>1?void 0:e?Qn(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Jn(t,n,r),r},Se=(i,t)=>(n,e)=>t(n,e,i);let ce=class extends l.Disposable{constructor(i,t,n){super(),this._localeService=i,this._commandService=t,this._sheetPermissionInterceptorBaseController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===me.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=qn([l.OnLifecycle(l.LifecycleStages.Rendered,ce),Se(0,S.Inject(l.LocaleService)),Se(1,l.ICommandService),Se(2,S.Inject(_.SheetPermissionInterceptorBaseController))],ce);var Ve=Object.defineProperty,et=Object.getOwnPropertyDescriptor,nt=(i,t,n)=>t in i?Ve(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,tt=(i,t,n,e)=>{for(var r=e>1?void 0:e?et(t,n):t,o=i.length-1,a;o>=0;o--)(a=i[o])&&(r=(e?a(t,n,r):a(r))||r);return e&&r&&Ve(t,n,r),r},We=(i,t)=>(n,e)=>t(n,e,i),$e=(i,t,n)=>(nt(i,typeof t!="symbol"?t+"":t,n),n);s.UniverSheetsHyperLinkUIPlugin=class extends l.Plugin{constructor(t,n,e){super(),this._config=t,this._injector=n,this._renderManagerService=e}onStarting(t){[[s.SheetsHyperLinkResolverService],[s.SheetsHyperLinkPopupService],[s.SheetsHyperLinkRemoveSheetController],[s.SheetsHyperLinkRefRangeController],[s.SheetsHyperLinkRenderManagerController],[s.SheetHyperLinkSetRangeController],[s.SheetsHyperLinkPopupController],[s.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(s.SheetsHyperLinkUIController,this._config)}],[s.SheetsHyperLinkAutoFillController],[s.SheetsHyperLinkCopyPasteController],[ce],[s.SheetHyperLinkUrlController]].forEach(e=>t.add(e)),this._renderManagerService.registerRenderController(l.UniverInstanceType.UNIVER_SHEET,s.SheetsHyperLinkRenderController)}},$e(s.UniverSheetsHyperLinkUIPlugin,"pluginName",he),$e(s.UniverSheetsHyperLinkUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),s.UniverSheetsHyperLinkUIPlugin=tt([l.DependentOn(v.UniverSheetsHyperLinkPlugin),We(1,S.Inject(S.Injector)),We(2,Ce.IRenderManagerService)],s.UniverSheetsHyperLinkUIPlugin),s.CloseHyperLinkSidebarOperation=Q,s.InsertHyperLinkOperation=q,s.InsertLinkShortcut=me,s.OpenHyperLinkSidebarOperation=ae,Object.defineProperty(s,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,s=null;t!==void 0&&(o=""+t),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)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:s,props:r,_owner:Ge.current}}re.Fragment=Ze,re.jsx=Ee,re.jsxs=Ee,be.exports=re;var m=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,s=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},s),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,s){return Oe(o,"".concat(e,"-").concat(i.tag,"-").concat(s),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 s=o[0],c=o[1];typeof c=="string"&&(n[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function qe(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?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"}}]},ie=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"all-border-single",ref:e,icon:nn}))});ie.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"}}]},we=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"copy-single",ref:e,icon:tn}))});we.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"}}]},oe=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"link-single",ref:e,icon:rn}))});oe.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"}}]},Me=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"unlink-single",ref:e,icon:on}))});Me.displayName="UnlinkSingle";var sn={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"}}]},He=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"write-single",ref:e,icon:sn}))});He.displayName="WriteSingle";var an={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"}}]},ge=C.forwardRef(function(i,e){return C.createElement($,Object.assign({},i,{id:"xlsx",ref:e,icon:an}))});ge.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(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===a.RANGE_TYPE.COLUMN||a.RANGE_TYPE.ROW)return i;const o=[];return t.forEach(s=>{a.Rectangle.intersects(i,s)&&o.push(s)}),a.Rectangle.realUnion(i,...o)}l.SheetsHyperLinkResolverService=class{constructor(e,t,n,r,o){this._univerInstanceService=e,this._commandService=t,this._definedNamesService=n,this._messageService=r,this._localeService=o}_getURLName(e){var d;const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return null;const s=t?o.getSheetBySheetId(t):o.getActiveSheet(),c=(d=s==null?void 0:s.getName())!=null?d:"";if(n){const h=D.deserializeRangeWithSheet(n).range;return a.isValidRange(h)&&n!==v.ERROR_RANGE?{type:"range",name:D.serializeRangeWithSheet(c,h)}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(r){const h=this._definedNamesService.getValueById(o.getUnitId(),r);return h?{type:"defineName",name:h.formulaOrRefString}:{type:"range-error",name:this._localeService.t("hyperLink.message.refError")}}if(t){const h=o.getSheetBySheetId(t);return h?{type:"sheet",name:h.getName()}:{type:"sheet-error",name:this._localeService.t("hyperLink.message.refError")}}return null}navigateTo(e){const{gid:t,range:n,rangeid:r}=e,o=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!o)return;const s=o.getUnitId();if(r&&this.navigateToDefineName(s,r),!!t){if(n){const c=D.deserializeRangeWithSheet(n);a.isValidRange(c.range)&&n!==v.ERROR_RANGE&&this.navigateToRange(s,t,c.range);return}this.navigateToSheetById(s,t)}}parseHyperLink(e){var t,n,r;if(e!=null&&e.startsWith("#")){const o=new URLSearchParams(e.slice(1)),s={gid:(t=o.get("gid"))!=null?t:"",range:(n=o.get("range"))!=null?n:"",rangeid:(r=o.get("rangeid"))!=null?r:""},c=this._getURLName(s);return{type:(c==null?void 0:c.type)||"link",name:(c==null?void 0:c.name)||e,url:e,searchObj:s,handler:()=>{this.navigateTo(s)}}}else return{type:"outer",name:e,url:e,handler:()=>{this.navigateToOtherWebsite(e)}}}async navigateToRange(e,t,n){const r=await this.navigateToSheetById(e,t);if(r){const o=un(n,r);await this._commandService.executeCommand(u.SetSelectionsOperation.id,{unitId:e,subUnitId:t,pluginName:u.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,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if((r==null?void 0:r.getName())===t)return!0;const o=n.getSheetBySheetName(t);if(!o){this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:k.MessageType.Error});return}const s=o.getSheetId();return n.getHiddenWorksheets().indexOf(s)>-1&&this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:k.MessageType.Error}),await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:s})}async navigateToSheetById(e,t){const n=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();if(!r)return!1;if(r.getSheetId()===t)return r;const o=n.getSheetBySheetId(t);return o?n.getHiddenWorksheets().indexOf(t)>-1?(this._messageService.show({content:this._localeService.t("hyperLink.message.hiddenSheet"),type:k.MessageType.Error}),!1):await this._commandService.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})?o:!1:(this._messageService.show({content:this._localeService.t("hyperLink.message.noSheet"),type:k.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,a.IUniverInstanceService),X(1,a.ICommandService),X(2,D.IDefinedNamesService),X(3,O.IMessageService),X(4,f.Inject(a.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 mn(i){return/^[a-zA-Z]+:\/\//.test(i)}function vn(i){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(i)}function Se(i){if(J(i)){const e=mn(i)?i:vn(i)?`mailto://${i}`:`http://${i}`,t=new URL(e);return t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol&&t.pathname===location.pathname&&t.hash&&!t.search?t.hash:e}return i}function 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)===a.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"},se=()=>{var te;const[i,e]=C.useState(""),[t,n]=C.useState(""),[r,o]=C.useState("link"),[s,c]=C.useState(""),d=T.useDependency(a.LocaleService),h=T.useDependency(D.IDefinedNamesService),g=T.useDependency(a.IUniverInstanceService),_=T.useDependency(l.SheetsHyperLinkPopupService),p=O.useObservable(_.currentEditing$),R=T.useDependency(v.HyperLinkModel),L=T.useDependency(l.SheetsHyperLinkResolverService),I=T.useDependency(a.ICommandService),[P,N]=C.useState(!1),w=C.useRef(!1);C.useEffect(()=>{var S,b,M;if((p==null?void 0:p.row)!==void 0&&p.column!==void 0){const E=R.getHyperLinkByLocationSync(p.unitId,p.subUnitId,p.row,p.column);if(E){const pe=L.parseHyperLink(E.payload);if(e(E.id),n(E.display),pe.type==="outer"){o("link"),c(pe.url),pe.url===E.display&&(w.current=!0);return}else{const W=pe.searchObj;if(W.rangeid){o("rangeid"),c(W.rangeid);return}if(W.range){const Jn=W.gid&&(M=(b=(S=g.getUnit(p.unitId))==null?void 0:S.getSheetBySheetId(W.gid))==null?void 0:b.getName())!=null?M:"";if(o("range"),W.range===v.ERROR_RANGE)c("");else{const De=D.serializeRangeWithSheet(Jn,D.deserializeRangeWithSheet(W.range).range);c(De),De===E.display&&(w.current=!0)}return}if(W.gid){o("gid"),c(W.gid);return}}}const j=g.getUnit(p.unitId),A=j==null?void 0:j.getSheetBySheetId(p.subUnitId),Xn=A==null?void 0:A.getCellRaw(p.row,p.column),ke=gn(Xn);o("link"),c(""),n((ke!=null?ke:"").toString()),e("");return}o("link"),c(""),n(""),e("")},[p,R,L,g]);const x=C.useMemo(()=>s,[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"}],H=g.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!H)return;const G=H.getHiddenWorksheets(),B=H.getSheets().map(S=>({label:S.getName(),value:S.getSheetId()})).filter(S=>G.indexOf(S.value)===-1),F=Object.values((te=h.getDefinedNameMap(H.getUnitId()))!=null?te:{}).map(S=>({label:S.name,value:S.id})),ne=(S,b)=>{if(S==="link")return Se(b);if(S==="range"){const M=D.deserializeRangeWithSheet(b),E=H.getSheetBySheetName(M.sheetName);if(E)return`#gid=${E.getSheetId()}&range=${D.serializeRange(M.range)}`}return`#${S}=${b}`},Le=O.useEvent(S=>{var E;const b=S[0];if(!b||!a.isValidRange(b.range))return;b.sheetName||(b.sheetName=((E=H.getActiveSheet())==null?void 0:E.getName())||"");const M=D.serializeRangeToRefString(b);c(M),M&&(w.current||!t)&&(n(M),w.current=!0)}),Ie=async()=>{if(p&&(i?await I.executeCommand(v.UpdateHyperLinkCommand.id,{unitId:p.unitId,subUnitId:p.subUnitId,id:i,payload:{display:t,payload:ne(r,s)}}):await I.executeCommand(v.AddHyperLinkCommand.id,{unitId:p.unitId,subUnitId:p.subUnitId,link:{id:a.Tools.generateRandomId(),row:p.row,column:p.column,payload:ne(r,s),display:t}})),p){await I.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:p.unitId,subUnitId:p.subUnitId});const S=5;await I.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(p.row-S,0),endRow:p.row+S,startColumn:Math.max(p.column-S,0),endColumn:p.column+S}})}I.executeCommand(Q.id)};return m.jsxs("div",{children:[m.jsx(k.FormLayout,{label:d.t("hyperLink.form.label"),error:P&&!t?d.t("hyperLink.form.inputError"):"",children:m.jsx(k.Input,{value:t,onChange:S=>{n(S),w.current=!1},placeholder:d.t("hyperLink.form.labelPlaceholder")})}),m.jsx(k.FormLayout,{label:d.t("hyperLink.form.type"),children:m.jsx(k.Select,{options:K,value:r,onChange:S=>{o(S),c("")}})}),r==="link"&&m.jsx(k.FormLayout,{error:P?s?J(s)?"":d.t("hyperLink.form.linkError"):d.t("hyperLink.form.inputError"):"",children:m.jsx(k.Input,{value:s,onChange:S=>{c(S),S&&(w.current||!t||t===s)&&(n(S),w.current=!0)},placeholder:d.t("hyperLink.form.linkPlaceholder")})}),r==="range"&&m.jsx(k.FormLayout,{error:P&&!s?d.t("hyperLink.form.inputError"):"",children:m.jsx(O.RangeSelector,{openForSheetUnitId:H.getUnitId(),id:a.createInternalEditorID("hyper-link-edit"),isSingleChoice:!0,value:x,onChange:Le})}),r==="gid"&&m.jsx(k.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(k.Select,{options:B,value:s,onChange:S=>{var E,j;c(S);const b=(E=B.find(A=>A.value===S))==null?void 0:E.label,M=(j=B.find(A=>A.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),r==="rangeid"&&m.jsx(k.FormLayout,{error:P&&!s?d.t("hyperLink.form.selectError"):"",children:m.jsx(k.Select,{options:F,value:s,onChange:S=>{var E,j;c(S);const b=(E=F.find(A=>A.value===S))==null?void 0:E.label,M=(j=F.find(A=>A.value===s))==null?void 0:j.label;b&&(w.current||!t||t===M)&&(n(b),w.current=!0)}})}),m.jsxs("div",{className:Sn.cellLinkEditButtons,children:[m.jsx(k.Button,{onClick:()=>{p&&I.executeCommand(u.SetWorksheetActiveOperation.id,{unitId:p.unitId,subUnitId:p.subUnitId}),I.executeCommand(Q.id)},children:d.t("hyperLink.form.cancel")}),m.jsx(k.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{if(!t||!s||r==="link"&&!J(s)){N(!0);return}Ie()},children:d.t("hyperLink.form.ok")})]})]})};se.componentKey="univer.sheet.cell-link-edit";const ae={type:a.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-sidebar",handler(i,e){if(!e)return!1;const{unitId:t,subUnitId:n,row:r,column:o}=e,s=i.get(v.HyperLinkModel),c=i.get(O.ISidebarService),d=i.get(l.SheetsHyperLinkPopupService),h=s.getHyperLinkByLocation(t,n,r,o);return d.startEditing(e),c.open({header:{title:h?"hyperLink.form.editTitle":"hyperLink.form.addTitle"},children:{label:se.componentKey}}),!0}},Q={type:a.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-sidebar",handler(i){const e=i.get(O.ISidebarService),t=i.get(l.SheetsHyperLinkPopupService);return e.close(),t.endEditing(),!0}},le={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(i){const e=i.get(a.IUniverInstanceService),t=u.getSheetCommandTarget(e);if(!t)return!1;const n=i.get(a.ICommandService),o=i.get(u.SelectionManagerService).getFirst();if(!(o!=null&&o.primary))return!1;const s=o.primary.startRow,c=o.primary.startColumn;return n.executeCommand(ae.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:s,column:c})}},fe={type:a.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(i){const e=i.get(a.ICommandService);return i.get(l.SheetsHyperLinkPopupService).currentEditing?e.executeCommand(Q.id):e.executeCommand(le.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:m.jsx(oe,{}),link:m.jsx(oe,{}),sheet:m.jsx(ge,{}),range:m.jsx(ie,{}),defineName:m.jsx(ie,{}),"range-error":m.jsx(ie,{}),"sheet-error":m.jsx(ge,{})},ce=()=>{const i=T.useDependency(l.SheetsHyperLinkPopupService),e=T.useDependency(v.HyperLinkModel),t=T.useDependency(a.ICommandService),n=T.useDependency(O.IMessageService),r=T.useDependency(a.LocaleService),o=O.useObservable(i.currentPopup$,i.currentPopup),s=T.useDependency(l.SheetsHyperLinkResolverService);if(!o)return null;const{unitId:c,subUnitId:d,id:h}=o,g=e.getHyperLink(c,d,h);if(!g)return null;const _=s.parseHyperLink(g.payload),p=_.type.indexOf("error")>-1;return m.jsxs("div",{className:V.cellLink,onClick:()=>i.hideCurrentPopup(),children:[m.jsxs("div",{className:Re(V.cellLinkContent,{[V.cellLinkContentError]:p}),onClick:_.handler,children:[m.jsx("div",{className:V.cellLinkType,children:fn[_.type]}),m.jsx(k.Tooltip,{showIfEllipsis:!0,title:_.name,children:m.jsx("span",{className:V.cellLinkUrl,children:_.name})})]}),m.jsxs("div",{className:V.cellLinkOperations,children:[o.copyPermission&&m.jsx("div",{className:Re(V.cellLinkOperation,{[V.cellLinkOperationError]:p}),onClick:()=>{if(!p){if(_.type!=="outer"){const R=new URL(window.location.href);R.hash=_.url.slice(1),navigator.clipboard.writeText(R.href)}else navigator.clipboard.writeText(_.url);n.show({content:r.t("hyperLink.message.coped"),type:k.MessageType.Info})}},children:m.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(we,{})})}),o.editPermission&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(ae.id,{unitId:c,subUnitId:d,row:g.row,column:g.column})},children:m.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(He,{})})}),m.jsx("div",{className:V.cellLinkOperation,onClick:()=>{t.executeCommand(v.CancelHyperLinkCommand.id,{unitId:c,subUnitId:d,id:g.id})},children:m.jsx(k.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(Me,{})})})]})]})]})};ce.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(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 a.Disposable{constructor(t,n){super();Y(this,"_currentPopup",null);Y(this,"_currentPopup$",new me.Subject);Y(this,"currentPopup$",this._currentPopup$.asObservable());Y(this,"_currentEditing$",new me.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:s}=t,c=this._hyperLinkModel.getHyperLinkByLocation(n,r,o,s);if(!c)return;const d=this._sheetCanvasPopManagerService.attachPopupToCell(o,s,{componentKey:ce.componentKey,direction:"bottom",closeOnSelfTarget:!0,onClickOutside:()=>{this.hideCurrentPopup()}});d&&(this._currentPopup={unitId:n,subUnitId:r,id:c.id,disposable:d,row:o,col:s,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(){var t;this._currentPopup&&((t=this._currentPopup.disposable)==null||t.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}startEditing(t){this._currentEditing$.next(t)}endEditing(){this._currentEditing$.next(null)}},l.SheetsHyperLinkPopupService=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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&In(e,t,r),r},q=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkSetRangeController=class extends a.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=>{var t;if(e.id===v.AddHyperLinkCommand.id){const n=e.params,{unitId:r,subUnitId:o,link:s}=n,c=this._getCurrentCell(r,o,s.row,s.column),d={unitId:r,subUnitId:o,cellValue:{[s.row]:{[s.column]:{v:s.display,p:null,t:(t=c==null?void 0:c.t)!=null?t:void 0}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:d}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}return{redos:[],undos:[]}}}))}_initUpdateHyperLinkCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===v.UpdateHyperLinkCommand.id){const t=e.params,{unitId:n,subUnitId:r,id:o,payload:s}=t,c=this._hyperLinkModel.getHyperLink(n,r,o);if(c&&c.display!==s.display){const d={unitId:n,subUnitId:r,cellValue:{[c.row]:{[c.column]:{v:s.display,t:a.CellValueType.STRING,p:null}}}};return{redos:[{id:u.SetRangeValuesMutation.id,params:d}],undos:[{id:u.SetRangeValuesMutation.id,params:u.SetRangeValuesUndoMutationFactory(this._injector,d)}]}}}return{redos:[],undos:[]}}}))}_initSetRangeValuesCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.SetRangeValuesCommand.id){const t=e.params,{unitId:n,subUnitId:r}=t,o=[],s=[];return t.cellValue&&new a.ObjectMatrix(t.cellValue).forValue((c,d,h)=>{var R,L,I;const g=(I=h==null?void 0:h.v)!=null?I:(L=(R=h==null?void 0:h.p)==null?void 0:R.body)==null?void 0:L.dataStream.slice(0,-2),_=(g!=null?g:"").toString(),p=this._hyperLinkModel.getHyperLinkByLocation(n,r,c,d);if(!p){if(J(_)){const P=a.Tools.generateRandomId();s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:P}}),o.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:{id:P,row:c,column:d,display:_,payload:Se(_)}}})}return}g===""&&(o.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n,subUnitId:r,id:p.id}}),s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n,subUnitId:r,link:p}}))}),{undos:s,redos:o}}return{redos:[],undos:[]}}}))}_initClearSelectionCommandInterceptor(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{if(e.id===u.ClearSelectionContentCommand.id||e.id===u.ClearSelectionAllCommand.id||e.id===u.ClearSelectionFormatCommand.id){const t=[],n=[],r=this._selectionManagerService.getFirst(),o=u.getSheetCommandTarget(this._univerInstanceService);if(r&&o){const{unitId:s,subUnitId:c}=o;a.Range.foreach(r.range,(d,h)=>{const g=this._hyperLinkModel.getHyperLinkByLocation(s,c,d,h);g&&(t.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:g.id}}),n.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:g}}))})}return{redos:t,undos:n}}return{redos:[],undos:[]}}}))}_getCurrentCell(e,t,n,r){var o,s;return(s=(o=this._univerInstanceService.getUnit(e,a.UniverInstanceType.UNIVER_SHEET))==null?void 0:o.getSheetBySheetId(t))==null?void 0:s.getCell(n,r)}},l.SheetHyperLinkSetRangeController=Rn([a.OnLifecycle(a.LifecycleStages.Starting,l.SheetHyperLinkSetRangeController),q(0,f.Inject(u.SheetInterceptorService)),q(1,f.Inject(f.Injector)),q(2,f.Inject(v.HyperLinkModel)),q(3,f.Inject(u.SelectionManagerService)),q(4,a.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Pn(e,t,r),r},ee=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkPopupController=class extends a.Disposable{constructor(e,t,n,r,o){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=t,this._renderManagerService=n,this._permissionService=r,this._sheetPermissionInterceptorBaseController=o,this._initHoverListener()}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(me.debounceTime(100)).subscribe(e=>{var p,R;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const t=(R=(p=this._renderManagerService.getRenderById(e.location.unitId))==null?void 0:p.with(y.SheetSkeletonManagerService).getUnitSkeleton(e.location.unitId,e.location.subUnitId))==null?void 0:R.skeleton,n=e.location.col,r=e.location.row;let o=r,s=n;if(t&&t.overflowCache.forValue((L,I,P)=>{a.Rectangle.contains(P,{startColumn:n,endColumn:n,startRow:r,endRow:r})&&(o=L,s=I)}),!this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookViewPermission],worksheetTypes:[u.WorksheetViewPermission],rangeTypes:[u.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}])){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const d=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:n,endRow:r,endColumn:n}]),h=e.location.unitId,g=e.location.subUnitId,_=this._permissionService.composePermission([new u.WorkbookCopyPermission(h).id,new u.WorksheetCopyPermission(h,g).id]).every(L=>L.value);this._sheetsHyperLinkPopupService.showPopup({...e.location,row:o,col:s,editPermission:d,copyPermission:_})}))}},l.SheetsHyperLinkPopupController=En([a.OnLifecycle(a.LifecycleStages.Rendered,l.SheetsHyperLinkPopupController),ee(0,f.Inject(y.HoverManagerService)),ee(1,f.Inject(l.SheetsHyperLinkPopupService)),ee(2,f.Inject(he.IRenderManagerService)),ee(3,f.Inject(a.IPermissionService)),ee(4,f.Inject(y.SheetPermissionInterceptorBaseController))],l.SheetsHyperLinkPopupController);const On=i=>({id:le.id,type:O.MenuItemType.BUTTON,positions:[O.MenuPosition.CONTEXT_MENU],title:"hyperLink.menu.add",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),icon:"LinkSingle",disabled$:y.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),wn=i=>({tooltip:"hyperLink.form.addTitle",positions:O.MenuPosition.TOOLBAR_START,group:O.MenuGroup.TOOLBAR_OTHERS,id:fe.id,type:O.MenuItemType.BUTTON,icon:"LinkSingle",hidden$:O.getMenuHiddenObservable(i,a.UniverInstanceType.UNIVER_SHEET),disabled$:y.getCurrentRangeDisable$(i,{workbookTypes:[u.WorkbookEditablePermission],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission],rangeTypes:[u.RangeProtectionPermissionEditPoint]})}),ye={id:fe.id,binding:O.KeyCode.K|O.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Mn=Object.defineProperty,Hn=Object.getOwnPropertyDescriptor,jn=(i,e,t,n)=>{for(var r=n>1?void 0:n?Hn(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Mn(e,t,r),r},Z=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkUIController=class extends a.Disposable{constructor(e,t,n,r,o,s,c){super(),this._config=e,this._componentManager=t,this._commandService=n,this._localeService=r,this._menuService=o,this._injector=s,this._shortcutService=c,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ce,ce.componentKey],[se,se.componentKey],[oe,"LinkSingle"]].forEach(([e,t])=>{this._componentManager.register(t,e)})}_initCommands(){[ae,Q,le,fe].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(wn(this._injector),(r=(n=this._config)==null?void 0:n.menu)!=null?r:{})}_initShortCut(){this._shortcutService.registerShortcut(ye)}},l.SheetsHyperLinkUIController=jn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkUIController),Z(1,f.Inject(O.ComponentManager)),Z(2,a.ICommandService),Z(3,f.Inject(a.LocaleService)),Z(4,O.IMenuService),Z(5,f.Inject(f.Injector)),Z(6,f.Inject(O.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&Tn(e,t,r),r},Te=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkAutoFillController=class extends a.Disposable{constructor(e,t){super(),this._autoFillService=e,this._hyperLinkModel=t,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,o)=>{const{source:s,target:c,unitId:d,subUnitId:h}=r,g=y.virtualizeDiscreteRanges([s,c]),[_,p]=g.ranges,{mapFunc:R}=g,L={row:_.startRow,col:_.startColumn},I=y.getAutoFillRepeatRange(_,p),P=[],N=[];return I.forEach(w=>{const x=w.repeatStartCell,K=w.relativeRange,H={startRow:L.row,startColumn:L.col,endColumn:L.col,endRow:L.row},G={startRow:x.row,startColumn:x.col,endColumn:x.col,endRow:x.row};a.Range.foreach(K,(B,F)=>{const ne=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},H),{row:Le,col:Ie}=R(ne.startRow,ne.startColumn),te=this._hyperLinkModel.getHyperLinkByLocation(d,h,Le,Ie);if(te){const S=a.Rectangle.getPositionRange({startRow:B,startColumn:F,endColumn:F,endRow:B},G),{row:b,col:M}=R(S.startRow,S.startColumn),E=a.Tools.generateRandomId(),j=this._hyperLinkModel.getHyperLinkByLocation(d,h,b,M);j&&P.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:j.id}}),(y.APPLY_TYPE.COPY===o||y.APPLY_TYPE.SERIES===o)&&(P.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:{...te,id:E,row:b,column:M}}}),N.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:d,subUnitId:h,id:E}})),j&&N.push({id:v.AddHyperLinkMutation.id,params:{unitId:d,subUnitId:h,link:j}})}})}),{undos:N,redos:P}},n={id:_e,onFillData:(r,o,s)=>s===y.APPLY_TYPE.COPY||s===y.APPLY_TYPE.ONLY_FORMAT||s===y.APPLY_TYPE.SERIES?t(r,s):e()};this.disposeWithMe(this._autoFillService.addHook(n))}},l.SheetsHyperLinkAutoFillController=Nn([a.OnLifecycle(a.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&An(e,t,r),r},de=(i,e)=>(t,n)=>e(t,n,i);l.SheetsHyperLinkCopyPasteController=class extends a.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:s=y.COPY_TYPE.COPY,pasteType:c}=o,{range:d}=t||{},{range:h,unitId:g,subUnitId:_}=n;return this._generateMutations(h,{copyType:s,pasteType:c,copyRange:d,unitId:g,subUnitId:_})},onPastePlainText:(t,n)=>{if(J(n)){const r=Se(n),{range:o,unitId:s,subUnitId:c}=t,{ranges:[d],mapFunc:h}=y.virtualizeDiscreteRanges([o]),g=[],_=[];return a.Range.foreach(d,(p,R)=>{const{row:L,col:I}=h(p,R),P=this._hyperLinkModel.getHyperLinkByLocation(s,c,L,I);P&&g.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:P.id}});const N=a.Tools.generateRandomId();g.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:{id:N,row:L,column:I,payload:r}}}),_.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:s,subUnitId:c,id:N}}),P&&_.push({id:v.AddHyperLinkMutation.id,params:{unitId:s,subUnitId:c,link:P}})}),{redos:g,undos:_}}return{undos:[],redos:[]}}})}_collect(t,n,r){const o=new a.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:o};const s={get:this._injector.get.bind(this._injector)},c=y.rangeToDiscreteRange(r,s,t,n);if(!c)return;const{rows:d,cols:h}=c;d.forEach((g,_)=>{h.forEach((p,R)=>{var I;const L=this._hyperLinkModel.getHyperLinkByLocation(t,n,g,p);o.setValue(_,R,(I=L==null?void 0:L.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,s=[],c=[],{ranges:[d,h],mapFunc:g}=y.virtualizeDiscreteRanges([n.copyRange,t]);return y.getRepeatRange(d,h,!0).forEach(({startRange:p})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((L,I,P)=>{const N=a.Rectangle.getPositionRange({startRow:L,endRow:L,startColumn:I,endColumn:I},p),w=this._hyperLinkModel.getHyperLink(r,o,P),{row:x,col:K}=g(N.startRow,N.startColumn),H=this._hyperLinkModel.getHyperLinkByLocation(n.unitId,n.subUnitId,x,K),G=a.Tools.generateRandomId();H&&s.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:H.id}}),w&&(s.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:{...w,id:G,row:x,column:K}}}),c.push({id:v.RemoveHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,id:G}})),H&&c.push({id:v.AddHyperLinkMutation.id,params:{unitId:n.unitId,subUnitId:n.subUnitId,link:H}})})}),{redos:s,undos:c}}},l.SheetsHyperLinkCopyPasteController=Vn([a.OnLifecycle(a.LifecycleStages.Ready,l.SheetsHyperLinkCopyPasteController),de(0,y.ISheetClipboardService),de(1,f.Inject(v.HyperLinkModel)),de(2,f.Inject(f.Injector)),de(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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&xn(e,t,r),r},Fn=(i,e)=>(t,n)=>e(t,n,i);l.SheetHyperLinkUrlController=class extends a.Disposable{constructor(e){super(),this._resolverService=e,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;e&&this._resolverService.parseHyperLink(e).handler()}},l.SheetHyperLinkUrlController=Bn([a.OnLifecycle(a.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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(r))||r);return n&&r&&$n(e,t,r),r},Ce=(i,e)=>(t,n)=>e(t,n,i);let ue=class extends a.Disposable{constructor(i,e,t){super(),this._localeService=i,this._commandService=e,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{i.id===ye.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[u.WorkbookEditablePermission],rangeTypes:[u.RangeProtectionPermissionEditPoint],worksheetTypes:[u.WorksheetEditPermission,u.WorksheetSetCellValuePermission,u.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};ue=zn([a.OnLifecycle(a.LifecycleStages.Rendered,ue),Ce(0,f.Inject(a.LocaleService)),Ce(1,a.ICommandService),Ce(2,f.Inject(y.SheetPermissionInterceptorBaseController))],ue);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,s;o>=0;o--)(s=i[o])&&(r=(n?s(e,t,r):s(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);l.UniverSheetsHyperLinkUIPlugin=class extends a.Plugin{constructor(e,t,n){super(),this._config=e,this._injector=t,this._renderManagerService=n}onStarting(e){[[l.SheetsHyperLinkResolverService],[l.SheetsHyperLinkPopupService],[l.SheetsHyperLinkRemoveSheetController],[l.SheetsHyperLinkRenderManagerController],[l.SheetHyperLinkSetRangeController],[l.SheetsHyperLinkPopupController],[l.SheetsHyperLinkUIController,{useFactory:()=>this._injector.createInstance(l.SheetsHyperLinkUIController,this._config)}],[l.SheetsHyperLinkAutoFillController],[l.SheetsHyperLinkCopyPasteController],[ue],[l.SheetHyperLinkUrlController]].forEach(n=>e.add(n)),this._renderManagerService.registerRenderController(a.UniverInstanceType.UNIVER_SHEET,l.SheetsHyperLinkRenderController)}},Ae(l.UniverSheetsHyperLinkUIPlugin,"pluginName",_e),Ae(l.UniverSheetsHyperLinkUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET),l.UniverSheetsHyperLinkUIPlugin=Gn([a.DependentOn(v.UniverSheetsHyperLinkPlugin),Ne(1,f.Inject(f.Injector)),Ne(2,he.IRenderManagerService)],l.UniverSheetsHyperLinkUIPlugin),l.CloseHyperLinkSidebarOperation=Q,l.InsertHyperLinkOperation=le,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.14",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -50,39 +50,39 @@
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/core": "0.1.14",
58
- "@univerjs/design": "0.1.14",
59
- "@univerjs/engine-formula": "0.1.14",
60
- "@univerjs/engine-render": "0.1.14",
61
- "@univerjs/sheets-formula": "0.1.14",
62
- "@univerjs/sheets": "0.1.14",
63
- "@univerjs/sheets-hyper-link": "0.1.14",
64
- "@univerjs/sheets-ui": "0.1.14",
65
- "@univerjs/ui": "0.1.14"
57
+ "@univerjs/engine-formula": "0.1.16",
58
+ "@univerjs/core": "0.1.16",
59
+ "@univerjs/sheets": "0.1.16",
60
+ "@univerjs/engine-render": "0.1.16",
61
+ "@univerjs/sheets-formula": "0.1.16",
62
+ "@univerjs/sheets-hyper-link": "0.1.16",
63
+ "@univerjs/sheets-ui": "0.1.16",
64
+ "@univerjs/ui": "0.1.16",
65
+ "@univerjs/design": "0.1.16"
66
66
  },
67
67
  "dependencies": {
68
- "@univerjs/icons": "^0.1.56",
69
- "@univerjs/sheets-hyper-link": "0.1.14"
68
+ "@univerjs/icons": "^0.1.57",
69
+ "@univerjs/sheets-hyper-link": "0.1.16"
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.3.1",
77
77
  "vitest": "^1.6.0",
78
- "@univerjs/engine-formula": "0.1.14",
79
- "@univerjs/core": "0.1.14",
80
- "@univerjs/sheets": "0.1.14",
81
- "@univerjs/engine-render": "0.1.14",
82
- "@univerjs/sheets-formula": "0.1.14",
83
- "@univerjs/ui": "0.1.14",
84
- "@univerjs/shared": "0.1.14",
85
- "@univerjs/sheets-ui": "0.1.14"
78
+ "@univerjs/core": "0.1.16",
79
+ "@univerjs/engine-formula": "0.1.16",
80
+ "@univerjs/engine-render": "0.1.16",
81
+ "@univerjs/sheets-formula": "0.1.16",
82
+ "@univerjs/shared": "0.1.16",
83
+ "@univerjs/sheets": "0.1.16",
84
+ "@univerjs/sheets-ui": "0.1.16",
85
+ "@univerjs/ui": "0.1.16"
86
86
  },
87
87
  "univerSpace": {
88
88
  ".": {
@@ -103,6 +103,7 @@
103
103
  "test:watch": "vitest",
104
104
  "coverage": "vitest run --coverage",
105
105
  "lint:types": "tsc --noEmit",
106
- "build": "tsc && vite build"
106
+ "build": "tsc && vite build",
107
+ "sync:cnpm": "cnpm sync"
107
108
  }
108
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
- }